order-ensure.js 1.05 KB
/**
 * 订单确认
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2015/11/12
 */

var $ = require('jquery'),
    lazyLoad = require('yoho.lazyload'),
    Hammer = require('yoho.hammer');

var dispatchModeHammer, dispatchTimeHammer;

lazyLoad();

function dispacthTapEvt(e) {
    var $cur = $(e.target).closest('li');

    if ($cur.length === 0 || $cur.hasClass('chosed')) {
        return;
    }

    $cur.siblings('li.chosed').removeClass('chosed');
    $cur.addClass('chosed');
}

dispatchModeHammer = new Hammer(document.getElementsByClassName('dispatch-mode')[0]);
dispatchModeHammer.on('tap', dispacthTapEvt);

dispatchTimeHammer = new Hammer(document.getElementsByClassName('dispatch-time')[0]);
dispatchTimeHammer.on('tap', dispacthTapEvt);

$('.checkbox').on('touchstart', function() {
    var $this = $(this);

    if ($this.hasClass('icon-cb-checked')) {
        $this.removeClass('icon-cb-checked').addClass('icon-checkbox');
        return;
    }
    if ($this.hasClass('icon-checkbox')) {
        $this.removeClass('icon-checkbox').addClass('icon-cb-checked');
    }
});