Authored by Lynnic

Merge branch 'develop' of git.dev.yoho.cn:web/yohobuy into develop

@@ -19,6 +19,15 @@ var $search = $searchBox.children('input[type="text"]'), @@ -19,6 +19,15 @@ var $search = $searchBox.children('input[type="text"]'),
19 $cancelSearch = $box.children('.no-search'), 19 $cancelSearch = $box.children('.no-search'),
20 $searchIcon = $searchBox.children('.search-icon'); 20 $searchIcon = $searchBox.children('.search-icon');
21 21
  22 +// variables for calculate the app download layer position
  23 +var layerInit = false,
  24 + windowViewHeight = 0,
  25 + layerContentHeight = $appFloatLayer.height(),
  26 + layerPaddingTop = parseInt($appFloatLayer.css('padding-top')),
  27 + layerPaddingBottom = parseInt($appFloatLayer.css('padding-bottom')),
  28 + layerHeight = layerContentHeight + layerPaddingTop + layerPaddingBottom,
  29 + layerNewPos;
  30 +
22 require('../common'); 31 require('../common');
23 32
24 $search.on('focus', function() { 33 $search.on('focus', function() {
@@ -45,15 +54,7 @@ $searchBox.children('.clear-text').on('touchstart', function() { @@ -45,15 +54,7 @@ $searchBox.children('.clear-text').on('touchstart', function() {
45 54
46 $searchBox.children('.search-icon').on('touchstart', function() { 55 $searchBox.children('.search-icon').on('touchstart', function() {
47 if (security.hasDangerInput()) { 56 if (security.hasDangerInput()) {
48 -<<<<<<< HEAD  
49 -<<<<<<< HEAD  
50 - return false;  
51 -=======  
52 return false; 57 return false;
53 ->>>>>>> 3685878e28b5f0a7fbf2ebdb250a96a5ecc47f52  
54 -=======  
55 - return false;  
56 ->>>>>>> 70676b75c6237c141c6f2f4e47518bcd80ea47d8  
57 } 58 }
58 $indexSearch.submit(); 59 $indexSearch.submit();
59 }); 60 });
@@ -80,32 +81,40 @@ $channelLink.on('touchstart', function() { @@ -80,32 +81,40 @@ $channelLink.on('touchstart', function() {
80 borderColor: '#fff' 81 borderColor: '#fff'
81 }); 82 });
82 }); 83 });
83 -var updateLayerPosition = (function() {  
84 - var init = false;  
85 - return function() {  
86 - var winHeight = window.innerHeight;  
87 - var bodyHeight = $doc.height();  
88 - var scrollTopPosition = $win.scrollTop();  
89 - var layerHeight = $appFloatLayer.height();  
90 - var layerPaddingTop = parseInt($appFloatLayer.css('padding-top'));  
91 - var layerPaddingBottom = parseInt($appFloatLayer.css('padding-bottom'));  
92 - var newPosition;  
93 - if(init){  
94 - newPosition = bodyHeight - winHeight- scrollTopPosition;  
95 - }else{  
96 - init = true;  
97 - newPosition = bodyHeight - winHeight - scrollTopPosition + layerHeight + layerPaddingTop + layerPaddingBottom; 84 +
  85 +
  86 +function updateLayerPosition() {
  87 + var winHeight = window.innerHeight,
  88 + bodyHeight = $doc.height(),
  89 + scrollTopPosition = $win.scrollTop();
  90 +
  91 + if (layerInit) {
  92 +
  93 + //keyboard is shown
  94 + if (windowViewHeight - winHeight > 200) {
  95 + if (scrollTopPosition + windowViewHeight + layerHeight >= bodyHeight) {
  96 + layerNewPos = 0;
  97 + } else {
  98 + layerNewPos = bodyHeight - windowViewHeight - scrollTopPosition - layerHeight;
98 } 99 }
  100 + } else {
  101 + layerNewPos = bodyHeight - winHeight - scrollTopPosition;
  102 + }
  103 +
  104 + } else {
  105 + windowViewHeight = winHeight;
  106 + layerNewPos = bodyHeight - winHeight - scrollTopPosition + layerHeight;
  107 + layerInit = true;
  108 + }
  109 +
99 $appFloatLayer.css({ 110 $appFloatLayer.css({
100 - 'position': 'relative',  
101 - 'bottom': newPosition + 'px' 111 + position: 'relative',
  112 + bottom: layerNewPos + 'px'
102 }); 113 });
103 - };  
104 -})(); 114 +}
105 115
106 -$win.scroll(function() {  
107 - updateLayerPosition(); 116 +$(window).scroll(function() {
  117 + window.requestAnimationFrame(updateLayerPosition);
108 }); 118 });
109 119
110 -  
111 $doc.on('ready', updateLayerPosition); 120 $doc.on('ready', updateLayerPosition);
@@ -49,15 +49,7 @@ cHammer.on('tap', function() { @@ -49,15 +49,7 @@ cHammer.on('tap', function() {
49 49
50 $('#search').on('touchend', function() { 50 $('#search').on('touchend', function() {
51 if (security.hasDangerInput()) { 51 if (security.hasDangerInput()) {
52 -<<<<<<< HEAD  
53 -<<<<<<< HEAD  
54 return false; 52 return false;
55 -=======  
56 - return false;  
57 ->>>>>>> 3685878e28b5f0a7fbf2ebdb250a96a5ecc47f52  
58 -=======  
59 - return false;  
60 ->>>>>>> 70676b75c6237c141c6f2f4e47518bcd80ea47d8  
61 } 53 }
62 $(this).closest('form').submit(); 54 $(this).closest('form').submit();
63 return false; 55 return false;
@@ -55,11 +55,7 @@ $addressForm.on('submit', function() { @@ -55,11 +55,7 @@ $addressForm.on('submit', function() {
55 } 55 }
56 56
57 if (security.hasDangerInput(false)) { 57 if (security.hasDangerInput(false)) {
58 -<<<<<<< HEAD  
59 return false; 58 return false;
60 -=======  
61 - return false;  
62 ->>>>>>> 3685878e28b5f0a7fbf2ebdb250a96a5ecc47f52  
63 } 59 }
64 60
65 // 简单的表单校验 61 // 简单的表单校验
@@ -168,15 +164,12 @@ $addressListPage.find('.address-last').each(function(i, elem) { @@ -168,15 +164,12 @@ $addressListPage.find('.address-last').each(function(i, elem) {
168 }); 164 });
169 }); 165 });
170 166
171 -<<<<<<< HEAD  
172 -=======  
173 $addressListPage.on('touchstart', 'li', function() { 167 $addressListPage.on('touchstart', 'li', function() {
174 $(this).addClass('highlight'); 168 $(this).addClass('highlight');
175 }).on('touchend touchcancel', 'li', function() { 169 }).on('touchend touchcancel', 'li', function() {
176 $(this).removeClass('highlight'); 170 $(this).removeClass('highlight');
177 }); 171 });
178 172
179 ->>>>>>> 3685878e28b5f0a7fbf2ebdb250a96a5ecc47f52  
180 $('input, textarea').on('focus', function() { 173 $('input, textarea').on('focus', function() {
181 $footer.hide(); 174 $footer.hide();
182 }).on('blur', function() { 175 }).on('blur', function() {
@@ -14,33 +14,7 @@ var $ = require('jquery'), @@ -14,33 +14,7 @@ var $ = require('jquery'),
14 * @return {Bool} true/false If the input have danger value 14 * @return {Bool} true/false If the input have danger value
15 */ 15 */
16 function hasDangerInput(needConvert) { 16 function hasDangerInput(needConvert) {
17 -<<<<<<< HEAD  
18 -<<<<<<< HEAD  
19 -=======  
20 ->>>>>>> 70676b75c6237c141c6f2f4e47518bcd80ea47d8  
21 - var validationPartten = /['"<>&\|]|--/g;  
22 - var inputs = $('input[type!=hidden], textarea');  
23 - var inputsLength = inputs.length;  
24 17
25 - // to set if the input value should be coverted, and its default value is true;  
26 - var willConvert = needConvert === undefined || typeof needConvert !== 'boolean' ? true : needConvert ;  
27 -  
28 - for (var i = 0; i < inputsLength; i++) {  
29 - var val = inputs.eq(i).val();  
30 - if (validationPartten.test(val)) {  
31 - if (willConvert) {  
32 - inputs.eq(i).val(val.replace(validationPartten, ' '));  
33 - } else{  
34 - var matchChars = val.match(validationPartten).join(' ');  
35 - tip.show('不可以输入 ' + matchChars + ' 哦!');  
36 - }  
37 - return !willConvert && true;  
38 -<<<<<<< HEAD  
39 - }  
40 - }  
41 -  
42 - return false;  
43 -=======  
44 var $inputs = $('input[type!=hidden], textarea'); 18 var $inputs = $('input[type!=hidden], textarea');
45 19
46 var validationPartten = /['"<>&\|]|--/g, 20 var validationPartten = /['"<>&\|]|--/g,
@@ -66,18 +40,10 @@ function hasDangerInput(needConvert) { @@ -66,18 +40,10 @@ function hasDangerInput(needConvert) {
66 40
67 return !willConvert && true; 41 return !willConvert && true;
68 } 42 }
69 -=======  
70 ->>>>>>> 70676b75c6237c141c6f2f4e47518bcd80ea47d8  
71 - }  
72 } 43 }
73 44
74 -<<<<<<< HEAD  
75 45
76 return false; 46 return false;
77 ->>>>>>> 3685878e28b5f0a7fbf2ebdb250a96a5ecc47f52  
78 -=======  
79 - return false;  
80 ->>>>>>> 70676b75c6237c141c6f2f4e47518bcd80ea47d8  
81 } 47 }
82 48
83 49