├── .gitignore ├── LICENSE ├── README.md ├── build ├── LICENSE ├── README.md ├── css │ └── pullload.css ├── index.html ├── index2.html ├── index3.html └── js │ ├── pullload.js │ ├── require-config.js │ ├── require.js │ └── zepto.min.js ├── css └── pullload.less ├── fis-conf.js ├── index.html ├── index2.html ├── index3.html └── js ├── pullload.js ├── require-config.js ├── require.js └── zepto.min.js /.gitignore: -------------------------------------------------------------------------------- 1 | output/* 2 | output 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 dainli 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # pullLoad 2 | 移动端 html5 插件,实现下拉刷新,加载更多等功能,支持require.js 3 | 4 | react 版本 [react-pullLoad](https://github.com/react-ld/react-pullLoad) 5 | 6 | #### 示例 7 | https://lidianhao123.github.io/pullLoad/ 8 | 9 | # 基本思路 10 | 1. 不依赖第三方库 11 | 2. 固定DOM结构 12 | 3. 支持 body 或者固定高度的 DOM 块级元素作为外部容器 contianer(即可视区域大小) 13 | 4. 普通版本和 react 版本核心代码一致,即抽离出核心代码层和具体实现层 14 | 15 | 经过实际开发发现抽离核心代码使逻辑更加的复杂,直接复用核心逻辑完成具体实现。 16 | 17 | 5. 触摸事件绑定在内容块 content(即高度为 auto 的DOM ) 18 | 19 | # 功能点 20 | 1. 下拉刷新 21 | 2. 滚动到距底部距离小于阈值加载更多 22 | 3. 上拉加载更多 TODO 23 | 4. 通过复写 css 实现自定义样式 TODO 24 | 5. 返回顶部功能 TODO 25 | 6. 所有功能点已扩展的形式进行开发互不影响 TODO 26 | 27 | # 使用说明 28 | #### 添加固定 DOM 结构模板 29 | 30 | ```html 31 | 32 |
33 |
34 |

35 |

36 | 37 |

38 |
39 |
40 | 41 |
42 | 48 |
49 | ``` 50 | 51 | #### 添加 Javascript 文件 52 | 53 | ```html 54 | 55 | ``` 56 | 当然也支持 require 模块化方式 57 | ```js 58 | require(["zepto", "pullload"], function($, pullload) {}) 59 | ``` 60 | 61 | #### 创建 pullload 对象 62 | 63 | 此示例代码为 [domo1](https://lidianhao123.github.io/pullLoad/index.html) 中部分代码节选,详情可直接参考 [domo1](https://lidianhao123.github.io/pullLoad/index.html) 64 | ```js 65 | var installObj = new pullload({ 66 | container: document.body, 67 | wrapper: document.getElementById("test_div"), 68 | downEnough: 100, 69 | distanceBottom: 300, 70 | // onRefresh 有两个回调函数,二者必须调用一个 71 | onRefresh: function(success,error){ 72 | console.info("实际代码 onRefresh") 73 | setTimeout(function(){ 74 | $(".test-ul").html(createAll(data)); 75 | success(); //完成刷新调用 76 | },2000); 77 | //error(); //异常调用 78 | }, 79 | // onLoadMore 有两个回调函数,二者必须调用一个 80 | onLoadMore: function(success, error){ 81 | console.info("实际代码 onLoadMore") 82 | setTimeout(function(){ 83 | $(".test-ul").append(createLi(data[loadMoreIndex])); 84 | // if(--loadMoreIndex){ 85 | success(false); //加载动作完成 86 | // } else{ 87 | // success(true); //加载动作完成 并且传递 true 参数通知组件无更多内容 88 | // } 89 | },500); 90 | //error(); //单词请求异常调用 91 | }, 92 | }); 93 | ``` 94 | 95 | # 参数说明: 96 | - container 可以是 body 或者固定高度的 DOM 块级元素作为外部容器 97 | - wrapper 必须是上述 id="test_div" 元素 98 | - downEnough 下拉满足刷新的距离 默认值为100像素 99 | - distanceBottom 距离底部距离触发加载更多 默认值为100像素 100 | - onRefresh 满足刷新动作回调函数,刷新的具体业务代码在此函数中进行,并且需要 success 或者 error 101 | - onLoadMore 满足加载更多回调函数,加载更多聚义业务代码在此函数中进行,并且需要 success 或者 error。无更多内容时请执行success(true); 102 | 103 | # License 104 | MIT 105 | -------------------------------------------------------------------------------- /build/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 dainli 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /build/README.md: -------------------------------------------------------------------------------- 1 | # pullLoad 2 | 移动端 html5 插件,实现下拉刷新,加载更多等功能,支持require.js 3 | 4 | #### 示例 5 | http://lidianhao123.github.io/pullLoad/ 6 | 7 | # 基本思路 8 | 1. 不依赖第三方库 9 | 2. 固定DOM结构 10 | 3. 支持 body 或者固定高度的 DOM 块级元素作为外部容器 contianer(即可视区域大小) 11 | 4. 普通版本和 react 版本核心代码一致,即抽离出核心代码层和具体实现层 12 | 13 | 经过实际开发发现抽离核心代码使逻辑更加的复杂,直接复用核心逻辑完成具体实现。 14 | 15 | 5. 触摸事件绑定在内容块 content(即高度为 auto 的DOM ) 16 | 17 | # 功能点 18 | 1. 下拉刷新 19 | 2. 滚动到距底部距离小于阈值加载更多 20 | 3. 上拉加载更多 TODO 21 | 4. 通过复写 css 实现自定义样式 TODO 22 | 5. 返回顶部功能 TODO 23 | 6. 所有功能点已扩展的形式进行开发互不影响 TODO 24 | 25 | # 使用说明 26 | #### 添加固定 DOM 结构模板 27 | 28 | ```html 29 | 30 |
31 |
32 |

33 |

34 | 35 |

36 |
37 |
38 | 39 |
40 | 46 |
47 | ``` 48 | 49 | #### 添加 Javascript 文件 50 | 51 | ```html 52 | 53 | ``` 54 | 当然也支持 require 模块化方式 55 | ```js 56 | require(["zepto", "pullload"], function($, pullload) {}) 57 | ``` 58 | 59 | #### 创建 pullload 对象 60 | 61 | 此示例代码为 [domo1](http://lidianhao123.github.io/pullLoad/index.html) 中部分代码节选,详情可直接参考 [domo1](http://lidianhao123.github.io/pullLoad/index.html) 62 | ```js 63 | var installObj = new pullload({ 64 | container: document.body, 65 | wrapper: document.getElementById("test_div"), 66 | downEnough: 100, 67 | distanceBottom: 300, 68 | // onRefresh 有两个回调函数,二者必须调用一个 69 | onRefresh: function(success,error){ 70 | console.info("实际代码 onRefresh") 71 | setTimeout(function(){ 72 | $(".test-ul").html(createAll(data)); 73 | success(); //完成刷新调用 74 | },2000); 75 | //error(); //异常调用 76 | }, 77 | // onLoadMore 有两个回调函数,二者必须调用一个 78 | onLoadMore: function(success, error){ 79 | console.info("实际代码 onLoadMore") 80 | setTimeout(function(){ 81 | $(".test-ul").append(createLi(data[loadMoreIndex])); 82 | // if(--loadMoreIndex){ 83 | success(false); //加载动作完成 84 | // } else{ 85 | // success(true); //加载动作完成 并且传递 true 参数通知组件无更多内容 86 | // } 87 | },500); 88 | //error(); //单词请求异常调用 89 | }, 90 | }); 91 | ``` 92 | 93 | # 参数说明: 94 | - container 可以是 body 或者固定高度的 DOM 块级元素作为外部容器 95 | - wrapper 必须是上述 id="test_div" 元素 96 | - downEnough 下拉满足刷新的距离 默认值为100像素 97 | - distanceBottom 距离底部距离触发加载更多 默认值为100像素 98 | - onRefresh 满足刷新动作回调函数,刷新的具体业务代码在此函数中进行,并且需要 success 或者 error 99 | - onLoadMore 满足加载更多回调函数,加载更多聚义业务代码在此函数中进行,并且需要 success 或者 error。无更多内容时请执行success(true); -------------------------------------------------------------------------------- /build/css/pullload.css: -------------------------------------------------------------------------------- 1 | .state-pulling .tloader-msg:after{content:'下拉刷新'}.state-pulling.enough .tloader-msg:after{content:'松开刷新'}.state-refreshed .tloader-msg:after{content:'刷新成功'}.tloader-loading:after{content:'正在加载...'}.tloader-symbol .tloader-loading:after{content:'正在刷新...'}.tloader-btn:after{content:'没有更多'}.tloader{position:relative}.tloader-symbol{position:absolute;top:0;left:0;right:0;color:#7676a1;text-align:center;height:3rem;overflow:hidden}.state- .tloader-symbol,.state-reset .tloader-symbol{height:0}.state-reset .tloader-symbol{-webkit-transition:height 0s .2s;transition:height 0s .2s}.tloader-msg{line-height:3rem;font-size:11px;opacity:0}.state-pulling .tloader-msg{opacity:1}.state-pulling .tloader-msg i{display:inline-block;font-size:2em;margin-right:.6em;vertical-align:middle;height:1em;border-left:1px solid;position:relative;-webkit-transition:-webkit-transform .3s ease;transition:transform .3s ease}.state-pulling .tloader-msg i:before,.state-pulling .tloader-msg i:after{content:'';position:absolute;font-size:.5em;width:1em;bottom:0;border-top:1px solid}.state-pulling .tloader-msg i:before{right:1px;-webkit-transform:rotate(50deg);transform:rotate(50deg);-webkit-transform-origin:right;transform-origin:right}.state-pulling .tloader-msg i:after{left:0;-webkit-transform:rotate(-50deg);transform:rotate(-50deg);-webkit-transform-origin:left;transform-origin:left}.state-pulling.enough .tloader-msg i{-webkit-transform:rotate(180deg);transform:rotate(180deg)}.state-refreshed .tloader-msg{opacity:1;-webkit-transition:opacity 1s;transition:opacity 1s}.state-refreshed .tloader-msg i{display:inline-block;-webkit-box-sizing:content-box;box-sizing:content-box;vertical-align:middle;margin-right:10px;font-size:20px;height:1em;width:1em;border:1px solid;border-radius:100%;position:relative}.state-refreshed .tloader-msg i:before{content:'';position:absolute;top:3px;left:7px;height:11px;width:5px;border:solid;border-width:0 1px 1px 0;-webkit-transform:rotate(40deg);transform:rotate(40deg)}.state-refreshing .tloader-body{-webkit-transform:translate3d(0,3rem,0);transform:translate3d(0,3rem,0);-webkit-transition:-webkit-transform .2s;transition:transform .2s}.state-refreshed .tloader-body{-webkit-animation:refreshed 1s;animation:refreshed 1s}.state-reset .tloader-body{-webkit-transition:-webkit-transform .2s;transition:transform .2s}@-webkit-keyframes refreshed{0%{-webkit-transform:translate3d(0,3rem,0);transform:translate3d(0,3rem,0)}50%{-webkit-transform:translate3d(0,3rem,0);transform:translate3d(0,3rem,0)}}@keyframes refreshed{0%{-webkit-transform:translate3d(0,3rem,0);transform:translate3d(0,3rem,0)}50%{-webkit-transform:translate3d(0,3rem,0);transform:translate3d(0,3rem,0)}}.state-refreshing .tloader-footer{display:none}.tloader-footer .tloader-btn{color:#484869;font-size:.9em;text-align:center;line-height:3rem;display:none}.state-loading .tloader-footer .tloader-btn{display:none}.tloader-loading{display:none;text-align:center;line-height:3rem;font-size:11px;color:#7676a1}.tloader-loading .ui-loading{font-size:20px;margin-right:.6rem}.state-refreshing .tloader-symbol .tloader-loading,.state-loading .tloader-footer .tloader-loading{display:block}@-webkit-keyframes circle{100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes circle{100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}.ui-loading{display:inline-block;vertical-align:middle;font-size:1.5rem;width:1em;height:1em;border:2px solid #9494b6;border-top-color:#fff;border-radius:100%;-webkit-animation:circle .8s infinite linear;animation:circle .8s infinite linear}#ui-waiting .ui-loading{border:2px solid #fff;border-top-color:#9494b6}@-webkit-keyframes tloader-progressing{0%{width:0}10%{width:40%}20%{width:75%}30%{width:95%}}@keyframes tloader-progressing{0%{width:0}10%{width:40%}20%{width:75%}30%{width:95%}}@-webkit-keyframes tloader-progressed{0%{opacity:1}}@keyframes tloader-progressed{0%{opacity:1}}.tloader-progress{position:relative}.tloader-progress:before{content:"";z-index:1000;position:absolute;top:0;left:0;height:2px;background-color:#08BF06;width:99%;-webkit-animation:tloader-progressing 9s ease-out;animation:tloader-progressing 9s ease-out}.ed.tloader-progress:before{opacity:0;width:100%;-webkit-animation:tloader-progressed 1s;animation:tloader-progressed 1s} -------------------------------------------------------------------------------- /build/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | pullload 以 body 为滚动容器 6 | 7 | 13 | 14 | 15 | 16 |
17 |
18 |

19 |

20 | 21 |

22 |
23 |
24 | 26 |
27 | 33 |
34 | 35 | 36 | 89 | 90 | -------------------------------------------------------------------------------- /build/index2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | pullload 支持 require.js 方式 6 | 7 | 8 | 9 | 15 | 16 | 17 | 18 |
19 |
20 |

21 |

22 | 23 |

24 |
25 |
26 | 28 |
29 | 35 |
36 | 91 | 92 | -------------------------------------------------------------------------------- /build/index3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | pullload 以块级元素为滚动容器 6 | 7 | 8 | 9 | 16 | 17 | 18 | 19 |
20 |
21 |

22 |

23 | 24 |

25 |
26 |
27 | 29 |
30 | 36 |
37 | 92 | 93 | -------------------------------------------------------------------------------- /build/js/pullload.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | 3 | var defaultConfig = { 4 | container: null, //具有scroll的容器 5 | wrapper: null, //结构外包围元素 6 | downEnough: 100, //下拉满足刷新的距离 7 | offsetScrollTop: 2, //与顶部的距离 8 | distanceBottom: 100, //距离底部距离触发加载更多 9 | onRefresh: function(){}, 10 | onLoadMore: function(){} 11 | } 12 | 13 | var STATS = { 14 | init: '', 15 | pulling: 'pulling', 16 | enough: 'pulling enough', 17 | refreshing: 'refreshing', 18 | refreshed: 'refreshed', 19 | reset: 'reset', 20 | loading: 'loading' // loading more 21 | }; 22 | 23 | var pullload = function(opts){ 24 | this.config = {}; 25 | this.container = null; //具有scroll的容器 26 | this.wrapper = null; //结构外包围元素 27 | this.loaderBody = null; //DOM 对象 28 | this.loaderSymbol = null; //DOM 对象 29 | this.loaderBtn = null; //DOM 对象 30 | this.loaderState = STATS.init; 31 | this.hasMore = true; //是否有加载更多 32 | this.startX = 0; //用于保存touchstart时初始位置 33 | this.startY = 0;//用于保存touchstart时初始位置 34 | this.init(opts); 35 | } 36 | 37 | pullload.prototype = { 38 | init: function(opts){ 39 | this.config = extend(defaultConfig, opts || {}); 40 | 41 | this.container = opts.container; 42 | this.wrapper = opts.wrapper; 43 | 44 | this.loaderBody = this.wrapper.querySelector(".tloader-body"); 45 | this.loaderSymbol = this.wrapper.querySelector(".tloader-symbol"); 46 | this.loaderBtn = this.wrapper.querySelector(".tloader-btn"); 47 | 48 | //将函数 'onTouchStart','onTouchMove','onTouchEnd' 进行 this 绑定。 49 | bindAll(['onTouchStart','onTouchMove','onTouchEnd'], this); 50 | 51 | addEvent(this.wrapper, "touchstart", this.onTouchStart); 52 | addEvent(this.wrapper, "touchmove", this.onTouchMove); 53 | addEvent(this.wrapper, "touchend", this.onTouchEnd); 54 | }, 55 | destory: function(){ 56 | removeEvent(this.wrapper, "touchstart", this.onTouchStart); 57 | removeEvent(this.wrapper, "touchmove", this.onTouchMove); 58 | removeEvent(this.wrapper, "touchend", this.onTouchEnd); 59 | this.config = {}; 60 | this.container = null; //具有scroll的容器 61 | this.wrapper = null; //结构外包围元素 62 | this.loaderBody = null; //DOM 对象 63 | this.loaderSymbol = null; //DOM 对象 64 | this.loaderBtn = null; //DOM 对象 65 | this.loaderState = STATS.init; 66 | this.hasMore = true; //是否有加载更多 67 | this.startX = 0; //用于保存touchstart时初始位置 68 | this.startY = 0;//用于保存touchstart时初始位置 69 | }, 70 | onTouchStart: function(event){ 71 | var targetEvent = event.changedTouches[0]; 72 | this.startX = targetEvent.clientX; 73 | this.startY = targetEvent.clientY; 74 | }, 75 | onTouchMove: function(event){ 76 | var targetEvent = event.changedTouches[0], 77 | x = targetEvent.clientX, 78 | y = targetEvent.clientY, 79 | scrollTop = this.container.scrollTop, 80 | scrollH = this.container.scrollHeight, 81 | conH = this.container === document.body ? document.documentElement.clientHeight : this.container.offsetHeight; 82 | diffX = x - this.startX, 83 | diffY = y - this.startY; 84 | 85 | //判断垂直移动距离是否大于5 && 横向移动距离小于纵向移动距离 86 | if(Math.abs(diffY) > 5 && Math.abs(diffY) > Math.abs(diffX)){ 87 | //滚动距离小于设定值 &&回调onPullDownMove 函数,并且回传位置值 88 | if(diffY > 5 && scrollTop < this.config.offsetScrollTop ){ 89 | // //阻止执行浏览器默认动作 90 | // event.preventDefault(); 91 | this.onPullDownMove(this.startY, y); 92 | } //滚动距离距离底部小于设定值 93 | else if(diffY < 0 && (scrollH - scrollTop - conH) < this.config.distanceBottom ){ 94 | //阻止执行浏览器默认动作 95 | // event.preventDefault(); 96 | this.onPullUpMove(this.startY, y); 97 | } 98 | } 99 | }, 100 | onTouchEnd: function(event){ 101 | var targetEvent = event.changedTouches[0], 102 | x = targetEvent.clientX, 103 | y = targetEvent.clientY, 104 | scrollTop = this.container.scrollTop, 105 | scrollH = this.container.scrollHeight, 106 | conH = this.container === document.body ? document.documentElement.clientHeight : this.container.offsetHeight; 107 | diffX = x - this.startX, 108 | diffY = y - this.startY; 109 | 110 | //判断垂直移动距离是否大于5 && 横向移动距离小于纵向移动距离 111 | if(Math.abs(diffY) > 5 && Math.abs(diffY) > Math.abs(diffX)){ 112 | if(diffY > 5 && scrollTop < this.config.offsetScrollTop ){ 113 | //回调onPullDownRefresh 函数,即满足刷新条件 114 | this.onPullDownRefresh(); 115 | } 116 | } 117 | }, 118 | onPullDownMove: function(startY, y){ 119 | if(this.loaderState === STATS.refreshing){ 120 | return false; 121 | } 122 | event.preventDefault(); 123 | 124 | var diff = y - startY, loaderState; 125 | if (diff < 0) { 126 | diff = 0; 127 | } 128 | 129 | diff = this.easing(diff); 130 | if (diff > this.config.downEnough) { 131 | loaderState = STATS.enough; 132 | } else { 133 | loaderState = STATS.pulling; 134 | } 135 | this.setChange(diff, loaderState); 136 | }, 137 | onPullDownRefresh: function(){ 138 | if(this.loaderState === STATS.refreshing){ 139 | return false; 140 | } 141 | else if (this.loaderState === STATS.pulling) { 142 | this.setEndState(); 143 | } else { 144 | this.setChange(0, STATS.refreshing); 145 | this.resetLoadMore(); 146 | if (typeof this.config.onRefresh === "function") { 147 | this.config.onRefresh( 148 | bind(function(){ 149 | this.setChange(0, STATS.refreshed); 150 | setTimeout(bind(function(){this.setChange(0, STATS.init);}, this), 1000); 151 | }, this), 152 | bind(function(){ 153 | this.setEndState(); 154 | }, this) 155 | ) 156 | } 157 | } 158 | }, 159 | onPullUpMove: function(staartY, y){ 160 | if(!this.hasMore || this.loaderState === STATS.loading){ 161 | return false; 162 | } 163 | if (typeof this.config.onLoadMore === "function") { 164 | this.setChange(0, STATS.loading); 165 | // console.info(this.state); 166 | this.config.onLoadMore(bind(function(isNoMore){ 167 | this.setEndState(); 168 | if(isNoMore){ 169 | this.setNoMoreState(); 170 | } 171 | }, this)); 172 | } 173 | }, 174 | // 拖拽的缓动公式 - easeOutSine 175 | easing: function(distance) { 176 | // t: current time, b: begInnIng value, c: change In value, d: duration 177 | var t = distance; 178 | var b = 0; 179 | var d = screen.availHeight; // 允许拖拽的最大距离 180 | var c = d / 2.5; // 提示标签最大有效拖拽距离 181 | 182 | return c * Math.sin(t / d * (Math.PI / 2)) + b; 183 | }, 184 | setChange: function(pullHeight, state){ 185 | var lbodyTop = pullHeight !== 0 ? 'translate3d(0, ' + pullHeight + 'px, 0)' : "", 186 | symbolTop = pullHeight - 50 > 0 ? pullHeight - 50 : 0; 187 | lSymbol = symbolTop !== 0 ? 'translate3d(0, ' + symbolTop + 'px, 0)' : ""; 188 | 189 | this.setClassName(state); 190 | this.loaderBody.style.WebkitTransform = lbodyTop; 191 | this.loaderBody.style.transform = lbodyTop; 192 | this.loaderSymbol.style.WebkitTransform = lSymbol; 193 | this.loaderSymbol.style.transform = lSymbol; 194 | }, 195 | //设置 wrapper DOM class 值 196 | setClassName: function(state){ 197 | this.loaderState = state; 198 | this.wrapper.className = 'tloader state-' + state; 199 | }, 200 | //设置动作结束状态 201 | setEndState: function(){ 202 | this.setChange(0, STATS.reset); 203 | }, 204 | setNoMoreState:function(){ 205 | this.loaderBtn.style.display = "block"; 206 | this.hasMore = false; 207 | }, 208 | resetLoadMore: function(){ 209 | this.loaderBtn.style.display = "none"; 210 | this.hasMore = true; 211 | } 212 | } 213 | 214 | function extendArrProps(arr, obj1, obj2){ 215 | var index = 0, len = arr.length; 216 | for(index; index < len; index++){ 217 | var value = arr[index]; 218 | if(typeof obj2[value] !== "undefined"){ 219 | obj1[value] = obj2[value]; 220 | } 221 | } 222 | return obj1; 223 | } 224 | 225 | //copy obj2 props to obj1 no deepClone 226 | function extend(obj1, obj2){ 227 | var newObj = {}; 228 | for(var s in obj1){ 229 | newObj[s] = obj1[s] 230 | } 231 | for(var s in obj2){ 232 | newObj[s] = obj2[s] 233 | } 234 | return newObj; 235 | } 236 | 237 | function addEvent(obj, type, fn) { 238 | if (obj.attachEvent) { 239 | obj['e' + type + fn] = fn; 240 | obj[type + fn] = function () { obj['e' + type + fn](window.event); } 241 | obj.attachEvent('on' + type, obj[type + fn]); 242 | } else 243 | obj.addEventListener(type, fn, false); 244 | } 245 | function removeEvent(obj, type, fn) { 246 | if (obj.detachEvent) { 247 | obj.detachEvent('on' + type, obj[type + fn]); 248 | obj[type + fn] = null; 249 | } else 250 | obj.removeEventListener(type, fn, false); 251 | } 252 | 253 | function asArray(quasiArray, start) { 254 | var result = [], 255 | i = (start || 0); 256 | for (; i < quasiArray.length; i++) { 257 | result.push(quasiArray[i]); 258 | } 259 | return result; 260 | } 261 | 262 | function bind(func, context) { 263 | if (arguments.length < 2 && typeof arguments[0] === "undefined") { 264 | return func; 265 | } 266 | 267 | var __method = func; 268 | var args = asArray(arguments, 2); 269 | 270 | return function() { 271 | var array = args.concat(asArray(arguments, 0)); 272 | return __method.apply(context, array); 273 | }; 274 | } 275 | /* bindAll 批量绑定 276 | * @param fns 待绑定的函数名称 277 | * @param obj 待绑定的实例对象 278 | * @param context 用于绑定的上下文对象 279 | * @describe 如果 context 为 undefined 则context = obj 280 | */ 281 | function bindAll(fns, obj, context){ 282 | var index = 0, len = fns.length; 283 | if(context === undefined){ 284 | context = obj; 285 | } 286 | 287 | for(index; index < len; index++){ 288 | var key = fns[index]; 289 | if(typeof obj[key] === 'function'){ 290 | obj[key] = b(obj[key], context); 291 | } 292 | } 293 | function b(func, context){ 294 | return function(){ 295 | return func.apply(context, asArray(arguments, 0)); 296 | } 297 | } 298 | } 299 | 300 | window.pullload = pullload; 301 | //增加 require 支持 302 | if ( typeof define === "function" && define.amd ) { 303 | define( "pullload", [], function () { return pullload; }); 304 | } 305 | 306 | })(); -------------------------------------------------------------------------------- /build/js/require-config.js: -------------------------------------------------------------------------------- 1 | var config = { 2 | baseUrl: "js/", //依赖相对路径 3 | paths: { //如果某个前缀的依赖不是按照baseUrl拼接这么简单,就需要在这里指出 4 | zepto: 'zepto.min', 5 | jquery: 'jquery-2.2.2.min' 6 | }, 7 | shim: { //引入没有使用requirejs模块写法的类库。backbone依赖underscore 8 | 'zepto': { 9 | exports: '$' 10 | }, 11 | 'jquery': { 12 | exports: '$' 13 | } 14 | } 15 | }; 16 | 17 | require.config(config); 18 | -------------------------------------------------------------------------------- /build/js/zepto.min.js: -------------------------------------------------------------------------------- 1 | /* Zepto 1.1.6 - zepto event ajax form detect fx fx_methods data deferred callbacks selector touch gesture - zeptojs.com/license */ 2 | var Zepto=function(){function A(t){return null==t?String(t):S[j.call(t)]||"object"}function D(t){return"function"==A(t)}function Z(t){return null!=t&&t==t.window}function L(t){return null!=t&&t.nodeType==t.DOCUMENT_NODE}function F(t){return"object"==A(t)}function $(t){return F(t)&&!Z(t)&&Object.getPrototypeOf(t)==Object.prototype}function _(t){return"number"==typeof t.length}function R(t){return s.call(t,function(t){return null!=t})}function z(t){return t.length>0?n.fn.concat.apply([],t):t}function q(t){return t.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}function I(t){return t in c?c[t]:c[t]=new RegExp("(^|\\s)"+t+"(\\s|$)")}function W(t,e){return"number"!=typeof e||l[q(t)]?e:e+"px"}function B(t){var e,n;return f[t]||(e=u.createElement(t),u.body.appendChild(e),n=getComputedStyle(e,"").getPropertyValue("display"),e.parentNode.removeChild(e),"none"==n&&(n="block"),f[t]=n),f[t]}function V(t){return"children"in t?a.call(t.children):n.map(t.childNodes,function(t){return 1==t.nodeType?t:void 0})}function H(t,e){var n,i=t?t.length:0;for(n=0;i>n;n++)this[n]=t[n];this.length=i,this.selector=e||""}function U(n,i,r){for(e in i)r&&($(i[e])||k(i[e]))?($(i[e])&&!$(n[e])&&(n[e]={}),k(i[e])&&!k(n[e])&&(n[e]=[]),U(n[e],i[e],r)):i[e]!==t&&(n[e]=i[e])}function X(t,e){return null==e?n(t):n(t).filter(e)}function Y(t,e,n,i){return D(e)?e.call(t,n,i):e}function J(t,e,n){null==n?t.removeAttribute(e):t.setAttribute(e,n)}function G(e,n){var i=e.className||"",r=i&&i.baseVal!==t;return n===t?r?i.baseVal:i:void(r?i.baseVal=n:e.className=n)}function K(t){try{return t?"true"==t||("false"==t?!1:"null"==t?null:+t+""==t?+t:/^[\[\{]/.test(t)?n.parseJSON(t):t):t}catch(e){return t}}function Q(t,e){e(t);for(var n=0,i=t.childNodes.length;i>n;n++)Q(t.childNodes[n],e)}var t,e,n,i,P,O,r=[],o=r.concat,s=r.filter,a=r.slice,u=window.document,f={},c={},l={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},h=/^\s*<(\w+|!)[^>]*>/,p=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,d=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,m=/^(?:body|html)$/i,g=/([A-Z])/g,v=["val","css","html","text","data","width","height","offset"],y=["after","prepend","before","append"],b=u.createElement("table"),w=u.createElement("tr"),x={tr:u.createElement("tbody"),tbody:b,thead:b,tfoot:b,td:w,th:w,"*":u.createElement("div")},E=/complete|loaded|interactive/,T=/^[\w-]*$/,S={},j=S.toString,C={},N=u.createElement("div"),M={tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},k=Array.isArray||function(t){return t instanceof Array};return C.matches=function(t,e){if(!e||!t||1!==t.nodeType)return!1;var n=t.webkitMatchesSelector||t.mozMatchesSelector||t.oMatchesSelector||t.matchesSelector;if(n)return n.call(t,e);var i,r=t.parentNode,o=!r;return o&&(r=N).appendChild(t),i=~C.qsa(r,e).indexOf(t),o&&N.removeChild(t),i},P=function(t){return t.replace(/-+(.)?/g,function(t,e){return e?e.toUpperCase():""})},O=function(t){return s.call(t,function(e,n){return t.indexOf(e)==n})},C.fragment=function(e,i,r){var o,s,f;return p.test(e)&&(o=n(u.createElement(RegExp.$1))),o||(e.replace&&(e=e.replace(d,"<$1>")),i===t&&(i=h.test(e)&&RegExp.$1),i in x||(i="*"),f=x[i],f.innerHTML=""+e,o=n.each(a.call(f.childNodes),function(){f.removeChild(this)})),$(r)&&(s=n(o),n.each(r,function(t,e){v.indexOf(t)>-1?s[t](e):s.attr(t,e)})),o},C.Z=function(t,e){return new H(t,e)},C.isZ=function(t){return t instanceof C.Z},C.init=function(e,i){var r;if(!e)return C.Z();if("string"==typeof e)if(e=e.trim(),"<"==e[0]&&h.test(e))r=C.fragment(e,RegExp.$1,i),e=null;else{if(i!==t)return n(i).find(e);r=C.qsa(u,e)}else{if(D(e))return n(u).ready(e);if(C.isZ(e))return e;if(k(e))r=R(e);else if(F(e))r=[e],e=null;else if(h.test(e))r=C.fragment(e.trim(),RegExp.$1,i),e=null;else{if(i!==t)return n(i).find(e);r=C.qsa(u,e)}}return C.Z(r,e)},n=function(t,e){return C.init(t,e)},n.extend=function(t){var e,n=a.call(arguments,1);return"boolean"==typeof t&&(e=t,t=n.shift()),n.forEach(function(n){U(t,n,e)}),t},C.qsa=function(t,e){var n,i="#"==e[0],r=!i&&"."==e[0],o=i||r?e.slice(1):e,s=T.test(o);return t.getElementById&&s&&i?(n=t.getElementById(o))?[n]:[]:1!==t.nodeType&&9!==t.nodeType&&11!==t.nodeType?[]:a.call(s&&!i&&t.getElementsByClassName?r?t.getElementsByClassName(o):t.getElementsByTagName(e):t.querySelectorAll(e))},n.contains=u.documentElement.contains?function(t,e){return t!==e&&t.contains(e)}:function(t,e){for(;e&&(e=e.parentNode);)if(e===t)return!0;return!1},n.type=A,n.isFunction=D,n.isWindow=Z,n.isArray=k,n.isPlainObject=$,n.isEmptyObject=function(t){var e;for(e in t)return!1;return!0},n.inArray=function(t,e,n){return r.indexOf.call(e,t,n)},n.camelCase=P,n.trim=function(t){return null==t?"":String.prototype.trim.call(t)},n.uuid=0,n.support={},n.expr={},n.noop=function(){},n.map=function(t,e){var n,r,o,i=[];if(_(t))for(r=0;r=0?e:e+this.length]},toArray:function(){return this.get()},size:function(){return this.length},remove:function(){return this.each(function(){null!=this.parentNode&&this.parentNode.removeChild(this)})},each:function(t){return r.every.call(this,function(e,n){return t.call(e,n,e)!==!1}),this},filter:function(t){return D(t)?this.not(this.not(t)):n(s.call(this,function(e){return C.matches(e,t)}))},add:function(t,e){return n(O(this.concat(n(t,e))))},is:function(t){return this.length>0&&C.matches(this[0],t)},not:function(e){var i=[];if(D(e)&&e.call!==t)this.each(function(t){e.call(this,t)||i.push(this)});else{var r="string"==typeof e?this.filter(e):_(e)&&D(e.item)?a.call(e):n(e);this.forEach(function(t){r.indexOf(t)<0&&i.push(t)})}return n(i)},has:function(t){return this.filter(function(){return F(t)?n.contains(this,t):n(this).find(t).size()})},eq:function(t){return-1===t?this.slice(t):this.slice(t,+t+1)},first:function(){var t=this[0];return t&&!F(t)?t:n(t)},last:function(){var t=this[this.length-1];return t&&!F(t)?t:n(t)},find:function(t){var e,i=this;return e=t?"object"==typeof t?n(t).filter(function(){var t=this;return r.some.call(i,function(e){return n.contains(e,t)})}):1==this.length?n(C.qsa(this[0],t)):this.map(function(){return C.qsa(this,t)}):n()},closest:function(t,e){var i=this[0],r=!1;for("object"==typeof t&&(r=n(t));i&&!(r?r.indexOf(i)>=0:C.matches(i,t));)i=i!==e&&!L(i)&&i.parentNode;return n(i)},parents:function(t){for(var e=[],i=this;i.length>0;)i=n.map(i,function(t){return(t=t.parentNode)&&!L(t)&&e.indexOf(t)<0?(e.push(t),t):void 0});return X(e,t)},parent:function(t){return X(O(this.pluck("parentNode")),t)},children:function(t){return X(this.map(function(){return V(this)}),t)},contents:function(){return this.map(function(){return this.contentDocument||a.call(this.childNodes)})},siblings:function(t){return X(this.map(function(t,e){return s.call(V(e.parentNode),function(t){return t!==e})}),t)},empty:function(){return this.each(function(){this.innerHTML=""})},pluck:function(t){return n.map(this,function(e){return e[t]})},show:function(){return this.each(function(){"none"==this.style.display&&(this.style.display=""),"none"==getComputedStyle(this,"").getPropertyValue("display")&&(this.style.display=B(this.nodeName))})},replaceWith:function(t){return this.before(t).remove()},wrap:function(t){var e=D(t);if(this[0]&&!e)var i=n(t).get(0),r=i.parentNode||this.length>1;return this.each(function(o){n(this).wrapAll(e?t.call(this,o):r?i.cloneNode(!0):i)})},wrapAll:function(t){if(this[0]){n(this[0]).before(t=n(t));for(var e;(e=t.children()).length;)t=e.first();n(t).append(this)}return this},wrapInner:function(t){var e=D(t);return this.each(function(i){var r=n(this),o=r.contents(),s=e?t.call(this,i):t;o.length?o.wrapAll(s):r.append(s)})},unwrap:function(){return this.parent().each(function(){n(this).replaceWith(n(this).children())}),this},clone:function(){return this.map(function(){return this.cloneNode(!0)})},hide:function(){return this.css("display","none")},toggle:function(e){return this.each(function(){var i=n(this);(e===t?"none"==i.css("display"):e)?i.show():i.hide()})},prev:function(t){return n(this.pluck("previousElementSibling")).filter(t||"*")},next:function(t){return n(this.pluck("nextElementSibling")).filter(t||"*")},html:function(t){return 0 in arguments?this.each(function(e){var i=this.innerHTML;n(this).empty().append(Y(this,t,e,i))}):0 in this?this[0].innerHTML:null},text:function(t){return 0 in arguments?this.each(function(e){var n=Y(this,t,e,this.textContent);this.textContent=null==n?"":""+n}):0 in this?this.pluck("textContent").join(""):null},attr:function(n,i){var r;return"string"!=typeof n||1 in arguments?this.each(function(t){if(1===this.nodeType)if(F(n))for(e in n)J(this,e,n[e]);else J(this,n,Y(this,i,t,this.getAttribute(n)))}):this.length&&1===this[0].nodeType?!(r=this[0].getAttribute(n))&&n in this[0]?this[0][n]:r:t},removeAttr:function(t){return this.each(function(){1===this.nodeType&&t.split(" ").forEach(function(t){J(this,t)},this)})},prop:function(t,e){return t=M[t]||t,1 in arguments?this.each(function(n){this[t]=Y(this,e,n,this[t])}):this[0]&&this[0][t]},data:function(e,n){var i="data-"+e.replace(g,"-$1").toLowerCase(),r=1 in arguments?this.attr(i,n):this.attr(i);return null!==r?K(r):t},val:function(t){return 0 in arguments?this.each(function(e){this.value=Y(this,t,e,this.value)}):this[0]&&(this[0].multiple?n(this[0]).find("option").filter(function(){return this.selected}).pluck("value"):this[0].value)},offset:function(t){if(t)return this.each(function(e){var i=n(this),r=Y(this,t,e,i.offset()),o=i.offsetParent().offset(),s={top:r.top-o.top,left:r.left-o.left};"static"==i.css("position")&&(s.position="relative"),i.css(s)});if(!this.length)return null;if(!n.contains(u.documentElement,this[0]))return{top:0,left:0};var e=this[0].getBoundingClientRect();return{left:e.left+window.pageXOffset,top:e.top+window.pageYOffset,width:Math.round(e.width),height:Math.round(e.height)}},css:function(t,i){if(arguments.length<2){var r,o=this[0];if(!o)return;if(r=getComputedStyle(o,""),"string"==typeof t)return o.style[P(t)]||r.getPropertyValue(t);if(k(t)){var s={};return n.each(t,function(t,e){s[e]=o.style[P(e)]||r.getPropertyValue(e)}),s}}var a="";if("string"==A(t))i||0===i?a=q(t)+":"+W(t,i):this.each(function(){this.style.removeProperty(q(t))});else for(e in t)t[e]||0===t[e]?a+=q(e)+":"+W(e,t[e])+";":this.each(function(){this.style.removeProperty(q(e))});return this.each(function(){this.style.cssText+=";"+a})},index:function(t){return t?this.indexOf(n(t)[0]):this.parent().children().indexOf(this[0])},hasClass:function(t){return t?r.some.call(this,function(t){return this.test(G(t))},I(t)):!1},addClass:function(t){return t?this.each(function(e){if("className"in this){i=[];var r=G(this),o=Y(this,t,e,r);o.split(/\s+/g).forEach(function(t){n(this).hasClass(t)||i.push(t)},this),i.length&&G(this,r+(r?" ":"")+i.join(" "))}}):this},removeClass:function(e){return this.each(function(n){if("className"in this){if(e===t)return G(this,"");i=G(this),Y(this,e,n,i).split(/\s+/g).forEach(function(t){i=i.replace(I(t)," ")}),G(this,i.trim())}})},toggleClass:function(e,i){return e?this.each(function(r){var o=n(this),s=Y(this,e,r,G(this));s.split(/\s+/g).forEach(function(e){(i===t?!o.hasClass(e):i)?o.addClass(e):o.removeClass(e)})}):this},scrollTop:function(e){if(this.length){var n="scrollTop"in this[0];return e===t?n?this[0].scrollTop:this[0].pageYOffset:this.each(n?function(){this.scrollTop=e}:function(){this.scrollTo(this.scrollX,e)})}},scrollLeft:function(e){if(this.length){var n="scrollLeft"in this[0];return e===t?n?this[0].scrollLeft:this[0].pageXOffset:this.each(n?function(){this.scrollLeft=e}:function(){this.scrollTo(e,this.scrollY)})}},position:function(){if(this.length){var t=this[0],e=this.offsetParent(),i=this.offset(),r=m.test(e[0].nodeName)?{top:0,left:0}:e.offset();return i.top-=parseFloat(n(t).css("margin-top"))||0,i.left-=parseFloat(n(t).css("margin-left"))||0,r.top+=parseFloat(n(e[0]).css("border-top-width"))||0,r.left+=parseFloat(n(e[0]).css("border-left-width"))||0,{top:i.top-r.top,left:i.left-r.left}}},offsetParent:function(){return this.map(function(){for(var t=this.offsetParent||u.body;t&&!m.test(t.nodeName)&&"static"==n(t).css("position");)t=t.offsetParent;return t})}},n.fn.detach=n.fn.remove,["width","height"].forEach(function(e){var i=e.replace(/./,function(t){return t[0].toUpperCase()});n.fn[e]=function(r){var o,s=this[0];return r===t?Z(s)?s["inner"+i]:L(s)?s.documentElement["scroll"+i]:(o=this.offset())&&o[e]:this.each(function(t){s=n(this),s.css(e,Y(this,r,t,s[e]()))})}}),y.forEach(function(t,e){var i=e%2;n.fn[t]=function(){var t,o,r=n.map(arguments,function(e){return t=A(e),"object"==t||"array"==t||null==e?e:C.fragment(e)}),s=this.length>1;return r.length<1?this:this.each(function(t,a){o=i?a:a.parentNode,a=0==e?a.nextSibling:1==e?a.firstChild:2==e?a:null;var f=n.contains(u.documentElement,o);r.forEach(function(t){if(s)t=t.cloneNode(!0);else if(!o)return n(t).remove();o.insertBefore(t,a),f&&Q(t,function(t){null==t.nodeName||"SCRIPT"!==t.nodeName.toUpperCase()||t.type&&"text/javascript"!==t.type||t.src||window.eval.call(window,t.innerHTML)})})})},n.fn[i?t+"To":"insert"+(e?"Before":"After")]=function(e){return n(e)[t](this),this}}),C.Z.prototype=H.prototype=n.fn,C.uniq=O,C.deserializeValue=K,n.zepto=C,n}();window.Zepto=Zepto,void 0===window.$&&(window.$=Zepto),function(t){function l(t){return t._zid||(t._zid=e++)}function h(t,e,n,i){if(e=p(e),e.ns)var r=d(e.ns);return(s[l(t)]||[]).filter(function(t){return t&&(!e.e||t.e==e.e)&&(!e.ns||r.test(t.ns))&&(!n||l(t.fn)===l(n))&&(!i||t.sel==i)})}function p(t){var e=(""+t).split(".");return{e:e[0],ns:e.slice(1).sort().join(" ")}}function d(t){return new RegExp("(?:^| )"+t.replace(" "," .* ?")+"(?: |$)")}function m(t,e){return t.del&&!u&&t.e in f||!!e}function g(t){return c[t]||u&&f[t]||t}function v(e,i,r,o,a,u,f){var h=l(e),d=s[h]||(s[h]=[]);i.split(/\s/).forEach(function(i){if("ready"==i)return t(document).ready(r);var s=p(i);s.fn=r,s.sel=a,s.e in c&&(r=function(e){var n=e.relatedTarget;return!n||n!==this&&!t.contains(this,n)?s.fn.apply(this,arguments):void 0}),s.del=u;var l=u||r;s.proxy=function(t){if(t=T(t),!t.isImmediatePropagationStopped()){t.data=o;var i=l.apply(e,t._args==n?[t]:[t].concat(t._args));return i===!1&&(t.preventDefault(),t.stopPropagation()),i}},s.i=d.length,d.push(s),"addEventListener"in e&&e.addEventListener(g(s.e),s.proxy,m(s,f))})}function y(t,e,n,i,r){var o=l(t);(e||"").split(/\s/).forEach(function(e){h(t,e,n,i).forEach(function(e){delete s[o][e.i],"removeEventListener"in t&&t.removeEventListener(g(e.e),e.proxy,m(e,r))})})}function T(e,i){return(i||!e.isDefaultPrevented)&&(i||(i=e),t.each(E,function(t,n){var r=i[t];e[t]=function(){return this[n]=b,r&&r.apply(i,arguments)},e[n]=w}),(i.defaultPrevented!==n?i.defaultPrevented:"returnValue"in i?i.returnValue===!1:i.getPreventDefault&&i.getPreventDefault())&&(e.isDefaultPrevented=b)),e}function S(t){var e,i={originalEvent:t};for(e in t)x.test(e)||t[e]===n||(i[e]=t[e]);return T(i,t)}var n,e=1,i=Array.prototype.slice,r=t.isFunction,o=function(t){return"string"==typeof t},s={},a={},u="onfocusin"in window,f={focus:"focusin",blur:"focusout"},c={mouseenter:"mouseover",mouseleave:"mouseout"};a.click=a.mousedown=a.mouseup=a.mousemove="MouseEvents",t.event={add:v,remove:y},t.proxy=function(e,n){var s=2 in arguments&&i.call(arguments,2);if(r(e)){var a=function(){return e.apply(n,s?s.concat(i.call(arguments)):arguments)};return a._zid=l(e),a}if(o(n))return s?(s.unshift(e[n],e),t.proxy.apply(null,s)):t.proxy(e[n],e);throw new TypeError("expected function")},t.fn.bind=function(t,e,n){return this.on(t,e,n)},t.fn.unbind=function(t,e){return this.off(t,e)},t.fn.one=function(t,e,n,i){return this.on(t,e,n,i,1)};var b=function(){return!0},w=function(){return!1},x=/^([A-Z]|returnValue$|layer[XY]$)/,E={preventDefault:"isDefaultPrevented",stopImmediatePropagation:"isImmediatePropagationStopped",stopPropagation:"isPropagationStopped"};t.fn.delegate=function(t,e,n){return this.on(e,t,n)},t.fn.undelegate=function(t,e,n){return this.off(e,t,n)},t.fn.live=function(e,n){return t(document.body).delegate(this.selector,e,n),this},t.fn.die=function(e,n){return t(document.body).undelegate(this.selector,e,n),this},t.fn.on=function(e,s,a,u,f){var c,l,h=this;return e&&!o(e)?(t.each(e,function(t,e){h.on(t,s,a,e,f)}),h):(o(s)||r(u)||u===!1||(u=a,a=s,s=n),(u===n||a===!1)&&(u=a,a=n),u===!1&&(u=w),h.each(function(n,r){f&&(c=function(t){return y(r,t.type,u),u.apply(this,arguments)}),s&&(l=function(e){var n,o=t(e.target).closest(s,r).get(0);return o&&o!==r?(n=t.extend(S(e),{currentTarget:o,liveFired:r}),(c||u).apply(o,[n].concat(i.call(arguments,1)))):void 0}),v(r,e,u,a,s,l||c)}))},t.fn.off=function(e,i,s){var a=this;return e&&!o(e)?(t.each(e,function(t,e){a.off(t,i,e)}),a):(o(i)||r(s)||s===!1||(s=i,i=n),s===!1&&(s=w),a.each(function(){y(this,e,s,i)}))},t.fn.trigger=function(e,n){return e=o(e)||t.isPlainObject(e)?t.Event(e):T(e),e._args=n,this.each(function(){e.type in f&&"function"==typeof this[e.type]?this[e.type]():"dispatchEvent"in this?this.dispatchEvent(e):t(this).triggerHandler(e,n)})},t.fn.triggerHandler=function(e,n){var i,r;return this.each(function(s,a){i=S(o(e)?t.Event(e):e),i._args=n,i.target=a,t.each(h(a,e.type||e),function(t,e){return r=e.proxy(i),i.isImmediatePropagationStopped()?!1:void 0})}),r},"focusin focusout focus blur load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select keydown keypress keyup error".split(" ").forEach(function(e){t.fn[e]=function(t){return 0 in arguments?this.bind(e,t):this.trigger(e)}}),t.Event=function(t,e){o(t)||(e=t,t=e.type);var n=document.createEvent(a[t]||"Events"),i=!0;if(e)for(var r in e)"bubbles"==r?i=!!e[r]:n[r]=e[r];return n.initEvent(t,i,!0),T(n)}}(Zepto),function(t){function h(e,n,i){var r=t.Event(n);return t(e).trigger(r,i),!r.isDefaultPrevented()}function p(t,e,i,r){return t.global?h(e||n,i,r):void 0}function d(e){e.global&&0===t.active++&&p(e,null,"ajaxStart")}function m(e){e.global&&!--t.active&&p(e,null,"ajaxStop")}function g(t,e){var n=e.context;return e.beforeSend.call(n,t,e)===!1||p(e,n,"ajaxBeforeSend",[t,e])===!1?!1:void p(e,n,"ajaxSend",[t,e])}function v(t,e,n,i){var r=n.context,o="success";n.success.call(r,t,o,e),i&&i.resolveWith(r,[t,o,e]),p(n,r,"ajaxSuccess",[e,n,t]),b(o,e,n)}function y(t,e,n,i,r){var o=i.context;i.error.call(o,n,e,t),r&&r.rejectWith(o,[n,e,t]),p(i,o,"ajaxError",[n,i,t||e]),b(e,n,i)}function b(t,e,n){var i=n.context;n.complete.call(i,e,t),p(n,i,"ajaxComplete",[e,n]),m(n)}function w(){}function x(t){return t&&(t=t.split(";",2)[0]),t&&(t==f?"html":t==u?"json":s.test(t)?"script":a.test(t)&&"xml")||"text"}function E(t,e){return""==e?t:(t+"&"+e).replace(/[&?]{1,2}/,"?")}function T(e){e.processData&&e.data&&"string"!=t.type(e.data)&&(e.data=t.param(e.data,e.traditional)),!e.data||e.type&&"GET"!=e.type.toUpperCase()||(e.url=E(e.url,e.data),e.data=void 0)}function S(e,n,i,r){return t.isFunction(n)&&(r=i,i=n,n=void 0),t.isFunction(i)||(r=i,i=void 0),{url:e,data:n,success:i,dataType:r}}function C(e,n,i,r){var o,s=t.isArray(n),a=t.isPlainObject(n);t.each(n,function(n,u){o=t.type(u),r&&(n=i?r:r+"["+(a||"object"==o||"array"==o?n:"")+"]"),!r&&s?e.add(u.name,u.value):"array"==o||!i&&"object"==o?C(e,u,i,n):e.add(n,u)})}var i,r,e=0,n=window.document,o=/)<[^<]*)*<\/script>/gi,s=/^(?:text|application)\/javascript/i,a=/^(?:text|application)\/xml/i,u="application/json",f="text/html",c=/^\s*$/,l=n.createElement("a");l.href=window.location.href,t.active=0,t.ajaxJSONP=function(i,r){if(!("type"in i))return t.ajax(i);var f,h,o=i.jsonpCallback,s=(t.isFunction(o)?o():o)||"jsonp"+ ++e,a=n.createElement("script"),u=window[s],c=function(e){t(a).triggerHandler("error",e||"abort")},l={abort:c};return r&&r.promise(l),t(a).on("load error",function(e,n){clearTimeout(h),t(a).off().remove(),"error"!=e.type&&f?v(f[0],l,i,r):y(null,n||"error",l,i,r),window[s]=u,f&&t.isFunction(u)&&u(f[0]),u=f=void 0}),g(l,i)===!1?(c("abort"),l):(window[s]=function(){f=arguments},a.src=i.url.replace(/\?(.+)=\?/,"?$1="+s),n.head.appendChild(a),i.timeout>0&&(h=setTimeout(function(){c("timeout")},i.timeout)),l)},t.ajaxSettings={type:"GET",beforeSend:w,success:w,error:w,complete:w,context:null,global:!0,xhr:function(){return new window.XMLHttpRequest},accepts:{script:"text/javascript, application/javascript, application/x-javascript",json:u,xml:"application/xml, text/xml",html:f,text:"text/plain"},crossDomain:!1,timeout:0,processData:!0,cache:!0},t.ajax=function(e){var a,u,o=t.extend({},e||{}),s=t.Deferred&&t.Deferred();for(i in t.ajaxSettings)void 0===o[i]&&(o[i]=t.ajaxSettings[i]);d(o),o.crossDomain||(a=n.createElement("a"),a.href=o.url,a.href=a.href,o.crossDomain=l.protocol+"//"+l.host!=a.protocol+"//"+a.host),o.url||(o.url=window.location.toString()),(u=o.url.indexOf("#"))>-1&&(o.url=o.url.slice(0,u)),T(o);var f=o.dataType,h=/\?.+=\?/.test(o.url);if(h&&(f="jsonp"),o.cache!==!1&&(e&&e.cache===!0||"script"!=f&&"jsonp"!=f)||(o.url=E(o.url,"_="+Date.now())),"jsonp"==f)return h||(o.url=E(o.url,o.jsonp?o.jsonp+"=?":o.jsonp===!1?"":"callback=?")),t.ajaxJSONP(o,s);var P,p=o.accepts[f],m={},b=function(t,e){m[t.toLowerCase()]=[t,e]},S=/^([\w-]+:)\/\//.test(o.url)?RegExp.$1:window.location.protocol,j=o.xhr(),C=j.setRequestHeader;if(s&&s.promise(j),o.crossDomain||b("X-Requested-With","XMLHttpRequest"),b("Accept",p||"*/*"),(p=o.mimeType||p)&&(p.indexOf(",")>-1&&(p=p.split(",",2)[0]),j.overrideMimeType&&j.overrideMimeType(p)),(o.contentType||o.contentType!==!1&&o.data&&"GET"!=o.type.toUpperCase())&&b("Content-Type",o.contentType||"application/x-www-form-urlencoded"),o.headers)for(r in o.headers)b(r,o.headers[r]);if(j.setRequestHeader=b,j.onreadystatechange=function(){if(4==j.readyState){j.onreadystatechange=w,clearTimeout(P);var e,n=!1;if(j.status>=200&&j.status<300||304==j.status||0==j.status&&"file:"==S){if(f=f||x(o.mimeType||j.getResponseHeader("content-type")),"arraybuffer"==j.responseType||"blob"==j.responseType)e=j.response;else{e=j.responseText;try{"script"==f?(1,eval)(e):"xml"==f?e=j.responseXML:"json"==f&&(e=c.test(e)?null:t.parseJSON(e))}catch(i){n=i}if(n)return y(n,"parsererror",j,o,s)}v(e,j,o,s)}else y(j.statusText||null,j.status?"error":"abort",j,o,s)}},g(j,o)===!1)return j.abort(),y(null,"abort",j,o,s),j;if(o.xhrFields)for(r in o.xhrFields)j[r]=o.xhrFields[r];var O="async"in o?o.async:!0;j.open(o.type,o.url,O,o.username,o.password);for(r in m)C.apply(j,m[r]);return o.timeout>0&&(P=setTimeout(function(){j.onreadystatechange=w,j.abort(),y(null,"timeout",j,o,s)},o.timeout)),j.send(o.data?o.data:null),j},t.get=function(){return t.ajax(S.apply(null,arguments))},t.post=function(){var e=S.apply(null,arguments);return e.type="POST",t.ajax(e)},t.getJSON=function(){var e=S.apply(null,arguments);return e.dataType="json",t.ajax(e)},t.fn.load=function(e,n,i){if(!this.length)return this;var a,r=this,s=e.split(/\s/),u=S(e,n,i),f=u.success;return s.length>1&&(u.url=s[0],a=s[1]),u.success=function(e){r.html(a?t("
").html(e.replace(o,"")).find(a):e),f&&f.apply(r,arguments)},t.ajax(u),this};var j=encodeURIComponent;t.param=function(e,n){var i=[];return i.add=function(e,n){t.isFunction(n)&&(n=n()),null==n&&(n=""),this.push(j(e)+"="+j(n))},C(i,e,n),i.join("&").replace(/%20/g,"+")}}(Zepto),function(t){t.fn.serializeArray=function(){var e,n,i=[],r=function(t){return t.forEach?t.forEach(r):void i.push({name:e,value:t})};return this[0]&&t.each(this[0].elements,function(i,o){n=o.type,e=o.name,e&&"fieldset"!=o.nodeName.toLowerCase()&&!o.disabled&&"submit"!=n&&"reset"!=n&&"button"!=n&&"file"!=n&&("radio"!=n&&"checkbox"!=n||o.checked)&&r(t(o).val())}),i},t.fn.serialize=function(){var t=[];return this.serializeArray().forEach(function(e){t.push(encodeURIComponent(e.name)+"="+encodeURIComponent(e.value))}),t.join("&")},t.fn.submit=function(e){if(0 in arguments)this.bind("submit",e);else if(this.length){var n=t.Event("submit");this.eq(0).trigger(n),n.isDefaultPrevented()||this.get(0).submit()}return this}}(Zepto),function(t){function e(t,e){var n=this.os={},i=this.browser={},r=t.match(/Web[kK]it[\/]{0,1}([\d.]+)/),o=t.match(/(Android);?[\s\/]+([\d.]+)?/),s=!!t.match(/\(Macintosh\; Intel /),a=t.match(/(iPad).*OS\s([\d_]+)/),u=t.match(/(iPod)(.*OS\s([\d_]+))?/),f=!a&&t.match(/(iPhone\sOS)\s([\d_]+)/),c=t.match(/(webOS|hpwOS)[\s\/]([\d.]+)/),l=/Win\d{2}|Windows/.test(e),h=t.match(/Windows Phone ([\d.]+)/),p=c&&t.match(/TouchPad/),d=t.match(/Kindle\/([\d.]+)/),m=t.match(/Silk\/([\d._]+)/),g=t.match(/(BlackBerry).*Version\/([\d.]+)/),v=t.match(/(BB10).*Version\/([\d.]+)/),y=t.match(/(RIM\sTablet\sOS)\s([\d.]+)/),b=t.match(/PlayBook/),w=t.match(/Chrome\/([\d.]+)/)||t.match(/CriOS\/([\d.]+)/),x=t.match(/Firefox\/([\d.]+)/),E=t.match(/\((?:Mobile|Tablet); rv:([\d.]+)\).*Firefox\/[\d.]+/),T=t.match(/MSIE\s([\d.]+)/)||t.match(/Trident\/[\d](?=[^\?]+).*rv:([0-9.].)/),S=!w&&t.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/),j=S||t.match(/Version\/([\d.]+)([^S](Safari)|[^M]*(Mobile)[^S]*(Safari))/);(i.webkit=!!r)&&(i.version=r[1]),o&&(n.android=!0,n.version=o[2]),f&&!u&&(n.ios=n.iphone=!0,n.version=f[2].replace(/_/g,".")),a&&(n.ios=n.ipad=!0,n.version=a[2].replace(/_/g,".")),u&&(n.ios=n.ipod=!0,n.version=u[3]?u[3].replace(/_/g,"."):null),h&&(n.wp=!0,n.version=h[1]),c&&(n.webos=!0,n.version=c[2]),p&&(n.touchpad=!0),g&&(n.blackberry=!0,n.version=g[2]),v&&(n.bb10=!0,n.version=v[2]),y&&(n.rimtabletos=!0,n.version=y[2]),b&&(i.playbook=!0),d&&(n.kindle=!0,n.version=d[1]),m&&(i.silk=!0,i.version=m[1]),!m&&n.android&&t.match(/Kindle Fire/)&&(i.silk=!0),w&&(i.chrome=!0,i.version=w[1]),x&&(i.firefox=!0,i.version=x[1]),E&&(n.firefoxos=!0,n.version=E[1]),T&&(i.ie=!0,i.version=T[1]),j&&(s||n.ios||l)&&(i.safari=!0,n.ios||(i.version=j[1])),S&&(i.webview=!0),n.tablet=!!(a||b||o&&!t.match(/Mobile/)||x&&t.match(/Tablet/)||T&&!t.match(/Phone/)&&t.match(/Touch/)),n.phone=!(n.tablet||n.ipod||!(o||f||c||g||v||w&&t.match(/Android/)||w&&t.match(/CriOS\/([\d.]+)/)||x&&t.match(/Mobile/)||T&&t.match(/Touch/)))}e.call(t,navigator.userAgent,navigator.platform),t.__detect=e}(Zepto),function(t,e){function v(t){return t.replace(/([a-z])([A-Z])/,"$1-$2").toLowerCase()}function y(t){return i?i+t:t.toLowerCase()}var i,a,u,f,c,l,h,p,d,m,n="",r={Webkit:"webkit",Moz:"",O:"o"},o=document.createElement("div"),s=/^((translate|rotate|scale)(X|Y|Z|3d)?|matrix(3d)?|perspective|skew(X|Y)?)$/i,g={};t.each(r,function(t,r){return o.style[t+"TransitionProperty"]!==e?(n="-"+t.toLowerCase()+"-",i=r,!1):void 0}),a=n+"transform",g[u=n+"transition-property"]=g[f=n+"transition-duration"]=g[l=n+"transition-delay"]=g[c=n+"transition-timing-function"]=g[h=n+"animation-name"]=g[p=n+"animation-duration"]=g[m=n+"animation-delay"]=g[d=n+"animation-timing-function"]="",t.fx={off:i===e&&o.style.transitionProperty===e,speeds:{_default:400,fast:200,slow:600},cssPrefix:n,transitionEnd:y("TransitionEnd"),animationEnd:y("AnimationEnd")},t.fn.animate=function(n,i,r,o,s){return t.isFunction(i)&&(o=i,r=e,i=e),t.isFunction(r)&&(o=r,r=e),t.isPlainObject(i)&&(r=i.easing,o=i.complete,s=i.delay,i=i.duration),i&&(i=("number"==typeof i?i:t.fx.speeds[i]||t.fx.speeds._default)/1e3),s&&(s=parseFloat(s)/1e3),this.anim(n,i,r,o,s)},t.fn.anim=function(n,i,r,o,y){var b,x,S,w={},E="",T=this,j=t.fx.transitionEnd,C=!1;if(i===e&&(i=t.fx.speeds._default/1e3),y===e&&(y=0),t.fx.off&&(i=0),"string"==typeof n)w[h]=n,w[p]=i+"s",w[m]=y+"s",w[d]=r||"linear",j=t.fx.animationEnd;else{x=[];for(b in n)s.test(b)?E+=b+"("+n[b]+") ":(w[b]=n[b],x.push(v(b)));E&&(w[a]=E,x.push(a)),i>0&&"object"==typeof n&&(w[u]=x.join(", "),w[f]=i+"s",w[l]=y+"s",w[c]=r||"linear")}return S=function(e){if("undefined"!=typeof e){if(e.target!==e.currentTarget)return;t(e.target).unbind(j,S)}else t(this).unbind(j,S);C=!0,t(this).css(g),o&&o.call(this)},i>0&&(this.bind(j,S),setTimeout(function(){C||S.call(T)},1e3*(i+y)+25)),this.size()&&this.get(0).clientLeft,this.css(w),0>=i&&setTimeout(function(){T.each(function(){S.call(this)})},0),this},o=null}(Zepto),function(t,e){function a(n,i,r,o,s){"function"!=typeof i||s||(s=i,i=e);var a={opacity:r};return o&&(a.scale=o,n.css(t.fx.cssPrefix+"transform-origin","0 0")),n.animate(a,i,null,s)}function u(e,n,i,r){return a(e,n,0,i,function(){o.call(t(this)),r&&r.call(this)})}var n=window.document,r=(n.documentElement,t.fn.show),o=t.fn.hide,s=t.fn.toggle;t.fn.show=function(t,n){return r.call(this),t===e?t=0:this.css("opacity",0),a(this,t,1,"1,1",n)},t.fn.hide=function(t,n){return t===e?o.call(this):u(this,t,"0,0",n)},t.fn.toggle=function(n,i){return n===e||"boolean"==typeof n?s.call(this,n):this.each(function(){var e=t(this);e["none"==e.css("display")?"show":"hide"](n,i)})},t.fn.fadeTo=function(t,e,n){return a(this,t,e,null,n)},t.fn.fadeIn=function(t,e){var n=this.css("opacity");return n>0?this.css("opacity",0):n=1,r.call(this).fadeTo(t,n,e)},t.fn.fadeOut=function(t,e){return u(this,t,null,e)},t.fn.fadeToggle=function(e,n){return this.each(function(){var i=t(this);i[0==i.css("opacity")||"none"==i.css("display")?"fadeIn":"fadeOut"](e,n)})}}(Zepto),function(t){function s(o,s){var u=o[r],f=u&&e[u];if(void 0===s)return f||a(o);if(f){if(s in f)return f[s];var c=i(s);if(c in f)return f[c]}return n.call(t(o),s)}function a(n,o,s){var a=n[r]||(n[r]=++t.uuid),f=e[a]||(e[a]=u(n));return void 0!==o&&(f[i(o)]=s),f}function u(e){var n={};return t.each(e.attributes||o,function(e,r){0==r.name.indexOf("data-")&&(n[i(r.name.replace("data-",""))]=t.zepto.deserializeValue(r.value))}),n}var e={},n=t.fn.data,i=t.camelCase,r=t.expando="Zepto"+ +new Date,o=[];t.fn.data=function(e,n){return void 0===n?t.isPlainObject(e)?this.each(function(n,i){t.each(e,function(t,e){a(i,t,e)})}):0 in this?s(this[0],e):void 0:this.each(function(){a(this,e,n)})},t.fn.removeData=function(n){return"string"==typeof n&&(n=n.split(/\s+/)),this.each(function(){var o=this[r],s=o&&e[o];s&&t.each(n||s,function(t){delete s[n?i(this):t]})})},["remove","empty"].forEach(function(e){var n=t.fn[e];t.fn[e]=function(){var t=this.find("*");return"remove"===e&&(t=t.add(this)),t.removeData(),n.call(this)}})}(Zepto),function(t){function n(e){var i=[["resolve","done",t.Callbacks({once:1,memory:1}),"resolved"],["reject","fail",t.Callbacks({once:1,memory:1}),"rejected"],["notify","progress",t.Callbacks({memory:1})]],r="pending",o={state:function(){return r},always:function(){return s.done(arguments).fail(arguments),this},then:function(){var e=arguments;return n(function(n){t.each(i,function(i,r){var a=t.isFunction(e[i])&&e[i];s[r[1]](function(){var e=a&&a.apply(this,arguments);if(e&&t.isFunction(e.promise))e.promise().done(n.resolve).fail(n.reject).progress(n.notify);else{var i=this===o?n.promise():this,s=a?[e]:arguments; 3 | n[r[0]+"With"](i,s)}})}),e=null}).promise()},promise:function(e){return null!=e?t.extend(e,o):o}},s={};return t.each(i,function(t,e){var n=e[2],a=e[3];o[e[1]]=n.add,a&&n.add(function(){r=a},i[1^t][2].disable,i[2][2].lock),s[e[0]]=function(){return s[e[0]+"With"](this===s?o:this,arguments),this},s[e[0]+"With"]=n.fireWith}),o.promise(s),e&&e.call(s,s),s}var e=Array.prototype.slice;t.when=function(i){var f,c,l,r=e.call(arguments),o=r.length,s=0,a=1!==o||i&&t.isFunction(i.promise)?o:0,u=1===a?i:n(),h=function(t,n,i){return function(r){n[t]=this,i[t]=arguments.length>1?e.call(arguments):r,i===f?u.notifyWith(n,i):--a||u.resolveWith(n,i)}};if(o>1)for(f=new Array(o),c=new Array(o),l=new Array(o);o>s;++s)r[s]&&t.isFunction(r[s].promise)?r[s].promise().done(h(s,l,r)).fail(u.reject).progress(h(s,c,f)):--a;return a||u.resolveWith(l,r),u.promise()},t.Deferred=n}(Zepto),function(t){t.Callbacks=function(e){e=t.extend({},e);var n,i,r,o,s,a,u=[],f=!e.once&&[],c=function(t){for(n=e.memory&&t,i=!0,a=o||0,o=0,s=u.length,r=!0;u&&s>a;++a)if(u[a].apply(t[0],t[1])===!1&&e.stopOnFalse){n=!1;break}r=!1,u&&(f?f.length&&c(f.shift()):n?u.length=0:l.disable())},l={add:function(){if(u){var i=u.length,a=function(n){t.each(n,function(t,n){"function"==typeof n?e.unique&&l.has(n)||u.push(n):n&&n.length&&"string"!=typeof n&&a(n)})};a(arguments),r?s=u.length:n&&(o=i,c(n))}return this},remove:function(){return u&&t.each(arguments,function(e,n){for(var i;(i=t.inArray(n,u,i))>-1;)u.splice(i,1),r&&(s>=i&&--s,a>=i&&--a)}),this},has:function(e){return!(!u||!(e?t.inArray(e,u)>-1:u.length))},empty:function(){return s=u.length=0,this},disable:function(){return u=f=n=void 0,this},disabled:function(){return!u},lock:function(){return f=void 0,n||l.disable(),this},locked:function(){return!f},fireWith:function(t,e){return!u||i&&!f||(e=e||[],e=[t,e.slice?e.slice():e],r?f.push(e):c(e)),this},fire:function(){return l.fireWith(this,arguments)},fired:function(){return!!i}};return l}}(Zepto),function(t){function r(e){return e=t(e),!(!e.width()&&!e.height())&&"none"!==e.css("display")}function f(t,e){t=t.replace(/=#\]/g,'="#"]');var n,i,r=s.exec(t);if(r&&r[2]in o&&(n=o[r[2]],i=r[3],t=r[1],i)){var a=Number(i);i=isNaN(a)?i.replace(/^["']|["']$/g,""):a}return e(t,n,i)}var e=t.zepto,n=e.qsa,i=e.matches,o=t.expr[":"]={visible:function(){return r(this)?this:void 0},hidden:function(){return r(this)?void 0:this},selected:function(){return this.selected?this:void 0},checked:function(){return this.checked?this:void 0},parent:function(){return this.parentNode},first:function(t){return 0===t?this:void 0},last:function(t,e){return t===e.length-1?this:void 0},eq:function(t,e,n){return t===n?this:void 0},contains:function(e,n,i){return t(this).text().indexOf(i)>-1?this:void 0},has:function(t,n,i){return e.qsa(this,i).length?this:void 0}},s=new RegExp("(.*):(\\w+)(?:\\(([^)]+)\\))?$\\s*"),a=/^\s*>/,u="Zepto"+ +new Date;e.qsa=function(i,r){return f(r,function(o,s,f){try{var c;!o&&s?o="*":a.test(o)&&(c=t(i).addClass(u),o="."+u+" "+o);var l=n(i,o)}catch(h){throw console.error("error performing selector: %o",r),h}finally{c&&c.removeClass(u)}return s?e.uniq(t.map(l,function(t,e){return s.call(t,e,l,f)})):l})},e.matches=function(t,e){return f(e,function(e,n,r){return(!e||i(t,e))&&(!n||n.call(t,null,r)===t)})}}(Zepto),function(t){function u(t,e,n,i){return Math.abs(t-e)>=Math.abs(n-i)?t-e>0?"Left":"Right":n-i>0?"Up":"Down"}function f(){o=null,e.last&&(e.el.trigger("longTap"),e={})}function c(){o&&clearTimeout(o),o=null}function l(){n&&clearTimeout(n),i&&clearTimeout(i),r&&clearTimeout(r),o&&clearTimeout(o),n=i=r=o=null,e={}}function h(t){return("touch"==t.pointerType||t.pointerType==t.MSPOINTER_TYPE_TOUCH)&&t.isPrimary}function p(t,e){return t.type=="pointer"+e||t.type.toLowerCase()=="mspointer"+e}var n,i,r,o,a,e={},s=750;t(document).ready(function(){var d,m,y,b,g=0,v=0;"MSGesture"in window&&(a=new MSGesture,a.target=document.body),t(document).bind("MSGestureEnd",function(t){var n=t.velocityX>1?"Right":t.velocityX<-1?"Left":t.velocityY>1?"Down":t.velocityY<-1?"Up":null;n&&(e.el.trigger("swipe"),e.el.trigger("swipe"+n))}).on("touchstart MSPointerDown pointerdown",function(i){(!(b=p(i,"down"))||h(i))&&(y=b?i:i.touches[0],i.touches&&1===i.touches.length&&e.x2&&(e.x2=void 0,e.y2=void 0),d=Date.now(),m=d-(e.last||d),e.el=t("tagName"in y.target?y.target:y.target.parentNode),n&&clearTimeout(n),e.x1=y.pageX,e.y1=y.pageY,m>0&&250>=m&&(e.isDoubleTap=!0),e.last=d,o=setTimeout(f,s),a&&b&&a.addPointer(i.pointerId))}).on("touchmove MSPointerMove pointermove",function(t){(!(b=p(t,"move"))||h(t))&&(y=b?t:t.touches[0],c(),e.x2=y.pageX,e.y2=y.pageY,g+=Math.abs(e.x1-e.x2),v+=Math.abs(e.y1-e.y2))}).on("touchend MSPointerUp pointerup",function(o){(!(b=p(o,"up"))||h(o))&&(c(),e.x2&&Math.abs(e.x1-e.x2)>30||e.y2&&Math.abs(e.y1-e.y2)>30?r=setTimeout(function(){e.el.trigger("swipe"),e.el.trigger("swipe"+u(e.x1,e.x2,e.y1,e.y2)),e={}},0):"last"in e&&(30>g&&30>v?i=setTimeout(function(){var i=t.Event("tap");i.cancelTouch=l,e.el.trigger(i),e.isDoubleTap?(e.el&&e.el.trigger("doubleTap"),e={}):n=setTimeout(function(){n=null,e.el&&e.el.trigger("singleTap"),e={}},250)},0):e={}),g=v=0)}).on("touchcancel MSPointerCancel pointercancel",l),t(window).on("scroll",l)}),["swipe","swipeLeft","swipeRight","swipeUp","swipeDown","doubleTap","tap","singleTap","longTap"].forEach(function(e){t.fn[e]=function(t){return this.on(e,t)}})}(Zepto),function(t){function i(t){return"tagName"in t?t:t.parentNode}if(t.os.ios){var n,e={};t(document).bind("gesturestart",function(t){var r=Date.now();r-(e.last||r);e.target=i(t.target),n&&clearTimeout(n),e.e1=t.scale,e.last=r}).bind("gesturechange",function(t){e.e2=t.scale}).bind("gestureend",function(n){e.e2>0?(0!=Math.abs(e.e1-e.e2)&&t(e.target).trigger("pinch")&&t(e.target).trigger("pinch"+(e.e1-e.e2>0?"In":"Out")),e.e1=e.e2=e.last=0):"last"in e&&(e={})}),["pinch","pinchIn","pinchOut"].forEach(function(e){t.fn[e]=function(t){return this.bind(e,t)}})}}(Zepto); 4 | window.Zepto = Zepto 5 | "$" in window || (window.$ = Zepto) 6 | if ( typeof define === "function" && define.amd ) { 7 | define( "zepto", [], function () { return Zepto; } ); 8 | } -------------------------------------------------------------------------------- /css/pullload.less: -------------------------------------------------------------------------------- 1 | @bg-dark: #EFEFF4; 2 | @progress-color: #08BF06; 3 | 4 | @height: 3rem; 5 | // @height: 48px; 6 | @fontSize: 11px; 7 | @fontColor: darken(@bg-dark, 40%);// state hint 8 | @btnColor: darken(@bg-dark, 60%);// load more 9 | 10 | @pullingMsg: '下拉刷新'; 11 | @pullingEnoughMsg: '松开刷新'; 12 | @refreshingMsg: '正在刷新...'; 13 | @refreshedMsg: '刷新成功'; 14 | @loadingMsg: '正在加载...'; 15 | // @btnLoadMore: '加载更多'; 16 | @btnLoadMore: '没有更多'; 17 | @transition-duration: .2s; 18 | 19 | .tloader-msg:after{ 20 | .state-pulling &{ 21 | content: @pullingMsg 22 | } 23 | 24 | .state-pulling.enough &{ 25 | content: @pullingEnoughMsg; 26 | } 27 | 28 | .state-refreshed &{ 29 | content: @refreshedMsg; 30 | } 31 | } 32 | .tloader-loading:after{ 33 | content: @loadingMsg; 34 | 35 | .tloader-symbol &{ 36 | content: @refreshingMsg; 37 | } 38 | } 39 | .tloader-btn:after{ 40 | content: @btnLoadMore; 41 | } 42 | 43 | 44 | .tloader{ 45 | position: relative; 46 | 47 | &.state-pulling{ 48 | // overflow-y: hidden;// 拖拽时临时阻止ios的overscroll 49 | } 50 | } 51 | 52 | // pull to refresh 53 | .tloader-symbol{ 54 | position: absolute; 55 | top: 0; 56 | left: 0; 57 | right: 0; 58 | color: @fontColor; 59 | text-align: center; 60 | height: @height; 61 | overflow: hidden; 62 | 63 | // 隐藏刷新提示标签 64 | .state- &, .state-reset &{ 65 | height: 0; 66 | } 67 | // 延迟至reset完成,隐藏刷新提示标签 68 | .state-reset &{ 69 | transition: height 0s @transition-duration; 70 | } 71 | } 72 | 73 | // 拖拽提示信息 74 | .tloader-msg{ 75 | line-height: @height; 76 | font-size: @fontSize; 77 | opacity: 0; 78 | 79 | .state-pulling &{ 80 | opacity: 1; 81 | 82 | // arrow down icon 83 | i{ 84 | display: inline-block; 85 | font-size: 2em; 86 | margin-right: .6em; 87 | vertical-align: middle; 88 | height: 1em; 89 | border-left: 1px solid; 90 | position: relative; 91 | transition: transform .3s ease; 92 | 93 | &:before,&:after{ 94 | content: ''; 95 | position: absolute; 96 | font-size: .5em; 97 | width: 1em; 98 | bottom: 0px; 99 | border-top: 1px solid; 100 | } 101 | &:before{ 102 | right: 1px; 103 | transform: rotate(50deg); 104 | transform-origin: right; 105 | } 106 | &:after{ 107 | left: 0px; 108 | transform: rotate(-50deg); 109 | transform-origin: left; 110 | } 111 | } 112 | } 113 | .state-pulling.enough &{ 114 | // arrow up 115 | i{ 116 | transform: rotate(180deg); 117 | } 118 | } 119 | 120 | // 刷新成功提示消息 121 | .state-refreshed &{ 122 | opacity: 1; 123 | transition: opacity 1s; 124 | 125 | // √ icon 126 | i{ 127 | display: inline-block; 128 | box-sizing: content-box; 129 | vertical-align: middle; 130 | margin-right: 10px; 131 | font-size: 20px; 132 | height: 1em; 133 | width: 1em; 134 | border: 1px solid; 135 | border-radius: 100%; 136 | position: relative; 137 | 138 | &:before{ 139 | content: ''; 140 | position: absolute; 141 | top: 3px; 142 | left: 7px; 143 | height: 11px; 144 | width: 5px; 145 | border: solid; 146 | border-width: 0 1px 1px 0; 147 | transform: rotate(40deg); 148 | } 149 | } 150 | } 151 | } 152 | 153 | .tloader-body{ 154 | // transform: translate3d(0,0,0);// make over the msg-refreshed 155 | 156 | .state-refreshing &{ 157 | transform: translate3d(0,@height,0); 158 | transition: transform @transition-duration; 159 | } 160 | 161 | .state-refreshed &{ 162 | // handle resolve within 1s 163 | animation: refreshed @transition-duration*5; 164 | } 165 | 166 | .state-reset &{ 167 | transition: transform @transition-duration; 168 | } 169 | } 170 | @keyframes refreshed { 171 | 0%{transform: translate3d(0,@height,0);} 172 | 50%{transform: translate3d(0,@height,0);} 173 | } 174 | 175 | // touch to load more 176 | .tloader-footer{ 177 | .state-refreshing &{ 178 | display: none; 179 | } 180 | 181 | .tloader-btn{ 182 | color: @btnColor; 183 | font-size: .9em; 184 | text-align: center; 185 | line-height: 3rem; 186 | display: none; 187 | 188 | .state-loading &{ 189 | display: none; 190 | } 191 | } 192 | } 193 | 194 | .tloader-loading{ 195 | display: none; 196 | text-align: center; 197 | line-height: @height; 198 | font-size: @fontSize; 199 | color: @fontColor; 200 | 201 | .ui-loading{ 202 | font-size: 20px; 203 | margin-right: .6rem; 204 | } 205 | 206 | .state-refreshing .tloader-symbol &, .state-loading .tloader-footer &{ 207 | display: block; 208 | } 209 | } 210 | 211 | // loading效果 212 | @keyframes circle { 213 | 100% { transform: rotate(360deg); } 214 | } 215 | .ui-loading{ 216 | display: inline-block; 217 | vertical-align: middle; 218 | font-size: 1.5rem; 219 | width: 1em; 220 | height: 1em; 221 | border: 2px solid darken(@bg-dark, 30%); 222 | border-top-color: #fff; 223 | border-radius: 100%; 224 | animation: circle .8s infinite linear; 225 | 226 | #ui-waiting &{ 227 | border: 2px solid #fff; 228 | border-top-color: darken(@bg-dark, 30%); 229 | } 230 | } 231 | 232 | // 进度条加载效果 233 | @keyframes tloader-progressing { 234 | 0% { width: 0; } 235 | 10%{ width: 40%; } 236 | 20%{ width: 75%; } 237 | 30%{ width: 95%; } 238 | } 239 | @keyframes tloader-progressed { 240 | 0% { 241 | opacity: 1; 242 | } 243 | } 244 | .tloader-progress { 245 | position: relative; 246 | 247 | &:before{ 248 | content: ""; 249 | z-index: 1000; 250 | position: absolute; 251 | top: 0; 252 | left: 0; 253 | height: 2px; 254 | background-color: @progress-color; 255 | width: 99%; 256 | animation: tloader-progressing 9s ease-out; 257 | 258 | .ed&{ 259 | opacity: 0; 260 | width: 100%; 261 | animation: tloader-progressed 1s; 262 | } 263 | } 264 | } -------------------------------------------------------------------------------- /fis-conf.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @auth lidian 3 | * @date 2016-05-16 4 | * @desc 5 | * 全局安装 fis3: sudo npm install -g fis3 6 | * 安装less插件 : sudo npm install -g fis-parser-less 7 | * 开发命令 : fis3 server start //开启fis3 本地server 8 | * fis3 server open //打开fis3 本地server文件夹路径 9 | * fis3 server clean //清空本地server文件夹路径内容 10 | * fis3 release debug -wL //将当前路径代码发布到本地调试服务器并且监听文件修改自动刷新浏览器 11 | * fis3 release prod //发布代码到当前路径\output下 12 | * 13 | * FIS3 构建会对 CSS 中,路径带 ?__sprite 的图片进行合并 14 | * http://fis.baidu.com/fis3/docs/beginning/release.html#CssSprite%E5%9B%BE%E7%89%87%E5%90%88%E5%B9%B6 15 | */ 16 | //FIS3 官方文档 http://fis.baidu.com/fis3/docs/beginning/intro.html 17 | //全局属性文档 http://fis.baidu.com/fis3/docs/api/config-props.html 18 | fis.set('project.ignore', ['printImgNames.js','fis-conf.js','node_modules/**', 'output/**', 'build/**']); 19 | 20 | fis.hook('relative'); 21 | 22 | //发布到默认的当前路径 build 下 23 | fis.media("prod") 24 | .match('::package', { 25 | spriter: fis.plugin('csssprites') 26 | }) 27 | .match("(*.less)", { 28 | parser: fis.plugin('less-2.x'), 29 | rExt: '.css', 30 | // 开发阶段默认不开启csssprites,如有需要设置成true即可 31 | useSprite: false, 32 | optimizer: fis.plugin('clean-css'), 33 | postprocessor: fis.plugin('autoprefixer',{ 34 | "browsers": ["Android >= 2.3", "ChromeAndroid > 1%", "iOS >= 4"], 35 | "cascade": true 36 | }) 37 | }) 38 | .match('**', { 39 | relative: true 40 | }) 41 | //将代码直接部署至./build 下 42 | .match('*', { 43 | deploy: fis.plugin('local-deliver', { 44 | to: './build' 45 | }) 46 | }); 47 | 48 | //开发阶段使用 49 | fis.media("debug") 50 | .match('::package', { 51 | spriter: fis.plugin('csssprites') 52 | }) 53 | .match("(*.less)", { 54 | parser: fis.plugin('less-2.x'), 55 | rExt: '.css', 56 | // 开发阶段默认不开启csssprites,如有需要设置成true即可 57 | useSprite: false, 58 | postprocessor: fis.plugin('autoprefixer',{ 59 | "browsers": ["Android >= 2.3", "ChromeAndroid > 1%", "iOS >= 4"], 60 | "cascade": true 61 | }) 62 | }); 63 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | pullload 以 body 为滚动容器 6 | 7 | 13 | 14 | 15 | 16 |
17 |
18 |

19 |

20 | 21 |

22 |
23 |
24 |
    25 |
26 |
27 | 33 |
34 | 35 | 36 | 89 | 90 | -------------------------------------------------------------------------------- /index2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | pullload 支持 require.js 方式 6 | 7 | 8 | 9 | 15 | 16 | 17 | 18 |
19 |
20 |

21 |

22 | 23 |

24 |
25 |
26 |
    27 |
28 |
29 | 35 |
36 | 91 | 92 | -------------------------------------------------------------------------------- /index3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | pullload 以块级元素为滚动容器 6 | 7 | 8 | 9 | 16 | 17 | 18 | 19 |
20 |
21 |

22 |

23 | 24 |

25 |
26 |
27 |
    28 |
29 |
30 | 36 |
37 | 92 | 93 | -------------------------------------------------------------------------------- /js/pullload.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | 3 | var defaultConfig = { 4 | container: null, //具有scroll的容器 5 | wrapper: null, //结构外包围元素 6 | downEnough: 100, //下拉满足刷新的距离 7 | offsetScrollTop: 2, //与顶部的距离 8 | distanceBottom: 100, //距离底部距离触发加载更多 9 | onRefresh: function(){}, 10 | onLoadMore: function(){} 11 | } 12 | 13 | var STATS = { 14 | init: '', 15 | pulling: 'pulling', 16 | enough: 'pulling enough', 17 | refreshing: 'refreshing', 18 | refreshed: 'refreshed', 19 | reset: 'reset', 20 | loading: 'loading' // loading more 21 | }; 22 | 23 | var pullload = function(opts){ 24 | this.config = {}; 25 | this.container = null; //具有scroll的容器 26 | this.wrapper = null; //结构外包围元素 27 | this.loaderBody = null; //DOM 对象 28 | this.loaderSymbol = null; //DOM 对象 29 | this.loaderBtn = null; //DOM 对象 30 | this.loaderState = STATS.init; 31 | this.hasMore = true; //是否有加载更多 32 | this.startX = 0; //用于保存touchstart时初始位置 33 | this.startY = 0;//用于保存touchstart时初始位置 34 | this.init(opts); 35 | } 36 | 37 | pullload.prototype = { 38 | init: function(opts){ 39 | this.config = extend(defaultConfig, opts || {}); 40 | 41 | this.container = opts.container; 42 | this.wrapper = opts.wrapper; 43 | 44 | this.loaderBody = this.wrapper.querySelector(".tloader-body"); 45 | this.loaderSymbol = this.wrapper.querySelector(".tloader-symbol"); 46 | this.loaderBtn = this.wrapper.querySelector(".tloader-btn"); 47 | 48 | //将函数 'onTouchStart','onTouchMove','onTouchEnd' 进行 this 绑定。 49 | bindAll(['onTouchStart','onTouchMove','onTouchEnd'], this); 50 | 51 | addEvent(this.wrapper, "touchstart", this.onTouchStart); 52 | addEvent(this.wrapper, "touchmove", this.onTouchMove); 53 | addEvent(this.wrapper, "touchend", this.onTouchEnd); 54 | }, 55 | destory: function(){ 56 | removeEvent(this.wrapper, "touchstart", this.onTouchStart); 57 | removeEvent(this.wrapper, "touchmove", this.onTouchMove); 58 | removeEvent(this.wrapper, "touchend", this.onTouchEnd); 59 | this.config = {}; 60 | this.container = null; //具有scroll的容器 61 | this.wrapper = null; //结构外包围元素 62 | this.loaderBody = null; //DOM 对象 63 | this.loaderSymbol = null; //DOM 对象 64 | this.loaderBtn = null; //DOM 对象 65 | this.loaderState = STATS.init; 66 | this.hasMore = true; //是否有加载更多 67 | this.startX = 0; //用于保存touchstart时初始位置 68 | this.startY = 0;//用于保存touchstart时初始位置 69 | }, 70 | onTouchStart: function(event){ 71 | var targetEvent = event.changedTouches[0]; 72 | this.startX = targetEvent.clientX; 73 | this.startY = targetEvent.clientY; 74 | }, 75 | onTouchMove: function(event){ 76 | var targetEvent = event.changedTouches[0], 77 | x = targetEvent.clientX, 78 | y = targetEvent.clientY, 79 | scrollTop = this.container.scrollTop, 80 | scrollH = this.container.scrollHeight, 81 | conH = this.container === document.body ? document.documentElement.clientHeight : this.container.offsetHeight; 82 | diffX = x - this.startX, 83 | diffY = y - this.startY; 84 | 85 | //判断垂直移动距离是否大于5 && 横向移动距离小于纵向移动距离 86 | if(Math.abs(diffY) > 5 && Math.abs(diffY) > Math.abs(diffX)){ 87 | //滚动距离小于设定值 &&回调onPullDownMove 函数,并且回传位置值 88 | if(diffY > 5 && scrollTop < this.config.offsetScrollTop ){ 89 | // //阻止执行浏览器默认动作 90 | // event.preventDefault(); 91 | this.onPullDownMove(this.startY, y); 92 | } //滚动距离距离底部小于设定值 93 | else if(diffY < 0 && (scrollH - scrollTop - conH) < this.config.distanceBottom ){ 94 | //阻止执行浏览器默认动作 95 | // event.preventDefault(); 96 | this.onPullUpMove(this.startY, y); 97 | } 98 | } 99 | }, 100 | onTouchEnd: function(event){ 101 | var targetEvent = event.changedTouches[0], 102 | x = targetEvent.clientX, 103 | y = targetEvent.clientY, 104 | scrollTop = this.container.scrollTop, 105 | scrollH = this.container.scrollHeight, 106 | conH = this.container === document.body ? document.documentElement.clientHeight : this.container.offsetHeight; 107 | diffX = x - this.startX, 108 | diffY = y - this.startY; 109 | 110 | //判断垂直移动距离是否大于5 && 横向移动距离小于纵向移动距离 111 | if(Math.abs(diffY) > 5 && Math.abs(diffY) > Math.abs(diffX)){ 112 | if(diffY > 5 && scrollTop < this.config.offsetScrollTop ){ 113 | //回调onPullDownRefresh 函数,即满足刷新条件 114 | this.onPullDownRefresh(); 115 | } 116 | } 117 | }, 118 | onPullDownMove: function(startY, y){ 119 | if(this.loaderState === STATS.refreshing){ 120 | return false; 121 | } 122 | event.preventDefault(); 123 | 124 | var diff = y - startY, loaderState; 125 | if (diff < 0) { 126 | diff = 0; 127 | } 128 | 129 | diff = this.easing(diff); 130 | if (diff > this.config.downEnough) { 131 | loaderState = STATS.enough; 132 | } else { 133 | loaderState = STATS.pulling; 134 | } 135 | this.setChange(diff, loaderState); 136 | }, 137 | onPullDownRefresh: function(){ 138 | if(this.loaderState === STATS.refreshing){ 139 | return false; 140 | } 141 | else if (this.loaderState === STATS.pulling) { 142 | this.setEndState(); 143 | } else { 144 | this.setChange(0, STATS.refreshing); 145 | this.resetLoadMore(); 146 | if (typeof this.config.onRefresh === "function") { 147 | this.config.onRefresh( 148 | bind(function(){ 149 | this.setChange(0, STATS.refreshed); 150 | setTimeout(bind(function(){this.setChange(0, STATS.init);}, this), 1000); 151 | }, this), 152 | bind(function(){ 153 | this.setEndState(); 154 | }, this) 155 | ) 156 | } 157 | } 158 | }, 159 | onPullUpMove: function(staartY, y){ 160 | if(!this.hasMore || this.loaderState === STATS.loading){ 161 | return false; 162 | } 163 | if (typeof this.config.onLoadMore === "function") { 164 | this.setChange(0, STATS.loading); 165 | // console.info(this.state); 166 | this.config.onLoadMore(bind(function(isNoMore){ 167 | this.setEndState(); 168 | if(isNoMore){ 169 | this.setNoMoreState(); 170 | } 171 | }, this)); 172 | } 173 | }, 174 | // 拖拽的缓动公式 - easeOutSine 175 | easing: function(distance) { 176 | // t: current time, b: begInnIng value, c: change In value, d: duration 177 | var t = distance; 178 | var b = 0; 179 | var d = screen.availHeight; // 允许拖拽的最大距离 180 | var c = d / 2.5; // 提示标签最大有效拖拽距离 181 | 182 | return c * Math.sin(t / d * (Math.PI / 2)) + b; 183 | }, 184 | setChange: function(pullHeight, state){ 185 | var lbodyTop = pullHeight !== 0 ? 'translate3d(0, ' + pullHeight + 'px, 0)' : "", 186 | symbolTop = pullHeight - 50 > 0 ? pullHeight - 50 : 0; 187 | lSymbol = symbolTop !== 0 ? 'translate3d(0, ' + symbolTop + 'px, 0)' : ""; 188 | 189 | this.setClassName(state); 190 | this.loaderBody.style.WebkitTransform = lbodyTop; 191 | this.loaderBody.style.transform = lbodyTop; 192 | this.loaderSymbol.style.WebkitTransform = lSymbol; 193 | this.loaderSymbol.style.transform = lSymbol; 194 | }, 195 | //设置 wrapper DOM class 值 196 | setClassName: function(state){ 197 | this.loaderState = state; 198 | this.wrapper.className = 'tloader state-' + state; 199 | }, 200 | //设置动作结束状态 201 | setEndState: function(){ 202 | this.setChange(0, STATS.reset); 203 | }, 204 | setNoMoreState:function(){ 205 | this.loaderBtn.style.display = "block"; 206 | this.hasMore = false; 207 | }, 208 | resetLoadMore: function(){ 209 | this.loaderBtn.style.display = "none"; 210 | this.hasMore = true; 211 | } 212 | } 213 | 214 | function extendArrProps(arr, obj1, obj2){ 215 | var index = 0, len = arr.length; 216 | for(index; index < len; index++){ 217 | var value = arr[index]; 218 | if(typeof obj2[value] !== "undefined"){ 219 | obj1[value] = obj2[value]; 220 | } 221 | } 222 | return obj1; 223 | } 224 | 225 | //copy obj2 props to obj1 no deepClone 226 | function extend(obj1, obj2){ 227 | var newObj = {}; 228 | for(var s in obj1){ 229 | newObj[s] = obj1[s] 230 | } 231 | for(var s in obj2){ 232 | newObj[s] = obj2[s] 233 | } 234 | return newObj; 235 | } 236 | 237 | function addEvent(obj, type, fn) { 238 | if (obj.attachEvent) { 239 | obj['e' + type + fn] = fn; 240 | obj[type + fn] = function () { obj['e' + type + fn](window.event); } 241 | obj.attachEvent('on' + type, obj[type + fn]); 242 | } else 243 | obj.addEventListener(type, fn, false); 244 | } 245 | function removeEvent(obj, type, fn) { 246 | if (obj.detachEvent) { 247 | obj.detachEvent('on' + type, obj[type + fn]); 248 | obj[type + fn] = null; 249 | } else 250 | obj.removeEventListener(type, fn, false); 251 | } 252 | 253 | function asArray(quasiArray, start) { 254 | var result = [], 255 | i = (start || 0); 256 | for (; i < quasiArray.length; i++) { 257 | result.push(quasiArray[i]); 258 | } 259 | return result; 260 | } 261 | 262 | function bind(func, context) { 263 | if (arguments.length < 2 && typeof arguments[0] === "undefined") { 264 | return func; 265 | } 266 | 267 | var __method = func; 268 | var args = asArray(arguments, 2); 269 | 270 | return function() { 271 | var array = args.concat(asArray(arguments, 0)); 272 | return __method.apply(context, array); 273 | }; 274 | } 275 | /* bindAll 批量绑定 276 | * @param fns 待绑定的函数名称 277 | * @param obj 待绑定的实例对象 278 | * @param context 用于绑定的上下文对象 279 | * @describe 如果 context 为 undefined 则context = obj 280 | */ 281 | function bindAll(fns, obj, context){ 282 | var index = 0, len = fns.length; 283 | if(context === undefined){ 284 | context = obj; 285 | } 286 | 287 | for(index; index < len; index++){ 288 | var key = fns[index]; 289 | if(typeof obj[key] === 'function'){ 290 | obj[key] = b(obj[key], context); 291 | } 292 | } 293 | function b(func, context){ 294 | return function(){ 295 | return func.apply(context, asArray(arguments, 0)); 296 | } 297 | } 298 | } 299 | 300 | window.pullload = pullload; 301 | //增加 require 支持 302 | if ( typeof define === "function" && define.amd ) { 303 | define( "pullload", [], function () { return pullload; }); 304 | } 305 | 306 | })(); -------------------------------------------------------------------------------- /js/require-config.js: -------------------------------------------------------------------------------- 1 | var config = { 2 | baseUrl: "js/", //依赖相对路径 3 | paths: { //如果某个前缀的依赖不是按照baseUrl拼接这么简单,就需要在这里指出 4 | zepto: 'zepto.min', 5 | jquery: 'jquery-2.2.2.min' 6 | }, 7 | shim: { //引入没有使用requirejs模块写法的类库。backbone依赖underscore 8 | 'zepto': { 9 | exports: '$' 10 | }, 11 | 'jquery': { 12 | exports: '$' 13 | } 14 | } 15 | }; 16 | 17 | require.config(config); 18 | -------------------------------------------------------------------------------- /js/require.js: -------------------------------------------------------------------------------- 1 | /** vim: et:ts=4:sw=4:sts=4 2 | * @license RequireJS 2.1.11 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved. 3 | * Available via the MIT or new BSD license. 4 | * see: http://github.com/jrburke/requirejs for details 5 | */ 6 | //Not using strict: uneven strict support in browsers, #392, and causes 7 | //problems with requirejs.exec()/transpiler plugins that may not be strict. 8 | /*jslint regexp: true, nomen: true, sloppy: true */ 9 | /*global window, navigator, document, importScripts, setTimeout, opera */ 10 | 11 | var requirejs, require, define; 12 | (function (global) { 13 | var req, s, head, baseElement, dataMain, src, 14 | interactiveScript, currentlyAddingScript, mainScript, subPath, 15 | version = '2.1.11', 16 | commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg, 17 | cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g, 18 | jsSuffixRegExp = /\.js$/, 19 | currDirRegExp = /^\.\//, 20 | op = Object.prototype, 21 | ostring = op.toString, 22 | hasOwn = op.hasOwnProperty, 23 | ap = Array.prototype, 24 | apsp = ap.splice, 25 | isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document), 26 | isWebWorker = !isBrowser && typeof importScripts !== 'undefined', 27 | //PS3 indicates loaded and complete, but need to wait for complete 28 | //specifically. Sequence is 'loading', 'loaded', execution, 29 | // then 'complete'. The UA check is unfortunate, but not sure how 30 | //to feature test w/o causing perf issues. 31 | readyRegExp = isBrowser && navigator.platform === 'PLAYSTATION 3' ? 32 | /^complete$/ : /^(complete|loaded)$/, 33 | defContextName = '_', 34 | //Oh the tragedy, detecting opera. See the usage of isOpera for reason. 35 | isOpera = typeof opera !== 'undefined' && opera.toString() === '[object Opera]', 36 | contexts = {}, 37 | cfg = {}, 38 | globalDefQueue = [], 39 | useInteractive = false; 40 | 41 | function isFunction(it) { 42 | return ostring.call(it) === '[object Function]'; 43 | } 44 | 45 | function isArray(it) { 46 | return ostring.call(it) === '[object Array]'; 47 | } 48 | 49 | /** 50 | * Helper function for iterating over an array. If the func returns 51 | * a true value, it will break out of the loop. 52 | */ 53 | function each(ary, func) { 54 | if (ary) { 55 | var i; 56 | for (i = 0; i < ary.length; i += 1) { 57 | if (ary[i] && func(ary[i], i, ary)) { 58 | break; 59 | } 60 | } 61 | } 62 | } 63 | 64 | /** 65 | * Helper function for iterating over an array backwards. If the func 66 | * returns a true value, it will break out of the loop. 67 | */ 68 | function eachReverse(ary, func) { 69 | if (ary) { 70 | var i; 71 | for (i = ary.length - 1; i > -1; i -= 1) { 72 | if (ary[i] && func(ary[i], i, ary)) { 73 | break; 74 | } 75 | } 76 | } 77 | } 78 | 79 | function hasProp(obj, prop) { 80 | return hasOwn.call(obj, prop); 81 | } 82 | 83 | function getOwn(obj, prop) { 84 | return hasProp(obj, prop) && obj[prop]; 85 | } 86 | 87 | /** 88 | * Cycles over properties in an object and calls a function for each 89 | * property value. If the function returns a truthy value, then the 90 | * iteration is stopped. 91 | */ 92 | function eachProp(obj, func) { 93 | var prop; 94 | for (prop in obj) { 95 | if (hasProp(obj, prop)) { 96 | if (func(obj[prop], prop)) { 97 | break; 98 | } 99 | } 100 | } 101 | } 102 | 103 | /** 104 | * Simple function to mix in properties from source into target, 105 | * but only if target does not already have a property of the same name. 106 | */ 107 | function mixin(target, source, force, deepStringMixin) { 108 | if (source) { 109 | eachProp(source, function (value, prop) { 110 | if (force || !hasProp(target, prop)) { 111 | if (deepStringMixin && typeof value === 'object' && value && 112 | !isArray(value) && !isFunction(value) && 113 | !(value instanceof RegExp)) { 114 | 115 | if (!target[prop]) { 116 | target[prop] = {}; 117 | } 118 | mixin(target[prop], value, force, deepStringMixin); 119 | } else { 120 | target[prop] = value; 121 | } 122 | } 123 | }); 124 | } 125 | return target; 126 | } 127 | 128 | //Similar to Function.prototype.bind, but the 'this' object is specified 129 | //first, since it is easier to read/figure out what 'this' will be. 130 | function bind(obj, fn) { 131 | return function () { 132 | return fn.apply(obj, arguments); 133 | }; 134 | } 135 | 136 | function scripts() { 137 | return document.getElementsByTagName('script'); 138 | } 139 | 140 | function defaultOnError(err) { 141 | throw err; 142 | } 143 | 144 | //Allow getting a global that is expressed in 145 | //dot notation, like 'a.b.c'. 146 | function getGlobal(value) { 147 | if (!value) { 148 | return value; 149 | } 150 | var g = global; 151 | each(value.split('.'), function (part) { 152 | g = g[part]; 153 | }); 154 | return g; 155 | } 156 | 157 | /** 158 | * Constructs an error with a pointer to an URL with more information. 159 | * @param {String} id the error ID that maps to an ID on a web page. 160 | * @param {String} message human readable error. 161 | * @param {Error} [err] the original error, if there is one. 162 | * 163 | * @returns {Error} 164 | */ 165 | function makeError(id, msg, err, requireModules) { 166 | var e = new Error(msg + '\nhttp://requirejs.org/docs/errors.html#' + id); 167 | e.requireType = id; 168 | e.requireModules = requireModules; 169 | if (err) { 170 | e.originalError = err; 171 | } 172 | return e; 173 | } 174 | 175 | if (typeof define !== 'undefined') { 176 | //If a define is already in play via another AMD loader, 177 | //do not overwrite. 178 | return; 179 | } 180 | 181 | if (typeof requirejs !== 'undefined') { 182 | if (isFunction(requirejs)) { 183 | //Do not overwrite and existing requirejs instance. 184 | return; 185 | } 186 | cfg = requirejs; 187 | requirejs = undefined; 188 | } 189 | 190 | //Allow for a require config object 191 | if (typeof require !== 'undefined' && !isFunction(require)) { 192 | //assume it is a config object. 193 | cfg = require; 194 | require = undefined; 195 | } 196 | 197 | function newContext(contextName) { 198 | var inCheckLoaded, Module, context, handlers, 199 | checkLoadedTimeoutId, 200 | config = { 201 | //Defaults. Do not set a default for map 202 | //config to speed up normalize(), which 203 | //will run faster if there is no default. 204 | waitSeconds: 7, 205 | baseUrl: './', 206 | paths: {}, 207 | bundles: {}, 208 | pkgs: {}, 209 | shim: {}, 210 | config: {} 211 | }, 212 | registry = {}, 213 | //registry of just enabled modules, to speed 214 | //cycle breaking code when lots of modules 215 | //are registered, but not activated. 216 | enabledRegistry = {}, 217 | undefEvents = {}, 218 | defQueue = [], 219 | defined = {}, 220 | urlFetched = {}, 221 | bundlesMap = {}, 222 | requireCounter = 1, 223 | unnormalizedCounter = 1; 224 | 225 | /** 226 | * Trims the . and .. from an array of path segments. 227 | * It will keep a leading path segment if a .. will become 228 | * the first path segment, to help with module name lookups, 229 | * which act like paths, but can be remapped. But the end result, 230 | * all paths that use this function should look normalized. 231 | * NOTE: this method MODIFIES the input array. 232 | * @param {Array} ary the array of path segments. 233 | */ 234 | function trimDots(ary) { 235 | var i, part, length = ary.length; 236 | for (i = 0; i < length; i++) { 237 | part = ary[i]; 238 | if (part === '.') { 239 | ary.splice(i, 1); 240 | i -= 1; 241 | } else if (part === '..') { 242 | if (i === 1 && (ary[2] === '..' || ary[0] === '..')) { 243 | //End of the line. Keep at least one non-dot 244 | //path segment at the front so it can be mapped 245 | //correctly to disk. Otherwise, there is likely 246 | //no path mapping for a path starting with '..'. 247 | //This can still fail, but catches the most reasonable 248 | //uses of .. 249 | break; 250 | } else if (i > 0) { 251 | ary.splice(i - 1, 2); 252 | i -= 2; 253 | } 254 | } 255 | } 256 | } 257 | 258 | /** 259 | * Given a relative module name, like ./something, normalize it to 260 | * a real name that can be mapped to a path. 261 | * @param {String} name the relative name 262 | * @param {String} baseName a real name that the name arg is relative 263 | * to. 264 | * @param {Boolean} applyMap apply the map config to the value. Should 265 | * only be done if this normalization is for a dependency ID. 266 | * @returns {String} normalized name 267 | */ 268 | function normalize(name, baseName, applyMap) { 269 | var pkgMain, mapValue, nameParts, i, j, nameSegment, lastIndex, 270 | foundMap, foundI, foundStarMap, starI, 271 | baseParts = baseName && baseName.split('/'), 272 | normalizedBaseParts = baseParts, 273 | map = config.map, 274 | starMap = map && map['*']; 275 | 276 | //Adjust any relative paths. 277 | if (name && name.charAt(0) === '.') { 278 | //If have a base name, try to normalize against it, 279 | //otherwise, assume it is a top-level require that will 280 | //be relative to baseUrl in the end. 281 | if (baseName) { 282 | //Convert baseName to array, and lop off the last part, 283 | //so that . matches that 'directory' and not name of the baseName's 284 | //module. For instance, baseName of 'one/two/three', maps to 285 | //'one/two/three.js', but we want the directory, 'one/two' for 286 | //this normalization. 287 | normalizedBaseParts = baseParts.slice(0, baseParts.length - 1); 288 | name = name.split('/'); 289 | lastIndex = name.length - 1; 290 | 291 | // If wanting node ID compatibility, strip .js from end 292 | // of IDs. Have to do this here, and not in nameToUrl 293 | // because node allows either .js or non .js to map 294 | // to same file. 295 | if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) { 296 | name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, ''); 297 | } 298 | 299 | name = normalizedBaseParts.concat(name); 300 | trimDots(name); 301 | name = name.join('/'); 302 | } else if (name.indexOf('./') === 0) { 303 | // No baseName, so this is ID is resolved relative 304 | // to baseUrl, pull off the leading dot. 305 | name = name.substring(2); 306 | } 307 | } 308 | 309 | //Apply map config if available. 310 | if (applyMap && map && (baseParts || starMap)) { 311 | nameParts = name.split('/'); 312 | 313 | outerLoop: for (i = nameParts.length; i > 0; i -= 1) { 314 | nameSegment = nameParts.slice(0, i).join('/'); 315 | 316 | if (baseParts) { 317 | //Find the longest baseName segment match in the config. 318 | //So, do joins on the biggest to smallest lengths of baseParts. 319 | for (j = baseParts.length; j > 0; j -= 1) { 320 | mapValue = getOwn(map, baseParts.slice(0, j).join('/')); 321 | 322 | //baseName segment has config, find if it has one for 323 | //this name. 324 | if (mapValue) { 325 | mapValue = getOwn(mapValue, nameSegment); 326 | if (mapValue) { 327 | //Match, update name to the new value. 328 | foundMap = mapValue; 329 | foundI = i; 330 | break outerLoop; 331 | } 332 | } 333 | } 334 | } 335 | 336 | //Check for a star map match, but just hold on to it, 337 | //if there is a shorter segment match later in a matching 338 | //config, then favor over this star map. 339 | if (!foundStarMap && starMap && getOwn(starMap, nameSegment)) { 340 | foundStarMap = getOwn(starMap, nameSegment); 341 | starI = i; 342 | } 343 | } 344 | 345 | if (!foundMap && foundStarMap) { 346 | foundMap = foundStarMap; 347 | foundI = starI; 348 | } 349 | 350 | if (foundMap) { 351 | nameParts.splice(0, foundI, foundMap); 352 | name = nameParts.join('/'); 353 | } 354 | } 355 | 356 | // If the name points to a package's name, use 357 | // the package main instead. 358 | pkgMain = getOwn(config.pkgs, name); 359 | 360 | return pkgMain ? pkgMain : name; 361 | } 362 | 363 | function removeScript(name) { 364 | if (isBrowser) { 365 | each(scripts(), function (scriptNode) { 366 | if (scriptNode.getAttribute('data-requiremodule') === name && 367 | scriptNode.getAttribute('data-requirecontext') === context.contextName) { 368 | scriptNode.parentNode.removeChild(scriptNode); 369 | return true; 370 | } 371 | }); 372 | } 373 | } 374 | 375 | function hasPathFallback(id) { 376 | var pathConfig = getOwn(config.paths, id); 377 | if (pathConfig && isArray(pathConfig) && pathConfig.length > 1) { 378 | //Pop off the first array value, since it failed, and 379 | //retry 380 | pathConfig.shift(); 381 | context.require.undef(id); 382 | context.require([id]); 383 | return true; 384 | } 385 | } 386 | 387 | //Turns a plugin!resource to [plugin, resource] 388 | //with the plugin being undefined if the name 389 | //did not have a plugin prefix. 390 | function splitPrefix(name) { 391 | var prefix, 392 | index = name ? name.indexOf('!') : -1; 393 | if (index > -1) { 394 | prefix = name.substring(0, index); 395 | name = name.substring(index + 1, name.length); 396 | } 397 | return [prefix, name]; 398 | } 399 | 400 | /** 401 | * Creates a module mapping that includes plugin prefix, module 402 | * name, and path. If parentModuleMap is provided it will 403 | * also normalize the name via require.normalize() 404 | * 405 | * @param {String} name the module name 406 | * @param {String} [parentModuleMap] parent module map 407 | * for the module name, used to resolve relative names. 408 | * @param {Boolean} isNormalized: is the ID already normalized. 409 | * This is true if this call is done for a define() module ID. 410 | * @param {Boolean} applyMap: apply the map config to the ID. 411 | * Should only be true if this map is for a dependency. 412 | * 413 | * @returns {Object} 414 | */ 415 | function makeModuleMap(name, parentModuleMap, isNormalized, applyMap) { 416 | var url, pluginModule, suffix, nameParts, 417 | prefix = null, 418 | parentName = parentModuleMap ? parentModuleMap.name : null, 419 | originalName = name, 420 | isDefine = true, 421 | normalizedName = ''; 422 | 423 | //If no name, then it means it is a require call, generate an 424 | //internal name. 425 | if (!name) { 426 | isDefine = false; 427 | name = '_@r' + (requireCounter += 1); 428 | } 429 | 430 | nameParts = splitPrefix(name); 431 | prefix = nameParts[0]; 432 | name = nameParts[1]; 433 | 434 | if (prefix) { 435 | prefix = normalize(prefix, parentName, applyMap); 436 | pluginModule = getOwn(defined, prefix); 437 | } 438 | 439 | //Account for relative paths if there is a base name. 440 | if (name) { 441 | if (prefix) { 442 | if (pluginModule && pluginModule.normalize) { 443 | //Plugin is loaded, use its normalize method. 444 | normalizedName = pluginModule.normalize(name, function (name) { 445 | return normalize(name, parentName, applyMap); 446 | }); 447 | } else { 448 | normalizedName = normalize(name, parentName, applyMap); 449 | } 450 | } else { 451 | //A regular module. 452 | normalizedName = normalize(name, parentName, applyMap); 453 | 454 | //Normalized name may be a plugin ID due to map config 455 | //application in normalize. The map config values must 456 | //already be normalized, so do not need to redo that part. 457 | nameParts = splitPrefix(normalizedName); 458 | prefix = nameParts[0]; 459 | normalizedName = nameParts[1]; 460 | isNormalized = true; 461 | 462 | url = context.nameToUrl(normalizedName); 463 | } 464 | } 465 | 466 | //If the id is a plugin id that cannot be determined if it needs 467 | //normalization, stamp it with a unique ID so two matching relative 468 | //ids that may conflict can be separate. 469 | suffix = prefix && !pluginModule && !isNormalized ? 470 | '_unnormalized' + (unnormalizedCounter += 1) : 471 | ''; 472 | 473 | return { 474 | prefix: prefix, 475 | name: normalizedName, 476 | parentMap: parentModuleMap, 477 | unnormalized: !!suffix, 478 | url: url, 479 | originalName: originalName, 480 | isDefine: isDefine, 481 | id: (prefix ? 482 | prefix + '!' + normalizedName : 483 | normalizedName) + suffix 484 | }; 485 | } 486 | 487 | function getModule(depMap) { 488 | var id = depMap.id, 489 | mod = getOwn(registry, id); 490 | 491 | if (!mod) { 492 | mod = registry[id] = new context.Module(depMap); 493 | } 494 | 495 | return mod; 496 | } 497 | 498 | function on(depMap, name, fn) { 499 | var id = depMap.id, 500 | mod = getOwn(registry, id); 501 | 502 | if (hasProp(defined, id) && 503 | (!mod || mod.defineEmitComplete)) { 504 | if (name === 'defined') { 505 | fn(defined[id]); 506 | } 507 | } else { 508 | mod = getModule(depMap); 509 | if (mod.error && name === 'error') { 510 | fn(mod.error); 511 | } else { 512 | mod.on(name, fn); 513 | } 514 | } 515 | } 516 | 517 | function onError(err, errback) { 518 | var ids = err.requireModules, 519 | notified = false; 520 | 521 | if (errback) { 522 | errback(err); 523 | } else { 524 | each(ids, function (id) { 525 | var mod = getOwn(registry, id); 526 | if (mod) { 527 | //Set error on module, so it skips timeout checks. 528 | mod.error = err; 529 | if (mod.events.error) { 530 | notified = true; 531 | mod.emit('error', err); 532 | } 533 | } 534 | }); 535 | 536 | if (!notified) { 537 | req.onError(err); 538 | } 539 | } 540 | } 541 | 542 | /** 543 | * Internal method to transfer globalQueue items to this context's 544 | * defQueue. 545 | */ 546 | function takeGlobalQueue() { 547 | //Push all the globalDefQueue items into the context's defQueue 548 | if (globalDefQueue.length) { 549 | //Array splice in the values since the context code has a 550 | //local var ref to defQueue, so cannot just reassign the one 551 | //on context. 552 | apsp.apply(defQueue, 553 | [defQueue.length, 0].concat(globalDefQueue)); 554 | globalDefQueue = []; 555 | } 556 | } 557 | 558 | handlers = { 559 | 'require': function (mod) { 560 | if (mod.require) { 561 | return mod.require; 562 | } else { 563 | return (mod.require = context.makeRequire(mod.map)); 564 | } 565 | }, 566 | 'exports': function (mod) { 567 | mod.usingExports = true; 568 | if (mod.map.isDefine) { 569 | if (mod.exports) { 570 | return (defined[mod.map.id] = mod.exports); 571 | } else { 572 | return (mod.exports = defined[mod.map.id] = {}); 573 | } 574 | } 575 | }, 576 | 'module': function (mod) { 577 | if (mod.module) { 578 | return mod.module; 579 | } else { 580 | return (mod.module = { 581 | id: mod.map.id, 582 | uri: mod.map.url, 583 | config: function () { 584 | return getOwn(config.config, mod.map.id) || {}; 585 | }, 586 | exports: mod.exports || (mod.exports = {}) 587 | }); 588 | } 589 | } 590 | }; 591 | 592 | function cleanRegistry(id) { 593 | //Clean up machinery used for waiting modules. 594 | delete registry[id]; 595 | delete enabledRegistry[id]; 596 | } 597 | 598 | function breakCycle(mod, traced, processed) { 599 | var id = mod.map.id; 600 | 601 | if (mod.error) { 602 | mod.emit('error', mod.error); 603 | } else { 604 | traced[id] = true; 605 | each(mod.depMaps, function (depMap, i) { 606 | var depId = depMap.id, 607 | dep = getOwn(registry, depId); 608 | 609 | //Only force things that have not completed 610 | //being defined, so still in the registry, 611 | //and only if it has not been matched up 612 | //in the module already. 613 | if (dep && !mod.depMatched[i] && !processed[depId]) { 614 | if (getOwn(traced, depId)) { 615 | mod.defineDep(i, defined[depId]); 616 | mod.check(); //pass false? 617 | } else { 618 | breakCycle(dep, traced, processed); 619 | } 620 | } 621 | }); 622 | processed[id] = true; 623 | } 624 | } 625 | 626 | function checkLoaded() { 627 | var err, usingPathFallback, 628 | waitInterval = config.waitSeconds * 1000, 629 | //It is possible to disable the wait interval by using waitSeconds of 0. 630 | expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(), 631 | noLoads = [], 632 | reqCalls = [], 633 | stillLoading = false, 634 | needCycleCheck = true; 635 | 636 | //Do not bother if this call was a result of a cycle break. 637 | if (inCheckLoaded) { 638 | return; 639 | } 640 | 641 | inCheckLoaded = true; 642 | 643 | //Figure out the state of all the modules. 644 | eachProp(enabledRegistry, function (mod) { 645 | var map = mod.map, 646 | modId = map.id; 647 | 648 | //Skip things that are not enabled or in error state. 649 | if (!mod.enabled) { 650 | return; 651 | } 652 | 653 | if (!map.isDefine) { 654 | reqCalls.push(mod); 655 | } 656 | 657 | if (!mod.error) { 658 | //If the module should be executed, and it has not 659 | //been inited and time is up, remember it. 660 | if (!mod.inited && expired) { 661 | if (hasPathFallback(modId)) { 662 | usingPathFallback = true; 663 | stillLoading = true; 664 | } else { 665 | noLoads.push(modId); 666 | removeScript(modId); 667 | } 668 | } else if (!mod.inited && mod.fetched && map.isDefine) { 669 | stillLoading = true; 670 | if (!map.prefix) { 671 | //No reason to keep looking for unfinished 672 | //loading. If the only stillLoading is a 673 | //plugin resource though, keep going, 674 | //because it may be that a plugin resource 675 | //is waiting on a non-plugin cycle. 676 | return (needCycleCheck = false); 677 | } 678 | } 679 | } 680 | }); 681 | 682 | if (expired && noLoads.length) { 683 | //If wait time expired, throw error of unloaded modules. 684 | err = makeError('timeout', 'Load timeout for modules: ' + noLoads, null, noLoads); 685 | err.contextName = context.contextName; 686 | return onError(err); 687 | } 688 | 689 | //Not expired, check for a cycle. 690 | if (needCycleCheck) { 691 | each(reqCalls, function (mod) { 692 | breakCycle(mod, {}, {}); 693 | }); 694 | } 695 | 696 | //If still waiting on loads, and the waiting load is something 697 | //other than a plugin resource, or there are still outstanding 698 | //scripts, then just try back later. 699 | if ((!expired || usingPathFallback) && stillLoading) { 700 | //Something is still waiting to load. Wait for it, but only 701 | //if a timeout is not already in effect. 702 | if ((isBrowser || isWebWorker) && !checkLoadedTimeoutId) { 703 | checkLoadedTimeoutId = setTimeout(function () { 704 | checkLoadedTimeoutId = 0; 705 | checkLoaded(); 706 | }, 50); 707 | } 708 | } 709 | 710 | inCheckLoaded = false; 711 | } 712 | 713 | Module = function (map) { 714 | this.events = getOwn(undefEvents, map.id) || {}; 715 | this.map = map; 716 | this.shim = getOwn(config.shim, map.id); 717 | this.depExports = []; 718 | this.depMaps = []; 719 | this.depMatched = []; 720 | this.pluginMaps = {}; 721 | this.depCount = 0; 722 | 723 | /* this.exports this.factory 724 | this.depMaps = [], 725 | this.enabled, this.fetched 726 | */ 727 | }; 728 | 729 | Module.prototype = { 730 | init: function (depMaps, factory, errback, options) { 731 | options = options || {}; 732 | 733 | //Do not do more inits if already done. Can happen if there 734 | //are multiple define calls for the same module. That is not 735 | //a normal, common case, but it is also not unexpected. 736 | if (this.inited) { 737 | return; 738 | } 739 | 740 | this.factory = factory; 741 | 742 | if (errback) { 743 | //Register for errors on this module. 744 | this.on('error', errback); 745 | } else if (this.events.error) { 746 | //If no errback already, but there are error listeners 747 | //on this module, set up an errback to pass to the deps. 748 | errback = bind(this, function (err) { 749 | this.emit('error', err); 750 | }); 751 | } 752 | 753 | //Do a copy of the dependency array, so that 754 | //source inputs are not modified. For example 755 | //"shim" deps are passed in here directly, and 756 | //doing a direct modification of the depMaps array 757 | //would affect that config. 758 | this.depMaps = depMaps && depMaps.slice(0); 759 | 760 | this.errback = errback; 761 | 762 | //Indicate this module has be initialized 763 | this.inited = true; 764 | 765 | this.ignore = options.ignore; 766 | 767 | //Could have option to init this module in enabled mode, 768 | //or could have been previously marked as enabled. However, 769 | //the dependencies are not known until init is called. So 770 | //if enabled previously, now trigger dependencies as enabled. 771 | if (options.enabled || this.enabled) { 772 | //Enable this module and dependencies. 773 | //Will call this.check() 774 | this.enable(); 775 | } else { 776 | this.check(); 777 | } 778 | }, 779 | 780 | defineDep: function (i, depExports) { 781 | //Because of cycles, defined callback for a given 782 | //export can be called more than once. 783 | if (!this.depMatched[i]) { 784 | this.depMatched[i] = true; 785 | this.depCount -= 1; 786 | this.depExports[i] = depExports; 787 | } 788 | }, 789 | 790 | fetch: function () { 791 | if (this.fetched) { 792 | return; 793 | } 794 | this.fetched = true; 795 | 796 | context.startTime = (new Date()).getTime(); 797 | 798 | var map = this.map; 799 | 800 | //If the manager is for a plugin managed resource, 801 | //ask the plugin to load it now. 802 | if (this.shim) { 803 | context.makeRequire(this.map, { 804 | enableBuildCallback: true 805 | })(this.shim.deps || [], bind(this, function () { 806 | return map.prefix ? this.callPlugin() : this.load(); 807 | })); 808 | } else { 809 | //Regular dependency. 810 | return map.prefix ? this.callPlugin() : this.load(); 811 | } 812 | }, 813 | 814 | load: function () { 815 | var url = this.map.url; 816 | 817 | //Regular dependency. 818 | if (!urlFetched[url]) { 819 | urlFetched[url] = true; 820 | context.load(this.map.id, url); 821 | } 822 | }, 823 | 824 | /** 825 | * Checks if the module is ready to define itself, and if so, 826 | * define it. 827 | */ 828 | check: function () { 829 | if (!this.enabled || this.enabling) { 830 | return; 831 | } 832 | 833 | var err, cjsModule, 834 | id = this.map.id, 835 | depExports = this.depExports, 836 | exports = this.exports, 837 | factory = this.factory; 838 | 839 | if (!this.inited) { 840 | this.fetch(); 841 | } else if (this.error) { 842 | this.emit('error', this.error); 843 | } else if (!this.defining) { 844 | //The factory could trigger another require call 845 | //that would result in checking this module to 846 | //define itself again. If already in the process 847 | //of doing that, skip this work. 848 | this.defining = true; 849 | 850 | if (this.depCount < 1 && !this.defined) { 851 | if (isFunction(factory)) { 852 | //If there is an error listener, favor passing 853 | //to that instead of throwing an error. However, 854 | //only do it for define()'d modules. require 855 | //errbacks should not be called for failures in 856 | //their callbacks (#699). However if a global 857 | //onError is set, use that. 858 | if ((this.events.error && this.map.isDefine) || 859 | req.onError !== defaultOnError) { 860 | try { 861 | exports = context.execCb(id, factory, depExports, exports); 862 | } catch (e) { 863 | err = e; 864 | } 865 | } else { 866 | exports = context.execCb(id, factory, depExports, exports); 867 | } 868 | 869 | // Favor return value over exports. If node/cjs in play, 870 | // then will not have a return value anyway. Favor 871 | // module.exports assignment over exports object. 872 | if (this.map.isDefine && exports === undefined) { 873 | cjsModule = this.module; 874 | if (cjsModule) { 875 | exports = cjsModule.exports; 876 | } else if (this.usingExports) { 877 | //exports already set the defined value. 878 | exports = this.exports; 879 | } 880 | } 881 | 882 | if (err) { 883 | err.requireMap = this.map; 884 | err.requireModules = this.map.isDefine ? [this.map.id] : null; 885 | err.requireType = this.map.isDefine ? 'define' : 'require'; 886 | return onError((this.error = err)); 887 | } 888 | 889 | } else { 890 | //Just a literal value 891 | exports = factory; 892 | } 893 | 894 | this.exports = exports; 895 | 896 | if (this.map.isDefine && !this.ignore) { 897 | defined[id] = exports; 898 | 899 | if (req.onResourceLoad) { 900 | req.onResourceLoad(context, this.map, this.depMaps); 901 | } 902 | } 903 | 904 | //Clean up 905 | cleanRegistry(id); 906 | 907 | this.defined = true; 908 | } 909 | 910 | //Finished the define stage. Allow calling check again 911 | //to allow define notifications below in the case of a 912 | //cycle. 913 | this.defining = false; 914 | 915 | if (this.defined && !this.defineEmitted) { 916 | this.defineEmitted = true; 917 | this.emit('defined', this.exports); 918 | this.defineEmitComplete = true; 919 | } 920 | 921 | } 922 | }, 923 | 924 | callPlugin: function () { 925 | var map = this.map, 926 | id = map.id, 927 | //Map already normalized the prefix. 928 | pluginMap = makeModuleMap(map.prefix); 929 | 930 | //Mark this as a dependency for this plugin, so it 931 | //can be traced for cycles. 932 | this.depMaps.push(pluginMap); 933 | 934 | on(pluginMap, 'defined', bind(this, function (plugin) { 935 | var load, normalizedMap, normalizedMod, 936 | bundleId = getOwn(bundlesMap, this.map.id), 937 | name = this.map.name, 938 | parentName = this.map.parentMap ? this.map.parentMap.name : null, 939 | localRequire = context.makeRequire(map.parentMap, { 940 | enableBuildCallback: true 941 | }); 942 | 943 | //If current map is not normalized, wait for that 944 | //normalized name to load instead of continuing. 945 | if (this.map.unnormalized) { 946 | //Normalize the ID if the plugin allows it. 947 | if (plugin.normalize) { 948 | name = plugin.normalize(name, function (name) { 949 | return normalize(name, parentName, true); 950 | }) || ''; 951 | } 952 | 953 | //prefix and name should already be normalized, no need 954 | //for applying map config again either. 955 | normalizedMap = makeModuleMap(map.prefix + '!' + name, 956 | this.map.parentMap); 957 | on(normalizedMap, 958 | 'defined', bind(this, function (value) { 959 | this.init([], function () { return value; }, null, { 960 | enabled: true, 961 | ignore: true 962 | }); 963 | })); 964 | 965 | normalizedMod = getOwn(registry, normalizedMap.id); 966 | if (normalizedMod) { 967 | //Mark this as a dependency for this plugin, so it 968 | //can be traced for cycles. 969 | this.depMaps.push(normalizedMap); 970 | 971 | if (this.events.error) { 972 | normalizedMod.on('error', bind(this, function (err) { 973 | this.emit('error', err); 974 | })); 975 | } 976 | normalizedMod.enable(); 977 | } 978 | 979 | return; 980 | } 981 | 982 | //If a paths config, then just load that file instead to 983 | //resolve the plugin, as it is built into that paths layer. 984 | if (bundleId) { 985 | this.map.url = context.nameToUrl(bundleId); 986 | this.load(); 987 | return; 988 | } 989 | 990 | load = bind(this, function (value) { 991 | this.init([], function () { return value; }, null, { 992 | enabled: true 993 | }); 994 | }); 995 | 996 | load.error = bind(this, function (err) { 997 | this.inited = true; 998 | this.error = err; 999 | err.requireModules = [id]; 1000 | 1001 | //Remove temp unnormalized modules for this module, 1002 | //since they will never be resolved otherwise now. 1003 | eachProp(registry, function (mod) { 1004 | if (mod.map.id.indexOf(id + '_unnormalized') === 0) { 1005 | cleanRegistry(mod.map.id); 1006 | } 1007 | }); 1008 | 1009 | onError(err); 1010 | }); 1011 | 1012 | //Allow plugins to load other code without having to know the 1013 | //context or how to 'complete' the load. 1014 | load.fromText = bind(this, function (text, textAlt) { 1015 | /*jslint evil: true */ 1016 | var moduleName = map.name, 1017 | moduleMap = makeModuleMap(moduleName), 1018 | hasInteractive = useInteractive; 1019 | 1020 | //As of 2.1.0, support just passing the text, to reinforce 1021 | //fromText only being called once per resource. Still 1022 | //support old style of passing moduleName but discard 1023 | //that moduleName in favor of the internal ref. 1024 | if (textAlt) { 1025 | text = textAlt; 1026 | } 1027 | 1028 | //Turn off interactive script matching for IE for any define 1029 | //calls in the text, then turn it back on at the end. 1030 | if (hasInteractive) { 1031 | useInteractive = false; 1032 | } 1033 | 1034 | //Prime the system by creating a module instance for 1035 | //it. 1036 | getModule(moduleMap); 1037 | 1038 | //Transfer any config to this other module. 1039 | if (hasProp(config.config, id)) { 1040 | config.config[moduleName] = config.config[id]; 1041 | } 1042 | 1043 | try { 1044 | req.exec(text); 1045 | } catch (e) { 1046 | return onError(makeError('fromtexteval', 1047 | 'fromText eval for ' + id + 1048 | ' failed: ' + e, 1049 | e, 1050 | [id])); 1051 | } 1052 | 1053 | if (hasInteractive) { 1054 | useInteractive = true; 1055 | } 1056 | 1057 | //Mark this as a dependency for the plugin 1058 | //resource 1059 | this.depMaps.push(moduleMap); 1060 | 1061 | //Support anonymous modules. 1062 | context.completeLoad(moduleName); 1063 | 1064 | //Bind the value of that module to the value for this 1065 | //resource ID. 1066 | localRequire([moduleName], load); 1067 | }); 1068 | 1069 | //Use parentName here since the plugin's name is not reliable, 1070 | //could be some weird string with no path that actually wants to 1071 | //reference the parentName's path. 1072 | plugin.load(map.name, localRequire, load, config); 1073 | })); 1074 | 1075 | context.enable(pluginMap, this); 1076 | this.pluginMaps[pluginMap.id] = pluginMap; 1077 | }, 1078 | 1079 | enable: function () { 1080 | enabledRegistry[this.map.id] = this; 1081 | this.enabled = true; 1082 | 1083 | //Set flag mentioning that the module is enabling, 1084 | //so that immediate calls to the defined callbacks 1085 | //for dependencies do not trigger inadvertent load 1086 | //with the depCount still being zero. 1087 | this.enabling = true; 1088 | 1089 | //Enable each dependency 1090 | each(this.depMaps, bind(this, function (depMap, i) { 1091 | var id, mod, handler; 1092 | 1093 | if (typeof depMap === 'string') { 1094 | //Dependency needs to be converted to a depMap 1095 | //and wired up to this module. 1096 | depMap = makeModuleMap(depMap, 1097 | (this.map.isDefine ? this.map : this.map.parentMap), 1098 | false, 1099 | !this.skipMap); 1100 | this.depMaps[i] = depMap; 1101 | 1102 | handler = getOwn(handlers, depMap.id); 1103 | 1104 | if (handler) { 1105 | this.depExports[i] = handler(this); 1106 | return; 1107 | } 1108 | 1109 | this.depCount += 1; 1110 | 1111 | on(depMap, 'defined', bind(this, function (depExports) { 1112 | this.defineDep(i, depExports); 1113 | this.check(); 1114 | })); 1115 | 1116 | if (this.errback) { 1117 | on(depMap, 'error', bind(this, this.errback)); 1118 | } 1119 | } 1120 | 1121 | id = depMap.id; 1122 | mod = registry[id]; 1123 | 1124 | //Skip special modules like 'require', 'exports', 'module' 1125 | //Also, don't call enable if it is already enabled, 1126 | //important in circular dependency cases. 1127 | if (!hasProp(handlers, id) && mod && !mod.enabled) { 1128 | context.enable(depMap, this); 1129 | } 1130 | })); 1131 | 1132 | //Enable each plugin that is used in 1133 | //a dependency 1134 | eachProp(this.pluginMaps, bind(this, function (pluginMap) { 1135 | var mod = getOwn(registry, pluginMap.id); 1136 | if (mod && !mod.enabled) { 1137 | context.enable(pluginMap, this); 1138 | } 1139 | })); 1140 | 1141 | this.enabling = false; 1142 | 1143 | this.check(); 1144 | }, 1145 | 1146 | on: function (name, cb) { 1147 | var cbs = this.events[name]; 1148 | if (!cbs) { 1149 | cbs = this.events[name] = []; 1150 | } 1151 | cbs.push(cb); 1152 | }, 1153 | 1154 | emit: function (name, evt) { 1155 | each(this.events[name], function (cb) { 1156 | cb(evt); 1157 | }); 1158 | if (name === 'error') { 1159 | //Now that the error handler was triggered, remove 1160 | //the listeners, since this broken Module instance 1161 | //can stay around for a while in the registry. 1162 | delete this.events[name]; 1163 | } 1164 | } 1165 | }; 1166 | 1167 | function callGetModule(args) { 1168 | //Skip modules already defined. 1169 | if (!hasProp(defined, args[0])) { 1170 | getModule(makeModuleMap(args[0], null, true)).init(args[1], args[2]); 1171 | } 1172 | } 1173 | 1174 | function removeListener(node, func, name, ieName) { 1175 | //Favor detachEvent because of IE9 1176 | //issue, see attachEvent/addEventListener comment elsewhere 1177 | //in this file. 1178 | if (node.detachEvent && !isOpera) { 1179 | //Probably IE. If not it will throw an error, which will be 1180 | //useful to know. 1181 | if (ieName) { 1182 | node.detachEvent(ieName, func); 1183 | } 1184 | } else { 1185 | node.removeEventListener(name, func, false); 1186 | } 1187 | } 1188 | 1189 | /** 1190 | * Given an event from a script node, get the requirejs info from it, 1191 | * and then removes the event listeners on the node. 1192 | * @param {Event} evt 1193 | * @returns {Object} 1194 | */ 1195 | function getScriptData(evt) { 1196 | //Using currentTarget instead of target for Firefox 2.0's sake. Not 1197 | //all old browsers will be supported, but this one was easy enough 1198 | //to support and still makes sense. 1199 | var node = evt.currentTarget || evt.srcElement; 1200 | 1201 | //Remove the listeners once here. 1202 | removeListener(node, context.onScriptLoad, 'load', 'onreadystatechange'); 1203 | removeListener(node, context.onScriptError, 'error'); 1204 | 1205 | return { 1206 | node: node, 1207 | id: node && node.getAttribute('data-requiremodule') 1208 | }; 1209 | } 1210 | 1211 | function intakeDefines() { 1212 | var args; 1213 | 1214 | //Any defined modules in the global queue, intake them now. 1215 | takeGlobalQueue(); 1216 | 1217 | //Make sure any remaining defQueue items get properly processed. 1218 | while (defQueue.length) { 1219 | args = defQueue.shift(); 1220 | if (args[0] === null) { 1221 | return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' + args[args.length - 1])); 1222 | } else { 1223 | //args are id, deps, factory. Should be normalized by the 1224 | //define() function. 1225 | callGetModule(args); 1226 | } 1227 | } 1228 | } 1229 | 1230 | context = { 1231 | config: config, 1232 | contextName: contextName, 1233 | registry: registry, 1234 | defined: defined, 1235 | urlFetched: urlFetched, 1236 | defQueue: defQueue, 1237 | Module: Module, 1238 | makeModuleMap: makeModuleMap, 1239 | nextTick: req.nextTick, 1240 | onError: onError, 1241 | 1242 | /** 1243 | * Set a configuration for the context. 1244 | * @param {Object} cfg config object to integrate. 1245 | */ 1246 | configure: function (cfg) { 1247 | //Make sure the baseUrl ends in a slash. 1248 | if (cfg.baseUrl) { 1249 | if (cfg.baseUrl.charAt(cfg.baseUrl.length - 1) !== '/') { 1250 | cfg.baseUrl += '/'; 1251 | } 1252 | } 1253 | 1254 | //Save off the paths since they require special processing, 1255 | //they are additive. 1256 | var shim = config.shim, 1257 | objs = { 1258 | paths: true, 1259 | bundles: true, 1260 | config: true, 1261 | map: true 1262 | }; 1263 | 1264 | eachProp(cfg, function (value, prop) { 1265 | if (objs[prop]) { 1266 | if (!config[prop]) { 1267 | config[prop] = {}; 1268 | } 1269 | mixin(config[prop], value, true, true); 1270 | } else { 1271 | config[prop] = value; 1272 | } 1273 | }); 1274 | 1275 | //Reverse map the bundles 1276 | if (cfg.bundles) { 1277 | eachProp(cfg.bundles, function (value, prop) { 1278 | each(value, function (v) { 1279 | if (v !== prop) { 1280 | bundlesMap[v] = prop; 1281 | } 1282 | }); 1283 | }); 1284 | } 1285 | 1286 | //Merge shim 1287 | if (cfg.shim) { 1288 | eachProp(cfg.shim, function (value, id) { 1289 | //Normalize the structure 1290 | if (isArray(value)) { 1291 | value = { 1292 | deps: value 1293 | }; 1294 | } 1295 | if ((value.exports || value.init) && !value.exportsFn) { 1296 | value.exportsFn = context.makeShimExports(value); 1297 | } 1298 | shim[id] = value; 1299 | }); 1300 | config.shim = shim; 1301 | } 1302 | 1303 | //Adjust packages if necessary. 1304 | if (cfg.packages) { 1305 | each(cfg.packages, function (pkgObj) { 1306 | var location, name; 1307 | 1308 | pkgObj = typeof pkgObj === 'string' ? { name: pkgObj } : pkgObj; 1309 | 1310 | name = pkgObj.name; 1311 | location = pkgObj.location; 1312 | if (location) { 1313 | config.paths[name] = pkgObj.location; 1314 | } 1315 | 1316 | //Save pointer to main module ID for pkg name. 1317 | //Remove leading dot in main, so main paths are normalized, 1318 | //and remove any trailing .js, since different package 1319 | //envs have different conventions: some use a module name, 1320 | //some use a file name. 1321 | config.pkgs[name] = pkgObj.name + '/' + (pkgObj.main || 'main') 1322 | .replace(currDirRegExp, '') 1323 | .replace(jsSuffixRegExp, ''); 1324 | }); 1325 | } 1326 | 1327 | //If there are any "waiting to execute" modules in the registry, 1328 | //update the maps for them, since their info, like URLs to load, 1329 | //may have changed. 1330 | eachProp(registry, function (mod, id) { 1331 | //If module already has init called, since it is too 1332 | //late to modify them, and ignore unnormalized ones 1333 | //since they are transient. 1334 | if (!mod.inited && !mod.map.unnormalized) { 1335 | mod.map = makeModuleMap(id); 1336 | } 1337 | }); 1338 | 1339 | //If a deps array or a config callback is specified, then call 1340 | //require with those args. This is useful when require is defined as a 1341 | //config object before require.js is loaded. 1342 | if (cfg.deps || cfg.callback) { 1343 | context.require(cfg.deps || [], cfg.callback); 1344 | } 1345 | }, 1346 | 1347 | makeShimExports: function (value) { 1348 | function fn() { 1349 | var ret; 1350 | if (value.init) { 1351 | ret = value.init.apply(global, arguments); 1352 | } 1353 | return ret || (value.exports && getGlobal(value.exports)); 1354 | } 1355 | return fn; 1356 | }, 1357 | 1358 | makeRequire: function (relMap, options) { 1359 | options = options || {}; 1360 | 1361 | function localRequire(deps, callback, errback) { 1362 | var id, map, requireMod; 1363 | 1364 | if (options.enableBuildCallback && callback && isFunction(callback)) { 1365 | callback.__requireJsBuild = true; 1366 | } 1367 | 1368 | if (typeof deps === 'string') { 1369 | if (isFunction(callback)) { 1370 | //Invalid call 1371 | return onError(makeError('requireargs', 'Invalid require call'), errback); 1372 | } 1373 | 1374 | //If require|exports|module are requested, get the 1375 | //value for them from the special handlers. Caveat: 1376 | //this only works while module is being defined. 1377 | if (relMap && hasProp(handlers, deps)) { 1378 | return handlers[deps](registry[relMap.id]); 1379 | } 1380 | 1381 | //Synchronous access to one module. If require.get is 1382 | //available (as in the Node adapter), prefer that. 1383 | if (req.get) { 1384 | return req.get(context, deps, relMap, localRequire); 1385 | } 1386 | 1387 | //Normalize module name, if it contains . or .. 1388 | map = makeModuleMap(deps, relMap, false, true); 1389 | id = map.id; 1390 | 1391 | if (!hasProp(defined, id)) { 1392 | return onError(makeError('notloaded', 'Module name "' + 1393 | id + 1394 | '" has not been loaded yet for context: ' + 1395 | contextName + 1396 | (relMap ? '' : '. Use require([])'))); 1397 | } 1398 | return defined[id]; 1399 | } 1400 | 1401 | //Grab defines waiting in the global queue. 1402 | intakeDefines(); 1403 | 1404 | //Mark all the dependencies as needing to be loaded. 1405 | context.nextTick(function () { 1406 | //Some defines could have been added since the 1407 | //require call, collect them. 1408 | intakeDefines(); 1409 | 1410 | requireMod = getModule(makeModuleMap(null, relMap)); 1411 | 1412 | //Store if map config should be applied to this require 1413 | //call for dependencies. 1414 | requireMod.skipMap = options.skipMap; 1415 | 1416 | requireMod.init(deps, callback, errback, { 1417 | enabled: true 1418 | }); 1419 | 1420 | checkLoaded(); 1421 | }); 1422 | 1423 | return localRequire; 1424 | } 1425 | 1426 | mixin(localRequire, { 1427 | isBrowser: isBrowser, 1428 | 1429 | /** 1430 | * Converts a module name + .extension into an URL path. 1431 | * *Requires* the use of a module name. It does not support using 1432 | * plain URLs like nameToUrl. 1433 | */ 1434 | toUrl: function (moduleNamePlusExt) { 1435 | var ext, 1436 | index = moduleNamePlusExt.lastIndexOf('.'), 1437 | segment = moduleNamePlusExt.split('/')[0], 1438 | isRelative = segment === '.' || segment === '..'; 1439 | 1440 | //Have a file extension alias, and it is not the 1441 | //dots from a relative path. 1442 | if (index !== -1 && (!isRelative || index > 1)) { 1443 | ext = moduleNamePlusExt.substring(index, moduleNamePlusExt.length); 1444 | moduleNamePlusExt = moduleNamePlusExt.substring(0, index); 1445 | } 1446 | 1447 | return context.nameToUrl(normalize(moduleNamePlusExt, 1448 | relMap && relMap.id, true), ext, true); 1449 | }, 1450 | 1451 | defined: function (id) { 1452 | return hasProp(defined, makeModuleMap(id, relMap, false, true).id); 1453 | }, 1454 | 1455 | specified: function (id) { 1456 | id = makeModuleMap(id, relMap, false, true).id; 1457 | return hasProp(defined, id) || hasProp(registry, id); 1458 | } 1459 | }); 1460 | 1461 | //Only allow undef on top level require calls 1462 | if (!relMap) { 1463 | localRequire.undef = function (id) { 1464 | //Bind any waiting define() calls to this context, 1465 | //fix for #408 1466 | takeGlobalQueue(); 1467 | 1468 | var map = makeModuleMap(id, relMap, true), 1469 | mod = getOwn(registry, id); 1470 | 1471 | removeScript(id); 1472 | 1473 | delete defined[id]; 1474 | delete urlFetched[map.url]; 1475 | delete undefEvents[id]; 1476 | 1477 | //Clean queued defines too. Go backwards 1478 | //in array so that the splices do not 1479 | //mess up the iteration. 1480 | eachReverse(defQueue, function(args, i) { 1481 | if(args[0] === id) { 1482 | defQueue.splice(i, 1); 1483 | } 1484 | }); 1485 | 1486 | if (mod) { 1487 | //Hold on to listeners in case the 1488 | //module will be attempted to be reloaded 1489 | //using a different config. 1490 | if (mod.events.defined) { 1491 | undefEvents[id] = mod.events; 1492 | } 1493 | 1494 | cleanRegistry(id); 1495 | } 1496 | }; 1497 | } 1498 | 1499 | return localRequire; 1500 | }, 1501 | 1502 | /** 1503 | * Called to enable a module if it is still in the registry 1504 | * awaiting enablement. A second arg, parent, the parent module, 1505 | * is passed in for context, when this method is overridden by 1506 | * the optimizer. Not shown here to keep code compact. 1507 | */ 1508 | enable: function (depMap) { 1509 | var mod = getOwn(registry, depMap.id); 1510 | if (mod) { 1511 | getModule(depMap).enable(); 1512 | } 1513 | }, 1514 | 1515 | /** 1516 | * Internal method used by environment adapters to complete a load event. 1517 | * A load event could be a script load or just a load pass from a synchronous 1518 | * load call. 1519 | * @param {String} moduleName the name of the module to potentially complete. 1520 | */ 1521 | completeLoad: function (moduleName) { 1522 | var found, args, mod, 1523 | shim = getOwn(config.shim, moduleName) || {}, 1524 | shExports = shim.exports; 1525 | 1526 | takeGlobalQueue(); 1527 | 1528 | while (defQueue.length) { 1529 | args = defQueue.shift(); 1530 | if (args[0] === null) { 1531 | args[0] = moduleName; 1532 | //If already found an anonymous module and bound it 1533 | //to this name, then this is some other anon module 1534 | //waiting for its completeLoad to fire. 1535 | if (found) { 1536 | break; 1537 | } 1538 | found = true; 1539 | } else if (args[0] === moduleName) { 1540 | //Found matching define call for this script! 1541 | found = true; 1542 | } 1543 | 1544 | callGetModule(args); 1545 | } 1546 | 1547 | //Do this after the cycle of callGetModule in case the result 1548 | //of those calls/init calls changes the registry. 1549 | mod = getOwn(registry, moduleName); 1550 | 1551 | if (!found && !hasProp(defined, moduleName) && mod && !mod.inited) { 1552 | if (config.enforceDefine && (!shExports || !getGlobal(shExports))) { 1553 | if (hasPathFallback(moduleName)) { 1554 | return; 1555 | } else { 1556 | return onError(makeError('nodefine', 1557 | 'No define call for ' + moduleName, 1558 | null, 1559 | [moduleName])); 1560 | } 1561 | } else { 1562 | //A script that does not call define(), so just simulate 1563 | //the call for it. 1564 | callGetModule([moduleName, (shim.deps || []), shim.exportsFn]); 1565 | } 1566 | } 1567 | 1568 | checkLoaded(); 1569 | }, 1570 | 1571 | /** 1572 | * Converts a module name to a file path. Supports cases where 1573 | * moduleName may actually be just an URL. 1574 | * Note that it **does not** call normalize on the moduleName, 1575 | * it is assumed to have already been normalized. This is an 1576 | * internal API, not a public one. Use toUrl for the public API. 1577 | */ 1578 | nameToUrl: function (moduleName, ext, skipExt) { 1579 | var paths, syms, i, parentModule, url, 1580 | parentPath, bundleId, 1581 | pkgMain = getOwn(config.pkgs, moduleName); 1582 | 1583 | if (pkgMain) { 1584 | moduleName = pkgMain; 1585 | } 1586 | 1587 | bundleId = getOwn(bundlesMap, moduleName); 1588 | 1589 | if (bundleId) { 1590 | return context.nameToUrl(bundleId, ext, skipExt); 1591 | } 1592 | 1593 | //If a colon is in the URL, it indicates a protocol is used and it is just 1594 | //an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?) 1595 | //or ends with .js, then assume the user meant to use an url and not a module id. 1596 | //The slash is important for protocol-less URLs as well as full paths. 1597 | if (req.jsExtRegExp.test(moduleName)) { 1598 | //Just a plain path, not module name lookup, so just return it. 1599 | //Add extension if it is included. This is a bit wonky, only non-.js things pass 1600 | //an extension, this method probably needs to be reworked. 1601 | url = moduleName + (ext || ''); 1602 | } else { 1603 | //A module that needs to be converted to a path. 1604 | paths = config.paths; 1605 | 1606 | syms = moduleName.split('/'); 1607 | //For each module name segment, see if there is a path 1608 | //registered for it. Start with most specific name 1609 | //and work up from it. 1610 | for (i = syms.length; i > 0; i -= 1) { 1611 | parentModule = syms.slice(0, i).join('/'); 1612 | 1613 | parentPath = getOwn(paths, parentModule); 1614 | if (parentPath) { 1615 | //If an array, it means there are a few choices, 1616 | //Choose the one that is desired 1617 | if (isArray(parentPath)) { 1618 | parentPath = parentPath[0]; 1619 | } 1620 | syms.splice(0, i, parentPath); 1621 | break; 1622 | } 1623 | } 1624 | 1625 | //Join the path parts together, then figure out if baseUrl is needed. 1626 | url = syms.join('/'); 1627 | url += (ext || (/^data\:|\?/.test(url) || skipExt ? '' : '.js')); 1628 | url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url; 1629 | } 1630 | 1631 | return config.urlArgs ? url + 1632 | ((url.indexOf('?') === -1 ? '?' : '&') + 1633 | config.urlArgs) : url; 1634 | }, 1635 | 1636 | //Delegates to req.load. Broken out as a separate function to 1637 | //allow overriding in the optimizer. 1638 | load: function (id, url) { 1639 | req.load(context, id, url); 1640 | }, 1641 | 1642 | /** 1643 | * Executes a module callback function. Broken out as a separate function 1644 | * solely to allow the build system to sequence the files in the built 1645 | * layer in the right sequence. 1646 | * 1647 | * @private 1648 | */ 1649 | execCb: function (name, callback, args, exports) { 1650 | return callback.apply(exports, args); 1651 | }, 1652 | 1653 | /** 1654 | * callback for script loads, used to check status of loading. 1655 | * 1656 | * @param {Event} evt the event from the browser for the script 1657 | * that was loaded. 1658 | */ 1659 | onScriptLoad: function (evt) { 1660 | //Using currentTarget instead of target for Firefox 2.0's sake. Not 1661 | //all old browsers will be supported, but this one was easy enough 1662 | //to support and still makes sense. 1663 | if (evt.type === 'load' || 1664 | (readyRegExp.test((evt.currentTarget || evt.srcElement).readyState))) { 1665 | //Reset interactive script so a script node is not held onto for 1666 | //to long. 1667 | interactiveScript = null; 1668 | 1669 | //Pull out the name of the module and the context. 1670 | var data = getScriptData(evt); 1671 | context.completeLoad(data.id); 1672 | } 1673 | }, 1674 | 1675 | /** 1676 | * Callback for script errors. 1677 | */ 1678 | onScriptError: function (evt) { 1679 | var data = getScriptData(evt); 1680 | if (!hasPathFallback(data.id)) { 1681 | return onError(makeError('scripterror', 'Script error for: ' + data.id, evt, [data.id])); 1682 | } 1683 | } 1684 | }; 1685 | 1686 | context.require = context.makeRequire(); 1687 | return context; 1688 | } 1689 | 1690 | /** 1691 | * Main entry point. 1692 | * 1693 | * If the only argument to require is a string, then the module that 1694 | * is represented by that string is fetched for the appropriate context. 1695 | * 1696 | * If the first argument is an array, then it will be treated as an array 1697 | * of dependency string names to fetch. An optional function callback can 1698 | * be specified to execute when all of those dependencies are available. 1699 | * 1700 | * Make a local req variable to help Caja compliance (it assumes things 1701 | * on a require that are not standardized), and to give a short 1702 | * name for minification/local scope use. 1703 | */ 1704 | req = requirejs = function (deps, callback, errback, optional) { 1705 | 1706 | //Find the right context, use default 1707 | var context, config, 1708 | contextName = defContextName; 1709 | 1710 | // Determine if have config object in the call. 1711 | if (!isArray(deps) && typeof deps !== 'string') { 1712 | // deps is a config object 1713 | config = deps; 1714 | if (isArray(callback)) { 1715 | // Adjust args if there are dependencies 1716 | deps = callback; 1717 | callback = errback; 1718 | errback = optional; 1719 | } else { 1720 | deps = []; 1721 | } 1722 | } 1723 | 1724 | if (config && config.context) { 1725 | contextName = config.context; 1726 | } 1727 | 1728 | context = getOwn(contexts, contextName); 1729 | if (!context) { 1730 | context = contexts[contextName] = req.s.newContext(contextName); 1731 | } 1732 | 1733 | if (config) { 1734 | context.configure(config); 1735 | } 1736 | 1737 | return context.require(deps, callback, errback); 1738 | }; 1739 | 1740 | /** 1741 | * Support require.config() to make it easier to cooperate with other 1742 | * AMD loaders on globally agreed names. 1743 | */ 1744 | req.config = function (config) { 1745 | return req(config); 1746 | }; 1747 | 1748 | /** 1749 | * Execute something after the current tick 1750 | * of the event loop. Override for other envs 1751 | * that have a better solution than setTimeout. 1752 | * @param {Function} fn function to execute later. 1753 | */ 1754 | req.nextTick = typeof setTimeout !== 'undefined' ? function (fn) { 1755 | setTimeout(fn, 4); 1756 | } : function (fn) { fn(); }; 1757 | 1758 | /** 1759 | * Export require as a global, but only if it does not already exist. 1760 | */ 1761 | if (!require) { 1762 | require = req; 1763 | } 1764 | 1765 | req.version = version; 1766 | 1767 | //Used to filter out dependencies that are already paths. 1768 | req.jsExtRegExp = /^\/|:|\?|\.js$/; 1769 | req.isBrowser = isBrowser; 1770 | s = req.s = { 1771 | contexts: contexts, 1772 | newContext: newContext 1773 | }; 1774 | 1775 | //Create default context. 1776 | req({}); 1777 | 1778 | //Exports some context-sensitive methods on global require. 1779 | each([ 1780 | 'toUrl', 1781 | 'undef', 1782 | 'defined', 1783 | 'specified' 1784 | ], function (prop) { 1785 | //Reference from contexts instead of early binding to default context, 1786 | //so that during builds, the latest instance of the default context 1787 | //with its config gets used. 1788 | req[prop] = function () { 1789 | var ctx = contexts[defContextName]; 1790 | return ctx.require[prop].apply(ctx, arguments); 1791 | }; 1792 | }); 1793 | 1794 | if (isBrowser) { 1795 | head = s.head = document.getElementsByTagName('head')[0]; 1796 | //If BASE tag is in play, using appendChild is a problem for IE6. 1797 | //When that browser dies, this can be removed. Details in this jQuery bug: 1798 | //http://dev.jquery.com/ticket/2709 1799 | baseElement = document.getElementsByTagName('base')[0]; 1800 | if (baseElement) { 1801 | head = s.head = baseElement.parentNode; 1802 | } 1803 | } 1804 | 1805 | /** 1806 | * Any errors that require explicitly generates will be passed to this 1807 | * function. Intercept/override it if you want custom error handling. 1808 | * @param {Error} err the error object. 1809 | */ 1810 | req.onError = defaultOnError; 1811 | 1812 | /** 1813 | * Creates the node for the load command. Only used in browser envs. 1814 | */ 1815 | req.createNode = function (config, moduleName, url) { 1816 | var node = config.xhtml ? 1817 | document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') : 1818 | document.createElement('script'); 1819 | node.type = config.scriptType || 'text/javascript'; 1820 | node.charset = 'utf-8'; 1821 | node.async = true; 1822 | return node; 1823 | }; 1824 | 1825 | /** 1826 | * Does the request to load a module for the browser case. 1827 | * Make this a separate function to allow other environments 1828 | * to override it. 1829 | * 1830 | * @param {Object} context the require context to find state. 1831 | * @param {String} moduleName the name of the module. 1832 | * @param {Object} url the URL to the module. 1833 | */ 1834 | req.load = function (context, moduleName, url) { 1835 | var config = (context && context.config) || {}, 1836 | node; 1837 | if (isBrowser) { 1838 | //In the browser so use a script tag 1839 | node = req.createNode(config, moduleName, url); 1840 | 1841 | node.setAttribute('data-requirecontext', context.contextName); 1842 | node.setAttribute('data-requiremodule', moduleName); 1843 | 1844 | //Set up load listener. Test attachEvent first because IE9 has 1845 | //a subtle issue in its addEventListener and script onload firings 1846 | //that do not match the behavior of all other browsers with 1847 | //addEventListener support, which fire the onload event for a 1848 | //script right after the script execution. See: 1849 | //https://connect.microsoft.com/IE/feedback/details/648057/script-onload-event-is-not-fired-immediately-after-script-execution 1850 | //UNFORTUNATELY Opera implements attachEvent but does not follow the script 1851 | //script execution mode. 1852 | if (node.attachEvent && 1853 | //Check if node.attachEvent is artificially added by custom script or 1854 | //natively supported by browser 1855 | //read https://github.com/jrburke/requirejs/issues/187 1856 | //if we can NOT find [native code] then it must NOT natively supported. 1857 | //in IE8, node.attachEvent does not have toString() 1858 | //Note the test for "[native code" with no closing brace, see: 1859 | //https://github.com/jrburke/requirejs/issues/273 1860 | !(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) && 1861 | !isOpera) { 1862 | //Probably IE. IE (at least 6-8) do not fire 1863 | //script onload right after executing the script, so 1864 | //we cannot tie the anonymous define call to a name. 1865 | //However, IE reports the script as being in 'interactive' 1866 | //readyState at the time of the define call. 1867 | useInteractive = true; 1868 | 1869 | node.attachEvent('onreadystatechange', context.onScriptLoad); 1870 | //It would be great to add an error handler here to catch 1871 | //404s in IE9+. However, onreadystatechange will fire before 1872 | //the error handler, so that does not help. If addEventListener 1873 | //is used, then IE will fire error before load, but we cannot 1874 | //use that pathway given the connect.microsoft.com issue 1875 | //mentioned above about not doing the 'script execute, 1876 | //then fire the script load event listener before execute 1877 | //next script' that other browsers do. 1878 | //Best hope: IE10 fixes the issues, 1879 | //and then destroys all installs of IE 6-9. 1880 | //node.attachEvent('onerror', context.onScriptError); 1881 | } else { 1882 | node.addEventListener('load', context.onScriptLoad, false); 1883 | node.addEventListener('error', context.onScriptError, false); 1884 | } 1885 | node.src = url; 1886 | 1887 | //For some cache cases in IE 6-8, the script executes before the end 1888 | //of the appendChild execution, so to tie an anonymous define 1889 | //call to the module name (which is stored on the node), hold on 1890 | //to a reference to this node, but clear after the DOM insertion. 1891 | currentlyAddingScript = node; 1892 | if (baseElement) { 1893 | head.insertBefore(node, baseElement); 1894 | } else { 1895 | head.appendChild(node); 1896 | } 1897 | currentlyAddingScript = null; 1898 | 1899 | return node; 1900 | } else if (isWebWorker) { 1901 | try { 1902 | //In a web worker, use importScripts. This is not a very 1903 | //efficient use of importScripts, importScripts will block until 1904 | //its script is downloaded and evaluated. However, if web workers 1905 | //are in play, the expectation that a build has been done so that 1906 | //only one script needs to be loaded anyway. This may need to be 1907 | //reevaluated if other use cases become common. 1908 | importScripts(url); 1909 | 1910 | //Account for anonymous modules 1911 | context.completeLoad(moduleName); 1912 | } catch (e) { 1913 | context.onError(makeError('importscripts', 1914 | 'importScripts failed for ' + 1915 | moduleName + ' at ' + url, 1916 | e, 1917 | [moduleName])); 1918 | } 1919 | } 1920 | }; 1921 | 1922 | function getInteractiveScript() { 1923 | if (interactiveScript && interactiveScript.readyState === 'interactive') { 1924 | return interactiveScript; 1925 | } 1926 | 1927 | eachReverse(scripts(), function (script) { 1928 | if (script.readyState === 'interactive') { 1929 | return (interactiveScript = script); 1930 | } 1931 | }); 1932 | return interactiveScript; 1933 | } 1934 | 1935 | //Look for a data-main script attribute, which could also adjust the baseUrl. 1936 | if (isBrowser && !cfg.skipDataMain) { 1937 | //Figure out baseUrl. Get it from the script tag with require.js in it. 1938 | eachReverse(scripts(), function (script) { 1939 | //Set the 'head' where we can append children by 1940 | //using the script's parent. 1941 | if (!head) { 1942 | head = script.parentNode; 1943 | } 1944 | 1945 | //Look for a data-main attribute to set main script for the page 1946 | //to load. If it is there, the path to data main becomes the 1947 | //baseUrl, if it is not already set. 1948 | dataMain = script.getAttribute('data-main'); 1949 | if (dataMain) { 1950 | //Preserve dataMain in case it is a path (i.e. contains '?') 1951 | mainScript = dataMain; 1952 | 1953 | //Set final baseUrl if there is not already an explicit one. 1954 | if (!cfg.baseUrl) { 1955 | //Pull off the directory of data-main for use as the 1956 | //baseUrl. 1957 | src = mainScript.split('/'); 1958 | mainScript = src.pop(); 1959 | subPath = src.length ? src.join('/') + '/' : './'; 1960 | 1961 | cfg.baseUrl = subPath; 1962 | } 1963 | 1964 | //Strip off any trailing .js since mainScript is now 1965 | //like a module name. 1966 | mainScript = mainScript.replace(jsSuffixRegExp, ''); 1967 | 1968 | //If mainScript is still a path, fall back to dataMain 1969 | if (req.jsExtRegExp.test(mainScript)) { 1970 | mainScript = dataMain; 1971 | } 1972 | 1973 | //Put the data-main script in the files to load. 1974 | cfg.deps = cfg.deps ? cfg.deps.concat(mainScript) : [mainScript]; 1975 | 1976 | return true; 1977 | } 1978 | }); 1979 | } 1980 | 1981 | /** 1982 | * The function that handles definitions of modules. Differs from 1983 | * require() in that a string for the module should be the first argument, 1984 | * and the function to execute after dependencies are loaded should 1985 | * return a value to define the module corresponding to the first argument's 1986 | * name. 1987 | */ 1988 | define = function (name, deps, callback) { 1989 | var node, context; 1990 | 1991 | //Allow for anonymous modules 1992 | if (typeof name !== 'string') { 1993 | //Adjust args appropriately 1994 | callback = deps; 1995 | deps = name; 1996 | name = null; 1997 | } 1998 | 1999 | //This module may not have dependencies 2000 | if (!isArray(deps)) { 2001 | callback = deps; 2002 | deps = null; 2003 | } 2004 | 2005 | //If no name, and callback is a function, then figure out if it a 2006 | //CommonJS thing with dependencies. 2007 | if (!deps && isFunction(callback)) { 2008 | deps = []; 2009 | //Remove comments from the callback string, 2010 | //look for require calls, and pull them into the dependencies, 2011 | //but only if there are function args. 2012 | if (callback.length) { 2013 | callback 2014 | .toString() 2015 | .replace(commentRegExp, '') 2016 | .replace(cjsRequireRegExp, function (match, dep) { 2017 | deps.push(dep); 2018 | }); 2019 | 2020 | //May be a CommonJS thing even without require calls, but still 2021 | //could use exports, and module. Avoid doing exports and module 2022 | //work though if it just needs require. 2023 | //REQUIRES the function to expect the CommonJS variables in the 2024 | //order listed below. 2025 | deps = (callback.length === 1 ? ['require'] : ['require', 'exports', 'module']).concat(deps); 2026 | } 2027 | } 2028 | 2029 | //If in IE 6-8 and hit an anonymous define() call, do the interactive 2030 | //work. 2031 | if (useInteractive) { 2032 | node = currentlyAddingScript || getInteractiveScript(); 2033 | if (node) { 2034 | if (!name) { 2035 | name = node.getAttribute('data-requiremodule'); 2036 | } 2037 | context = contexts[node.getAttribute('data-requirecontext')]; 2038 | } 2039 | } 2040 | 2041 | //Always save off evaluating the def call until the script onload handler. 2042 | //This allows multiple modules to be in a file without prematurely 2043 | //tracing dependencies, and allows for anonymous module support, 2044 | //where the module name is not known until the script onload event 2045 | //occurs. If no context, use the global queue, and get it processed 2046 | //in the onscript load callback. 2047 | (context ? context.defQueue : globalDefQueue).push([name, deps, callback]); 2048 | }; 2049 | 2050 | define.amd = { 2051 | jQuery: true 2052 | }; 2053 | 2054 | 2055 | /** 2056 | * Executes the text. Normally just uses eval, but can be modified 2057 | * to use a better, environment-specific call. Only used for transpiling 2058 | * loader plugins, not for plain JS modules. 2059 | * @param {String} text the text to execute/evaluate. 2060 | */ 2061 | req.exec = function (text) { 2062 | /*jslint evil: true */ 2063 | return eval(text); 2064 | }; 2065 | 2066 | //Set up with config info. 2067 | req(cfg); 2068 | }(this)); -------------------------------------------------------------------------------- /js/zepto.min.js: -------------------------------------------------------------------------------- 1 | /* Zepto 1.1.6 - zepto event ajax form detect fx fx_methods data deferred callbacks selector touch gesture - zeptojs.com/license */ 2 | var Zepto=function(){function A(t){return null==t?String(t):S[j.call(t)]||"object"}function D(t){return"function"==A(t)}function Z(t){return null!=t&&t==t.window}function L(t){return null!=t&&t.nodeType==t.DOCUMENT_NODE}function F(t){return"object"==A(t)}function $(t){return F(t)&&!Z(t)&&Object.getPrototypeOf(t)==Object.prototype}function _(t){return"number"==typeof t.length}function R(t){return s.call(t,function(t){return null!=t})}function z(t){return t.length>0?n.fn.concat.apply([],t):t}function q(t){return t.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}function I(t){return t in c?c[t]:c[t]=new RegExp("(^|\\s)"+t+"(\\s|$)")}function W(t,e){return"number"!=typeof e||l[q(t)]?e:e+"px"}function B(t){var e,n;return f[t]||(e=u.createElement(t),u.body.appendChild(e),n=getComputedStyle(e,"").getPropertyValue("display"),e.parentNode.removeChild(e),"none"==n&&(n="block"),f[t]=n),f[t]}function V(t){return"children"in t?a.call(t.children):n.map(t.childNodes,function(t){return 1==t.nodeType?t:void 0})}function H(t,e){var n,i=t?t.length:0;for(n=0;i>n;n++)this[n]=t[n];this.length=i,this.selector=e||""}function U(n,i,r){for(e in i)r&&($(i[e])||k(i[e]))?($(i[e])&&!$(n[e])&&(n[e]={}),k(i[e])&&!k(n[e])&&(n[e]=[]),U(n[e],i[e],r)):i[e]!==t&&(n[e]=i[e])}function X(t,e){return null==e?n(t):n(t).filter(e)}function Y(t,e,n,i){return D(e)?e.call(t,n,i):e}function J(t,e,n){null==n?t.removeAttribute(e):t.setAttribute(e,n)}function G(e,n){var i=e.className||"",r=i&&i.baseVal!==t;return n===t?r?i.baseVal:i:void(r?i.baseVal=n:e.className=n)}function K(t){try{return t?"true"==t||("false"==t?!1:"null"==t?null:+t+""==t?+t:/^[\[\{]/.test(t)?n.parseJSON(t):t):t}catch(e){return t}}function Q(t,e){e(t);for(var n=0,i=t.childNodes.length;i>n;n++)Q(t.childNodes[n],e)}var t,e,n,i,P,O,r=[],o=r.concat,s=r.filter,a=r.slice,u=window.document,f={},c={},l={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},h=/^\s*<(\w+|!)[^>]*>/,p=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,d=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,m=/^(?:body|html)$/i,g=/([A-Z])/g,v=["val","css","html","text","data","width","height","offset"],y=["after","prepend","before","append"],b=u.createElement("table"),w=u.createElement("tr"),x={tr:u.createElement("tbody"),tbody:b,thead:b,tfoot:b,td:w,th:w,"*":u.createElement("div")},E=/complete|loaded|interactive/,T=/^[\w-]*$/,S={},j=S.toString,C={},N=u.createElement("div"),M={tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},k=Array.isArray||function(t){return t instanceof Array};return C.matches=function(t,e){if(!e||!t||1!==t.nodeType)return!1;var n=t.webkitMatchesSelector||t.mozMatchesSelector||t.oMatchesSelector||t.matchesSelector;if(n)return n.call(t,e);var i,r=t.parentNode,o=!r;return o&&(r=N).appendChild(t),i=~C.qsa(r,e).indexOf(t),o&&N.removeChild(t),i},P=function(t){return t.replace(/-+(.)?/g,function(t,e){return e?e.toUpperCase():""})},O=function(t){return s.call(t,function(e,n){return t.indexOf(e)==n})},C.fragment=function(e,i,r){var o,s,f;return p.test(e)&&(o=n(u.createElement(RegExp.$1))),o||(e.replace&&(e=e.replace(d,"<$1>")),i===t&&(i=h.test(e)&&RegExp.$1),i in x||(i="*"),f=x[i],f.innerHTML=""+e,o=n.each(a.call(f.childNodes),function(){f.removeChild(this)})),$(r)&&(s=n(o),n.each(r,function(t,e){v.indexOf(t)>-1?s[t](e):s.attr(t,e)})),o},C.Z=function(t,e){return new H(t,e)},C.isZ=function(t){return t instanceof C.Z},C.init=function(e,i){var r;if(!e)return C.Z();if("string"==typeof e)if(e=e.trim(),"<"==e[0]&&h.test(e))r=C.fragment(e,RegExp.$1,i),e=null;else{if(i!==t)return n(i).find(e);r=C.qsa(u,e)}else{if(D(e))return n(u).ready(e);if(C.isZ(e))return e;if(k(e))r=R(e);else if(F(e))r=[e],e=null;else if(h.test(e))r=C.fragment(e.trim(),RegExp.$1,i),e=null;else{if(i!==t)return n(i).find(e);r=C.qsa(u,e)}}return C.Z(r,e)},n=function(t,e){return C.init(t,e)},n.extend=function(t){var e,n=a.call(arguments,1);return"boolean"==typeof t&&(e=t,t=n.shift()),n.forEach(function(n){U(t,n,e)}),t},C.qsa=function(t,e){var n,i="#"==e[0],r=!i&&"."==e[0],o=i||r?e.slice(1):e,s=T.test(o);return t.getElementById&&s&&i?(n=t.getElementById(o))?[n]:[]:1!==t.nodeType&&9!==t.nodeType&&11!==t.nodeType?[]:a.call(s&&!i&&t.getElementsByClassName?r?t.getElementsByClassName(o):t.getElementsByTagName(e):t.querySelectorAll(e))},n.contains=u.documentElement.contains?function(t,e){return t!==e&&t.contains(e)}:function(t,e){for(;e&&(e=e.parentNode);)if(e===t)return!0;return!1},n.type=A,n.isFunction=D,n.isWindow=Z,n.isArray=k,n.isPlainObject=$,n.isEmptyObject=function(t){var e;for(e in t)return!1;return!0},n.inArray=function(t,e,n){return r.indexOf.call(e,t,n)},n.camelCase=P,n.trim=function(t){return null==t?"":String.prototype.trim.call(t)},n.uuid=0,n.support={},n.expr={},n.noop=function(){},n.map=function(t,e){var n,r,o,i=[];if(_(t))for(r=0;r=0?e:e+this.length]},toArray:function(){return this.get()},size:function(){return this.length},remove:function(){return this.each(function(){null!=this.parentNode&&this.parentNode.removeChild(this)})},each:function(t){return r.every.call(this,function(e,n){return t.call(e,n,e)!==!1}),this},filter:function(t){return D(t)?this.not(this.not(t)):n(s.call(this,function(e){return C.matches(e,t)}))},add:function(t,e){return n(O(this.concat(n(t,e))))},is:function(t){return this.length>0&&C.matches(this[0],t)},not:function(e){var i=[];if(D(e)&&e.call!==t)this.each(function(t){e.call(this,t)||i.push(this)});else{var r="string"==typeof e?this.filter(e):_(e)&&D(e.item)?a.call(e):n(e);this.forEach(function(t){r.indexOf(t)<0&&i.push(t)})}return n(i)},has:function(t){return this.filter(function(){return F(t)?n.contains(this,t):n(this).find(t).size()})},eq:function(t){return-1===t?this.slice(t):this.slice(t,+t+1)},first:function(){var t=this[0];return t&&!F(t)?t:n(t)},last:function(){var t=this[this.length-1];return t&&!F(t)?t:n(t)},find:function(t){var e,i=this;return e=t?"object"==typeof t?n(t).filter(function(){var t=this;return r.some.call(i,function(e){return n.contains(e,t)})}):1==this.length?n(C.qsa(this[0],t)):this.map(function(){return C.qsa(this,t)}):n()},closest:function(t,e){var i=this[0],r=!1;for("object"==typeof t&&(r=n(t));i&&!(r?r.indexOf(i)>=0:C.matches(i,t));)i=i!==e&&!L(i)&&i.parentNode;return n(i)},parents:function(t){for(var e=[],i=this;i.length>0;)i=n.map(i,function(t){return(t=t.parentNode)&&!L(t)&&e.indexOf(t)<0?(e.push(t),t):void 0});return X(e,t)},parent:function(t){return X(O(this.pluck("parentNode")),t)},children:function(t){return X(this.map(function(){return V(this)}),t)},contents:function(){return this.map(function(){return this.contentDocument||a.call(this.childNodes)})},siblings:function(t){return X(this.map(function(t,e){return s.call(V(e.parentNode),function(t){return t!==e})}),t)},empty:function(){return this.each(function(){this.innerHTML=""})},pluck:function(t){return n.map(this,function(e){return e[t]})},show:function(){return this.each(function(){"none"==this.style.display&&(this.style.display=""),"none"==getComputedStyle(this,"").getPropertyValue("display")&&(this.style.display=B(this.nodeName))})},replaceWith:function(t){return this.before(t).remove()},wrap:function(t){var e=D(t);if(this[0]&&!e)var i=n(t).get(0),r=i.parentNode||this.length>1;return this.each(function(o){n(this).wrapAll(e?t.call(this,o):r?i.cloneNode(!0):i)})},wrapAll:function(t){if(this[0]){n(this[0]).before(t=n(t));for(var e;(e=t.children()).length;)t=e.first();n(t).append(this)}return this},wrapInner:function(t){var e=D(t);return this.each(function(i){var r=n(this),o=r.contents(),s=e?t.call(this,i):t;o.length?o.wrapAll(s):r.append(s)})},unwrap:function(){return this.parent().each(function(){n(this).replaceWith(n(this).children())}),this},clone:function(){return this.map(function(){return this.cloneNode(!0)})},hide:function(){return this.css("display","none")},toggle:function(e){return this.each(function(){var i=n(this);(e===t?"none"==i.css("display"):e)?i.show():i.hide()})},prev:function(t){return n(this.pluck("previousElementSibling")).filter(t||"*")},next:function(t){return n(this.pluck("nextElementSibling")).filter(t||"*")},html:function(t){return 0 in arguments?this.each(function(e){var i=this.innerHTML;n(this).empty().append(Y(this,t,e,i))}):0 in this?this[0].innerHTML:null},text:function(t){return 0 in arguments?this.each(function(e){var n=Y(this,t,e,this.textContent);this.textContent=null==n?"":""+n}):0 in this?this.pluck("textContent").join(""):null},attr:function(n,i){var r;return"string"!=typeof n||1 in arguments?this.each(function(t){if(1===this.nodeType)if(F(n))for(e in n)J(this,e,n[e]);else J(this,n,Y(this,i,t,this.getAttribute(n)))}):this.length&&1===this[0].nodeType?!(r=this[0].getAttribute(n))&&n in this[0]?this[0][n]:r:t},removeAttr:function(t){return this.each(function(){1===this.nodeType&&t.split(" ").forEach(function(t){J(this,t)},this)})},prop:function(t,e){return t=M[t]||t,1 in arguments?this.each(function(n){this[t]=Y(this,e,n,this[t])}):this[0]&&this[0][t]},data:function(e,n){var i="data-"+e.replace(g,"-$1").toLowerCase(),r=1 in arguments?this.attr(i,n):this.attr(i);return null!==r?K(r):t},val:function(t){return 0 in arguments?this.each(function(e){this.value=Y(this,t,e,this.value)}):this[0]&&(this[0].multiple?n(this[0]).find("option").filter(function(){return this.selected}).pluck("value"):this[0].value)},offset:function(t){if(t)return this.each(function(e){var i=n(this),r=Y(this,t,e,i.offset()),o=i.offsetParent().offset(),s={top:r.top-o.top,left:r.left-o.left};"static"==i.css("position")&&(s.position="relative"),i.css(s)});if(!this.length)return null;if(!n.contains(u.documentElement,this[0]))return{top:0,left:0};var e=this[0].getBoundingClientRect();return{left:e.left+window.pageXOffset,top:e.top+window.pageYOffset,width:Math.round(e.width),height:Math.round(e.height)}},css:function(t,i){if(arguments.length<2){var r,o=this[0];if(!o)return;if(r=getComputedStyle(o,""),"string"==typeof t)return o.style[P(t)]||r.getPropertyValue(t);if(k(t)){var s={};return n.each(t,function(t,e){s[e]=o.style[P(e)]||r.getPropertyValue(e)}),s}}var a="";if("string"==A(t))i||0===i?a=q(t)+":"+W(t,i):this.each(function(){this.style.removeProperty(q(t))});else for(e in t)t[e]||0===t[e]?a+=q(e)+":"+W(e,t[e])+";":this.each(function(){this.style.removeProperty(q(e))});return this.each(function(){this.style.cssText+=";"+a})},index:function(t){return t?this.indexOf(n(t)[0]):this.parent().children().indexOf(this[0])},hasClass:function(t){return t?r.some.call(this,function(t){return this.test(G(t))},I(t)):!1},addClass:function(t){return t?this.each(function(e){if("className"in this){i=[];var r=G(this),o=Y(this,t,e,r);o.split(/\s+/g).forEach(function(t){n(this).hasClass(t)||i.push(t)},this),i.length&&G(this,r+(r?" ":"")+i.join(" "))}}):this},removeClass:function(e){return this.each(function(n){if("className"in this){if(e===t)return G(this,"");i=G(this),Y(this,e,n,i).split(/\s+/g).forEach(function(t){i=i.replace(I(t)," ")}),G(this,i.trim())}})},toggleClass:function(e,i){return e?this.each(function(r){var o=n(this),s=Y(this,e,r,G(this));s.split(/\s+/g).forEach(function(e){(i===t?!o.hasClass(e):i)?o.addClass(e):o.removeClass(e)})}):this},scrollTop:function(e){if(this.length){var n="scrollTop"in this[0];return e===t?n?this[0].scrollTop:this[0].pageYOffset:this.each(n?function(){this.scrollTop=e}:function(){this.scrollTo(this.scrollX,e)})}},scrollLeft:function(e){if(this.length){var n="scrollLeft"in this[0];return e===t?n?this[0].scrollLeft:this[0].pageXOffset:this.each(n?function(){this.scrollLeft=e}:function(){this.scrollTo(e,this.scrollY)})}},position:function(){if(this.length){var t=this[0],e=this.offsetParent(),i=this.offset(),r=m.test(e[0].nodeName)?{top:0,left:0}:e.offset();return i.top-=parseFloat(n(t).css("margin-top"))||0,i.left-=parseFloat(n(t).css("margin-left"))||0,r.top+=parseFloat(n(e[0]).css("border-top-width"))||0,r.left+=parseFloat(n(e[0]).css("border-left-width"))||0,{top:i.top-r.top,left:i.left-r.left}}},offsetParent:function(){return this.map(function(){for(var t=this.offsetParent||u.body;t&&!m.test(t.nodeName)&&"static"==n(t).css("position");)t=t.offsetParent;return t})}},n.fn.detach=n.fn.remove,["width","height"].forEach(function(e){var i=e.replace(/./,function(t){return t[0].toUpperCase()});n.fn[e]=function(r){var o,s=this[0];return r===t?Z(s)?s["inner"+i]:L(s)?s.documentElement["scroll"+i]:(o=this.offset())&&o[e]:this.each(function(t){s=n(this),s.css(e,Y(this,r,t,s[e]()))})}}),y.forEach(function(t,e){var i=e%2;n.fn[t]=function(){var t,o,r=n.map(arguments,function(e){return t=A(e),"object"==t||"array"==t||null==e?e:C.fragment(e)}),s=this.length>1;return r.length<1?this:this.each(function(t,a){o=i?a:a.parentNode,a=0==e?a.nextSibling:1==e?a.firstChild:2==e?a:null;var f=n.contains(u.documentElement,o);r.forEach(function(t){if(s)t=t.cloneNode(!0);else if(!o)return n(t).remove();o.insertBefore(t,a),f&&Q(t,function(t){null==t.nodeName||"SCRIPT"!==t.nodeName.toUpperCase()||t.type&&"text/javascript"!==t.type||t.src||window.eval.call(window,t.innerHTML)})})})},n.fn[i?t+"To":"insert"+(e?"Before":"After")]=function(e){return n(e)[t](this),this}}),C.Z.prototype=H.prototype=n.fn,C.uniq=O,C.deserializeValue=K,n.zepto=C,n}();window.Zepto=Zepto,void 0===window.$&&(window.$=Zepto),function(t){function l(t){return t._zid||(t._zid=e++)}function h(t,e,n,i){if(e=p(e),e.ns)var r=d(e.ns);return(s[l(t)]||[]).filter(function(t){return t&&(!e.e||t.e==e.e)&&(!e.ns||r.test(t.ns))&&(!n||l(t.fn)===l(n))&&(!i||t.sel==i)})}function p(t){var e=(""+t).split(".");return{e:e[0],ns:e.slice(1).sort().join(" ")}}function d(t){return new RegExp("(?:^| )"+t.replace(" "," .* ?")+"(?: |$)")}function m(t,e){return t.del&&!u&&t.e in f||!!e}function g(t){return c[t]||u&&f[t]||t}function v(e,i,r,o,a,u,f){var h=l(e),d=s[h]||(s[h]=[]);i.split(/\s/).forEach(function(i){if("ready"==i)return t(document).ready(r);var s=p(i);s.fn=r,s.sel=a,s.e in c&&(r=function(e){var n=e.relatedTarget;return!n||n!==this&&!t.contains(this,n)?s.fn.apply(this,arguments):void 0}),s.del=u;var l=u||r;s.proxy=function(t){if(t=T(t),!t.isImmediatePropagationStopped()){t.data=o;var i=l.apply(e,t._args==n?[t]:[t].concat(t._args));return i===!1&&(t.preventDefault(),t.stopPropagation()),i}},s.i=d.length,d.push(s),"addEventListener"in e&&e.addEventListener(g(s.e),s.proxy,m(s,f))})}function y(t,e,n,i,r){var o=l(t);(e||"").split(/\s/).forEach(function(e){h(t,e,n,i).forEach(function(e){delete s[o][e.i],"removeEventListener"in t&&t.removeEventListener(g(e.e),e.proxy,m(e,r))})})}function T(e,i){return(i||!e.isDefaultPrevented)&&(i||(i=e),t.each(E,function(t,n){var r=i[t];e[t]=function(){return this[n]=b,r&&r.apply(i,arguments)},e[n]=w}),(i.defaultPrevented!==n?i.defaultPrevented:"returnValue"in i?i.returnValue===!1:i.getPreventDefault&&i.getPreventDefault())&&(e.isDefaultPrevented=b)),e}function S(t){var e,i={originalEvent:t};for(e in t)x.test(e)||t[e]===n||(i[e]=t[e]);return T(i,t)}var n,e=1,i=Array.prototype.slice,r=t.isFunction,o=function(t){return"string"==typeof t},s={},a={},u="onfocusin"in window,f={focus:"focusin",blur:"focusout"},c={mouseenter:"mouseover",mouseleave:"mouseout"};a.click=a.mousedown=a.mouseup=a.mousemove="MouseEvents",t.event={add:v,remove:y},t.proxy=function(e,n){var s=2 in arguments&&i.call(arguments,2);if(r(e)){var a=function(){return e.apply(n,s?s.concat(i.call(arguments)):arguments)};return a._zid=l(e),a}if(o(n))return s?(s.unshift(e[n],e),t.proxy.apply(null,s)):t.proxy(e[n],e);throw new TypeError("expected function")},t.fn.bind=function(t,e,n){return this.on(t,e,n)},t.fn.unbind=function(t,e){return this.off(t,e)},t.fn.one=function(t,e,n,i){return this.on(t,e,n,i,1)};var b=function(){return!0},w=function(){return!1},x=/^([A-Z]|returnValue$|layer[XY]$)/,E={preventDefault:"isDefaultPrevented",stopImmediatePropagation:"isImmediatePropagationStopped",stopPropagation:"isPropagationStopped"};t.fn.delegate=function(t,e,n){return this.on(e,t,n)},t.fn.undelegate=function(t,e,n){return this.off(e,t,n)},t.fn.live=function(e,n){return t(document.body).delegate(this.selector,e,n),this},t.fn.die=function(e,n){return t(document.body).undelegate(this.selector,e,n),this},t.fn.on=function(e,s,a,u,f){var c,l,h=this;return e&&!o(e)?(t.each(e,function(t,e){h.on(t,s,a,e,f)}),h):(o(s)||r(u)||u===!1||(u=a,a=s,s=n),(u===n||a===!1)&&(u=a,a=n),u===!1&&(u=w),h.each(function(n,r){f&&(c=function(t){return y(r,t.type,u),u.apply(this,arguments)}),s&&(l=function(e){var n,o=t(e.target).closest(s,r).get(0);return o&&o!==r?(n=t.extend(S(e),{currentTarget:o,liveFired:r}),(c||u).apply(o,[n].concat(i.call(arguments,1)))):void 0}),v(r,e,u,a,s,l||c)}))},t.fn.off=function(e,i,s){var a=this;return e&&!o(e)?(t.each(e,function(t,e){a.off(t,i,e)}),a):(o(i)||r(s)||s===!1||(s=i,i=n),s===!1&&(s=w),a.each(function(){y(this,e,s,i)}))},t.fn.trigger=function(e,n){return e=o(e)||t.isPlainObject(e)?t.Event(e):T(e),e._args=n,this.each(function(){e.type in f&&"function"==typeof this[e.type]?this[e.type]():"dispatchEvent"in this?this.dispatchEvent(e):t(this).triggerHandler(e,n)})},t.fn.triggerHandler=function(e,n){var i,r;return this.each(function(s,a){i=S(o(e)?t.Event(e):e),i._args=n,i.target=a,t.each(h(a,e.type||e),function(t,e){return r=e.proxy(i),i.isImmediatePropagationStopped()?!1:void 0})}),r},"focusin focusout focus blur load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select keydown keypress keyup error".split(" ").forEach(function(e){t.fn[e]=function(t){return 0 in arguments?this.bind(e,t):this.trigger(e)}}),t.Event=function(t,e){o(t)||(e=t,t=e.type);var n=document.createEvent(a[t]||"Events"),i=!0;if(e)for(var r in e)"bubbles"==r?i=!!e[r]:n[r]=e[r];return n.initEvent(t,i,!0),T(n)}}(Zepto),function(t){function h(e,n,i){var r=t.Event(n);return t(e).trigger(r,i),!r.isDefaultPrevented()}function p(t,e,i,r){return t.global?h(e||n,i,r):void 0}function d(e){e.global&&0===t.active++&&p(e,null,"ajaxStart")}function m(e){e.global&&!--t.active&&p(e,null,"ajaxStop")}function g(t,e){var n=e.context;return e.beforeSend.call(n,t,e)===!1||p(e,n,"ajaxBeforeSend",[t,e])===!1?!1:void p(e,n,"ajaxSend",[t,e])}function v(t,e,n,i){var r=n.context,o="success";n.success.call(r,t,o,e),i&&i.resolveWith(r,[t,o,e]),p(n,r,"ajaxSuccess",[e,n,t]),b(o,e,n)}function y(t,e,n,i,r){var o=i.context;i.error.call(o,n,e,t),r&&r.rejectWith(o,[n,e,t]),p(i,o,"ajaxError",[n,i,t||e]),b(e,n,i)}function b(t,e,n){var i=n.context;n.complete.call(i,e,t),p(n,i,"ajaxComplete",[e,n]),m(n)}function w(){}function x(t){return t&&(t=t.split(";",2)[0]),t&&(t==f?"html":t==u?"json":s.test(t)?"script":a.test(t)&&"xml")||"text"}function E(t,e){return""==e?t:(t+"&"+e).replace(/[&?]{1,2}/,"?")}function T(e){e.processData&&e.data&&"string"!=t.type(e.data)&&(e.data=t.param(e.data,e.traditional)),!e.data||e.type&&"GET"!=e.type.toUpperCase()||(e.url=E(e.url,e.data),e.data=void 0)}function S(e,n,i,r){return t.isFunction(n)&&(r=i,i=n,n=void 0),t.isFunction(i)||(r=i,i=void 0),{url:e,data:n,success:i,dataType:r}}function C(e,n,i,r){var o,s=t.isArray(n),a=t.isPlainObject(n);t.each(n,function(n,u){o=t.type(u),r&&(n=i?r:r+"["+(a||"object"==o||"array"==o?n:"")+"]"),!r&&s?e.add(u.name,u.value):"array"==o||!i&&"object"==o?C(e,u,i,n):e.add(n,u)})}var i,r,e=0,n=window.document,o=/)<[^<]*)*<\/script>/gi,s=/^(?:text|application)\/javascript/i,a=/^(?:text|application)\/xml/i,u="application/json",f="text/html",c=/^\s*$/,l=n.createElement("a");l.href=window.location.href,t.active=0,t.ajaxJSONP=function(i,r){if(!("type"in i))return t.ajax(i);var f,h,o=i.jsonpCallback,s=(t.isFunction(o)?o():o)||"jsonp"+ ++e,a=n.createElement("script"),u=window[s],c=function(e){t(a).triggerHandler("error",e||"abort")},l={abort:c};return r&&r.promise(l),t(a).on("load error",function(e,n){clearTimeout(h),t(a).off().remove(),"error"!=e.type&&f?v(f[0],l,i,r):y(null,n||"error",l,i,r),window[s]=u,f&&t.isFunction(u)&&u(f[0]),u=f=void 0}),g(l,i)===!1?(c("abort"),l):(window[s]=function(){f=arguments},a.src=i.url.replace(/\?(.+)=\?/,"?$1="+s),n.head.appendChild(a),i.timeout>0&&(h=setTimeout(function(){c("timeout")},i.timeout)),l)},t.ajaxSettings={type:"GET",beforeSend:w,success:w,error:w,complete:w,context:null,global:!0,xhr:function(){return new window.XMLHttpRequest},accepts:{script:"text/javascript, application/javascript, application/x-javascript",json:u,xml:"application/xml, text/xml",html:f,text:"text/plain"},crossDomain:!1,timeout:0,processData:!0,cache:!0},t.ajax=function(e){var a,u,o=t.extend({},e||{}),s=t.Deferred&&t.Deferred();for(i in t.ajaxSettings)void 0===o[i]&&(o[i]=t.ajaxSettings[i]);d(o),o.crossDomain||(a=n.createElement("a"),a.href=o.url,a.href=a.href,o.crossDomain=l.protocol+"//"+l.host!=a.protocol+"//"+a.host),o.url||(o.url=window.location.toString()),(u=o.url.indexOf("#"))>-1&&(o.url=o.url.slice(0,u)),T(o);var f=o.dataType,h=/\?.+=\?/.test(o.url);if(h&&(f="jsonp"),o.cache!==!1&&(e&&e.cache===!0||"script"!=f&&"jsonp"!=f)||(o.url=E(o.url,"_="+Date.now())),"jsonp"==f)return h||(o.url=E(o.url,o.jsonp?o.jsonp+"=?":o.jsonp===!1?"":"callback=?")),t.ajaxJSONP(o,s);var P,p=o.accepts[f],m={},b=function(t,e){m[t.toLowerCase()]=[t,e]},S=/^([\w-]+:)\/\//.test(o.url)?RegExp.$1:window.location.protocol,j=o.xhr(),C=j.setRequestHeader;if(s&&s.promise(j),o.crossDomain||b("X-Requested-With","XMLHttpRequest"),b("Accept",p||"*/*"),(p=o.mimeType||p)&&(p.indexOf(",")>-1&&(p=p.split(",",2)[0]),j.overrideMimeType&&j.overrideMimeType(p)),(o.contentType||o.contentType!==!1&&o.data&&"GET"!=o.type.toUpperCase())&&b("Content-Type",o.contentType||"application/x-www-form-urlencoded"),o.headers)for(r in o.headers)b(r,o.headers[r]);if(j.setRequestHeader=b,j.onreadystatechange=function(){if(4==j.readyState){j.onreadystatechange=w,clearTimeout(P);var e,n=!1;if(j.status>=200&&j.status<300||304==j.status||0==j.status&&"file:"==S){if(f=f||x(o.mimeType||j.getResponseHeader("content-type")),"arraybuffer"==j.responseType||"blob"==j.responseType)e=j.response;else{e=j.responseText;try{"script"==f?(1,eval)(e):"xml"==f?e=j.responseXML:"json"==f&&(e=c.test(e)?null:t.parseJSON(e))}catch(i){n=i}if(n)return y(n,"parsererror",j,o,s)}v(e,j,o,s)}else y(j.statusText||null,j.status?"error":"abort",j,o,s)}},g(j,o)===!1)return j.abort(),y(null,"abort",j,o,s),j;if(o.xhrFields)for(r in o.xhrFields)j[r]=o.xhrFields[r];var O="async"in o?o.async:!0;j.open(o.type,o.url,O,o.username,o.password);for(r in m)C.apply(j,m[r]);return o.timeout>0&&(P=setTimeout(function(){j.onreadystatechange=w,j.abort(),y(null,"timeout",j,o,s)},o.timeout)),j.send(o.data?o.data:null),j},t.get=function(){return t.ajax(S.apply(null,arguments))},t.post=function(){var e=S.apply(null,arguments);return e.type="POST",t.ajax(e)},t.getJSON=function(){var e=S.apply(null,arguments);return e.dataType="json",t.ajax(e)},t.fn.load=function(e,n,i){if(!this.length)return this;var a,r=this,s=e.split(/\s/),u=S(e,n,i),f=u.success;return s.length>1&&(u.url=s[0],a=s[1]),u.success=function(e){r.html(a?t("
").html(e.replace(o,"")).find(a):e),f&&f.apply(r,arguments)},t.ajax(u),this};var j=encodeURIComponent;t.param=function(e,n){var i=[];return i.add=function(e,n){t.isFunction(n)&&(n=n()),null==n&&(n=""),this.push(j(e)+"="+j(n))},C(i,e,n),i.join("&").replace(/%20/g,"+")}}(Zepto),function(t){t.fn.serializeArray=function(){var e,n,i=[],r=function(t){return t.forEach?t.forEach(r):void i.push({name:e,value:t})};return this[0]&&t.each(this[0].elements,function(i,o){n=o.type,e=o.name,e&&"fieldset"!=o.nodeName.toLowerCase()&&!o.disabled&&"submit"!=n&&"reset"!=n&&"button"!=n&&"file"!=n&&("radio"!=n&&"checkbox"!=n||o.checked)&&r(t(o).val())}),i},t.fn.serialize=function(){var t=[];return this.serializeArray().forEach(function(e){t.push(encodeURIComponent(e.name)+"="+encodeURIComponent(e.value))}),t.join("&")},t.fn.submit=function(e){if(0 in arguments)this.bind("submit",e);else if(this.length){var n=t.Event("submit");this.eq(0).trigger(n),n.isDefaultPrevented()||this.get(0).submit()}return this}}(Zepto),function(t){function e(t,e){var n=this.os={},i=this.browser={},r=t.match(/Web[kK]it[\/]{0,1}([\d.]+)/),o=t.match(/(Android);?[\s\/]+([\d.]+)?/),s=!!t.match(/\(Macintosh\; Intel /),a=t.match(/(iPad).*OS\s([\d_]+)/),u=t.match(/(iPod)(.*OS\s([\d_]+))?/),f=!a&&t.match(/(iPhone\sOS)\s([\d_]+)/),c=t.match(/(webOS|hpwOS)[\s\/]([\d.]+)/),l=/Win\d{2}|Windows/.test(e),h=t.match(/Windows Phone ([\d.]+)/),p=c&&t.match(/TouchPad/),d=t.match(/Kindle\/([\d.]+)/),m=t.match(/Silk\/([\d._]+)/),g=t.match(/(BlackBerry).*Version\/([\d.]+)/),v=t.match(/(BB10).*Version\/([\d.]+)/),y=t.match(/(RIM\sTablet\sOS)\s([\d.]+)/),b=t.match(/PlayBook/),w=t.match(/Chrome\/([\d.]+)/)||t.match(/CriOS\/([\d.]+)/),x=t.match(/Firefox\/([\d.]+)/),E=t.match(/\((?:Mobile|Tablet); rv:([\d.]+)\).*Firefox\/[\d.]+/),T=t.match(/MSIE\s([\d.]+)/)||t.match(/Trident\/[\d](?=[^\?]+).*rv:([0-9.].)/),S=!w&&t.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/),j=S||t.match(/Version\/([\d.]+)([^S](Safari)|[^M]*(Mobile)[^S]*(Safari))/);(i.webkit=!!r)&&(i.version=r[1]),o&&(n.android=!0,n.version=o[2]),f&&!u&&(n.ios=n.iphone=!0,n.version=f[2].replace(/_/g,".")),a&&(n.ios=n.ipad=!0,n.version=a[2].replace(/_/g,".")),u&&(n.ios=n.ipod=!0,n.version=u[3]?u[3].replace(/_/g,"."):null),h&&(n.wp=!0,n.version=h[1]),c&&(n.webos=!0,n.version=c[2]),p&&(n.touchpad=!0),g&&(n.blackberry=!0,n.version=g[2]),v&&(n.bb10=!0,n.version=v[2]),y&&(n.rimtabletos=!0,n.version=y[2]),b&&(i.playbook=!0),d&&(n.kindle=!0,n.version=d[1]),m&&(i.silk=!0,i.version=m[1]),!m&&n.android&&t.match(/Kindle Fire/)&&(i.silk=!0),w&&(i.chrome=!0,i.version=w[1]),x&&(i.firefox=!0,i.version=x[1]),E&&(n.firefoxos=!0,n.version=E[1]),T&&(i.ie=!0,i.version=T[1]),j&&(s||n.ios||l)&&(i.safari=!0,n.ios||(i.version=j[1])),S&&(i.webview=!0),n.tablet=!!(a||b||o&&!t.match(/Mobile/)||x&&t.match(/Tablet/)||T&&!t.match(/Phone/)&&t.match(/Touch/)),n.phone=!(n.tablet||n.ipod||!(o||f||c||g||v||w&&t.match(/Android/)||w&&t.match(/CriOS\/([\d.]+)/)||x&&t.match(/Mobile/)||T&&t.match(/Touch/)))}e.call(t,navigator.userAgent,navigator.platform),t.__detect=e}(Zepto),function(t,e){function v(t){return t.replace(/([a-z])([A-Z])/,"$1-$2").toLowerCase()}function y(t){return i?i+t:t.toLowerCase()}var i,a,u,f,c,l,h,p,d,m,n="",r={Webkit:"webkit",Moz:"",O:"o"},o=document.createElement("div"),s=/^((translate|rotate|scale)(X|Y|Z|3d)?|matrix(3d)?|perspective|skew(X|Y)?)$/i,g={};t.each(r,function(t,r){return o.style[t+"TransitionProperty"]!==e?(n="-"+t.toLowerCase()+"-",i=r,!1):void 0}),a=n+"transform",g[u=n+"transition-property"]=g[f=n+"transition-duration"]=g[l=n+"transition-delay"]=g[c=n+"transition-timing-function"]=g[h=n+"animation-name"]=g[p=n+"animation-duration"]=g[m=n+"animation-delay"]=g[d=n+"animation-timing-function"]="",t.fx={off:i===e&&o.style.transitionProperty===e,speeds:{_default:400,fast:200,slow:600},cssPrefix:n,transitionEnd:y("TransitionEnd"),animationEnd:y("AnimationEnd")},t.fn.animate=function(n,i,r,o,s){return t.isFunction(i)&&(o=i,r=e,i=e),t.isFunction(r)&&(o=r,r=e),t.isPlainObject(i)&&(r=i.easing,o=i.complete,s=i.delay,i=i.duration),i&&(i=("number"==typeof i?i:t.fx.speeds[i]||t.fx.speeds._default)/1e3),s&&(s=parseFloat(s)/1e3),this.anim(n,i,r,o,s)},t.fn.anim=function(n,i,r,o,y){var b,x,S,w={},E="",T=this,j=t.fx.transitionEnd,C=!1;if(i===e&&(i=t.fx.speeds._default/1e3),y===e&&(y=0),t.fx.off&&(i=0),"string"==typeof n)w[h]=n,w[p]=i+"s",w[m]=y+"s",w[d]=r||"linear",j=t.fx.animationEnd;else{x=[];for(b in n)s.test(b)?E+=b+"("+n[b]+") ":(w[b]=n[b],x.push(v(b)));E&&(w[a]=E,x.push(a)),i>0&&"object"==typeof n&&(w[u]=x.join(", "),w[f]=i+"s",w[l]=y+"s",w[c]=r||"linear")}return S=function(e){if("undefined"!=typeof e){if(e.target!==e.currentTarget)return;t(e.target).unbind(j,S)}else t(this).unbind(j,S);C=!0,t(this).css(g),o&&o.call(this)},i>0&&(this.bind(j,S),setTimeout(function(){C||S.call(T)},1e3*(i+y)+25)),this.size()&&this.get(0).clientLeft,this.css(w),0>=i&&setTimeout(function(){T.each(function(){S.call(this)})},0),this},o=null}(Zepto),function(t,e){function a(n,i,r,o,s){"function"!=typeof i||s||(s=i,i=e);var a={opacity:r};return o&&(a.scale=o,n.css(t.fx.cssPrefix+"transform-origin","0 0")),n.animate(a,i,null,s)}function u(e,n,i,r){return a(e,n,0,i,function(){o.call(t(this)),r&&r.call(this)})}var n=window.document,r=(n.documentElement,t.fn.show),o=t.fn.hide,s=t.fn.toggle;t.fn.show=function(t,n){return r.call(this),t===e?t=0:this.css("opacity",0),a(this,t,1,"1,1",n)},t.fn.hide=function(t,n){return t===e?o.call(this):u(this,t,"0,0",n)},t.fn.toggle=function(n,i){return n===e||"boolean"==typeof n?s.call(this,n):this.each(function(){var e=t(this);e["none"==e.css("display")?"show":"hide"](n,i)})},t.fn.fadeTo=function(t,e,n){return a(this,t,e,null,n)},t.fn.fadeIn=function(t,e){var n=this.css("opacity");return n>0?this.css("opacity",0):n=1,r.call(this).fadeTo(t,n,e)},t.fn.fadeOut=function(t,e){return u(this,t,null,e)},t.fn.fadeToggle=function(e,n){return this.each(function(){var i=t(this);i[0==i.css("opacity")||"none"==i.css("display")?"fadeIn":"fadeOut"](e,n)})}}(Zepto),function(t){function s(o,s){var u=o[r],f=u&&e[u];if(void 0===s)return f||a(o);if(f){if(s in f)return f[s];var c=i(s);if(c in f)return f[c]}return n.call(t(o),s)}function a(n,o,s){var a=n[r]||(n[r]=++t.uuid),f=e[a]||(e[a]=u(n));return void 0!==o&&(f[i(o)]=s),f}function u(e){var n={};return t.each(e.attributes||o,function(e,r){0==r.name.indexOf("data-")&&(n[i(r.name.replace("data-",""))]=t.zepto.deserializeValue(r.value))}),n}var e={},n=t.fn.data,i=t.camelCase,r=t.expando="Zepto"+ +new Date,o=[];t.fn.data=function(e,n){return void 0===n?t.isPlainObject(e)?this.each(function(n,i){t.each(e,function(t,e){a(i,t,e)})}):0 in this?s(this[0],e):void 0:this.each(function(){a(this,e,n)})},t.fn.removeData=function(n){return"string"==typeof n&&(n=n.split(/\s+/)),this.each(function(){var o=this[r],s=o&&e[o];s&&t.each(n||s,function(t){delete s[n?i(this):t]})})},["remove","empty"].forEach(function(e){var n=t.fn[e];t.fn[e]=function(){var t=this.find("*");return"remove"===e&&(t=t.add(this)),t.removeData(),n.call(this)}})}(Zepto),function(t){function n(e){var i=[["resolve","done",t.Callbacks({once:1,memory:1}),"resolved"],["reject","fail",t.Callbacks({once:1,memory:1}),"rejected"],["notify","progress",t.Callbacks({memory:1})]],r="pending",o={state:function(){return r},always:function(){return s.done(arguments).fail(arguments),this},then:function(){var e=arguments;return n(function(n){t.each(i,function(i,r){var a=t.isFunction(e[i])&&e[i];s[r[1]](function(){var e=a&&a.apply(this,arguments);if(e&&t.isFunction(e.promise))e.promise().done(n.resolve).fail(n.reject).progress(n.notify);else{var i=this===o?n.promise():this,s=a?[e]:arguments; 3 | n[r[0]+"With"](i,s)}})}),e=null}).promise()},promise:function(e){return null!=e?t.extend(e,o):o}},s={};return t.each(i,function(t,e){var n=e[2],a=e[3];o[e[1]]=n.add,a&&n.add(function(){r=a},i[1^t][2].disable,i[2][2].lock),s[e[0]]=function(){return s[e[0]+"With"](this===s?o:this,arguments),this},s[e[0]+"With"]=n.fireWith}),o.promise(s),e&&e.call(s,s),s}var e=Array.prototype.slice;t.when=function(i){var f,c,l,r=e.call(arguments),o=r.length,s=0,a=1!==o||i&&t.isFunction(i.promise)?o:0,u=1===a?i:n(),h=function(t,n,i){return function(r){n[t]=this,i[t]=arguments.length>1?e.call(arguments):r,i===f?u.notifyWith(n,i):--a||u.resolveWith(n,i)}};if(o>1)for(f=new Array(o),c=new Array(o),l=new Array(o);o>s;++s)r[s]&&t.isFunction(r[s].promise)?r[s].promise().done(h(s,l,r)).fail(u.reject).progress(h(s,c,f)):--a;return a||u.resolveWith(l,r),u.promise()},t.Deferred=n}(Zepto),function(t){t.Callbacks=function(e){e=t.extend({},e);var n,i,r,o,s,a,u=[],f=!e.once&&[],c=function(t){for(n=e.memory&&t,i=!0,a=o||0,o=0,s=u.length,r=!0;u&&s>a;++a)if(u[a].apply(t[0],t[1])===!1&&e.stopOnFalse){n=!1;break}r=!1,u&&(f?f.length&&c(f.shift()):n?u.length=0:l.disable())},l={add:function(){if(u){var i=u.length,a=function(n){t.each(n,function(t,n){"function"==typeof n?e.unique&&l.has(n)||u.push(n):n&&n.length&&"string"!=typeof n&&a(n)})};a(arguments),r?s=u.length:n&&(o=i,c(n))}return this},remove:function(){return u&&t.each(arguments,function(e,n){for(var i;(i=t.inArray(n,u,i))>-1;)u.splice(i,1),r&&(s>=i&&--s,a>=i&&--a)}),this},has:function(e){return!(!u||!(e?t.inArray(e,u)>-1:u.length))},empty:function(){return s=u.length=0,this},disable:function(){return u=f=n=void 0,this},disabled:function(){return!u},lock:function(){return f=void 0,n||l.disable(),this},locked:function(){return!f},fireWith:function(t,e){return!u||i&&!f||(e=e||[],e=[t,e.slice?e.slice():e],r?f.push(e):c(e)),this},fire:function(){return l.fireWith(this,arguments)},fired:function(){return!!i}};return l}}(Zepto),function(t){function r(e){return e=t(e),!(!e.width()&&!e.height())&&"none"!==e.css("display")}function f(t,e){t=t.replace(/=#\]/g,'="#"]');var n,i,r=s.exec(t);if(r&&r[2]in o&&(n=o[r[2]],i=r[3],t=r[1],i)){var a=Number(i);i=isNaN(a)?i.replace(/^["']|["']$/g,""):a}return e(t,n,i)}var e=t.zepto,n=e.qsa,i=e.matches,o=t.expr[":"]={visible:function(){return r(this)?this:void 0},hidden:function(){return r(this)?void 0:this},selected:function(){return this.selected?this:void 0},checked:function(){return this.checked?this:void 0},parent:function(){return this.parentNode},first:function(t){return 0===t?this:void 0},last:function(t,e){return t===e.length-1?this:void 0},eq:function(t,e,n){return t===n?this:void 0},contains:function(e,n,i){return t(this).text().indexOf(i)>-1?this:void 0},has:function(t,n,i){return e.qsa(this,i).length?this:void 0}},s=new RegExp("(.*):(\\w+)(?:\\(([^)]+)\\))?$\\s*"),a=/^\s*>/,u="Zepto"+ +new Date;e.qsa=function(i,r){return f(r,function(o,s,f){try{var c;!o&&s?o="*":a.test(o)&&(c=t(i).addClass(u),o="."+u+" "+o);var l=n(i,o)}catch(h){throw console.error("error performing selector: %o",r),h}finally{c&&c.removeClass(u)}return s?e.uniq(t.map(l,function(t,e){return s.call(t,e,l,f)})):l})},e.matches=function(t,e){return f(e,function(e,n,r){return(!e||i(t,e))&&(!n||n.call(t,null,r)===t)})}}(Zepto),function(t){function u(t,e,n,i){return Math.abs(t-e)>=Math.abs(n-i)?t-e>0?"Left":"Right":n-i>0?"Up":"Down"}function f(){o=null,e.last&&(e.el.trigger("longTap"),e={})}function c(){o&&clearTimeout(o),o=null}function l(){n&&clearTimeout(n),i&&clearTimeout(i),r&&clearTimeout(r),o&&clearTimeout(o),n=i=r=o=null,e={}}function h(t){return("touch"==t.pointerType||t.pointerType==t.MSPOINTER_TYPE_TOUCH)&&t.isPrimary}function p(t,e){return t.type=="pointer"+e||t.type.toLowerCase()=="mspointer"+e}var n,i,r,o,a,e={},s=750;t(document).ready(function(){var d,m,y,b,g=0,v=0;"MSGesture"in window&&(a=new MSGesture,a.target=document.body),t(document).bind("MSGestureEnd",function(t){var n=t.velocityX>1?"Right":t.velocityX<-1?"Left":t.velocityY>1?"Down":t.velocityY<-1?"Up":null;n&&(e.el.trigger("swipe"),e.el.trigger("swipe"+n))}).on("touchstart MSPointerDown pointerdown",function(i){(!(b=p(i,"down"))||h(i))&&(y=b?i:i.touches[0],i.touches&&1===i.touches.length&&e.x2&&(e.x2=void 0,e.y2=void 0),d=Date.now(),m=d-(e.last||d),e.el=t("tagName"in y.target?y.target:y.target.parentNode),n&&clearTimeout(n),e.x1=y.pageX,e.y1=y.pageY,m>0&&250>=m&&(e.isDoubleTap=!0),e.last=d,o=setTimeout(f,s),a&&b&&a.addPointer(i.pointerId))}).on("touchmove MSPointerMove pointermove",function(t){(!(b=p(t,"move"))||h(t))&&(y=b?t:t.touches[0],c(),e.x2=y.pageX,e.y2=y.pageY,g+=Math.abs(e.x1-e.x2),v+=Math.abs(e.y1-e.y2))}).on("touchend MSPointerUp pointerup",function(o){(!(b=p(o,"up"))||h(o))&&(c(),e.x2&&Math.abs(e.x1-e.x2)>30||e.y2&&Math.abs(e.y1-e.y2)>30?r=setTimeout(function(){e.el.trigger("swipe"),e.el.trigger("swipe"+u(e.x1,e.x2,e.y1,e.y2)),e={}},0):"last"in e&&(30>g&&30>v?i=setTimeout(function(){var i=t.Event("tap");i.cancelTouch=l,e.el.trigger(i),e.isDoubleTap?(e.el&&e.el.trigger("doubleTap"),e={}):n=setTimeout(function(){n=null,e.el&&e.el.trigger("singleTap"),e={}},250)},0):e={}),g=v=0)}).on("touchcancel MSPointerCancel pointercancel",l),t(window).on("scroll",l)}),["swipe","swipeLeft","swipeRight","swipeUp","swipeDown","doubleTap","tap","singleTap","longTap"].forEach(function(e){t.fn[e]=function(t){return this.on(e,t)}})}(Zepto),function(t){function i(t){return"tagName"in t?t:t.parentNode}if(t.os.ios){var n,e={};t(document).bind("gesturestart",function(t){var r=Date.now();r-(e.last||r);e.target=i(t.target),n&&clearTimeout(n),e.e1=t.scale,e.last=r}).bind("gesturechange",function(t){e.e2=t.scale}).bind("gestureend",function(n){e.e2>0?(0!=Math.abs(e.e1-e.e2)&&t(e.target).trigger("pinch")&&t(e.target).trigger("pinch"+(e.e1-e.e2>0?"In":"Out")),e.e1=e.e2=e.last=0):"last"in e&&(e={})}),["pinch","pinchIn","pinchOut"].forEach(function(e){t.fn[e]=function(t){return this.bind(e,t)}})}}(Zepto); 4 | window.Zepto = Zepto 5 | "$" in window || (window.$ = Zepto) 6 | if ( typeof define === "function" && define.amd ) { 7 | define( "zepto", [], function () { return Zepto; } ); 8 | } --------------------------------------------------------------------------------