Showing
1 changed file
with
19 additions
and
27 deletions
@@ -71,26 +71,38 @@ function setEditModeWithSknId(sknId, isThisGoodSelected) { | @@ -71,26 +71,38 @@ function setEditModeWithSknId(sknId, isThisGoodSelected) { | ||
71 | isSelected = isThisGoodSelected; | 71 | isSelected = isThisGoodSelected; |
72 | } | 72 | } |
73 | 73 | ||
74 | -function preventDefault(e) { | ||
75 | - console.log(e); | ||
76 | - if (e.target.localName === 'ul') return; | ||
77 | - e = e || window.event; | ||
78 | - if (e.preventDefault) | 74 | +function preventDefault(event) { |
75 | + var e = event || window.event; | ||
76 | + | ||
77 | + var $target = $(e.target); | ||
78 | + | ||
79 | + if (($target.hasClass('.chose-items') || $target.closest('chose-items')) && | ||
80 | + ($('.color-list').find('ul').not('.hide').find('li').length > 4 || | ||
81 | + $('.size-list').find('ul').not('.hide').find('li').length > 4)) { | ||
82 | + e.stopPropagation(); | ||
83 | + return false; | ||
84 | + } | ||
85 | + | ||
86 | + if (e.preventDefault) { | ||
79 | e.preventDefault(); | 87 | e.preventDefault(); |
88 | + } | ||
80 | e.returnValue = false; | 89 | e.returnValue = false; |
81 | } | 90 | } |
82 | 91 | ||
83 | function disableScroll(e) { | 92 | function disableScroll(e) { |
84 | - if (window.addEventListener) // older FF | 93 | + if (window.addEventListener) {// older FF |
85 | window.addEventListener('DOMMouseScroll', preventDefault, false); | 94 | window.addEventListener('DOMMouseScroll', preventDefault, false); |
95 | + } | ||
96 | + | ||
86 | window.onwheel = preventDefault; // modern standard | 97 | window.onwheel = preventDefault; // modern standard |
87 | window.onmousewheel = document.onmousewheel = preventDefault; // older browsers, IE | 98 | window.onmousewheel = document.onmousewheel = preventDefault; // older browsers, IE |
88 | window.ontouchmove = preventDefault; // mobile | 99 | window.ontouchmove = preventDefault; // mobile |
89 | } | 100 | } |
90 | 101 | ||
91 | function enableScroll() { | 102 | function enableScroll() { |
92 | - if (window.removeEventListener) | 103 | + if (window.removeEventListener) { |
93 | window.removeEventListener('DOMMouseScroll', preventDefault, false); | 104 | window.removeEventListener('DOMMouseScroll', preventDefault, false); |
105 | + } | ||
94 | window.onmousewheel = document.onmousewheel = null; | 106 | window.onmousewheel = document.onmousewheel = null; |
95 | window.onwheel = null; | 107 | window.onwheel = null; |
96 | window.ontouchmove = null; | 108 | window.ontouchmove = null; |
@@ -138,18 +150,6 @@ function disableNumEdit() { | @@ -138,18 +150,6 @@ function disableNumEdit() { | ||
138 | 150 | ||
139 | 151 | ||
140 | function show(html, cb) { | 152 | function show(html, cb) { |
141 | - var scrollPosition = [ | ||
142 | - document.documentElement.scrollLeft || document.body.scrollLeft, | ||
143 | - document.documentElement.scrollTop || document.body.scrollTop | ||
144 | - ], | ||
145 | - $html = $('html, body'); // it would make more sense to apply this to body, but IE7 won't have that | ||
146 | - | ||
147 | - $html.data('scroll-position', scrollPosition); | ||
148 | - $html.data('previous-overflow', $html.css('overflow')); | ||
149 | - $html.css('overflow', 'hidden'); | ||
150 | - $html.css('height', '100%'); | ||
151 | - window.scrollTo(scrollPosition[0], scrollPosition[1]); | ||
152 | - | ||
153 | if (html) { | 153 | if (html) { |
154 | $chosePanel.html(html); | 154 | $chosePanel.html(html); |
155 | if ($('#promotionId').val() !== '') { | 155 | if ($('#promotionId').val() !== '') { |
@@ -166,15 +166,7 @@ function show(html, cb) { | @@ -166,15 +166,7 @@ function show(html, cb) { | ||
166 | 166 | ||
167 | //隐藏当前Panel | 167 | //隐藏当前Panel |
168 | function hide() { | 168 | function hide() { |
169 | - var $html = $('html, body'), | ||
170 | - scrollPosition = $html.data('scroll-position'); | ||
171 | - | ||
172 | - // un-lock scroll position | ||
173 | - $html.css('overflow', $html.data('previous-overflow')); | ||
174 | - $html.css('height', 'auto'); | ||
175 | - window.scrollTo(scrollPosition[0], scrollPosition[1]); | ||
176 | $('.chose-panel').hide(); | 169 | $('.chose-panel').hide(); |
177 | - | ||
178 | enableScroll(); | 170 | enableScroll(); |
179 | } | 171 | } |
180 | 172 |
-
Please register or login to post a comment