/*! * Nestable jQuery Plugin - Copyright (c) 2012 David Bushell - http://dbushell.com/ * Dual-licensed under the BSD or MIT licenses */ !function(a,b,c,d){function e(b,d){this.w=a(c),this.el=a(b),this.options=a.extend({},h,d),this.init()}var f="ontouchstart"in c,g=function(){var a=c.createElement("div"),d=c.documentElement;if(!("pointerEvents"in a.style))return!1;a.style.pointerEvents="auto",a.style.pointerEvents="x",d.appendChild(a);var e=b.getComputedStyle&&"auto"===b.getComputedStyle(a,"").pointerEvents;return d.removeChild(a),!!e}(),h={"listNodeName":"ol","itemNodeName":"li","rootClass":"dd","listClass":"dd-list","itemClass":"dd-item","dragClass":"dd-dragel","handleClass":"dd-handle","collapsedClass":"dd-collapsed","placeClass":"dd-placeholder","noDragClass":"dd-nodrag","emptyClass":"dd-empty","expandBtnHTML":'',"collapseBtnHTML":'',"group":0,"maxDepth":5,"threshold":20};e.prototype={"init":function(){var c=this;c.reset(),c.el.data("nestable-group",this.options.group),c.placeEl=a('
'),a.each(this.el.find(c.options.itemNodeName),function(b,d){c.setParent(a(d))}),c.el.on("click","button",function(b){if(!c.dragEl){var d=a(b.currentTarget),e=d.data("action"),f=d.parent(c.options.itemNodeName);"collapse"===e&&c.collapseItem(f),"expand"===e&&c.expandItem(f)}});var d=function(b){var d=a(b.target);if(!d.hasClass(c.options.handleClass)){if(d.closest("."+c.options.noDragClass).length)return;d=d.closest("."+c.options.handleClass)}d.length&&!c.dragEl&&(c.isTouch=/^touch/.test(b.type),c.isTouch&&1!==b.touches.length||(b.preventDefault(),c.dragStart(b.touches?b.touches[0]:b)))},e=function(a){c.dragEl&&(a.preventDefault(),c.dragMove(a.touches?a.touches[0]:a))},g=function(a){c.dragEl&&(a.preventDefault(),c.dragStop(a.touches?a.touches[0]:a))};f&&(c.el[0].addEventListener("touchstart",d,!1),b.addEventListener("touchmove",e,!1),b.addEventListener("touchend",g,!1),b.addEventListener("touchcancel",g,!1)),c.el.on("mousedown",d),c.w.on("mousemove",e),c.w.on("mouseup",g)},"serialize":function(){var b,c=0,d=this;return step=function(b,c){var e=[],f=b.children(d.options.itemNodeName);return f.each(function(){var b=a(this),f=a.extend({},b.data()),g=b.children(d.options.listNodeName);g.length&&(f.children=step(g,c+1)),e.push(f)}),e},b=step(d.el.find(d.options.listNodeName).first(),c)},"serialise":function(){return this.serialize()},"reset":function(){this.mouse={"offsetX":0,"offsetY":0,"startX":0,"startY":0,"lastX":0,"lastY":0,"nowX":0,"nowY":0,"distX":0,"distY":0,"dirAx":0,"dirX":0,"dirY":0,"lastDirX":0,"lastDirY":0,"distAxX":0,"distAxY":0},this.isTouch=!1,this.moving=!1,this.dragEl=null,this.dragRootEl=null,this.dragDepth=0,this.hasNewRoot=!1,this.pointEl=null},"expandItem":function(a){a.removeClass(this.options.collapsedClass),a.children('[data-action="expand"]').hide(),a.children('[data-action="collapse"]').show(),a.children(this.options.listNodeName).show()},"collapseItem":function(a){var b=a.children(this.options.listNodeName);b.length&&(a.addClass(this.options.collapsedClass),a.children('[data-action="collapse"]').hide(),a.children('[data-action="expand"]').show(),a.children(this.options.listNodeName).hide())},"expandAll":function(){var b=this;b.el.find(b.options.itemNodeName).each(function(){b.expandItem(a(this))})},"collapseAll":function(){var b=this;b.el.find(b.options.itemNodeName).each(function(){b.collapseItem(a(this))})},"setParent":function(b){b.children(this.options.listNodeName).length&&(b.prepend(a(this.options.expandBtnHTML)),b.prepend(a(this.options.collapseBtnHTML))),b.children('[data-action="expand"]').hide()},"unsetParent":function(a){a.removeClass(this.options.collapsedClass),a.children("[data-action]").remove(),a.children(this.options.listNodeName).remove()},"dragStart":function(b){var e=this.mouse,f=a(b.target),g=f.closest(this.options.itemNodeName);this.placeEl.css("height",g.height()),e.offsetX=b.offsetX!==d?b.offsetX:b.pageX-f.offset().left,e.offsetY=b.offsetY!==d?b.offsetY:b.pageY-f.offset().top,e.startX=e.lastX=b.pageX,e.startY=e.lastY=b.pageY,this.dragRootEl=this.el,this.dragEl=a(c.createElement(this.options.listNodeName)).addClass(this.options.listClass+" "+this.options.dragClass),this.dragEl.css("width",g.width()),g.after(this.placeEl),g[0].parentNode.removeChild(g[0]),g.appendTo(this.dragEl),a(c.body).append(this.dragEl),this.dragEl.css({"left":b.pageX-e.offsetX,"top":b.pageY-e.offsetY});var h,i,j=this.dragEl.find(this.options.itemNodeName);for(h=0;h