This commit is contained in:
wlh
2014-12-11 00:12:26 +08:00
parent f65ff8a953
commit 8eec9390ef
24 changed files with 5686 additions and 47 deletions
+65
View File
@@ -237,9 +237,74 @@ section .list_item:last-child{
display: inline-block;
}
/*--------music list-----*/
.music_list_item{
margin-top:10px;
height:160px;
width: 100%;
min-width:300px;
border:1px solid #F0F0F0;
background-color:#FFF;
font-size:14px;
}
.music_list_circle{
width:80px;height:80px;
}
.music_list_circle_img{
border-radius:40px;
}
.mlra{
margin-left:auto;
margin-right: auto;
}
.music_list_mt8{
margin-top:8px;
}
.music_list_title{
color:#007722;
}
.music_list_left_part{
margin-left:5px;
}
.music_list_part{
width:150px;
}
.white_space{
white-space:nowrap;
}
.music_list_tw{
width:110px;
}
.music_list_part span{
margin-left: 2px;
float: left;
}
.music_list_text_h{
height:40px;
}
.music_list_qudou{
width:60px;height:24px;
border-radius:2px;
text-align:center;
line-height: 24px;
margin-top:3px;
background-color:#66BA9C;
color:#FFF;
}
.music_list_qudou a{
color: #FFF;
text-decoration:none;
}
/*-douban music-*/
.douban_music{
font-size:18px;margin-left:5px;color:#66BA9C;margin-top:5px;
}
+20 -19
View File
@@ -3,29 +3,30 @@
<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>测试Angular</title>
<title>测试框架</title>
<link rel="stylesheet" type="text/css" href="../css/main.css">
</head>
<body>
<ng-include id="header_div" src="'./view/header_search.html'"></ng-include>
<div ng-view></div>
<!--<div id="footer_div" ng-include="'./view/footer_search.html'"></div>-->
<footer ng-controller="MenuController">
<a ng-click="bookSearch()">图书</a>
<a ng-click="musicSearch()">音乐</a>
<a ng-click="movieSearch()">电影</a>
</footer>
<div id="loading" ng-show="isNoLoaded">
<img src="../imgs/loading.gif" />
</div>
<div ui-view="header"></div>
<div ui-view="container"></div>
<div ui-view="footer"></div>
<div loading></div>
<script type="text/javascript" src="../js/angular.js"></script>
<script type="text/javascript" src="../js/angular-route.js" ></script>
<script type="text/javascript" src="../js/angular-ui-router.js"></script>
<script type="text/javascript" src="../lib/main.js"></script>
<script type="text/javascript" src="../lib/bookService.js"></script>
<script type="text/javascript" src="../lib/BookController.js"></script>
<script type="text/javascript" src="../lib/searchController.js"></script>
<script type="text/javascript" src="../lib/menuController.js"></script>
<!--service-->
<script type="text/javascript" src="../lib/service/bookList.js"></script>
<script type="text/javascript" src="../lib/service/musicList.js"></script>
<script type="text/javascript" src="../lib/service/movieList.js"></script>
<!--directive-->
<script type="text/javascript" src="../lib/directive/loading.js"></script>
<!--header-->
<script type="text/javascript" src="../lib/list/searchController.js"></script>
<script type="text/javascript" src="../lib/list/menuController.js"></script>
<!--list-->
<script type="text/javascript" src="../lib/list/bookController.js"></script>
<script type="text/javascript" src="../lib/list/musicController.js"></script>
<script type="text/javascript" src="../lib/list/movieController.js"></script>
</body>
</html>
+9
View File
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
</body>
</html>
+49
View File
@@ -0,0 +1,49 @@
<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>
+9
View File
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
</body>
</html>
+32
View File
@@ -0,0 +1,32 @@
<section ng-controller="BookListController">
<div>
<div class="list_item" ng-repeat="data in bookList">
<a class="list_bookname_a" href="#/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>
+5
View File
@@ -0,0 +1,5 @@
<footer ng-controller="MenuController">
<a ng-click="bookSearch()">图书</a>
<a ng-click="musicSearch()">音乐</a>
<a ng-click="movieSearch()">电影</a>
</footer>
+9
View File
@@ -0,0 +1,9 @@
<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>
+5
View File
@@ -0,0 +1,5 @@
<section ng-controller="movieListController">
<div style="height:45px;"></div>
</section>
+36
View File
@@ -0,0 +1,36 @@
<section ng-controller="musicListController">
<div class="music_list_item" ng-repeat="data in musicList">
<div class="music_list_circle mlra music_list_mt8">
<img class="music_list_circle music_list_circle_img" ng-src="{{data.image}}"/>
</div>
<div>
<div class="fl music_list_part">
<span class="music_list_title music_list_left_part">曲目</span>
<span class="overflow music_list_tw white_space">{{data.title}}</span>
</div>
<div class="fr music_list_part">
<span class="music_list_title">演唱</span>
<span class="overflow music_list_tw white_space">{{data.author[0].name}}</span>
</div>
</div>
<div class="music_list_text_h">
<div class="fl music_list_part">
<span class="music_list_title music_list_left_part">时间</span>
<span class="overflow music_list_tw">{{data.attrs.pubdate[0]}}年</span>
</div>
<div class="fr music_list_part">
<span class="music_list_title">评分</span>
<span class="overflow music_list_tw white_space">{{data.rating.average}}</span>
</div>
</div>
<div class="music_list_qudou mlra"><a href="{{data.mobile_link}}">去豆瓣</a></div>
</div>
<div style="height:45px;"></div>
</section>
+3
View File
@@ -0,0 +1,3 @@
<header>
<div class="douban_music">豆瓣MUSIC</div>
</header>
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

+4232
View File
File diff suppressed because it is too large Load Diff
+944
View File
@@ -0,0 +1,944 @@
/*! iScroll v5.1.3 ~ (c) 2008-2014 Matteo Spinelli ~ http://cubiq.org/license */
(function (window, document, Math) {
var rAF = window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function (callback) { window.setTimeout(callback, 1000 / 60); };
var utils = (function () {
var me = {};
var _elementStyle = document.createElement('div').style;
var _vendor = (function () {
var vendors = ['t', 'webkitT', 'MozT', 'msT', 'OT'],
transform,
i = 0,
l = vendors.length;
for ( ; i < l; i++ ) {
transform = vendors[i] + 'ransform';
if ( transform in _elementStyle ) return vendors[i].substr(0, vendors[i].length-1);
}
return false;
})();
function _prefixStyle (style) {
if ( _vendor === false ) return false;
if ( _vendor === '' ) return style;
return _vendor + style.charAt(0).toUpperCase() + style.substr(1);
}
me.getTime = Date.now || function getTime () { return new Date().getTime(); };
me.extend = function (target, obj) {
for ( var i in obj ) {
target[i] = obj[i];
}
};
me.addEvent = function (el, type, fn, capture) {
el.addEventListener(type, fn, !!capture);
};
me.removeEvent = function (el, type, fn, capture) {
el.removeEventListener(type, fn, !!capture);
};
me.prefixPointerEvent = function (pointerEvent) {
return window.MSPointerEvent ?
'MSPointer' + pointerEvent.charAt(9).toUpperCase() + pointerEvent.substr(10):
pointerEvent;
};
me.momentum = function (current, start, time, lowerMargin, wrapperSize, deceleration) {
var distance = current - start,
speed = Math.abs(distance) / time,
destination,
duration;
deceleration = deceleration === undefined ? 0.0006 : deceleration;
destination = current + ( speed * speed ) / ( 2 * deceleration ) * ( distance < 0 ? -1 : 1 );
duration = speed / deceleration;
if ( destination < lowerMargin ) {
destination = wrapperSize ? lowerMargin - ( wrapperSize / 2.5 * ( speed / 8 ) ) : lowerMargin;
distance = Math.abs(destination - current);
duration = distance / speed;
} else if ( destination > 0 ) {
destination = wrapperSize ? wrapperSize / 2.5 * ( speed / 8 ) : 0;
distance = Math.abs(current) + destination;
duration = distance / speed;
}
return {
destination: Math.round(destination),
duration: duration
};
};
var _transform = _prefixStyle('transform');
me.extend(me, {
hasTransform: _transform !== false,
hasPerspective: _prefixStyle('perspective') in _elementStyle,
hasTouch: 'ontouchstart' in window,
hasPointer: window.PointerEvent || window.MSPointerEvent, // IE10 is prefixed
hasTransition: _prefixStyle('transition') in _elementStyle
});
// This should find all Android browsers lower than build 535.19 (both stock browser and webview)
me.isBadAndroid = /Android /.test(window.navigator.appVersion) && !(/Chrome\/\d/.test(window.navigator.appVersion));
me.extend(me.style = {}, {
transform: _transform,
transitionTimingFunction: _prefixStyle('transitionTimingFunction'),
transitionDuration: _prefixStyle('transitionDuration'),
transitionDelay: _prefixStyle('transitionDelay'),
transformOrigin: _prefixStyle('transformOrigin')
});
me.hasClass = function (e, c) {
var re = new RegExp("(^|\\s)" + c + "(\\s|$)");
return re.test(e.className);
};
me.addClass = function (e, c) {
if ( me.hasClass(e, c) ) {
return;
}
var newclass = e.className.split(' ');
newclass.push(c);
e.className = newclass.join(' ');
};
me.removeClass = function (e, c) {
if ( !me.hasClass(e, c) ) {
return;
}
var re = new RegExp("(^|\\s)" + c + "(\\s|$)", 'g');
e.className = e.className.replace(re, ' ');
};
me.offset = function (el) {
var left = -el.offsetLeft,
top = -el.offsetTop;
// jshint -W084
while (el = el.offsetParent) {
left -= el.offsetLeft;
top -= el.offsetTop;
}
// jshint +W084
return {
left: left,
top: top
};
};
me.preventDefaultException = function (el, exceptions) {
for ( var i in exceptions ) {
if ( exceptions[i].test(el[i]) ) {
return true;
}
}
return false;
};
me.extend(me.eventType = {}, {
touchstart: 1,
touchmove: 1,
touchend: 1,
mousedown: 2,
mousemove: 2,
mouseup: 2,
pointerdown: 3,
pointermove: 3,
pointerup: 3,
MSPointerDown: 3,
MSPointerMove: 3,
MSPointerUp: 3
});
me.extend(me.ease = {}, {
quadratic: {
style: 'cubic-bezier(0.25, 0.46, 0.45, 0.94)',
fn: function (k) {
return k * ( 2 - k );
}
},
circular: {
style: 'cubic-bezier(0.1, 0.57, 0.1, 1)', // Not properly "circular" but this looks better, it should be (0.075, 0.82, 0.165, 1)
fn: function (k) {
return Math.sqrt( 1 - ( --k * k ) );
}
},
back: {
style: 'cubic-bezier(0.175, 0.885, 0.32, 1.275)',
fn: function (k) {
var b = 4;
return ( k = k - 1 ) * k * ( ( b + 1 ) * k + b ) + 1;
}
},
bounce: {
style: '',
fn: function (k) {
if ( ( k /= 1 ) < ( 1 / 2.75 ) ) {
return 7.5625 * k * k;
} else if ( k < ( 2 / 2.75 ) ) {
return 7.5625 * ( k -= ( 1.5 / 2.75 ) ) * k + 0.75;
} else if ( k < ( 2.5 / 2.75 ) ) {
return 7.5625 * ( k -= ( 2.25 / 2.75 ) ) * k + 0.9375;
} else {
return 7.5625 * ( k -= ( 2.625 / 2.75 ) ) * k + 0.984375;
}
}
},
elastic: {
style: '',
fn: function (k) {
var f = 0.22,
e = 0.4;
if ( k === 0 ) { return 0; }
if ( k == 1 ) { return 1; }
return ( e * Math.pow( 2, - 10 * k ) * Math.sin( ( k - f / 4 ) * ( 2 * Math.PI ) / f ) + 1 );
}
}
});
me.tap = function (e, eventName) {
var ev = document.createEvent('Event');
ev.initEvent(eventName, true, true);
ev.pageX = e.pageX;
ev.pageY = e.pageY;
e.target.dispatchEvent(ev);
};
me.click = function (e) {
var target = e.target,
ev;
if ( !(/(SELECT|INPUT|TEXTAREA)/i).test(target.tagName) ) {
ev = document.createEvent('MouseEvents');
ev.initMouseEvent('click', true, true, e.view, 1,
target.screenX, target.screenY, target.clientX, target.clientY,
e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
0, null);
ev._constructed = true;
target.dispatchEvent(ev);
}
};
return me;
})();
function IScroll (el, options) {
this.wrapper = typeof el == 'string' ? document.querySelector(el) : el;
this.scroller = this.wrapper.children[0];
this.scrollerStyle = this.scroller.style; // cache style for better performance
this.options = {
// INSERT POINT: OPTIONS
startX: 0,
startY: 0,
scrollY: true,
directionLockThreshold: 5,
momentum: true,
bounce: true,
bounceTime: 600,
bounceEasing: '',
preventDefault: true,
preventDefaultException: { tagName: /^(INPUT|TEXTAREA|BUTTON|SELECT)$/ },
HWCompositing: true,
useTransition: true,
useTransform: true
};
for ( var i in options ) {
this.options[i] = options[i];
}
// Normalize options
this.translateZ = this.options.HWCompositing && utils.hasPerspective ? ' translateZ(0)' : '';
this.options.useTransition = utils.hasTransition && this.options.useTransition;
this.options.useTransform = utils.hasTransform && this.options.useTransform;
this.options.eventPassthrough = this.options.eventPassthrough === true ? 'vertical' : this.options.eventPassthrough;
this.options.preventDefault = !this.options.eventPassthrough && this.options.preventDefault;
// If you want eventPassthrough I have to lock one of the axes
this.options.scrollY = this.options.eventPassthrough == 'vertical' ? false : this.options.scrollY;
this.options.scrollX = this.options.eventPassthrough == 'horizontal' ? false : this.options.scrollX;
// With eventPassthrough we also need lockDirection mechanism
this.options.freeScroll = this.options.freeScroll && !this.options.eventPassthrough;
this.options.directionLockThreshold = this.options.eventPassthrough ? 0 : this.options.directionLockThreshold;
this.options.bounceEasing = typeof this.options.bounceEasing == 'string' ? utils.ease[this.options.bounceEasing] || utils.ease.circular : this.options.bounceEasing;
this.options.resizePolling = this.options.resizePolling === undefined ? 60 : this.options.resizePolling;
if ( this.options.tap === true ) {
this.options.tap = 'tap';
}
// INSERT POINT: NORMALIZATION
// Some defaults
this.x = 0;
this.y = 0;
this.directionX = 0;
this.directionY = 0;
this._events = {};
// INSERT POINT: DEFAULTS
this._init();
this.refresh();
this.scrollTo(this.options.startX, this.options.startY);
this.enable();
}
IScroll.prototype = {
version: '5.1.3',
_init: function () {
this._initEvents();
// INSERT POINT: _init
},
destroy: function () {
this._initEvents(true);
this._execEvent('destroy');
},
_transitionEnd: function (e) {
if ( e.target != this.scroller || !this.isInTransition ) {
return;
}
this._transitionTime();
if ( !this.resetPosition(this.options.bounceTime) ) {
this.isInTransition = false;
this._execEvent('scrollEnd');
}
},
_start: function (e) {
// React to left mouse button only
if ( utils.eventType[e.type] != 1 ) {
if ( e.button !== 0 ) {
return;
}
}
if ( !this.enabled || (this.initiated && utils.eventType[e.type] !== this.initiated) ) {
return;
}
if ( this.options.preventDefault && !utils.isBadAndroid && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) {
e.preventDefault();
}
var point = e.touches ? e.touches[0] : e,
pos;
this.initiated = utils.eventType[e.type];
this.moved = false;
this.distX = 0;
this.distY = 0;
this.directionX = 0;
this.directionY = 0;
this.directionLocked = 0;
this._transitionTime();
this.startTime = utils.getTime();
if ( this.options.useTransition && this.isInTransition ) {
this.isInTransition = false;
pos = this.getComputedPosition();
this._translate(Math.round(pos.x), Math.round(pos.y));
this._execEvent('scrollEnd');
} else if ( !this.options.useTransition && this.isAnimating ) {
this.isAnimating = false;
this._execEvent('scrollEnd');
}
this.startX = this.x;
this.startY = this.y;
this.absStartX = this.x;
this.absStartY = this.y;
this.pointX = point.pageX;
this.pointY = point.pageY;
this._execEvent('beforeScrollStart');
},
_move: function (e) {
if ( !this.enabled || utils.eventType[e.type] !== this.initiated ) {
return;
}
if ( this.options.preventDefault ) { // increases performance on Android? TODO: check!
e.preventDefault();
}
var point = e.touches ? e.touches[0] : e,
deltaX = point.pageX - this.pointX,
deltaY = point.pageY - this.pointY,
timestamp = utils.getTime(),
newX, newY,
absDistX, absDistY;
this.pointX = point.pageX;
this.pointY = point.pageY;
this.distX += deltaX;
this.distY += deltaY;
absDistX = Math.abs(this.distX);
absDistY = Math.abs(this.distY);
// We need to move at least 10 pixels for the scrolling to initiate
if ( timestamp - this.endTime > 300 && (absDistX < 10 && absDistY < 10) ) {
return;
}
// If you are scrolling in one direction lock the other
if ( !this.directionLocked && !this.options.freeScroll ) {
if ( absDistX > absDistY + this.options.directionLockThreshold ) {
this.directionLocked = 'h'; // lock horizontally
} else if ( absDistY >= absDistX + this.options.directionLockThreshold ) {
this.directionLocked = 'v'; // lock vertically
} else {
this.directionLocked = 'n'; // no lock
}
}
if ( this.directionLocked == 'h' ) {
if ( this.options.eventPassthrough == 'vertical' ) {
e.preventDefault();
} else if ( this.options.eventPassthrough == 'horizontal' ) {
this.initiated = false;
return;
}
deltaY = 0;
} else if ( this.directionLocked == 'v' ) {
if ( this.options.eventPassthrough == 'horizontal' ) {
e.preventDefault();
} else if ( this.options.eventPassthrough == 'vertical' ) {
this.initiated = false;
return;
}
deltaX = 0;
}
deltaX = this.hasHorizontalScroll ? deltaX : 0;
deltaY = this.hasVerticalScroll ? deltaY : 0;
newX = this.x + deltaX;
newY = this.y + deltaY;
// Slow down if outside of the boundaries
if ( newX > 0 || newX < this.maxScrollX ) {
newX = this.options.bounce ? this.x + deltaX / 3 : newX > 0 ? 0 : this.maxScrollX;
}
if ( newY > 0 || newY < this.maxScrollY ) {
newY = this.options.bounce ? this.y + deltaY / 3 : newY > 0 ? 0 : this.maxScrollY;
}
this.directionX = deltaX > 0 ? -1 : deltaX < 0 ? 1 : 0;
this.directionY = deltaY > 0 ? -1 : deltaY < 0 ? 1 : 0;
if ( !this.moved ) {
this._execEvent('scrollStart');
}
this.moved = true;
this._translate(newX, newY);
/* REPLACE START: _move */
if ( timestamp - this.startTime > 300 ) {
this.startTime = timestamp;
this.startX = this.x;
this.startY = this.y;
}
/* REPLACE END: _move */
},
_end: function (e) {
if ( !this.enabled || utils.eventType[e.type] !== this.initiated ) {
return;
}
if ( this.options.preventDefault && !utils.preventDefaultException(e.target, this.options.preventDefaultException) ) {
e.preventDefault();
}
var point = e.changedTouches ? e.changedTouches[0] : e,
momentumX,
momentumY,
duration = utils.getTime() - this.startTime,
newX = Math.round(this.x),
newY = Math.round(this.y),
distanceX = Math.abs(newX - this.startX),
distanceY = Math.abs(newY - this.startY),
time = 0,
easing = '';
this.isInTransition = 0;
this.initiated = 0;
this.endTime = utils.getTime();
// reset if we are outside of the boundaries
if ( this.resetPosition(this.options.bounceTime) ) {
return;
}
this.scrollTo(newX, newY); // ensures that the last position is rounded
// we scrolled less than 10 pixels
if ( !this.moved ) {
if ( this.options.tap ) {
utils.tap(e, this.options.tap);
}
if ( this.options.click ) {
utils.click(e);
}
this._execEvent('scrollCancel');
return;
}
if ( this._events.flick && duration < 200 && distanceX < 100 && distanceY < 100 ) {
this._execEvent('flick');
return;
}
// start momentum animation if needed
if ( this.options.momentum && duration < 300 ) {
momentumX = this.hasHorizontalScroll ? utils.momentum(this.x, this.startX, duration, this.maxScrollX, this.options.bounce ? this.wrapperWidth : 0, this.options.deceleration) : { destination: newX, duration: 0 };
momentumY = this.hasVerticalScroll ? utils.momentum(this.y, this.startY, duration, this.maxScrollY, this.options.bounce ? this.wrapperHeight : 0, this.options.deceleration) : { destination: newY, duration: 0 };
newX = momentumX.destination;
newY = momentumY.destination;
time = Math.max(momentumX.duration, momentumY.duration);
this.isInTransition = 1;
}
// INSERT POINT: _end
if ( newX != this.x || newY != this.y ) {
// change easing function when scroller goes out of the boundaries
if ( newX > 0 || newX < this.maxScrollX || newY > 0 || newY < this.maxScrollY ) {
easing = utils.ease.quadratic;
}
this.scrollTo(newX, newY, time, easing);
return;
}
this._execEvent('scrollEnd');
},
_resize: function () {
var that = this;
clearTimeout(this.resizeTimeout);
this.resizeTimeout = setTimeout(function () {
that.refresh();
}, this.options.resizePolling);
},
resetPosition: function (time) {
var x = this.x,
y = this.y;
time = time || 0;
if ( !this.hasHorizontalScroll || this.x > 0 ) {
x = 0;
} else if ( this.x < this.maxScrollX ) {
x = this.maxScrollX;
}
if ( !this.hasVerticalScroll || this.y > 0 ) {
y = 0;
} else if ( this.y < this.maxScrollY ) {
y = this.maxScrollY;
}
if ( x == this.x && y == this.y ) {
return false;
}
this.scrollTo(x, y, time, this.options.bounceEasing);
return true;
},
disable: function () {
this.enabled = false;
},
enable: function () {
this.enabled = true;
},
refresh: function () {
var rf = this.wrapper.offsetHeight; // Force reflow
this.wrapperWidth = this.wrapper.clientWidth;
this.wrapperHeight = this.wrapper.clientHeight;
/* REPLACE START: refresh */
this.scrollerWidth = this.scroller.offsetWidth;
this.scrollerHeight = this.scroller.offsetHeight;
this.maxScrollX = this.wrapperWidth - this.scrollerWidth;
this.maxScrollY = this.wrapperHeight - this.scrollerHeight;
/* REPLACE END: refresh */
this.hasHorizontalScroll = this.options.scrollX && this.maxScrollX < 0;
this.hasVerticalScroll = this.options.scrollY && this.maxScrollY < 0;
if ( !this.hasHorizontalScroll ) {
this.maxScrollX = 0;
this.scrollerWidth = this.wrapperWidth;
}
if ( !this.hasVerticalScroll ) {
this.maxScrollY = 0;
this.scrollerHeight = this.wrapperHeight;
}
this.endTime = 0;
this.directionX = 0;
this.directionY = 0;
this.wrapperOffset = utils.offset(this.wrapper);
this._execEvent('refresh');
this.resetPosition();
// INSERT POINT: _refresh
},
on: function (type, fn) {
if ( !this._events[type] ) {
this._events[type] = [];
}
this._events[type].push(fn);
},
off: function (type, fn) {
if ( !this._events[type] ) {
return;
}
var index = this._events[type].indexOf(fn);
if ( index > -1 ) {
this._events[type].splice(index, 1);
}
},
_execEvent: function (type) {
if ( !this._events[type] ) {
return;
}
var i = 0,
l = this._events[type].length;
if ( !l ) {
return;
}
for ( ; i < l; i++ ) {
this._events[type][i].apply(this, [].slice.call(arguments, 1));
}
},
scrollBy: function (x, y, time, easing) {
x = this.x + x;
y = this.y + y;
time = time || 0;
this.scrollTo(x, y, time, easing);
},
scrollTo: function (x, y, time, easing) {
easing = easing || utils.ease.circular;
this.isInTransition = this.options.useTransition && time > 0;
if ( !time || (this.options.useTransition && easing.style) ) {
this._transitionTimingFunction(easing.style);
this._transitionTime(time);
this._translate(x, y);
} else {
this._animate(x, y, time, easing.fn);
}
},
scrollToElement: function (el, time, offsetX, offsetY, easing) {
el = el.nodeType ? el : this.scroller.querySelector(el);
if ( !el ) {
return;
}
var pos = utils.offset(el);
pos.left -= this.wrapperOffset.left;
pos.top -= this.wrapperOffset.top;
// if offsetX/Y are true we center the element to the screen
if ( offsetX === true ) {
offsetX = Math.round(el.offsetWidth / 2 - this.wrapper.offsetWidth / 2);
}
if ( offsetY === true ) {
offsetY = Math.round(el.offsetHeight / 2 - this.wrapper.offsetHeight / 2);
}
pos.left -= offsetX || 0;
pos.top -= offsetY || 0;
pos.left = pos.left > 0 ? 0 : pos.left < this.maxScrollX ? this.maxScrollX : pos.left;
pos.top = pos.top > 0 ? 0 : pos.top < this.maxScrollY ? this.maxScrollY : pos.top;
time = time === undefined || time === null || time === 'auto' ? Math.max(Math.abs(this.x-pos.left), Math.abs(this.y-pos.top)) : time;
this.scrollTo(pos.left, pos.top, time, easing);
},
_transitionTime: function (time) {
time = time || 0;
this.scrollerStyle[utils.style.transitionDuration] = time + 'ms';
if ( !time && utils.isBadAndroid ) {
this.scrollerStyle[utils.style.transitionDuration] = '0.001s';
}
// INSERT POINT: _transitionTime
},
_transitionTimingFunction: function (easing) {
this.scrollerStyle[utils.style.transitionTimingFunction] = easing;
// INSERT POINT: _transitionTimingFunction
},
_translate: function (x, y) {
if ( this.options.useTransform ) {
/* REPLACE START: _translate */
this.scrollerStyle[utils.style.transform] = 'translate(' + x + 'px,' + y + 'px)' + this.translateZ;
/* REPLACE END: _translate */
} else {
x = Math.round(x);
y = Math.round(y);
this.scrollerStyle.left = x + 'px';
this.scrollerStyle.top = y + 'px';
}
this.x = x;
this.y = y;
// INSERT POINT: _translate
},
_initEvents: function (remove) {
var eventType = remove ? utils.removeEvent : utils.addEvent,
target = this.options.bindToWrapper ? this.wrapper : window;
eventType(window, 'orientationchange', this);
eventType(window, 'resize', this);
if ( this.options.click ) {
eventType(this.wrapper, 'click', this, true);
}
if ( !this.options.disableMouse ) {
eventType(this.wrapper, 'mousedown', this);
eventType(target, 'mousemove', this);
eventType(target, 'mousecancel', this);
eventType(target, 'mouseup', this);
}
if ( utils.hasPointer && !this.options.disablePointer ) {
eventType(this.wrapper, utils.prefixPointerEvent('pointerdown'), this);
eventType(target, utils.prefixPointerEvent('pointermove'), this);
eventType(target, utils.prefixPointerEvent('pointercancel'), this);
eventType(target, utils.prefixPointerEvent('pointerup'), this);
}
if ( utils.hasTouch && !this.options.disableTouch ) {
eventType(this.wrapper, 'touchstart', this);
eventType(target, 'touchmove', this);
eventType(target, 'touchcancel', this);
eventType(target, 'touchend', this);
}
eventType(this.scroller, 'transitionend', this);
eventType(this.scroller, 'webkitTransitionEnd', this);
eventType(this.scroller, 'oTransitionEnd', this);
eventType(this.scroller, 'MSTransitionEnd', this);
},
getComputedPosition: function () {
var matrix = window.getComputedStyle(this.scroller, null),
x, y;
if ( this.options.useTransform ) {
matrix = matrix[utils.style.transform].split(')')[0].split(', ');
x = +(matrix[12] || matrix[4]);
y = +(matrix[13] || matrix[5]);
} else {
x = +matrix.left.replace(/[^-\d.]/g, '');
y = +matrix.top.replace(/[^-\d.]/g, '');
}
return { x: x, y: y };
},
_animate: function (destX, destY, duration, easingFn) {
var that = this,
startX = this.x,
startY = this.y,
startTime = utils.getTime(),
destTime = startTime + duration;
function step () {
var now = utils.getTime(),
newX, newY,
easing;
if ( now >= destTime ) {
that.isAnimating = false;
that._translate(destX, destY);
if ( !that.resetPosition(that.options.bounceTime) ) {
that._execEvent('scrollEnd');
}
return;
}
now = ( now - startTime ) / duration;
easing = easingFn(now);
newX = ( destX - startX ) * easing + startX;
newY = ( destY - startY ) * easing + startY;
that._translate(newX, newY);
if ( that.isAnimating ) {
rAF(step);
}
}
this.isAnimating = true;
step();
},
handleEvent: function (e) {
switch ( e.type ) {
case 'touchstart':
case 'pointerdown':
case 'MSPointerDown':
case 'mousedown':
this._start(e);
break;
case 'touchmove':
case 'pointermove':
case 'MSPointerMove':
case 'mousemove':
this._move(e);
break;
case 'touchend':
case 'pointerup':
case 'MSPointerUp':
case 'mouseup':
case 'touchcancel':
case 'pointercancel':
case 'MSPointerCancel':
case 'mousecancel':
this._end(e);
break;
case 'orientationchange':
case 'resize':
this._resize();
break;
case 'transitionend':
case 'webkitTransitionEnd':
case 'oTransitionEnd':
case 'MSTransitionEnd':
this._transitionEnd(e);
break;
case 'wheel':
case 'DOMMouseScroll':
case 'mousewheel':
this._wheel(e);
break;
case 'keydown':
this._key(e);
break;
case 'click':
if ( !e._constructed ) {
e.preventDefault();
e.stopPropagation();
}
break;
}
}
};
IScroll.utils = utils;
if ( typeof module != 'undefined' && module.exports ) {
module.exports = IScroll;
} else {
window.IScroll = IScroll;
}
})(window, document, Math);
+12
View File
@@ -0,0 +1,12 @@
app.directive('loading', function(){
var str = '<div id="loading" ng-show="isNoLoaded"><img src="../imgs/loading.gif" /></div>';
return {
restrict: 'AE',
template: str,
replace: true
};
});
+19
View File
@@ -0,0 +1,19 @@
/*初始化图书列表页*/
app.controller('BookListController', function($rootScope, bookList){
if(!$rootScope.keywordsObj.book){
$rootScope.keywordsObj.book = 'C语言';
}
bookList.getData($rootScope.keywordsObj.book);
});
/*图书详情页*/
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;
};
});
+14
View File
@@ -0,0 +1,14 @@
app.controller('MenuController', function($scope, $location){
$scope.bookSearch = function(){
$location.path('/book');
};
$scope.musicSearch = function(){
$location.path('/music');
};
$scope.movieSearch = function(){
$location.path('/movie');
};
});
+7
View File
@@ -0,0 +1,7 @@
/*初始化的结果*/
app.controller('movieListController', function($rootScope, movieList){
if(!$rootScope.keywordsObj.movie){
$rootScope.keywordsObj.movie = '笑傲江湖';
}
movieList.getData($rootScope.keywordsObj.movie);
});
+9
View File
@@ -0,0 +1,9 @@
/*初始化的结果*/
app.controller('musicListController', function($rootScope, musicList){
if(!$rootScope.keywordsObj.music){
$rootScope.keywordsObj.music = '刘德华';
}
musicList.getData($rootScope.keywordsObj.music);
});
+25
View File
@@ -0,0 +1,25 @@
/*搜索*/
app.controller('SearchController', function($scope, $rootScope, $location, bookList, musicList, movieList){
var path = $location.path();
$scope.search = function(){
var keywords = $scope.keywords;
if(path.indexOf('/book') !== -1 || path === '/'){
if(keywords){
$rootScope.keywordsObj.book = keywords;
}
bookList.getData($rootScope.keywordsObj.book);
}else if(path.indexOf('/music') !== -1 || path === '/music'){
if(keywords){
$rootScope.keywordsObj.music = keywords;
}
musicList.getData($rootScope.keywordsObj.music);
}else if(path.indexOf('/movie') !== -1 || path === '/movie'){
if(keywords){
$rootScope.keywordsObj.movie = keywords;
}
movieList.getData($rootScope.keywordsObj.music);
}
};
});
+111 -28
View File
@@ -1,46 +1,129 @@
var app = angular.module('app', ['ngRoute']);
window.scrollTo(0, 0);
var app = angular.module('app', ['ui.router']);
/*$rootScope的相关配置*/
app.run(function($rootScope){
$rootScope.version = '0.1';
$rootScope.author = 'vczero';
$rootScope.author_alias = '鬼谣';
$rootScope.isNoLoaded = true;
$rootScope.rootList = []; //当然这是个不好的做法,只因为APP太simple
$rootScope.bookList = []; //当然这是个不好的做法,只因为APP太simple
$rootScope.musicList = [];
$rootScope.movieList = [];
$rootScope.keywordsObj = {
book: '',
music: '',
movie: ''
};
});
/*服务的URL配置*/
app.constant('ServiceConfig', {
book_search: 'https://api.douban.com/v2/book/search',
book_search_id: 'https://api.douban.com/v2/book/'
book_search_id: 'https://api.douban.com/v2/book/',
music_search: 'https://api.douban.com/v2/music/search',
music_search_id: 'https://api.douban.com/v2/music/',
movie_search: 'https://api.douban.com/v2/movie/search',
movie_search_id: 'https://api.douban.com/v2/movie/subject/'
});
/*路由控制*/
app.config(['$routeProvider', function ($routeProvider) {
$routeProvider
/*图书搜索*/
.when('/list/book', {
templateUrl: 'view/book_list.html',
controller: 'BookListController'
app.config(function($stateProvider, $urlRouterProvider){
/*URL路由*/
$urlRouterProvider.otherwise("/");
/*状态配置*/
$stateProvider
//首页
.state('index',{
url: '/',
views:{
header:{
templateUrl: '../html/views/list_header.html',
controller: 'SearchController'
},
container:{
templateUrl: '../html/views/list_book.html',
controller: 'BookListController'
},
footer:{
templateUrl: '../html/views/list_footer.html',
controller: ''
}
}
})
.when('/list/book/:id', {
templateUrl: 'view/book_detail.html',
controller: 'BookDetailController'
//book list
.state('book_list',{
url: '/book',
views:{
header:{
templateUrl: '../html/views/list_header.html',
controller: 'SearchController'
},
container:{
templateUrl: '../html/views/list_book.html',
controller: 'BookListController'
},
footer:{
templateUrl: '../html/views/list_footer.html',
controller: ''
}
}
})
/*音乐搜索*/
.when('/list/music', {
templateUrl: 'view/book_list.html',
controller: 'BookListController'
// book detail
.state('book_detail',{
url: '/book/:id',
views:{
header:{
templateUrl: '../html/views/list_header.html',
controller: 'SearchController'
},
container:{
templateUrl: '../html/views/detail_book.html',
controller: 'BookDetailController'
},
footer:{
templateUrl: '../html/views/list_footer.html',
controller: ''
}
}
})
/*电影搜索*/
.when('/list/movie', {
templateUrl: 'view/book_list.html',
controller: 'BookListController'
// music list
.state('music_lsit',{
url: '/music',
views:{
header:{
templateUrl: '../html/views/list_header.html',
controller: 'SearchController'
},
container:{
templateUrl: '../html/views/list_music.html',
controller: 'musicListController'
},
footer:{
templateUrl: '../html/views/list_footer.html',
controller: ''
}
}
})
/*定向到首页*/
.otherwise({
redirectTo: '/',
templateUrl: 'view/book_list.html',
controller: 'BookListController'
// movie list
.state('movie_lsit',{
url: '/movie',
views:{
header:{
templateUrl: '../html/views/list_header.html',
controller: 'SearchController'
},
container:{
templateUrl: '../html/views/list_movie.html',
controller: 'movieListController'
},
footer:{
templateUrl: '../html/views/list_footer.html',
controller: ''
}
}
});
}]);
});
+32
View File
@@ -0,0 +1,32 @@
/*构建BookList服务*/
app.factory('bookList', function($rootScope, $http, ServiceConfig){
$rootScope.isNoLoaded = true;
var _BookList = {
getData: function(keywords){
$rootScope.isNoLoaded = true;
$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.bookList = list;
};
}
};
return _BookList;
});
+20
View File
@@ -0,0 +1,20 @@
/*构建movieList服务*/
app.factory('movieList', function($rootScope, $http, ServiceConfig){
$rootScope.isNoLoaded = true;
var _MovieList = {
getData: function(keywords){
$rootScope.isNoLoaded = true;
$http.jsonp(ServiceConfig.movie_search + '?callback=movieSearch&count=10&q=' + keywords);
window.movieSearch = function(data){
$rootScope.isNoLoaded = false;
if(data.subjects && data.subjects.length){
$rootScope.movieList = data.subjects;
}
console.log(data.subjects)
};
}
};
return _MovieList;
});
+19
View File
@@ -0,0 +1,19 @@
/*构建musicList服务*/
app.factory('musicList', function($rootScope, $http, ServiceConfig){
$rootScope.isNoLoaded = true;
var _MusicList = {
getData: function(keywords){
$rootScope.isNoLoaded = true;
$http.jsonp(ServiceConfig.music_search + '?callback=musicSearch&count=10&q=' + keywords);
window.musicSearch = function(data){
$rootScope.isNoLoaded = false;
if(data.musics && data.musics.length){
$rootScope.musicList = data.musics;
}
};
}
};
return _MusicList;
});