kea-rails 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kea-rails/version.rb +1 -1
- data/vendor/assets/components/Keypress/LICENSE +191 -0
- data/vendor/assets/components/Keypress/README.md +78 -0
- data/vendor/assets/components/Keypress/bower.json +28 -0
- data/vendor/assets/components/Keypress/keypress-2.1.0.min.js +33 -0
- data/vendor/assets/components/Keypress/keypress.coffee +921 -0
- data/vendor/assets/components/Keypress/keypress.js +1132 -0
- data/vendor/assets/components/Keypress/package.json +15 -0
- data/vendor/assets/components/attachejs/attache-jquery.js +47 -0
- data/vendor/assets/components/attachejs/attache-knockout.js +56 -0
- data/vendor/assets/components/attachejs/attache.css +10 -0
- data/vendor/assets/components/attachejs/attache.js +589 -0
- data/vendor/assets/components/attachejs/bower.json +36 -0
- data/vendor/assets/components/humane-js/bower.json +8 -0
- data/vendor/assets/components/humane-js/changelog.md +165 -0
- data/vendor/assets/components/humane-js/humane.js +238 -0
- data/vendor/assets/components/humane-js/humane.min.js +11 -0
- data/vendor/assets/components/humane-js/index.html +190 -0
- data/vendor/assets/components/humane-js/package.json +25 -0
- data/vendor/assets/components/humane-js/readme.md +85 -0
- data/vendor/assets/components/humane-js/test/issue23.html +11 -0
- data/vendor/assets/components/humane-js/test/issue36.html +9 -0
- data/vendor/assets/components/humane-js/test/issue38.html +15 -0
- data/vendor/assets/components/humane-js/test/issue49.html +9 -0
- data/vendor/assets/components/humane-js/theme-src/bigbox.styl +65 -0
- data/vendor/assets/components/humane-js/theme-src/boldlight.styl +64 -0
- data/vendor/assets/components/humane-js/theme-src/jackedup.styl +69 -0
- data/vendor/assets/components/humane-js/theme-src/libnotify.styl +61 -0
- data/vendor/assets/components/humane-js/theme-src/original.styl +51 -0
- data/vendor/assets/components/humane-js/themes/bigbox.css +123 -0
- data/vendor/assets/components/humane-js/themes/boldlight.css +122 -0
- data/vendor/assets/components/humane-js/themes/flatty.css +94 -0
- data/vendor/assets/components/humane-js/themes/jackedup.css +123 -0
- data/vendor/assets/components/humane-js/themes/libnotify.css +115 -0
- data/vendor/assets/components/humane-js/themes/original.css +72 -0
- data/vendor/assets/components/knockout-sortable/README.md +129 -0
- data/vendor/assets/components/knockout-sortable/bower.json +15 -0
- data/vendor/assets/components/knockout-sortable/build/knockout-sortable.js +358 -0
- data/vendor/assets/components/knockout-sortable/build/knockout-sortable.min.js +2 -0
- data/vendor/assets/components/uri.js/README.md +437 -0
- data/vendor/assets/components/uri.js/URI.jquery.json +38 -0
- data/vendor/assets/components/uri.js/about-uris.html +156 -0
- data/vendor/assets/components/uri.js/build.html +66 -0
- data/vendor/assets/components/uri.js/build.js +78 -0
- data/vendor/assets/components/uri.js/component.json +15 -0
- data/vendor/assets/components/uri.js/contribute.md +11 -0
- data/vendor/assets/components/uri.js/docs.html +1280 -0
- data/vendor/assets/components/uri.js/index.html +173 -0
- data/vendor/assets/components/uri.js/jquery-1.10.2.min.js +6 -0
- data/vendor/assets/components/uri.js/jquery-1.7.2.min.js +4 -0
- data/vendor/assets/components/uri.js/jquery-1.8.2.min.js +2 -0
- data/vendor/assets/components/uri.js/jquery-1.9.1.min.js +5 -0
- data/vendor/assets/components/uri.js/jquery-uri-plugin.html +203 -0
- data/vendor/assets/components/uri.js/package.json +75 -0
- data/vendor/assets/components/uri.js/prettify/lang-apollo.js +2 -0
- data/vendor/assets/components/uri.js/prettify/lang-clj.js +18 -0
- data/vendor/assets/components/uri.js/prettify/lang-css.js +2 -0
- data/vendor/assets/components/uri.js/prettify/lang-go.js +1 -0
- data/vendor/assets/components/uri.js/prettify/lang-hs.js +2 -0
- data/vendor/assets/components/uri.js/prettify/lang-lisp.js +3 -0
- data/vendor/assets/components/uri.js/prettify/lang-lua.js +2 -0
- data/vendor/assets/components/uri.js/prettify/lang-ml.js +2 -0
- data/vendor/assets/components/uri.js/prettify/lang-n.js +4 -0
- data/vendor/assets/components/uri.js/prettify/lang-proto.js +1 -0
- data/vendor/assets/components/uri.js/prettify/lang-scala.js +2 -0
- data/vendor/assets/components/uri.js/prettify/lang-sql.js +2 -0
- data/vendor/assets/components/uri.js/prettify/lang-tex.js +1 -0
- data/vendor/assets/components/uri.js/prettify/lang-vb.js +2 -0
- data/vendor/assets/components/uri.js/prettify/lang-vhdl.js +3 -0
- data/vendor/assets/components/uri.js/prettify/lang-wiki.js +2 -0
- data/vendor/assets/components/uri.js/prettify/lang-xq.js +3 -0
- data/vendor/assets/components/uri.js/prettify/lang-yaml.js +2 -0
- data/vendor/assets/components/uri.js/prettify/prettify.css +1 -0
- data/vendor/assets/components/uri.js/prettify/prettify.js +28 -0
- data/vendor/assets/components/uri.js/prettify/prettify.sunburst.css +52 -0
- data/vendor/assets/components/uri.js/screen.css +167 -0
- data/vendor/assets/components/uri.js/screen.js +39 -0
- data/vendor/assets/components/uri.js/src/IPv6.js +185 -0
- data/vendor/assets/components/uri.js/src/SecondLevelDomains.js +220 -0
- data/vendor/assets/components/uri.js/src/URI.fragmentQuery.js +103 -0
- data/vendor/assets/components/uri.js/src/URI.fragmentURI.js +96 -0
- data/vendor/assets/components/uri.js/src/URI.js +1938 -0
- data/vendor/assets/components/uri.js/src/URI.min.js +81 -0
- data/vendor/assets/components/uri.js/src/URITemplate.js +494 -0
- data/vendor/assets/components/uri.js/src/jquery.URI.js +232 -0
- data/vendor/assets/components/uri.js/src/jquery.URI.min.js +7 -0
- data/vendor/assets/components/uri.js/src/punycode.js +508 -0
- data/vendor/assets/components/uri.js/test/index.html +26 -0
- data/vendor/assets/components/uri.js/test/pre_libs.js +4 -0
- data/vendor/assets/components/uri.js/test/qunit/qunit-composite.css +13 -0
- data/vendor/assets/components/uri.js/test/qunit/qunit-composite.js +167 -0
- data/vendor/assets/components/uri.js/test/qunit/qunit.css +244 -0
- data/vendor/assets/components/uri.js/test/qunit/qunit.js +2212 -0
- data/vendor/assets/components/uri.js/test/test.URI.html +26 -0
- data/vendor/assets/components/uri.js/test/test.fragmentQuery.html +31 -0
- data/vendor/assets/components/uri.js/test/test.fragmentURI.html +31 -0
- data/vendor/assets/components/uri.js/test/test.jQuery-1.10.html +31 -0
- data/vendor/assets/components/uri.js/test/test.jQuery-1.7.html +31 -0
- data/vendor/assets/components/uri.js/test/test.jQuery-1.8.html +31 -0
- data/vendor/assets/components/uri.js/test/test.jQuery-1.9.html +31 -0
- data/vendor/assets/components/uri.js/test/test.js +1409 -0
- data/vendor/assets/components/uri.js/test/test_fragmentQuery.js +57 -0
- data/vendor/assets/components/uri.js/test/test_fragmentURI.js +59 -0
- data/vendor/assets/components/uri.js/test/test_jim.js +143 -0
- data/vendor/assets/components/uri.js/test/test_jquery.js +138 -0
- data/vendor/assets/components/uri.js/test/test_template.js +385 -0
- data/vendor/assets/components/uri.js/test/urls.js +1236 -0
- data/vendor/assets/components/uri.js/uri-template.html +234 -0
- data/vendor/assets/components/uri.js/utils/SLDs.php +37 -0
- data/vendor/assets/components/uri.js/utils/sld.js +101 -0
- data/vendor/assets/components/veiljs/bower.json +36 -0
- data/vendor/assets/components/veiljs/veil-jquery.js +47 -0
- data/vendor/assets/components/veiljs/veil-knockout.js +55 -0
- data/vendor/assets/components/veiljs/veil.js +465 -0
- data/vendor/assets/javascripts/fuse.js +472 -0
- data/vendor/assets/javascripts/jquery-ui.js +3844 -0
- data/vendor/assets/javascripts/knockout-3.2.0-debug.js +5299 -0
- data/vendor/assets/javascripts/moment.js +1902 -0
- data/vendor/assets/javascripts/pikaday.js +896 -0
- data/vendor/assets/stylesheets/pikaday.css +171 -0
- metadata +120 -1
@@ -0,0 +1,358 @@
|
|
1
|
+
// knockout-sortable 0.9.3 | (c) 2014 Ryan Niemeyer | http://www.opensource.org/licenses/mit-license
|
2
|
+
;(function(factory) {
|
3
|
+
if (typeof define === "function" && define.amd) {
|
4
|
+
// AMD anonymous module
|
5
|
+
define(["knockout", "jquery", "jquery.ui.sortable"], factory);
|
6
|
+
} else if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
|
7
|
+
// CommonJS module
|
8
|
+
var ko = require("knockout"),
|
9
|
+
jQuery = require("jquery");
|
10
|
+
require("jquery.ui.sortable");
|
11
|
+
factory(ko, jQuery);
|
12
|
+
} else {
|
13
|
+
// No module loader (plain <script> tag) - put directly in global namespace
|
14
|
+
factory(window.ko, window.jQuery);
|
15
|
+
}
|
16
|
+
})(function(ko, $) {
|
17
|
+
var ITEMKEY = "ko_sortItem",
|
18
|
+
INDEXKEY = "ko_sourceIndex",
|
19
|
+
LISTKEY = "ko_sortList",
|
20
|
+
PARENTKEY = "ko_parentList",
|
21
|
+
DRAGKEY = "ko_dragItem",
|
22
|
+
unwrap = ko.utils.unwrapObservable,
|
23
|
+
dataGet = ko.utils.domData.get,
|
24
|
+
dataSet = ko.utils.domData.set,
|
25
|
+
version = $.ui && $.ui.version,
|
26
|
+
//1.8.24 included a fix for how events were triggered in nested sortables. indexOf checks will fail if version starts with that value (0 vs. -1)
|
27
|
+
hasNestedSortableFix = version && version.indexOf("1.6.") && version.indexOf("1.7.") && (version.indexOf("1.8.") || version === "1.8.24");
|
28
|
+
|
29
|
+
//internal afterRender that adds meta-data to children
|
30
|
+
var addMetaDataAfterRender = function(elements, data) {
|
31
|
+
ko.utils.arrayForEach(elements, function(element) {
|
32
|
+
if (element.nodeType === 1) {
|
33
|
+
dataSet(element, ITEMKEY, data);
|
34
|
+
dataSet(element, PARENTKEY, dataGet(element.parentNode, LISTKEY));
|
35
|
+
}
|
36
|
+
});
|
37
|
+
};
|
38
|
+
|
39
|
+
//prepare the proper options for the template binding
|
40
|
+
var prepareTemplateOptions = function(valueAccessor, dataName) {
|
41
|
+
var result = {},
|
42
|
+
options = unwrap(valueAccessor()) || {},
|
43
|
+
actualAfterRender;
|
44
|
+
|
45
|
+
//build our options to pass to the template engine
|
46
|
+
if (options.data) {
|
47
|
+
result[dataName] = options.data;
|
48
|
+
result.name = options.template;
|
49
|
+
} else {
|
50
|
+
result[dataName] = valueAccessor();
|
51
|
+
}
|
52
|
+
|
53
|
+
ko.utils.arrayForEach(["afterAdd", "afterRender", "as", "beforeRemove", "includeDestroyed", "templateEngine", "templateOptions"], function (option) {
|
54
|
+
result[option] = options[option] || ko.bindingHandlers.sortable[option];
|
55
|
+
});
|
56
|
+
|
57
|
+
//use an afterRender function to add meta-data
|
58
|
+
if (dataName === "foreach") {
|
59
|
+
if (result.afterRender) {
|
60
|
+
//wrap the existing function, if it was passed
|
61
|
+
actualAfterRender = result.afterRender;
|
62
|
+
result.afterRender = function(element, data) {
|
63
|
+
addMetaDataAfterRender.call(data, element, data);
|
64
|
+
actualAfterRender.call(data, element, data);
|
65
|
+
};
|
66
|
+
} else {
|
67
|
+
result.afterRender = addMetaDataAfterRender;
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
//return options to pass to the template binding
|
72
|
+
return result;
|
73
|
+
};
|
74
|
+
|
75
|
+
var updateIndexFromDestroyedItems = function(index, items) {
|
76
|
+
var unwrapped = unwrap(items);
|
77
|
+
|
78
|
+
if (unwrapped) {
|
79
|
+
for (var i = 0; i < index; i++) {
|
80
|
+
//add one for every destroyed item we find before the targetIndex in the target array
|
81
|
+
if (unwrapped[i] && unwrap(unwrapped[i]._destroy)) {
|
82
|
+
index++;
|
83
|
+
}
|
84
|
+
}
|
85
|
+
}
|
86
|
+
|
87
|
+
return index;
|
88
|
+
};
|
89
|
+
|
90
|
+
//remove problematic leading/trailing whitespace from templates
|
91
|
+
var stripTemplateWhitespace = function(element, name) {
|
92
|
+
var templateSource,
|
93
|
+
templateElement;
|
94
|
+
|
95
|
+
//process named templates
|
96
|
+
if (name) {
|
97
|
+
templateElement = document.getElementById(name);
|
98
|
+
if (templateElement) {
|
99
|
+
templateSource = new ko.templateSources.domElement(templateElement);
|
100
|
+
templateSource.text($.trim(templateSource.text()));
|
101
|
+
}
|
102
|
+
}
|
103
|
+
else {
|
104
|
+
//remove leading/trailing non-elements from anonymous templates
|
105
|
+
$(element).contents().each(function() {
|
106
|
+
if (this && this.nodeType !== 1) {
|
107
|
+
element.removeChild(this);
|
108
|
+
}
|
109
|
+
});
|
110
|
+
}
|
111
|
+
};
|
112
|
+
|
113
|
+
//connect items with observableArrays
|
114
|
+
ko.bindingHandlers.sortable = {
|
115
|
+
init: function(element, valueAccessor, allBindingsAccessor, data, context) {
|
116
|
+
var $element = $(element),
|
117
|
+
value = unwrap(valueAccessor()) || {},
|
118
|
+
templateOptions = prepareTemplateOptions(valueAccessor, "foreach"),
|
119
|
+
sortable = {},
|
120
|
+
startActual, updateActual;
|
121
|
+
|
122
|
+
stripTemplateWhitespace(element, templateOptions.name);
|
123
|
+
|
124
|
+
//build a new object that has the global options with overrides from the binding
|
125
|
+
$.extend(true, sortable, ko.bindingHandlers.sortable);
|
126
|
+
if (value.options && sortable.options) {
|
127
|
+
ko.utils.extend(sortable.options, value.options);
|
128
|
+
delete value.options;
|
129
|
+
}
|
130
|
+
ko.utils.extend(sortable, value);
|
131
|
+
|
132
|
+
//if allowDrop is an observable or a function, then execute it in a computed observable
|
133
|
+
if (sortable.connectClass && (ko.isObservable(sortable.allowDrop) || typeof sortable.allowDrop == "function")) {
|
134
|
+
ko.computed({
|
135
|
+
read: function() {
|
136
|
+
var value = unwrap(sortable.allowDrop),
|
137
|
+
shouldAdd = typeof value == "function" ? value.call(this, templateOptions.foreach) : value;
|
138
|
+
ko.utils.toggleDomNodeCssClass(element, sortable.connectClass, shouldAdd);
|
139
|
+
},
|
140
|
+
disposeWhenNodeIsRemoved: element
|
141
|
+
}, this);
|
142
|
+
} else {
|
143
|
+
ko.utils.toggleDomNodeCssClass(element, sortable.connectClass, sortable.allowDrop);
|
144
|
+
}
|
145
|
+
|
146
|
+
//wrap the template binding
|
147
|
+
ko.bindingHandlers.template.init(element, function() { return templateOptions; }, allBindingsAccessor, data, context);
|
148
|
+
|
149
|
+
//keep a reference to start/update functions that might have been passed in
|
150
|
+
startActual = sortable.options.start;
|
151
|
+
updateActual = sortable.options.update;
|
152
|
+
|
153
|
+
//initialize sortable binding after template binding has rendered in update function
|
154
|
+
var createTimeout = setTimeout(function() {
|
155
|
+
var dragItem;
|
156
|
+
$element.sortable(ko.utils.extend(sortable.options, {
|
157
|
+
start: function(event, ui) {
|
158
|
+
//track original index
|
159
|
+
var el = ui.item[0];
|
160
|
+
dataSet(el, INDEXKEY, ko.utils.arrayIndexOf(ui.item.parent().children(), el));
|
161
|
+
|
162
|
+
//make sure that fields have a chance to update model
|
163
|
+
ui.item.find("input:focus").change();
|
164
|
+
if (startActual) {
|
165
|
+
startActual.apply(this, arguments);
|
166
|
+
}
|
167
|
+
},
|
168
|
+
receive: function(event, ui) {
|
169
|
+
dragItem = dataGet(ui.item[0], DRAGKEY);
|
170
|
+
if (dragItem) {
|
171
|
+
//copy the model item, if a clone option is provided
|
172
|
+
if (dragItem.clone) {
|
173
|
+
dragItem = dragItem.clone();
|
174
|
+
}
|
175
|
+
|
176
|
+
//configure a handler to potentially manipulate item before drop
|
177
|
+
if (sortable.dragged) {
|
178
|
+
dragItem = sortable.dragged.call(this, dragItem, event, ui) || dragItem;
|
179
|
+
}
|
180
|
+
}
|
181
|
+
},
|
182
|
+
update: function(event, ui) {
|
183
|
+
var sourceParent, targetParent, sourceIndex, targetIndex, arg,
|
184
|
+
el = ui.item[0],
|
185
|
+
parentEl = ui.item.parent()[0],
|
186
|
+
item = dataGet(el, ITEMKEY) || dragItem;
|
187
|
+
|
188
|
+
dragItem = null;
|
189
|
+
|
190
|
+
//make sure that moves only run once, as update fires on multiple containers
|
191
|
+
if (item && (this === parentEl) || (!hasNestedSortableFix && $.contains(this, parentEl))) {
|
192
|
+
//identify parents
|
193
|
+
sourceParent = dataGet(el, PARENTKEY);
|
194
|
+
sourceIndex = dataGet(el, INDEXKEY);
|
195
|
+
targetParent = dataGet(el.parentNode, LISTKEY);
|
196
|
+
targetIndex = ko.utils.arrayIndexOf(ui.item.parent().children(), el);
|
197
|
+
|
198
|
+
//take destroyed items into consideration
|
199
|
+
if (!templateOptions.includeDestroyed) {
|
200
|
+
sourceIndex = updateIndexFromDestroyedItems(sourceIndex, sourceParent);
|
201
|
+
targetIndex = updateIndexFromDestroyedItems(targetIndex, targetParent);
|
202
|
+
}
|
203
|
+
|
204
|
+
//build up args for the callbacks
|
205
|
+
if (sortable.beforeMove || sortable.afterMove) {
|
206
|
+
arg = {
|
207
|
+
item: item,
|
208
|
+
sourceParent: sourceParent,
|
209
|
+
sourceParentNode: sourceParent && ui.sender || el.parentNode,
|
210
|
+
sourceIndex: sourceIndex,
|
211
|
+
targetParent: targetParent,
|
212
|
+
targetIndex: targetIndex,
|
213
|
+
cancelDrop: false
|
214
|
+
};
|
215
|
+
|
216
|
+
//execute the configured callback prior to actually moving items
|
217
|
+
if (sortable.beforeMove) {
|
218
|
+
sortable.beforeMove.call(this, arg, event, ui);
|
219
|
+
}
|
220
|
+
}
|
221
|
+
|
222
|
+
//call cancel on the correct list, so KO can take care of DOM manipulation
|
223
|
+
if (sourceParent) {
|
224
|
+
$(sourceParent === targetParent ? this : ui.sender || this).sortable("cancel");
|
225
|
+
}
|
226
|
+
//for a draggable item just remove the element
|
227
|
+
else {
|
228
|
+
$(el).remove();
|
229
|
+
}
|
230
|
+
|
231
|
+
//if beforeMove told us to cancel, then we are done
|
232
|
+
if (arg && arg.cancelDrop) {
|
233
|
+
return;
|
234
|
+
}
|
235
|
+
|
236
|
+
//do the actual move
|
237
|
+
if (targetIndex >= 0) {
|
238
|
+
if (sourceParent) {
|
239
|
+
sourceParent.splice(sourceIndex, 1);
|
240
|
+
|
241
|
+
//if using deferred updates plugin, force updates
|
242
|
+
if (ko.processAllDeferredBindingUpdates) {
|
243
|
+
ko.processAllDeferredBindingUpdates();
|
244
|
+
}
|
245
|
+
}
|
246
|
+
|
247
|
+
targetParent.splice(targetIndex, 0, item);
|
248
|
+
}
|
249
|
+
|
250
|
+
//rendering is handled by manipulating the observableArray; ignore dropped element
|
251
|
+
dataSet(el, ITEMKEY, null);
|
252
|
+
|
253
|
+
//if using deferred updates plugin, force updates
|
254
|
+
if (ko.processAllDeferredBindingUpdates) {
|
255
|
+
ko.processAllDeferredBindingUpdates();
|
256
|
+
}
|
257
|
+
|
258
|
+
//allow binding to accept a function to execute after moving the item
|
259
|
+
if (sortable.afterMove) {
|
260
|
+
sortable.afterMove.call(this, arg, event, ui);
|
261
|
+
}
|
262
|
+
}
|
263
|
+
|
264
|
+
if (updateActual) {
|
265
|
+
updateActual.apply(this, arguments);
|
266
|
+
}
|
267
|
+
},
|
268
|
+
connectWith: sortable.connectClass ? "." + sortable.connectClass : false
|
269
|
+
}));
|
270
|
+
|
271
|
+
//handle enabling/disabling sorting
|
272
|
+
if (sortable.isEnabled !== undefined) {
|
273
|
+
ko.computed({
|
274
|
+
read: function() {
|
275
|
+
$element.sortable(unwrap(sortable.isEnabled) ? "enable" : "disable");
|
276
|
+
},
|
277
|
+
disposeWhenNodeIsRemoved: element
|
278
|
+
});
|
279
|
+
}
|
280
|
+
}, 0);
|
281
|
+
|
282
|
+
//handle disposal
|
283
|
+
ko.utils.domNodeDisposal.addDisposeCallback(element, function() {
|
284
|
+
//only call destroy if sortable has been created
|
285
|
+
if ($element.data("ui-sortable") || $element.data("sortable")) {
|
286
|
+
$element.sortable("destroy");
|
287
|
+
}
|
288
|
+
|
289
|
+
//do not create the sortable if the element has been removed from DOM
|
290
|
+
clearTimeout(createTimeout);
|
291
|
+
});
|
292
|
+
|
293
|
+
return { 'controlsDescendantBindings': true };
|
294
|
+
},
|
295
|
+
update: function(element, valueAccessor, allBindingsAccessor, data, context) {
|
296
|
+
var templateOptions = prepareTemplateOptions(valueAccessor, "foreach");
|
297
|
+
|
298
|
+
//attach meta-data
|
299
|
+
dataSet(element, LISTKEY, templateOptions.foreach);
|
300
|
+
|
301
|
+
//call template binding's update with correct options
|
302
|
+
ko.bindingHandlers.template.update(element, function() { return templateOptions; }, allBindingsAccessor, data, context);
|
303
|
+
},
|
304
|
+
connectClass: 'ko_container',
|
305
|
+
allowDrop: true,
|
306
|
+
afterMove: null,
|
307
|
+
beforeMove: null,
|
308
|
+
options: {}
|
309
|
+
};
|
310
|
+
|
311
|
+
//create a draggable that is appropriate for dropping into a sortable
|
312
|
+
ko.bindingHandlers.draggable = {
|
313
|
+
init: function(element, valueAccessor, allBindingsAccessor, data, context) {
|
314
|
+
var value = unwrap(valueAccessor()) || {},
|
315
|
+
options = value.options || {},
|
316
|
+
draggableOptions = ko.utils.extend({}, ko.bindingHandlers.draggable.options),
|
317
|
+
templateOptions = prepareTemplateOptions(valueAccessor, "data"),
|
318
|
+
connectClass = value.connectClass || ko.bindingHandlers.draggable.connectClass,
|
319
|
+
isEnabled = value.isEnabled !== undefined ? value.isEnabled : ko.bindingHandlers.draggable.isEnabled;
|
320
|
+
|
321
|
+
value = "data" in value ? value.data : value;
|
322
|
+
|
323
|
+
//set meta-data
|
324
|
+
dataSet(element, DRAGKEY, value);
|
325
|
+
|
326
|
+
//override global options with override options passed in
|
327
|
+
ko.utils.extend(draggableOptions, options);
|
328
|
+
|
329
|
+
//setup connection to a sortable
|
330
|
+
draggableOptions.connectToSortable = connectClass ? "." + connectClass : false;
|
331
|
+
|
332
|
+
//initialize draggable
|
333
|
+
$(element).draggable(draggableOptions);
|
334
|
+
|
335
|
+
//handle enabling/disabling sorting
|
336
|
+
if (isEnabled !== undefined) {
|
337
|
+
ko.computed({
|
338
|
+
read: function() {
|
339
|
+
$(element).draggable(unwrap(isEnabled) ? "enable" : "disable");
|
340
|
+
},
|
341
|
+
disposeWhenNodeIsRemoved: element
|
342
|
+
});
|
343
|
+
}
|
344
|
+
|
345
|
+
return ko.bindingHandlers.template.init(element, function() { return templateOptions; }, allBindingsAccessor, data, context);
|
346
|
+
},
|
347
|
+
update: function(element, valueAccessor, allBindingsAccessor, data, context) {
|
348
|
+
var templateOptions = prepareTemplateOptions(valueAccessor, "data");
|
349
|
+
|
350
|
+
return ko.bindingHandlers.template.update(element, function() { return templateOptions; }, allBindingsAccessor, data, context);
|
351
|
+
},
|
352
|
+
connectClass: ko.bindingHandlers.sortable.connectClass,
|
353
|
+
options: {
|
354
|
+
helper: "clone"
|
355
|
+
}
|
356
|
+
};
|
357
|
+
|
358
|
+
});
|
@@ -0,0 +1,2 @@
|
|
1
|
+
// knockout-sortable 0.9.3 | (c) 2014 Ryan Niemeyer | http://www.opensource.org/licenses/mit-license
|
2
|
+
!function(a){if("function"==typeof define&&define.amd)define(["knockout","jquery","jquery.ui.sortable"],a);else if("function"==typeof require&&"object"==typeof exports&&"object"==typeof module){var b=require("knockout"),c=require("jquery");require("jquery.ui.sortable"),a(b,c)}else a(window.ko,window.jQuery)}(function(a,b){var c="ko_sortItem",d="ko_sourceIndex",e="ko_sortList",f="ko_parentList",g="ko_dragItem",h=a.utils.unwrapObservable,i=a.utils.domData.get,j=a.utils.domData.set,k=b.ui&&b.ui.version,l=k&&k.indexOf("1.6.")&&k.indexOf("1.7.")&&(k.indexOf("1.8.")||"1.8.24"===k),m=function(b,d){a.utils.arrayForEach(b,function(a){1===a.nodeType&&(j(a,c,d),j(a,f,i(a.parentNode,e)))})},n=function(b,c){var d,e={},f=h(b())||{};return f.data?(e[c]=f.data,e.name=f.template):e[c]=b(),a.utils.arrayForEach(["afterAdd","afterRender","as","beforeRemove","includeDestroyed","templateEngine","templateOptions"],function(b){e[b]=f[b]||a.bindingHandlers.sortable[b]}),"foreach"===c&&(e.afterRender?(d=e.afterRender,e.afterRender=function(a,b){m.call(b,a,b),d.call(b,a,b)}):e.afterRender=m),e},o=function(a,b){var c=h(b);if(c)for(var d=0;a>d;d++)c[d]&&h(c[d]._destroy)&&a++;return a},p=function(c,d){var e,f;d?(f=document.getElementById(d),f&&(e=new a.templateSources.domElement(f),e.text(b.trim(e.text())))):b(c).contents().each(function(){this&&1!==this.nodeType&&c.removeChild(this)})};a.bindingHandlers.sortable={init:function(k,m,q,r,s){var t,u,v=b(k),w=h(m())||{},x=n(m,"foreach"),y={};p(k,x.name),b.extend(!0,y,a.bindingHandlers.sortable),w.options&&y.options&&(a.utils.extend(y.options,w.options),delete w.options),a.utils.extend(y,w),y.connectClass&&(a.isObservable(y.allowDrop)||"function"==typeof y.allowDrop)?a.computed({read:function(){var b=h(y.allowDrop),c="function"==typeof b?b.call(this,x.foreach):b;a.utils.toggleDomNodeCssClass(k,y.connectClass,c)},disposeWhenNodeIsRemoved:k},this):a.utils.toggleDomNodeCssClass(k,y.connectClass,y.allowDrop),a.bindingHandlers.template.init(k,function(){return x},q,r,s),t=y.options.start,u=y.options.update;var z=setTimeout(function(){var m;v.sortable(a.utils.extend(y.options,{start:function(b,c){var e=c.item[0];j(e,d,a.utils.arrayIndexOf(c.item.parent().children(),e)),c.item.find("input:focus").change(),t&&t.apply(this,arguments)},receive:function(a,b){m=i(b.item[0],g),m&&(m.clone&&(m=m.clone()),y.dragged&&(m=y.dragged.call(this,m,a,b)||m))},update:function(g,h){var k,n,p,q,r,s=h.item[0],t=h.item.parent()[0],v=i(s,c)||m;if(m=null,v&&this===t||!l&&b.contains(this,t)){if(k=i(s,f),p=i(s,d),n=i(s.parentNode,e),q=a.utils.arrayIndexOf(h.item.parent().children(),s),x.includeDestroyed||(p=o(p,k),q=o(q,n)),(y.beforeMove||y.afterMove)&&(r={item:v,sourceParent:k,sourceParentNode:k&&h.sender||s.parentNode,sourceIndex:p,targetParent:n,targetIndex:q,cancelDrop:!1},y.beforeMove&&y.beforeMove.call(this,r,g,h)),k?b(k===n?this:h.sender||this).sortable("cancel"):b(s).remove(),r&&r.cancelDrop)return;q>=0&&(k&&(k.splice(p,1),a.processAllDeferredBindingUpdates&&a.processAllDeferredBindingUpdates()),n.splice(q,0,v)),j(s,c,null),a.processAllDeferredBindingUpdates&&a.processAllDeferredBindingUpdates(),y.afterMove&&y.afterMove.call(this,r,g,h)}u&&u.apply(this,arguments)},connectWith:y.connectClass?"."+y.connectClass:!1})),void 0!==y.isEnabled&&a.computed({read:function(){v.sortable(h(y.isEnabled)?"enable":"disable")},disposeWhenNodeIsRemoved:k})},0);return a.utils.domNodeDisposal.addDisposeCallback(k,function(){(v.data("ui-sortable")||v.data("sortable"))&&v.sortable("destroy"),clearTimeout(z)}),{controlsDescendantBindings:!0}},update:function(b,c,d,f,g){var h=n(c,"foreach");j(b,e,h.foreach),a.bindingHandlers.template.update(b,function(){return h},d,f,g)},connectClass:"ko_container",allowDrop:!0,afterMove:null,beforeMove:null,options:{}},a.bindingHandlers.draggable={init:function(c,d,e,f,i){var k=h(d())||{},l=k.options||{},m=a.utils.extend({},a.bindingHandlers.draggable.options),o=n(d,"data"),p=k.connectClass||a.bindingHandlers.draggable.connectClass,q=void 0!==k.isEnabled?k.isEnabled:a.bindingHandlers.draggable.isEnabled;return k="data"in k?k.data:k,j(c,g,k),a.utils.extend(m,l),m.connectToSortable=p?"."+p:!1,b(c).draggable(m),void 0!==q&&a.computed({read:function(){b(c).draggable(h(q)?"enable":"disable")},disposeWhenNodeIsRemoved:c}),a.bindingHandlers.template.init(c,function(){return o},e,f,i)},update:function(b,c,d,e,f){var g=n(c,"data");return a.bindingHandlers.template.update(b,function(){return g},d,e,f)},connectClass:a.bindingHandlers.sortable.connectClass,options:{helper:"clone"}}});
|