Authored by xuqi

event rebuild

... ... @@ -5,8 +5,8 @@
* @date: 2015/10/21
*/
var $ = require('jquery');
var Handlebars = require('yoho.handlebars');
var $ = require('jquery'),
Handlebars = require('yoho.handlebars');
var $page = $('.yoho-page');
... ... @@ -37,7 +37,7 @@ function remove() {
$('.chose-panel').remove();
}
$('.yoho-page').delegate('.chose-panel', 'tap', function(e) {
$('.yoho-page').on('touchstart', '.chose-panel', function(e) {
var $cur = $(e.target);
if ($cur.closest('.main').length > 0) {
... ... @@ -46,10 +46,10 @@ $('.yoho-page').delegate('.chose-panel', 'tap', function(e) {
//点击蒙版消失
remove();
}).delegate('#chose-btn-sure', 'tap', function() {
}).on('touchstart', '#chose-btn-sure', function() {
//确定
}).delegate('.block', 'tap', function() {
}).on('touchstart', '.block', function() {
//尺寸颜色点选
var $this = $(this);
... ... @@ -60,7 +60,7 @@ $('.yoho-page').delegate('.chose-panel', 'tap', function(e) {
$this.siblings('.chosed').removeClass('chosed');
$this.addClass('chosed');
}).delegate('.btn-minus', 'tap', function() {
}).on('touchstart', '.btn-minus', function() {
var num = +$num.val();
if (num === 1) {
... ... @@ -68,7 +68,7 @@ $('.yoho-page').delegate('.chose-panel', 'tap', function(e) {
}
$num.val(num - 1);
}).delegate('.btn-plus', 'tap', function() {
}).on('touchstart', '.btn-plus', function() {
var num = +$num.val();
//TODO:库存数验证
... ...
... ... @@ -10,21 +10,14 @@ var $ = require('jquery'),
var chosePanel = require('./chose-panel');
//删除面板显示后任何点击行为都将触发隐藏面板
function docTouchEvt(e) {
var $tar = $(e.target);
if ($tar.closest('.opt-panel').length === 0) {
$('.opt-panel:not(.hide)').addClass('hide');
//
$(document).unbind('tap', docTouchEvt);
}
$(document).off('touchstart', docTouchEvt);
}
// function unbindDocTouchEvt(e) {
// $(document).unbind('tap', docTouchEvt);
// }
ellipsis.init();
lazyLoad($('.lazy'));
... ... @@ -32,7 +25,7 @@ lazyLoad($('.lazy'));
$('.name')[0].mlellipsis(2);
//TIP:事件委托在.cart-goods,商品列表的容器统一需要有.cart-goods
$('.cart-goods').delegate('.checkbox', 'tap', function() {
$('.cart-goods').on('touchstart', '.checkbox', function() {
var $this = $(this);
if ($this.hasClass('icon-cb-checked')) {
... ... @@ -40,7 +33,7 @@ $('.cart-goods').delegate('.checkbox', 'tap', function() {
} else {
$this.removeClass('icon-checkbox').addClass('icon-cb-checked');
}
}).delegate('.icon-edit', 'tap', function() {
}).on('touchstart', '.icon-edit', function() {
var id = $(this).closest('.shopping-cart-good').data('id');
$.ajax({
... ... @@ -55,36 +48,33 @@ $('.cart-goods').delegate('.checkbox', 'tap', function() {
}
}
});
}).delegate('.icon-del', 'tap', function(e) {
}).on('touchstart', '.icon-del', function(e) {
e.stopPropagation();
$(this).closest('.shopping-cart-good').children('.opt-panel').removeClass('hide');
$(document).bind('tap', docTouchEvt);
}).delegate('.opt-panel', 'tap', function() {
$(document).on('touchstart', docTouchEvt);
}).on('touchstart', '.opt-panel', function() {
var $this = $(this),
id = $this.closest('.shopping-cart-good').data('id');
id = $this.closest('.shopping-cart-good').data('id'),
url;
if ($this.closest('.put-in-favorite')) {
//移入收藏夹
$.ajax({
type: 'POST',
url: '/shoppingCart/col',
data: {
id: id
}
});
url = '/shoppingCart/col';
} else {
//删除
url = '/shoppingCart/del';
}
$.ajax({
type: 'POST',
url: '/shoppingCart/del',
url: url,
data: {
id: id
}
});
}
});
... ...