diff --git a/bower.json b/bower.json index 715de45..6d8cb63 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "knockout-sortable", - "version": "0.9.0", + "version": "0.9.1", "main": "./build/knockout-sortable.min.js", "ignore": [ "examples", diff --git a/build/knockout-sortable.js b/build/knockout-sortable.js index 64d1d50..fe4a152 100644 --- a/build/knockout-sortable.js +++ b/build/knockout-sortable.js @@ -1,4 +1,4 @@ -// knockout-sortable 0.9.0 | (c) 2014 Ryan Niemeyer | http://www.opensource.org/licenses/mit-license +// knockout-sortable 0.9.1 | (c) 2014 Ryan Niemeyer | http://www.opensource.org/licenses/mit-license ;(function(factory) { if (typeof define === "function" && define.amd) { // AMD anonymous module @@ -309,7 +309,7 @@ connectClass = value.connectClass || ko.bindingHandlers.draggable.connectClass, isEnabled = value.isEnabled !== undefined ? value.isEnabled : ko.bindingHandlers.draggable.isEnabled; - value = value.data || value; + value = "data" in value ? value.data : value; //set meta-data dataSet(element, DRAGKEY, value); diff --git a/build/knockout-sortable.min.js b/build/knockout-sortable.min.js index 4cebabc..10bd0f8 100644 --- a/build/knockout-sortable.min.js +++ b/build/knockout-sortable.min.js @@ -1,2 +1,2 @@ -// knockout-sortable 0.9.0 | (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=function(b,d){a.utils.arrayForEach(b,function(a){1===a.nodeType&&(j(a,c,d),j(a,f,i(a.parentNode,e)))})},l=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){k.call(b,a,b),d.call(b,a,b)}):e.afterRender=k),e},m=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},n=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,o,p,q,r){var s,t,u=b(k),v=h(o())||{},w=l(o,"foreach"),x={};n(k,w.name),b.extend(!0,x,a.bindingHandlers.sortable),v.options&&x.options&&(a.utils.extend(x.options,v.options),delete v.options),a.utils.extend(x,v),x.connectClass&&(a.isObservable(x.allowDrop)||"function"==typeof x.allowDrop)?a.computed({read:function(){var b=h(x.allowDrop),c="function"==typeof b?b.call(this,w.foreach):b;a.utils.toggleDomNodeCssClass(k,x.connectClass,c)},disposeWhenNodeIsRemoved:k},this):a.utils.toggleDomNodeCssClass(k,x.connectClass,x.allowDrop),a.bindingHandlers.template.init(k,function(){return w},p,q,r),s=x.options.start,t=x.options.update;var y=setTimeout(function(){var l;u.sortable(a.utils.extend(x.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(),s&&s.apply(this,arguments)},receive:function(a,b){l=i(b.item[0],g),l&&(l.clone&&(l=l.clone()),x.dragged&&(l=x.dragged.call(this,l,a,b)||l))},update:function(g,h){var k,n,o,p,q,r=h.item[0],s=h.item.parent()[0],u=i(r,c)||l;if(l=null,u&&(this===s||b.contains(this,s))){if(k=i(r,f),o=i(r,d),n=i(r.parentNode,e),p=a.utils.arrayIndexOf(h.item.parent().children(),r),w.includeDestroyed||(o=m(o,k),p=m(p,n)),(x.beforeMove||x.afterMove)&&(q={item:u,sourceParent:k,sourceParentNode:k&&h.sender||r.parentNode,sourceIndex:o,targetParent:n,targetIndex:p,cancelDrop:!1},x.beforeMove&&x.beforeMove.call(this,q,g,h)),k?b(k===n?this:h.sender||this).sortable("cancel"):b(r).remove(),q&&q.cancelDrop)return;p>=0&&(k&&(k.splice(o,1),a.processAllDeferredBindingUpdates&&a.processAllDeferredBindingUpdates()),n.splice(p,0,u)),j(r,c,null),a.processAllDeferredBindingUpdates&&a.processAllDeferredBindingUpdates(),x.afterMove&&x.afterMove.call(this,q,g,h)}t&&t.apply(this,arguments)},connectWith:x.connectClass?"."+x.connectClass:!1})),void 0!==x.isEnabled&&a.computed({read:function(){u.sortable(h(x.isEnabled)?"enable":"disable")},disposeWhenNodeIsRemoved:k})},0);return a.utils.domNodeDisposal.addDisposeCallback(k,function(){(u.data("ui-sortable")||u.data("sortable"))&&u.sortable("destroy"),clearTimeout(y)}),{controlsDescendantBindings:!0}},update:function(b,c,d,f,g){var h=l(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())||{},m=k.options||{},n=a.utils.extend({},a.bindingHandlers.draggable.options),o=l(d,"data"),p=k.connectClass||a.bindingHandlers.draggable.connectClass,q=void 0!==k.isEnabled?k.isEnabled:a.bindingHandlers.draggable.isEnabled;return k=k.data||k,j(c,g,k),a.utils.extend(n,m),n.connectToSortable=p?"."+p:!1,b(c).draggable(n),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=l(c,"data");return a.bindingHandlers.template.update(b,function(){return g},d,e,f)},connectClass:a.bindingHandlers.sortable.connectClass,options:{helper:"clone"}}}); \ No newline at end of file +// knockout-sortable 0.9.1 | (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=function(b,d){a.utils.arrayForEach(b,function(a){1===a.nodeType&&(j(a,c,d),j(a,f,i(a.parentNode,e)))})},l=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){k.call(b,a,b),d.call(b,a,b)}):e.afterRender=k),e},m=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},n=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,o,p,q,r){var s,t,u=b(k),v=h(o())||{},w=l(o,"foreach"),x={};n(k,w.name),b.extend(!0,x,a.bindingHandlers.sortable),v.options&&x.options&&(a.utils.extend(x.options,v.options),delete v.options),a.utils.extend(x,v),x.connectClass&&(a.isObservable(x.allowDrop)||"function"==typeof x.allowDrop)?a.computed({read:function(){var b=h(x.allowDrop),c="function"==typeof b?b.call(this,w.foreach):b;a.utils.toggleDomNodeCssClass(k,x.connectClass,c)},disposeWhenNodeIsRemoved:k},this):a.utils.toggleDomNodeCssClass(k,x.connectClass,x.allowDrop),a.bindingHandlers.template.init(k,function(){return w},p,q,r),s=x.options.start,t=x.options.update;var y=setTimeout(function(){var l;u.sortable(a.utils.extend(x.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(),s&&s.apply(this,arguments)},receive:function(a,b){l=i(b.item[0],g),l&&(l.clone&&(l=l.clone()),x.dragged&&(l=x.dragged.call(this,l,a,b)||l))},update:function(g,h){var k,n,o,p,q,r=h.item[0],s=h.item.parent()[0],u=i(r,c)||l;if(l=null,u&&(this===s||b.contains(this,s))){if(k=i(r,f),o=i(r,d),n=i(r.parentNode,e),p=a.utils.arrayIndexOf(h.item.parent().children(),r),w.includeDestroyed||(o=m(o,k),p=m(p,n)),(x.beforeMove||x.afterMove)&&(q={item:u,sourceParent:k,sourceParentNode:k&&h.sender||r.parentNode,sourceIndex:o,targetParent:n,targetIndex:p,cancelDrop:!1},x.beforeMove&&x.beforeMove.call(this,q,g,h)),k?b(k===n?this:h.sender||this).sortable("cancel"):b(r).remove(),q&&q.cancelDrop)return;p>=0&&(k&&(k.splice(o,1),a.processAllDeferredBindingUpdates&&a.processAllDeferredBindingUpdates()),n.splice(p,0,u)),j(r,c,null),a.processAllDeferredBindingUpdates&&a.processAllDeferredBindingUpdates(),x.afterMove&&x.afterMove.call(this,q,g,h)}t&&t.apply(this,arguments)},connectWith:x.connectClass?"."+x.connectClass:!1})),void 0!==x.isEnabled&&a.computed({read:function(){u.sortable(h(x.isEnabled)?"enable":"disable")},disposeWhenNodeIsRemoved:k})},0);return a.utils.domNodeDisposal.addDisposeCallback(k,function(){(u.data("ui-sortable")||u.data("sortable"))&&u.sortable("destroy"),clearTimeout(y)}),{controlsDescendantBindings:!0}},update:function(b,c,d,f,g){var h=l(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())||{},m=k.options||{},n=a.utils.extend({},a.bindingHandlers.draggable.options),o=l(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(n,m),n.connectToSortable=p?"."+p:!1,b(c).draggable(n),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=l(c,"data");return a.bindingHandlers.template.update(b,function(){return g},d,e,f)},connectClass:a.bindingHandlers.sortable.connectClass,options:{helper:"clone"}}}); \ No newline at end of file diff --git a/package.json b/package.json index 476401f..18c8410 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "knockout-sortable", - "version": "0.9.0", + "version": "0.9.1", "devDependencies": { "grunt": "~0.4.1", "grunt-contrib-uglify": "0.x.x",