script.js
3.64 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
$(function() {
$(document)
.on('click', '.export-link', function(e) {
e.preventDefault();
var url = $(this)
.data('url');
var file = $(this)
.data('file');
var interval = showProgress();
$.get(url, function(data) {
clearInterval(interval);
var progressBar = $('#export-progress');
var progressValueBar = progressBar.find('.progress-bar')
.first();
progressValueBar.width('100%');
progressValueBar.attr('aria-valuenow', 100);
progressValueBar.removeClass('active');
if (data.success) {
var exportLink = $('#export-link');
exportLink.removeClass('hidden');
exportLink.find('a')
.attr('href', file);
} else {
progressValueBar.addClass('progress-bar-danger');
}
})
.fail(function(xhr, textStatus) {
clearInterval(interval);
console.log(textStatus);
var progressBar = $('#export-progress');
var progressValueBar = progressBar.find('.progress-bar')
.first();
progressValueBar.width('100%');
progressValueBar.attr('aria-valuenow', 100);
progressValueBar.removeClass('active');
progressValueBar.addClass('progress-bar-danger');
});
});
});
function showProgress() {
var progressBar = $('#export-progress');
var progressValueBar = progressBar.find('.progress-bar')
.first();
progressValueBar.removeClass('progress-bar-danger');
progressValueBar.addClass('active');
progressBar.removeClass('hidden');
var progress = 0;
progressValueBar.width(0 + '%');
progressValueBar.attr('aria-valuenow', progress);
var exportLink = $('#export-link');
exportLink.addClass('hidden');
var interval = setInterval(function() {
progress = progressValueBar.attr('aria-valuenow');
if (progress < 100) {
progress = Number(progress) + 5;
progressValueBar.width(progress + '%');
progressValueBar.attr('aria-valuenow', progress);
}
if (progress > 90) {
clearInterval(interval);
}
}, 1000);
return interval;
}
$(document)
.on(
'click', '#add-category-btn', function() {
var button = $(this);
$.ajax(
{
type: "POST",
url: "/admin/product-option-group-exclusion/get-row",
data: {
id: button.attr('data-id'),
title: button.attr('data-title')
},
success: function(data) {
$('.jambo_table tbody')
.append(data);
$('input.flat')
.iCheck(
{
checkboxClass: 'icheckbox_flat-green',
radioClass: 'iradio_flat-green'
}
);
}
}
);
}
);
$(document)
.on(
'click', '.jambo_table .delete-row', function() {
$(this)
.parent()
.parent()
.remove();
}
);