Showing
4 changed files
with
27 additions
and
14 deletions
@@ -7,6 +7,7 @@ | @@ -7,6 +7,7 @@ | ||
7 | var $ = require('jquery'), | 7 | var $ = require('jquery'), |
8 | Hammer = require('yoho.hammer'), | 8 | Hammer = require('yoho.hammer'), |
9 | tip = require('../plugin/tip'), | 9 | tip = require('../plugin/tip'), |
10 | + loading = require('../plugin/loading'), | ||
10 | lazyLoad = require('yoho.lazyload'); | 11 | lazyLoad = require('yoho.lazyload'); |
11 | 12 | ||
12 | var navHammer, | 13 | var navHammer, |
@@ -65,7 +66,7 @@ if (lifestyleType) { | @@ -65,7 +66,7 @@ if (lifestyleType) { | ||
65 | }); | 66 | }); |
66 | } | 67 | } |
67 | 68 | ||
68 | -//loading.init($('.maybe-like')); | 69 | +loading.init($('.maybe-like')); |
69 | 70 | ||
70 | function search() { | 71 | function search() { |
71 | if (searching) { | 72 | if (searching) { |
@@ -73,7 +74,7 @@ function search() { | @@ -73,7 +74,7 @@ function search() { | ||
73 | } | 74 | } |
74 | searching = true; | 75 | searching = true; |
75 | 76 | ||
76 | - //loading.showLoadingMask(); | 77 | + loading.showLoadingMask(); |
77 | 78 | ||
78 | //num = $goodList.find('.good-info').length; | 79 | //num = $goodList.find('.good-info').length; |
79 | $.ajax({ | 80 | $.ajax({ |
@@ -123,15 +124,13 @@ function search() { | @@ -123,15 +124,13 @@ function search() { | ||
123 | } | 124 | } |
124 | 125 | ||
125 | searching = false; | 126 | searching = false; |
126 | - | ||
127 | - //loading.hideLoadingMask(); | 127 | + loading.hideLoadingMask(); |
128 | page++; | 128 | page++; |
129 | }, | 129 | }, |
130 | error: function() { | 130 | error: function() { |
131 | tip.show('网络断开连接了~'); | 131 | tip.show('网络断开连接了~'); |
132 | searching = false; | 132 | searching = false; |
133 | - | ||
134 | - //loading.hideLoadingMask(); | 133 | + loading.hideLoadingMask(); |
135 | } | 134 | } |
136 | }); | 135 | }); |
137 | } | 136 | } |
@@ -8,19 +8,30 @@ var $ = require('jquery'); | @@ -8,19 +8,30 @@ var $ = require('jquery'); | ||
8 | 8 | ||
9 | var $page = $('.yoho-page'); | 9 | var $page = $('.yoho-page'); |
10 | 10 | ||
11 | -var $loading; | 11 | +var $loading, |
12 | + hasInit = false; | ||
12 | 13 | ||
13 | -//初始化 | ||
14 | -(function() { | 14 | +/** modify by liangzhifeng at 2015.11.2 */ |
15 | + | ||
16 | +// 初始化 | ||
17 | +function init($container) { | ||
18 | + hasInit = true; | ||
19 | + if ($container === undefined) { | ||
20 | + $container = $page; | ||
21 | + } | ||
15 | var html = '<div class="loading-mask hide"><div class="loading"></div></div>'; | 22 | var html = '<div class="loading-mask hide"><div class="loading"></div></div>'; |
16 | 23 | ||
17 | - $page.append(html); | 24 | + $container.append(html); |
18 | 25 | ||
19 | - $loading = $page.children('.loading-mask'); | ||
20 | -}()); | 26 | + $loading = $container.children('.loading-mask'); |
27 | +} | ||
21 | 28 | ||
22 | //显示loading | 29 | //显示loading |
23 | function showLoadingMask() { | 30 | function showLoadingMask() { |
31 | + if (!hasInit) { | ||
32 | + init(); | ||
33 | + hasInit = true; | ||
34 | + } | ||
24 | $loading.removeClass('hide'); | 35 | $loading.removeClass('hide'); |
25 | } | 36 | } |
26 | 37 | ||
@@ -29,5 +40,6 @@ function hideLoadingMask() { | @@ -29,5 +40,6 @@ function hideLoadingMask() { | ||
29 | $loading.addClass('hide'); | 40 | $loading.addClass('hide'); |
30 | } | 41 | } |
31 | 42 | ||
43 | +exports.init = init; | ||
32 | exports.showLoadingMask = showLoadingMask; | 44 | exports.showLoadingMask = showLoadingMask; |
33 | exports.hideLoadingMask = hideLoadingMask; | 45 | exports.hideLoadingMask = hideLoadingMask; |
1 | .loading-mask { | 1 | .loading-mask { |
2 | - position: fixed; | 2 | + position: absolute; |
3 | background: rgba(0,0,0,.1); | 3 | background: rgba(0,0,0,.1); |
4 | top: 0; | 4 | top: 0; |
5 | bottom: 0; | 5 | bottom: 0; |
@@ -17,4 +17,5 @@ | @@ -17,4 +17,5 @@ | ||
17 | margin-left: -50rem / $pxConvertRem; | 17 | margin-left: -50rem / $pxConvertRem; |
18 | margin-top: -20rem / $pxConvertRem; | 18 | margin-top: -20rem / $pxConvertRem; |
19 | } | 19 | } |
20 | -} | ||
20 | +} | ||
21 | + |
@@ -4,6 +4,7 @@ | @@ -4,6 +4,7 @@ | ||
4 | border-top: 1px solid #ccc; | 4 | border-top: 1px solid #ccc; |
5 | // border-bottom: 1px solid #ccc; | 5 | // border-bottom: 1px solid #ccc; |
6 | margin-top: 30rem / $pxConvertRem; | 6 | margin-top: 30rem / $pxConvertRem; |
7 | + position: relative; | ||
7 | .title { | 8 | .title { |
8 | height: 104rem / $pxConvertRem; | 9 | height: 104rem / $pxConvertRem; |
9 | font-size: 38rem / $pxConvertRem; | 10 | font-size: 38rem / $pxConvertRem; |
-
Please register or login to post a comment