mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 20:49:20 +03:00
Merged from sub repository (filters - step 4)
This commit is contained in:
parent
67e45a6a6f
commit
e4b286e257
58 changed files with 1176 additions and 236 deletions
129
vendors/knockout-sortable/README.md
vendored
Normal file
129
vendors/knockout-sortable/README.md
vendored
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
**knockout-sortable** is a binding for [Knockout.js](http://knockoutjs.com/) designed to connect observableArrays with jQuery UI's sortable functionality. This allows a user to drag and drop items within a list or between lists and have the corresponding observableArrays updated appropriately.
|
||||
|
||||
**Basic Usage**
|
||||
|
||||
* using anonymous templates:
|
||||
|
||||
```html
|
||||
<ul data-bind="sortable: items">
|
||||
<li data-bind="text: name"></li>
|
||||
</ul>
|
||||
```
|
||||
|
||||
|
||||
* using named templates:
|
||||
|
||||
```html
|
||||
<ul data-bind="sortable: { template: 'itemTmpl', data: items }"></ul>
|
||||
<script id="itemTmpl" type="text/html"><li data-bind="text: name"></li></script>
|
||||
```
|
||||
|
||||
Note: The sortable binding assumes that the child "templates" have a single container element. You cannot use containerless bindings (comment-based) bindings at the top-level of your template, as the jQuery draggable/sortable functionality needs an element to operate on.
|
||||
|
||||
Note2: (*Update: 0.9.0 adds code to automatically strip leading/trailing whitespace*) When using named templates, you will have the best results across browsers, if you ensure that there is only a single top-level node inside your template with no surrounding text nodes. Inside of the top-level nodes, you can freely use whitespace/text nodes. So, you will want:
|
||||
|
||||
```html
|
||||
<!-- good - no text nodes surrounding template root node -->
|
||||
<script id="goodTmpl" type="text/html"><li data-bind="text: name">
|
||||
<span data-bind="text: name"></span>
|
||||
</li></script>
|
||||
|
||||
<!-- bad -->
|
||||
<script id="badTmpl" type="text/html">
|
||||
<li>
|
||||
<span data-bind="text: name"></span>
|
||||
</li>
|
||||
</script>
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
**Additional Options**
|
||||
|
||||
* **connectClass** - specify the class that should be used to indicate a droppable target. The default class is "ko_container". This value can be passed in the binding or configured globally by setting `ko.bindingHandlers.sortable.connectClass`.
|
||||
|
||||
* **allowDrop** - specify whether this container should be a target for drops. This can be a static value, observable, or a function that is passed the observableArray as its first argument. If a function is specified, then it will be executed in a computed observable, so it will run again whenever any dependencies are updated. This option can be passed in the binding or configured globally by setting `ko.bindingHandlers.sortable.allowDrop`.
|
||||
|
||||
* **beforeMove** - specify a function to execute prior to an item being moved from its original position to its new position in the data. This function receives an object for its first argument that contains the following information:
|
||||
* `arg.item` - the actual item being moved
|
||||
* `arg.sourceIndex` - the position of the item in the original observableArray
|
||||
* `arg.sourceParent` - the original observableArray
|
||||
* `arg.sourceParentNode` - the container node of the original list
|
||||
* `arg.targetIndex` - the position of the item in the destination observableArray
|
||||
* `arg.targetParent` - the destination observableArray
|
||||
* `arg.cancelDrop` - this defaults to false and can be set to true to indicate that the drop should be cancelled.
|
||||
|
||||
This option can be passed in the binding or configured globally by setting `ko.bindingHandlers.sortable.beforeMove`. This callback also receives the `event` and `ui` objects as the second and third arguments.
|
||||
|
||||
* **afterMove** - specify a function to execute after an item has been moved to its new destination. This function receives an object for its first argument that contains the following information:
|
||||
* `arg.item` - the actual item being moved
|
||||
* `arg.sourceIndex` - the position of the item in the original observableArray
|
||||
* `arg.sourceParent` - the original observableArray
|
||||
* `arg.sourceParentNode` - the container node of the original list. Useful if moving items between lists, but within a single array. The value of `this` in the callback will be the target container node.
|
||||
* `arg.targetIndex` - the position of the item in the destination observableArray
|
||||
* `arg.targetParent` - the destination observableArray
|
||||
|
||||
This option can be passed in the binding or configured globally by setting `ko.bindingHandlers.sortable.afterMove`. This callback also receives the `event` and `ui` objects as the second and third arguments.
|
||||
|
||||
* **dragged** - specify a function to execute after a draggable item has been dropped into a sortable. This callback receives the drag item as the first argument, the `event` as the second argument, and the `ui` object as the third argument. If the function returns a value, then it will be used as item that is dropped into the sortable. This can be used as an alternative to the original item including a `clone` function.
|
||||
|
||||
* **isEnabled** - specify whether the sortable widget should be enabled. If this is an observable, then it will enable/disable the widget when the observable's value changes. This option can be passed in the binding or configured globally by setting `ko.bindingHandlers.sortable.isEnabled`.
|
||||
|
||||
* **options** - specify any additional options to pass on to the `.sortable` jQuery UI call. These options can be specified in the binding or specified globally by setting `ko.bindingHandlers.sortable.options`.
|
||||
|
||||
* **afterAdd, beforeRemove, afterRender, includeDestroyed, templateEngine, as** - this binding will pass these options on to the template binding.
|
||||
|
||||
**Draggable binding**
|
||||
|
||||
This library also includes a `draggable` binding that you can place on single items that can be moved into a `sortable` collection. When the item is dropped into a sortable, the plugin will attempt to call a `clone` function on the item to make a suitable copy of it, otherwise it will use the item directly. Additionally, the `dragged` callback can be used to provide a copy of the object, as described above.
|
||||
|
||||
* using anonymous templates:
|
||||
|
||||
```html
|
||||
<div data-bind="draggable: item">
|
||||
<span data-bind="text: name"></span>
|
||||
</div>
|
||||
```
|
||||
|
||||
* using named templates:
|
||||
|
||||
```html
|
||||
<div data-bind="draggable: { template: 'itemTmpl', data: item }"></div>
|
||||
<script id="itemTmpl" type="text/html"><span data-bind="text: name"></span></script>
|
||||
```
|
||||
|
||||
**Additional Options**
|
||||
|
||||
* **connectClass** - specify a class used to indicate which sortables that this draggable should be allowed to drop into. The default class is "ko_container". This value can be passed in the binding or configured globally by setting `ko.bindingHandlers.draggable.connectClass`.
|
||||
|
||||
* **isEnabled** - specify whether the draggable widget should be enabled. If this is an observable, then it will enable/disable the widget when the observable's value changes. This option can be passed in the binding or configured globally by setting `ko.bindingHandlers.draggable.isEnabled`.
|
||||
|
||||
* **options** - specify any additional options to pass on to the `.draggable` jQuery UI call. These options can be specified in the binding or specified globally by setting `ko.bindingHandlers.draggable.options`.
|
||||
|
||||
|
||||
**Dependencies**
|
||||
|
||||
* Knockout 2.0+
|
||||
* jQuery - no specific version identified yet as minimum
|
||||
* jQuery UI - no specific version identfied yet as minimum
|
||||
|
||||
**Touch Support** - for touch support take a look at: http://touchpunch.furf.com/
|
||||
|
||||
|
||||
**Build:** This project uses [grunt](http://gruntjs.com/) for building/minifying.
|
||||
|
||||
**Examples** The `examples` directory contains samples that include a simple sortable list, connected lists, and a seating chart that takes advantage of many of the additional options.
|
||||
|
||||
**Fiddles**
|
||||
|
||||
* simple: http://jsfiddle.net/rniemeyer/hw9B2/
|
||||
* connected: http://jsfiddle.net/rniemeyer/Jr2rE/
|
||||
* draggable: http://jsfiddle.net/rniemeyer/AC49j/
|
||||
* seating chart: http://jsfiddle.net/rniemeyer/UdXr4/
|
||||
|
||||
|
||||
|
||||
**License**: MIT [http://www.opensource.org/licenses/mit-license.php](http://www.opensource.org/licenses/mit-license.php)
|
||||
352
vendors/knockout-sortable/knockout-sortable.js
vendored
Normal file
352
vendors/knockout-sortable/knockout-sortable.js
vendored
Normal file
|
|
@ -0,0 +1,352 @@
|
|||
// knockout-sortable 0.9.2 | (c) 2014 Ryan Niemeyer | http://www.opensource.org/licenses/mit-license
|
||||
;(function(factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
// AMD anonymous module
|
||||
define(["knockout", "jquery", "jquery.ui.sortable"], factory);
|
||||
} else {
|
||||
// No module loader (plain <script> tag) - put directly in global namespace
|
||||
factory(window.ko, jQuery);
|
||||
}
|
||||
})(function(ko, $) {
|
||||
var ITEMKEY = "ko_sortItem",
|
||||
INDEXKEY = "ko_sourceIndex",
|
||||
LISTKEY = "ko_sortList",
|
||||
PARENTKEY = "ko_parentList",
|
||||
DRAGKEY = "ko_dragItem",
|
||||
unwrap = ko.utils.unwrapObservable,
|
||||
dataGet = ko.utils.domData.get,
|
||||
dataSet = ko.utils.domData.set,
|
||||
version = $.ui && $.ui.version,
|
||||
//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)
|
||||
hasNestedSortableFix = version && version.indexOf("1.6.") && version.indexOf("1.7.") && (version.indexOf("1.8.") || version === "1.8.24");
|
||||
|
||||
//internal afterRender that adds meta-data to children
|
||||
var addMetaDataAfterRender = function(elements, data) {
|
||||
ko.utils.arrayForEach(elements, function(element) {
|
||||
if (element.nodeType === 1) {
|
||||
dataSet(element, ITEMKEY, data);
|
||||
dataSet(element, PARENTKEY, dataGet(element.parentNode, LISTKEY));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
//prepare the proper options for the template binding
|
||||
var prepareTemplateOptions = function(valueAccessor, dataName) {
|
||||
var result = {},
|
||||
options = unwrap(valueAccessor()) || {},
|
||||
actualAfterRender;
|
||||
|
||||
//build our options to pass to the template engine
|
||||
if (options.data) {
|
||||
result[dataName] = options.data;
|
||||
result.name = options.template;
|
||||
} else {
|
||||
result[dataName] = valueAccessor();
|
||||
}
|
||||
|
||||
ko.utils.arrayForEach(["afterAdd", "afterRender", "as", "beforeRemove", "includeDestroyed", "templateEngine", "templateOptions"], function (option) {
|
||||
result[option] = options[option] || ko.bindingHandlers.sortable[option];
|
||||
});
|
||||
|
||||
//use an afterRender function to add meta-data
|
||||
if (dataName === "foreach") {
|
||||
if (result.afterRender) {
|
||||
//wrap the existing function, if it was passed
|
||||
actualAfterRender = result.afterRender;
|
||||
result.afterRender = function(element, data) {
|
||||
addMetaDataAfterRender.call(data, element, data);
|
||||
actualAfterRender.call(data, element, data);
|
||||
};
|
||||
} else {
|
||||
result.afterRender = addMetaDataAfterRender;
|
||||
}
|
||||
}
|
||||
|
||||
//return options to pass to the template binding
|
||||
return result;
|
||||
};
|
||||
|
||||
var updateIndexFromDestroyedItems = function(index, items) {
|
||||
var unwrapped = unwrap(items);
|
||||
|
||||
if (unwrapped) {
|
||||
for (var i = 0; i < index; i++) {
|
||||
//add one for every destroyed item we find before the targetIndex in the target array
|
||||
if (unwrapped[i] && unwrap(unwrapped[i]._destroy)) {
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return index;
|
||||
};
|
||||
|
||||
//remove problematic leading/trailing whitespace from templates
|
||||
var stripTemplateWhitespace = function(element, name) {
|
||||
var templateSource,
|
||||
templateElement;
|
||||
|
||||
//process named templates
|
||||
if (name) {
|
||||
templateElement = document.getElementById(name);
|
||||
if (templateElement) {
|
||||
templateSource = new ko.templateSources.domElement(templateElement);
|
||||
templateSource.text($.trim(templateSource.text()));
|
||||
}
|
||||
}
|
||||
else {
|
||||
//remove leading/trailing non-elements from anonymous templates
|
||||
$(element).contents().each(function() {
|
||||
if (this && this.nodeType !== 1) {
|
||||
element.removeChild(this);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
//connect items with observableArrays
|
||||
ko.bindingHandlers.sortable = {
|
||||
init: function(element, valueAccessor, allBindingsAccessor, data, context) {
|
||||
var $element = $(element),
|
||||
value = unwrap(valueAccessor()) || {},
|
||||
templateOptions = prepareTemplateOptions(valueAccessor, "foreach"),
|
||||
sortable = {},
|
||||
startActual, updateActual;
|
||||
|
||||
stripTemplateWhitespace(element, templateOptions.name);
|
||||
|
||||
//build a new object that has the global options with overrides from the binding
|
||||
$.extend(true, sortable, ko.bindingHandlers.sortable);
|
||||
if (value.options && sortable.options) {
|
||||
ko.utils.extend(sortable.options, value.options);
|
||||
delete value.options;
|
||||
}
|
||||
ko.utils.extend(sortable, value);
|
||||
|
||||
//if allowDrop is an observable or a function, then execute it in a computed observable
|
||||
if (sortable.connectClass && (ko.isObservable(sortable.allowDrop) || typeof sortable.allowDrop == "function")) {
|
||||
ko.computed({
|
||||
read: function() {
|
||||
var value = unwrap(sortable.allowDrop),
|
||||
shouldAdd = typeof value == "function" ? value.call(this, templateOptions.foreach) : value;
|
||||
ko.utils.toggleDomNodeCssClass(element, sortable.connectClass, shouldAdd);
|
||||
},
|
||||
disposeWhenNodeIsRemoved: element
|
||||
}, this);
|
||||
} else {
|
||||
ko.utils.toggleDomNodeCssClass(element, sortable.connectClass, sortable.allowDrop);
|
||||
}
|
||||
|
||||
//wrap the template binding
|
||||
ko.bindingHandlers.template.init(element, function() { return templateOptions; }, allBindingsAccessor, data, context);
|
||||
|
||||
//keep a reference to start/update functions that might have been passed in
|
||||
startActual = sortable.options.start;
|
||||
updateActual = sortable.options.update;
|
||||
|
||||
//initialize sortable binding after template binding has rendered in update function
|
||||
var createTimeout = setTimeout(function() {
|
||||
var dragItem;
|
||||
$element.sortable(ko.utils.extend(sortable.options, {
|
||||
start: function(event, ui) {
|
||||
//track original index
|
||||
var el = ui.item[0];
|
||||
dataSet(el, INDEXKEY, ko.utils.arrayIndexOf(ui.item.parent().children(), el));
|
||||
|
||||
//make sure that fields have a chance to update model
|
||||
ui.item.find("input:focus").change();
|
||||
if (startActual) {
|
||||
startActual.apply(this, arguments);
|
||||
}
|
||||
},
|
||||
receive: function(event, ui) {
|
||||
dragItem = dataGet(ui.item[0], DRAGKEY);
|
||||
if (dragItem) {
|
||||
//copy the model item, if a clone option is provided
|
||||
if (dragItem.clone) {
|
||||
dragItem = dragItem.clone();
|
||||
}
|
||||
|
||||
//configure a handler to potentially manipulate item before drop
|
||||
if (sortable.dragged) {
|
||||
dragItem = sortable.dragged.call(this, dragItem, event, ui) || dragItem;
|
||||
}
|
||||
}
|
||||
},
|
||||
update: function(event, ui) {
|
||||
var sourceParent, targetParent, sourceIndex, targetIndex, arg,
|
||||
el = ui.item[0],
|
||||
parentEl = ui.item.parent()[0],
|
||||
item = dataGet(el, ITEMKEY) || dragItem;
|
||||
|
||||
dragItem = null;
|
||||
|
||||
//make sure that moves only run once, as update fires on multiple containers
|
||||
if (item && (this === parentEl) || (!hasNestedSortableFix && $.contains(this, parentEl))) {
|
||||
//identify parents
|
||||
sourceParent = dataGet(el, PARENTKEY);
|
||||
sourceIndex = dataGet(el, INDEXKEY);
|
||||
targetParent = dataGet(el.parentNode, LISTKEY);
|
||||
targetIndex = ko.utils.arrayIndexOf(ui.item.parent().children(), el);
|
||||
|
||||
//take destroyed items into consideration
|
||||
if (!templateOptions.includeDestroyed) {
|
||||
sourceIndex = updateIndexFromDestroyedItems(sourceIndex, sourceParent);
|
||||
targetIndex = updateIndexFromDestroyedItems(targetIndex, targetParent);
|
||||
}
|
||||
|
||||
//build up args for the callbacks
|
||||
if (sortable.beforeMove || sortable.afterMove) {
|
||||
arg = {
|
||||
item: item,
|
||||
sourceParent: sourceParent,
|
||||
sourceParentNode: sourceParent && ui.sender || el.parentNode,
|
||||
sourceIndex: sourceIndex,
|
||||
targetParent: targetParent,
|
||||
targetIndex: targetIndex,
|
||||
cancelDrop: false
|
||||
};
|
||||
|
||||
//execute the configured callback prior to actually moving items
|
||||
if (sortable.beforeMove) {
|
||||
sortable.beforeMove.call(this, arg, event, ui);
|
||||
}
|
||||
}
|
||||
|
||||
//call cancel on the correct list, so KO can take care of DOM manipulation
|
||||
if (sourceParent) {
|
||||
$(sourceParent === targetParent ? this : ui.sender || this).sortable("cancel");
|
||||
}
|
||||
//for a draggable item just remove the element
|
||||
else {
|
||||
$(el).remove();
|
||||
}
|
||||
|
||||
//if beforeMove told us to cancel, then we are done
|
||||
if (arg && arg.cancelDrop) {
|
||||
return;
|
||||
}
|
||||
|
||||
//do the actual move
|
||||
if (targetIndex >= 0) {
|
||||
if (sourceParent) {
|
||||
sourceParent.splice(sourceIndex, 1);
|
||||
|
||||
//if using deferred updates plugin, force updates
|
||||
if (ko.processAllDeferredBindingUpdates) {
|
||||
ko.processAllDeferredBindingUpdates();
|
||||
}
|
||||
}
|
||||
|
||||
targetParent.splice(targetIndex, 0, item);
|
||||
}
|
||||
|
||||
//rendering is handled by manipulating the observableArray; ignore dropped element
|
||||
dataSet(el, ITEMKEY, null);
|
||||
|
||||
//if using deferred updates plugin, force updates
|
||||
if (ko.processAllDeferredBindingUpdates) {
|
||||
ko.processAllDeferredBindingUpdates();
|
||||
}
|
||||
|
||||
//allow binding to accept a function to execute after moving the item
|
||||
if (sortable.afterMove) {
|
||||
sortable.afterMove.call(this, arg, event, ui);
|
||||
}
|
||||
}
|
||||
|
||||
if (updateActual) {
|
||||
updateActual.apply(this, arguments);
|
||||
}
|
||||
},
|
||||
connectWith: sortable.connectClass ? "." + sortable.connectClass : false
|
||||
}));
|
||||
|
||||
//handle enabling/disabling sorting
|
||||
if (sortable.isEnabled !== undefined) {
|
||||
ko.computed({
|
||||
read: function() {
|
||||
$element.sortable(unwrap(sortable.isEnabled) ? "enable" : "disable");
|
||||
},
|
||||
disposeWhenNodeIsRemoved: element
|
||||
});
|
||||
}
|
||||
}, 0);
|
||||
|
||||
//handle disposal
|
||||
ko.utils.domNodeDisposal.addDisposeCallback(element, function() {
|
||||
//only call destroy if sortable has been created
|
||||
if ($element.data("ui-sortable") || $element.data("sortable")) {
|
||||
$element.sortable("destroy");
|
||||
}
|
||||
|
||||
//do not create the sortable if the element has been removed from DOM
|
||||
clearTimeout(createTimeout);
|
||||
});
|
||||
|
||||
return { 'controlsDescendantBindings': true };
|
||||
},
|
||||
update: function(element, valueAccessor, allBindingsAccessor, data, context) {
|
||||
var templateOptions = prepareTemplateOptions(valueAccessor, "foreach");
|
||||
|
||||
//attach meta-data
|
||||
dataSet(element, LISTKEY, templateOptions.foreach);
|
||||
|
||||
//call template binding's update with correct options
|
||||
ko.bindingHandlers.template.update(element, function() { return templateOptions; }, allBindingsAccessor, data, context);
|
||||
},
|
||||
connectClass: 'ko_container',
|
||||
allowDrop: true,
|
||||
afterMove: null,
|
||||
beforeMove: null,
|
||||
options: {}
|
||||
};
|
||||
|
||||
//create a draggable that is appropriate for dropping into a sortable
|
||||
ko.bindingHandlers.draggable = {
|
||||
init: function(element, valueAccessor, allBindingsAccessor, data, context) {
|
||||
var value = unwrap(valueAccessor()) || {},
|
||||
options = value.options || {},
|
||||
draggableOptions = ko.utils.extend({}, ko.bindingHandlers.draggable.options),
|
||||
templateOptions = prepareTemplateOptions(valueAccessor, "data"),
|
||||
connectClass = value.connectClass || ko.bindingHandlers.draggable.connectClass,
|
||||
isEnabled = value.isEnabled !== undefined ? value.isEnabled : ko.bindingHandlers.draggable.isEnabled;
|
||||
|
||||
value = "data" in value ? value.data : value;
|
||||
|
||||
//set meta-data
|
||||
dataSet(element, DRAGKEY, value);
|
||||
|
||||
//override global options with override options passed in
|
||||
ko.utils.extend(draggableOptions, options);
|
||||
|
||||
//setup connection to a sortable
|
||||
draggableOptions.connectToSortable = connectClass ? "." + connectClass : false;
|
||||
|
||||
//initialize draggable
|
||||
$(element).draggable(draggableOptions);
|
||||
|
||||
//handle enabling/disabling sorting
|
||||
if (isEnabled !== undefined) {
|
||||
ko.computed({
|
||||
read: function() {
|
||||
$(element).draggable(unwrap(isEnabled) ? "enable" : "disable");
|
||||
},
|
||||
disposeWhenNodeIsRemoved: element
|
||||
});
|
||||
}
|
||||
|
||||
return ko.bindingHandlers.template.init(element, function() { return templateOptions; }, allBindingsAccessor, data, context);
|
||||
},
|
||||
update: function(element, valueAccessor, allBindingsAccessor, data, context) {
|
||||
var templateOptions = prepareTemplateOptions(valueAccessor, "data");
|
||||
|
||||
return ko.bindingHandlers.template.update(element, function() { return templateOptions; }, allBindingsAccessor, data, context);
|
||||
},
|
||||
connectClass: ko.bindingHandlers.sortable.connectClass,
|
||||
options: {
|
||||
helper: "clone"
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
2
vendors/knockout-sortable/knockout-sortable.min.js
vendored
Normal file
2
vendors/knockout-sortable/knockout-sortable.min.js
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
// knockout-sortable 0.9.2 | (c) 2014 Ryan Niemeyer | http://www.opensource.org/licenses/mit-license
|
||||
!function(a){"function"==typeof define&&define.amd?define(["knockout","jquery","jquery.ui.sortable"],a):a(window.ko,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"}}});
|
||||
13
vendors/knockout-sortable/package.json
vendored
Normal file
13
vendors/knockout-sortable/package.json
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"name": "knockout-sortable",
|
||||
"version": "0.9.2",
|
||||
"devDependencies": {
|
||||
"grunt": "~0.4.1",
|
||||
"grunt-contrib-uglify": "0.x.x",
|
||||
"grunt-contrib-jshint": "0.x.x",
|
||||
"grunt-contrib-watch": "0.x.x",
|
||||
"grunt-contrib-concat": "0.x.x",
|
||||
"grunt-contrib-jasmine": "0.x.x",
|
||||
"grunt-template-jasmine-istanbul": "0.x.x"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue