Файл: static/js/jquery_ui.js
Строк: 2855
<?php
/*! jQuery UI - v1.9.1 - 2012-11-01
* http://jqueryui.com
* Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.sortable.js
* Copyright (c) 2012 jQuery Foundation and other contributors Licensed MIT */
(function(f,b){function a(j,m){var k,h,l,e=j.nodeName.toLowerCase();return"area"===e?(k=j.parentNode,h=k.name,!j.href||!h||k.nodeName.toLowerCase()!=="map"?!1:(l=f("img[usemap=#"+h+"]")[0],!!l&&c(l))):(/input|select|textarea|button|object/.test(e)?!j.disabled:"a"===e?j.href||m:m)&&c(j)}function c(e){return f.expr.filters.visible(e)&&!f(e).parents().andSelf().filter(function(){return f.css(this,"visibility")==="hidden"}).length}var g=0,d=/^ui-id-d+$/;f.ui=f.ui||{};if(f.ui.version){return}f.extend(f.ui,{version:"1.9.1",keyCode:{BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38}}),f.fn.extend({_focus:f.fn.focus,focus:function(e,h){return typeof e=="number"?this.each(function(){var i=this;setTimeout(function(){f(i).focus(),h&&h.call(i)},e)}):this._focus.apply(this,arguments)},scrollParent:function(){var e;return f.ui.ie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?e=this.parents().filter(function(){return/(relative|absolute|fixed)/.test(f.css(this,"position"))&&/(auto|scroll)/.test(f.css(this,"overflow")+f.css(this,"overflow-y")+f.css(this,"overflow-x"))}).eq(0):e=this.parents().filter(function(){return/(auto|scroll)/.test(f.css(this,"overflow")+f.css(this,"overflow-y")+f.css(this,"overflow-x"))}).eq(0),/fixed/.test(this.css("position"))||!e.length?f(document):e},zIndex:function(k){if(k!==b){return this.css("zIndex",k)}if(this.length){var j=f(this[0]),e,h;while(j.length&&j[0]!==document){e=j.css("position");if(e==="absolute"||e==="relative"||e==="fixed"){h=parseInt(j.css("zIndex"),10);if(!isNaN(h)&&h!==0){return h}}j=j.parent()}}return 0},uniqueId:function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++g)})},removeUniqueId:function(){return this.each(function(){d.test(this.id)&&f(this).removeAttr("id")})}}),f("<a>").outerWidth(1).jquery||f.each(["Width","Height"],function(m,k){function e(i,q,p,o){return f.each(h,function(){q-=parseFloat(f.css(i,"padding"+this))||0,p&&(q-=parseFloat(f.css(i,"border"+this+"Width"))||0),o&&(q-=parseFloat(f.css(i,"margin"+this))||0)}),q}var h=k==="Width"?["Left","Right"]:["Top","Bottom"],j=k.toLowerCase(),l={innerWidth:f.fn.innerWidth,innerHeight:f.fn.innerHeight,outerWidth:f.fn.outerWidth,outerHeight:f.fn.outerHeight};f.fn["inner"+k]=function(i){return i===b?l["inner"+k].call(this):this.each(function(){f(this).css(j,e(this,i)+"px")})},f.fn["outer"+k]=function(i,o){return typeof i!="number"?l["outer"+k].call(this,i):this.each(function(){f(this).css(j,e(this,i,!0,o)+"px")})}}),f.extend(f.expr[":"],{data:f.expr.createPseudo?f.expr.createPseudo(function(e){return function(h){return !!f.data(h,e)}}):function(e,i,h){return !!f.data(e,h[3])},focusable:function(e){return a(e,!isNaN(f.attr(e,"tabindex")))},tabbable:function(e){var i=f.attr(e,"tabindex"),h=isNaN(i);return(h||i>=0)&&a(e,!h)}}),f(function(){var e=document.body,h=e.appendChild(h=document.createElement("div"));h.offsetHeight,f.extend(h.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0}),f.support.minHeight=h.offsetHeight===100,f.support.selectstart="onselectstart" in h,e.removeChild(h).style.display="none"}),function(){var e=/msie ([w.]+)/.exec(navigator.userAgent.toLowerCase())||[];f.ui.ie=e.length?!0:!1,f.ui.ie6=parseFloat(e[1],10)===6}(),f.fn.extend({disableSelection:function(){return this.bind((f.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(h){h.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),f.extend(f.ui,{plugin:{add:function(h,l,k){var e,j=f.ui[h].prototype;for(e in k){j.plugins[e]=j.plugins[e]||[],j.plugins[e].push([l,k[e]])}},call:function(l,j,m){var k,h=l.plugins[j];if(!h||!l.element[0].parentNode||l.element[0].parentNode.nodeType===11){return}for(k=0;k<h.length;k++){l.options[h[k][0]]&&h[k][1].apply(l.element,m)}}},contains:f.contains,hasScroll:function(h,k){if(f(h).css("overflow")==="hidden"){return !1}var j=k&&k==="left"?"scrollLeft":"scrollTop",e=!1;return h[j]>0?!0:(h[j]=1,e=h[j]>0,h[j]=0,e)},isOverAxis:function(i,h,j){return i>h&&i<h+j},isOver:function(h,m,k,e,j,l){return f.ui.isOverAxis(h,k,j)&&f.ui.isOverAxis(m,e,l)}})})(jQuery);(function(d,b){var f=0,c=Array.prototype.slice,a=d.cleanData;d.cleanData=function(e){for(var i=0,h;(h=e[i])!=null;i++){try{d(h).triggerHandler("remove")}catch(g){}}a(e)},d.widget=function(j,p,l){var h,k,m,g,e=j.split(".")[0];j=j.split(".")[1],h=e+"-"+j,l||(l=p,p=d.Widget),d.expr[":"][h.toLowerCase()]=function(i){return !!d.data(i,h)},d[e]=d[e]||{},k=d[e][j],m=d[e][j]=function(n,i){if(!this._createWidget){return new m(n,i)}arguments.length&&this._createWidget(n,i)},d.extend(m,k,{version:l.version,_proto:d.extend({},l),_childConstructors:[]}),g=new p,g.options=d.widget.extend({},g.options),d.each(l,function(o,n){d.isFunction(n)&&(l[o]=function(){var q=function(){return p.prototype[o].apply(this,arguments)},i=function(r){return p.prototype[o].apply(this,r)};return function(){var r=this._super,v=this._superApply,u;return this._super=q,this._superApply=i,u=n.apply(this,arguments),this._super=r,this._superApply=v,u}}())}),m.prototype=d.widget.extend(g,{widgetEventPrefix:g.widgetEventPrefix||j},l,{constructor:m,namespace:e,widgetName:j,widgetBaseClass:h,widgetFullName:h}),k?(d.each(k._childConstructors,function(i,q){var o=q.prototype;d.widget(o.namespace+"."+o.widgetName,m,q._proto)}),delete k._childConstructors):p._childConstructors.push(m),d.widget.bridge(j,m)},d.widget.extend=function(l){var h=c.call(arguments,1),j=0,k=h.length,g,e;for(;j<k;j++){for(g in h[j]){e=h[j][g],h[j].hasOwnProperty(g)&&e!==b&&(d.isPlainObject(e)?l[g]=d.isPlainObject(l[g])?d.widget.extend({},l[g],e):d.widget.extend({},e):l[g]=e)}}return l},d.widget.bridge=function(h,e){var g=e.prototype.widgetFullName;d.fn[h]=function(l){var j=typeof l=="string",i=c.call(arguments,1),k=this;return l=!j&&i.length?d.widget.extend.apply(null,[l].concat(i)):l,j?this.each(function(){var n,m=d.data(this,g);if(!m){return d.error("cannot call methods on "+h+" prior to initialization; attempted to call method '"+l+"'")}if(!d.isFunction(m[l])||l.charAt(0)==="_"){return d.error("no such method '"+l+"' for "+h+" widget instance")}n=m[l].apply(m,i);if(n!==m&&n!==b){return k=n&&n.jquery?k.pushStack(n.get()):n,!1}}):this.each(function(){var m=d.data(this,g);m?m.option(l||{})._init():new e(l,this)}),k}},d.Widget=function(){},d.Widget._childConstructors=[],d.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"<div>",options:{disabled:!1,create:null},_createWidget:function(e,g){g=d(g||this.defaultElement||this)[0],this.element=d(g),this.uuid=f++,this.eventNamespace="."+this.widgetName+this.uuid,this.options=d.widget.extend({},this.options,this._getCreateOptions(),e),this.bindings=d(),this.hoverable=d(),this.focusable=d(),g!==this&&(d.data(g,this.widgetName,this),d.data(g,this.widgetFullName,this),this._on(this.element,{remove:function(h){h.target===g&&this.destroy()}}),this.document=d(g.style?g.ownerDocument:g.document||g),this.window=d(this.document[0].defaultView||this.document[0].parentWindow)),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:d.noop,_getCreateEventData:d.noop,_create:d.noop,_init:d.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetName).removeData(this.widgetFullName).removeData(d.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:d.noop,widget:function(){return this.element},option:function(l,j){var g=l,h,k,e;if(arguments.length===0){return d.widget.extend({},this.options)}if(typeof l=="string"){g={},h=l.split("."),l=h.shift();if(h.length){k=g[l]=d.widget.extend({},this.options[l]);for(e=0;e<h.length-1;e++){k[h[e]]=k[h[e]]||{},k=k[h[e]]}l=h.pop();if(j===b){return k[l]===b?null:k[l]}k[l]=j}else{if(j===b){return this.options[l]===b?null:this.options[l]}g[l]=j}}return this._setOptions(g),this},_setOptions:function(h){var g;for(g in h){this._setOption(g,h[g])}return this},_setOption:function(h,g){return this.options[h]=g,h==="disabled"&&(this.widget().toggleClass(this.widgetFullName+"-disabled ui-state-disabled",!!g).attr("aria-disabled",g),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")),this},enable:function(){return this._setOption("disabled",!1)},disable:function(){return this._setOption("disabled",!0)},_on:function(g,j){var h,e=this;j?(g=h=d(g),this.bindings=this.bindings.add(g)):(j=g,g=this.element,h=this.widget()),d.each(j,function(q,l){function p(){if(e.options.disabled===!0||d(this).hasClass("ui-state-disabled")){return}return(typeof l=="string"?e[l]:l).apply(e,arguments)}typeof l!="string"&&(p.guid=l.guid=l.guid||p.guid||d.guid++);var k=q.match(/^(w+)s*(.*)$/),i=k[1]+e.eventNamespace,m=k[2];m?h.delegate(m,i,p):g.bind(i,p)})},_off:function(h,g){g=(g||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,h.unbind(g).undelegate(g)},_delay:function(i,g){function j(){return(typeof i=="string"?h[i]:i).apply(h,arguments)}var h=this;return setTimeout(j,g||0)},_hoverable:function(e){this.hoverable=this.hoverable.add(e),this._on(e,{mouseenter:function(g){d(g.currentTarget).addClass("ui-state-hover")},mouseleave:function(g){d(g.currentTarget).removeClass("ui-state-hover")}})},_focusable:function(e){this.focusable=this.focusable.add(e),this._on(e,{focusin:function(g){d(g.currentTarget).addClass("ui-state-focus")},focusout:function(g){d(g.currentTarget).removeClass("ui-state-focus")}})},_trigger:function(g,l,j){var e,h,k=this.options[g];j=j||{},l=d.Event(l),l.type=(g===this.widgetEventPrefix?g:this.widgetEventPrefix+g).toLowerCase(),l.target=this.element[0],h=l.originalEvent;if(h){for(e in h){e in l||(l[e]=h[e])}}return this.element.trigger(l,j),!(d.isFunction(k)&&k.apply(this.element[0],[l].concat(j))===!1||l.isDefaultPrevented())}},d.each({show:"fadeIn",hide:"fadeOut"},function(e,g){d.Widget.prototype["_"+e]=function(l,j,k){typeof j=="string"&&(j={effect:j});var m,h=j?j===!0||typeof j=="number"?g:j.effect||g:e;j=j||{},typeof j=="number"&&(j={duration:j}),m=!d.isEmptyObject(j),j.complete=k,j.delay&&l.delay(j.delay),m&&d.effects&&(d.effects.effect[h]||d.uiBackCompat!==!1&&d.effects[h])?l[e](j):h!==e&&l[h]?l[h](j.duration,j.easing,k):l.queue(function(i){d(this)[e](),k&&k.call(l[0]),i()})}}),d.uiBackCompat!==!1&&(d.Widget.prototype._getCreateOptions=function(){return d.metadata&&d.metadata.get(this.element[0])[this.widgetName]})})(jQuery);(function(b,a){var c=!1;b(document).mouseup(function(d){c=!1}),b.widget("ui.mouse",{version:"1.9.1",options:{cancel:"input,textarea,button,select,option",distance:1,delay:0},_mouseInit:function(){var d=this;this.element.bind("mousedown."+this.widgetName,function(f){return d._mouseDown(f)}).bind("click."+this.widgetName,function(e){if(!0===b.data(e.target,d.widgetName+".preventClickEvent")){return b.removeData(e.target,d.widgetName+".preventClickEvent"),e.stopImmediatePropagation(),!1}}),this.started=!1},_mouseDestroy:function(){this.element.unbind("."+this.widgetName),this._mouseMoveDelegate&&b(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(e){if(c){return}this._mouseStarted&&this._mouseUp(e),this._mouseDownEvent=e;var g=this,d=e.which===1,f=typeof this.options.cancel=="string"&&e.target.nodeName?b(e.target).closest(this.options.cancel).length:!1;if(!d||f||!this._mouseCapture(e)){return !0}this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){g.mouseDelayMet=!0},this.options.delay));if(this._mouseDistanceMet(e)&&this._mouseDelayMet(e)){this._mouseStarted=this._mouseStart(e)!==!1;if(!this._mouseStarted){return e.preventDefault(),!0}}return !0===b.data(e.target,this.widgetName+".preventClickEvent")&&b.removeData(e.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(h){return g._mouseMove(h)},this._mouseUpDelegate=function(h){return g._mouseUp(h)},b(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate),e.preventDefault(),c=!0,!0},_mouseMove:function(d){return !b.ui.ie||document.documentMode>=9||!!d.button?this._mouseStarted?(this._mouseDrag(d),d.preventDefault()):(this._mouseDistanceMet(d)&&this._mouseDelayMet(d)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,d)!==!1,this._mouseStarted?this._mouseDrag(d):this._mouseUp(d)),!this._mouseStarted):this._mouseUp(d)},_mouseUp:function(d){return b(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,d.target===this._mouseDownEvent.target&&b.data(d.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(d)),!1},_mouseDistanceMet:function(d){return Math.max(Math.abs(this._mouseDownEvent.pageX-d.pageX),Math.abs(this._mouseDownEvent.pageY-d.pageY))>=this.options.distance},_mouseDelayMet:function(d){return this.mouseDelayMet},_mouseStart:function(d){},_mouseDrag:function(d){},_mouseStop:function(d){},_mouseCapture:function(d){return !0}})})(jQuery);(function(b,a){b.widget("ui.draggable",b.ui.mouse,{version:"1.9.1",widgetEventPrefix:"drag",options:{addClasses:!0,appendTo:"parent",axis:!1,connectToSortable:!1,containment:!1,cursor:"auto",cursorAt:!1,grid:!1,handle:!1,helper:"original",iframeFix:!1,opacity:!1,refreshPositions:!1,revert:!1,revertDuration:500,scope:"default",scroll:!0,scrollSensitivity:20,scrollSpeed:20,snap:!1,snapMode:"both",snapTolerance:20,stack:!1,zIndex:!1},_create:function(){this.options.helper=="original"&&!/^(?:r|a|f)/.test(this.element.css("position"))&&(this.element[0].style.position="relative"),this.options.addClasses&&this.element.addClass("ui-draggable"),this.options.disabled&&this.element.addClass("ui-draggable-disabled"),this._mouseInit()},_destroy:function(){this.element.removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled"),this._mouseDestroy()},_mouseCapture:function(c){var d=this.options;return this.helper||d.disabled||b(c.target).is(".ui-resizable-handle")?!1:(this.handle=this._getHandle(c),this.handle?(b(d.iframeFix===!0?"iframe":d.iframeFix).each(function(){b('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1000}).css(b(this).offset()).appendTo("body")}),!0):!1)},_mouseStart:function(c){var d=this.options;return this.helper=this._createHelper(c),this.helper.addClass("ui-draggable-dragging"),this._cacheHelperProportions(),b.ui.ddmanager&&(b.ui.ddmanager.current=this),this._cacheMargins(),this.cssPosition=this.helper.css("position"),this.scrollParent=this.helper.scrollParent(),this.offset=this.positionAbs=this.element.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},b.extend(this.offset,{click:{left:c.pageX-this.offset.left,top:c.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.originalPosition=this.position=this._generatePosition(c),this.originalPageX=c.pageX,this.originalPageY=c.pageY,d.cursorAt&&this._adjustOffsetFromHelper(d.cursorAt),d.containment&&this._setContainment(),this._trigger("start",c)===!1?(this._clear(),!1):(this._cacheHelperProportions(),b.ui.ddmanager&&!d.dropBehaviour&&b.ui.ddmanager.prepareOffsets(this,c),this._mouseDrag(c,!0),b.ui.ddmanager&&b.ui.ddmanager.dragStart(this,c),!0)},_mouseDrag:function(c,e){this.position=this._generatePosition(c),this.positionAbs=this._convertPositionTo("absolute");if(!e){var d=this._uiHash();if(this._trigger("drag",c,d)===!1){return this._mouseUp({}),!1}this.position=d.position}if(!this.options.axis||this.options.axis!="y"){this.helper[0].style.left=this.position.left+"px"}if(!this.options.axis||this.options.axis!="x"){this.helper[0].style.top=this.position.top+"px"}return b.ui.ddmanager&&b.ui.ddmanager.drag(this,c),!1},_mouseStop:function(d){var g=!1;b.ui.ddmanager&&!this.options.dropBehaviour&&(g=b.ui.ddmanager.drop(this,d)),this.dropped&&(g=this.dropped,this.dropped=!1);var f=this.element[0],c=!1;while(f&&(f=f.parentNode)){f==document&&(c=!0)}if(!c&&this.options.helper==="original"){return !1}if(this.options.revert=="invalid"&&!g||this.options.revert=="valid"&&g||this.options.revert===!0||b.isFunction(this.options.revert)&&this.options.revert.call(this.element,g)){var e=this;b(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){e._trigger("stop",d)!==!1&&e._clear()})}else{this._trigger("stop",d)!==!1&&this._clear()}return !1},_mouseUp:function(c){return b("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)}),b.ui.ddmanager&&b.ui.ddmanager.dragStop(this,c),b.ui.mouse.prototype._mouseUp.call(this,c)},cancel:function(){return this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear(),this},_getHandle:function(c){var d=!this.options.handle||!b(this.options.handle,this.element).length?!0:!1;return b(this.options.handle,this.element).find("*").andSelf().each(function(){this==c.target&&(d=!0)}),d},_createHelper:function(c){var e=this.options,d=b.isFunction(e.helper)?b(e.helper.apply(this.element[0],[c])):e.helper=="clone"?this.element.clone().removeAttr("id"):this.element;return d.parents("body").length||d.appendTo(e.appendTo=="parent"?this.element[0].parentNode:e.appendTo),d[0]!=this.element[0]&&!/(fixed|absolute)/.test(d.css("position"))&&d.css("position","absolute"),d},_adjustOffsetFromHelper:function(c){typeof c=="string"&&(c=c.split(" ")),b.isArray(c)&&(c={left:+c[0],top:+c[1]||0}),"left" in c&&(this.offset.click.left=c.left+this.margins.left),"right" in c&&(this.offset.click.left=this.helperProportions.width-c.right+this.margins.left),"top" in c&&(this.offset.click.top=c.top+this.margins.top),"bottom" in c&&(this.offset.click.top=this.helperProportions.height-c.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var c=this.offsetParent.offset();this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&b.contains(this.scrollParent[0],this.offsetParent[0])&&(c.left+=this.scrollParent.scrollLeft(),c.top+=this.scrollParent.scrollTop());if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&b.ui.ie){c={top:0,left:0}}return{top:c.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:c.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var c=this.element.position();return{top:c.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:c.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var d=this.options;d.containment=="parent"&&(d.containment=this.helper[0].parentNode);if(d.containment=="document"||d.containment=="window"){this.containment=[d.containment=="document"?0:b(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,d.containment=="document"?0:b(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,(d.containment=="document"?0:b(window).scrollLeft())+b(d.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(d.containment=="document"?0:b(window).scrollTop())+(b(d.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]}if(!/^(document|window|parent)$/.test(d.containment)&&d.containment.constructor!=Array){var g=b(d.containment),f=g[0];if(!f){return}var c=g.offset(),e=b(f).css("overflow")!="hidden";this.containment=[(parseInt(b(f).css("borderLeftWidth"),10)||0)+(parseInt(b(f).css("paddingLeft"),10)||0),(parseInt(b(f).css("borderTopWidth"),10)||0)+(parseInt(b(f).css("paddingTop"),10)||0),(e?Math.max(f.scrollWidth,f.offsetWidth):f.offsetWidth)-(parseInt(b(f).css("borderLeftWidth"),10)||0)-(parseInt(b(f).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(e?Math.max(f.scrollHeight,f.offsetHeight):f.offsetHeight)-(parseInt(b(f).css("borderTopWidth"),10)||0)-(parseInt(b(f).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom],this.relative_container=g}else{d.containment.constructor==Array&&(this.containment=d.containment)}},_convertPositionTo:function(d,h){h||(h=this.position);var f=d=="absolute"?1:-1,c=this.options,e=this.cssPosition!="absolute"||this.scrollParent[0]!=document&&!!b.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,g=/(html|body)/i.test(e[0].tagName);return{top:h.top+this.offset.relative.top*f+this.offset.parent.top*f-(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():g?0:e.scrollTop())*f,left:h.left+this.offset.relative.left*f+this.offset.parent.left*f-(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():g?0:e.scrollLeft())*f}},_generatePosition:function(p){var e=this.options,c=this.cssPosition!="absolute"||this.scrollParent[0]!=document&&!!b.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,h=/(html|body)/i.test(c[0].tagName),q=p.pageX,d=p.pageY;if(this.originalPosition){var m;if(this.containment){if(this.relative_container){var k=this.relative_container.offset();m=[this.containment[0]+k.left,this.containment[1]+k.top,this.containment[2]+k.left,this.containment[3]+k.top]}else{m=this.containment}p.pageX-this.offset.click.left<m[0]&&(q=m[0]+this.offset.click.left),p.pageY-this.offset.click.top<m[1]&&(d=m[1]+this.offset.click.top),p.pageX-this.offset.click.left>m[2]&&(q=m[2]+this.offset.click.left),p.pageY-this.offset.click.top>m[3]&&(d=m[3]+this.offset.click.top)}if(e.grid){var j=e.grid[1]?this.originalPageY+Math.round((d-this.originalPageY)/e.grid[1])*e.grid[1]:this.originalPageY;d=m?j-this.offset.click.top<m[1]||j-this.offset.click.top>m[3]?j-this.offset.click.top<m[1]?j+e.grid[1]:j-e.grid[1]:j:j;var g=e.grid[0]?this.originalPageX+Math.round((q-this.originalPageX)/e.grid[0])*e.grid[0]:this.originalPageX;q=m?g-this.offset.click.left<m[0]||g-this.offset.click.left>m[2]?g-this.offset.click.left<m[0]?g+e.grid[0]:g-e.grid[0]:g:g}}return{top:d-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():h?0:c.scrollTop()),left:q-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():h?0:c.scrollLeft())}},_clear:function(){this.helper.removeClass("ui-draggable-dragging"),this.helper[0]!=this.element[0]&&!this.cancelHelperRemoval&&this.helper.remove(),this.helper=null,this.cancelHelperRemoval=!1},_trigger:function(c,e,d){return d=d||this._uiHash(),b.ui.plugin.call(this,c,[e,d]),c=="drag"&&(this.positionAbs=this._convertPositionTo("absolute")),b.Widget.prototype._trigger.call(this,c,e,d)},plugins:{},_uiHash:function(c){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}}),b.ui.plugin.add("draggable","connectToSortable",{start:function(d,g){var f=b(this).data("draggable"),c=f.options,e=b.extend({},g,{item:f.element});f.sortables=[],b(c.connectToSortable).each(function(){var h=b.data(this,"sortable");h&&!h.options.disabled&&(f.sortables.push({instance:h,shouldRevert:h.options.revert}),h.refreshPositions(),h._trigger("activate",d,e))})},stop:function(d,f){var e=b(this).data("draggable"),c=b.extend({},f,{item:e.element});b.each(e.sortables,function(){this.instance.isOver?(this.instance.isOver=0,e.cancelHelperRemoval=!0,this.instance.cancelHelperRemoval=!1,this.shouldRevert&&(this.instance.options.revert=!0),this.instance._mouseStop(d),this.instance.options.helper=this.instance.options._helper,e.options.helper=="original"&&this.instance.currentItem.css({top:"auto",left:"auto"})):(this.instance.cancelHelperRemoval=!1,this.instance._trigger("deactivate",d,c))})},drag:function(d,g){var f=b(this).data("draggable"),c=this,e=function(v){var k=this.offset.click.top,h=this.offset.click.left,l=this.positionAbs.top,w=this.positionAbs.left,j=v.height,q=v.width,p=v.top,m=v.left;return b.ui.isOver(l+k,w+h,p,m,j,q)};b.each(f.sortables,function(i){var j=!1,h=this;this.instance.positionAbs=f.positionAbs,this.instance.helperProportions=f.helperProportions,this.instance.offset.click=f.offset.click,this.instance._intersectsWith(this.instance.containerCache)&&(j=!0,b.each(f.sortables,function(){return this.instance.positionAbs=f.positionAbs,this.instance.helperProportions=f.helperProportions,this.instance.offset.click=f.offset.click,this!=h&&this.instance._intersectsWith(this.instance.containerCache)&&b.ui.contains(h.instance.element[0],this.instance.element[0])&&(j=!1),j})),j?(this.instance.isOver||(this.instance.isOver=1,this.instance.currentItem=b(c).clone().removeAttr("id").appendTo(this.instance.element).data("sortable-item",!0),this.instance.options._helper=this.instance.options.helper,this.instance.options.helper=function(){return g.helper[0]},d.target=this.instance.currentItem[0],this.instance._mouseCapture(d,!0),this.instance._mouseStart(d,!0,!0),this.instance.offset.click.top=f.offset.click.top,this.instance.offset.click.left=f.offset.click.left,this.instance.offset.parent.left-=f.offset.parent.left-this.instance.offset.parent.left,this.instance.offset.parent.top-=f.offset.parent.top-this.instance.offset.parent.top,f._trigger("toSortable",d),f.dropped=this.instance.element,f.currentItem=f.element,this.instance.fromOutside=f),this.instance.currentItem&&this.instance._mouseDrag(d)):this.instance.isOver&&(this.instance.isOver=0,this.instance.cancelHelperRemoval=!0,this.instance.options.revert=!1,this.instance._trigger("out",d,this.instance._uiHash(this.instance)),this.instance._mouseStop(d,!0),this.instance.options.helper=this.instance.options._helper,this.instance.currentItem.remove(),this.instance.placeholder&&this.instance.placeholder.remove(),f._trigger("fromSortable",d),f.dropped=!1)})}}),b.ui.plugin.add("draggable","cursor",{start:function(d,f){var e=b("body"),c=b(this).data("draggable").options;e.css("cursor")&&(c._cursor=e.css("cursor")),e.css("cursor",c.cursor)},stop:function(c,e){var d=b(this).data("draggable").options;d._cursor&&b("body").css("cursor",d._cursor)}}),b.ui.plugin.add("draggable","opacity",{start:function(d,f){var e=b(f.helper),c=b(this).data("draggable").options;e.css("opacity")&&(c._opacity=e.css("opacity")),e.css("opacity",c.opacity)},stop:function(c,e){var d=b(this).data("draggable").options;d._opacity&&b(e.helper).css("opacity",d._opacity)}}),b.ui.plugin.add("draggable","scroll",{start:function(c,e){var d=b(this).data("draggable");d.scrollParent[0]!=document&&d.scrollParent[0].tagName!="HTML"&&(d.overflowOffset=d.scrollParent.offset())},drag:function(d,g){var f=b(this).data("draggable"),c=f.options,e=!1;if(f.scrollParent[0]!=document&&f.scrollParent[0].tagName!="HTML"){if(!c.axis||c.axis!="x"){f.overflowOffset.top+f.scrollParent[0].offsetHeight-d.pageY<c.scrollSensitivity?f.scrollParent[0].scrollTop=e=f.scrollParent[0].scrollTop+c.scrollSpeed:d.pageY-f.overflowOffset.top<c.scrollSensitivity&&(f.scrollParent[0].scrollTop=e=f.scrollParent[0].scrollTop-c.scrollSpeed)}if(!c.axis||c.axis!="y"){f.overflowOffset.left+f.scrollParent[0].offsetWidth-d.pageX<c.scrollSensitivity?f.scrollParent[0].scrollLeft=e=f.scrollParent[0].scrollLeft+c.scrollSpeed:d.pageX-f.overflowOffset.left<c.scrollSensitivity&&(f.scrollParent[0].scrollLeft=e=f.scrollParent[0].scrollLeft-c.scrollSpeed)}}else{if(!c.axis||c.axis!="x"){d.pageY-b(document).scrollTop()<c.scrollSensitivity?e=b(document).scrollTop(b(document).scrollTop()-c.scrollSpeed):b(window).height()-(d.pageY-b(document).scrollTop())<c.scrollSensitivity&&(e=b(document).scrollTop(b(document).scrollTop()+c.scrollSpeed))}if(!c.axis||c.axis!="y"){d.pageX-b(document).scrollLeft()<c.scrollSensitivity?e=b(document).scrollLeft(b(document).scrollLeft()-c.scrollSpeed):b(window).width()-(d.pageX-b(document).scrollLeft())<c.scrollSensitivity&&(e=b(document).scrollLeft(b(document).scrollLeft()+c.scrollSpeed))}}e!==!1&&b.ui.ddmanager&&!c.dropBehaviour&&b.ui.ddmanager.prepareOffsets(f,d)}}),b.ui.plugin.add("draggable","snap",{start:function(d,f){var e=b(this).data("draggable"),c=e.options;e.snapElements=[],b(c.snap.constructor!=String?c.snap.items||":data(draggable)":c.snap).each(function(){var g=b(this),h=g.offset();this!=e.element[0]&&e.snapElements.push({item:this,width:g.outerWidth(),height:g.outerHeight(),top:h.top,left:h.left})})},drag:function(q,B){var x=b(this).data("draggable"),E=x.options,w=E.snapTolerance,A=B.offset.left,k=A+x.helperProportions.width,L=B.offset.top,H=L+x.helperProportions.height;for(var D=x.snapElements.length-1;D>=0;D--){var J=x.snapElements[D].left,F=J+x.snapElements[D].width,z=x.snapElements[D].top,I=z+x.snapElements[D].height;if(!(J-w<A&&A<F+w&&z-w<L&&L<I+w||J-w<A&&A<F+w&&z-w<H&&H<I+w||J-w<k&&k<F+w&&z-w<L&&L<I+w||J-w<k&&k<F+w&&z-w<H&&H<I+w)){x.snapElements[D].snapping&&x.options.snap.release&&x.options.snap.release.call(x.element,q,b.extend(x._uiHash(),{snapItem:x.snapElements[D].item})),x.snapElements[D].snapping=!1;continue}if(E.snapMode!="inner"){var j=Math.abs(z-H)<=w,C=Math.abs(I-L)<=w,G=Math.abs(J-k)<=w,e=Math.abs(F-A)<=w;j&&(B.position.top=x._convertPositionTo("relative",{top:z-x.helperProportions.height,left:0}).top-x.margins.top),C&&(B.position.top=x._convertPositionTo("relative",{top:I,left:0}).top-x.margins.top),G&&(B.position.left=x._convertPositionTo("relative",{top:0,left:J-x.helperProportions.width}).left-x.margins.left),e&&(B.position.left=x._convertPositionTo("relative",{top:0,left:F}).left-x.margins.left)}var K=j||C||G||e;if(E.snapMode!="outer"){var j=Math.abs(z-L)<=w,C=Math.abs(I-H)<=w,G=Math.abs(J-A)<=w,e=Math.abs(F-k)<=w;j&&(B.position.top=x._convertPositionTo("relative",{top:z,left:0}).top-x.margins.top),C&&(B.position.top=x._convertPositionTo("relative",{top:I-x.helperProportions.height,left:0}).top-x.margins.top),G&&(B.position.left=x._convertPositionTo("relative",{top:0,left:J}).left-x.margins.left),e&&(B.position.left=x._convertPositionTo("relative",{top:0,left:F-x.helperProportions.width}).left-x.margins.left)}!x.snapElements[D].snapping&&(j||C||G||e||K)&&x.options.snap.snap&&x.options.snap.snap.call(x.element,q,b.extend(x._uiHash(),{snapItem:x.snapElements[D].item})),x.snapElements[D].snapping=j||C||G||e||K}}}),b.ui.plugin.add("draggable","stack",{start:function(d,g){var f=b(this).data("draggable").options,c=b.makeArray(b(f.stack)).sort(function(h,i){return(parseInt(b(h).css("zIndex"),10)||0)-(parseInt(b(i).css("zIndex"),10)||0)});if(!c.length){return}var e=parseInt(c[0].style.zIndex)||0;b(c).each(function(h){this.style.zIndex=e+h}),this[0].style.zIndex=e+c.length}}),b.ui.plugin.add("draggable","zIndex",{start:function(d,f){var e=b(f.helper),c=b(this).data("draggable").options;e.css("zIndex")&&(c._zIndex=e.css("zIndex")),e.css("zIndex",c.zIndex)},stop:function(c,e){var d=b(this).data("draggable").options;d._zIndex&&b(e.helper).css("zIndex",d._zIndex)}})})(jQuery);(function(b,a){b.widget("ui.droppable",{version:"1.9.1",widgetEventPrefix:"drop",options:{accept:"*",activeClass:!1,addClasses:!0,greedy:!1,hoverClass:!1,scope:"default",tolerance:"intersect"},_create:function(){var c=this.options,d=c.accept;this.isover=0,this.isout=1,this.accept=b.isFunction(d)?d:function(f){return f.is(d)},this.proportions={width:this.element[0].offsetWidth,height:this.element[0].offsetHeight},b.ui.ddmanager.droppables[c.scope]=b.ui.ddmanager.droppables[c.scope]||[],b.ui.ddmanager.droppables[c.scope].push(this),c.addClasses&&this.element.addClass("ui-droppable")},_destroy:function(){var c=b.ui.ddmanager.droppables[this.options.scope];for(var d=0;d<c.length;d++){c[d]==this&&c.splice(d,1)}this.element.removeClass("ui-droppable ui-droppable-disabled")},_setOption:function(c,d){c=="accept"&&(this.accept=b.isFunction(d)?d:function(f){return f.is(d)}),b.Widget.prototype._setOption.apply(this,arguments)},_activate:function(c){var d=b.ui.ddmanager.current;this.options.activeClass&&this.element.addClass(this.options.activeClass),d&&this._trigger("activate",c,this.ui(d))},_deactivate:function(c){var d=b.ui.ddmanager.current;this.options.activeClass&&this.element.removeClass(this.options.activeClass),d&&this._trigger("deactivate",c,this.ui(d))},_over:function(c){var d=b.ui.ddmanager.current;if(!d||(d.currentItem||d.element)[0]==this.element[0]){return}this.accept.call(this.element[0],d.currentItem||d.element)&&(this.options.hoverClass&&this.element.addClass(this.options.hoverClass),this._trigger("over",c,this.ui(d)))},_out:function(c){var d=b.ui.ddmanager.current;if(!d||(d.currentItem||d.element)[0]==this.element[0]){return}this.accept.call(this.element[0],d.currentItem||d.element)&&(this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("out",c,this.ui(d)))},_drop:function(d,f){var e=f||b.ui.ddmanager.current;if(!e||(e.currentItem||e.element)[0]==this.element[0]){return !1}var c=!1;return this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function(){var g=b.data(this,"droppable");if(g.options.greedy&&!g.options.disabled&&g.options.scope==e.options.scope&&g.accept.call(g.element[0],e.currentItem||e.element)&&b.ui.intersect(e,b.extend(g,{offset:g.element.offset()}),g.options.tolerance)){return c=!0,!1}}),c?!1:this.accept.call(this.element[0],e.currentItem||e.element)?(this.options.activeClass&&this.element.removeClass(this.options.activeClass),this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("drop",d,this.ui(e)),this.element):!1},ui:function(c){return{draggable:c.currentItem||c.element,helper:c.helper,position:c.position,offset:c.positionAbs}}}),b.ui.intersect=function(B,k,e){if(!k.offset){return !1}var q=(B.positionAbs||B.position.absolute).left,C=q+B.helperProportions.width,j=(B.positionAbs||B.position.absolute).top,A=j+B.helperProportions.height,z=k.offset.left,w=z+k.proportions.width,m=k.offset.top,y=m+k.proportions.height;switch(e){case"fit":return z<=q&&C<=w&&m<=j&&A<=y;case"intersect":return z<q+B.helperProportions.width/2&&C-B.helperProportions.width/2<w&&m<j+B.helperProportions.height/2&&A-B.helperProportions.height/2<y;case"pointer":var v=(B.positionAbs||B.position.absolute).left+(B.clickOffset||B.offset.click).left,g=(B.positionAbs||B.position.absolute).top+(B.clickOffset||B.offset.click).top,x=b.ui.isOver(g,v,m,z,k.proportions.height,k.proportions.width);return x;case"touch":return(j>=m&&j<=y||A>=m&&A<=y||j<m&&A>y)&&(q>=z&&q<=w||C>=z&&C<=w||q<z&&C>w);default:return !1}},b.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(e,j){var g=b.ui.ddmanager.droppables[e.options.scope]||[],d=j?j.type:null,f=(e.currentItem||e.element).find(":data(droppable)").andSelf();b:for(var h=0;h<g.length;h++){if(g[h].options.disabled||e&&!g[h].accept.call(g[h].element[0],e.currentItem||e.element)){continue}for(var c=0;c<f.length;c++){if(f[c]==g[h].element[0]){g[h].proportions.height=0;continue b}}g[h].visible=g[h].element.css("display")!="none";if(!g[h].visible){continue}d=="mousedown"&&g[h]._activate.call(g[h],j),g[h].offset=g[h].element.offset(),g[h].proportions={width:g[h].element[0].offsetWidth,height:g[h].element[0].offsetHeight}}},drop:function(c,e){var d=!1;return b.each(b.ui.ddmanager.droppables[c.options.scope]||[],function(){if(!this.options){return}!this.options.disabled&&this.visible&&b.ui.intersect(c,this,this.options.tolerance)&&(d=this._drop.call(this,e)||d),!this.options.disabled&&this.visible&&this.accept.call(this.element[0],c.currentItem||c.element)&&(this.isout=1,this.isover=0,this._deactivate.call(this,e))}),d},dragStart:function(c,d){c.element.parentsUntil("body").bind("scroll.droppable",function(){c.options.refreshPositions||b.ui.ddmanager.prepareOffsets(c,d)})},drag:function(c,d){c.options.refreshPositions&&b.ui.ddmanager.prepareOffsets(c,d),b.each(b.ui.ddmanager.droppables[c.options.scope]||[],function(){if(this.options.disabled||this.greedyChild||!this.visible){return}var h=b.ui.intersect(c,this,this.options.tolerance),f=!h&&this.isover==1?"isout":h&&this.isover==0?"isover":null;if(!f){return}var g;if(this.options.greedy){var j=this.options.scope,e=this.element.parents(":data(droppable)").filter(function(){return b.data(this,"droppable").options.scope===j});e.length&&(g=b.data(e[0],"droppable"),g.greedyChild=f=="isover"?1:0)}g&&f=="isover"&&(g.isover=0,g.isout=1,g._out.call(g,d)),this[f]=1,this[f=="isout"?"isover":"isout"]=0,this[f=="isover"?"_over":"_out"].call(this,d),g&&f=="isout"&&(g.isout=0,g.isover=1,g._over.call(g,d))})},dragStop:function(c,d){c.element.parentsUntil("body").unbind("scroll.droppable"),c.options.refreshPositions||b.ui.ddmanager.prepareOffsets(c,d)}}})(jQuery);(function(b,a){b.widget("ui.sortable",b.ui.mouse,{version:"1.9.1",widgetEventPrefix:"sort",ready:!1,options:{appendTo:"parent",axis:!1,connectWith:!1,containment:!1,cursor:"auto",cursorAt:!1,dropOnEmpty:!0,forcePlaceholderSize:!1,forceHelperSize:!1,grid:!1,handle:!1,helper:"original",items:"> *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1000},_create:function(){var c=this.options;this.containerCache={},this.element.addClass("ui-sortable"),this.refresh(),this.floating=this.items.length?c.axis==="x"||/left|right/.test(this.items[0].item.css("float"))||/inline|table-cell/.test(this.items[0].item.css("display")):!1,this.offset=this.element.offset(),this._mouseInit(),this.ready=!0},_destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled"),this._mouseDestroy();for(var c=this.items.length-1;c>=0;c--){this.items[c].item.removeData(this.widgetName+"-item")}return this},_setOption:function(c,d){c==="disabled"?(this.options[c]=d,this.widget().toggleClass("ui-sortable-disabled",!!d)):b.Widget.prototype._setOption.apply(this,arguments)},_mouseCapture:function(d,h){var f=this;if(this.reverting){return !1}if(this.options.disabled||this.options.type=="static"){return !1}this._refreshItems(d);var c=null,e=b(d.target).parents().each(function(){if(b.data(this,f.widgetName+"-item")==f){return c=b(this),!1}});b.data(d.target,f.widgetName+"-item")==f&&(c=b(d.target));if(!c){return !1}if(this.options.handle&&!h){var g=!1;b(this.options.handle,c).find("*").andSelf().each(function(){this==d.target&&(g=!0)});if(!g){return !1}}return this.currentItem=c,this._removeCurrentsFromItems(),!0},_mouseStart:function(d,g,f){var c=this.options;this.currentContainer=this,this.refreshPositions(),this.helper=this._createHelper(d),this._cacheHelperProportions(),this._cacheMargins(),this.scrollParent=this.helper.scrollParent(),this.offset=this.currentItem.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},b.extend(this.offset,{click:{left:d.pageX-this.offset.left,top:d.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.helper.css("position","absolute"),this.cssPosition=this.helper.css("position"),this.originalPosition=this._generatePosition(d),this.originalPageX=d.pageX,this.originalPageY=d.pageY,c.cursorAt&&this._adjustOffsetFromHelper(c.cursorAt),this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]},this.helper[0]!=this.currentItem[0]&&this.currentItem.hide(),this._createPlaceholder(),c.containment&&this._setContainment(),c.cursor&&(b("body").css("cursor")&&(this._storedCursor=b("body").css("cursor")),b("body").css("cursor",c.cursor)),c.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",c.opacity)),c.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",c.zIndex)),this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML"&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",d,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions();if(!f){for(var e=this.containers.length-1;e>=0;e--){this.containers[e]._trigger("activate",d,this._uiHash(this))}}return b.ui.ddmanager&&(b.ui.ddmanager.current=this),b.ui.ddmanager&&!c.dropBehaviour&&b.ui.ddmanager.prepareOffsets(this,d),this.dragging=!0,this.helper.addClass("ui-sortable-helper"),this._mouseDrag(d),!0},_mouseDrag:function(e){this.position=this._generatePosition(e),this.positionAbs=this._convertPositionTo("absolute"),this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs);if(this.options.scroll){var j=this.options,g=!1;this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML"?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-e.pageY<j.scrollSensitivity?this.scrollParent[0].scrollTop=g=this.scrollParent[0].scrollTop+j.scrollSpeed:e.pageY-this.overflowOffset.top<j.scrollSensitivity&&(this.scrollParent[0].scrollTop=g=this.scrollParent[0].scrollTop-j.scrollSpeed),this.overflowOffset.left+this.scrollParent[0].offsetWidth-e.pageX<j.scrollSensitivity?this.scrollParent[0].scrollLeft=g=this.scrollParent[0].scrollLeft+j.scrollSpeed:e.pageX-this.overflowOffset.left<j.scrollSensitivity&&(this.scrollParent[0].scrollLeft=g=this.scrollParent[0].scrollLeft-j.scrollSpeed)):(e.pageY-b(document).scrollTop()<j.scrollSensitivity?g=b(document).scrollTop(b(document).scrollTop()-j.scrollSpeed):b(window).height()-(e.pageY-b(document).scrollTop())<j.scrollSensitivity&&(g=b(document).scrollTop(b(document).scrollTop()+j.scrollSpeed)),e.pageX-b(document).scrollLeft()<j.scrollSensitivity?g=b(document).scrollLeft(b(document).scrollLeft()-j.scrollSpeed):b(window).width()-(e.pageX-b(document).scrollLeft())<j.scrollSensitivity&&(g=b(document).scrollLeft(b(document).scrollLeft()+j.scrollSpeed))),g!==!1&&b.ui.ddmanager&&!j.dropBehaviour&&b.ui.ddmanager.prepareOffsets(this,e)}this.positionAbs=this._convertPositionTo("absolute");if(!this.options.axis||this.options.axis!="y"){this.helper[0].style.left=this.position.left+"px"}if(!this.options.axis||this.options.axis!="x"){this.helper[0].style.top=this.position.top+"px"}for(var d=this.items.length-1;d>=0;d--){var f=this.items[d],h=f.item[0],c=this._intersectsWithPointer(f);if(!c){continue}if(f.instance!==this.currentContainer){continue}if(h!=this.currentItem[0]&&this.placeholder[c==1?"next":"prev"]()[0]!=h&&!b.contains(this.placeholder[0],h)&&(this.options.type=="semi-dynamic"?!b.contains(this.element[0],h):!0)){this.direction=c==1?"down":"up";if(this.options.tolerance!="pointer"&&!this._intersectsWithSides(f)){break}this._rearrange(e,f),this._trigger("change",e,this._uiHash());break}}return this._contactContainers(e),b.ui.ddmanager&&b.ui.ddmanager.drag(this,e),this._trigger("sort",e,this._uiHash()),this.lastPositionAbs=this.positionAbs,!1},_mouseStop:function(d,f){if(!d){return}b.ui.ddmanager&&!this.options.dropBehaviour&&b.ui.ddmanager.drop(this,d);if(this.options.revert){var e=this,c=this.placeholder.offset();this.reverting=!0,b(this.helper).animate({left:c.left-this.offset.parent.left-this.margins.left+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollLeft),top:c.top-this.offset.parent.top-this.margins.top+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollTop)},parseInt(this.options.revert,10)||500,function(){e._clear(d)})}else{this._clear(d,f)}return !1},cancel:function(){if(this.dragging){this._mouseUp({target:null}),this.options.helper=="original"?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"):this.currentItem.show();for(var c=this.containers.length-1;c>=0;c--){this.containers[c]._trigger("deactivate",null,this._uiHash(this)),this.containers[c].containerCache.over&&(this.containers[c]._trigger("out",null,this._uiHash(this)),this.containers[c].containerCache.over=0)}}return this.placeholder&&(this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.options.helper!="original"&&this.helper&&this.helper[0].parentNode&&this.helper.remove(),b.extend(this,{helper:null,dragging:!1,reverting:!1,_noFinalSort:null}),this.domPosition.prev?b(this.domPosition.prev).after(this.currentItem):b(this.domPosition.parent).prepend(this.currentItem)),this},serialize:function(c){var e=this._getItemsAsjQuery(c&&c.connected),d=[];return c=c||{},b(e).each(function(){var f=(b(c.item||this).attr(c.attribute||"id")||"").match(c.expression||/(.+)[-=_](.+)/);f&&d.push((c.key||f[1]+"[]")+"="+(c.key&&c.expression?f[1]:f[2]))}),!d.length&&c.key&&d.push(c.key+"="),d.join("&")},toArray:function(c){var e=this._getItemsAsjQuery(c&&c.connected),d=[];return c=c||{},e.each(function(){d.push(b(c.item||this).attr(c.attribute||"id")||"")}),d},_intersectsWith:function(p){var x=this.positionAbs.left,h=x+this.helperProportions.width,d=this.positionAbs.top,k=d+this.helperProportions.height,y=p.left,g=y+p.width,w=p.top,v=w+p.height,m=this.offset.click.top,j=this.offset.click.left,q=d+m>w&&d+m<v&&x+j>y&&x+j<g;return this.options.tolerance=="pointer"||this.options.forcePointerForContainers||this.options.tolerance!="pointer"&&this.helperProportions[this.floating?"width":"height"]>p[this.floating?"width":"height"]?q:y<x+this.helperProportions.width/2&&h-this.helperProportions.width/2<g&&w<d+this.helperProportions.height/2&&k-this.helperProportions.height/2<v},_intersectsWithPointer:function(d){var h=this.options.axis==="x"||b.ui.isOverAxis(this.positionAbs.top+this.offset.click.top,d.top,d.height),f=this.options.axis==="y"||b.ui.isOverAxis(this.positionAbs.left+this.offset.click.left,d.left,d.width),c=h&&f,e=this._getDragVerticalDirection(),g=this._getDragHorizontalDirection();return c?this.floating?g&&g=="right"||e=="down"?2:1:e&&(e=="down"?2:1):!1},_intersectsWithSides:function(d){var g=b.ui.isOverAxis(this.positionAbs.top+this.offset.click.top,d.top+d.height/2,d.height),f=b.ui.isOverAxis(this.positionAbs.left+this.offset.click.left,d.left+d.width/2,d.width),c=this._getDragVerticalDirection(),e=this._getDragHorizontalDirection();return this.floating&&e?e=="right"&&f||e=="left"&&!f:c&&(c=="down"&&g||c=="up"&&!g)},_getDragVerticalDirection:function(){var c=this.positionAbs.top-this.lastPositionAbs.top;return c!=0&&(c>0?"down":"up")},_getDragHorizontalDirection:function(){var c=this.positionAbs.left-this.lastPositionAbs.left;return c!=0&&(c>0?"right":"left")},refresh:function(c){return this._refreshItems(c),this.refreshPositions(),this},_connectWith:function(){var c=this.options;return c.connectWith.constructor==String?[c.connectWith]:c.connectWith},_getItemsAsjQuery:function(f){var k=[],h=[],e=this._connectWith();if(e&&f){for(var g=e.length-1;g>=0;g--){var j=b(e[g]);for(var d=j.length-1;d>=0;d--){var c=b.data(j[d],this.widgetName);c&&c!=this&&!c.options.disabled&&h.push([b.isFunction(c.options.items)?c.options.items.call(c.element):b(c.options.items,c.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),c])}}}h.push([b.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):b(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]);for(var g=h.length-1;g>=0;g--){h[g][0].each(function(){k.push(this)})}return b(k)},_removeCurrentsFromItems:function(){var c=this.currentItem.find(":data("+this.widgetName+"-item)");this.items=b.grep(this.items,function(d){for(var f=0;f<c.length;f++){if(c[f]==d.item[0]){return !1}}return !0})},_refreshItems:function(x){this.items=[],this.containers=[this];var g=this.items,d=[[b.isFunction(this.options.items)?this.options.items.call(this.element[0],x,{item:this.currentItem}):b(this.options.items,this.element),this]],k=this._connectWith();if(k&&this.ready){for(var y=k.length-1;y>=0;y--){var e=b(k[y]);for(var w=e.length-1;w>=0;w--){var v=b.data(e[w],this.widgetName);v&&v!=this&&!v.options.disabled&&(d.push([b.isFunction(v.options.items)?v.options.items.call(v.element[0],x,{item:this.currentItem}):b(v.options.items,v.element),v]),this.containers.push(v))}}}for(var y=d.length-1;y>=0;y--){var p=d[y][1],j=d[y][0];for(var w=0,q=j.length;w<q;w++){var m=b(j[w]);m.data(this.widgetName+"-item",p),g.push({item:m,instance:p,width:0,height:0,left:0,top:0})}}},refreshPositions:function(d){this.offsetParent&&this.helper&&(this.offset.parent=this._getParentOffset());for(var g=this.items.length-1;g>=0;g--){var f=this.items[g];if(f.instance!=this.currentContainer&&this.currentContainer&&f.item[0]!=this.currentItem[0]){continue}var c=this.options.toleranceElement?b(this.options.toleranceElement,f.item):f.item;d||(f.width=c.outerWidth(),f.height=c.outerHeight());var e=c.offset();f.left=e.left,f.top=e.top}if(this.options.custom&&this.options.custom.refreshContainers){this.options.custom.refreshContainers.call(this)}else{for(var g=this.containers.length-1;g>=0;g--){var e=this.containers[g].element.offset();this.containers[g].containerCache.left=e.left,this.containers[g].containerCache.top=e.top,this.containers[g].containerCache.width=this.containers[g].element.outerWidth(),this.containers[g].containerCache.height=this.containers[g].element.outerHeight()}}return this},_createPlaceholder:function(c){c=c||this;var e=c.options;if(!e.placeholder||e.placeholder.constructor==String){var d=e.placeholder;e.placeholder={element:function(){var f=b(document.createElement(c.currentItem[0].nodeName)).addClass(d||c.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper")[0];return d||(f.style.visibility="hidden"),f},update:function(g,f){if(d&&!e.forcePlaceholderSize){return}f.height()||f.height(c.currentItem.innerHeight()-parseInt(c.currentItem.css("paddingTop")||0,10)-parseInt(c.currentItem.css("paddingBottom")||0,10)),f.width()||f.width(c.currentItem.innerWidth()-parseInt(c.currentItem.css("paddingLeft")||0,10)-parseInt(c.currentItem.css("paddingRight")||0,10))}}}c.placeholder=b(e.placeholder.element.call(c.element,c.currentItem)),c.currentItem.after(c.placeholder),e.placeholder.update(c,c.placeholder)},_contactContainers:function(x){var g=null,d=null;for(var k=this.containers.length-1;k>=0;k--){if(b.contains(this.currentItem[0],this.containers[k].element[0])){continue}if(this._intersectsWith(this.containers[k].containerCache)){if(g&&b.contains(this.containers[k].element[0],g.element[0])){continue}g=this.containers[k],d=k}else{this.containers[k].containerCache.over&&(this.containers[k]._trigger("out",x,this._uiHash(this)),this.containers[k].containerCache.over=0)}}if(!g){return}if(this.containers.length===1){this.containers[d]._trigger("over",x,this._uiHash(this)),this.containers[d].containerCache.over=1}else{var y=10000,e=null,w=this.containers[d].floating?"left":"top",v=this.containers[d].floating?"width":"height",p=this.positionAbs[w]+this.offset.click[w];for(var j=this.items.length-1;j>=0;j--){if(!b.contains(this.containers[d].element[0],this.items[j].item[0])){continue}if(this.items[j].item[0]==this.currentItem[0]){continue}var q=this.items[j].item.offset()[w],m=!1;Math.abs(q-p)>Math.abs(q+this.items[j][v]-p)&&(m=!0,q+=this.items[j][v]),Math.abs(q-p)<y&&(y=Math.abs(q-p),e=this.items[j],this.direction=m?"up":"down")}if(!e&&!this.options.dropOnEmpty){return}this.currentContainer=this.containers[d],e?this._rearrange(x,e,null,!0):this._rearrange(x,null,this.containers[d].element,!0),this._trigger("change",x,this._uiHash()),this.containers[d]._trigger("change",x,this._uiHash(this)),this.options.placeholder.update(this.currentContainer,this.placeholder),this.containers[d]._trigger("over",x,this._uiHash(this)),this.containers[d].containerCache.over=1}},_createHelper:function(c){var e=this.options,d=b.isFunction(e.helper)?b(e.helper.apply(this.element[0],[c,this.currentItem])):e.helper=="clone"?this.currentItem.clone():this.currentItem;return d.parents("body").length||b(e.appendTo!="parent"?e.appendTo:this.currentItem[0].parentNode)[0].appendChild(d[0]),d[0]==this.currentItem[0]&&(this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")}),(d[0].style.width==""||e.forceHelperSize)&&d.width(this.currentItem.width()),(d[0].style.height==""||e.forceHelperSize)&&d.height(this.currentItem.height()),d},_adjustOffsetFromHelper:function(c){typeof c=="string"&&(c=c.split(" ")),b.isArray(c)&&(c={left:+c[0],top:+c[1]||0}),"left" in c&&(this.offset.click.left=c.left+this.margins.left),"right" in c&&(this.offset.click.left=this.helperProportions.width-c.right+this.margins.left),"top" in c&&(this.offset.click.top=c.top+this.margins.top),"bottom" in c&&(this.offset.click.top=this.helperProportions.height-c.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var c=this.offsetParent.offset();this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&b.contains(this.scrollParent[0],this.offsetParent[0])&&(c.left+=this.scrollParent.scrollLeft(),c.top+=this.scrollParent.scrollTop());if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&b.ui.ie){c={top:0,left:0}}return{top:c.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:c.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var c=this.currentItem.position();return{top:c.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:c.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.currentItem.css("marginLeft"),10)||0,top:parseInt(this.currentItem.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var d=this.options;d.containment=="parent"&&(d.containment=this.helper[0].parentNode);if(d.containment=="document"||d.containment=="window"){this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,b(d.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(b(d.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]}if(!/^(document|window|parent)$/.test(d.containment)){var f=b(d.containment)[0],e=b(d.containment).offset(),c=b(f).css("overflow")!="hidden";this.containment=[e.left+(parseInt(b(f).css("borderLeftWidth"),10)||0)+(parseInt(b(f).css("paddingLeft"),10)||0)-this.margins.left,e.top+(parseInt(b(f).css("borderTopWidth"),10)||0)+(parseInt(b(f).css("paddingTop"),10)||0)-this.margins.top,e.left+(c?Math.max(f.scrollWidth,f.offsetWidth):f.offsetWidth)-(parseInt(b(f).css("borderLeftWidth"),10)||0)-(parseInt(b(f).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,e.top+(c?Math.max(f.scrollHeight,f.offsetHeight):f.offsetHeight)-(parseInt(b(f).css("borderTopWidth"),10)||0)-(parseInt(b(f).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top]}},_convertPositionTo:function(d,h){h||(h=this.position);var f=d=="absolute"?1:-1,c=this.options,e=this.cssPosition!="absolute"||this.scrollParent[0]!=document&&!!b.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,g=/(html|body)/i.test(e[0].tagName);return{top:h.top+this.offset.relative.top*f+this.offset.parent.top*f-(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():g?0:e.scrollTop())*f,left:h.left+this.offset.relative.left*f+this.offset.parent.left*f-(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():g?0:e.scrollLeft())*f}},_generatePosition:function(f){var k=this.options,h=this.cssPosition!="absolute"||this.scrollParent[0]!=document&&!!b.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,e=/(html|body)/i.test(h[0].tagName);this.cssPosition=="relative"&&(this.scrollParent[0]==document||this.scrollParent[0]==this.offsetParent[0])&&(this.offset.relative=this._getRelativeOffset());var g=f.pageX,j=f.pageY;if(this.originalPosition){this.containment&&(f.pageX-this.offset.click.left<this.containment[0]&&(g=this.containment[0]+this.offset.click.left),f.pageY-this.offset.click.top<this.containment[1]&&(j=this.containment[1]+this.offset.click.top),f.pageX-this.offset.click.left>this.containment[2]&&(g=this.containment[2]+this.offset.click.left),f.pageY-this.offset.click.top>this.containment[3]&&(j=this.containment[3]+this.offset.click.top));if(k.grid){var d=this.originalPageY+Math.round((j-this.originalPageY)/k.grid[1])*k.grid[1];j=this.containment?d-this.offset.click.top<this.containment[1]||d-this.offset.click.top>this.containment[3]?d-this.offset.click.top<this.containment[1]?d+k.grid[1]:d-k.grid[1]:d:d;var c=this.originalPageX+Math.round((g-this.originalPageX)/k.grid[0])*k.grid[0];g=this.containment?c-this.offset.click.left<this.containment[0]||c-this.offset.click.left>this.containment[2]?c-this.offset.click.left<this.containment[0]?c+k.grid[0]:c-k.grid[0]:c:c}}return{top:j-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():e?0:h.scrollTop()),left:g-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():e?0:h.scrollLeft())}},_rearrange:function(g,d,h,f){h?h[0].appendChild(this.placeholder[0]):d.item[0].parentNode.insertBefore(this.placeholder[0],this.direction=="down"?d.item[0]:d.item[0].nextSibling),this.counter=this.counter?++this.counter:1;var c=this.counter;this._delay(function(){c==this.counter&&this.refreshPositions(!f)})},_clear:function(d,f){this.reverting=!1;var e=[];!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem),this._noFinalSort=null;if(this.helper[0]==this.currentItem[0]){for(var c in this._storedCSS){if(this._storedCSS[c]=="auto"||this._storedCSS[c]=="static"){this._storedCSS[c]=""}}this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else{this.currentItem.show()}this.fromOutside&&!f&&e.push(function(g){this._trigger("receive",g,this._uiHash(this.fromOutside))}),(this.fromOutside||this.domPosition.prev!=this.currentItem.prev().not(".ui-sortable-helper")[0]||this.domPosition.parent!=this.currentItem.parent()[0])&&!f&&e.push(function(g){this._trigger("update",g,this._uiHash())}),this!==this.currentContainer&&(f||(e.push(function(g){this._trigger("remove",g,this._uiHash())}),e.push(function(g){return function(h){g._trigger("receive",h,this._uiHash(this))}}.call(this,this.currentContainer)),e.push(function(g){return function(h){g._trigger("update",h,this._uiHash(this))}}.call(this,this.currentContainer))));for(var c=this.containers.length-1;c>=0;c--){f||e.push(function(g){return function(h){g._trigger("deactivate",h,this._uiHash(this))}}.call(this,this.containers[c])),this.containers[c].containerCache.over&&(e.push(function(g){return function(h){g._trigger("out",h,this._uiHash(this))}}.call(this,this.containers[c])),this.containers[c].containerCache.over=0)}this._storedCursor&&b("body").css("cursor",this._storedCursor),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex",this._storedZIndex=="auto"?"":this._storedZIndex),this.dragging=!1;if(this.cancelHelperRemoval){if(!f){this._trigger("beforeStop",d,this._uiHash());for(var c=0;c<e.length;c++){e[c].call(this,d)}this._trigger("stop",d,this._uiHash())}return this.fromOutside=!1,!1}f||this._trigger("beforeStop",d,this._uiHash()),this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.helper[0]!=this.currentItem[0]&&this.helper.remove(),this.helper=null;if(!f){for(var c=0;c<e.length;c++){e[c].call(this,d)}this._trigger("stop",d,this._uiHash())}return this.fromOutside=!1,!0},_trigger:function(){b.Widget.prototype._trigger.apply(this,arguments)===!1&&this.cancel()},_uiHash:function(c){var d=c||this;return{helper:d.helper,placeholder:d.placeholder||b([]),position:d.position,originalPosition:d.originalPosition,offset:d.positionAbs,item:d.currentItem,sender:c?c.element:null}}})})(jQuery);
?>