├── .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 |
16 | 17 |
18 |
19 |
20 | 21 | 22 | 23 |
24 |
25 | 26 | 27 | 28 |
29 |
30 |
31 |
32 | 33 |
34 | 39 |
40 |
41 |

骆驼男装2016夏装男士短袖T恤 圆领衣服 印花男装体恤 半袖打底衫

42 |
43 |
尺码
44 | 73 |
74 |
75 |
76 |
77 | 很棒!!! 78 |
79 |
80 |
81 |
82 | 默认好评 83 |
84 |
85 |
86 |
87 | 一般 88 |
89 |
90 |
91 |
92 | 辣鸡~~~ 93 |
94 |
95 |
96 |
97 | 一分价钱一分货 98 |
99 |
100 |
101 |
102 |

T恤+裙+默认X通发货

103 |
104 |
105 |
106 |
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 |
16 | 17 |
18 |
19 |
20 | 21 | 22 | 23 |
24 |
25 | 26 | 27 | 28 |
29 |
30 | 31 | 32 | 33 |
34 |
35 |
36 |
37 | 38 |
导航栏一
39 | 65 | 66 |
导航栏二
67 |
68 | 69 |
70 | 71 |
72 |
73 |

标题标题标题标题标题

74 |
75 |
76 | ¥34.7 77 | ¥45.65 78 |
79 |
80 |
81 |
82 | 83 |
84 | 85 |
86 |
87 |

骆驼男装2016夏装男士短袖T恤 圆领衣服 印花男装体恤 半袖打底衫

88 |
89 |
90 | ¥34.7 91 | ¥45.65 92 |
93 |
94 |
95 |
96 | 97 |
98 | 99 |
100 |
101 |

条纹短袖T恤男士韩版衣服大码潮流男装夏季圆领体恤2016新款半袖

102 |
103 |
104 | ¥34.7 105 | ¥45.65 106 |
107 |
108 |
109 |
110 | 111 |
112 | 113 |
114 |
115 |

夏季青少年衣服男生潮牌t恤 男士 夏秋学生 日系棉短袖半袖男小衫

116 |
117 |
118 | ¥34.7 119 | ¥45.65 120 |
121 |
122 |
123 |
124 |
125 | 126 |
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 |
16 |
17 | 18 |
19 | 20 |
21 |
22 |

标题标题标题标题标题

23 |
24 |
25 | ¥34.7 26 | ¥45.65 27 |
28 | 29 |
30 |
31 |
32 | 33 |
34 | 35 |
36 |
37 |

骆驼男装2016夏装男士短袖T恤 圆领衣服 印花男装体恤 半袖打底衫

38 |
39 |
40 | ¥34.7 41 | ¥45.65 42 |
43 |
44 |
45 |
46 | 47 |
48 | 49 |
50 |
51 |

条纹短袖T恤男士韩版衣服大码潮流男装夏季圆领体恤2016新款半袖

52 |
53 |
54 | ¥34.7 55 | ¥45.65 56 |
57 |
58 |
59 |
60 | 61 |
62 | 63 |
64 |
65 |

夏季青少年衣服男生潮牌t恤 男士 夏秋学生 日系棉短袖半袖男小衫

66 |
67 |
68 | ¥34.7 69 | ¥45.65 70 |
71 | 72 |
73 |
74 |
75 | 76 |
77 | 78 |
79 |
80 |

夏季青少年衣服男生潮牌t恤 男士 夏秋学生 日系棉短袖半袖男小衫

81 |
82 |
83 | ¥34.7 84 | ¥45.65 85 |
86 | 87 |
88 |
89 |
90 | 91 |
92 | 93 |
94 |
95 |

夏季青少年衣服男生潮牌t恤 男士 夏秋学生 日系棉短袖半袖男小衫

96 |
97 |
98 | ¥34.7 99 | ¥45.65 100 |
101 | 102 |
103 |
104 |
105 | 106 |
107 | 108 |
109 |
110 |

夏季青少年衣服男生潮牌t恤 男士 夏秋学生 日系棉短袖半袖男小衫

111 |
112 |
113 | ¥34.7 114 | ¥45.65 115 |
116 | 117 |
118 |
119 |
120 |
121 |
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 |
16 |
个人信息
17 |
18 | 19 |
昵称
20 |
生生
21 |
22 | 23 |
手机
24 |
182 8820 1862
25 |
26 | 27 |
邮箱
28 |
pang_yongsheng@outlook.com
29 |
30 |
31 |
性别:
32 | 40 |
41 |
42 | 43 |
购物信息
44 | 58 |
收货地址
59 |
60 |
61 |
所在地区:
62 |
63 | 64 |
65 |
66 |
67 |
接受推送信息
68 |
69 | 76 | 83 | 90 |
91 | 92 |
意见反馈
93 |
94 |
95 |
96 | 97 |
98 |
99 |
100 | 101 | 102 |
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>") 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 = /)<[^<]*)*<\/script>/gi, 1163 | scriptTypeRE = /^(?:text|application)\/javascript/i, 1164 | xmlTypeRE = /^(?:text|application)\/xml/i, 1165 | jsonType = 'application/json', 1166 | htmlType = 'text/html', 1167 | blankRE = /^\s*$/, 1168 | originAnchor = document.createElement('a') 1169 | 1170 | originAnchor.href = window.location.href 1171 | 1172 | // trigger a custom event and return false if it was cancelled 1173 | function triggerAndReturn(context, eventName, data) { 1174 | var event = $.Event(eventName) 1175 | $(context).trigger(event, data) 1176 | return !event.isDefaultPrevented() 1177 | } 1178 | 1179 | // trigger an Ajax "global" event 1180 | function triggerGlobal(settings, context, eventName, data) { 1181 | if (settings.global) return triggerAndReturn(context || document, eventName, data) 1182 | } 1183 | 1184 | // Number of active Ajax requests 1185 | $.active = 0 1186 | 1187 | function ajaxStart(settings) { 1188 | if (settings.global && $.active++ === 0) triggerGlobal(settings, null, 'ajaxStart') 1189 | } 1190 | function ajaxStop(settings) { 1191 | if (settings.global && !(--$.active)) triggerGlobal(settings, null, 'ajaxStop') 1192 | } 1193 | 1194 | // triggers an extra global event "ajaxBeforeSend" that's like "ajaxSend" but cancelable 1195 | function ajaxBeforeSend(xhr, settings) { 1196 | var context = settings.context 1197 | if (settings.beforeSend.call(context, xhr, settings) === false || 1198 | triggerGlobal(settings, context, 'ajaxBeforeSend', [xhr, settings]) === false) 1199 | return false 1200 | 1201 | triggerGlobal(settings, context, 'ajaxSend', [xhr, settings]) 1202 | } 1203 | function ajaxSuccess(data, xhr, settings, deferred) { 1204 | var context = settings.context, status = 'success' 1205 | settings.success.call(context, data, status, xhr) 1206 | if (deferred) deferred.resolveWith(context, [data, status, xhr]) 1207 | triggerGlobal(settings, context, 'ajaxSuccess', [xhr, settings, data]) 1208 | ajaxComplete(status, xhr, settings) 1209 | } 1210 | // type: "timeout", "error", "abort", "parsererror" 1211 | function ajaxError(error, type, xhr, settings, deferred) { 1212 | var context = settings.context 1213 | settings.error.call(context, xhr, type, error) 1214 | if (deferred) deferred.rejectWith(context, [xhr, type, error]) 1215 | triggerGlobal(settings, context, 'ajaxError', [xhr, settings, error || type]) 1216 | ajaxComplete(type, xhr, settings) 1217 | } 1218 | // status: "success", "notmodified", "error", "timeout", "abort", "parsererror" 1219 | function ajaxComplete(status, xhr, settings) { 1220 | var context = settings.context 1221 | settings.complete.call(context, xhr, status) 1222 | triggerGlobal(settings, context, 'ajaxComplete', [xhr, settings]) 1223 | ajaxStop(settings) 1224 | } 1225 | 1226 | // Empty function, used as default callback 1227 | function empty() {} 1228 | 1229 | $.ajaxJSONP = function(options, deferred){ 1230 | if (!('type' in options)) return $.ajax(options) 1231 | 1232 | var _callbackName = options.jsonpCallback, 1233 | callbackName = ($.isFunction(_callbackName) ? 1234 | _callbackName() : _callbackName) || ('jsonp' + (++jsonpID)), 1235 | script = document.createElement('script'), 1236 | originalCallback = window[callbackName], 1237 | responseData, 1238 | abort = function(errorType) { 1239 | $(script).triggerHandler('error', errorType || 'abort') 1240 | }, 1241 | xhr = { abort: abort }, abortTimeout 1242 | 1243 | if (deferred) deferred.promise(xhr) 1244 | 1245 | $(script).on('load error', function(e, errorType){ 1246 | clearTimeout(abortTimeout) 1247 | $(script).off().remove() 1248 | 1249 | if (e.type == 'error' || !responseData) { 1250 | ajaxError(null, errorType || 'error', xhr, options, deferred) 1251 | } else { 1252 | ajaxSuccess(responseData[0], xhr, options, deferred) 1253 | } 1254 | 1255 | window[callbackName] = originalCallback 1256 | if (responseData && $.isFunction(originalCallback)) 1257 | originalCallback(responseData[0]) 1258 | 1259 | originalCallback = responseData = undefined 1260 | }) 1261 | 1262 | if (ajaxBeforeSend(xhr, options) === false) { 1263 | abort('abort') 1264 | return xhr 1265 | } 1266 | 1267 | window[callbackName] = function(){ 1268 | responseData = arguments 1269 | } 1270 | 1271 | script.src = options.url.replace(/\?(.+)=\?/, '?$1=' + callbackName) 1272 | document.head.appendChild(script) 1273 | 1274 | if (options.timeout > 0) abortTimeout = setTimeout(function(){ 1275 | abort('timeout') 1276 | }, options.timeout) 1277 | 1278 | return xhr 1279 | } 1280 | 1281 | $.ajaxSettings = { 1282 | // Default type of request 1283 | type: 'GET', 1284 | // Callback that is executed before request 1285 | beforeSend: empty, 1286 | // Callback that is executed if the request succeeds 1287 | success: empty, 1288 | // Callback that is executed the the server drops error 1289 | error: empty, 1290 | // Callback that is executed on request complete (both: error and success) 1291 | complete: empty, 1292 | // The context for the callbacks 1293 | context: null, 1294 | // Whether to trigger "global" Ajax events 1295 | global: true, 1296 | // Transport 1297 | xhr: function () { 1298 | return new window.XMLHttpRequest() 1299 | }, 1300 | // MIME types mapping 1301 | // IIS returns Javascript as "application/x-javascript" 1302 | accepts: { 1303 | script: 'text/javascript, application/javascript, application/x-javascript', 1304 | json: jsonType, 1305 | xml: 'application/xml, text/xml', 1306 | html: htmlType, 1307 | text: 'text/plain' 1308 | }, 1309 | // Whether the request is to another domain 1310 | crossDomain: false, 1311 | // Default timeout 1312 | timeout: 0, 1313 | // Whether data should be serialized to string 1314 | processData: true, 1315 | // Whether the browser should be allowed to cache GET responses 1316 | cache: true 1317 | } 1318 | 1319 | function mimeToDataType(mime) { 1320 | if (mime) mime = mime.split(';', 2)[0] 1321 | return mime && ( mime == htmlType ? 'html' : 1322 | mime == jsonType ? 'json' : 1323 | scriptTypeRE.test(mime) ? 'script' : 1324 | xmlTypeRE.test(mime) && 'xml' ) || 'text' 1325 | } 1326 | 1327 | function appendQuery(url, query) { 1328 | if (query == '') return url 1329 | return (url + '&' + query).replace(/[&?]{1,2}/, '?') 1330 | } 1331 | 1332 | // serialize payload and append it to the URL for GET requests 1333 | function serializeData(options) { 1334 | if (options.processData && options.data && $.type(options.data) != "string") 1335 | options.data = $.param(options.data, options.traditional) 1336 | if (options.data && (!options.type || options.type.toUpperCase() == 'GET')) 1337 | options.url = appendQuery(options.url, options.data), options.data = undefined 1338 | } 1339 | 1340 | $.ajax = function(options){ 1341 | var settings = $.extend({}, options || {}), 1342 | deferred = $.Deferred && $.Deferred(), 1343 | urlAnchor 1344 | for (key in $.ajaxSettings) if (settings[key] === undefined) settings[key] = $.ajaxSettings[key] 1345 | 1346 | ajaxStart(settings) 1347 | 1348 | if (!settings.crossDomain) { 1349 | urlAnchor = document.createElement('a') 1350 | urlAnchor.href = settings.url 1351 | urlAnchor.href = urlAnchor.href 1352 | settings.crossDomain = (originAnchor.protocol + '//' + originAnchor.host) !== (urlAnchor.protocol + '//' + urlAnchor.host) 1353 | } 1354 | 1355 | if (!settings.url) settings.url = window.location.toString() 1356 | serializeData(settings) 1357 | 1358 | var dataType = settings.dataType, hasPlaceholder = /\?.+=\?/.test(settings.url) 1359 | if (hasPlaceholder) dataType = 'jsonp' 1360 | 1361 | if (settings.cache === false || ( 1362 | (!options || options.cache !== true) && 1363 | ('script' == dataType || 'jsonp' == dataType) 1364 | )) 1365 | settings.url = appendQuery(settings.url, '_=' + Date.now()) 1366 | 1367 | if ('jsonp' == dataType) { 1368 | if (!hasPlaceholder) 1369 | settings.url = appendQuery(settings.url, 1370 | settings.jsonp ? (settings.jsonp + '=?') : settings.jsonp === false ? '' : 'callback=?') 1371 | return $.ajaxJSONP(settings, deferred) 1372 | } 1373 | 1374 | var mime = settings.accepts[dataType], 1375 | headers = { }, 1376 | setHeader = function(name, value) { headers[name.toLowerCase()] = [name, value] }, 1377 | protocol = /^([\w-]+:)\/\//.test(settings.url) ? RegExp.$1 : window.location.protocol, 1378 | xhr = settings.xhr(), 1379 | nativeSetHeader = xhr.setRequestHeader, 1380 | abortTimeout 1381 | 1382 | if (deferred) deferred.promise(xhr) 1383 | 1384 | if (!settings.crossDomain) setHeader('X-Requested-With', 'XMLHttpRequest') 1385 | setHeader('Accept', mime || '*/*') 1386 | if (mime = settings.mimeType || mime) { 1387 | if (mime.indexOf(',') > -1) mime = mime.split(',', 2)[0] 1388 | xhr.overrideMimeType && xhr.overrideMimeType(mime) 1389 | } 1390 | if (settings.contentType || (settings.contentType !== false && settings.data && settings.type.toUpperCase() != 'GET')) 1391 | setHeader('Content-Type', settings.contentType || 'application/x-www-form-urlencoded') 1392 | 1393 | if (settings.headers) for (name in settings.headers) setHeader(name, settings.headers[name]) 1394 | xhr.setRequestHeader = setHeader 1395 | 1396 | xhr.onreadystatechange = function(){ 1397 | if (xhr.readyState == 4) { 1398 | xhr.onreadystatechange = empty 1399 | clearTimeout(abortTimeout) 1400 | var result, error = false 1401 | if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304 || (xhr.status == 0 && protocol == 'file:')) { 1402 | dataType = dataType || mimeToDataType(settings.mimeType || xhr.getResponseHeader('content-type')) 1403 | result = xhr.responseText 1404 | 1405 | try { 1406 | // http://perfectionkills.com/global-eval-what-are-the-options/ 1407 | if (dataType == 'script') (1,eval)(result) 1408 | else if (dataType == 'xml') result = xhr.responseXML 1409 | else if (dataType == 'json') result = blankRE.test(result) ? null : $.parseJSON(result) 1410 | } catch (e) { error = e } 1411 | 1412 | if (error) ajaxError(error, 'parsererror', xhr, settings, deferred) 1413 | else ajaxSuccess(result, xhr, settings, deferred) 1414 | } else { 1415 | ajaxError(xhr.statusText || null, xhr.status ? 'error' : 'abort', xhr, settings, deferred) 1416 | } 1417 | } 1418 | } 1419 | 1420 | if (ajaxBeforeSend(xhr, settings) === false) { 1421 | xhr.abort() 1422 | ajaxError(null, 'abort', xhr, settings, deferred) 1423 | return xhr 1424 | } 1425 | 1426 | if (settings.xhrFields) for (name in settings.xhrFields) xhr[name] = settings.xhrFields[name] 1427 | 1428 | var async = 'async' in settings ? settings.async : true 1429 | xhr.open(settings.type, settings.url, async, settings.username, settings.password) 1430 | 1431 | for (name in headers) nativeSetHeader.apply(xhr, headers[name]) 1432 | 1433 | if (settings.timeout > 0) abortTimeout = setTimeout(function(){ 1434 | xhr.onreadystatechange = empty 1435 | xhr.abort() 1436 | ajaxError(null, 'timeout', xhr, settings, deferred) 1437 | }, settings.timeout) 1438 | 1439 | // avoid sending empty string (#319) 1440 | xhr.send(settings.data ? settings.data : null) 1441 | return xhr 1442 | } 1443 | 1444 | // handle optional data/success arguments 1445 | function parseArguments(url, data, success, dataType) { 1446 | if ($.isFunction(data)) dataType = success, success = data, data = undefined 1447 | if (!$.isFunction(success)) dataType = success, success = undefined 1448 | return { 1449 | url: url 1450 | , data: data 1451 | , success: success 1452 | , dataType: dataType 1453 | } 1454 | } 1455 | 1456 | $.get = function(/* url, data, success, dataType */){ 1457 | return $.ajax(parseArguments.apply(null, arguments)) 1458 | } 1459 | 1460 | $.post = function(/* url, data, success, dataType */){ 1461 | var options = parseArguments.apply(null, arguments) 1462 | options.type = 'POST' 1463 | return $.ajax(options) 1464 | } 1465 | 1466 | $.getJSON = function(/* url, data, success */){ 1467 | var options = parseArguments.apply(null, arguments) 1468 | options.dataType = 'json' 1469 | return $.ajax(options) 1470 | } 1471 | 1472 | $.fn.load = function(url, data, success){ 1473 | if (!this.length) return this 1474 | var self = this, parts = url.split(/\s/), selector, 1475 | options = parseArguments(url, data, success), 1476 | callback = options.success 1477 | if (parts.length > 1) options.url = parts[0], selector = parts[1] 1478 | options.success = function(response){ 1479 | self.html(selector ? 1480 | $('
').html(response.replace(rscript, "")).find(selector) 1481 | : response) 1482 | callback && callback.apply(self, arguments) 1483 | } 1484 | $.ajax(options) 1485 | return this 1486 | } 1487 | 1488 | var escape = encodeURIComponent 1489 | 1490 | function serialize(params, obj, traditional, scope){ 1491 | var type, array = $.isArray(obj), hash = $.isPlainObject(obj) 1492 | $.each(obj, function(key, value) { 1493 | type = $.type(value) 1494 | if (scope) key = traditional ? scope : 1495 | scope + '[' + (hash || type == 'object' || type == 'array' ? key : '') + ']' 1496 | // handle data in serializeArray() format 1497 | if (!scope && array) params.add(value.name, value.value) 1498 | // recurse into nested objects 1499 | else if (type == "array" || (!traditional && type == "object")) 1500 | serialize(params, value, traditional, key) 1501 | else params.add(key, value) 1502 | }) 1503 | } 1504 | 1505 | $.param = function(obj, traditional){ 1506 | var params = [] 1507 | params.add = function(key, value) { 1508 | if ($.isFunction(value)) value = value() 1509 | if (value == null) value = "" 1510 | this.push(escape(key) + '=' + escape(value)) 1511 | } 1512 | serialize(params, obj, traditional) 1513 | return params.join('&').replace(/%20/g, '+') 1514 | } 1515 | })(Zepto) 1516 | 1517 | ;(function($){ 1518 | $.fn.serializeArray = function() { 1519 | var name, type, result = [], 1520 | add = function(value) { 1521 | if (value.forEach) return value.forEach(add) 1522 | result.push({ name: name, value: value }) 1523 | } 1524 | if (this[0]) $.each(this[0].elements, function(_, field){ 1525 | type = field.type, name = field.name 1526 | if (name && field.nodeName.toLowerCase() != 'fieldset' && 1527 | !field.disabled && type != 'submit' && type != 'reset' && type != 'button' && type != 'file' && 1528 | ((type != 'radio' && type != 'checkbox') || field.checked)) 1529 | add($(field).val()) 1530 | }) 1531 | return result 1532 | } 1533 | 1534 | $.fn.serialize = function(){ 1535 | var result = [] 1536 | this.serializeArray().forEach(function(elm){ 1537 | result.push(encodeURIComponent(elm.name) + '=' + encodeURIComponent(elm.value)) 1538 | }) 1539 | return result.join('&') 1540 | } 1541 | 1542 | $.fn.submit = function(callback) { 1543 | if (0 in arguments) this.bind('submit', callback) 1544 | else if (this.length) { 1545 | var event = $.Event('submit') 1546 | this.eq(0).trigger(event) 1547 | if (!event.isDefaultPrevented()) this.get(0).submit() 1548 | } 1549 | return this 1550 | } 1551 | 1552 | })(Zepto) 1553 | 1554 | ;(function($){ 1555 | // __proto__ doesn't exist on IE<11, so redefine 1556 | // the Z function to use object extension instead 1557 | if (!('__proto__' in {})) { 1558 | $.extend($.zepto, { 1559 | Z: function(dom, selector){ 1560 | dom = dom || [] 1561 | $.extend(dom, $.fn) 1562 | dom.selector = selector || '' 1563 | dom.__Z = true 1564 | return dom 1565 | }, 1566 | // this is a kludge but works 1567 | isZ: function(object){ 1568 | return $.type(object) === 'array' && '__Z' in object 1569 | } 1570 | }) 1571 | } 1572 | 1573 | // getComputedStyle shouldn't freak out when called 1574 | // without a valid element as argument 1575 | try { 1576 | getComputedStyle(undefined) 1577 | } catch(e) { 1578 | var nativeGetComputedStyle = getComputedStyle; 1579 | window.getComputedStyle = function(element){ 1580 | try { 1581 | return nativeGetComputedStyle(element) 1582 | } catch(e) { 1583 | return null 1584 | } 1585 | } 1586 | } 1587 | })(Zepto) 1588 | 1589 | ;(function() { 1590 | /** 1591 | * 动态加载js文件 1592 | * @param {string} url js文件的url地址 1593 | * @param {Function} callback 加载完成后的回调函数 1594 | */ 1595 | var _getScript = function(url, callback) { 1596 | var script = document.createElement("script"); 1597 | script.type = "text/javascript"; 1598 | if(typeof(callback) != "undefined"){ 1599 | if (script.readyState) { 1600 | script.onreadystatechange = function () { 1601 | if (script.readyState == "loaded" || script.readyState == "complete") { 1602 | script.onreadystatechange = null; 1603 | callback(); 1604 | } 1605 | }; 1606 | } else { 1607 | script.onload = function () { 1608 | callback(); 1609 | }; 1610 | } 1611 | } 1612 | script.src = url; 1613 | document.body.appendChild(script); 1614 | } 1615 | 1616 | //如果使用的是zepto,就添加扩展函数 1617 | $.getScript = _getScript; 1618 | })(Zepto); 1619 | -------------------------------------------------------------------------------- /src/js/public/common.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pangyongsheng/spa/5ff3874287768fa21c6951b6281ba19c0d9093ec/src/js/public/common.js -------------------------------------------------------------------------------- /src/pages/detail/detail.css: -------------------------------------------------------------------------------- 1 | #detail .m-navbar{ 2 | background: linear-gradient(-45deg, #2ed1d1, #23c8c8); 3 | background: -webkit-linear-gradient(-45deg, #2ed1d1, #23c8c8); 4 | background: -o-linear-gradient(-45deg, #2ed1d1, #23c8c8); 5 | background: -moz-linear-gradient(-45deg, #2ed1d1, #23c8c8); 6 | } 7 | #detail .m-navbar .iconc{ 8 | font-size: .4rem; 9 | color: #fff; 10 | font-weight: lighter; 11 | } 12 | #detail .m-navbar .navbar-title{ 13 | color: #fff; 14 | font-weight: bolder; 15 | } 16 | #detail .iconc{ 17 | color: #fff; 18 | } 19 | #detail .tabbar-active{ 20 | color: #23c8c8; 21 | } 22 | #detail .m-celltitle{ 23 | margin-top: .1rem; 24 | } 25 | #detail .tab-nav-item.tab-active{ 26 | color:#2ed1d1; 27 | } 28 | #detail .slider-pagination-item-active{ 29 | background-color:#2ed1d1; 30 | } 31 | -------------------------------------------------------------------------------- /src/pages/detail/detail.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 14 | 15 |
16 | 17 |
18 |
19 |
20 | 21 | 22 | 23 |
24 |
25 | 26 | 27 | 28 |
29 |
30 |
31 |
32 | 33 |
34 | 39 |
40 |
41 |

