operations.category.Index.js
8.19 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
webpackJsonp([102],{
/***/ 0:
/***/ function(module, exports, __webpack_require__) {
/**
* Created by ty on 2016/5/26.
*/
var $ = __webpack_require__(1),
common = __webpack_require__(2);
__webpack_require__(67);
new common.dropDown({el: "#status"});
new common.dropDown({el: "#platform"});
var Bll = {
initGrid: function () {
common.util.__ajax({
async: false,
url: "/category/getCategoryList",
data: {
platform: common.util.__input("platform"),
status: common.util.__input("status")
}
},function(res) {
$("#basicTable").html(common.util.__template2($("#grid-template").html(), res));
$('#author_id, #article_gender, #status,#tag,#is_hot,#platform').select2();
$('#nestable').nestable();
$('.dd').nestable('collapseAll');
$('div[data-toggle="category"]').on('click', function(){
var sort_id = $(this).parent().data('id');
$('#addModalBox').on('click', function(){
$.get('/cmsproduct/sortattribute/attribute', {sort_id : sort_id}, function(html){
$('.modal-dialog').html(html);
$('#addModal').modal();
$('#attribute_id').select2();
$('#addAttribute').on('click', function(){
var attribute_id = $('#attribute_id').val();
var _text = $('#attribute_id option:selected').text();
var _count = $('#attributeBox tr').length;
var _html = '<tr><td>'+_text+'<input type="hidden" name="data['+_count+'][attribute_id]" value="'+attribute_id+'" /></td><td><input type="text" name="data['+_count+'][order_by]" style="height:28px;width:60px;" value="" /></td></tr>';
$('#attributeBox').append(_html);
});
});
});
});
}, true);
}
}
Bll.initGrid();
$(document).on("click", "#filter-btn", function () {
Bll.initGrid();
});
$(document).on("click", ".updateStatus", function() {
var id = $(this).data("id");
var status = $(this).data("status");
common.util.__ajax({
url: "/category/updateCategoryStatus",
data: {
id:id,
status: status
}
},function() {
Bll.initGrid();
});
});
/***/ },
/***/ 67:
/***/ function(module, exports, __webpack_require__) {
/*!
* Nestable jQuery Plugin - Copyright (c) 2012 David Bushell - http://dbushell.com/
* Dual-licensed under the BSD or MIT licenses
*/
var jQuery = __webpack_require__(1);
;(function($, window, document, undefined)
{
var hasTouch = 'ontouchstart' in window;
/**
* Detect CSS pointer-events property
* events are normally disabled on the dragging element to avoid conflicts
* https://github.com/ausi/Feature-detection-technique-for-pointer-events/blob/master/modernizr-pointerevents.js
*/
var defaults = {
listNodeName : 'ol',
itemNodeName : 'li',
rootClass : 'dd',
listClass : 'dd-list',
itemClass : 'dd-item',
dragClass : 'dd-dragel',
handleClass : 'dd-handle',
collapsedClass : 'dd-collapsed',
placeClass : 'dd-placeholder',
noDragClass : 'dd-nodrag',
emptyClass : 'dd-empty',
expandBtnHTML : '<button data-action="expand" type="button">Expand</button>',
collapseBtnHTML : '<button data-action="collapse" type="button">Collapse</button>',
group : 0,
maxDepth : 5,
threshold : 20
};
function Plugin(element, options)
{
this.w = $(window);
this.el = $(element);
this.options = $.extend({}, defaults, options);
this.init();
}
Plugin.prototype = {
init: function()
{
var list = this;
list.el.data('nestable-group', this.options.group);
list.placeEl = $('<div class="' + list.options.placeClass + '"/>');
$.each(this.el.find(list.options.itemNodeName), function(k, el) {
list.setParent($(el));
});
list.el.on('click', 'button', function(e) {
if (list.dragEl || (!hasTouch && e.button !== 0)) {
return;
}
var target = $(e.currentTarget),
action = target.data('action'),
item = target.parent(list.options.itemNodeName);
if (action === 'collapse') {
list.collapseItem(item);
}
if (action === 'expand') {
list.expandItem(item);
}
});
},
serialize: function()
{
var data,
depth = 0,
list = this;
step = function(level, depth)
{
var array = [ ],
items = level.children(list.options.itemNodeName);
items.each(function()
{
var li = $(this),
item = $.extend({}, li.data()),
sub = li.children(list.options.listNodeName);
if (sub.length) {
item.children = step(sub, depth + 1);
}
array.push(item);
});
return array;
};
data = step(list.el.find(list.options.listNodeName).first(), depth);
return data;
},
serialise: function()
{
return this.serialize();
},
expandItem: function(li)
{
li.removeClass(this.options.collapsedClass);
li.children('[data-action="expand"]').hide();
li.children('[data-action="collapse"]').show();
li.children(this.options.listNodeName).show();
},
collapseItem: function(li)
{
var lists = li.children(this.options.listNodeName);
if (lists.length) {
li.addClass(this.options.collapsedClass);
li.children('[data-action="collapse"]').hide();
li.children('[data-action="expand"]').show();
li.children(this.options.listNodeName).hide();
}
},
expandAll: function()
{
var list = this;
list.el.find(list.options.itemNodeName).each(function() {
list.expandItem($(this));
});
},
collapseAll: function()
{
var list = this;
list.el.find(list.options.itemNodeName).each(function() {
list.collapseItem($(this));
});
},
setParent: function(li)
{
if (li.children(this.options.listNodeName).length) {
li.prepend($(this.options.expandBtnHTML));
li.prepend($(this.options.collapseBtnHTML));
}
li.children('[data-action="expand"]').hide();
},
unsetParent: function(li)
{
li.removeClass(this.options.collapsedClass);
li.children('[data-action]').remove();
li.children(this.options.listNodeName).remove();
},
};
$.fn.nestable = function(params)
{
var lists = this,
retval = this;
lists.each(function()
{
var plugin = $(this).data("nestable");
if (!plugin) {
$(this).data("nestable", new Plugin(this, params));
$(this).data("nestable-id", new Date().getTime());
} else {
if (typeof params === 'string' && typeof plugin[params] === 'function') {
retval = plugin[params]();
}
}
});
return retval || lists;
};
})(jQuery, window, document);
/***/ }
});