common-modal.js
2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
$(document).on('tap', '.set-target', function() {
var $this = $(this),
$target = $($this.data('target'));
if ($target.length) {
if ('INPUT' == $target[0].tagName) {
$target.val($this.data('value'));
} else {
$target.html($this.data('value'));
}
}
}).on('tap', '.li-radio-check-triger', function() {
var $this = $(this),
$parent = $(this).parent();
$('.address-frist').removeClass('add-address');
$('.address-frist').addClass('no-address');
$('.no-address').removeClass('active');
$this.addClass('active');
$parent.closest('.modal').hide();
$($this.data('target')).val($this.data('id'));
$($parent.data('target')).html($this.html());
if (!$('.modal-checkout:visible').length) {
$('html').css('overflow', '');
}
/*$parent.siblings('.li-radio-check').removeClass('on');
$parent.addClass('on');
$parent.find('input:radio').prop('checked', true);
$parent.closest('.modal').hide();
$($parent.data('target')).html($this.find('section:first').html());
if (!$('.modal-checkout:visible').length) {
$('html').css('overflow', '');
}*/
}).on('tap', '.li-radio', function() {
var $this = $(this);
$this.siblings('.li-radio').removeClass('on');
$this.addClass('on');
$this.find('input:radio').prop('checked', true);
}).on('tap', '.li-checkbox', function() {
var $this = $(this),
status = !$this.hasClass('on');
$this.toggleClass('on', status);
$this.find('input:checkbox').prop('checked', status);
}).on('tap', '.toggle-modal', function() {
var $this = $(this),
target = $this.data('target'),
$target = $(target),
title = $this.data('title'),
url = $this.data('url');
$target.find('.modal-title').html(title);
if (url) {
//layer.load();
$target.find('.modal-body').load(url, function() {
$('html').css('overflow', 'hidden');
$target.show();
//layer.closeAll('loading');
});
} else {
$('html').css('overflow', 'hidden');
$target.show();
}
}).on('tap', '.modal-close', function() {
$(this).closest('.modal-checkout').hide();
if (!$('.modal-checkout:visible').length) {
$('html').css('overflow', '');
}
})