骆驼男装2016夏装男士短袖T恤 圆领衣服 印花男装体恤 半袖打底衫

42 |
43 |
尺码
44 | 73 |
74 |
75 |
76 |
77 | 很棒!!! 78 |
79 |
80 |
81 |
82 | 默认好评 83 |
84 |
85 |
86 |
87 | 一般 88 |
89 |
90 |
91 |
92 | 辣鸡~~~ 93 |
94 |
95 |
96 |
97 | 一分价钱一分货 98 |
99 |
100 |
101 |
102 |

T恤+裙+默认X通发货

103 |
104 |
105 |
106 |
107 | 108 |
109 | -------------------------------------------------------------------------------- /src/pages/detail/detail.js: -------------------------------------------------------------------------------- 1 | $(function(){ 2 | //获取传参 3 | var obj = router.parse(); 4 | console.log(obj); 5 | $("#title").html(obj.param.title); 6 | //返回 7 | $(document).on('click','.navback',function(){ 8 | window.location.hash = router.stringify('home',{animate:'left'}); 9 | }) 10 | //轮播图 11 | $('#J_Slider').slider({ 12 | speed: 200, 13 | autoplay: 2000, 14 | lazyLoad: true 15 | }); 16 | //tab页 17 | var $tab = $('#J_Tab'); 18 | $tab.tab({ 19 | nav: '.tab-nav-item', 20 | panel: '.tab-panel-item', 21 | activeClass: 'tab-active' 22 | }); 23 | $tab.find('.tab-nav-item').on('open.ydui.tab', function (e) { 24 | console.log('索引:%s - [%s]正在打开', e.index, $(this).text()); 25 | }); 26 | $tab.find('.tab-nav-item').on('opened.ydui.tab', function (e) { 27 | console.log('索引:%s - [%s]已经打开了', e.index, $(this).text()); 28 | }); 29 | 30 | }) 31 | -------------------------------------------------------------------------------- /src/pages/home/home.css: -------------------------------------------------------------------------------- 1 | #home .m-navbar{ 2 | background: linear-gradient(-45deg, #2ed1d1, #23c8c8); 3 | background: -webkit-linear-gradient(-45deg, #2ed1d1, #23c8c8); 4 | background: -o-linear-gradient(-45deg, #2ed1d1, #23c8c8); 5 | background: -moz-linear-gradient(-45deg, #2ed1d1, #23c8c8); 6 | } 7 | #home .m-navbar .iconc{ 8 | font-size: .4rem; 9 | color: #fff; 10 | font-weight: lighter; 11 | } 12 | #home .m-navbar .navbar-title{ 13 | color: #fff; 14 | font-weight: bolder; 15 | } 16 | 17 | #home .tabbar-active{ 18 | color: #23c8c8; 19 | } 20 | #home .m-celltitle{ 21 | margin-top: .1rem; 22 | color:rgb(172, 184, 180); 23 | 24 | } 25 | #home .icons{ 26 | color: #23c8c8; 27 | font-size: .6rem; 28 | } 29 | #home .slider-pagination-item-active{ 30 | background-color: #23c8c8; 31 | } 32 | #home .list-price{ 33 | color: #23c8c8; 34 | } 35 | #home .badge-danger{ 36 | background-color: rgb(231, 57, 129); 37 | } 38 | -------------------------------------------------------------------------------- /src/pages/home/home.html: -------------------------------------------------------------------------------- 1 | 150 | -------------------------------------------------------------------------------- /src/pages/home/home.js: -------------------------------------------------------------------------------- 1 | $(function(){ 2 | //轮播图 3 | $('#J_Slider').slider({ 4 | speed: 200, 5 | autoplay: 2000, 6 | lazyLoad: true 7 | }); 8 | //扫码 9 | var dialog = window.YDUI.dialog; 10 | 11 | $(document).on('click','.nav-qs',function(){ 12 | dialog.notify('扫码!', 1000, function(){ 13 | }); 14 | }) 15 | //菜单 16 | $(document).on('click','.nav-me',function(){ 17 | dialog.notify('菜单', 1000, function(){ 18 | }); 19 | }) 20 | // 21 | $(document).on('click','.qq',function(){ 22 | dialog.toast('820568018', 'success', 500); 23 | }) 24 | $(document).on('click','.wb',function(){ 25 | dialog.toast('没有微博', 'success', 500); 26 | }) 27 | $(document).on('click','.wx',function(){ 28 | dialog.toast('pangyongsheng', 'success', 500); 29 | }) 30 | //查看详情 31 | $(document).on('click','.list-item',function(){ 32 | var name=$(this).find('.list-title').html(); 33 | window.location.hash = router.stringify('detail',{animate:'right',title:name}); 34 | }) 35 | 36 | }) 37 | -------------------------------------------------------------------------------- /src/pages/list/list.css: -------------------------------------------------------------------------------- 1 | #list .m-navbar{ 2 | background: linear-gradient(-45deg, #2ed1d1, #23c8c8); 3 | background: -webkit-linear-gradient(-45deg, #2ed1d1, #23c8c8); 4 | background: -o-linear-gradient(-45deg, #2ed1d1, #23c8c8); 5 | background: -moz-linear-gradient(-45deg, #2ed1d1, #23c8c8); 6 | } 7 | #list .m-navbar .iconc{ 8 | font-size: .4rem; 9 | color: #fff; 10 | font-weight: lighter; 11 | } 12 | #list .m-navbar .navbar-title{ 13 | color: #fff; 14 | font-weight: bolder; 15 | } 16 | 17 | #list .tabbar-active{ 18 | color: #23c8c8; 19 | } 20 | #list .m-celltitle{ 21 | margin-top: .1rem; 22 | } 23 | #list .list-price{ 24 | color:#23c8c8; 25 | } 26 | #list .badge-danger{ 27 | background-color: rgb(231, 57, 129); 28 | } 29 | -------------------------------------------------------------------------------- /src/pages/list/list.html: -------------------------------------------------------------------------------- 1 |  146 | -------------------------------------------------------------------------------- /src/pages/list/list.js: -------------------------------------------------------------------------------- 1 | $(function(){ 2 | 3 | }) 4 | -------------------------------------------------------------------------------- /src/pages/personal/personal.css: -------------------------------------------------------------------------------- 1 | #personal .m-navbar{ 2 | background: linear-gradient(-45deg, #2ed1d1, #23c8c8); 3 | background: -webkit-linear-gradient(-45deg, #2ed1d1, #23c8c8); 4 | background: -o-linear-gradient(-45deg, #2ed1d1, #23c8c8); 5 | background: -moz-linear-gradient(-45deg, #2ed1d1, #23c8c8); 6 | } 7 | #personal .m-navbar .iconc{ 8 | font-size: .4rem; 9 | color: #fff; 10 | font-weight: lighter; 11 | } 12 | #personal .m-navbar .navbar-title{ 13 | color: #fff; 14 | font-weight: bolder; 15 | } 16 | 17 | #personal .tabbar-active{ 18 | color: #23c8c8; 19 | } 20 | #personal .m-celltitle{ 21 | /* margin-top: .1rem; */ 22 | } 23 | #personal .cell-select{ 24 | direction: rtl; 25 | } 26 | #personal .cell-icon:before, .cell-icon:after{ 27 | color: #23c8c8; 28 | } 29 | #personal #sub{ 30 | background-color: #23c8c8; 31 | } 32 | #personal .cell-right input[type="radio"]:checked + .cell-checkbox-icon:after, .cell-right input[type="checkbox"]:not(.m-switch):checked + .cell-checkbox-icon:after{ 33 | color: #23c8c8; 34 | } 35 | -------------------------------------------------------------------------------- /src/pages/personal/personal.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 14 | 15 |
16 |
个人信息
17 |
18 | 19 |
昵称
20 |
生生
21 |
22 | 23 |
手机
24 |
182 8820 1862
25 |
26 | 27 |
邮箱
28 |
pang_yongsheng@outlook.com
29 |
30 |
31 |
性别:
32 | 40 |
41 |
42 | 43 |
购物信息
44 | 58 |
收货地址
59 |
60 |
61 |
所在地区:
62 |
63 | 64 |
65 |
66 |
67 |
接受推送信息
68 |
69 | 76 | 83 | 90 |
91 | 92 |
意见反馈
93 |
94 |
95 |
96 | 97 |
98 |
99 |
100 | 101 | 102 |
103 | 104 | 105 | 125 |
126 | -------------------------------------------------------------------------------- /src/pages/personal/personal.js: -------------------------------------------------------------------------------- 1 | $(function(){ 2 | var dialog = window.YDUI.dialog; 3 | $(document).on('click','#sub',function(){ 4 | dialog.notify('提交成功!', 5000, function(){ 5 | }); 6 | }) 7 | }) 8 | -------------------------------------------------------------------------------- /src/router.js: -------------------------------------------------------------------------------- 1 | $(function(){ 2 | 3 | router.start({ 4 | view: '#ui-view', 5 | errorTemplateId: '#error', // 可选 6 | router: { 7 | 'home': { 8 | templateUrl: './pages/home/home.html', 9 | controller: './pages/home/home.js', 10 | styles:'./pages/home/home.css', 11 | animate:'' 12 | }, 13 | 'list': { 14 | templateUrl: './pages/list/list.html', 15 | controller: './pages/list/list.js', 16 | styles:'./pages/list/list.css', 17 | animate:'' 18 | }, 19 | 'personal': { 20 | templateUrl: './pages/personal/personal.html', 21 | controller: './pages/personal/personal.js', 22 | styles:'./pages/personal/personal.css', 23 | animate:'' 24 | }, 25 | 'detail':{ 26 | templateUrl: './pages/detail/detail.html', 27 | controller: './pages/detail/detail.js', 28 | styles:'./pages/detail/detail.css', 29 | animate:'right' 30 | }, 31 | 'defaults': 'home' //默认路由 32 | } 33 | }); 34 | 35 | }); 36 | -------------------------------------------------------------------------------- /webpack.build.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const glob = require('glob'); 3 | const fs = require('fs'); 4 | const webpack = require('webpack'); 5 | const ExtractTextPlugin = require('extract-text-webpack-plugin'); 6 | const HtmlWebpackPlugin = require('html-webpack-plugin'); 7 | const WebpackMd5Hash = require('webpack-md5-hash'); 8 | 9 | const enterFile={}; //存放入口文件 10 | 11 | enterFile.vendors= 12 | ['./src/js/libs/zepto.js', 13 | './src/js/libs/route.js', 14 | './src/router.js', 15 | //'./src/js/libs/ydui.flexible.js', 16 | //'./src/js/libs/ydui.js', 17 | './src/js/public/common.js' 18 | ]; 19 | 20 | //公共js 21 | // const jsPath=glob.sync('./src/js/**/*.js'); 22 | // jsPath.forEach(function (files) { 23 | // enterFile.vendors.push(files); 24 | // }) 25 | 26 | //公共css 27 | const cssPath=glob.sync('./src/css/**/*.css'); 28 | cssPath.forEach(function (files) { 29 | enterFile.vendors.push(files); 30 | }) 31 | //page下资源 32 | const pagePath=glob.sync('./src/pages/*'); 33 | 34 | pagePath.forEach(function (files) { 35 | let arr=[]; 36 | arr.push(path.resolve(__dirname,glob.sync(files+'/**/*.js').toString())); 37 | arr.push(path.resolve(__dirname,glob.sync(files+'/**/*.css').toString())); 38 | enterFile[path.basename(files)]= arr; 39 | //console.log(enterFile); 40 | }) 41 | 42 | const config={ 43 | entry: enterFile, 44 | output: { 45 | path: path.join(__dirname, 'dist'), 46 | //publicPath: "../", 47 | filename: 'pages/[name]/[name].js', 48 | //chunkFilename: 'js/[id].chunk.js' 49 | }, 50 | module: { 51 | loaders: [ //加载器 52 | { 53 | test: /\.css$/, 54 | loader: ExtractTextPlugin.extract("style", "css!autoprefixer") 55 | },{ 56 | test: /\.html$/, 57 | loader: "html" 58 | }, { 59 | test: /\.(woff|woff2|ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, 60 | loader: 'url-loader?name=css/fonts/[name].[ext]' 61 | }, { 62 | test: /\.(png|jpe?g|gif)$/, 63 | loader: 'url-loader?limit=8192&name=imgs/[name].[ext]' 64 | // 内联 base64 URLs, 限定 <=8k 的图片, 其他的用 URL 65 | } 66 | ] 67 | 68 | }, 69 | plugins: [ 70 | new ExtractTextPlugin('pages/[name]/[name].css', {allChunks: true}), 71 | ] 72 | } 73 | 74 | //页面文件打包 75 | var pages = getEntry('src/**/*.html', 'src/'); 76 | 77 | for (var pathname in pages) 78 | { 79 | //路径转化 80 | var temPath = pages[pathname].replace(/\\/, '/'); 81 | var pName = pathname.replace(/\\/g, '/'); 82 | 83 | //同步方式读取文件,清空ide中默认