This commit is contained in:
wlh
2014-12-11 15:19:47 +08:00
parent 038266a3c5
commit 38cb1e5dfc
12 changed files with 0 additions and 442 deletions
-49
View File
@@ -1,49 +0,0 @@
<section ng-controller="BookDetailController">
<div>
<div id="book_detail_info">
<div class="fl book_detail_pic">
<img class="book_detail_pic" ng-src="{{data.image}}"/>
</div>
<div class="fl">
<div>
<span class="book_detail_title">书名:</span><span class="overflow book_detail_t_w">{{data.title}}</span>
</div>
<div>
<span class="book_detail_title">作者:</span><span class="overflow book_detail_t_w">{{data.author[0]}}</span>
</div>
<div>
<span class="book_detail_title">出版社:</span><span class="overflow book_detail_t_w">{{data.publisher}}</span>
</div>
<div>
<span class="book_detail_title">价格:</span><span class="overflow book_detail_t_w">{{data.price}}</span>
</div>
<div>
<span class="book_detail_title">页码:</span><span class="overflow book_detail_t_w">{{data.pages}}页</span>
</div>
</div>
</div>
<div>
<div class="book_detail_sum">
<div>
书籍简介
</div>
<span>
{{data.summary}}
</span>
</div>
<div class="book_detail_sum">
<div>作者简介</div>
<span>
{{data.author_intro}}
</span>
</div>
</div>
</div>
<div style="height:45px;"></div>
</section>
-35
View File
@@ -1,35 +0,0 @@
<section ng-controller="BookListController">
<div>
<div class="list_item" ng-repeat="data in rootList">
<a class="list_bookname_a" href="#/list/book/{{data.id}}">
<div class="list_img overflow fl">
<img class="list_img" ng-src="{{data.image}}"/>
</div>
<div class="list_content overflow fl">
<div class="list_bookname overflow">
{{data.origin_title}}
</div>
<div class="list_author overflow">
{{data.author}} {{data.publisher}}
</div>
<div class="list_bookprice">
<span class="list_price_num">
{{data.price}}
</span>
<span></span>
</div>
</div>
<div class="list_other overflow fr">
<span>
{{data.pages}}页
</span>
</div>
</a>
</div>
</div>
<div style="height:45px;"></div>
</section>
-9
View File
@@ -1,9 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
</body>
</html>
-6
View File
@@ -1,6 +0,0 @@
<footer>
<a >图书</a>
<a>音乐</a>
<a>电影</a>
</footer>
-8
View File
@@ -1,8 +0,0 @@
<header ng-controller="SearchController">
<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>
-33
View File
@@ -1,33 +0,0 @@
<section ng-controller="BookListController">
<div>
<div class="list_item" ng-repeat="data in list">
<a class="list_bookname_a" bookname = "{{data.origin_title}}" href="#/list/{{data.origin_title}}">
<div class="list_img overflow fl">
<img class="list_img" ng-src="{{data.image}}"/>
</div>
<div class="list_content overflow fl">
<div class="list_bookname overflow">
{{data.origin_title}}
</div>
<div class="list_author overflow">
{{data.author}} {{data.publisher}}
</div>
<div class="list_bookprice">
<span class="list_price_num">
{{data.price}}
</span>
<span></span>
</div>
</div>
<div class="list_other overflow fr">
<span>
{{data.pages}}页
</span>
</div>
</a>
</div>
</div>
<div style="height:45px;"></div>
</section>
-16
View File
@@ -1,16 +0,0 @@
/*图书列表页*/
app.controller('BookListController', function($scope, bookList){
bookList.getData('C语言');
});
/*图书详情页*/
app.controller('BookDetailController', function($rootScope, $http, $scope, $location, ServiceConfig){
var bookId = $location.path().split('/book/')[1] || '';
$rootScope.isNoLoaded = true;
$http.jsonp(ServiceConfig.book_search_id + '' + bookId + '?callback=showBookDeatil');
window.showBookDeatil = function(data){
$rootScope.isNoLoaded = false;
$scope.data = data;
};
});
-31
View File
@@ -1,31 +0,0 @@
/*构建BookList服务*/
app.factory('bookList', function($rootScope, $http, ServiceConfig){
$rootScope.isNoLoaded = true;
var _BookList = {
getData: function(keywords){
$http.jsonp(ServiceConfig.book_search + '?callback=searchBookList&count=10&q=' + keywords);
window.searchBookList = function(data){
if(data.books.length){
$rootScope.isNoLoaded = false;
}
var list = [];
for(var i = 0; i < data.books.length; i++){
var book = data.books[i];
var item = {
id: book.id,
image: book.image,
origin_title: book.title || '书名未共享',
author: book.author[0] || '作者未知',
publisher: book.publisher || '出版社未知',
price: book.price.split('.')[0] || '未知',
pages: book.pages
};
list.push(item);
}
$rootScope.rootList = list;
};
}
};
return _BookList;
});
-9
View File
@@ -1,9 +0,0 @@
(function(global){
var config = {
book_search: 'https://api.douban.com/v2/book/search',
book_search_id: 'https://api.douban.com/v2/book/'
};
global.CONFIG_SERVER = config;
})(window);
-220
View File
@@ -1,220 +0,0 @@
var app = angular.module('app', ['ngRoute']);
app.run(function($rootScope){
$rootScope.version = '0.1';
$rootScope.author = 'vczero';
$rootScope.author_alias = '鬼谣';
$rootScope.isNoLoaded = true;
$rootScope.rootList = []; //当然这是个不好的做法,只因为APP太simple
});
/*服务的URL配置*/
app.constant('ServiceConfig', {
book_search: 'https://api.douban.com/v2/book/search',
book_search_id: 'https://api.douban.com/v2/book/'
});
/*路由控制*/
app.config(['$routeProvider', function ($routeProvider) {
$routeProvider
/*图书搜索*/
.when('/list/book', {
templateUrl: 'view/book_list.html',
controller: 'BookListController'
})
.when('/list/book/:id', {
templateUrl: 'view/book_detail.html',
controller: 'BookDetailController'
})
/*音乐搜索*/
.when('/list/music', {
templateUrl: 'view/book_list.html',
controller: 'BookListController'
})
/*电影搜索*/
.when('/list/movie', {
templateUrl: 'view/book_list.html',
controller: 'BookListController'
})
/*定向到首页*/
.otherwise({
redirectTo: '/',
templateUrl: 'view/book_list.html',
controller: 'BookListController'
});
}]);
/*构建BookList服务*/
app.factory('bookList', function($rootScope, $http, ServiceConfig){
$rootScope.isNoLoaded = true;
var _BookList = {
getData: function(keywords){
$http.jsonp(ServiceConfig.book_search + '?callback=searchBookList&count=10&q=' + keywords);
window.searchBookList = function(data){
if(data.books.length){
$rootScope.isNoLoaded = false;
}
var list = [];
for(var i = 0; i < data.books.length; i++){
var book = data.books[i];
var item = {
id: book.id,
image: book.image,
origin_title: book.title || '书名未共享',
author: book.author[0] || '作者未知',
publisher: book.publisher || '出版社未知',
price: book.price.split('.')[0] || '未知',
pages: book.pages
};
list.push(item);
}
$rootScope.rootList = list;
};
}
};
return _BookList;
});
/*图书列表页*/
app.controller('BookListController', function($scope, bookList){
bookList.getData('C语言');
});
/*图书详情页*/
app.controller('BookDetailController', function($rootScope, $http, $scope, $location, ServiceConfig){
$rootScope.isNoLoaded = true;
var bookId = $location.path().split('/book/')[1] || '';
$http.jsonp(ServiceConfig.book_search_id + '' + bookId + '?callback=showBookDeatil');
window.showBookDeatil = function(data){
$rootScope.isNoLoaded = false;
$scope.data = data;
};
});
/*搜索*/
app.controller('SearchController', function($scope, $location, bookList){
var path = $location.path();
$scope.search = function(){
var keywords = $scope.keywords;
if(path.indexOf('/list/book') !== -1 || path === '/'){
bookList.getData(keywords);
}else if(path.indexOf('/list/music') !== -1 || path === '/music'){
}
};
});
app.controller('MenuController', function($scope, $location){
$scope.bookSearch = function(){
$location.path('/list/book');
};
$scope.musicSearch = function(){
$location.path('/list/music');
};
$scope.movieSearch = function(){
$location.path('/list/movie');
};
});
//
//app.directive('nprLink', function() {
//return {
// restrict: 'EA',
// require: ['^ngModel'],
// replace: true,
// scope: {
// ngModel: '=',
// play: '&'
// },
// templateUrl: '/views/nprListItem.html',
// link: function(scope, ele, attr) {
// scope.duration = scope.ngModel.audio[0].duration.$text;
// }
//}
//});
// simple directive
//app.directive('helloWorld',function(){
// return {
// restrict: 'AE',
// replace: true,
// template: '<h3>Hello World!</h3>'
// }
//});
//app.directive('helloWorld',function(){
// return {
// restrict: 'AE',
// replace: true,
// template: '<p style="background-color:{{color}}"></p>',
// link: function(scope,elem,attr){
// elem.bind('click',function(){
// elem.css('background-color','white');
// scope.$apply(function(){
// scope.color = "white";
// });
// });
// elem.bind('mouseover',function(){
// elem.css('cursor','pointer');
// });
// }
// }
//});
//注意到link函数被用在了指令中。它接收三个参数:
//
//scope - 它代表指令被使用的作用域。在上面的例子中它等同于符控制器的作用域。
//elem - 它代表绑定指令的元素的jQlite(jQuery的一个自己)包裹元素。如果你在AngularJS被包含之前就包括了jQuery
//那么它将变成jQuery包裹元素。由于该元素已经被jQuery/jQlite包裹,我们没有必要将它包含在$()中来进行DOM操作。
//attars - 它代表绑定指令的元素上的属性。例如,如果你在HTML元素上有一些指令形式为:<hello-world some-attribute>
//</hello-world>,你可以在link函数内用attrs.someAttribute来引用这些属性。
//
//app.directive('test',function(){
// return {
// compile: function(tElem,attrs){
// //在这里原则性的做一些DOM转换
// return function(scope,elem,attrs){
// //这里编写link函数
// }
// }
// }
//});
//改变作用域
//app.directive('helloWorld',function(){
// return {
// scope: true, //使用一个继承父作用域的自作用域 ,如果需要隔离的话,值为{}即可
// restrict: 'AE',
// replace: true,
// template: '<h3>Hello World!</h3>'
// }
//});
//var editor = elem.find('#editor');
//
//scope.restore(); //初始化我们的应用控制
//scope.notes = notesFactory.getAll();//载入笔记
//
//editor.bind('keyup keydown',function(){
// scope.noetText = editor.text().trim();
//});
-14
View File
@@ -1,14 +0,0 @@
app.controller('MenuController', function($scope, $location){
$scope.bookSearch = function(){
$location.path('/list/book');
};
$scope.musicSearch = function(){
$location.path('/list/music');
};
$scope.movieSearch = function(){
$location.path('/list/movie');
};
});
-12
View File
@@ -1,12 +0,0 @@
/*搜索*/
app.controller('SearchController', function($scope, $location, bookList){
var path = $location.path();
$scope.search = function(){
var keywords = $scope.keywords;
if(path.indexOf('/list/book') !== -1 || path === '/'){
bookList.getData(keywords);
}else if(path.indexOf('/list/music') !== -1 || path === '/music'){
}
};
});