alchemy_cms 6.0.0.pre.rc6 → 6.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +23 -8
- data/.github/workflows/stale.yml +21 -7
- data/.gitignore +0 -1
- data/.rspec +1 -0
- data/CHANGELOG.md +102 -0
- data/Gemfile +20 -5
- data/README.md +4 -3
- data/Rakefile +5 -1
- data/alchemy_cms.gemspec +3 -3
- data/app/assets/javascripts/alchemy/admin.js +0 -1
- data/app/assets/javascripts/alchemy/alchemy.link_dialog.js.coffee +2 -0
- data/app/assets/javascripts/alchemy/page_select.js +13 -8
- data/app/assets/javascripts/alchemy/templates/index.js +1 -0
- data/app/assets/javascripts/alchemy/templates/page.hbs +17 -7
- data/app/assets/javascripts/alchemy/templates/page_folder.hbs +3 -0
- data/app/assets/stylesheets/alchemy/archive.scss +9 -0
- data/app/assets/stylesheets/alchemy/elements.scss +4 -0
- data/app/assets/stylesheets/alchemy/page-select.scss +29 -4
- data/app/assets/stylesheets/alchemy/sitemap.scss +2 -6
- data/app/controllers/alchemy/admin/elements_controller.rb +20 -17
- data/app/controllers/alchemy/admin/pages_controller.rb +24 -19
- data/app/controllers/alchemy/api/base_controller.rb +4 -3
- data/app/controllers/alchemy/api/contents_controller.rb +1 -5
- data/app/controllers/alchemy/api/elements_controller.rb +2 -6
- data/app/controllers/alchemy/api/nodes_controller.rb +1 -0
- data/app/controllers/alchemy/api/pages_controller.rb +16 -10
- data/app/controllers/alchemy/base_controller.rb +7 -0
- data/app/controllers/alchemy/messages_controller.rb +0 -3
- data/app/controllers/alchemy/pages_controller.rb +0 -7
- data/app/helpers/alchemy/elements_helper.rb +17 -12
- data/app/models/alchemy/element.rb +13 -6
- data/app/models/alchemy/ingredient.rb +10 -1
- data/app/models/alchemy/ingredient_validator.rb +1 -1
- data/app/models/alchemy/language.rb +1 -1
- data/app/models/alchemy/page/page_elements.rb +2 -2
- data/app/models/alchemy/page/page_naming.rb +1 -1
- data/app/models/alchemy/page.rb +1 -1
- data/app/models/alchemy/picture/transformations.rb +2 -2
- data/app/models/alchemy/picture.rb +1 -1
- data/app/models/alchemy/picture_variant.rb +3 -1
- data/app/models/alchemy/site.rb +1 -1
- data/app/serializers/alchemy/page_serializer.rb +7 -1
- data/app/serializers/alchemy/page_tree_serializer.rb +3 -3
- data/app/views/alchemy/admin/clipboard/insert.js.erb +13 -0
- data/app/views/alchemy/admin/elements/_add_nested_element_form.html.erb +27 -0
- data/app/views/alchemy/admin/elements/_element.html.erb +1 -23
- data/app/views/alchemy/admin/elements/_form.html.erb +5 -1
- data/app/views/alchemy/admin/pages/_form.html.erb +19 -0
- data/app/views/alchemy/admin/pages/_new_page_form.html.erb +16 -5
- data/app/views/alchemy/admin/pages/_page.html.erb +111 -133
- data/app/views/alchemy/admin/pages/_sitemap.html.erb +2 -8
- data/app/views/alchemy/admin/pages/_toolbar.html.erb +0 -12
- data/app/views/alchemy/admin/pages/index.html.erb +1 -1
- data/app/views/alchemy/admin/pages/update.js.erb +7 -0
- data/app/views/alchemy/admin/partials/_routes.html.erb +12 -1
- data/app/views/alchemy/admin/resources/_form.html.erb +5 -0
- data/app/views/alchemy/essences/_essence_node_editor.html.erb +1 -1
- data/app/views/alchemy/essences/_essence_page_editor.html.erb +1 -1
- data/config/alchemy/config.yml +1 -0
- data/config/initializers/dragonfly.rb +2 -0
- data/config/locales/alchemy.en.yml +0 -3
- data/config/routes.rb +4 -2
- data/lib/alchemy/config.rb +5 -1
- data/lib/alchemy/controller_actions.rb +2 -1
- data/lib/alchemy/dragonfly/processors/thumbnail.rb +27 -0
- data/lib/alchemy/element_definition.rb +2 -3
- data/lib/alchemy/elements_finder.rb +1 -2
- data/lib/alchemy/engine.rb +12 -1
- data/lib/alchemy/essence.rb +1 -27
- data/lib/alchemy/page_layout.rb +5 -1
- data/lib/alchemy/permissions.rb +2 -3
- data/lib/alchemy/resource.rb +16 -1
- data/lib/alchemy/test_support/essence_shared_examples.rb +0 -12
- data/lib/alchemy/test_support/shared_ingredient_examples.rb +4 -2
- data/lib/alchemy/upgrader/tasks/ingredients_migrator.rb +1 -1
- data/lib/alchemy/version.rb +1 -1
- data/lib/alchemy.rb +2 -4
- data/lib/generators/alchemy/base.rb +7 -3
- data/lib/generators/alchemy/install/install_generator.rb +10 -2
- data/package/src/image_loader.js +4 -2
- data/package/src/node_tree.js +13 -6
- data/package/src/page_publication_fields.js +15 -14
- data/package/src/page_sorter.js +62 -0
- data/package/src/picture_editors.js +8 -8
- data/package/src/sitemap.js +51 -36
- data/package/src/utils/__tests__/ajax.spec.js +52 -16
- data/package/src/utils/ajax.js +12 -0
- data/package.json +1 -1
- metadata +43 -42
- data/app/assets/javascripts/alchemy/alchemy.page_sorter.js +0 -24
- data/app/views/alchemy/admin/pages/fold.js.erb +0 -2
- data/app/views/alchemy/admin/pages/sort.html.erb +0 -19
- data/vendor/assets/javascripts/jquery_plugins/jquery.ui.nestedSortable.js +0 -434
@@ -1,434 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* jQuery UI Nested Sortable
|
3
|
-
* v 1.3.5 / 21 jun 2012
|
4
|
-
* http://mjsarfatti.com/code/nestedSortable
|
5
|
-
*
|
6
|
-
* Depends on:
|
7
|
-
* jquery.ui.sortable.js 1.8+
|
8
|
-
*
|
9
|
-
* Copyright (c) 2010-2012 Manuele J Sarfatti
|
10
|
-
* Licensed under the MIT License
|
11
|
-
* http://www.opensource.org/licenses/mit-license.php
|
12
|
-
*/
|
13
|
-
|
14
|
-
(function($) {
|
15
|
-
|
16
|
-
$.widget("mjs.nestedSortable", $.extend({}, $.ui.sortable.prototype, {
|
17
|
-
|
18
|
-
options: {
|
19
|
-
tabSize: 20,
|
20
|
-
disableNesting: 'mjs-nestedSortable-no-nesting',
|
21
|
-
errorClass: 'mjs-nestedSortable-error',
|
22
|
-
doNotClear: false,
|
23
|
-
listType: 'ol',
|
24
|
-
maxLevels: 0,
|
25
|
-
protectRoot: false,
|
26
|
-
rootID: null,
|
27
|
-
rtl: false,
|
28
|
-
isAllowed: function(item, parent) { return true; }
|
29
|
-
},
|
30
|
-
|
31
|
-
_create: function() {
|
32
|
-
this.element.data('sortable', this.element.data('nestedSortable'));
|
33
|
-
|
34
|
-
if (!this.element.is(this.options.listType))
|
35
|
-
throw new Error('nestedSortable: Please check the listType option is set to your actual list type');
|
36
|
-
|
37
|
-
return $.ui.sortable.prototype._create.apply(this, arguments);
|
38
|
-
},
|
39
|
-
|
40
|
-
destroy: function() {
|
41
|
-
this.element
|
42
|
-
.removeData("nestedSortable")
|
43
|
-
.unbind(".nestedSortable");
|
44
|
-
return $.ui.sortable.prototype.destroy.apply(this, arguments);
|
45
|
-
},
|
46
|
-
|
47
|
-
_mouseDrag: function(event) {
|
48
|
-
|
49
|
-
//Compute the helpers position
|
50
|
-
this.position = this._generatePosition(event);
|
51
|
-
this.positionAbs = this._convertPositionTo("absolute");
|
52
|
-
|
53
|
-
if (!this.lastPositionAbs) {
|
54
|
-
this.lastPositionAbs = this.positionAbs;
|
55
|
-
}
|
56
|
-
|
57
|
-
var o = this.options;
|
58
|
-
|
59
|
-
//Do scrolling
|
60
|
-
if(this.options.scroll) {
|
61
|
-
var scrolled = false;
|
62
|
-
if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') {
|
63
|
-
|
64
|
-
if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
|
65
|
-
this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
|
66
|
-
else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity)
|
67
|
-
this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
|
68
|
-
|
69
|
-
if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
|
70
|
-
this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
|
71
|
-
else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity)
|
72
|
-
this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
|
73
|
-
|
74
|
-
} else {
|
75
|
-
|
76
|
-
if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
|
77
|
-
scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
|
78
|
-
else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
|
79
|
-
scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
|
80
|
-
|
81
|
-
if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
|
82
|
-
scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
|
83
|
-
else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
|
84
|
-
scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
|
85
|
-
|
86
|
-
}
|
87
|
-
|
88
|
-
if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
|
89
|
-
$.ui.ddmanager.prepareOffsets(this, event);
|
90
|
-
}
|
91
|
-
|
92
|
-
//Regenerate the absolute position used for position checks
|
93
|
-
this.positionAbs = this._convertPositionTo("absolute");
|
94
|
-
|
95
|
-
// Find the top offset before rearrangement,
|
96
|
-
var previousTopOffset = this.placeholder.offset().top;
|
97
|
-
|
98
|
-
//Set the helper position
|
99
|
-
if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
|
100
|
-
if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
|
101
|
-
|
102
|
-
//Rearrange
|
103
|
-
for (var i = this.items.length - 1; i >= 0; i--) {
|
104
|
-
|
105
|
-
//Cache variables and intersection, continue if no intersection
|
106
|
-
var item = this.items[i], itemElement = item.item[0], intersection = this._intersectsWithPointer(item);
|
107
|
-
if (!intersection) continue;
|
108
|
-
|
109
|
-
if(itemElement != this.currentItem[0] //cannot intersect with itself
|
110
|
-
&& this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before
|
111
|
-
&& !$.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked
|
112
|
-
&& (this.options.type == 'semi-dynamic' ? !$.contains(this.element[0], itemElement) : true)
|
113
|
-
//&& itemElement.parentNode == this.placeholder[0].parentNode // only rearrange items within the same container
|
114
|
-
) {
|
115
|
-
|
116
|
-
$(itemElement).mouseenter();
|
117
|
-
|
118
|
-
this.direction = intersection == 1 ? "down" : "up";
|
119
|
-
|
120
|
-
if (this.options.tolerance == "pointer" || this._intersectsWithSides(item)) {
|
121
|
-
$(itemElement).mouseleave();
|
122
|
-
this._rearrange(event, item);
|
123
|
-
} else {
|
124
|
-
break;
|
125
|
-
}
|
126
|
-
|
127
|
-
// Clear emtpy ul's/ol's
|
128
|
-
this._clearEmpty(itemElement);
|
129
|
-
|
130
|
-
this._trigger("change", event, this._uiHash());
|
131
|
-
break;
|
132
|
-
}
|
133
|
-
}
|
134
|
-
|
135
|
-
var parentItem = (this.placeholder[0].parentNode.parentNode &&
|
136
|
-
$(this.placeholder[0].parentNode.parentNode).closest('.ui-sortable').length)
|
137
|
-
? $(this.placeholder[0].parentNode.parentNode)
|
138
|
-
: null,
|
139
|
-
level = this._getLevel(this.placeholder),
|
140
|
-
childLevels = this._getChildLevels(this.helper);
|
141
|
-
|
142
|
-
// To find the previous sibling in the list, keep backtracking until we hit a valid list item.
|
143
|
-
var previousItem = this.placeholder[0].previousSibling ? $(this.placeholder[0].previousSibling) : null;
|
144
|
-
if (previousItem != null) {
|
145
|
-
while (previousItem[0].nodeName.toLowerCase() != 'li' || previousItem[0] == this.currentItem[0] || previousItem[0] == this.helper[0]) {
|
146
|
-
if (previousItem[0].previousSibling) {
|
147
|
-
previousItem = $(previousItem[0].previousSibling);
|
148
|
-
} else {
|
149
|
-
previousItem = null;
|
150
|
-
break;
|
151
|
-
}
|
152
|
-
}
|
153
|
-
}
|
154
|
-
|
155
|
-
// To find the next sibling in the list, keep stepping forward until we hit a valid list item.
|
156
|
-
var nextItem = this.placeholder[0].nextSibling ? $(this.placeholder[0].nextSibling) : null;
|
157
|
-
if (nextItem != null) {
|
158
|
-
while (nextItem[0].nodeName.toLowerCase() != 'li' || nextItem[0] == this.currentItem[0] || nextItem[0] == this.helper[0]) {
|
159
|
-
if (nextItem[0].nextSibling) {
|
160
|
-
nextItem = $(nextItem[0].nextSibling);
|
161
|
-
} else {
|
162
|
-
nextItem = null;
|
163
|
-
break;
|
164
|
-
}
|
165
|
-
}
|
166
|
-
}
|
167
|
-
|
168
|
-
var newList = document.createElement(o.listType);
|
169
|
-
|
170
|
-
this.beyondMaxLevels = 0;
|
171
|
-
|
172
|
-
// If the item is moved to the left, send it to its parent's level unless there are siblings below it.
|
173
|
-
if (parentItem != null && nextItem == null &&
|
174
|
-
(o.rtl && (this.positionAbs.left + this.helper.outerWidth() > parentItem.offset().left + parentItem.outerWidth()) ||
|
175
|
-
!o.rtl && (this.positionAbs.left < parentItem.offset().left))) {
|
176
|
-
parentItem.after(this.placeholder[0]);
|
177
|
-
this._clearEmpty(parentItem[0]);
|
178
|
-
this._trigger("change", event, this._uiHash());
|
179
|
-
}
|
180
|
-
// If the item is below a sibling and is moved to the right, make it a child of that sibling.
|
181
|
-
else if (previousItem != null &&
|
182
|
-
(o.rtl && (this.positionAbs.left + this.helper.outerWidth() < previousItem.offset().left + previousItem.outerWidth() - o.tabSize) ||
|
183
|
-
!o.rtl && (this.positionAbs.left > previousItem.offset().left + o.tabSize))) {
|
184
|
-
this._isAllowed(previousItem, level, level+childLevels+1);
|
185
|
-
if (!previousItem.children(o.listType).length) {
|
186
|
-
previousItem[0].appendChild(newList);
|
187
|
-
}
|
188
|
-
// If this item is being moved from the top, add it to the top of the list.
|
189
|
-
if (previousTopOffset && (previousTopOffset <= previousItem.offset().top)) {
|
190
|
-
previousItem.children(o.listType).prepend(this.placeholder);
|
191
|
-
}
|
192
|
-
// Otherwise, add it to the bottom of the list.
|
193
|
-
else {
|
194
|
-
previousItem.children(o.listType)[0].appendChild(this.placeholder[0]);
|
195
|
-
}
|
196
|
-
this._trigger("change", event, this._uiHash());
|
197
|
-
}
|
198
|
-
else {
|
199
|
-
this._isAllowed(parentItem, level, level+childLevels);
|
200
|
-
}
|
201
|
-
|
202
|
-
//Post events to containers
|
203
|
-
this._contactContainers(event);
|
204
|
-
|
205
|
-
//Interconnect with droppables
|
206
|
-
if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
|
207
|
-
|
208
|
-
//Call callbacks
|
209
|
-
this._trigger('sort', event, this._uiHash());
|
210
|
-
|
211
|
-
this.lastPositionAbs = this.positionAbs;
|
212
|
-
return false;
|
213
|
-
|
214
|
-
},
|
215
|
-
|
216
|
-
_mouseStop: function(event, noPropagation) {
|
217
|
-
|
218
|
-
// If the item is in a position not allowed, send it back
|
219
|
-
if (this.beyondMaxLevels) {
|
220
|
-
|
221
|
-
this.placeholder.removeClass(this.options.errorClass);
|
222
|
-
|
223
|
-
if (this.domPosition.prev) {
|
224
|
-
$(this.domPosition.prev).after(this.placeholder);
|
225
|
-
} else {
|
226
|
-
$(this.domPosition.parent).prepend(this.placeholder);
|
227
|
-
}
|
228
|
-
|
229
|
-
this._trigger("revert", event, this._uiHash());
|
230
|
-
|
231
|
-
}
|
232
|
-
|
233
|
-
// Clean last empty ul/ol
|
234
|
-
for (var i = this.items.length - 1; i >= 0; i--) {
|
235
|
-
var item = this.items[i].item[0];
|
236
|
-
this._clearEmpty(item);
|
237
|
-
}
|
238
|
-
|
239
|
-
$.ui.sortable.prototype._mouseStop.apply(this, arguments);
|
240
|
-
|
241
|
-
},
|
242
|
-
|
243
|
-
serialize: function(options) {
|
244
|
-
|
245
|
-
var o = $.extend({}, this.options, options),
|
246
|
-
items = this._getItemsAsjQuery(o && o.connected),
|
247
|
-
str = [];
|
248
|
-
|
249
|
-
$(items).each(function() {
|
250
|
-
var res = ($(o.item || this).attr(o.attribute || 'id') || '')
|
251
|
-
.match(o.expression || (/(.+)[-=_](.+)/)),
|
252
|
-
pid = ($(o.item || this).parent(o.listType)
|
253
|
-
.parent(o.items)
|
254
|
-
.attr(o.attribute || 'id') || '')
|
255
|
-
.match(o.expression || (/(.+)[-=_](.+)/));
|
256
|
-
|
257
|
-
if (res) {
|
258
|
-
str.push(((o.key || res[1]) + '[' + (o.key && o.expression ? res[1] : res[2]) + ']')
|
259
|
-
+ '='
|
260
|
-
+ (pid ? (o.key && o.expression ? pid[1] : pid[2]) : o.rootID));
|
261
|
-
}
|
262
|
-
});
|
263
|
-
|
264
|
-
if(!str.length && o.key) {
|
265
|
-
str.push(o.key + '=');
|
266
|
-
}
|
267
|
-
|
268
|
-
return str.join('&');
|
269
|
-
|
270
|
-
},
|
271
|
-
|
272
|
-
toHierarchy: function(options) {
|
273
|
-
|
274
|
-
var o = $.extend({}, this.options, options),
|
275
|
-
sDepth = o.startDepthCount || 0,
|
276
|
-
ret = [];
|
277
|
-
|
278
|
-
$(this.element).children(o.items).each(function () {
|
279
|
-
var level = _recursiveItems(this);
|
280
|
-
ret.push(level);
|
281
|
-
});
|
282
|
-
|
283
|
-
return ret;
|
284
|
-
|
285
|
-
function _recursiveItems(item) {
|
286
|
-
var id = ($(item).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
|
287
|
-
|
288
|
-
var restricted = $(item).data("restricted");
|
289
|
-
var slug = $(item).data("slug");
|
290
|
-
var visible = $(item).data("visible");
|
291
|
-
|
292
|
-
if (id) {
|
293
|
-
var currentItem = {"id" : id[2], "slug" : slug, "restricted" : restricted, "visible" : visible};
|
294
|
-
if ($(item).children(o.listType).children(o.items).length > 0) {
|
295
|
-
currentItem.children = [];
|
296
|
-
$(item).children(o.listType).children(o.items).each(function() {
|
297
|
-
var level = _recursiveItems(this);
|
298
|
-
currentItem.children.push(level);
|
299
|
-
});
|
300
|
-
}
|
301
|
-
return currentItem;
|
302
|
-
}
|
303
|
-
}
|
304
|
-
},
|
305
|
-
|
306
|
-
toArray: function(options) {
|
307
|
-
|
308
|
-
var o = $.extend({}, this.options, options),
|
309
|
-
sDepth = o.startDepthCount || 0,
|
310
|
-
ret = [],
|
311
|
-
left = 2;
|
312
|
-
|
313
|
-
ret.push({
|
314
|
-
"item_id": o.rootID,
|
315
|
-
"parent_id": 'none',
|
316
|
-
"depth": sDepth,
|
317
|
-
"left": '1',
|
318
|
-
"right": ($(o.items, this.element).length + 1) * 2
|
319
|
-
});
|
320
|
-
|
321
|
-
$(this.element).children(o.items).each(function () {
|
322
|
-
left = _recursiveArray(this, sDepth + 1, left);
|
323
|
-
});
|
324
|
-
|
325
|
-
ret = ret.sort(function(a,b){ return (a.left - b.left); });
|
326
|
-
|
327
|
-
return ret;
|
328
|
-
|
329
|
-
function _recursiveArray(item, depth, left) {
|
330
|
-
|
331
|
-
var right = left + 1,
|
332
|
-
id,
|
333
|
-
pid;
|
334
|
-
|
335
|
-
if ($(item).children(o.listType).children(o.items).length > 0) {
|
336
|
-
depth ++;
|
337
|
-
$(item).children(o.listType).children(o.items).each(function () {
|
338
|
-
right = _recursiveArray($(this), depth, right);
|
339
|
-
});
|
340
|
-
depth --;
|
341
|
-
}
|
342
|
-
|
343
|
-
id = ($(item).attr(o.attribute || 'id')).match(o.expression || (/(.+)[-=_](.+)/));
|
344
|
-
|
345
|
-
if (depth === sDepth + 1) {
|
346
|
-
pid = o.rootID;
|
347
|
-
} else {
|
348
|
-
var parentItem = ($(item).parent(o.listType)
|
349
|
-
.parent(o.items)
|
350
|
-
.attr(o.attribute || 'id'))
|
351
|
-
.match(o.expression || (/(.+)[-=_](.+)/));
|
352
|
-
pid = parentItem[2];
|
353
|
-
}
|
354
|
-
|
355
|
-
if (id) {
|
356
|
-
ret.push({"item_id": id[2], "parent_id": pid, "depth": depth, "left": left, "right": right});
|
357
|
-
}
|
358
|
-
|
359
|
-
left = right + 1;
|
360
|
-
return left;
|
361
|
-
}
|
362
|
-
|
363
|
-
},
|
364
|
-
|
365
|
-
_clearEmpty: function(item) {
|
366
|
-
|
367
|
-
var emptyList = $(item).children(this.options.listType);
|
368
|
-
if (emptyList.length && !emptyList.children().length && !this.options.doNotClear) {
|
369
|
-
emptyList.remove();
|
370
|
-
}
|
371
|
-
|
372
|
-
},
|
373
|
-
|
374
|
-
_getLevel: function(item) {
|
375
|
-
|
376
|
-
var level = 1;
|
377
|
-
|
378
|
-
if (this.options.listType) {
|
379
|
-
var list = item.closest(this.options.listType);
|
380
|
-
while (list && list.length > 0 &&
|
381
|
-
!list.is('.ui-sortable')) {
|
382
|
-
level++;
|
383
|
-
list = list.parent().closest(this.options.listType);
|
384
|
-
}
|
385
|
-
}
|
386
|
-
|
387
|
-
return level;
|
388
|
-
},
|
389
|
-
|
390
|
-
_getChildLevels: function(parent, depth) {
|
391
|
-
var self = this,
|
392
|
-
o = this.options,
|
393
|
-
result = 0;
|
394
|
-
depth = depth || 0;
|
395
|
-
|
396
|
-
$(parent).children(o.listType).children(o.items).each(function (index, child) {
|
397
|
-
result = Math.max(self._getChildLevels(child, depth + 1), result);
|
398
|
-
});
|
399
|
-
|
400
|
-
return depth ? result + 1 : result;
|
401
|
-
},
|
402
|
-
|
403
|
-
_isAllowed: function(parentItem, level, levels) {
|
404
|
-
var o = this.options,
|
405
|
-
isRoot = $(this.domPosition.parent).hasClass('ui-sortable') ? true : false,
|
406
|
-
maxLevels = this.placeholder.closest('.ui-sortable').nestedSortable('option', 'maxLevels'); // this takes into account the maxLevels set to the recipient list
|
407
|
-
|
408
|
-
// Is the root protected?
|
409
|
-
// Are we trying to nest under a no-nest?
|
410
|
-
// Are we nesting too deep?
|
411
|
-
if (!o.isAllowed(this.currentItem, parentItem) ||
|
412
|
-
parentItem && parentItem.hasClass(o.disableNesting) ||
|
413
|
-
o.protectRoot && (parentItem == null && !isRoot || isRoot && level > 1)) {
|
414
|
-
this.placeholder.addClass(o.errorClass);
|
415
|
-
if (maxLevels < levels && maxLevels != 0) {
|
416
|
-
this.beyondMaxLevels = levels - maxLevels;
|
417
|
-
} else {
|
418
|
-
this.beyondMaxLevels = 1;
|
419
|
-
}
|
420
|
-
} else {
|
421
|
-
if (maxLevels < levels && maxLevels != 0) {
|
422
|
-
this.placeholder.addClass(o.errorClass);
|
423
|
-
this.beyondMaxLevels = levels - maxLevels;
|
424
|
-
} else {
|
425
|
-
this.placeholder.removeClass(o.errorClass);
|
426
|
-
this.beyondMaxLevels = 0;
|
427
|
-
}
|
428
|
-
}
|
429
|
-
}
|
430
|
-
|
431
|
-
}));
|
432
|
-
|
433
|
-
$.mjs.nestedSortable.prototype.options = $.extend({}, $.ui.sortable.prototype.options, $.mjs.nestedSortable.prototype.options);
|
434
|
-
})(jQuery);
|