rails_admin_nested_set 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -0
- data/Gemfile +0 -0
- data/README.md +0 -0
- data/app/assets/javascripts/rails_admin/jquery.mjs.nestedSortable.js +541 -357
- data/app/assets/javascripts/rails_admin/rails_admin_nested_set.js.coffee +5 -6
- data/app/assets/stylesheets/rails_admin/rails_admin_nested_set.css.scss +4 -135
- data/app/views/rails_admin/main/nested_set.html.haml +0 -0
- data/config/locales/en.nested_set.yml +0 -0
- data/config/locales/es.nested_set.yml +0 -0
- data/config/locales/ru.nested_set.yml +0 -0
- data/lib/rails_admin_nested_set.rb +0 -0
- data/lib/rails_admin_nested_set/action.rb +0 -0
- data/lib/rails_admin_nested_set/configuration.rb +1 -1
- data/lib/rails_admin_nested_set/engine.rb +0 -0
- data/lib/rails_admin_nested_set/helper.rb +1 -2
- data/lib/rails_admin_nested_set/model.rb +0 -0
- data/lib/rails_admin_nested_set/version.rb +1 -1
- data/rails_admin_nested_set.gemspec +0 -4
- metadata +4 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07d822653283fdabcf97010737971642d53ce49c
|
4
|
+
data.tar.gz: 500b6d9fbbdc6ab8aa2e42dd9d13dcb834ebf242
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24579546b8cfcba8824ce14337c42258c70c7698b8dd6bc333fed11463c8a3ff46720b4dc5ce48badcc6dfeb1d667e3db52e00922d39d8042e7ea3256776d77f
|
7
|
+
data.tar.gz: 8dc13f099cfc1425ec7dd6fbe89fdc294ea020098b1dbdf64e571435a45b3b0b9a4bd4b3450e98fcf2be2972fee62c2a9b8e338b4ecfe3243cd96d6aa999e9f2
|
data/.gitignore
CHANGED
File without changes
|
data/Gemfile
CHANGED
File without changes
|
data/README.md
CHANGED
File without changes
|
@@ -1,161 +1,276 @@
|
|
1
1
|
/*
|
2
2
|
* jQuery UI Nested Sortable
|
3
|
-
* v
|
4
|
-
* http://mjsarfatti.com/
|
3
|
+
* v 2.0 / 29 oct 2012
|
4
|
+
* http://mjsarfatti.com/sandbox/nestedSortable
|
5
5
|
*
|
6
6
|
* Depends on:
|
7
|
-
*
|
7
|
+
* jquery.ui.sortable.js 1.10+
|
8
8
|
*
|
9
|
-
* Copyright (c) 2010-
|
9
|
+
* Copyright (c) 2010-2013 Manuele J Sarfatti
|
10
10
|
* Licensed under the MIT License
|
11
11
|
* http://www.opensource.org/licenses/mit-license.php
|
12
12
|
*/
|
13
13
|
|
14
14
|
(function($) {
|
15
15
|
|
16
|
-
|
16
|
+
function isOverAxis( x, reference, size ) {
|
17
|
+
return ( x > reference ) && ( x < ( reference + size ) );
|
18
|
+
}
|
19
|
+
|
20
|
+
$.widget("mjs.nestedSortable", $.extend({}, $.ui.sortable.prototype, {
|
21
|
+
|
22
|
+
options: {
|
23
|
+
doNotClear: false,
|
24
|
+
expandOnHover: 700,
|
25
|
+
isAllowed: function(placeholder, placeholderParent, originalItem) { return true; },
|
26
|
+
isTree: false,
|
27
|
+
listType: 'ol',
|
28
|
+
maxLevels: 0,
|
29
|
+
protectRoot: false,
|
30
|
+
rootID: null,
|
31
|
+
rtl: false,
|
32
|
+
startCollapsed: false,
|
33
|
+
tabSize: 20,
|
34
|
+
|
35
|
+
branchClass: 'mjs-nestedSortable-branch',
|
36
|
+
collapsedClass: 'mjs-nestedSortable-collapsed',
|
37
|
+
disableNestingClass: 'mjs-nestedSortable-no-nesting',
|
38
|
+
errorClass: 'mjs-nestedSortable-error',
|
39
|
+
expandedClass: 'mjs-nestedSortable-expanded',
|
40
|
+
hoveringClass: 'mjs-nestedSortable-hovering',
|
41
|
+
leafClass: 'mjs-nestedSortable-leaf'
|
42
|
+
},
|
43
|
+
|
44
|
+
_create: function() {
|
45
|
+
this.element.data('ui-sortable', this.element.data('mjs-nestedSortable'));
|
46
|
+
|
47
|
+
// mjs - prevent browser from freezing if the HTML is not correct
|
48
|
+
if (!this.element.is(this.options.listType))
|
49
|
+
throw new Error('nestedSortable: Please check that the listType option is set to your actual list type');
|
50
|
+
|
51
|
+
// mjs - force 'intersect' tolerance method if we have a tree with expanding/collapsing functionality
|
52
|
+
if (this.options.isTree && this.options.expandOnHover) {
|
53
|
+
this.options.tolerance = 'intersect';
|
54
|
+
}
|
17
55
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
56
|
+
$.ui.sortable.prototype._create.apply(this, arguments);
|
57
|
+
|
58
|
+
// mjs - prepare the tree by applying the right classes (the CSS is responsible for actual hide/show functionality)
|
59
|
+
if (this.options.isTree) {
|
60
|
+
var self = this;
|
61
|
+
$(this.items).each(function() {
|
62
|
+
var $li = this.item;
|
63
|
+
if ($li.children(self.options.listType).length) {
|
64
|
+
$li.addClass(self.options.branchClass);
|
65
|
+
// expand/collapse class only if they have children
|
66
|
+
if (self.options.startCollapsed) $li.addClass(self.options.collapsedClass);
|
67
|
+
else $li.addClass(self.options.expandedClass);
|
68
|
+
} else {
|
69
|
+
$li.addClass(self.options.leafClass);
|
70
|
+
}
|
71
|
+
})
|
72
|
+
}
|
73
|
+
},
|
74
|
+
|
75
|
+
_destroy: function() {
|
76
|
+
this.element
|
77
|
+
.removeData("mjs-nestedSortable")
|
78
|
+
.removeData("ui-sortable");
|
79
|
+
return $.ui.sortable.prototype._destroy.apply(this, arguments);
|
80
|
+
},
|
81
|
+
|
82
|
+
_mouseDrag: function(event) {
|
83
|
+
var i, item, itemElement, intersection,
|
84
|
+
o = this.options,
|
85
|
+
scrolled = false;
|
86
|
+
|
87
|
+
//Compute the helpers position
|
88
|
+
this.position = this._generatePosition(event);
|
89
|
+
this.positionAbs = this._convertPositionTo("absolute");
|
90
|
+
|
91
|
+
if (!this.lastPositionAbs) {
|
92
|
+
this.lastPositionAbs = this.positionAbs;
|
93
|
+
}
|
30
94
|
|
31
|
-
|
32
|
-
|
95
|
+
//Do scrolling
|
96
|
+
if(this.options.scroll) {
|
97
|
+
if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') {
|
33
98
|
|
34
|
-
|
35
|
-
|
99
|
+
if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
|
100
|
+
this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
|
101
|
+
} else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
|
102
|
+
this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
|
103
|
+
}
|
36
104
|
|
37
|
-
|
38
|
-
|
105
|
+
if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
|
106
|
+
this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
|
107
|
+
} else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
|
108
|
+
this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
|
109
|
+
}
|
39
110
|
|
40
|
-
|
41
|
-
this.element
|
42
|
-
.removeData("nestedSortable")
|
43
|
-
.unbind(".nestedSortable");
|
44
|
-
return $.ui.sortable.prototype.destroy.apply(this, arguments);
|
45
|
-
},
|
111
|
+
} else {
|
46
112
|
|
47
|
-
|
113
|
+
if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
|
114
|
+
scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
|
115
|
+
} else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
|
116
|
+
scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
|
117
|
+
}
|
48
118
|
|
49
|
-
|
50
|
-
|
51
|
-
|
119
|
+
if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
|
120
|
+
scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
|
121
|
+
} else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
|
122
|
+
scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
|
123
|
+
}
|
52
124
|
|
53
|
-
|
54
|
-
this.lastPositionAbs = this.positionAbs;
|
55
|
-
}
|
125
|
+
}
|
56
126
|
|
57
|
-
|
127
|
+
if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
|
128
|
+
$.ui.ddmanager.prepareOffsets(this, event);
|
129
|
+
}
|
58
130
|
|
59
|
-
|
60
|
-
|
61
|
-
var scrolled = false;
|
62
|
-
if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') {
|
131
|
+
//Regenerate the absolute position used for position checks
|
132
|
+
this.positionAbs = this._convertPositionTo("absolute");
|
63
133
|
|
64
|
-
|
65
|
-
|
66
|
-
else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity)
|
67
|
-
this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
|
134
|
+
// mjs - find the top offset before rearrangement,
|
135
|
+
var previousTopOffset = this.placeholder.offset().top;
|
68
136
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
137
|
+
//Set the helper position
|
138
|
+
if(!this.options.axis || this.options.axis !== "y") {
|
139
|
+
this.helper[0].style.left = this.position.left+"px";
|
140
|
+
}
|
141
|
+
if(!this.options.axis || this.options.axis !== "x") {
|
142
|
+
this.helper[0].style.top = this.position.top+"px";
|
143
|
+
}
|
73
144
|
|
74
|
-
|
145
|
+
// mjs - check and reset hovering state at each cycle
|
146
|
+
this.hovering = this.hovering ? this.hovering : null;
|
147
|
+
this.mouseentered = this.mouseentered ? this.mouseentered : false;
|
148
|
+
|
149
|
+
// mjs - let's start caching some variables
|
150
|
+
var parentItem = (this.placeholder[0].parentNode.parentNode &&
|
151
|
+
$(this.placeholder[0].parentNode.parentNode).closest('.ui-sortable').length)
|
152
|
+
? $(this.placeholder[0].parentNode.parentNode)
|
153
|
+
: null,
|
154
|
+
level = this._getLevel(this.placeholder),
|
155
|
+
childLevels = this._getChildLevels(this.helper);
|
156
|
+
|
157
|
+
var newList = document.createElement(o.listType);
|
158
|
+
|
159
|
+
//Rearrange
|
160
|
+
for (i = this.items.length - 1; i >= 0; i--) {
|
161
|
+
|
162
|
+
//Cache variables and intersection, continue if no intersection
|
163
|
+
item = this.items[i];
|
164
|
+
itemElement = item.item[0];
|
165
|
+
intersection = this._intersectsWithPointer(item);
|
166
|
+
if (!intersection) {
|
167
|
+
continue;
|
168
|
+
}
|
75
169
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
170
|
+
// Only put the placeholder inside the current Container, skip all
|
171
|
+
// items form other containers. This works because when moving
|
172
|
+
// an item from one container to another the
|
173
|
+
// currentContainer is switched before the placeholder is moved.
|
174
|
+
//
|
175
|
+
// Without this moving items in "sub-sortables" can cause the placeholder to jitter
|
176
|
+
// beetween the outer and inner container.
|
177
|
+
if (item.instance !== this.currentContainer) {
|
178
|
+
continue;
|
179
|
+
}
|
80
180
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
181
|
+
// cannot intersect with itself
|
182
|
+
// no useless actions that have been done before
|
183
|
+
// no action if the item moved is the parent of the item checked
|
184
|
+
if (itemElement !== this.currentItem[0] &&
|
185
|
+
this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
|
186
|
+
!$.contains(this.placeholder[0], itemElement) &&
|
187
|
+
(this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
|
188
|
+
) {
|
189
|
+
|
190
|
+
// mjs - we are intersecting an element: trigger the mouseenter event and store this state
|
191
|
+
if (!this.mouseentered) {
|
192
|
+
$(itemElement).mouseenter();
|
193
|
+
this.mouseentered = true;
|
194
|
+
}
|
85
195
|
|
86
|
-
|
196
|
+
// mjs - if the element has children and they are hidden, show them after a delay (CSS responsible)
|
197
|
+
if (o.isTree && $(itemElement).hasClass(o.collapsedClass) && o.expandOnHover) {
|
198
|
+
if (!this.hovering) {
|
199
|
+
$(itemElement).addClass(o.hoveringClass);
|
200
|
+
var self = this;
|
201
|
+
this.hovering = window.setTimeout(function() {
|
202
|
+
$(itemElement).removeClass(o.collapsedClass).addClass(o.expandedClass);
|
203
|
+
self.refreshPositions();
|
204
|
+
self._trigger("expand", event, self._uiHash());
|
205
|
+
}, o.expandOnHover);
|
206
|
+
}
|
207
|
+
}
|
87
208
|
|
88
|
-
|
89
|
-
|
90
|
-
|
209
|
+
this.direction = intersection == 1 ? "down" : "up";
|
210
|
+
|
211
|
+
// mjs - rearrange the elements and reset timeouts and hovering state
|
212
|
+
if (this.options.tolerance == "pointer" || this._intersectsWithSides(item)) {
|
213
|
+
$(itemElement).mouseleave();
|
214
|
+
this.mouseentered = false;
|
215
|
+
$(itemElement).removeClass(o.hoveringClass);
|
216
|
+
this.hovering && window.clearTimeout(this.hovering);
|
217
|
+
this.hovering = null;
|
218
|
+
|
219
|
+
// mjs - do not switch container if it's a root item and 'protectRoot' is true
|
220
|
+
// or if it's not a root item but we are trying to make it root
|
221
|
+
if (o.protectRoot
|
222
|
+
&& ! (this.currentItem[0].parentNode == this.element[0] // it's a root item
|
223
|
+
&& itemElement.parentNode != this.element[0]) // it's intersecting a non-root item
|
224
|
+
) {
|
225
|
+
if (this.currentItem[0].parentNode != this.element[0]
|
226
|
+
&& itemElement.parentNode == this.element[0]
|
227
|
+
) {
|
228
|
+
|
229
|
+
if ( ! $(itemElement).children(o.listType).length) {
|
230
|
+
itemElement.appendChild(newList);
|
231
|
+
o.isTree && $(itemElement).removeClass(o.leafClass).addClass(o.branchClass + ' ' + o.expandedClass);
|
232
|
+
}
|
233
|
+
|
234
|
+
var a = this.direction === "down" ? $(itemElement).prev().children(o.listType) : $(itemElement).children(o.listType);
|
235
|
+
if (a[0] !== undefined) {
|
236
|
+
this._rearrange(event, null, a);
|
237
|
+
}
|
238
|
+
|
239
|
+
} else {
|
240
|
+
this._rearrange(event, item);
|
241
|
+
}
|
242
|
+
} else if ( ! o.protectRoot) {
|
243
|
+
this._rearrange(event, item);
|
244
|
+
}
|
245
|
+
} else {
|
246
|
+
break;
|
247
|
+
}
|
91
248
|
|
92
|
-
|
93
|
-
|
249
|
+
// Clear emtpy ul's/ol's
|
250
|
+
this._clearEmpty(itemElement);
|
94
251
|
|
95
|
-
|
96
|
-
|
252
|
+
this._trigger("change", event, this._uiHash());
|
253
|
+
break;
|
254
|
+
}
|
255
|
+
}
|
97
256
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
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.
|
257
|
+
// mjs - to find the previous sibling in the list, keep backtracking until we hit a valid list item.
|
258
|
+
var previousItem = this.placeholder[0].previousSibling ? $(this.placeholder[0].previousSibling) : null;
|
259
|
+
if (previousItem != null) {
|
260
|
+
while (previousItem[0].nodeName.toLowerCase() != $(o.listType)[0].nodeName.toLowerCase() || previousItem[0] == this.currentItem[0] || previousItem[0] == this.helper[0]) {
|
261
|
+
if (previousItem[0].previousSibling) {
|
262
|
+
previousItem = $(previousItem[0].previousSibling);
|
263
|
+
} else {
|
264
|
+
previousItem = null;
|
265
|
+
break;
|
266
|
+
}
|
267
|
+
}
|
268
|
+
}
|
269
|
+
|
270
|
+
// mjs - to find the next sibling in the list, keep stepping forward until we hit a valid list item.
|
156
271
|
var nextItem = this.placeholder[0].nextSibling ? $(this.placeholder[0].nextSibling) : null;
|
157
272
|
if (nextItem != null) {
|
158
|
-
while (nextItem[0].nodeName.toLowerCase() !=
|
273
|
+
while (nextItem[0].nodeName.toLowerCase() != $(o.listType)[0].nodeName.toLowerCase() || nextItem[0] == this.currentItem[0] || nextItem[0] == this.helper[0]) {
|
159
274
|
if (nextItem[0].nextSibling) {
|
160
275
|
nextItem = $(nextItem[0].nextSibling);
|
161
276
|
} else {
|
@@ -165,265 +280,334 @@
|
|
165
280
|
}
|
166
281
|
}
|
167
282
|
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
283
|
+
this.beyondMaxLevels = 0;
|
284
|
+
|
285
|
+
// mjs - if the item is moved to the left, send it one level up but only if it's at the bottom of the list
|
286
|
+
if (parentItem != null
|
287
|
+
&& nextItem == null
|
288
|
+
&& ! (o.protectRoot && parentItem[0].parentNode == this.element[0])
|
289
|
+
&&
|
290
|
+
(o.rtl && (this.positionAbs.left + this.helper.outerWidth() > parentItem.offset().left + parentItem.outerWidth())
|
291
|
+
|| ! o.rtl && (this.positionAbs.left < parentItem.offset().left))
|
292
|
+
) {
|
293
|
+
|
294
|
+
parentItem.after(this.placeholder[0]);
|
295
|
+
if (o.isTree && parentItem.children(o.listItem).children(o.listItem + ':visible:not(.ui-sortable-helper)').length < 1) {
|
296
|
+
parentItem.removeClass(this.options.branchClass + ' ' + this.options.expandedClass)
|
297
|
+
.addClass(this.options.leafClass);
|
298
|
+
}
|
299
|
+
this._clearEmpty(parentItem[0]);
|
300
|
+
this._trigger("change", event, this._uiHash());
|
301
|
+
}
|
302
|
+
// mjs - if the item is below a sibling and is moved to the right, make it a child of that sibling
|
303
|
+
else if (previousItem != null
|
304
|
+
&& ! previousItem.hasClass(o.disableNestingClass)
|
305
|
+
&&
|
306
|
+
(previousItem.children(o.listType).length && previousItem.children(o.listType).is(':visible')
|
307
|
+
|| ! previousItem.children(o.listType).length)
|
308
|
+
&& ! (o.protectRoot && this.currentItem[0].parentNode == this.element[0])
|
309
|
+
&&
|
310
|
+
(o.rtl && (this.positionAbs.left + this.helper.outerWidth() < previousItem.offset().left + previousItem.outerWidth() - o.tabSize)
|
311
|
+
|| ! o.rtl && (this.positionAbs.left > previousItem.offset().left + o.tabSize))
|
312
|
+
) {
|
313
|
+
|
314
|
+
this._isAllowed(previousItem, level, level+childLevels+1);
|
315
|
+
|
316
|
+
if (!previousItem.children(o.listType).length) {
|
317
|
+
previousItem[0].appendChild(newList);
|
318
|
+
o.isTree && previousItem.removeClass(o.leafClass).addClass(o.branchClass + ' ' + o.expandedClass);
|
319
|
+
}
|
320
|
+
|
321
|
+
// mjs - if this item is being moved from the top, add it to the top of the list.
|
322
|
+
if (previousTopOffset && (previousTopOffset <= previousItem.offset().top)) {
|
323
|
+
previousItem.children(o.listType).prepend(this.placeholder);
|
324
|
+
}
|
325
|
+
// mjs - otherwise, add it to the bottom of the list.
|
326
|
+
else if(previousItem.children(o.listType).length) {
|
327
|
+
previousItem.children(o.listType)[0].appendChild(this.placeholder[0]);
|
328
|
+
}
|
329
|
+
|
330
|
+
this._trigger("change", event, this._uiHash());
|
331
|
+
}
|
332
|
+
else {
|
333
|
+
this._isAllowed(parentItem, level, level+childLevels);
|
334
|
+
}
|
335
|
+
|
336
|
+
//Post events to containers
|
337
|
+
this._contactContainers(event);
|
338
|
+
|
339
|
+
//Interconnect with droppables
|
340
|
+
if($.ui.ddmanager) {
|
341
|
+
$.ui.ddmanager.drag(this, event);
|
342
|
+
}
|
343
|
+
|
344
|
+
//Call callbacks
|
345
|
+
this._trigger('sort', event, this._uiHash());
|
346
|
+
|
347
|
+
this.lastPositionAbs = this.positionAbs;
|
348
|
+
return false;
|
349
|
+
|
350
|
+
},
|
351
|
+
|
352
|
+
_mouseStop: function(event, noPropagation) {
|
353
|
+
|
354
|
+
// mjs - if the item is in a position not allowed, send it back
|
355
|
+
if (this.beyondMaxLevels) {
|
356
|
+
|
357
|
+
this.placeholder.removeClass(this.options.errorClass);
|
358
|
+
|
359
|
+
if (this.domPosition.prev) {
|
360
|
+
$(this.domPosition.prev).after(this.placeholder);
|
361
|
+
} else {
|
362
|
+
$(this.domPosition.parent).prepend(this.placeholder);
|
191
363
|
}
|
192
|
-
|
193
|
-
|
194
|
-
|
364
|
+
|
365
|
+
this._trigger("revert", event, this._uiHash());
|
366
|
+
|
367
|
+
}
|
368
|
+
|
369
|
+
|
370
|
+
// mjs - clear the hovering timeout, just to be sure
|
371
|
+
$('.'+this.options.hoveringClass).mouseleave().removeClass(this.options.hoveringClass);
|
372
|
+
this.mouseentered = false;
|
373
|
+
this.hovering && window.clearTimeout(this.hovering);
|
374
|
+
this.hovering = null;
|
375
|
+
|
376
|
+
$.ui.sortable.prototype._mouseStop.apply(this, arguments);
|
377
|
+
|
378
|
+
},
|
379
|
+
|
380
|
+
// mjs - this function is slightly modified to make it easier to hover over a collapsed element and have it expand
|
381
|
+
_intersectsWithSides: function(item) {
|
382
|
+
|
383
|
+
var half = this.options.isTree ? .8 : .5;
|
384
|
+
|
385
|
+
var isOverBottomHalf = isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height*half), item.height),
|
386
|
+
isOverTopHalf = isOverAxis(this.positionAbs.top + this.offset.click.top, item.top - (item.height*half), item.height),
|
387
|
+
isOverRightHalf = isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
|
388
|
+
verticalDirection = this._getDragVerticalDirection(),
|
389
|
+
horizontalDirection = this._getDragHorizontalDirection();
|
390
|
+
|
391
|
+
if (this.floating && horizontalDirection) {
|
392
|
+
return ((horizontalDirection == "right" && isOverRightHalf) || (horizontalDirection == "left" && !isOverRightHalf));
|
393
|
+
} else {
|
394
|
+
return verticalDirection && ((verticalDirection == "down" && isOverBottomHalf) || (verticalDirection == "up" && isOverTopHalf));
|
395
|
+
}
|
396
|
+
|
397
|
+
},
|
398
|
+
|
399
|
+
_contactContainers: function(event) {
|
400
|
+
|
401
|
+
if (this.options.protectRoot && this.currentItem[0].parentNode == this.element[0] ) {
|
402
|
+
return;
|
403
|
+
}
|
404
|
+
|
405
|
+
$.ui.sortable.prototype._contactContainers.apply(this, arguments);
|
406
|
+
|
407
|
+
},
|
408
|
+
|
409
|
+
_clear: function(event, noPropagation) {
|
410
|
+
|
411
|
+
$.ui.sortable.prototype._clear.apply(this, arguments);
|
412
|
+
|
413
|
+
// mjs - clean last empty ul/ol
|
414
|
+
for (var i = this.items.length - 1; i >= 0; i--) {
|
415
|
+
var item = this.items[i].item[0];
|
416
|
+
this._clearEmpty(item);
|
417
|
+
}
|
418
|
+
|
419
|
+
},
|
420
|
+
|
421
|
+
serialize: function(options) {
|
422
|
+
|
423
|
+
var o = $.extend({}, this.options, options),
|
424
|
+
items = this._getItemsAsjQuery(o && o.connected),
|
425
|
+
str = [];
|
426
|
+
|
427
|
+
$(items).each(function() {
|
428
|
+
var res = ($(o.item || this).attr(o.attribute || 'id') || '')
|
429
|
+
.match(o.expression || (/(.+)[-=_](.+)/)),
|
430
|
+
pid = ($(o.item || this).parent(o.listType)
|
431
|
+
.parent(o.items)
|
432
|
+
.attr(o.attribute || 'id') || '')
|
433
|
+
.match(o.expression || (/(.+)[-=_](.+)/));
|
434
|
+
|
435
|
+
if (res) {
|
436
|
+
str.push(((o.key || res[1]) + '[' + (o.key && o.expression ? res[1] : res[2]) + ']')
|
437
|
+
+ '='
|
438
|
+
+ (pid ? (o.key && o.expression ? pid[1] : pid[2]) : o.rootID));
|
195
439
|
}
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
440
|
+
});
|
441
|
+
|
442
|
+
if(!str.length && o.key) {
|
443
|
+
str.push(o.key + '=');
|
444
|
+
}
|
445
|
+
|
446
|
+
return str.join('&');
|
447
|
+
|
448
|
+
},
|
449
|
+
|
450
|
+
toHierarchy: function(options) {
|
201
451
|
|
202
|
-
|
203
|
-
|
452
|
+
var o = $.extend({}, this.options, options),
|
453
|
+
sDepth = o.startDepthCount || 0,
|
454
|
+
ret = [];
|
455
|
+
|
456
|
+
$(this.element).children(o.items).each(function () {
|
457
|
+
var level = _recursiveItems(this);
|
458
|
+
ret.push(level);
|
459
|
+
});
|
460
|
+
|
461
|
+
return ret;
|
462
|
+
|
463
|
+
function _recursiveItems(item) {
|
464
|
+
var id = ($(item).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
|
465
|
+
if (id) {
|
466
|
+
var currentItem = {"id" : id[2]};
|
467
|
+
if ($(item).children(o.listType).children(o.items).length > 0) {
|
468
|
+
currentItem.children = [];
|
469
|
+
$(item).children(o.listType).children(o.items).each(function() {
|
470
|
+
var level = _recursiveItems(this);
|
471
|
+
currentItem.children.push(level);
|
472
|
+
});
|
473
|
+
}
|
474
|
+
return currentItem;
|
475
|
+
}
|
476
|
+
}
|
477
|
+
},
|
478
|
+
|
479
|
+
toArray: function(options) {
|
480
|
+
|
481
|
+
var o = $.extend({}, this.options, options),
|
482
|
+
sDepth = o.startDepthCount || 0,
|
483
|
+
ret = [],
|
484
|
+
left = 1;
|
485
|
+
|
486
|
+
if (!o.excludeRoot) {
|
487
|
+
ret.push({
|
488
|
+
"item_id": o.rootID,
|
489
|
+
"parent_id": null,
|
490
|
+
"depth": sDepth,
|
491
|
+
"left": left,
|
492
|
+
"right": ($(o.items, this.element).length + 1) * 2
|
493
|
+
});
|
494
|
+
left++
|
495
|
+
}
|
204
496
|
|
205
|
-
|
206
|
-
|
497
|
+
$(this.element).children(o.items).each(function () {
|
498
|
+
left = _recursiveArray(this, sDepth + 1, left);
|
499
|
+
});
|
207
500
|
|
208
|
-
|
209
|
-
this._trigger('sort', event, this._uiHash());
|
501
|
+
ret = ret.sort(function(a,b){ return (a.left - b.left); });
|
210
502
|
|
211
|
-
|
212
|
-
return false;
|
503
|
+
return ret;
|
213
504
|
|
214
|
-
|
505
|
+
function _recursiveArray(item, depth, left) {
|
215
506
|
|
216
|
-
|
507
|
+
var right = left + 1,
|
508
|
+
id,
|
509
|
+
pid;
|
217
510
|
|
218
|
-
|
219
|
-
|
511
|
+
if ($(item).children(o.listType).children(o.items).length > 0) {
|
512
|
+
depth ++;
|
513
|
+
$(item).children(o.listType).children(o.items).each(function () {
|
514
|
+
right = _recursiveArray($(this), depth, right);
|
515
|
+
});
|
516
|
+
depth --;
|
517
|
+
}
|
220
518
|
|
221
|
-
|
519
|
+
id = ($(item).attr(o.attribute || 'id')).match(o.expression || (/(.+)[-=_](.+)/));
|
222
520
|
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
521
|
+
if (depth === sDepth + 1) {
|
522
|
+
pid = o.rootID;
|
523
|
+
} else {
|
524
|
+
var parentItem = ($(item).parent(o.listType)
|
525
|
+
.parent(o.items)
|
526
|
+
.attr(o.attribute || 'id'))
|
527
|
+
.match(o.expression || (/(.+)[-=_](.+)/));
|
528
|
+
pid = parentItem[2];
|
529
|
+
}
|
228
530
|
|
229
|
-
|
531
|
+
if (id) {
|
532
|
+
ret.push({"item_id": id[2], "parent_id": pid, "depth": depth, "left": left, "right": right});
|
533
|
+
}
|
230
534
|
|
231
|
-
|
535
|
+
left = right + 1;
|
536
|
+
return left;
|
537
|
+
}
|
232
538
|
|
233
|
-
|
234
|
-
for (var i = this.items.length - 1; i >= 0; i--) {
|
235
|
-
var item = this.items[i].item[0];
|
236
|
-
this._clearEmpty(item);
|
237
|
-
}
|
539
|
+
},
|
238
540
|
|
239
|
-
|
541
|
+
_clearEmpty: function(item) {
|
542
|
+
var o = this.options;
|
240
543
|
|
241
|
-
|
544
|
+
var emptyList = $(item).children(o.listType);
|
242
545
|
|
243
|
-
|
546
|
+
if (emptyList.length && !emptyList.children().length && !o.doNotClear) {
|
547
|
+
o.isTree && $(item).removeClass(o.branchClass + ' ' + o.expandedClass).addClass(o.leafClass);
|
548
|
+
emptyList.remove();
|
549
|
+
} else if (o.isTree && emptyList.length && emptyList.children().length && emptyList.is(':visible')) {
|
550
|
+
$(item).removeClass(o.leafClass).addClass(o.branchClass + ' ' + o.expandedClass);
|
551
|
+
} else if (o.isTree && emptyList.length && emptyList.children().length && !emptyList.is(':visible')) {
|
552
|
+
$(item).removeClass(o.leafClass).addClass(o.branchClass + ' ' + o.collapsedClass);
|
553
|
+
}
|
244
554
|
|
245
|
-
|
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
|
-
});
|
555
|
+
},
|
263
556
|
|
264
|
-
|
265
|
-
str.push(o.key + '=');
|
266
|
-
}
|
557
|
+
_getLevel: function(item) {
|
267
558
|
|
268
|
-
|
559
|
+
var level = 1;
|
269
560
|
|
270
|
-
|
561
|
+
if (this.options.listType) {
|
562
|
+
var list = item.closest(this.options.listType);
|
563
|
+
while (list && list.length > 0 &&
|
564
|
+
!list.is('.ui-sortable')) {
|
565
|
+
level++;
|
566
|
+
list = list.parent().closest(this.options.listType);
|
567
|
+
}
|
568
|
+
}
|
271
569
|
|
272
|
-
|
570
|
+
return level;
|
571
|
+
},
|
273
572
|
|
274
|
-
|
275
|
-
|
276
|
-
|
573
|
+
_getChildLevels: function(parent, depth) {
|
574
|
+
var self = this,
|
575
|
+
o = this.options,
|
576
|
+
result = 0;
|
577
|
+
depth = depth || 0;
|
277
578
|
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
});
|
579
|
+
$(parent).children(o.listType).children(o.items).each(function (index, child) {
|
580
|
+
result = Math.max(self._getChildLevels(child, depth + 1), result);
|
581
|
+
});
|
282
582
|
|
283
|
-
|
583
|
+
return depth ? result + 1 : result;
|
584
|
+
},
|
284
585
|
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
var currentItem = {"id" : id[2]};
|
289
|
-
if ($(item).children(o.listType).children(o.items).length > 0) {
|
290
|
-
currentItem.children = [];
|
291
|
-
$(item).children(o.listType).children(o.items).each(function() {
|
292
|
-
var level = _recursiveItems(this);
|
293
|
-
currentItem.children.push(level);
|
294
|
-
});
|
295
|
-
}
|
296
|
-
return currentItem;
|
297
|
-
}
|
298
|
-
}
|
299
|
-
},
|
586
|
+
_isAllowed: function(parentItem, level, levels) {
|
587
|
+
var o = this.options,
|
588
|
+
maxLevels = this.placeholder.closest('.ui-sortable').nestedSortable('option', 'maxLevels'); // this takes into account the maxLevels set to the recipient list
|
300
589
|
|
301
|
-
|
590
|
+
// mjs - is the root protected?
|
591
|
+
// mjs - are we nesting too deep?
|
592
|
+
if ( ! o.isAllowed(this.placeholder, parentItem, this.currentItem)) {
|
593
|
+
this.placeholder.addClass(o.errorClass);
|
594
|
+
if (maxLevels < levels && maxLevels != 0) {
|
595
|
+
this.beyondMaxLevels = levels - maxLevels;
|
596
|
+
} else {
|
597
|
+
this.beyondMaxLevels = 1;
|
598
|
+
}
|
599
|
+
} else {
|
600
|
+
if (maxLevels < levels && maxLevels != 0) {
|
601
|
+
this.placeholder.addClass(o.errorClass);
|
602
|
+
this.beyondMaxLevels = levels - maxLevels;
|
603
|
+
} else {
|
604
|
+
this.placeholder.removeClass(o.errorClass);
|
605
|
+
this.beyondMaxLevels = 0;
|
606
|
+
}
|
607
|
+
}
|
608
|
+
}
|
302
609
|
|
303
|
-
|
304
|
-
sDepth = o.startDepthCount || 0,
|
305
|
-
ret = [],
|
306
|
-
left = 2;
|
610
|
+
}));
|
307
611
|
|
308
|
-
|
309
|
-
"item_id": o.rootID,
|
310
|
-
"parent_id": 'none',
|
311
|
-
"depth": sDepth,
|
312
|
-
"left": '1',
|
313
|
-
"right": ($(o.items, this.element).length + 1) * 2
|
314
|
-
});
|
315
|
-
|
316
|
-
$(this.element).children(o.items).each(function () {
|
317
|
-
left = _recursiveArray(this, sDepth + 1, left);
|
318
|
-
});
|
319
|
-
|
320
|
-
ret = ret.sort(function(a,b){ return (a.left - b.left); });
|
321
|
-
|
322
|
-
return ret;
|
323
|
-
|
324
|
-
function _recursiveArray(item, depth, left) {
|
325
|
-
|
326
|
-
var right = left + 1,
|
327
|
-
id,
|
328
|
-
pid;
|
329
|
-
|
330
|
-
if ($(item).children(o.listType).children(o.items).length > 0) {
|
331
|
-
depth ++;
|
332
|
-
$(item).children(o.listType).children(o.items).each(function () {
|
333
|
-
right = _recursiveArray($(this), depth, right);
|
334
|
-
});
|
335
|
-
depth --;
|
336
|
-
}
|
337
|
-
|
338
|
-
id = ($(item).attr(o.attribute || 'id')).match(o.expression || (/(.+)[-=_](.+)/));
|
339
|
-
|
340
|
-
if (depth === sDepth + 1) {
|
341
|
-
pid = o.rootID;
|
342
|
-
} else {
|
343
|
-
var parentItem = ($(item).parent(o.listType)
|
344
|
-
.parent(o.items)
|
345
|
-
.attr(o.attribute || 'id'))
|
346
|
-
.match(o.expression || (/(.+)[-=_](.+)/));
|
347
|
-
pid = parentItem[2];
|
348
|
-
}
|
349
|
-
|
350
|
-
if (id) {
|
351
|
-
ret.push({"item_id": id[2], "parent_id": pid, "depth": depth, "left": left, "right": right});
|
352
|
-
}
|
353
|
-
|
354
|
-
left = right + 1;
|
355
|
-
return left;
|
356
|
-
}
|
357
|
-
|
358
|
-
},
|
359
|
-
|
360
|
-
_clearEmpty: function(item) {
|
361
|
-
|
362
|
-
var emptyList = $(item).children(this.options.listType);
|
363
|
-
if (emptyList.length && !emptyList.children().length && !this.options.doNotClear) {
|
364
|
-
emptyList.remove();
|
365
|
-
}
|
366
|
-
|
367
|
-
},
|
368
|
-
|
369
|
-
_getLevel: function(item) {
|
370
|
-
|
371
|
-
var level = 1;
|
372
|
-
|
373
|
-
if (this.options.listType) {
|
374
|
-
var list = item.closest(this.options.listType);
|
375
|
-
while (list && list.length > 0 &&
|
376
|
-
!list.is('.ui-sortable')) {
|
377
|
-
level++;
|
378
|
-
list = list.parent().closest(this.options.listType);
|
379
|
-
}
|
380
|
-
}
|
381
|
-
|
382
|
-
return level;
|
383
|
-
},
|
384
|
-
|
385
|
-
_getChildLevels: function(parent, depth) {
|
386
|
-
var self = this,
|
387
|
-
o = this.options,
|
388
|
-
result = 0;
|
389
|
-
depth = depth || 0;
|
390
|
-
|
391
|
-
$(parent).children(o.listType).children(o.items).each(function (index, child) {
|
392
|
-
result = Math.max(self._getChildLevels(child, depth + 1), result);
|
393
|
-
});
|
394
|
-
|
395
|
-
return depth ? result + 1 : result;
|
396
|
-
},
|
397
|
-
|
398
|
-
_isAllowed: function(parentItem, level, levels) {
|
399
|
-
var o = this.options,
|
400
|
-
isRoot = $(this.domPosition.parent).hasClass('ui-sortable') ? true : false,
|
401
|
-
maxLevels = this.placeholder.closest('.ui-sortable').nestedSortable('option', 'maxLevels'); // this takes into account the maxLevels set to the recipient list
|
402
|
-
|
403
|
-
// Is the root protected?
|
404
|
-
// Are we trying to nest under a no-nest?
|
405
|
-
// Are we nesting too deep?
|
406
|
-
if (!o.isAllowed(this.currentItem, parentItem) ||
|
407
|
-
parentItem && parentItem.hasClass(o.disableNesting) ||
|
408
|
-
o.protectRoot && (parentItem == null && !isRoot || isRoot && level > 1)) {
|
409
|
-
this.placeholder.addClass(o.errorClass);
|
410
|
-
if (maxLevels < levels && maxLevels != 0) {
|
411
|
-
this.beyondMaxLevels = levels - maxLevels;
|
412
|
-
} else {
|
413
|
-
this.beyondMaxLevels = 1;
|
414
|
-
}
|
415
|
-
} else {
|
416
|
-
if (maxLevels < levels && maxLevels != 0) {
|
417
|
-
this.placeholder.addClass(o.errorClass);
|
418
|
-
this.beyondMaxLevels = levels - maxLevels;
|
419
|
-
} else {
|
420
|
-
this.placeholder.removeClass(o.errorClass);
|
421
|
-
this.beyondMaxLevels = 0;
|
422
|
-
}
|
423
|
-
}
|
424
|
-
}
|
425
|
-
|
426
|
-
}));
|
427
|
-
|
428
|
-
$.mjs.nestedSortable.prototype.options = $.extend({}, $.ui.sortable.prototype.options, $.mjs.nestedSortable.prototype.options);
|
612
|
+
$.mjs.nestedSortable.prototype.options = $.extend({}, $.ui.sortable.prototype.options, $.mjs.nestedSortable.prototype.options);
|
429
613
|
})(jQuery);
|
@@ -11,14 +11,13 @@ window.rails_admin_nested_set = (tree_config) ->
|
|
11
11
|
|
12
12
|
$ ->
|
13
13
|
$("#" + tree_config["id"]).nestedSortable
|
14
|
-
|
15
|
-
#
|
16
|
-
|
17
|
-
items: "li"
|
14
|
+
handle: '.dd-handle',
|
15
|
+
#helper: "clone"
|
16
|
+
items: ".dd-item"
|
18
17
|
maxLevels: tree_config["max_depth"]
|
19
|
-
opacity: .6
|
20
18
|
placeholder: "dd-placeholder"
|
21
|
-
|
19
|
+
tolerance: 'pointer',
|
20
|
+
toleranceElement: '> div',
|
22
21
|
update: (event, ui) ->
|
23
22
|
$.ajax
|
24
23
|
type: "POST"
|
@@ -25,13 +25,7 @@
|
|
25
25
|
padding-left: 30px;
|
26
26
|
}
|
27
27
|
|
28
|
-
.dd-
|
29
|
-
display: none;
|
30
|
-
}
|
31
|
-
|
32
|
-
.dd-item,
|
33
|
-
.dd-empty,
|
34
|
-
.dd-placeholder {
|
28
|
+
.dd-item, .dd-placeholder {
|
35
29
|
display: block;
|
36
30
|
position: relative;
|
37
31
|
margin: 0;
|
@@ -66,146 +60,21 @@
|
|
66
60
|
background: #fff;
|
67
61
|
}
|
68
62
|
|
69
|
-
.dd-item
|
70
|
-
|
71
|
-
position: relative;
|
72
|
-
cursor: pointer;
|
73
|
-
float: left;
|
74
|
-
width: 25px;
|
75
|
-
height: 20px;
|
76
|
-
margin: 5px 0;
|
77
|
-
padding: 0;
|
78
|
-
text-indent: 100%;
|
79
|
-
white-space: nowrap;
|
80
|
-
overflow: hidden;
|
81
|
-
border: 0;
|
82
|
-
background: transparent;
|
83
|
-
font-size: 12px;
|
84
|
-
line-height: 1;
|
85
|
-
text-align: center;
|
86
|
-
font-weight: bold;
|
63
|
+
.dd-item {
|
64
|
+
margin-top: 5px
|
87
65
|
}
|
88
66
|
|
89
|
-
.dd-
|
90
|
-
content: '+';
|
91
|
-
display: block;
|
92
|
-
position: absolute;
|
93
|
-
width: 100%;
|
94
|
-
text-align: center;
|
95
|
-
text-indent: 0;
|
96
|
-
}
|
97
|
-
|
98
|
-
.dd-item > button[data-action="collapse"]:before {
|
99
|
-
content: '-';
|
100
|
-
}
|
101
|
-
|
102
|
-
.dd-placeholder, .dd-empty {
|
67
|
+
.dd-placeholder {
|
103
68
|
margin: 5px 0;
|
104
69
|
padding: 0;
|
105
70
|
min-height: 30px;
|
106
71
|
background: #f2fbff;
|
107
72
|
border: 1px dashed #b6bcbf;
|
108
|
-
box-sizing: border-box;
|
109
|
-
-moz-box-sizing: border-box;
|
110
|
-
}
|
111
|
-
|
112
|
-
.dd-empty {
|
113
|
-
border: 1px dashed #bbb;
|
114
|
-
min-height: 100px;
|
115
|
-
background-color: #e5e5e5;
|
116
|
-
background-image: -webkit-linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff), -webkit-linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff);
|
117
|
-
background-image: -moz-linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff), -moz-linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff);
|
118
|
-
background-image: linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff), linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff);
|
119
|
-
background-size: 60px 60px;
|
120
|
-
background-position: 0 0, 30px 30px;
|
121
|
-
}
|
122
|
-
|
123
|
-
.dd-dragel {
|
124
|
-
position: absolute;
|
125
|
-
pointer-events: none;
|
126
|
-
z-index: 9999;
|
127
|
-
}
|
128
|
-
|
129
|
-
.dd-dragel > .dd-item .dd-handle {
|
130
|
-
margin-top: 0;
|
131
|
-
}
|
132
|
-
|
133
|
-
.dd-dragel .dd-handle {
|
134
|
-
-webkit-box-shadow: 2px 4px 6px 0 rgba(0, 0, 0, .1);
|
135
|
-
box-shadow: 2px 4px 6px 0 rgba(0, 0, 0, .1);
|
136
73
|
}
|
137
74
|
|
138
|
-
/**
|
139
|
-
* Nestable Extras
|
140
|
-
*/
|
141
|
-
|
142
|
-
.nestable-lists {
|
143
|
-
display: block;
|
144
|
-
clear: both;
|
145
|
-
padding: 30px 0;
|
146
|
-
width: 100%;
|
147
|
-
border: 0;
|
148
|
-
border-top: 2px solid #ddd;
|
149
|
-
border-bottom: 2px solid #ddd;
|
150
|
-
}
|
151
|
-
|
152
|
-
#nestable-menu {
|
153
|
-
padding: 0;
|
154
|
-
margin: 20px 0;
|
155
|
-
}
|
156
|
-
|
157
|
-
#nestable-output, #nestable2-output {
|
158
|
-
width: 100%;
|
159
|
-
height: 7em;
|
160
|
-
font-size: 0.75em;
|
161
|
-
line-height: 1.333333em;
|
162
|
-
font-family: Consolas, monospace;
|
163
|
-
padding: 5px;
|
164
|
-
box-sizing: border-box;
|
165
|
-
-moz-box-sizing: border-box;
|
166
|
-
}
|
167
|
-
|
168
|
-
#nestable2 .dd-handle {
|
169
|
-
color: #fff;
|
170
|
-
border: 1px solid #999;
|
171
|
-
background: #bbb;
|
172
|
-
background: -webkit-linear-gradient(top, #bbb 0%, #999 100%);
|
173
|
-
background: -moz-linear-gradient(top, #bbb 0%, #999 100%);
|
174
|
-
background: linear-gradient(top, #bbb 0%, #999 100%);
|
175
|
-
}
|
176
|
-
|
177
|
-
#nestable2 .dd-handle:hover {
|
178
|
-
background: #bbb;
|
179
|
-
}
|
180
|
-
|
181
|
-
#nestable2 .dd-item > button:before {
|
182
|
-
color: #fff;
|
183
|
-
}
|
184
|
-
|
185
|
-
@media only screen and (min-width: 700px) {
|
186
|
-
|
187
|
-
.dd {
|
188
|
-
float: none;
|
189
|
-
width: auto;
|
190
|
-
}
|
191
|
-
.dd + .dd {
|
192
|
-
margin-left: 2%;
|
193
|
-
}
|
194
|
-
|
195
|
-
}
|
196
|
-
|
197
|
-
.dd-hover > .dd-handle {
|
198
|
-
background: #2ea8e5 !important;
|
199
|
-
}
|
200
|
-
|
201
|
-
/**
|
202
|
-
* Nestable Draggable Handles
|
203
|
-
*/
|
204
|
-
|
205
75
|
.dd3-content {
|
206
76
|
display: block;
|
207
77
|
height: 30px;
|
208
|
-
margin: 5px 0;
|
209
78
|
padding: 5px 10px 5px 40px;
|
210
79
|
color: #333;
|
211
80
|
text-decoration: none;
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -15,7 +15,6 @@ module RailsAdminNestedSet
|
|
15
15
|
li_classes = 'dd-item dd3-item'
|
16
16
|
|
17
17
|
content_tag :li, class: li_classes, :'data-id' => node.id do
|
18
|
-
|
19
18
|
output = content_tag :div, 'drag', class: 'dd-handle dd3-handle'
|
20
19
|
output+= content_tag :div, class: 'dd3-content' do
|
21
20
|
content = link_to @model_config.with(object: node).object_label, edit_path(@abstract_model, node.id)
|
@@ -24,7 +23,7 @@ module RailsAdminNestedSet
|
|
24
23
|
|
25
24
|
children = tree.select{|elem| elem.parent_id == node.id}
|
26
25
|
if children.any?
|
27
|
-
output
|
26
|
+
output = content_tag(:div, output) + content_tag(:ol, rails_admin_nested_set_builder(children, tree), class: 'dd-list')
|
28
27
|
end
|
29
28
|
|
30
29
|
output
|
File without changes
|
@@ -12,10 +12,6 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.summary = %q{Interface for editing a nested set for rails_admin}
|
13
13
|
gem.homepage = "https://github.com/rs-pro/rails_admin_nested_set"
|
14
14
|
|
15
|
-
gem.add_dependency "rails", "~> 4.0.0"
|
16
|
-
gem.add_dependency "jquery-rails"
|
17
|
-
gem.add_dependency "jquery-ui-rails"
|
18
|
-
|
19
15
|
gem.files = `git ls-files`.split($/)
|
20
16
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
21
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
metadata
CHANGED
@@ -1,57 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_admin_nested_set
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gleb Tv
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: rails
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ~>
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 4.0.0
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ~>
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 4.0.0
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: jquery-rails
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - '>='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - '>='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: jquery-ui-rails
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - '>='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
11
|
+
date: 2014-02-26 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
55
13
|
description: Rails admin nested set
|
56
14
|
email:
|
57
15
|
- glebtv@gmail.com
|
@@ -100,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
58
|
version: '0'
|
101
59
|
requirements: []
|
102
60
|
rubyforge_project:
|
103
|
-
rubygems_version: 2.1
|
61
|
+
rubygems_version: 2.2.1
|
104
62
|
signing_key:
|
105
63
|
specification_version: 4
|
106
64
|
summary: Interface for editing a nested set for rails_admin
|