Skip to content

Commit

Permalink
add search page
Browse files Browse the repository at this point in the history
  • Loading branch information
vczero committed Dec 12, 2014
1 parent 292a65e commit 557582d
Show file tree
Hide file tree
Showing 11 changed files with 142 additions and 43 deletions.
3 changes: 2 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ module.exports = function(grunt){
'./lib/main.js',
'./lib/directive/**/*.js',
'./lib/service/**/*.js',
'./lib/list/**/*.js'
'./lib/list/**/*.js',
'./lib/search/**/*.js'
],
dest:'./build/main.js'
}
Expand Down
57 changes: 47 additions & 10 deletions build/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,24 @@ app.config(['$stateProvider', '$urlRouterProvider',function($stateProvider, $url
controller: ''
}
}
})

.state('search',{
url: '/search/:type',
views:{
header:{
templateUrl: '../html/views/search.html',
controller: 'Search'
},
container:{
templateUrl: '',
controller: ''
},
footer:{
templateUrl: '',
controller: ''
}
}
});
}]);
;
Expand Down Expand Up @@ -263,32 +281,51 @@ app.controller('musicListController', ['$rootScope', 'musicList',function($rootS
}
musicList.getData($rootScope.keywordsObj.music);
}]);
;/*搜索*/
var SearchController = function($scope, $rootScope, $location, bookList, musicList, movieList){
;/*负责搜索结果的导向*/
var Search = function($scope, $rootScope, $location, bookList, musicList, movieList){
var path = $location.path();
$rootScope.isNoLoaded = false;
//跳回列表页
$scope.search = function(){
var keywords = $scope.keywords;
if(path.indexOf('/book') !== -1 || path === '/'){
if(path.indexOf('/book') !== -1){
if(keywords){
$rootScope.keywordsObj.book = keywords;
}
bookList.getData($rootScope.keywordsObj.book);
$location.path('/book');

}else if(path.indexOf('/music') !== -1 || path === '/music'){
}else if(path.indexOf('/music') !== -1){
if(keywords){
$rootScope.keywordsObj.music = keywords;
}
musicList.getData($rootScope.keywordsObj.music);
$location.path('/music');

}else if(path.indexOf('/movie') !== -1 || path === '/movie'){
}else if(path.indexOf('/movie') !== -1){
if(keywords){
$rootScope.keywordsObj.movie = keywords;
}
movieList.getData($rootScope.keywordsObj.movie);
$location.path('/movie');
}
};
};
Search.$inject = ['$scope', '$rootScope', '$location', 'bookList', 'musicList', 'movieList'];
app.controller('Search', Search);;/*仅负责搜索页面的打开*/
var SearchController = function($scope, $rootScope, $location){
var path = $location.path();
$scope.goToSearch = function(){
if(path.indexOf('/book') !== -1 || path === '/'){
$location.path('/search/book');

}else if(path.indexOf('/music') !== -1 || path === '/music'){
$location.path('/search/music');


}else if(path.indexOf('/movie') !== -1 || path === '/movie'){
$location.path('/search/movie');
}
};

};

SearchController.$inject = ['$scope', '$rootScope', '$location', 'bookList', 'musicList', 'movieList'];

SearchController.$inject = ['$scope', '$rootScope', '$location'];
app.controller('SearchController', SearchController);
2 changes: 1 addition & 1 deletion build/main.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ input{
-webkit-appearance:none;
outline:none;
border-radius:0;
-webkit-tap-highlight-color:rgba(255,255,255,0);
}

div{
-webkit-tap-highlight-color:rgba(255,255,255,0);
}


a{
color: #525252;
-webkit-tap-highlight-color:rgba(255,255,255,0);
}

header{
Expand Down Expand Up @@ -361,6 +367,12 @@ section .list_item:last-child{
color:#000;
}

@media (max-height:350px) {
footer {
display: none;
}
}




Expand Down
4 changes: 3 additions & 1 deletion html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
<title>i搜索 i生活</title>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<title>爱搜索 爱生活</title>
<link rel="stylesheet" type="text/css" href="../css/main.css">
</head>
<body>
Expand Down
4 changes: 2 additions & 2 deletions html/views/list_header.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

<header ng-controller="SearchController">
<div>
<input id="search_input" ng-model="keywords" type="text" placeholder="请输入关键字"/>
<input id="search_input" ng-model="keywords" type="text" placeholder="请输入关键字" ng-click="goToSearch()"/>
</div>
<div>
<input type="button" id="search_btn" ng-click="search()" value="搜索"/>
<input type="button" id="search_btn" value="搜索"/>
</div>
</header>
8 changes: 8 additions & 0 deletions html/views/search.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<header ng-controller="Search">
<div>
<input id="search_input" ng-model="keywords" type="text" placeholder="请输入关键字"/>
</div>
<div>
<input type="button" id="search_btn" ng-click="search()" value="搜索"/>
</div>
</header>
28 changes: 0 additions & 28 deletions lib/list/searchController.js

This file was deleted.

18 changes: 18 additions & 0 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,23 @@ app.config(['$stateProvider', '$urlRouterProvider',function($stateProvider, $url
controller: ''
}
}
})

.state('search',{
url: '/search/:type',
views:{
header:{
templateUrl: '../html/views/search.html',
controller: 'Search'
},
container:{
templateUrl: '',
controller: ''
},
footer:{
templateUrl: '',
controller: ''
}
}
});
}]);
29 changes: 29 additions & 0 deletions lib/search/Search.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*负责搜索结果的导向*/
var Search = function($scope, $rootScope, $location, bookList, musicList, movieList){
var path = $location.path();
$rootScope.isNoLoaded = false;
//跳回列表页
$scope.search = function(){
var keywords = $scope.keywords;
if(path.indexOf('/book') !== -1){
if(keywords){
$rootScope.keywordsObj.book = keywords;
}
$location.path('/book');

}else if(path.indexOf('/music') !== -1){
if(keywords){
$rootScope.keywordsObj.music = keywords;
}
$location.path('/music');

}else if(path.indexOf('/movie') !== -1){
if(keywords){
$rootScope.keywordsObj.movie = keywords;
}
$location.path('/movie');
}
};
};
Search.$inject = ['$scope', '$rootScope', '$location', 'bookList', 'musicList', 'movieList'];
app.controller('Search', Search);
20 changes: 20 additions & 0 deletions lib/search/searchController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*仅负责搜索页面的打开*/
var SearchController = function($scope, $rootScope, $location){
var path = $location.path();
$scope.goToSearch = function(){
if(path.indexOf('/book') !== -1 || path === '/'){
$location.path('/search/book');

}else if(path.indexOf('/music') !== -1 || path === '/music'){
$location.path('/search/music');


}else if(path.indexOf('/movie') !== -1 || path === '/movie'){
$location.path('/search/movie');
}
};

};

SearchController.$inject = ['$scope', '$rootScope', '$location'];
app.controller('SearchController', SearchController);

0 comments on commit 557582d

Please sign in to comment.