this.containment[2]&&(o=this.containment[2]+this.offset.click.left),e.pageY-this.offset.click.top>this.containment[3]&&(r=this.containment[3]+this.offset.click.top)),s.grid&&(i=this.originalPageY+Math.round((r-this.originalPageY)/s.grid[1])*s.grid[1],r=this.containment?i-this.offset.click.top>=this.containment[1]&&i-this.offset.click.top<=this.containment[3]?i:i-this.offset.click.top>=this.containment[1]?i-s.grid[1]:i+s.grid[1]:i,n=this.originalPageX+Math.round((o-this.originalPageX)/s.grid[0])*s.grid[0],o=this.containment?n-this.offset.click.left>=this.containment[0]&&n-this.offset.click.left<=this.containment[2]?n:n-this.offset.click.left>=this.containment[0]?n-s.grid[0]:n+s.grid[0]:n)),{top:r-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.scrollParent.scrollTop():l?0:a.scrollTop()),left:o-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():l?0:a.scrollLeft())}},_rearrange:function(t,e,i,n){i?i[0].appendChild(this.placeholder[0]):e.item[0].parentNode.insertBefore(this.placeholder[0],"down"===this.direction?e.item[0]:e.item[0].nextSibling),
+this.counter=this.counter?++this.counter:1;var s=this.counter;this._delay(function(){s===this.counter&&this.refreshPositions(!n)})},_clear:function(t,e){function i(t,e,i){return function(n){i._trigger(t,n,e._uiHash(e))}}this.reverting=!1;var n,s=[];if(!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem),this._noFinalSort=null,this.helper[0]===this.currentItem[0]){for(n in this._storedCSS)("auto"===this._storedCSS[n]||"static"===this._storedCSS[n])&&(this._storedCSS[n]="");this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else this.currentItem.show();for(this.fromOutside&&!e&&s.push(function(t){this._trigger("receive",t,this._uiHash(this.fromOutside))}),!this.fromOutside&&this.domPosition.prev===this.currentItem.prev().not(".ui-sortable-helper")[0]&&this.domPosition.parent===this.currentItem.parent()[0]||e||s.push(function(t){this._trigger("update",t,this._uiHash())}),this!==this.currentContainer&&(e||(s.push(function(t){this._trigger("remove",t,this._uiHash())}),s.push(function(t){return function(e){t._trigger("receive",e,this._uiHash(this))}}.call(this,this.currentContainer)),s.push(function(t){return function(e){t._trigger("update",e,this._uiHash(this))}}.call(this,this.currentContainer)))),n=this.containers.length-1;n>=0;n--)e||s.push(i("deactivate",this,this.containers[n])),this.containers[n].containerCache.over&&(s.push(i("out",this,this.containers[n])),this.containers[n].containerCache.over=0);if(this.storedCursor&&(this.document.find("body").css("cursor",this.storedCursor),this.storedStylesheet.remove()),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex","auto"===this._storedZIndex?"":this._storedZIndex),this.dragging=!1,e||this._trigger("beforeStop",t,this._uiHash()),this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.cancelHelperRemoval||(this.helper[0]!==this.currentItem[0]&&this.helper.remove(),this.helper=null),!e){for(n=0;s.length>n;n++)s[n].call(this,t);this._trigger("stop",t,this._uiHash())}return this.fromOutside=!1,!this.cancelHelperRemoval},_trigger:function(){t.Widget.prototype._trigger.apply(this,arguments)===!1&&this.cancel()},_uiHash:function(e){var i=e||this;return{helper:i.helper,placeholder:i.placeholder||t([]),position:i.position,originalPosition:i.originalPosition,offset:i.positionAbs,item:i.currentItem,sender:e?e.element:null}}});var r="ui-effects-",a=t;t.effects={effect:{}},function(t,e){function i(t,e,i){var n=d[e.type]||{};return null==t?i||!e.def?null:e.def:(t=n.floor?~~t:parseFloat(t),isNaN(t)?e.def:n.mod?(t+n.mod)%n.mod:0>t?0:t>n.max?n.max:t)}function n(i){var n=c(),s=n._rgba=[];return i=i.toLowerCase(),f(l,function(t,o){var r,a=o.re.exec(i),l=a&&o.parse(a),c=o.space||"rgba";return l?(r=n[c](l),n[u[c].cache]=r[u[c].cache],s=n._rgba=r._rgba,!1):e}),s.length?("0,0,0,0"===s.join()&&t.extend(s,o.transparent),n):o[i]}function s(t,e,i){return i=(i+1)%1,1>6*i?t+6*(e-t)*i:1>2*i?e:2>3*i?t+6*(e-t)*(2/3-i):t}var o,r="backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",a=/^([\-+])=\s*(\d+\.?\d*)/,l=[{re:/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(t){return[t[1],t[2],t[3],t[4]]}},{re:/rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(t){return[2.55*t[1],2.55*t[2],2.55*t[3],t[4]]}},{re:/#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,parse:function(t){return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]}},{re:/#([a-f0-9])([a-f0-9])([a-f0-9])/,parse:function(t){return[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16)]}},{re:/hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,space:"hsla",parse:function(t){return[t[1],t[2]/100,t[3]/100,t[4]]}}],c=t.Color=function(e,i,n,s){return new t.Color.fn.parse(e,i,n,s)},u={rgba:{props:{red:{idx:0,type:"byte"},green:{idx:1,type:"byte"},blue:{idx:2,type:"byte"}}},hsla:{props:{hue:{idx:0,type:"degrees"},saturation:{idx:1,type:"percent"},lightness:{idx:2,type:"percent"}}}},d={"byte":{floor:!0,max:255},percent:{max:1},degrees:{mod:360,floor:!0}},h=c.support={},p=t("")[0],f=t.each;p.style.cssText="background-color:rgba(1,1,1,.5)",h.rgba=p.style.backgroundColor.indexOf("rgba")>-1,f(u,function(t,e){e.cache="_"+t,e.props.alpha={idx:3,type:"percent",def:1}}),c.fn=t.extend(c.prototype,{parse:function(s,r,a,l){if(s===e)return this._rgba=[null,null,null,null],this;(s.jquery||s.nodeType)&&(s=t(s).css(r),r=e);var d=this,h=t.type(s),p=this._rgba=[];return r!==e&&(s=[s,r,a,l],h="array"),"string"===h?this.parse(n(s)||o._default):"array"===h?(f(u.rgba.props,function(t,e){p[e.idx]=i(s[e.idx],e)}),this):"object"===h?(s instanceof c?f(u,function(t,e){s[e.cache]&&(d[e.cache]=s[e.cache].slice())}):f(u,function(e,n){var o=n.cache;f(n.props,function(t,e){if(!d[o]&&n.to){if("alpha"===t||null==s[t])return;d[o]=n.to(d._rgba)}d[o][e.idx]=i(s[t],e,!0)}),d[o]&&0>t.inArray(null,d[o].slice(0,3))&&(d[o][3]=1,n.from&&(d._rgba=n.from(d[o])))}),this):e},is:function(t){var i=c(t),n=!0,s=this;return f(u,function(t,o){var r,a=i[o.cache];return a&&(r=s[o.cache]||o.to&&o.to(s._rgba)||[],f(o.props,function(t,i){return null!=a[i.idx]?n=a[i.idx]===r[i.idx]:e})),n}),n},_space:function(){var t=[],e=this;return f(u,function(i,n){e[n.cache]&&t.push(i)}),t.pop()},transition:function(t,e){var n=c(t),s=n._space(),o=u[s],r=0===this.alpha()?c("transparent"):this,a=r[o.cache]||o.to(r._rgba),l=a.slice();return n=n[o.cache],f(o.props,function(t,s){var o=s.idx,r=a[o],c=n[o],u=d[s.type]||{};null!==c&&(null===r?l[o]=c:(u.mod&&(c-r>u.mod/2?r+=u.mod:r-c>u.mod/2&&(r-=u.mod)),l[o]=i((c-r)*e+r,s)))}),this[s](l)},blend:function(e){if(1===this._rgba[3])return this;var i=this._rgba.slice(),n=i.pop(),s=c(e)._rgba;return c(t.map(i,function(t,e){return(1-n)*s[e]+n*t}))},toRgbaString:function(){var e="rgba(",i=t.map(this._rgba,function(t,e){return null==t?e>2?1:0:t});return 1===i[3]&&(i.pop(),e="rgb("),e+i.join()+")"},toHslaString:function(){var e="hsla(",i=t.map(this.hsla(),function(t,e){return null==t&&(t=e>2?1:0),e&&3>e&&(t=Math.round(100*t)+"%"),t});return 1===i[3]&&(i.pop(),e="hsl("),e+i.join()+")"},toHexString:function(e){var i=this._rgba.slice(),n=i.pop();return e&&i.push(~~(255*n)),"#"+t.map(i,function(t){return t=(t||0).toString(16),1===t.length?"0"+t:t}).join("")},toString:function(){return 0===this._rgba[3]?"transparent":this.toRgbaString()}}),c.fn.parse.prototype=c.fn,u.hsla.to=function(t){if(null==t[0]||null==t[1]||null==t[2])return[null,null,null,t[3]];var e,i,n=t[0]/255,s=t[1]/255,o=t[2]/255,r=t[3],a=Math.max(n,s,o),l=Math.min(n,s,o),c=a-l,u=a+l,d=.5*u;return e=l===a?0:n===a?60*(s-o)/c+360:s===a?60*(o-n)/c+120:60*(n-s)/c+240,i=0===c?0:.5>=d?c/u:c/(2-u),[Math.round(e)%360,i,d,null==r?1:r]},u.hsla.from=function(t){if(null==t[0]||null==t[1]||null==t[2])return[null,null,null,t[3]];var e=t[0]/360,i=t[1],n=t[2],o=t[3],r=.5>=n?n*(1+i):n+i-n*i,a=2*n-r;return[Math.round(255*s(a,r,e+1/3)),Math.round(255*s(a,r,e)),Math.round(255*s(a,r,e-1/3)),o]},f(u,function(n,s){var o=s.props,r=s.cache,l=s.to,u=s.from;c.fn[n]=function(n){if(l&&!this[r]&&(this[r]=l(this._rgba)),n===e)return this[r].slice();var s,a=t.type(n),d="array"===a||"object"===a?n:arguments,h=this[r].slice();return f(o,function(t,e){var n=d["object"===a?t:e.idx];null==n&&(n=h[e.idx]),h[e.idx]=i(n,e)}),u?(s=c(u(h)),s[r]=h,s):c(h)},f(o,function(e,i){c.fn[e]||(c.fn[e]=function(s){var o,r=t.type(s),l="alpha"===e?this._hsla?"hsla":"rgba":n,c=this[l](),u=c[i.idx];return"undefined"===r?u:("function"===r&&(s=s.call(this,u),r=t.type(s)),null==s&&i.empty?this:("string"===r&&(o=a.exec(s),o&&(s=u+parseFloat(o[2])*("+"===o[1]?1:-1))),c[i.idx]=s,this[l](c)))})})}),c.hook=function(e){var i=e.split(" ");f(i,function(e,i){t.cssHooks[i]={set:function(e,s){var o,r,a="";if("transparent"!==s&&("string"!==t.type(s)||(o=n(s)))){if(s=c(o||s),!h.rgba&&1!==s._rgba[3]){for(r="backgroundColor"===i?e.parentNode:e;(""===a||"transparent"===a)&&r&&r.style;)try{a=t.css(r,"backgroundColor"),r=r.parentNode}catch(l){}s=s.blend(a&&"transparent"!==a?a:"_default")}s=s.toRgbaString()}try{e.style[i]=s}catch(l){}}},t.fx.step[i]=function(e){e.colorInit||(e.start=c(e.elem,i),e.end=c(e.end),e.colorInit=!0),t.cssHooks[i].set(e.elem,e.start.transition(e.end,e.pos))}})},c.hook(r),t.cssHooks.borderColor={expand:function(t){var e={};return f(["Top","Right","Bottom","Left"],function(i,n){e["border"+n+"Color"]=t}),e}},o=t.Color.names={aqua:"#00ffff",black:"#000000",blue:"#0000ff",fuchsia:"#ff00ff",gray:"#808080",green:"#008000",lime:"#00ff00",maroon:"#800000",navy:"#000080",olive:"#808000",purple:"#800080",red:"#ff0000",silver:"#c0c0c0",teal:"#008080",white:"#ffffff",yellow:"#ffff00",transparent:[null,null,null,0],_default:"#ffffff"}}(a),function(){function e(e){var i,n,s=e.ownerDocument.defaultView?e.ownerDocument.defaultView.getComputedStyle(e,null):e.currentStyle,o={};if(s&&s.length&&s[0]&&s[s[0]])for(n=s.length;n--;)i=s[n],"string"==typeof s[i]&&(o[t.camelCase(i)]=s[i]);else for(i in s)"string"==typeof s[i]&&(o[i]=s[i]);return o}function i(e,i){var n,o,r={};for(n in i)o=i[n],e[n]!==o&&(s[n]||(t.fx.step[n]||!isNaN(parseFloat(o)))&&(r[n]=o));return r}var n=["add","remove","toggle"],s={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};t.each(["borderLeftStyle","borderRightStyle","borderBottomStyle","borderTopStyle"],function(e,i){t.fx.step[i]=function(t){("none"!==t.end&&!t.setAttr||1===t.pos&&!t.setAttr)&&(a.style(t.elem,i,t.end),t.setAttr=!0)}}),t.fn.addBack||(t.fn.addBack=function(t){return this.add(null==t?this.prevObject:this.prevObject.filter(t))}),t.effects.animateClass=function(s,o,r,a){var l=t.speed(o,r,a);return this.queue(function(){var o,r=t(this),a=r.attr("class")||"",c=l.children?r.find("*").addBack():r;c=c.map(function(){var i=t(this);return{el:i,start:e(this)}}),o=function(){t.each(n,function(t,e){s[e]&&r[e+"Class"](s[e])})},o(),c=c.map(function(){return this.end=e(this.el[0]),this.diff=i(this.start,this.end),this}),r.attr("class",a),c=c.map(function(){var e=this,i=t.Deferred(),n=t.extend({},l,{queue:!1,complete:function(){i.resolve(e)}});return this.el.animate(this.diff,n),i.promise()}),t.when.apply(t,c.get()).done(function(){o(),t.each(arguments,function(){var e=this.el;t.each(this.diff,function(t){e.css(t,"")})}),l.complete.call(r[0])})})},t.fn.extend({addClass:function(e){return function(i,n,s,o){return n?t.effects.animateClass.call(this,{add:i},n,s,o):e.apply(this,arguments)}}(t.fn.addClass),removeClass:function(e){return function(i,n,s,o){return arguments.length>1?t.effects.animateClass.call(this,{remove:i},n,s,o):e.apply(this,arguments)}}(t.fn.removeClass),toggleClass:function(e){return function(i,n,s,o,r){return"boolean"==typeof n||void 0===n?s?t.effects.animateClass.call(this,n?{add:i}:{remove:i},s,o,r):e.apply(this,arguments):t.effects.animateClass.call(this,{toggle:i},n,s,o)}}(t.fn.toggleClass),switchClass:function(e,i,n,s,o){return t.effects.animateClass.call(this,{add:i,remove:e},n,s,o)}})}(),function(){function e(e,i,n,s){return t.isPlainObject(e)&&(i=e,e=e.effect),e={effect:e},null==i&&(i={}),t.isFunction(i)&&(s=i,n=null,i={}),("number"==typeof i||t.fx.speeds[i])&&(s=n,n=i,i={}),t.isFunction(n)&&(s=n,n=null),i&&t.extend(e,i),n=n||i.duration,e.duration=t.fx.off?0:"number"==typeof n?n:n in t.fx.speeds?t.fx.speeds[n]:t.fx.speeds._default,e.complete=s||i.complete,e}function i(e){return!e||"number"==typeof e||t.fx.speeds[e]?!0:"string"!=typeof e||t.effects.effect[e]?t.isFunction(e)?!0:"object"==typeof e&&!e.effect:!0}t.extend(t.effects,{version:"1.11.4",save:function(t,e){for(var i=0;e.length>i;i++)null!==e[i]&&t.data(r+e[i],t[0].style[e[i]])},restore:function(t,e){var i,n;for(n=0;e.length>n;n++)null!==e[n]&&(i=t.data(r+e[n]),void 0===i&&(i=""),t.css(e[n],i))},setMode:function(t,e){return"toggle"===e&&(e=t.is(":hidden")?"show":"hide"),e},getBaseline:function(t,e){var i,n;switch(t[0]){case"top":i=0;break;case"middle":i=.5;break;case"bottom":i=1;break;default:i=t[0]/e.height}switch(t[1]){case"left":n=0;break;case"center":n=.5;break;case"right":n=1;break;default:n=t[1]/e.width}return{x:n,y:i}},createWrapper:function(e){if(e.parent().is(".ui-effects-wrapper"))return e.parent();var i={width:e.outerWidth(!0),height:e.outerHeight(!0),"float":e.css("float")},n=t("
").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0}),s={width:e.width(),height:e.height()},o=document.activeElement;try{o.id}catch(r){o=document.body}return e.wrap(n),(e[0]===o||t.contains(e[0],o))&&t(o).focus(),n=e.parent(),"static"===e.css("position")?(n.css({position:"relative"}),e.css({position:"relative"})):(t.extend(i,{position:e.css("position"),zIndex:e.css("z-index")}),t.each(["top","left","bottom","right"],function(t,n){i[n]=e.css(n),isNaN(parseInt(i[n],10))&&(i[n]="auto")}),e.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"})),e.css(s),n.css(i).show()},removeWrapper:function(e){var i=document.activeElement;return e.parent().is(".ui-effects-wrapper")&&(e.parent().replaceWith(e),(e[0]===i||t.contains(e[0],i))&&t(i).focus()),e},setTransition:function(e,i,n,s){return s=s||{},t.each(i,function(t,i){var o=e.cssUnit(i);o[0]>0&&(s[i]=o[0]*n+o[1])}),s}}),t.fn.extend({effect:function(){function i(e){function i(){t.isFunction(o)&&o.call(s[0]),t.isFunction(e)&&e()}var s=t(this),o=n.complete,a=n.mode;(s.is(":hidden")?"hide"===a:"show"===a)?(s[a](),i()):r.call(s[0],n,i)}var n=e.apply(this,arguments),s=n.mode,o=n.queue,r=t.effects.effect[n.effect];return t.fx.off||!r?s?this[s](n.duration,n.complete):this.each(function(){n.complete&&n.complete.call(this)}):o===!1?this.each(i):this.queue(o||"fx",i)},show:function(t){return function(n){if(i(n))return t.apply(this,arguments);var s=e.apply(this,arguments);return s.mode="show",this.effect.call(this,s)}}(t.fn.show),hide:function(t){return function(n){if(i(n))return t.apply(this,arguments);var s=e.apply(this,arguments);return s.mode="hide",this.effect.call(this,s)}}(t.fn.hide),toggle:function(t){return function(n){if(i(n)||"boolean"==typeof n)return t.apply(this,arguments);var s=e.apply(this,arguments);return s.mode="toggle",this.effect.call(this,s)}}(t.fn.toggle),cssUnit:function(e){var i=this.css(e),n=[];return t.each(["em","px","%","pt"],function(t,e){i.indexOf(e)>0&&(n=[parseFloat(i),e])}),n}})}(),function(){var e={};t.each(["Quad","Cubic","Quart","Quint","Expo"],function(t,i){e[i]=function(e){return Math.pow(e,t+2)}}),t.extend(e,{Sine:function(t){return 1-Math.cos(t*Math.PI/2)},Circ:function(t){return 1-Math.sqrt(1-t*t)},Elastic:function(t){return 0===t||1===t?t:-Math.pow(2,8*(t-1))*Math.sin((80*(t-1)-7.5)*Math.PI/15)},Back:function(t){return t*t*(3*t-2)},Bounce:function(t){for(var e,i=4;((e=Math.pow(2,--i))-1)/11>t;);return 1/Math.pow(4,3-i)-7.5625*Math.pow((3*e-2)/22-t,2)}}),t.each(e,function(e,i){t.easing["easeIn"+e]=i,t.easing["easeOut"+e]=function(t){return 1-i(1-t)},t.easing["easeInOut"+e]=function(t){return.5>t?i(2*t)/2:1-i(-2*t+2)/2}})}(),t.effects})},function(t,e,i){var n=i(1);!function(t){function e(t,e,i){return t>e&&e+i>t}t.widget("mjs.nestedSortable",t.extend({},t.ui.sortable.prototype,{options:{doNotClear:!1,expandOnHover:700,isAllowed:function(t,e,i){return!0},isTree:!1,listType:"ol",maxLevels:0,protectRoot:!1,rootID:null,rtl:!1,startCollapsed:!1,tabSize:20,branchClass:"mjs-nestedSortable-branch",collapsedClass:"mjs-nestedSortable-collapsed",disableNestingClass:"mjs-nestedSortable-no-nesting",errorClass:"mjs-nestedSortable-error",expandedClass:"mjs-nestedSortable-expanded",hoveringClass:"mjs-nestedSortable-hovering",leafClass:"mjs-nestedSortable-leaf"},_create:function(){if(this.element.data("ui-sortable",this.element.data("mjs-nestedSortable")),!this.element.is(this.options.listType))throw new Error("nestedSortable: Please check that the listType option is set to your actual list type");if(this.options.isTree&&this.options.expandOnHover&&(this.options.tolerance="intersect"),t.ui.sortable.prototype._create.apply(this,arguments),this.options.isTree){var e=this;t(this.items).each(function(){var t=this.item;t.children(e.options.listType).length?(t.addClass(e.options.branchClass),e.options.startCollapsed?t.addClass(e.options.collapsedClass):t.addClass(e.options.expandedClass)):t.addClass(e.options.leafClass)})}},_destroy:function(){return this.element.removeData("mjs-nestedSortable").removeData("ui-sortable"),t.ui.sortable.prototype._destroy.apply(this,arguments)},_mouseDrag:function(e){var i,n,s,o,r=this.options,a=!1;this.position=this._generatePosition(e),this.positionAbs=this._convertPositionTo("absolute"),this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs),this.options.scroll&&(this.scrollParent[0]!=document&&"HTML"!=this.scrollParent[0].tagName?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-e.pageY=0;i--)if(n=this.items[i],s=n.item[0],o=this._intersectsWithPointer(n),o&&n.instance===this.currentContainer&&s!==this.currentItem[0]&&this.placeholder[1===o?"next":"prev"]()[0]!==s&&!t.contains(this.placeholder[0],s)&&("semi-dynamic"===this.options.type?!t.contains(this.element[0],s):!0)){if(this.mouseentered||(t(s).mouseenter(),this.mouseentered=!0),r.isTree&&t(s).hasClass(r.collapsedClass)&&r.expandOnHover&&!this.hovering){t(s).addClass(r.hoveringClass);var p=this;this.hovering=window.setTimeout(function(){t(s).removeClass(r.collapsedClass).addClass(r.expandedClass),p.refreshPositions(),p._trigger("expand",e,p._uiHash())},r.expandOnHover)}if(this.direction=1==o?"down":"up","pointer"!=this.options.tolerance&&!this._intersectsWithSides(n))break;if(t(s).mouseleave(),this.mouseentered=!1,t(s).removeClass(r.hoveringClass),this.hovering&&window.clearTimeout(this.hovering),this.hovering=null,!r.protectRoot||this.currentItem[0].parentNode==this.element[0]&&s.parentNode!=this.element[0])r.protectRoot||this._rearrange(e,n);else if(this.currentItem[0].parentNode!=this.element[0]&&s.parentNode==this.element[0]){t(s).children(r.listType).length||(s.appendChild(h),r.isTree&&t(s).removeClass(r.leafClass).addClass(r.branchClass+" "+r.expandedClass));var f="down"===this.direction?t(s).prev().children(r.listType):t(s).children(r.listType);void 0!==f[0]&&this._rearrange(e,null,f)}else this._rearrange(e,n);this._clearEmpty(s),this._trigger("change",e,this._uiHash());break}var m=this.placeholder[0].previousSibling?t(this.placeholder[0].previousSibling):null;if(null!=m)for(;m[0].nodeName.toLowerCase()!=t(r.listType)[0].nodeName.toLowerCase()||m[0]==this.currentItem[0]||m[0]==this.helper[0];){if(!m[0].previousSibling){m=null;break}m=t(m[0].previousSibling)}var g=this.placeholder[0].nextSibling?t(this.placeholder[0].nextSibling):null;if(null!=g)for(;g[0].nodeName.toLowerCase()!=t(r.listType)[0].nodeName.toLowerCase()||g[0]==this.currentItem[0]||g[0]==this.helper[0];){if(!g[0].nextSibling){g=null;break}g=t(g[0].nextSibling)}return this.beyondMaxLevels=0,null==c||null!=g||r.protectRoot&&c[0].parentNode==this.element[0]||!(r.rtl&&this.positionAbs.left+this.helper.outerWidth()>c.offset().left+c.outerWidth()||!r.rtl&&this.positionAbs.leftm.offset().left+r.tabSize)?this._isAllowed(c,u,u+d):(this._isAllowed(m,u,u+d+1),m.children(r.listType).length||(m[0].appendChild(h),r.isTree&&m.removeClass(r.leafClass).addClass(r.branchClass+" "+r.expandedClass)),l&&l<=m.offset().top?m.children(r.listType).prepend(this.placeholder):m.children(r.listType).length&&m.children(r.listType)[0].appendChild(this.placeholder[0]),this._trigger("change",e,this._uiHash())):(c.after(this.placeholder[0]),r.isTree&&c.children(r.listItem).children(r.listItem+":visible:not(.ui-sortable-helper)").length<1&&c.removeClass(this.options.branchClass+" "+this.options.expandedClass).addClass(this.options.leafClass),this._clearEmpty(c[0]),this._trigger("change",e,this._uiHash())),this._contactContainers(e),t.ui.ddmanager&&t.ui.ddmanager.drag(this,e),this._trigger("sort",e,this._uiHash()),this.lastPositionAbs=this.positionAbs,!1},_mouseStop:function(e,i){this.beyondMaxLevels&&(this.placeholder.removeClass(this.options.errorClass),this.domPosition.prev?t(this.domPosition.prev).after(this.placeholder):t(this.domPosition.parent).prepend(this.placeholder),this._trigger("revert",e,this._uiHash())),t("."+this.options.hoveringClass).mouseleave().removeClass(this.options.hoveringClass),this.mouseentered=!1,this.hovering&&window.clearTimeout(this.hovering),this.hovering=null,t.ui.sortable.prototype._mouseStop.apply(this,arguments)},_intersectsWithSides:function(t){var i=this.options.isTree?.8:.5,n=e(this.positionAbs.top+this.offset.click.top,t.top+t.height*i,t.height),s=e(this.positionAbs.top+this.offset.click.top,t.top-t.height*i,t.height),o=e(this.positionAbs.left+this.offset.click.left,t.left+t.width/2,t.width),r=this._getDragVerticalDirection(),a=this._getDragHorizontalDirection();return this.floating&&a?"right"==a&&o||"left"==a&&!o:r&&("down"==r&&n||"up"==r&&s)},_contactContainers:function(e){this.options.protectRoot&&this.currentItem[0].parentNode==this.element[0]||t.ui.sortable.prototype._contactContainers.apply(this,arguments)},_clear:function(e,i){t.ui.sortable.prototype._clear.apply(this,arguments);for(var n=this.items.length-1;n>=0;n--){var s=this.items[n].item[0];this._clearEmpty(s)}},serialize:function(e){var i=t.extend({},this.options,e),n=this._getItemsAsjQuery(i&&i.connected),s=[];return t(n).each(function(){var e=(t(i.item||this).attr(i.attribute||"id")||"").match(i.expression||/(.+)[-=_](.+)/),n=(t(i.item||this).parent(i.listType).parent(i.items).attr(i.attribute||"id")||"").match(i.expression||/(.+)[-=_](.+)/);e&&s.push((i.key||e[1])+"["+(i.key&&i.expression?e[1]:e[2])+"]="+(n?i.key&&i.expression?n[1]:n[2]:i.rootID))}),!s.length&&i.key&&s.push(i.key+"="),s.join("&")},toHierarchy:function(e){function i(e){var s=(t(e).attr(n.attribute||"id")||"").match(n.expression||/(.+)[-=_](.+)/);if(s){var o={id:s[2]};return t(e).children(n.listType).children(n.items).length>0&&(o.children=[],t(e).children(n.listType).children(n.items).each(function(){var t=i(this);o.children.push(t)})),o}}var n=t.extend({},this.options,e),s=(n.startDepthCount||0,[]);return t(this.element).children(n.items).each(function(){var t=i(this);s.push(t)}),s},toArray:function(e){function i(e,r,a){var l,c,u=a+1;if(t(e).children(n.listType).children(n.items).length>0&&(r++,t(e).children(n.listType).children(n.items).each(function(){u=i(t(this),r,u)}),r--),l=t(e).attr(n.attribute||"id").match(n.expression||/(.+)[-=_](.+)/),r===s+1)c=n.rootID;else{var d=t(e).parent(n.listType).parent(n.items).attr(n.attribute||"id").match(n.expression||/(.+)[-=_](.+)/);c=d[2]}return l&&o.push({item_id:l[2],parent_id:c,depth:r,left:a,right:u}),a=u+1}var n=t.extend({},this.options,e),s=n.startDepthCount||0,o=[],r=1;return n.excludeRoot||(o.push({item_id:n.rootID,parent_id:null,depth:s,left:r,right:2*(t(n.items,this.element).length+1)}),r++),t(this.element).children(n.items).each(function(){r=i(this,s+1,r)}),o=o.sort(function(t,e){return t.left-e.left})},_clearEmpty:function(e){var i=this.options,n=t(e).children(i.listType);!n.length||n.children().length||i.doNotClear?i.isTree&&n.length&&n.children().length&&n.is(":visible")?t(e).removeClass(i.leafClass).addClass(i.branchClass+" "+i.expandedClass):i.isTree&&n.length&&n.children().length&&!n.is(":visible")&&t(e).removeClass(i.leafClass).addClass(i.branchClass+" "+i.collapsedClass):(i.isTree&&t(e).removeClass(i.branchClass+" "+i.expandedClass).addClass(i.leafClass),n.remove())},_getLevel:function(t){var e=1;if(this.options.listType)for(var i=t.closest(this.options.listType);i&&i.length>0&&!i.is(".ui-sortable");)e++,i=i.parent().closest(this.options.listType);return e},_getChildLevels:function(e,i){var n=this,s=this.options,o=0;return i=i||0,t(e).children(s.listType).children(s.items).each(function(t,e){o=Math.max(n._getChildLevels(e,i+1),o)}),i?o+1:o},_isAllowed:function(t,e,i){var n=this.options,s=this.placeholder.closest(".ui-sortable").nestedSortable("option","maxLevels");n.isAllowed(this.placeholder,t,this.currentItem)?i>s&&0!=s?(this.placeholder.addClass(n.errorClass),this.beyondMaxLevels=i-s):(this.placeholder.removeClass(n.errorClass),this.beyondMaxLevels=0):(this.placeholder.addClass(n.errorClass),i>s&&0!=s?this.beyondMaxLevels=i-s:this.beyondMaxLevels=1)}})),t.mjs.nestedSortable.prototype.options=t.extend({},t.ui.sortable.prototype.options,t.mjs.nestedSortable.prototype.options)}(n)},function(t,e,i){var n=i(1);!function(t){function e(t,e){if(!(t.originalEvent.touches.length>1)){t.preventDefault();var i=t.originalEvent.changedTouches[0],n=document.createEvent("MouseEvents");n.initMouseEvent(e,!0,!0,window,1,i.screenX,i.screenY,i.clientX,i.clientY,!1,!1,!1,!1,0,null),t.target.dispatchEvent(n)}}if(t.support.touch="ontouchend"in document,t.support.touch){var i,n=t.ui.mouse.prototype,s=n._mouseInit,o=n._mouseDestroy;n._touchStart=function(t){var n=this;!i&&n._mouseCapture(t.originalEvent.changedTouches[0])&&(i=!0,n._touchMoved=!1,e(t,"mouseover"),e(t,"mousemove"),e(t,"mousedown"))},n._touchMove=function(t){i&&(this._touchMoved=!0,e(t,"mousemove"))},n._touchEnd=function(t){i&&(e(t,"mouseup"),e(t,"mouseout"),this._touchMoved||e(t,"click"),i=!1)},n._mouseInit=function(){var e=this;e.element.bind({touchstart:t.proxy(e,"_touchStart"),touchmove:t.proxy(e,"_touchMove"),touchend:t.proxy(e,"_touchEnd")}),s.call(e)},n._mouseDestroy=function(){var e=this;e.element.unbind({touchstart:t.proxy(e,"_touchStart"),touchmove:t.proxy(e,"_touchMove"),touchend:t.proxy(e,"_touchEnd")}),o.call(e)}}}(n)}]);
\ No newline at end of file
diff --git a/cms/static/cms/js/modules/cms.plugins.js b/cms/static/cms/js/modules/cms.plugins.js
index e9c9c242cbd..0934762bf01 100644
--- a/cms/static/cms/js/modules/cms.plugins.js
+++ b/cms/static/cms/js/modules/cms.plugins.js
@@ -67,6 +67,9 @@ var Plugin = new Class({
// bind data element to the container
this.ui.container.data('settings', this.options);
+ if (Plugin.aliasPluginDuplicatesMap[this.options.plugin_id]) {
+ return;
+ }
Plugin._initializeDragItemsStates();
// determine type of plugin
@@ -76,6 +79,7 @@ var Plugin = new Class({
this._collapsables();
break;
case 'plugin': // handler for all plugins
+ Plugin.aliasPluginDuplicatesMap[this.options.plugin_id] = true;
this._setPlugin();
this._collapsables();
break;
@@ -1645,6 +1649,8 @@ Plugin._initializeDragItemsStates = Helpers.once(function _initializeDragItemsSt
});
});
+Plugin.aliasPluginDuplicatesMap = {};
+
// shorthand for jQuery(document).ready();
$(Plugin._initializeGlobalHandlers);
diff --git a/cms/tests/frontend/unit/cms.plugins.test.js b/cms/tests/frontend/unit/cms.plugins.test.js
index 054c33ab4da..742aa14331e 100644
--- a/cms/tests/frontend/unit/cms.plugins.test.js
+++ b/cms/tests/frontend/unit/cms.plugins.test.js
@@ -39,6 +39,10 @@ describe('CMS.Plugin', function () {
});
});
+ afterEach(function () {
+ Plugin.aliasPluginDuplicatesMap = {};
+ });
+
describe('instance', function () {
var plugin1;
var plugin2;
@@ -244,8 +248,35 @@ describe('CMS.Plugin', function () {
expect(generic.ui.container.data('settings')).toEqual(generic.options);
});
+ it('doesnt reset the ui if the same plugin is initialized twice (alias case)', function () {
+ spyOn(Plugin.prototype, '_setPlugin');
+ spyOn(Plugin.prototype, '_setPlaceholder');
+ spyOn(Plugin.prototype, '_setGeneric');
+ expect(Plugin.aliasPluginDuplicatesMap[plugin1.options.plugin_id]).toEqual(true);
+
+ new CMS.Plugin('cms-plugin-1', {
+ type: 'plugin',
+ plugin_id: 1,
+ plugin_type: 'TextPlugin',
+ placeholder_id: 1,
+ urls: {
+ add_plugin: '/en/admin/cms/page/add-plugin/',
+ edit_plugin: '/en/admin/cms/page/edit-plugin/1/',
+ move_plugin: '/en/admin/cms/page/move-plugin/',
+ delete_plugin: '/en/admin/cms/page/delete-plugin/1/',
+ copy_plugin: '/en/admin/cms/page/copy-plugins/'
+ }
+ });
+
+ expect(Plugin.aliasPluginDuplicatesMap[plugin1.options.plugin_id]).toEqual(true);
+ expect(Plugin.prototype._setPlugin).not.toHaveBeenCalled();
+ expect(Plugin.prototype._setPlaceholder).not.toHaveBeenCalled();
+ expect(Plugin.prototype._setGeneric).not.toHaveBeenCalled();
+ });
+
it('checks if pasting into this plugin is allowed', function () {
spyOn(CMS.Plugin.prototype, '_checkIfPasteAllowed');
+ Plugin.aliasPluginDuplicatesMap = {};
plugin1 = new CMS.Plugin('cms-plugin-1', {
type: 'plugin',