├── .gitignore
├── README.md
├── dist
├── index.html
└── pages
│ ├── detail
│ ├── detail.css
│ ├── detail.css.map
│ ├── detail.html
│ ├── detail.js
│ └── detail.js.map
│ ├── home
│ ├── home.css
│ ├── home.css.map
│ ├── home.html
│ ├── home.js
│ └── home.js.map
│ ├── list
│ ├── list.css
│ ├── list.css.map
│ ├── list.html
│ ├── list.js
│ └── list.js.map
│ ├── personal
│ ├── personal.css
│ ├── personal.css.map
│ ├── personal.html
│ ├── personal.js
│ └── personal.js.map
│ └── vendors
│ ├── vendors.css
│ ├── vendors.css.map
│ ├── vendors.js
│ └── vendors.js.map
├── package.json
├── src
├── css
│ ├── font
│ │ ├── iconfont-full.ttf
│ │ └── iconfont.ttf
│ ├── libs
│ │ ├── route.css
│ │ └── ydui.css
│ └── public
│ │ └── common.css
├── index.html
├── js
│ ├── libs
│ │ ├── route.js
│ │ ├── ydui.flexible.js
│ │ ├── ydui.js
│ │ └── zepto.js
│ └── public
│ │ └── common.js
├── pages
│ ├── detail
│ │ ├── detail.css
│ │ ├── detail.html
│ │ └── detail.js
│ ├── home
│ │ ├── home.css
│ │ ├── home.html
│ │ └── home.js
│ ├── list
│ │ ├── list.css
│ │ ├── list.html
│ │ └── list.js
│ └── personal
│ │ ├── personal.css
│ │ ├── personal.html
│ │ └── personal.js
└── router.js
├── webpack.build.config.js
└── webpack.config.js
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 |
3 | npm-debug.log
4 |
5 | .DS_Store
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 基于Zepto(jquery)的单页面引用
2 |
3 | 一个基于zepto或jquery的简版单页面应用项目,可用于做一些交互逻辑简单的单页面应用,这里是一个dome,可根据实际情况进行修改
4 |
5 | ## 使用
6 |
7 | $ git clone https://github.com/pangyongsheng/spa.git
8 |
9 | $ npm install
10 |
11 | $ npm run dev
12 |
13 | ## 目录结构
14 |
15 | ```shell
16 |
17 | * |-- src
18 | * | |--index.html 首页(空页面,通过路由加载其他页面)
19 | * | |--router.js 路由
20 | * | |--css 公共css文件
21 | * | | |--libs 第三方ui库
22 | * | | |--public 公共样式
23 | * | |--js 公共js文件
24 | * | | |--libs 第三方js库、插件
25 | * | | |--public 公共方法
26 | * | |--pages 页面
27 | * | |--home home页文件
28 | * | | |--home.html html
29 | * | | |--home.js js
30 | * | | |--home.css css
31 | * | |
32 | * | |--list list页文件
33 | * | | |--
34 | * | | |--
35 | * | | |--
36 | * | |... 其他页面
37 | * |
38 | * |--packjson
39 | * |--webpack.config.js 开发模式配置文件:仅使用webpack-server启服务,不打包
40 | * |--webpack.bulid.config.js bulid配置文件,执行 npm run bulid 打包(不推荐使用)
41 |
42 | ```
43 |
--------------------------------------------------------------------------------
/dist/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | SPA
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/dist/pages/detail/detail.css:
--------------------------------------------------------------------------------
1 | #detail .m-navbar{
2 | background: linear-gradient(-45deg, #2ed1d1, #23c8c8);
3 | background: -moz-linear-gradient(-45deg, #2ed1d1, #23c8c8);
4 | }
5 | #detail .m-navbar .iconc{
6 | font-size: .4rem;
7 | color: #fff;
8 | font-weight: lighter;
9 | }
10 | #detail .m-navbar .navbar-title{
11 | color: #fff;
12 | font-weight: bolder;
13 | }
14 | #detail .iconc{
15 | color: #fff;
16 | }
17 | #detail .tabbar-active{
18 | color: #23c8c8;
19 | }
20 | #detail .m-celltitle{
21 | margin-top: .1rem;
22 | }
23 | #detail .tab-nav-item.tab-active{
24 | color:#2ed1d1;
25 | }
26 | #detail .slider-pagination-item-active{
27 | background-color:#2ed1d1;
28 | }
29 |
30 | /*# sourceMappingURL=detail.css.map*/
--------------------------------------------------------------------------------
/dist/pages/detail/detail.css.map:
--------------------------------------------------------------------------------
1 | {"version":3,"sources":[],"names":[],"mappings":"","file":"pages/detail/detail.css","sourceRoot":""}
--------------------------------------------------------------------------------
/dist/pages/detail/detail.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
14 |
15 |
107 |
108 |
109 |
--------------------------------------------------------------------------------
/dist/pages/detail/detail.js:
--------------------------------------------------------------------------------
1 | /******/ (function(modules) { // webpackBootstrap
2 | /******/ // The module cache
3 | /******/ var installedModules = {};
4 | /******/
5 | /******/ // The require function
6 | /******/ function __webpack_require__(moduleId) {
7 | /******/
8 | /******/ // Check if module is in cache
9 | /******/ if(installedModules[moduleId])
10 | /******/ return installedModules[moduleId].exports;
11 | /******/
12 | /******/ // Create a new module (and put it into the cache)
13 | /******/ var module = installedModules[moduleId] = {
14 | /******/ exports: {},
15 | /******/ id: moduleId,
16 | /******/ loaded: false
17 | /******/ };
18 | /******/
19 | /******/ // Execute the module function
20 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21 | /******/
22 | /******/ // Flag the module as loaded
23 | /******/ module.loaded = true;
24 | /******/
25 | /******/ // Return the exports of the module
26 | /******/ return module.exports;
27 | /******/ }
28 | /******/
29 | /******/
30 | /******/ // expose the modules object (__webpack_modules__)
31 | /******/ __webpack_require__.m = modules;
32 | /******/
33 | /******/ // expose the module cache
34 | /******/ __webpack_require__.c = installedModules;
35 | /******/
36 | /******/ // __webpack_public_path__
37 | /******/ __webpack_require__.p = "";
38 | /******/
39 | /******/ // Load entry module and return exports
40 | /******/ return __webpack_require__(0);
41 | /******/ })
42 | /************************************************************************/
43 | /******/ ([
44 | /* 0 */
45 | /*!********************!*\
46 | !*** multi detail ***!
47 | \********************/
48 | /***/ (function(module, exports, __webpack_require__) {
49 |
50 | __webpack_require__(/*! E:\pro\spa\src\pages\detail\detail.js */1);
51 | module.exports = __webpack_require__(/*! E:\pro\spa\src\pages\detail\detail.css */2);
52 |
53 |
54 | /***/ }),
55 | /* 1 */
56 | /*!************************************!*\
57 | !*** ./src/pages/detail/detail.js ***!
58 | \************************************/
59 | /***/ (function(module, exports) {
60 |
61 | $(function(){
62 | //获取传参
63 | var obj = router.parse();
64 | console.log(obj);
65 | $("#title").html(obj.param.title);
66 | //返回
67 | $(document).on('click','.navback',function(){
68 | window.location.hash = router.stringify('home',{animate:'left'});
69 | })
70 | //轮播图
71 | $('#J_Slider').slider({
72 | speed: 200,
73 | autoplay: 2000,
74 | lazyLoad: true
75 | });
76 | //tab页
77 | var $tab = $('#J_Tab');
78 | $tab.tab({
79 | nav: '.tab-nav-item',
80 | panel: '.tab-panel-item',
81 | activeClass: 'tab-active'
82 | });
83 | $tab.find('.tab-nav-item').on('open.ydui.tab', function (e) {
84 | console.log('索引:%s - [%s]正在打开', e.index, $(this).text());
85 | });
86 | $tab.find('.tab-nav-item').on('opened.ydui.tab', function (e) {
87 | console.log('索引:%s - [%s]已经打开了', e.index, $(this).text());
88 | });
89 |
90 | })
91 |
92 |
93 | /***/ }),
94 | /* 2 */
95 | /*!*************************************!*\
96 | !*** ./src/pages/detail/detail.css ***!
97 | \*************************************/
98 | /***/ (function(module, exports) {
99 |
100 | // removed by extract-text-webpack-plugin
101 |
102 | /***/ })
103 | /******/ ]);
104 | //# sourceMappingURL=detail.js.map
--------------------------------------------------------------------------------
/dist/pages/detail/detail.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"sources":["webpack:///webpack/bootstrap 6e93fb57b9cb467fb36f","webpack:///./src/pages/detail/detail.js","webpack:///./src/pages/detail/detail.css"],"names":[],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;;;;;;;;;;;;;;;ACtCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,yDAAwD,eAAe;AACvE,MAAK;AACL;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;AACA,MAAK;AACL;AACA;AACA,MAAK;;AAEL,EAAC;;;;;;;;;;AC7BD,0C","file":"pages/detail/detail.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 6e93fb57b9cb467fb36f","$(function(){\r\n //获取传参\r\n var obj = router.parse();\r\n console.log(obj);\r\n $(\"#title\").html(obj.param.title);\r\n //返回\r\n $(document).on('click','.navback',function(){\r\n window.location.hash = router.stringify('home',{animate:'left'});\r\n })\r\n //轮播图\r\n $('#J_Slider').slider({\r\n speed: 200,\r\n autoplay: 2000,\r\n lazyLoad: true\r\n });\r\n //tab页\r\n var $tab = $('#J_Tab');\r\n $tab.tab({\r\n nav: '.tab-nav-item',\r\n panel: '.tab-panel-item',\r\n activeClass: 'tab-active'\r\n });\r\n $tab.find('.tab-nav-item').on('open.ydui.tab', function (e) {\r\n console.log('索引:%s - [%s]正在打开', e.index, $(this).text());\r\n });\r\n $tab.find('.tab-nav-item').on('opened.ydui.tab', function (e) {\r\n console.log('索引:%s - [%s]已经打开了', e.index, $(this).text());\r\n });\r\n\r\n})\r\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/pages/detail/detail.js\n// module id = 1\n// module chunks = 0","// removed by extract-text-webpack-plugin\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/pages/detail/detail.css\n// module id = 2\n// module chunks = 0"],"sourceRoot":""}
--------------------------------------------------------------------------------
/dist/pages/home/home.css:
--------------------------------------------------------------------------------
1 | #home .m-navbar{
2 | background: linear-gradient(-45deg, #2ed1d1, #23c8c8);
3 | background: -moz-linear-gradient(-45deg, #2ed1d1, #23c8c8);
4 | }
5 | #home .m-navbar .iconc{
6 | font-size: .4rem;
7 | color: #fff;
8 | font-weight: lighter;
9 | }
10 | #home .m-navbar .navbar-title{
11 | color: #fff;
12 | font-weight: bolder;
13 | }
14 |
15 | #home .tabbar-active{
16 | color: #23c8c8;
17 | }
18 | #home .m-celltitle{
19 | margin-top: .1rem;
20 | color:rgb(172, 184, 180);
21 |
22 | }
23 | #home .icons{
24 | color: #23c8c8;
25 | font-size: .6rem;
26 | }
27 | #home .slider-pagination-item-active{
28 | background-color: #23c8c8;
29 | }
30 | #home .list-price{
31 | color: #23c8c8;
32 | }
33 | #home .badge-danger{
34 | background-color: rgb(231, 57, 129);
35 | }
36 |
37 | /*# sourceMappingURL=home.css.map*/
--------------------------------------------------------------------------------
/dist/pages/home/home.css.map:
--------------------------------------------------------------------------------
1 | {"version":3,"sources":[],"names":[],"mappings":"","file":"pages/home/home.css","sourceRoot":""}
--------------------------------------------------------------------------------
/dist/pages/home/home.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
14 |
15 |
127 |
128 |
149 |
150 |
--------------------------------------------------------------------------------
/dist/pages/home/home.js:
--------------------------------------------------------------------------------
1 | /******/ (function(modules) { // webpackBootstrap
2 | /******/ // The module cache
3 | /******/ var installedModules = {};
4 | /******/
5 | /******/ // The require function
6 | /******/ function __webpack_require__(moduleId) {
7 | /******/
8 | /******/ // Check if module is in cache
9 | /******/ if(installedModules[moduleId])
10 | /******/ return installedModules[moduleId].exports;
11 | /******/
12 | /******/ // Create a new module (and put it into the cache)
13 | /******/ var module = installedModules[moduleId] = {
14 | /******/ exports: {},
15 | /******/ id: moduleId,
16 | /******/ loaded: false
17 | /******/ };
18 | /******/
19 | /******/ // Execute the module function
20 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21 | /******/
22 | /******/ // Flag the module as loaded
23 | /******/ module.loaded = true;
24 | /******/
25 | /******/ // Return the exports of the module
26 | /******/ return module.exports;
27 | /******/ }
28 | /******/
29 | /******/
30 | /******/ // expose the modules object (__webpack_modules__)
31 | /******/ __webpack_require__.m = modules;
32 | /******/
33 | /******/ // expose the module cache
34 | /******/ __webpack_require__.c = installedModules;
35 | /******/
36 | /******/ // __webpack_public_path__
37 | /******/ __webpack_require__.p = "";
38 | /******/
39 | /******/ // Load entry module and return exports
40 | /******/ return __webpack_require__(0);
41 | /******/ })
42 | /************************************************************************/
43 | /******/ ([
44 | /* 0 */
45 | /*!******************!*\
46 | !*** multi home ***!
47 | \******************/
48 | /***/ (function(module, exports, __webpack_require__) {
49 |
50 | __webpack_require__(/*! E:\pro\spa\src\pages\home\home.js */3);
51 | module.exports = __webpack_require__(/*! E:\pro\spa\src\pages\home\home.css */4);
52 |
53 |
54 | /***/ }),
55 | /* 1 */,
56 | /* 2 */,
57 | /* 3 */
58 | /*!********************************!*\
59 | !*** ./src/pages/home/home.js ***!
60 | \********************************/
61 | /***/ (function(module, exports) {
62 |
63 | $(function(){
64 | //轮播图
65 | $('#J_Slider').slider({
66 | speed: 200,
67 | autoplay: 2000,
68 | lazyLoad: true
69 | });
70 | //扫码
71 | var dialog = window.YDUI.dialog;
72 |
73 | $(document).on('click','.nav-qs',function(){
74 | dialog.notify('扫码!', 1000, function(){
75 | });
76 | })
77 | //菜单
78 | $(document).on('click','.nav-me',function(){
79 | dialog.notify('菜单', 1000, function(){
80 | });
81 | })
82 | //
83 | $(document).on('click','.qq',function(){
84 | dialog.toast('820568018', 'success', 500);
85 | })
86 | $(document).on('click','.wb',function(){
87 | dialog.toast('没有微博', 'success', 500);
88 | })
89 | $(document).on('click','.wx',function(){
90 | dialog.toast('pangyongsheng', 'success', 500);
91 | })
92 | //查看详情
93 | $(document).on('click','.list-item',function(){
94 | var name=$(this).find('.list-title').html();
95 | window.location.hash = router.stringify('detail',{animate:'right',title:name});
96 | })
97 |
98 | })
99 |
100 |
101 | /***/ }),
102 | /* 4 */
103 | /*!*********************************!*\
104 | !*** ./src/pages/home/home.css ***!
105 | \*********************************/
106 | /***/ (function(module, exports) {
107 |
108 | // removed by extract-text-webpack-plugin
109 |
110 | /***/ })
111 | /******/ ]);
112 | //# sourceMappingURL=home.js.map
--------------------------------------------------------------------------------
/dist/pages/home/home.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"sources":["webpack:///webpack/bootstrap 6e93fb57b9cb467fb36f?9a76","webpack:///./src/pages/home/home.js","webpack:///./src/pages/home/home.css"],"names":[],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;;;;;;;;;;;;;;;;;ACtCA;AACA;AACA;AACA;AACA;AACA;AACA,MAAK;AACL;AACA;;AAEA;AACA;AACA,UAAS;AACT,MAAK;AACL;AACA;AACA;AACA,UAAS;AACT,MAAK;AACL;AACA;AACA;AACA,MAAK;AACL;AACA;AACA,MAAK;AACL;AACA;AACA,MAAK;AACL;AACA;AACA;AACA,2DAA0D,2BAA2B;AACrF,MAAK;;AAEL,EAAC;;;;;;;;;;ACnCD,0C","file":"pages/home/home.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 6e93fb57b9cb467fb36f","$(function(){\r\n //轮播图\r\n $('#J_Slider').slider({\r\n speed: 200,\r\n autoplay: 2000,\r\n lazyLoad: true\r\n });\r\n //扫码\r\n var dialog = window.YDUI.dialog;\r\n\r\n $(document).on('click','.nav-qs',function(){\r\n dialog.notify('扫码!', 1000, function(){\r\n });\r\n })\r\n //菜单\r\n $(document).on('click','.nav-me',function(){\r\n dialog.notify('菜单', 1000, function(){\r\n });\r\n })\r\n //\r\n $(document).on('click','.qq',function(){\r\n dialog.toast('820568018', 'success', 500);\r\n })\r\n $(document).on('click','.wb',function(){\r\n dialog.toast('没有微博', 'success', 500);\r\n })\r\n $(document).on('click','.wx',function(){\r\n dialog.toast('pangyongsheng', 'success', 500);\r\n })\r\n //查看详情\r\n $(document).on('click','.list-item',function(){\r\n var name=$(this).find('.list-title').html();\r\n window.location.hash = router.stringify('detail',{animate:'right',title:name});\r\n })\r\n\r\n})\r\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/pages/home/home.js\n// module id = 3\n// module chunks = 1","// removed by extract-text-webpack-plugin\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/pages/home/home.css\n// module id = 4\n// module chunks = 1"],"sourceRoot":""}
--------------------------------------------------------------------------------
/dist/pages/list/list.css:
--------------------------------------------------------------------------------
1 | #list .m-navbar{
2 | background: linear-gradient(-45deg, #2ed1d1, #23c8c8);
3 | background: -moz-linear-gradient(-45deg, #2ed1d1, #23c8c8);
4 | }
5 | #list .m-navbar .iconc{
6 | font-size: .4rem;
7 | color: #fff;
8 | font-weight: lighter;
9 | }
10 | #list .m-navbar .navbar-title{
11 | color: #fff;
12 | font-weight: bolder;
13 | }
14 |
15 | #list .tabbar-active{
16 | color: #23c8c8;
17 | }
18 | #list .m-celltitle{
19 | margin-top: .1rem;
20 | }
21 | #list .list-price{
22 | color:#23c8c8;
23 | }
24 | #list .badge-danger{
25 | background-color: rgb(231, 57, 129);
26 | }
27 |
28 | /*# sourceMappingURL=list.css.map*/
--------------------------------------------------------------------------------
/dist/pages/list/list.css.map:
--------------------------------------------------------------------------------
1 | {"version":3,"sources":[],"names":[],"mappings":"","file":"pages/list/list.css","sourceRoot":""}
--------------------------------------------------------------------------------
/dist/pages/list/list.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
14 |
15 |
122 |
123 |
124 |
145 |
146 |
--------------------------------------------------------------------------------
/dist/pages/list/list.js:
--------------------------------------------------------------------------------
1 | /******/ (function(modules) { // webpackBootstrap
2 | /******/ // The module cache
3 | /******/ var installedModules = {};
4 | /******/
5 | /******/ // The require function
6 | /******/ function __webpack_require__(moduleId) {
7 | /******/
8 | /******/ // Check if module is in cache
9 | /******/ if(installedModules[moduleId])
10 | /******/ return installedModules[moduleId].exports;
11 | /******/
12 | /******/ // Create a new module (and put it into the cache)
13 | /******/ var module = installedModules[moduleId] = {
14 | /******/ exports: {},
15 | /******/ id: moduleId,
16 | /******/ loaded: false
17 | /******/ };
18 | /******/
19 | /******/ // Execute the module function
20 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21 | /******/
22 | /******/ // Flag the module as loaded
23 | /******/ module.loaded = true;
24 | /******/
25 | /******/ // Return the exports of the module
26 | /******/ return module.exports;
27 | /******/ }
28 | /******/
29 | /******/
30 | /******/ // expose the modules object (__webpack_modules__)
31 | /******/ __webpack_require__.m = modules;
32 | /******/
33 | /******/ // expose the module cache
34 | /******/ __webpack_require__.c = installedModules;
35 | /******/
36 | /******/ // __webpack_public_path__
37 | /******/ __webpack_require__.p = "";
38 | /******/
39 | /******/ // Load entry module and return exports
40 | /******/ return __webpack_require__(0);
41 | /******/ })
42 | /************************************************************************/
43 | /******/ ([
44 | /* 0 */
45 | /*!******************!*\
46 | !*** multi list ***!
47 | \******************/
48 | /***/ (function(module, exports, __webpack_require__) {
49 |
50 | __webpack_require__(/*! E:\pro\spa\src\pages\list\list.js */5);
51 | module.exports = __webpack_require__(/*! E:\pro\spa\src\pages\list\list.css */6);
52 |
53 |
54 | /***/ }),
55 | /* 1 */,
56 | /* 2 */,
57 | /* 3 */,
58 | /* 4 */,
59 | /* 5 */
60 | /*!********************************!*\
61 | !*** ./src/pages/list/list.js ***!
62 | \********************************/
63 | /***/ (function(module, exports) {
64 |
65 | $(function(){
66 |
67 | })
68 |
69 |
70 | /***/ }),
71 | /* 6 */
72 | /*!*********************************!*\
73 | !*** ./src/pages/list/list.css ***!
74 | \*********************************/
75 | /***/ (function(module, exports) {
76 |
77 | // removed by extract-text-webpack-plugin
78 |
79 | /***/ })
80 | /******/ ]);
81 | //# sourceMappingURL=list.js.map
--------------------------------------------------------------------------------
/dist/pages/list/list.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"sources":["webpack:///webpack/bootstrap 6e93fb57b9cb467fb36f?9a76*","webpack:///./src/pages/list/list.js","webpack:///./src/pages/list/list.css"],"names":[],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;ACtCA;;AAEA,EAAC;;;;;;;;;;ACFD,0C","file":"pages/list/list.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 6e93fb57b9cb467fb36f","$(function(){\r\n\r\n})\r\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/pages/list/list.js\n// module id = 5\n// module chunks = 2","// removed by extract-text-webpack-plugin\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/pages/list/list.css\n// module id = 6\n// module chunks = 2"],"sourceRoot":""}
--------------------------------------------------------------------------------
/dist/pages/personal/personal.css:
--------------------------------------------------------------------------------
1 | #personal .m-navbar{
2 | background: linear-gradient(-45deg, #2ed1d1, #23c8c8);
3 | background: -moz-linear-gradient(-45deg, #2ed1d1, #23c8c8);
4 | }
5 | #personal .m-navbar .iconc{
6 | font-size: .4rem;
7 | color: #fff;
8 | font-weight: lighter;
9 | }
10 | #personal .m-navbar .navbar-title{
11 | color: #fff;
12 | font-weight: bolder;
13 | }
14 |
15 | #personal .tabbar-active{
16 | color: #23c8c8;
17 | }
18 | #personal .m-celltitle{
19 | /* margin-top: .1rem; */
20 | }
21 | #personal .cell-select{
22 | direction: rtl;
23 | }
24 | #personal .cell-icon:before, .cell-icon:after{
25 | color: #23c8c8;
26 | }
27 | #personal #sub{
28 | background-color: #23c8c8;
29 | }
30 | #personal .cell-right input[type="radio"]:checked + .cell-checkbox-icon:after, .cell-right input[type="checkbox"]:not(.m-switch):checked + .cell-checkbox-icon:after{
31 | color: #23c8c8;
32 | }
33 |
34 | /*# sourceMappingURL=personal.css.map*/
--------------------------------------------------------------------------------
/dist/pages/personal/personal.css.map:
--------------------------------------------------------------------------------
1 | {"version":3,"sources":[],"names":[],"mappings":"","file":"pages/personal/personal.css","sourceRoot":""}
--------------------------------------------------------------------------------
/dist/pages/personal/personal.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
14 |
15 |
103 |
104 |
105 |
125 |
126 |
--------------------------------------------------------------------------------
/dist/pages/personal/personal.js:
--------------------------------------------------------------------------------
1 | /******/ (function(modules) { // webpackBootstrap
2 | /******/ // The module cache
3 | /******/ var installedModules = {};
4 | /******/
5 | /******/ // The require function
6 | /******/ function __webpack_require__(moduleId) {
7 | /******/
8 | /******/ // Check if module is in cache
9 | /******/ if(installedModules[moduleId])
10 | /******/ return installedModules[moduleId].exports;
11 | /******/
12 | /******/ // Create a new module (and put it into the cache)
13 | /******/ var module = installedModules[moduleId] = {
14 | /******/ exports: {},
15 | /******/ id: moduleId,
16 | /******/ loaded: false
17 | /******/ };
18 | /******/
19 | /******/ // Execute the module function
20 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21 | /******/
22 | /******/ // Flag the module as loaded
23 | /******/ module.loaded = true;
24 | /******/
25 | /******/ // Return the exports of the module
26 | /******/ return module.exports;
27 | /******/ }
28 | /******/
29 | /******/
30 | /******/ // expose the modules object (__webpack_modules__)
31 | /******/ __webpack_require__.m = modules;
32 | /******/
33 | /******/ // expose the module cache
34 | /******/ __webpack_require__.c = installedModules;
35 | /******/
36 | /******/ // __webpack_public_path__
37 | /******/ __webpack_require__.p = "";
38 | /******/
39 | /******/ // Load entry module and return exports
40 | /******/ return __webpack_require__(0);
41 | /******/ })
42 | /************************************************************************/
43 | /******/ ({
44 |
45 | /***/ 0:
46 | /*!**********************!*\
47 | !*** multi personal ***!
48 | \**********************/
49 | /***/ (function(module, exports, __webpack_require__) {
50 |
51 | __webpack_require__(/*! E:\pro\spa\src\pages\personal\personal.js */7);
52 | module.exports = __webpack_require__(/*! E:\pro\spa\src\pages\personal\personal.css */8);
53 |
54 |
55 | /***/ }),
56 |
57 | /***/ 7:
58 | /*!****************************************!*\
59 | !*** ./src/pages/personal/personal.js ***!
60 | \****************************************/
61 | /***/ (function(module, exports) {
62 |
63 | $(function(){
64 | var dialog = window.YDUI.dialog;
65 | $(document).on('click','#sub',function(){
66 | dialog.notify('提交成功!', 5000, function(){
67 | });
68 | })
69 | })
70 |
71 |
72 | /***/ }),
73 |
74 | /***/ 8:
75 | /*!*****************************************!*\
76 | !*** ./src/pages/personal/personal.css ***!
77 | \*****************************************/
78 | /***/ (function(module, exports) {
79 |
80 | // removed by extract-text-webpack-plugin
81 |
82 | /***/ })
83 |
84 | /******/ });
85 | //# sourceMappingURL=personal.js.map
--------------------------------------------------------------------------------
/dist/pages/personal/personal.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"sources":["webpack:///webpack/bootstrap 6e93fb57b9cb467fb36f?9a76**","webpack:///./src/pages/personal/personal.js","webpack:///./src/pages/personal/personal.css"],"names":[],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;;;;;;;;;;;;;;;;;ACtCA;AACA;AACA;AACA;AACA,UAAS;AACT,MAAK;AACL,EAAC;;;;;;;;;;;ACND,0C","file":"pages/personal/personal.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 6e93fb57b9cb467fb36f","$(function(){\r\n var dialog = window.YDUI.dialog;\r\n $(document).on('click','#sub',function(){\r\n dialog.notify('提交成功!', 5000, function(){\r\n });\r\n })\r\n})\r\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/pages/personal/personal.js\n// module id = 7\n// module chunks = 3","// removed by extract-text-webpack-plugin\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./src/pages/personal/personal.css\n// module id = 8\n// module chunks = 3"],"sourceRoot":""}
--------------------------------------------------------------------------------
/dist/pages/vendors/vendors.css.map:
--------------------------------------------------------------------------------
1 | {"version":3,"sources":[],"names":[],"mappings":"","file":"pages/vendors/vendors.css","sourceRoot":""}
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "app",
3 | "version": "1.0.0",
4 | "description": "app",
5 | "main": "index.js",
6 | "scripts": {
7 | "dev": "webpack-dev-server --colors --progress --inline --hot",
8 | "build": "webpack --config webpack.build.config.js -d"
9 | },
10 | "author": "",
11 | "license": "ISC",
12 | "devDependencies": {
13 | "open-browser-webpack-plugin": "0.0.3",
14 | "webpack": "^1.13.1",
15 | "webpack-dev-server": "^1.14.1",
16 | "glob": "^7.0.0",
17 | "autoprefixer-loader": "^3.2.0",
18 | "css-loader": "^0.23.1",
19 | "style-loader": "^0.13.0",
20 | "extract-text-webpack-plugin": "^1.0.1",
21 | "file-loader": "^0.8.5",
22 | "html-loader": "^0.4.3",
23 | "html-webpack-plugin": "^2.9.0",
24 | "url-loader": "^0.5.7",
25 | "webpack-md5-hash": "0.0.5"
26 | },
27 | "dependencies": {}
28 | }
29 |
--------------------------------------------------------------------------------
/src/css/font/iconfont-full.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pangyongsheng/spa/5ff3874287768fa21c6951b6281ba19c0d9093ec/src/css/font/iconfont-full.ttf
--------------------------------------------------------------------------------
/src/css/font/iconfont.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pangyongsheng/spa/5ff3874287768fa21c6951b6281ba19c0d9093ec/src/css/font/iconfont.ttf
--------------------------------------------------------------------------------
/src/css/libs/route.css:
--------------------------------------------------------------------------------
1 |
2 | #ui-view{
3 | position: absolute;
4 | top:0;
5 | left: 0;
6 | right: 0;
7 | bottom:0;
8 | }
9 |
10 | /*
11 | * 路由动画
12 | */
13 | .page-from-center-to-left {
14 | animation: pageFromCenterToLeft 400ms forwards;
15 | }
16 | .page-from-left-to-center {
17 | animation: pageFromLeftToCenter 400ms forwards;
18 | }
19 | @keyframes pageFromCenterToLeft {
20 | from {
21 | opacity: 1;
22 | transform: translate3d(0, 0, 0);
23 | }
24 | to {
25 | opacity: 0.5;
26 | transform: translate3d(-100%, 0, 0);
27 | }
28 | }
29 | @keyframes pageFromLeftToCenter {
30 | from {
31 | opacity: .5;
32 | transform: translate3d(-100%, 0, 0);
33 | }
34 | to {
35 | opacity: 1;
36 | transform: translate3d(0, 0, 0);
37 | }
38 | }
39 |
40 | .page-from-right-to-center {
41 | animation: pageFromRightToCenter 400ms forwards;
42 | z-index: 2002;
43 | }
44 | .page-from-center-to-right {
45 | animation: pageFromCenterToRight 400ms forwards;
46 | z-index: 2002;
47 | }
48 | @keyframes pageFromRightToCenter {
49 | from {
50 | transform: translate3d(100%, 0, 0);
51 | opacity: .9;
52 | }
53 | to {
54 | transform: translate3d(0,0, 0);
55 | opacity: 1;
56 | }
57 | }
58 | @keyframes pageFromCenterToRight {
59 | from {
60 | transform: translate3d(0, 0, 0);
61 | opacity: 1;
62 | }
63 | to {
64 | transform: translate3d(100%, 0, 0);
65 | opacity: .9;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/css/public/common.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pangyongsheng/spa/5ff3874287768fa21c6951b6281ba19c0d9093ec/src/css/public/common.css
--------------------------------------------------------------------------------
/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | SPA
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/src/js/libs/route.js:
--------------------------------------------------------------------------------
1 | (function(){
2 | //创建R对象
3 | function R(){
4 | }
5 | R.prototype.start = function(config){
6 | var _this = this;
7 | _this.routerMap = config.router; //路由配置
8 | _this.mainView = config.view; //目标div
9 | _this.errorTemplateId = config.errorTemplateId; //错误id
10 | startRouter(); //初始化
11 | window.onhashchange = function(){ //监听路由变化
12 | startRouter();
13 | };
14 | };
15 | var messageStack = [];
16 |
17 | R.prototype.getMessage = function(id){
18 | var msg = {};
19 | $.each(messageStack,function(i,e){
20 | if(e.id===id){
21 | msg = e;
22 | }
23 | });
24 | return msg;
25 | };
26 | R.prototype.setMessage = function(obj){
27 | var _obj = JSON.parse(JSON.stringify(obj));
28 | $.each(messageStack,function(i,e){
29 | if(e.id===_obj.id){
30 | e = _obj;
31 | return false;
32 | }
33 | });
34 | messageStack.push(_obj);
35 | };
36 | R.prototype.delMessage = function(id){
37 | if(typeof id==='undefined'){
38 | return false;
39 | }
40 | var index = 0;
41 | $.each(messageStack,function(i,e){
42 | if(e.id===id){
43 | index = i;
44 | }
45 | });
46 | $.each(messageStack,function(i,e){
47 | if(i>index){
48 | messageStack[i-1] = e;
49 | }
50 | });
51 | };
52 | R.prototype.clearMessage = function(id){
53 | var index = 0;
54 | messageStack = [];
55 | };
56 |
57 | R.prototype.stringify = function(routerUrl,paramObj){
58 | var paramStr='' ,hash;
59 | for(var i in paramObj){
60 | paramStr += i + '=' + encodeURIComponent(paramObj[i]) + '&';
61 | }
62 | if(paramStr === ''){
63 | hash = routerUrl;
64 | }
65 | else{
66 | paramStr = paramStr.substring(0,paramStr.length-1);
67 | hash = routerUrl + '?' + paramStr;
68 | }
69 | return hash;
70 | };
71 | R.prototype.parse = function(routerHash){
72 | var hash = typeof routerHash ==='undefined'?location.hash:routerHash;
73 | var obj = {
74 | url:'',
75 | param: {}
76 | };
77 | var param = {},url='';
78 | var pIndex = hash.indexOf('?');
79 | if(hash===''){
80 | return obj;
81 | }
82 |
83 | if(pIndex>-1){
84 | url = hash.substring(1,pIndex);
85 | var paramStr = hash.substring(pIndex+1);
86 | var paramArr = paramStr.split('&');
87 |
88 | $.each(paramArr,function(i,e){
89 | var item = e.split('='),
90 | key,
91 | val;
92 | key = item[0];
93 | val = item[1];
94 | if(key!==''){
95 | param[key] = decodeURIComponent(val);
96 | }
97 |
98 |
99 | });
100 | }
101 | else{
102 | url = hash.substring(1);
103 | param = {};
104 | }
105 | return {
106 | url:url,
107 | param: param
108 | };
109 | };
110 | function routerAction (routeObj){
111 |
112 | var routerItem = router.routerMap[routeObj.url];
113 |
114 | if(typeof routerItem==='undefined'){
115 | var defaultsRoute = router.routerMap.defaults;
116 | routerItem = router.routerMap[defaultsRoute];
117 | location.hash = defaultsRoute;
118 | return false;
119 | }
120 |
121 | var routerAnimate=routeObj.param.animate ? routeObj.param.animate : routerItem.animate;
122 |
123 | $.ajax({
124 | type: 'GET',
125 | url: routerItem.templateUrl,
126 | dataType: 'html',
127 | success: function(data, status, xhr){
128 | //加载页面,动画分享
129 |
130 | if(routerAnimate=='right'){
131 | $(router.mainView).html(data).children().addClass('page-from-right-to-center');
132 |
133 | }else if(routerAnimate=='left'){
134 | $(router.mainView).html(data).children().addClass('page-from-left-to-center');
135 | }else{
136 | $(router.mainView).html(data)
137 | }
138 | $(document).on('webkitAnimationEnd',router.mainView+'>div',function(){
139 | $(this).removeClass('page-from-right-to-center');
140 | });
141 | //console.log($(router.mainView)
142 | loadScript(routerItem.controller);
143 | loadCss(routerItem.styles);
144 | },
145 | error: function(xhr, errorType, error){
146 | if($(router.errorTemplateId).length===0){
147 | return false;
148 | }
149 | var errHtml = $(router.errorTemplateId).html();
150 | errHtml = errHtml.replace(/{{errStatus}}/,xhr.status);
151 | errHtml = errHtml.replace(/{{errContent}}/,xhr.responseText);
152 | $(router.mainView).html(errHtml);
153 | }
154 | });
155 | }
156 |
157 | function startRouter () {
158 | var hash = location.hash; //获取当前URL的锚部分
159 | var routeObj = router.parse(hash);
160 | //console.log(routeObj);
161 | routerAction(routeObj);
162 | }
163 |
164 | function loadScript(src, callback) {
165 |
166 | var script = document.createElement('script'),
167 | loaded;
168 |
169 | script.setAttribute('src', src);
170 | script.onreadystatechange = script.onload = function() {
171 | script.onreadystatechange = null;
172 | document.documentElement.removeChild(script);
173 | script = null;
174 | if (!loaded) {
175 | if(typeof callback==='function')
176 | callback();
177 | }
178 | loaded = true;
179 | };
180 |
181 | document.documentElement.appendChild(script);
182 | }
183 |
184 | function loadCss(src,callback){
185 | if(!src) return;
186 | var head = document.getElementsByTagName('head')[0],
187 | cssURL = src,
188 | linkTag = document.createElement('link');
189 |
190 | linkTag.href = cssURL;
191 | linkTag.setAttribute('rel','stylesheet');
192 | linkTag.setAttribute('media','all');
193 | linkTag.setAttribute('type','text/css');
194 |
195 | head.appendChild(linkTag);
196 | }
197 |
198 | window.router = new R();
199 | })();
200 |
--------------------------------------------------------------------------------
/src/js/libs/ydui.flexible.js:
--------------------------------------------------------------------------------
1 | /**
2 | * YDUI 可伸缩布局方案
3 | * rem计算方式:设计图尺寸px / 100 = 实际rem 例: 100px = 1rem
4 | */
5 | !function (window) {
6 |
7 | /* 设计图文档宽度 */
8 | var docWidth = 750;
9 |
10 | var doc = window.document,
11 | docEl = doc.documentElement,
12 | resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize';
13 |
14 | var recalc = (function refreshRem () {
15 | var clientWidth = docEl.getBoundingClientRect().width;
16 |
17 | /* 8.55:小于320px不再缩小,11.2:大于420px不再放大 */
18 | docEl.style.fontSize = Math.max(Math.min(20 * (clientWidth / docWidth), 11.2), 8.55) * 5 + 'px';
19 |
20 | return refreshRem;
21 | })();
22 |
23 | /* 添加倍屏标识,安卓倍屏为1 */
24 | docEl.setAttribute('data-dpr', window.navigator.appVersion.match(/iphone/gi) ? window.devicePixelRatio : 1);
25 |
26 | if (/iP(hone|od|ad)/.test(window.navigator.userAgent)) {
27 | /* 添加IOS标识 */
28 | doc.documentElement.classList.add('ios');
29 | /* IOS8以上给html添加hairline样式,以便特殊处理 */
30 | if (parseInt(window.navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/)[1], 10) >= 8)
31 | doc.documentElement.classList.add('hairline');
32 | }
33 |
34 | if (!doc.addEventListener) return;
35 | window.addEventListener(resizeEvt, recalc, false);
36 | doc.addEventListener('DOMContentLoaded', recalc, false);
37 |
38 | }(window);
39 |
--------------------------------------------------------------------------------
/src/js/libs/zepto.js:
--------------------------------------------------------------------------------
1 | /* Zepto v1.1.6 - zepto event ajax form ie - zeptojs.com/license */
2 |
3 | var Zepto = (function() {
4 | var undefined, key, $, classList, emptyArray = [], slice = emptyArray.slice, filter = emptyArray.filter,
5 | document = window.document,
6 | elementDisplay = {}, classCache = {},
7 | cssNumber = { 'column-count': 1, 'columns': 1, 'font-weight': 1, 'line-height': 1,'opacity': 1, 'z-index': 1, 'zoom': 1 },
8 | fragmentRE = /^\s*<(\w+|!)[^>]*>/,
9 | singleTagRE = /^<(\w+)\s*\/?>(?:<\/\1>|)$/,
10 | tagExpanderRE = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
11 | rootNodeRE = /^(?:body|html)$/i,
12 | capitalRE = /([A-Z])/g,
13 |
14 | // special attributes that should be get/set via method calls
15 | methodAttributes = ['val', 'css', 'html', 'text', 'data', 'width', 'height', 'offset'],
16 |
17 | adjacencyOperators = [ 'after', 'prepend', 'before', 'append' ],
18 | table = document.createElement('table'),
19 | tableRow = document.createElement('tr'),
20 | containers = {
21 | 'tr': document.createElement('tbody'),
22 | 'tbody': table, 'thead': table, 'tfoot': table,
23 | 'td': tableRow, 'th': tableRow,
24 | '*': document.createElement('div')
25 | },
26 | readyRE = /complete|loaded|interactive/,
27 | simpleSelectorRE = /^[\w-]*$/,
28 | class2type = {},
29 | toString = class2type.toString,
30 | zepto = {},
31 | camelize, uniq,
32 | tempParent = document.createElement('div'),
33 | propMap = {
34 | 'tabindex': 'tabIndex',
35 | 'readonly': 'readOnly',
36 | 'for': 'htmlFor',
37 | 'class': 'className',
38 | 'maxlength': 'maxLength',
39 | 'cellspacing': 'cellSpacing',
40 | 'cellpadding': 'cellPadding',
41 | 'rowspan': 'rowSpan',
42 | 'colspan': 'colSpan',
43 | 'usemap': 'useMap',
44 | 'frameborder': 'frameBorder',
45 | 'contenteditable': 'contentEditable'
46 | },
47 | isArray = Array.isArray ||
48 | function(object){ return object instanceof Array }
49 |
50 | zepto.matches = function(element, selector) {
51 | if (!selector || !element || element.nodeType !== 1) return false
52 | var matchesSelector = element.webkitMatchesSelector || element.mozMatchesSelector ||
53 | element.oMatchesSelector || element.matchesSelector
54 | if (matchesSelector) return matchesSelector.call(element, selector)
55 | // fall back to performing a selector:
56 | var match, parent = element.parentNode, temp = !parent
57 | if (temp) (parent = tempParent).appendChild(element)
58 | match = ~zepto.qsa(parent, selector).indexOf(element)
59 | temp && tempParent.removeChild(element)
60 | return match
61 | }
62 |
63 | function type(obj) {
64 | return obj == null ? String(obj) :
65 | class2type[toString.call(obj)] || "object"
66 | }
67 |
68 | function isFunction(value) { return type(value) == "function" }
69 | function isWindow(obj) { return obj != null && obj == obj.window }
70 | function isDocument(obj) { return obj != null && obj.nodeType == obj.DOCUMENT_NODE }
71 | function isObject(obj) { return type(obj) == "object" }
72 | function isPlainObject(obj) {
73 | return isObject(obj) && !isWindow(obj) && Object.getPrototypeOf(obj) == Object.prototype
74 | }
75 | function likeArray(obj) { return typeof obj.length == 'number' }
76 |
77 | function compact(array) { return filter.call(array, function(item){ return item != null }) }
78 | function flatten(array) { return array.length > 0 ? $.fn.concat.apply([], array) : array }
79 | camelize = function(str){ return str.replace(/-+(.)?/g, function(match, chr){ return chr ? chr.toUpperCase() : '' }) }
80 | function dasherize(str) {
81 | return str.replace(/::/g, '/')
82 | .replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2')
83 | .replace(/([a-z\d])([A-Z])/g, '$1_$2')
84 | .replace(/_/g, '-')
85 | .toLowerCase()
86 | }
87 | uniq = function(array){ return filter.call(array, function(item, idx){ return array.indexOf(item) == idx }) }
88 |
89 | function classRE(name) {
90 | return name in classCache ?
91 | classCache[name] : (classCache[name] = new RegExp('(^|\\s)' + name + '(\\s|$)'))
92 | }
93 |
94 | function maybeAddPx(name, value) {
95 | return (typeof value == "number" && !cssNumber[dasherize(name)]) ? value + "px" : value
96 | }
97 |
98 | function defaultDisplay(nodeName) {
99 | var element, display
100 | if (!elementDisplay[nodeName]) {
101 | element = document.createElement(nodeName)
102 | document.body.appendChild(element)
103 | display = getComputedStyle(element, '').getPropertyValue("display")
104 | element.parentNode.removeChild(element)
105 | display == "none" && (display = "block")
106 | elementDisplay[nodeName] = display
107 | }
108 | return elementDisplay[nodeName]
109 | }
110 |
111 | function children(element) {
112 | return 'children' in element ?
113 | slice.call(element.children) :
114 | $.map(element.childNodes, function(node){ if (node.nodeType == 1) return node })
115 | }
116 |
117 | // `$.zepto.fragment` takes a html string and an optional tag name
118 | // to generate DOM nodes nodes from the given html string.
119 | // The generated DOM nodes are returned as an array.
120 | // This function can be overriden in plugins for example to make
121 | // it compatible with browsers that don't support the DOM fully.
122 | zepto.fragment = function(html, name, properties) {
123 | var dom, nodes, container
124 |
125 | // A special case optimization for a single tag
126 | if (singleTagRE.test(html)) dom = $(document.createElement(RegExp.$1))
127 |
128 | if (!dom) {
129 | if (html.replace) html = html.replace(tagExpanderRE, "<$1>$2>")
130 | if (name === undefined) name = fragmentRE.test(html) && RegExp.$1
131 | if (!(name in containers)) name = '*'
132 |
133 | container = containers[name]
134 | container.innerHTML = '' + html
135 | dom = $.each(slice.call(container.childNodes), function(){
136 | container.removeChild(this)
137 | })
138 | }
139 |
140 | if (isPlainObject(properties)) {
141 | nodes = $(dom)
142 | $.each(properties, function(key, value) {
143 | if (methodAttributes.indexOf(key) > -1) nodes[key](value)
144 | else nodes.attr(key, value)
145 | })
146 | }
147 |
148 | return dom
149 | }
150 |
151 | // `$.zepto.Z` swaps out the prototype of the given `dom` array
152 | // of nodes with `$.fn` and thus supplying all the Zepto functions
153 | // to the array. Note that `__proto__` is not supported on Internet
154 | // Explorer. This method can be overriden in plugins.
155 | zepto.Z = function(dom, selector) {
156 | dom = dom || []
157 | dom.__proto__ = $.fn
158 | dom.selector = selector || ''
159 | return dom
160 | }
161 |
162 | // `$.zepto.isZ` should return `true` if the given object is a Zepto
163 | // collection. This method can be overriden in plugins.
164 | zepto.isZ = function(object) {
165 | return object instanceof zepto.Z
166 | }
167 |
168 | // `$.zepto.init` is Zepto's counterpart to jQuery's `$.fn.init` and
169 | // takes a CSS selector and an optional context (and handles various
170 | // special cases).
171 | // This method can be overriden in plugins.
172 | zepto.init = function(selector, context) {
173 | var dom
174 | // If nothing given, return an empty Zepto collection
175 | if (!selector) return zepto.Z()
176 | // Optimize for string selectors
177 | else if (typeof selector == 'string') {
178 | selector = selector.trim()
179 | // If it's a html fragment, create nodes from it
180 | // Note: In both Chrome 21 and Firefox 15, DOM error 12
181 | // is thrown if the fragment doesn't begin with <
182 | if (selector[0] == '<' && fragmentRE.test(selector))
183 | dom = zepto.fragment(selector, RegExp.$1, context), selector = null
184 | // If there's a context, create a collection on that context first, and select
185 | // nodes from there
186 | else if (context !== undefined) return $(context).find(selector)
187 | // If it's a CSS selector, use it to select nodes.
188 | else dom = zepto.qsa(document, selector)
189 | }
190 | // If a function is given, call it when the DOM is ready
191 | else if (isFunction(selector)) return $(document).ready(selector)
192 | // If a Zepto collection is given, just return it
193 | else if (zepto.isZ(selector)) return selector
194 | else {
195 | // normalize array if an array of nodes is given
196 | if (isArray(selector)) dom = compact(selector)
197 | // Wrap DOM nodes.
198 | else if (isObject(selector))
199 | dom = [selector], selector = null
200 | // If it's a html fragment, create nodes from it
201 | else if (fragmentRE.test(selector))
202 | dom = zepto.fragment(selector.trim(), RegExp.$1, context), selector = null
203 | // If there's a context, create a collection on that context first, and select
204 | // nodes from there
205 | else if (context !== undefined) return $(context).find(selector)
206 | // And last but no least, if it's a CSS selector, use it to select nodes.
207 | else dom = zepto.qsa(document, selector)
208 | }
209 | // create a new Zepto collection from the nodes found
210 | return zepto.Z(dom, selector)
211 | }
212 |
213 | // `$` will be the base `Zepto` object. When calling this
214 | // function just call `$.zepto.init, which makes the implementation
215 | // details of selecting nodes and creating Zepto collections
216 | // patchable in plugins.
217 | $ = function(selector, context){
218 | return zepto.init(selector, context)
219 | }
220 |
221 | function extend(target, source, deep) {
222 | for (key in source)
223 | if (deep && (isPlainObject(source[key]) || isArray(source[key]))) {
224 | if (isPlainObject(source[key]) && !isPlainObject(target[key]))
225 | target[key] = {}
226 | if (isArray(source[key]) && !isArray(target[key]))
227 | target[key] = []
228 | extend(target[key], source[key], deep)
229 | }
230 | else if (source[key] !== undefined) target[key] = source[key]
231 | }
232 |
233 | // Copy all but undefined properties from one or more
234 | // objects to the `target` object.
235 | $.extend = function(target){
236 | var deep, args = slice.call(arguments, 1)
237 | if (typeof target == 'boolean') {
238 | deep = target
239 | target = args.shift()
240 | }
241 | args.forEach(function(arg){ extend(target, arg, deep) })
242 | return target
243 | }
244 |
245 | // `$.zepto.qsa` is Zepto's CSS selector implementation which
246 | // uses `document.querySelectorAll` and optimizes for some special cases, like `#id`.
247 | // This method can be overriden in plugins.
248 | zepto.qsa = function(element, selector){
249 | var found,
250 | maybeID = selector[0] == '#',
251 | maybeClass = !maybeID && selector[0] == '.',
252 | nameOnly = maybeID || maybeClass ? selector.slice(1) : selector, // Ensure that a 1 char tag name still gets checked
253 | isSimple = simpleSelectorRE.test(nameOnly)
254 | return (isDocument(element) && isSimple && maybeID) ?
255 | ( (found = element.getElementById(nameOnly)) ? [found] : [] ) :
256 | (element.nodeType !== 1 && element.nodeType !== 9) ? [] :
257 | slice.call(
258 | isSimple && !maybeID ?
259 | maybeClass ? element.getElementsByClassName(nameOnly) : // If it's simple, it could be a class
260 | element.getElementsByTagName(selector) : // Or a tag
261 | element.querySelectorAll(selector) // Or it's not simple, and we need to query all
262 | )
263 | }
264 |
265 | function filtered(nodes, selector) {
266 | return selector == null ? $(nodes) : $(nodes).filter(selector)
267 | }
268 |
269 | $.contains = document.documentElement.contains ?
270 | function(parent, node) {
271 | return parent !== node && parent.contains(node)
272 | } :
273 | function(parent, node) {
274 | while (node && (node = node.parentNode))
275 | if (node === parent) return true
276 | return false
277 | }
278 |
279 | function funcArg(context, arg, idx, payload) {
280 | return isFunction(arg) ? arg.call(context, idx, payload) : arg
281 | }
282 |
283 | function setAttribute(node, name, value) {
284 | value == null ? node.removeAttribute(name) : node.setAttribute(name, value)
285 | }
286 |
287 | // access className property while respecting SVGAnimatedString
288 | function className(node, value){
289 | var klass = node.className || '',
290 | svg = klass && klass.baseVal !== undefined
291 |
292 | if (value === undefined) return svg ? klass.baseVal : klass
293 | svg ? (klass.baseVal = value) : (node.className = value)
294 | }
295 |
296 | // "true" => true
297 | // "false" => false
298 | // "null" => null
299 | // "42" => 42
300 | // "42.5" => 42.5
301 | // "08" => "08"
302 | // JSON => parse if valid
303 | // String => self
304 | function deserializeValue(value) {
305 | try {
306 | return value ?
307 | value == "true" ||
308 | ( value == "false" ? false :
309 | value == "null" ? null :
310 | +value + "" == value ? +value :
311 | /^[\[\{]/.test(value) ? $.parseJSON(value) :
312 | value )
313 | : value
314 | } catch(e) {
315 | return value
316 | }
317 | }
318 |
319 | $.type = type
320 | $.isFunction = isFunction
321 | $.isWindow = isWindow
322 | $.isArray = isArray
323 | $.isPlainObject = isPlainObject
324 |
325 | $.isEmptyObject = function(obj) {
326 | var name
327 | for (name in obj) return false
328 | return true
329 | }
330 |
331 | $.inArray = function(elem, array, i){
332 | return emptyArray.indexOf.call(array, elem, i)
333 | }
334 |
335 | $.camelCase = camelize
336 | $.trim = function(str) {
337 | return str == null ? "" : String.prototype.trim.call(str)
338 | }
339 |
340 | // plugin compatibility
341 | $.uuid = 0
342 | $.support = { }
343 | $.expr = { }
344 |
345 | $.map = function(elements, callback){
346 | var value, values = [], i, key
347 | if (likeArray(elements))
348 | for (i = 0; i < elements.length; i++) {
349 | value = callback(elements[i], i)
350 | if (value != null) values.push(value)
351 | }
352 | else
353 | for (key in elements) {
354 | value = callback(elements[key], key)
355 | if (value != null) values.push(value)
356 | }
357 | return flatten(values)
358 | }
359 |
360 | $.each = function(elements, callback){
361 | var i, key
362 | if (likeArray(elements)) {
363 | for (i = 0; i < elements.length; i++)
364 | if (callback.call(elements[i], i, elements[i]) === false) return elements
365 | } else {
366 | for (key in elements)
367 | if (callback.call(elements[key], key, elements[key]) === false) return elements
368 | }
369 |
370 | return elements
371 | }
372 |
373 | $.grep = function(elements, callback){
374 | return filter.call(elements, callback)
375 | }
376 |
377 | if (window.JSON) $.parseJSON = JSON.parse
378 |
379 | // Populate the class2type map
380 | $.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
381 | class2type[ "[object " + name + "]" ] = name.toLowerCase()
382 | })
383 |
384 | // Define methods that will be available on all
385 | // Zepto collections
386 | $.fn = {
387 | // Because a collection acts like an array
388 | // copy over these useful array functions.
389 | forEach: emptyArray.forEach,
390 | reduce: emptyArray.reduce,
391 | push: emptyArray.push,
392 | sort: emptyArray.sort,
393 | indexOf: emptyArray.indexOf,
394 | concat: emptyArray.concat,
395 |
396 | // `map` and `slice` in the jQuery API work differently
397 | // from their array counterparts
398 | map: function(fn){
399 | return $($.map(this, function(el, i){ return fn.call(el, i, el) }))
400 | },
401 | slice: function(){
402 | return $(slice.apply(this, arguments))
403 | },
404 |
405 | ready: function(callback){
406 | // need to check if document.body exists for IE as that browser reports
407 | // document ready when it hasn't yet created the body element
408 | if (readyRE.test(document.readyState) && document.body) callback($)
409 | else document.addEventListener('DOMContentLoaded', function(){ callback($) }, false)
410 | return this
411 | },
412 | get: function(idx){
413 | return idx === undefined ? slice.call(this) : this[idx >= 0 ? idx : idx + this.length]
414 | },
415 | toArray: function(){ return this.get() },
416 | size: function(){
417 | return this.length
418 | },
419 | remove: function(){
420 | return this.each(function(){
421 | if (this.parentNode != null)
422 | this.parentNode.removeChild(this)
423 | })
424 | },
425 | each: function(callback){
426 | emptyArray.every.call(this, function(el, idx){
427 | return callback.call(el, idx, el) !== false
428 | })
429 | return this
430 | },
431 | filter: function(selector){
432 | if (isFunction(selector)) return this.not(this.not(selector))
433 | return $(filter.call(this, function(element){
434 | return zepto.matches(element, selector)
435 | }))
436 | },
437 | add: function(selector,context){
438 | return $(uniq(this.concat($(selector,context))))
439 | },
440 | is: function(selector){
441 | return this.length > 0 && zepto.matches(this[0], selector)
442 | },
443 | not: function(selector){
444 | var nodes=[]
445 | if (isFunction(selector) && selector.call !== undefined)
446 | this.each(function(idx){
447 | if (!selector.call(this,idx)) nodes.push(this)
448 | })
449 | else {
450 | var excludes = typeof selector == 'string' ? this.filter(selector) :
451 | (likeArray(selector) && isFunction(selector.item)) ? slice.call(selector) : $(selector)
452 | this.forEach(function(el){
453 | if (excludes.indexOf(el) < 0) nodes.push(el)
454 | })
455 | }
456 | return $(nodes)
457 | },
458 | has: function(selector){
459 | return this.filter(function(){
460 | return isObject(selector) ?
461 | $.contains(this, selector) :
462 | $(this).find(selector).size()
463 | })
464 | },
465 | eq: function(idx){
466 | return idx === -1 ? this.slice(idx) : this.slice(idx, + idx + 1)
467 | },
468 | first: function(){
469 | var el = this[0]
470 | return el && !isObject(el) ? el : $(el)
471 | },
472 | last: function(){
473 | var el = this[this.length - 1]
474 | return el && !isObject(el) ? el : $(el)
475 | },
476 | find: function(selector){
477 | var result, $this = this
478 | if (!selector) result = $()
479 | else if (typeof selector == 'object')
480 | result = $(selector).filter(function(){
481 | var node = this
482 | return emptyArray.some.call($this, function(parent){
483 | return $.contains(parent, node)
484 | })
485 | })
486 | else if (this.length == 1) result = $(zepto.qsa(this[0], selector))
487 | else result = this.map(function(){ return zepto.qsa(this, selector) })
488 | return result
489 | },
490 | closest: function(selector, context){
491 | var node = this[0], collection = false
492 | if (typeof selector == 'object') collection = $(selector)
493 | while (node && !(collection ? collection.indexOf(node) >= 0 : zepto.matches(node, selector)))
494 | node = node !== context && !isDocument(node) && node.parentNode
495 | return $(node)
496 | },
497 | parents: function(selector){
498 | var ancestors = [], nodes = this
499 | while (nodes.length > 0)
500 | nodes = $.map(nodes, function(node){
501 | if ((node = node.parentNode) && !isDocument(node) && ancestors.indexOf(node) < 0) {
502 | ancestors.push(node)
503 | return node
504 | }
505 | })
506 | return filtered(ancestors, selector)
507 | },
508 | parent: function(selector){
509 | return filtered(uniq(this.pluck('parentNode')), selector)
510 | },
511 | children: function(selector){
512 | return filtered(this.map(function(){ return children(this) }), selector)
513 | },
514 | contents: function() {
515 | return this.map(function() { return slice.call(this.childNodes) })
516 | },
517 | siblings: function(selector){
518 | return filtered(this.map(function(i, el){
519 | return filter.call(children(el.parentNode), function(child){ return child!==el })
520 | }), selector)
521 | },
522 | empty: function(){
523 | return this.each(function(){ this.innerHTML = '' })
524 | },
525 | // `pluck` is borrowed from Prototype.js
526 | pluck: function(property){
527 | return $.map(this, function(el){ return el[property] })
528 | },
529 | show: function(){
530 | return this.each(function(){
531 | this.style.display == "none" && (this.style.display = '')
532 | if (getComputedStyle(this, '').getPropertyValue("display") == "none")
533 | this.style.display = defaultDisplay(this.nodeName)
534 | })
535 | },
536 | replaceWith: function(newContent){
537 | return this.before(newContent).remove()
538 | },
539 | wrap: function(structure){
540 | var func = isFunction(structure)
541 | if (this[0] && !func)
542 | var dom = $(structure).get(0),
543 | clone = dom.parentNode || this.length > 1
544 |
545 | return this.each(function(index){
546 | $(this).wrapAll(
547 | func ? structure.call(this, index) :
548 | clone ? dom.cloneNode(true) : dom
549 | )
550 | })
551 | },
552 | wrapAll: function(structure){
553 | if (this[0]) {
554 | $(this[0]).before(structure = $(structure))
555 | var children
556 | // drill down to the inmost element
557 | while ((children = structure.children()).length) structure = children.first()
558 | $(structure).append(this)
559 | }
560 | return this
561 | },
562 | wrapInner: function(structure){
563 | var func = isFunction(structure)
564 | return this.each(function(index){
565 | var self = $(this), contents = self.contents(),
566 | dom = func ? structure.call(this, index) : structure
567 | contents.length ? contents.wrapAll(dom) : self.append(dom)
568 | })
569 | },
570 | unwrap: function(){
571 | this.parent().each(function(){
572 | $(this).replaceWith($(this).children())
573 | })
574 | return this
575 | },
576 | clone: function(){
577 | return this.map(function(){ return this.cloneNode(true) })
578 | },
579 | hide: function(){
580 | return this.css("display", "none")
581 | },
582 | toggle: function(setting){
583 | return this.each(function(){
584 | var el = $(this)
585 | ;(setting === undefined ? el.css("display") == "none" : setting) ? el.show() : el.hide()
586 | })
587 | },
588 | prev: function(selector){ return $(this.pluck('previousElementSibling')).filter(selector || '*') },
589 | next: function(selector){ return $(this.pluck('nextElementSibling')).filter(selector || '*') },
590 | html: function(html){
591 | return 0 in arguments ?
592 | this.each(function(idx){
593 | var originHtml = this.innerHTML
594 | $(this).empty().append( funcArg(this, html, idx, originHtml) )
595 | }) :
596 | (0 in this ? this[0].innerHTML : null)
597 | },
598 | text: function(text){
599 | return 0 in arguments ?
600 | this.each(function(idx){
601 | var newText = funcArg(this, text, idx, this.textContent)
602 | this.textContent = newText == null ? '' : ''+newText
603 | }) :
604 | (0 in this ? this[0].textContent : null)
605 | },
606 | attr: function(name, value){
607 | var result
608 | return (typeof name == 'string' && !(1 in arguments)) ?
609 | (!this.length || this[0].nodeType !== 1 ? undefined :
610 | (!(result = this[0].getAttribute(name)) && name in this[0]) ? this[0][name] : result
611 | ) :
612 | this.each(function(idx){
613 | if (this.nodeType !== 1) return
614 | if (isObject(name)) for (key in name) setAttribute(this, key, name[key])
615 | else setAttribute(this, name, funcArg(this, value, idx, this.getAttribute(name)))
616 | })
617 | },
618 | removeAttr: function(name){
619 | return this.each(function(){ this.nodeType === 1 && name.split(' ').forEach(function(attribute){
620 | setAttribute(this, attribute)
621 | }, this)})
622 | },
623 | prop: function(name, value){
624 | name = propMap[name] || name
625 | return (1 in arguments) ?
626 | this.each(function(idx){
627 | this[name] = funcArg(this, value, idx, this[name])
628 | }) :
629 | (this[0] && this[0][name])
630 | },
631 | data: function(name, value){
632 | var attrName = 'data-' + name.replace(capitalRE, '-$1').toLowerCase()
633 |
634 | var data = (1 in arguments) ?
635 | this.attr(attrName, value) :
636 | this.attr(attrName)
637 |
638 | return data !== null ? deserializeValue(data) : undefined
639 | },
640 | val: function(value){
641 | return 0 in arguments ?
642 | this.each(function(idx){
643 | this.value = funcArg(this, value, idx, this.value)
644 | }) :
645 | (this[0] && (this[0].multiple ?
646 | $(this[0]).find('option').filter(function(){ return this.selected }).pluck('value') :
647 | this[0].value)
648 | )
649 | },
650 | offset: function(coordinates){
651 | if (coordinates) return this.each(function(index){
652 | var $this = $(this),
653 | coords = funcArg(this, coordinates, index, $this.offset()),
654 | parentOffset = $this.offsetParent().offset(),
655 | props = {
656 | top: coords.top - parentOffset.top,
657 | left: coords.left - parentOffset.left
658 | }
659 |
660 | if ($this.css('position') == 'static') props['position'] = 'relative'
661 | $this.css(props)
662 | })
663 | if (!this.length) return null
664 | var obj = this[0].getBoundingClientRect()
665 | return {
666 | left: obj.left + window.pageXOffset,
667 | top: obj.top + window.pageYOffset,
668 | width: Math.round(obj.width),
669 | height: Math.round(obj.height)
670 | }
671 | },
672 | css: function(property, value){
673 | if (arguments.length < 2) {
674 | var computedStyle, element = this[0]
675 | if(!element) return
676 | computedStyle = getComputedStyle(element, '')
677 | if (typeof property == 'string')
678 | return element.style[camelize(property)] || computedStyle.getPropertyValue(property)
679 | else if (isArray(property)) {
680 | var props = {}
681 | $.each(property, function(_, prop){
682 | props[prop] = (element.style[camelize(prop)] || computedStyle.getPropertyValue(prop))
683 | })
684 | return props
685 | }
686 | }
687 |
688 | var css = ''
689 | if (type(property) == 'string') {
690 | if (!value && value !== 0)
691 | this.each(function(){ this.style.removeProperty(dasherize(property)) })
692 | else
693 | css = dasherize(property) + ":" + maybeAddPx(property, value)
694 | } else {
695 | for (key in property)
696 | if (!property[key] && property[key] !== 0)
697 | this.each(function(){ this.style.removeProperty(dasherize(key)) })
698 | else
699 | css += dasherize(key) + ':' + maybeAddPx(key, property[key]) + ';'
700 | }
701 |
702 | return this.each(function(){ this.style.cssText += ';' + css })
703 | },
704 | index: function(element){
705 | return element ? this.indexOf($(element)[0]) : this.parent().children().indexOf(this[0])
706 | },
707 | hasClass: function(name){
708 | if (!name) return false
709 | return emptyArray.some.call(this, function(el){
710 | return this.test(className(el))
711 | }, classRE(name))
712 | },
713 | addClass: function(name){
714 | if (!name) return this
715 | return this.each(function(idx){
716 | if (!('className' in this)) return
717 | classList = []
718 | var cls = className(this), newName = funcArg(this, name, idx, cls)
719 | newName.split(/\s+/g).forEach(function(klass){
720 | if (!$(this).hasClass(klass)) classList.push(klass)
721 | }, this)
722 | classList.length && className(this, cls + (cls ? " " : "") + classList.join(" "))
723 | })
724 | },
725 | removeClass: function(name){
726 | return this.each(function(idx){
727 | if (!('className' in this)) return
728 | if (name === undefined) return className(this, '')
729 | classList = className(this)
730 | funcArg(this, name, idx, classList).split(/\s+/g).forEach(function(klass){
731 | classList = classList.replace(classRE(klass), " ")
732 | })
733 | className(this, classList.trim())
734 | })
735 | },
736 | toggleClass: function(name, when){
737 | if (!name) return this
738 | return this.each(function(idx){
739 | var $this = $(this), names = funcArg(this, name, idx, className(this))
740 | names.split(/\s+/g).forEach(function(klass){
741 | (when === undefined ? !$this.hasClass(klass) : when) ?
742 | $this.addClass(klass) : $this.removeClass(klass)
743 | })
744 | })
745 | },
746 | scrollTop: function(value){
747 | if (!this.length) return
748 | var hasScrollTop = 'scrollTop' in this[0]
749 | if (value === undefined) return hasScrollTop ? this[0].scrollTop : this[0].pageYOffset
750 | return this.each(hasScrollTop ?
751 | function(){ this.scrollTop = value } :
752 | function(){ this.scrollTo(this.scrollX, value) })
753 | },
754 | scrollLeft: function(value){
755 | if (!this.length) return
756 | var hasScrollLeft = 'scrollLeft' in this[0]
757 | if (value === undefined) return hasScrollLeft ? this[0].scrollLeft : this[0].pageXOffset
758 | return this.each(hasScrollLeft ?
759 | function(){ this.scrollLeft = value } :
760 | function(){ this.scrollTo(value, this.scrollY) })
761 | },
762 | position: function() {
763 | if (!this.length) return
764 |
765 | var elem = this[0],
766 | // Get *real* offsetParent
767 | offsetParent = this.offsetParent(),
768 | // Get correct offsets
769 | offset = this.offset(),
770 | parentOffset = rootNodeRE.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset()
771 |
772 | // Subtract element margins
773 | // note: when an element has margin: auto the offsetLeft and marginLeft
774 | // are the same in Safari causing offset.left to incorrectly be 0
775 | offset.top -= parseFloat( $(elem).css('margin-top') ) || 0
776 | offset.left -= parseFloat( $(elem).css('margin-left') ) || 0
777 |
778 | // Add offsetParent borders
779 | parentOffset.top += parseFloat( $(offsetParent[0]).css('border-top-width') ) || 0
780 | parentOffset.left += parseFloat( $(offsetParent[0]).css('border-left-width') ) || 0
781 |
782 | // Subtract the two offsets
783 | return {
784 | top: offset.top - parentOffset.top,
785 | left: offset.left - parentOffset.left
786 | }
787 | },
788 | offsetParent: function() {
789 | return this.map(function(){
790 | var parent = this.offsetParent || document.body
791 | while (parent && !rootNodeRE.test(parent.nodeName) && $(parent).css("position") == "static")
792 | parent = parent.offsetParent
793 | return parent
794 | })
795 | }
796 | }
797 |
798 | // for now
799 | $.fn.detach = $.fn.remove
800 |
801 | // Generate the `width` and `height` functions
802 | ;['width', 'height'].forEach(function(dimension){
803 | var dimensionProperty =
804 | dimension.replace(/./, function(m){ return m[0].toUpperCase() })
805 |
806 | $.fn[dimension] = function(value){
807 | var offset, el = this[0]
808 | if (value === undefined) return isWindow(el) ? el['inner' + dimensionProperty] :
809 | isDocument(el) ? el.documentElement['scroll' + dimensionProperty] :
810 | (offset = this.offset()) && offset[dimension]
811 | else return this.each(function(idx){
812 | el = $(this)
813 | el.css(dimension, funcArg(this, value, idx, el[dimension]()))
814 | })
815 | }
816 | })
817 |
818 | function traverseNode(node, fun) {
819 | fun(node)
820 | for (var i = 0, len = node.childNodes.length; i < len; i++)
821 | traverseNode(node.childNodes[i], fun)
822 | }
823 |
824 | // Generate the `after`, `prepend`, `before`, `append`,
825 | // `insertAfter`, `insertBefore`, `appendTo`, and `prependTo` methods.
826 | adjacencyOperators.forEach(function(operator, operatorIndex) {
827 | var inside = operatorIndex % 2 //=> prepend, append
828 |
829 | $.fn[operator] = function(){
830 | // arguments can be nodes, arrays of nodes, Zepto objects and HTML strings
831 | var argType, nodes = $.map(arguments, function(arg) {
832 | argType = type(arg)
833 | return argType == "object" || argType == "array" || arg == null ?
834 | arg : zepto.fragment(arg)
835 | }),
836 | parent, copyByClone = this.length > 1
837 | if (nodes.length < 1) return this
838 |
839 | return this.each(function(_, target){
840 | parent = inside ? target : target.parentNode
841 |
842 | // convert all methods to a "before" operation
843 | target = operatorIndex == 0 ? target.nextSibling :
844 | operatorIndex == 1 ? target.firstChild :
845 | operatorIndex == 2 ? target :
846 | null
847 |
848 | var parentInDocument = $.contains(document.documentElement, parent)
849 |
850 | nodes.forEach(function(node){
851 | if (copyByClone) node = node.cloneNode(true)
852 | else if (!parent) return $(node).remove()
853 |
854 | parent.insertBefore(node, target)
855 | if (parentInDocument) traverseNode(node, function(el){
856 | if (el.nodeName != null && el.nodeName.toUpperCase() === 'SCRIPT' &&
857 | (!el.type || el.type === 'text/javascript') && !el.src)
858 | window['eval'].call(window, el.innerHTML)
859 | })
860 | })
861 | })
862 | }
863 |
864 | // after => insertAfter
865 | // prepend => prependTo
866 | // before => insertBefore
867 | // append => appendTo
868 | $.fn[inside ? operator+'To' : 'insert'+(operatorIndex ? 'Before' : 'After')] = function(html){
869 | $(html)[operator](this)
870 | return this
871 | }
872 | })
873 |
874 | zepto.Z.prototype = $.fn
875 |
876 | // Export internal API functions in the `$.zepto` namespace
877 | zepto.uniq = uniq
878 | zepto.deserializeValue = deserializeValue
879 | $.zepto = zepto
880 |
881 | return $
882 | })()
883 |
884 | window.Zepto = Zepto
885 | window.$ === undefined && (window.$ = Zepto)
886 |
887 | ;(function($){
888 | var _zid = 1, undefined,
889 | slice = Array.prototype.slice,
890 | isFunction = $.isFunction,
891 | isString = function(obj){ return typeof obj == 'string' },
892 | handlers = {},
893 | specialEvents={},
894 | focusinSupported = 'onfocusin' in window,
895 | focus = { focus: 'focusin', blur: 'focusout' },
896 | hover = { mouseenter: 'mouseover', mouseleave: 'mouseout' }
897 |
898 | specialEvents.click = specialEvents.mousedown = specialEvents.mouseup = specialEvents.mousemove = 'MouseEvents'
899 |
900 | function zid(element) {
901 | return element._zid || (element._zid = _zid++)
902 | }
903 | function findHandlers(element, event, fn, selector) {
904 | event = parse(event)
905 | if (event.ns) var matcher = matcherFor(event.ns)
906 | return (handlers[zid(element)] || []).filter(function(handler) {
907 | return handler
908 | && (!event.e || handler.e == event.e)
909 | && (!event.ns || matcher.test(handler.ns))
910 | && (!fn || zid(handler.fn) === zid(fn))
911 | && (!selector || handler.sel == selector)
912 | })
913 | }
914 | function parse(event) {
915 | var parts = ('' + event).split('.')
916 | return {e: parts[0], ns: parts.slice(1).sort().join(' ')}
917 | }
918 | function matcherFor(ns) {
919 | return new RegExp('(?:^| )' + ns.replace(' ', ' .* ?') + '(?: |$)')
920 | }
921 |
922 | function eventCapture(handler, captureSetting) {
923 | return handler.del &&
924 | (!focusinSupported && (handler.e in focus)) ||
925 | !!captureSetting
926 | }
927 |
928 | function realEvent(type) {
929 | return hover[type] || (focusinSupported && focus[type]) || type
930 | }
931 |
932 | function add(element, events, fn, data, selector, delegator, capture){
933 | var id = zid(element), set = (handlers[id] || (handlers[id] = []))
934 | events.split(/\s/).forEach(function(event){
935 | if (event == 'ready') return $(document).ready(fn)
936 | var handler = parse(event)
937 | handler.fn = fn
938 | handler.sel = selector
939 | // emulate mouseenter, mouseleave
940 | if (handler.e in hover) fn = function(e){
941 | var related = e.relatedTarget
942 | if (!related || (related !== this && !$.contains(this, related)))
943 | return handler.fn.apply(this, arguments)
944 | }
945 | handler.del = delegator
946 | var callback = delegator || fn
947 | handler.proxy = function(e){
948 | e = compatible(e)
949 | if (e.isImmediatePropagationStopped()) return
950 | e.data = data
951 | var result = callback.apply(element, e._args == undefined ? [e] : [e].concat(e._args))
952 | if (result === false) e.preventDefault(), e.stopPropagation()
953 | return result
954 | }
955 | handler.i = set.length
956 | set.push(handler)
957 | if ('addEventListener' in element)
958 | element.addEventListener(realEvent(handler.e), handler.proxy, eventCapture(handler, capture))
959 | })
960 | }
961 | function remove(element, events, fn, selector, capture){
962 | var id = zid(element)
963 | ;(events || '').split(/\s/).forEach(function(event){
964 | findHandlers(element, event, fn, selector).forEach(function(handler){
965 | delete handlers[id][handler.i]
966 | if ('removeEventListener' in element)
967 | element.removeEventListener(realEvent(handler.e), handler.proxy, eventCapture(handler, capture))
968 | })
969 | })
970 | }
971 |
972 | $.event = { add: add, remove: remove }
973 |
974 | $.proxy = function(fn, context) {
975 | var args = (2 in arguments) && slice.call(arguments, 2)
976 | if (isFunction(fn)) {
977 | var proxyFn = function(){ return fn.apply(context, args ? args.concat(slice.call(arguments)) : arguments) }
978 | proxyFn._zid = zid(fn)
979 | return proxyFn
980 | } else if (isString(context)) {
981 | if (args) {
982 | args.unshift(fn[context], fn)
983 | return $.proxy.apply(null, args)
984 | } else {
985 | return $.proxy(fn[context], fn)
986 | }
987 | } else {
988 | throw new TypeError("expected function")
989 | }
990 | }
991 |
992 | $.fn.bind = function(event, data, callback){
993 | return this.on(event, data, callback)
994 | }
995 | $.fn.unbind = function(event, callback){
996 | return this.off(event, callback)
997 | }
998 | $.fn.one = function(event, selector, data, callback){
999 | return this.on(event, selector, data, callback, 1)
1000 | }
1001 |
1002 | var returnTrue = function(){return true},
1003 | returnFalse = function(){return false},
1004 | ignoreProperties = /^([A-Z]|returnValue$|layer[XY]$)/,
1005 | eventMethods = {
1006 | preventDefault: 'isDefaultPrevented',
1007 | stopImmediatePropagation: 'isImmediatePropagationStopped',
1008 | stopPropagation: 'isPropagationStopped'
1009 | }
1010 |
1011 | function compatible(event, source) {
1012 | if (source || !event.isDefaultPrevented) {
1013 | source || (source = event)
1014 |
1015 | $.each(eventMethods, function(name, predicate) {
1016 | var sourceMethod = source[name]
1017 | event[name] = function(){
1018 | this[predicate] = returnTrue
1019 | return sourceMethod && sourceMethod.apply(source, arguments)
1020 | }
1021 | event[predicate] = returnFalse
1022 | })
1023 |
1024 | if (source.defaultPrevented !== undefined ? source.defaultPrevented :
1025 | 'returnValue' in source ? source.returnValue === false :
1026 | source.getPreventDefault && source.getPreventDefault())
1027 | event.isDefaultPrevented = returnTrue
1028 | }
1029 | return event
1030 | }
1031 |
1032 | function createProxy(event) {
1033 | var key, proxy = { originalEvent: event }
1034 | for (key in event)
1035 | if (!ignoreProperties.test(key) && event[key] !== undefined) proxy[key] = event[key]
1036 |
1037 | return compatible(proxy, event)
1038 | }
1039 |
1040 | $.fn.delegate = function(selector, event, callback){
1041 | return this.on(event, selector, callback)
1042 | }
1043 | $.fn.undelegate = function(selector, event, callback){
1044 | return this.off(event, selector, callback)
1045 | }
1046 |
1047 | $.fn.live = function(event, callback){
1048 | $(document.body).delegate(this.selector, event, callback)
1049 | return this
1050 | }
1051 | $.fn.die = function(event, callback){
1052 | $(document.body).undelegate(this.selector, event, callback)
1053 | return this
1054 | }
1055 |
1056 | $.fn.on = function(event, selector, data, callback, one){
1057 | var autoRemove, delegator, $this = this
1058 | if (event && !isString(event)) {
1059 | $.each(event, function(type, fn){
1060 | $this.on(type, selector, data, fn, one)
1061 | })
1062 | return $this
1063 | }
1064 |
1065 | if (!isString(selector) && !isFunction(callback) && callback !== false)
1066 | callback = data, data = selector, selector = undefined
1067 | if (isFunction(data) || data === false)
1068 | callback = data, data = undefined
1069 |
1070 | if (callback === false) callback = returnFalse
1071 |
1072 | return $this.each(function(_, element){
1073 | if (one) autoRemove = function(e){
1074 | remove(element, e.type, callback)
1075 | return callback.apply(this, arguments)
1076 | }
1077 |
1078 | if (selector) delegator = function(e){
1079 | var evt, match = $(e.target).closest(selector, element).get(0)
1080 | if (match && match !== element) {
1081 | evt = $.extend(createProxy(e), {currentTarget: match, liveFired: element})
1082 | return (autoRemove || callback).apply(match, [evt].concat(slice.call(arguments, 1)))
1083 | }
1084 | }
1085 |
1086 | add(element, event, callback, data, selector, delegator || autoRemove)
1087 | })
1088 | }
1089 | $.fn.off = function(event, selector, callback){
1090 | var $this = this
1091 | if (event && !isString(event)) {
1092 | $.each(event, function(type, fn){
1093 | $this.off(type, selector, fn)
1094 | })
1095 | return $this
1096 | }
1097 |
1098 | if (!isString(selector) && !isFunction(callback) && callback !== false)
1099 | callback = selector, selector = undefined
1100 |
1101 | if (callback === false) callback = returnFalse
1102 |
1103 | return $this.each(function(){
1104 | remove(this, event, callback, selector)
1105 | })
1106 | }
1107 |
1108 | $.fn.trigger = function(event, args){
1109 | event = (isString(event) || $.isPlainObject(event)) ? $.Event(event) : compatible(event)
1110 | event._args = args
1111 | return this.each(function(){
1112 | // handle focus(), blur() by calling them directly
1113 | if (event.type in focus && typeof this[event.type] == "function") this[event.type]()
1114 | // items in the collection might not be DOM elements
1115 | else if ('dispatchEvent' in this) this.dispatchEvent(event)
1116 | else $(this).triggerHandler(event, args)
1117 | })
1118 | }
1119 |
1120 | // triggers event handlers on current element just as if an event occurred,
1121 | // doesn't trigger an actual event, doesn't bubble
1122 | $.fn.triggerHandler = function(event, args){
1123 | var e, result
1124 | this.each(function(i, element){
1125 | e = createProxy(isString(event) ? $.Event(event) : event)
1126 | e._args = args
1127 | e.target = element
1128 | $.each(findHandlers(element, event.type || event), function(i, handler){
1129 | result = handler.proxy(e)
1130 | if (e.isImmediatePropagationStopped()) return false
1131 | })
1132 | })
1133 | return result
1134 | }
1135 |
1136 | // shortcut methods for `.bind(event, fn)` for each event type
1137 | ;('focusin focusout focus blur load resize scroll unload click dblclick '+
1138 | 'mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave '+
1139 | 'change select keydown keypress keyup error').split(' ').forEach(function(event) {
1140 | $.fn[event] = function(callback) {
1141 | return (0 in arguments) ?
1142 | this.bind(event, callback) :
1143 | this.trigger(event)
1144 | }
1145 | })
1146 |
1147 | $.Event = function(type, props) {
1148 | if (!isString(type)) props = type, type = props.type
1149 | var event = document.createEvent(specialEvents[type] || 'Events'), bubbles = true
1150 | if (props) for (var name in props) (name == 'bubbles') ? (bubbles = !!props[name]) : (event[name] = props[name])
1151 | event.initEvent(type, bubbles, true)
1152 | return compatible(event)
1153 | }
1154 |
1155 | })(Zepto)
1156 |
1157 | ;(function($){
1158 | var jsonpID = 0,
1159 | document = window.document,
1160 | key,
1161 | name,
1162 | rscript = /