-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultibox.js
More file actions
67 lines (57 loc) · 1.82 KB
/
multibox.js
File metadata and controls
67 lines (57 loc) · 1.82 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
var Multibox = /** @class */ (function () {
function Multibox(instance, boxData, rowData) {
this.instance = instance;
this.boxData = boxData;
this.rowData = rowData;
}
Multibox.prototype.getBox = function () {
var box_id = $(this.instance).attr('data-index');
$(this.instance).attr('data-index', parseInt(box_id) + 1);
var data = {
box: box_id,
row: '0',
instance: this.instance
};
var b = $(this.instance).find('.box');
this.boxData(data, function (html) {
b.last().after(html.view).next().attr('box-index', data.box).attr('row-index', data.row);
var box_count = parseInt(b.length) - 1;
if (box_count != 0) {
b.last().find('.add-box').hide();
b.last().find('.remove-box').show();
}
});
};
Multibox.prototype.getRow = function (el, target) {
//var target = $(el).parent().parent();
var row_id = $(target).attr('row-index');
$(target).attr('row-index', parseInt(row_id) + 1);
var data = {
box: $(target).attr('box-index'),
row: parseInt(row_id) + 1,
instance: this.instance
};
this.rowData(data, function (html) {
$(target).find('.remove-row').show();
$(target).find('.data-row').last().after(html.view);
$(el).remove();
});
};
Multibox.prototype.deleteBox = function (el, id, cb) {
if (id && cb) {
cb(el, id);
}
else {
$(el).remove();
}
};
Multibox.prototype.deleteRow = function (el, id, cb) {
if (id && cb) {
cb(el, id);
}
else {
$(el).remove();
}
};
return Multibox;
}());