Authored by Lynnic

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

... ... @@ -16,8 +16,17 @@ var $searchBox = $('.search-box'),
$appFloatLayer = $('#float-layer-app');
var $search = $searchBox.children('input[type="text"]'),
$cancelSearch = $box.children('.no-search'),
$searchIcon = $searchBox.children('.search-icon');
$cancelSearch = $box.children('.no-search'),
$searchIcon = $searchBox.children('.search-icon');
// variables for calculate the app download layer position
var layerInit = false,
windowViewHeight = 0,
layerContentHeight = $appFloatLayer.height(),
layerPaddingTop = parseInt($appFloatLayer.css('padding-top')),
layerPaddingBottom = parseInt($appFloatLayer.css('padding-bottom')),
layerHeight = layerContentHeight + layerPaddingTop + layerPaddingBottom,
layerNewPos;
require('../common');
... ... @@ -45,15 +54,7 @@ $searchBox.children('.clear-text').on('touchstart', function() {
$searchBox.children('.search-icon').on('touchstart', function() {
if (security.hasDangerInput()) {
<<<<<<< HEAD
<<<<<<< HEAD
return false;
=======
return false;
>>>>>>> 3685878e28b5f0a7fbf2ebdb250a96a5ecc47f52
=======
return false;
>>>>>>> 70676b75c6237c141c6f2f4e47518bcd80ea47d8
}
$indexSearch.submit();
});
... ... @@ -80,32 +81,40 @@ $channelLink.on('touchstart', function() {
borderColor: '#fff'
});
});
var updateLayerPosition = (function() {
var init = false;
return function() {
var winHeight = window.innerHeight;
var bodyHeight = $doc.height();
var scrollTopPosition = $win.scrollTop();
var layerHeight = $appFloatLayer.height();
var layerPaddingTop = parseInt($appFloatLayer.css('padding-top'));
var layerPaddingBottom = parseInt($appFloatLayer.css('padding-bottom'));
var newPosition;
if(init){
newPosition = bodyHeight - winHeight- scrollTopPosition;
}else{
init = true;
newPosition = bodyHeight - winHeight - scrollTopPosition + layerHeight + layerPaddingTop + layerPaddingBottom;
}
$appFloatLayer.css({
'position': 'relative',
'bottom': newPosition + 'px'
});
};
})();
$win.scroll(function() {
updateLayerPosition();
});
function updateLayerPosition() {
var winHeight = window.innerHeight,
bodyHeight = $doc.height(),
scrollTopPosition = $win.scrollTop();
if (layerInit) {
//keyboard is shown
if (windowViewHeight - winHeight > 200) {
if (scrollTopPosition + windowViewHeight + layerHeight >= bodyHeight) {
layerNewPos = 0;
} else {
layerNewPos = bodyHeight - windowViewHeight - scrollTopPosition - layerHeight;
}
} else {
layerNewPos = bodyHeight - winHeight - scrollTopPosition;
}
} else {
windowViewHeight = winHeight;
layerNewPos = bodyHeight - winHeight - scrollTopPosition + layerHeight;
layerInit = true;
}
$appFloatLayer.css({
position: 'relative',
bottom: layerNewPos + 'px'
});
}
$(window).scroll(function() {
window.requestAnimationFrame(updateLayerPosition);
});
$doc.on('ready', updateLayerPosition);
... ...
... ... @@ -49,15 +49,7 @@ cHammer.on('tap', function() {
$('#search').on('touchend', function() {
if (security.hasDangerInput()) {
<<<<<<< HEAD
<<<<<<< HEAD
return false;
=======
return false;
>>>>>>> 3685878e28b5f0a7fbf2ebdb250a96a5ecc47f52
=======
return false;
>>>>>>> 70676b75c6237c141c6f2f4e47518bcd80ea47d8
}
$(this).closest('form').submit();
return false;
... ...
... ... @@ -55,11 +55,7 @@ $addressForm.on('submit', function() {
}
if (security.hasDangerInput(false)) {
<<<<<<< HEAD
return false;
=======
return false;
>>>>>>> 3685878e28b5f0a7fbf2ebdb250a96a5ecc47f52
}
// 简单的表单校验
... ... @@ -168,15 +164,12 @@ $addressListPage.find('.address-last').each(function(i, elem) {
});
});
<<<<<<< HEAD
=======
$addressListPage.on('touchstart', 'li', function() {
$(this).addClass('highlight');
}).on('touchend touchcancel', 'li', function() {
$(this).removeClass('highlight');
});
>>>>>>> 3685878e28b5f0a7fbf2ebdb250a96a5ecc47f52
$('input, textarea').on('focus', function() {
$footer.hide();
}).on('blur', function() {
... ...
... ... @@ -14,33 +14,7 @@ var $ = require('jquery'),
* @return {Bool} true/false If the input have danger value
*/
function hasDangerInput(needConvert) {
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> 70676b75c6237c141c6f2f4e47518bcd80ea47d8
var validationPartten = /['"<>&\|]|--/g;
var inputs = $('input[type!=hidden], textarea');
var inputsLength = inputs.length;
// to set if the input value should be coverted, and its default value is true;
var willConvert = needConvert === undefined || typeof needConvert !== 'boolean' ? true : needConvert ;
for (var i = 0; i < inputsLength; i++) {
var val = inputs.eq(i).val();
if (validationPartten.test(val)) {
if (willConvert) {
inputs.eq(i).val(val.replace(validationPartten, ' '));
} else{
var matchChars = val.match(validationPartten).join(' ');
tip.show('不可以输入 ' + matchChars + ' 哦!');
}
return !willConvert && true;
<<<<<<< HEAD
}
}
return false;
=======
var $inputs = $('input[type!=hidden], textarea');
var validationPartten = /['"<>&\|]|--/g,
... ... @@ -66,18 +40,10 @@ function hasDangerInput(needConvert) {
return !willConvert && true;
}
=======
>>>>>>> 70676b75c6237c141c6f2f4e47518bcd80ea47d8
}
}
<<<<<<< HEAD
return false;
>>>>>>> 3685878e28b5f0a7fbf2ebdb250a96a5ecc47f52
=======
return false;
>>>>>>> 70676b75c6237c141c6f2f4e47518bcd80ea47d8
}
... ...