text: /**
   * Garnish UI toolkit
   *
   * @copyright 2013 Pixel & Tonic, Inc.. All rights reserved.
   * @author    Brandon Kelly <brandon@pixelandtonic.com>
   * @version   0.1.9
   * @license   MIT
   */
  !function(t){function e(){return"undefined"==typeof n&&(n=elementResizeDetectorMaker()),n}function i(e){t(e).trigger("resize")}var s=function(){};if(s.extend=function(t,e){var i=s.prototype.extend;s._prototyping=!0;var n=new this;i.call(n,t),n.base=function(){},delete s._prototyping;var h=n.constructor,o=n.constructor=function(){if(!s._prototyping)if(this._constructing||this.constructor==o)this._constructing=!0,h.apply(this,arguments),delete this._constructing;else if(null!=arguments[0])return(arguments[0].extend||i).call(arguments[0],n)};return o.ancestor=this,o.extend=this.extend,o.forEach=this.forEach,o.implement=this.implement,o.prototype=n,o.toString=this.toString,o.valueOf=function(t){return"object"==t?o:h.valueOf()},i.call(o,e),"function"==typeof o.init&&o.init(),o},s.prototype={extend:function(t,e){if(arguments.length>1){var i=this[t];if(i&&"function"==typeof e&&(!i.valueOf||i.valueOf()!=e.valueOf())&&/\bbase\b/.test(e)){var n=e.valueOf();e=function(){var t=this.base||s.prototype.base;this.base=i;var e=n.apply(this,arguments);return this.base=t,e},e.valueOf=function(t){return"object"==t?e:n},e.toString=s.toString}this[t]=e}else if(t){var h=s.prototype.extend;s._prototyping||"function"==typeof this||(h=this.extend||h);for(var o={toSource:null},r=["constructor","toString","valueOf"],a=s._prototyping?0:1;l=r[a++];)t[l]!=o[l]&&h.call(this,l,t[l]);for(var l in t)if(!o[l]){var g=Object.getOwnPropertyDescriptor(t,l);"undefined"!=typeof g.value?h.call(this,l,g.value):Object.defineProperty(this,l,g)}}return this}},s=s.extend({constructor:function(){this.extend(arguments[0])}},{ancestor:Object,version:"1.1",forEach:function(t,e,i){for(var s in t)void 0===this.prototype[s]&&e.call(i,t[s],s,t)},implement:function(){for(var t=0;t<arguments.length;t++)"function"==typeof arguments[t]?arguments[t](this.prototype):this.prototype.extend(arguments[t]);return this},toString:function(){return String(this.valueOf())}}),"undefined"!=typeof Garnish)throw"Garnish is already defined!";Garnish={$win:t(window),$doc:t(document),$bod:t(document.body)},Garnish.rtl=Garnish.$bod.hasClass("rtl"),Garnish.ltr=!Garnish.rtl,Garnish=t.extend(Garnish,{$scrollContainer:Garnish.$win,DELETE_KEY:8,SHIFT_KEY:16,CTRL_KEY:17,ALT_KEY:18,RETURN_KEY:13,ESC_KEY:27,SPACE_KEY:32,LEFT_KEY:37,UP_KEY:38,RIGHT_KEY:39,DOWN_KEY:40,A_KEY:65,S_KEY:83,CMD_KEY:91,PRIMARY_CLICK:1,SECONDARY_CLICK:3,X_AXIS:"x",Y_AXIS:"y",FX_DURATION:100,TEXT_NODE:3,log:function(t){"undefined"!=typeof console&&"function"==typeof console.log&&console.log(t)},_isMobileBrowser:null,_isMobileOrTabletBrowser:null,isMobileBrowser:function(t){var e=t?"_isMobileOrTabletBrowser":"_isMobileBrowser";if(null===Garnish[e]){var i=navigator.userAgent||navigator.vendor||window.opera;Garnish[e]=new RegExp("(android|bbd+|meego).+mobile|avantgo|bada/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)/|plucker|pocket|psp|series(4|6)0|symbian|treo|up.(browser|link)|vodafone|wap|windows ce|xda|xiino"+(t?"|android|ipad|playbook|silk":""),"i").test(i)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(i.substr(0,4))}return Garnish[e]},isArray:function(t){return t instanceof Array},isJquery:function(t){return t instanceof jQuery},isString:function(t){return"string"==typeof t},hasAttr:function(e,i){var s=t(e).attr(i);return"undefined"!=typeof s&&s!==!1},isTextNode:function(t){return t.nodeType==Garnish.TEXT_NODE},getOffset:function(e){return this.getOffset._offset=t(e).offset(),Garnish.$scrollContainer[0]!=Garnish.$win[0]&&(this.getOffset._offset.top+=Garnish.$scrollContainer.scrollTop(),this.getOffset._offset.left+=Garnish.$scrollContainer.scrollLeft()),this.getOffset._offset},getDist:function(t,e,i,s){return Math.sqrt(Math.pow(t-i,2)+Math.pow(e-s,2))},hitTest:function(e,i,s){return Garnish.hitTest._$elem=t(s),Garnish.hitTest._offset=Garnish.hitTest._$elem.offset(),Garnish.hitTest._x1=Garnish.hitTest._offset.left,Garnish.hitTest._y1=Garnish.hitTest._offset.top,Garnish.hitTest._x2=Garnish.hitTest._x1+Garnish.hitTest._$elem.outerWidth(),Garnish.hitTest._y2=Garnish.hitTest._y1+Garnish.hitTest._$elem.outerHeight(),e>=Garnish.hitTest._x1&&e<Garnish.hitTest._x2&&i>=Garnish.hitTest._y1&&i<Garnish.hitTest._y2},isCursorOver:function(t,e){return Garnish.hitTest(t.pageX,t.pageY,e)},copyTextStyles:function(e,i){var s=t(e),n=t(i);n.css({fontFamily:s.css("fontFamily"),fontSize:s.css("fontSize"),fontWeight:s.css("fontWeight"),letterSpacing:s.css("letterSpacing"),lineHeight:s.css("lineHeight"),textAlign:s.css("textAlign"),textIndent:s.css("textIndent"),whiteSpace:s.css("whiteSpace"),wordSpacing:s.css("wordSpacing"),wordWrap:s.css("wordWrap")})},getBodyScrollTop:function(){return Garnish.getBodyScrollTop._scrollTop=document.body.scrollTop,Garnish.getBodyScrollTop._scrollTop<0?Garnish.getBodyScrollTop._scrollTop=0:(Garnish.getBodyScrollTop._maxScrollTop=Garnish.$bod.outerHeight()-Garnish.$win.height(),Garnish.getBodyScrollTop._scrollTop>Garnish.getBodyScrollTop._maxScrollTop&&(Garnish.getBodyScrollTop._scrollTop=Garnish.getBodyScrollTop._maxScrollTop)),Garnish.getBodyScrollTop._scrollTop},requestAnimationFrame:function(){var t=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||function(t){return window.setTimeout(t,20)};return function(e){return t(e)}}(),cancelAnimationFrame:function(){var t=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.clearTimeout;return function(e){return t(e)}}(),scrollContainerToElement:function(e,i){if("undefined"==typeof i){var s=t(e);n=s.scrollParent()}else var n=t(e),s=t(i);"HTML"!==n.prop("nodeName")&&n[0]!=Garnish.$doc[0]||(n=Garnish.$win);var h=n.scrollTop(),o=s.offset().top;if(n[0]==window)var r=o-h;else var r=o-n.offset().top;var a=!1;if(r<0)a=h+r-10;else{var l=s.outerHeight(),g=n[0]==window?window.innerHeight:n[0].clientHeight;r+l>g&&(a=h+(r-(g-l))+10)}a!==!1&&(n[0]==window?t("html").velocity("scroll",{offset:a+"px",mobileHA:!1}):n.scrollTop(a))},SHAKE_STEPS:10,SHAKE_STEP_DURATION:25,shake:function(e,i){var s=t(e);i||(i="margin-left");var n=parseInt(s.css(i));isNaN(n)&&(n=0);for(var h=0;h<=Garnish.SHAKE_STEPS;h++)!function(t){setTimeout(function(){Garnish.shake._properties={},Garnish.shake._properties[i]=n+(t%2?-1:1)*(10-t),s.velocity(Garnish.shake._properties,Garnish.SHAKE_STEP_DURATION)},Garnish.SHAKE_STEP_DURATION*t)}(h)},getElement:function(e){return t.makeArray(e)[0]},getInputBasename:function(e){var i=t(e).attr("name");return i?i.replace(/\[.*/,""):null},getInputPostVal:function(t){var e=t.attr("type"),i=t.val();return"checkbox"==e||"radio"==e?t.prop("checked")?i:null:Garnish.isArray(i)&&"[]"!=t.attr("name").substr(-2)?i.length?i[i.length-1]:null:i},findInputs:function(e){return t(e).find("input,text,textarea,select,button")},getPostData:function(t){for(var e={},i={},s=Garnish.findInputs(t),n=0;n<s.length;n++){var h=s.eq(n);if(!h.prop("disabled")){var o=h.attr("name");if(o){var r=Garnish.getInputPostVal(h);if(null!==r){var a="[]"==o.substr(-2);if(a){var l=o.substring(0,o.length-2);"undefined"==typeof i[l]&&(i[l]=0)}Garnish.isArray(r)||(r=[r]);for(var g=0;g<r.length;g++){if(a){var o=l+"["+i[l]+"]";i[l]++}e[o]=r[g]}}}}}return e},copyInputValues:function(t,e){for(var i=Garnish.findInputs(t),s=Garnish.findInputs(e),n=0;n<i.length&&"undefined"!=typeof s[n];n++)s.eq(n).val(i.eq(n).val())},isCtrlKeyPressed:function(t){return window.navigator.platform.match(/Mac/)?t.metaKey:t.ctrlKey&&!t.altKey}}),Garnish.Base=s.extend({settings:null,_eventHandlers:null,_namespace:null,_$listeners:null,_disabled:!1,constructor:function(){this._eventHandlers=[],this._namespace=".Garnish"+Math.floor(1e9*Math.random()),this._listeners=[],this.init.apply(this,arguments)},init:t.noop,setSettings:function(e,i){var s="undefined"==typeof this.settings?{}:this.settings;this.settings=t.extend({},s,i,e)},on:function(t,e,i){"function"==typeof e&&(i=e,e={});for(var t=this._normalizeEvents(t),s=0;s<t.length;s++){var n=t[s];this._eventHandlers.push({type:n[0],namespace:n[1],data:e,handler:i})}},off:function(t,e){for(var t=this._normalizeEvents(t),i=0;i<t.length;i++)for(var s=t[i],n=this._eventHandlers.length-1;n>=0;n--){var h=this._eventHandlers[n];h.type!=s[0]||s[1]&&h.namespace!=s[1]||h.handler!==e||this._eventHandlers.splice(n,1)}},trigger:function(e,i){var s={type:e,target:this};"undefined"==typeof params&&(params=[]);for(var n=0;n<this._eventHandlers.length;n++){var h=this._eventHandlers[n];if(h.type==e){var o=t.extend({data:h.data},i,s);h.handler(o)}}},_normalizeEvents:function(t){"string"==typeof t&&(t=t.split(" "));for(var e=0;e<t.length;e++)"string"==typeof t[e]&&(t[e]=t[e].split("."));return t},_splitEvents:function(e){if("string"==typeof e){e=e.split(",");for(var i=0;i<e.length;i++)e[i]=t.trim(e[i])}return e},_formatEvents:function(t){for(var t=this._splitEvents(t).slice(0),e=0;e<t.length;e++)t[e]+=this._namespace;return t.join(" ")},addListener:function(e,i,s,n){var h=t(e);h.length&&(i=this._splitEvents(i),"undefined"==typeof n&&"object"!=typeof s&&(n=s,s={}),n="function"==typeof n?t.proxy(n,this):t.proxy(this,n),h.on(this._formatEvents(i),s,t.proxy(function(){this._disabled||n.apply(this,arguments)},this)),t.inArray(e,this._listeners)==-1&&this._listeners.push(e))},removeListener:function(e,i){t(e).off(this._formatEvents(i))},removeAllListeners:function(e){t(e).off(this._namespace)},disable:function(){this._disabled=!0},enable:function(){this._disabled=!1},destroy:function(){this.trigger("destroy"),this.removeAllListeners(this._listeners)}});var n;t.extend(jQuery.event.special,{activate:{setup:function(e,i,s){var n=(this._namespace+"-activate",t(this));n.on({"mousedown.garnish-activate":function(t){t.preventDefault()},"click.garnish-activate":function(t){t.preventDefault(),n.hasClass("disabled")||n.trigger("activate")},"keydown.garnish-activate":function(t){this==n[0]&&t.keyCode==Garnish.SPACE_KEY&&(t.preventDefault(),n.hasClass("disabled")||(n.addClass("active"),Garnish.$doc.on("keyup.garnish-activate",function(t){n.removeClass("active"),t.keyCode==Garnish.SPACE_KEY&&(t.preventDefault(),n.trigger("activate")),Garnish.$doc.off("keyup.garnish-activate")})))}}),n.hasClass("disabled")?n.removeAttr("tabindex"):n.attr("tabindex","0")},teardown:function(){t(this).off(".garnish-activate")}},textchange:{setup:function(e,i,s){var n=t(this);n.data("garnish-textchange-value",n.val()),n.on("keypress.garnish-textchange keyup.garnish-textchange change.garnish-textchange blur.garnish-textchange",function(t){var e=n.val();e!=n.data("garnish-textchange-value")&&(n.data("garnish-textchange-value",e),n.trigger("textchange"))})},teardown:function(){t(this).off(".garnish-textchange")},handle:function(e,i){var s=this,n=arguments,h=i&&"undefined"!=typeof i.delay?i.delay:e.data&&"undefined"!=typeof e.data.delay?e.data.delay:null,o=e.handleObj,r=t.data(e.target);return h?(r.delayTimeout&&clearTimeout(r.delayTimeout),void(r.delayTimeout=setTimeout(function(){o.handler.apply(s,n)},h))):o.handler.apply(s,n)}},resize:{setup:function(s,n,h){return this!=window&&(t("> :last-child",this).addClass("last"),void e().listenTo(this,i))},teardown:function(){return this!=window&&void e().removeListener(this,i)}}}),jQuery.each(["activate","textchange","resize"],function(t,e){jQuery.fn[e]=function(t,i){return arguments.length>0?this.on(e,null,t,i):this.trigger(e)}}),Garnish.BaseDrag=Garnish.Base.extend({$items:null,dragging:!1,mousedownX:null,mousedownY:null,realMouseX:null,realMouseY:null,mouseX:null,mouseY:null,mouseDistX:null,mouseDistY:null,mouseOffsetX:null,mouseOffsetY:null,$targetItem:null,scrollProperty:null,scrollAxis:null,scrollDist:null,scrollProxy:null,scrollFrame:null,_:null,init:function(e,i){"undefined"==typeof i&&t.isPlainObject(e)&&(i=e,e=null),this.settings=t.extend({},Garnish.BaseDrag.defaults,i),this.$items=t(),this._={},e&&this.addItems(e)},allowDragging:function(){return!0},startDragging:function(){this.dragging=!0,this.onDragStart()},drag:function(e){e&&(this.drag._scrollProperty=null,this.settings.axis!=Garnish.X_AXIS&&(this.drag._winScrollTop=Garnish.$win.scrollTop(),this.drag._minMouseScrollY=this.drag._winScrollTop+Garnish.BaseDrag.windowScrollTargetSize,this.mouseY<this.drag._minMouseScrollY?(this.drag._scrollProperty="scrollTop",this.drag._scrollAxis="Y",this.drag._scrollDist=Math.round((this.mouseY-this.drag._minMouseScrollY)/2)):(this.drag._maxMouseScrollY=this.drag._winScrollTop+Garnish.$win.height()-Garnish.BaseDrag.windowScrollTargetSize,this.mouseY>this.drag._maxMouseScrollY&&(this.drag._scrollProperty="scrollTop",this.drag._scrollAxis="Y",this.drag._scrollDist=Math.round((this.mouseY-this.drag._maxMouseScrollY)/2)))),this.drag._scrollProperty||this.settings.axis==Garnish.Y_AXIS||(this.drag._winScrollLeft=Garnish.$win.scrollLeft(),this.drag._minMouseScrollX=this.drag._winScrollLeft+Garnish.BaseDrag.windowScrollTargetSize,this.mouseX<this.drag._minMouseScrollX?(this.drag._scrollProperty="scrollLeft",this.drag._scrollAxis="X",this.drag._scrollDist=Math.round((this.mouseX-this.drag._minMouseScrollX)/2)):(this.drag._maxMouseScrollX=this.drag._winScrollLeft+Garnish.$win.width()-Garnish.BaseDrag.windowScrollTargetSize,this.mouseX>this.drag._maxMouseScrollX&&(this.drag._scrollProperty="scrollLeft",this.drag._scrollAxis="X",this.drag._scrollDist=Math.round((this.mouseX-this.drag._maxMouseScrollX)/2)))),this.drag._scrollProperty?(this.scrollProperty||(this.scrollProxy||(this.scrollProxy=t.proxy(this,"_scrollWindow")),this.scrollFrame&&(Garnish.cancelAnimationFrame(this.scrollFrame),this.scrollFrame=null),this.scrollFrame=Garnish.requestAnimationFrame(this.scrollProxy)),this.scrollProperty=this.drag._scrollProperty,this.scrollAxis=this.drag._scrollAxis,this.scrollDist=this.drag._scrollDist):this._cancelWindowScroll()),this.onDrag()},stopDragging:function(){this.dragging=!1,this.onDragStop(),this._cancelWindowScroll()},addItems:function(e){e=t.makeArray(e);for(var i=0;i<e.length;i++){var s=e[i];t.data(s,"drag")&&(Garnish.log("Element was added to more than one dragger"),t.data(s,"drag").removeItems(s)),t.data(s,"drag",this),this.addListener(s,"mousedown","_handleMouseDown")}this.$items=this.$items.add(e)},removeItems:function(e){e=t.makeArray(e);for(var i=0;i<e.length;i++){var s=e[i],n=t.inArray(s,this.$items);n!=-1&&(this._deinitItem(s),this.$items.splice(n,1))}},removeAllItems:function(){for(var e=0;e<this.$items.length;e++)this._deinitItem(this.$items[e]);this.$items=t()},destroy:function(){this.removeAllItems(),this.base()},onDragStart:function(){Garnish.requestAnimationFrame(t.proxy(function(){this.trigger("dragStart"),this.settings.onDragStart()},this))},onDrag:function(){Garnish.requestAnimationFrame(t.proxy(function(){this.trigger("drag"),this.settings.onDrag()},this))},onDragStop:function(){Garnish.requestAnimationFrame(t.proxy(function(){this.trigger("dragStop"),this.settings.onDragStop()},this))},_handleMouseDown:function(e){if(e.which==Garnish.PRIMARY_CLICK&&!this.$targetItem){var i=t(e.target),s=this._getItemHandle(e.currentTarget);if((i.is(s)||i.closest(s).length)&&(e.currentTarget==e.target||!this.settings.ignoreHandleSelector||!i.is(this.settings.ignoreHandleSelector)&&!i.closest(this.settings.ignoreHandleSelector).length)&&(e.preventDefault(),this.allowDragging())){this.$targetItem=t(e.currentTarget),this.mousedownX=this.mouseX=e.pageX,this.mousedownY=this.mouseY=e.pageY;var n=this.$targetItem.offset();this.mouseOffsetX=e.pageX-n.left,this.mouseOffsetY=e.pageY-n.top,this.addListener(Garnish.$doc,"mousemove","_handleMouseMove"),this.addListener(Garnish.$doc,"mouseup","_handleMouseUp")}}},_getItemHandle:function(e){if(this.settings.handle){if("object"==typeof this.settings.handle)return t(this.settings.handle);if("string"==typeof this.settings.handle)return t(this.settings.handle,e);if("function"==typeof this.settings.handle)return t(this.settings.handle(e))}return t(e)},_handleMouseMove:function(t){t.preventDefault(),this.realMouseX=t.pageX,this.realMouseY=t.pageY,this.settings.axis!=Garnish.Y_AXIS&&(this.mouseX=t.pageX),this.settings.axis!=Garnish.X_AXIS&&(this.mouseY=t.pageY),this.mouseDistX=this.mouseX-this.mousedownX,this.mouseDistY=this.mouseY-this.mousedownY,this.dragging||(this._handleMouseMove._mouseDist=Garnish.getDist(this.mousedownX,this.mousedownY,this.realMouseX,this.realMouseY),this._handleMouseMove._mouseDist>=Garnish.BaseDrag.minMouseDist&&this.startDragging()),this.dragging&&this.drag(!0)},_handleMouseUp:function(t){this.removeAllListeners(Garnish.$doc),this.dragging&&this.stopDragging(),this.$targetItem=null},_scrollWindow:function(){this._.scrollPos=Garnish.$scrollContainer[this.scrollProperty](),Garnish.$scrollContainer[this.scrollProperty](this._.scrollPos+this.scrollDist),this["mouse"+this.scrollAxis]-=this._.scrollPos-Garnish.$scrollContainer[this.scrollProperty](),this["realMouse"+this.scrollAxis]=this["mouse"+this.scrollAxis],this.drag(),this.scrollFrame=Garnish.requestAnimationFrame(this.scrollProxy)},_cancelWindowScroll:function(){this.scrollFrame&&(Garnish.cancelAnimationFrame(this.scrollFrame),this.scrollFrame=null),this.scrollProperty=null,this.scrollAxis=null,this.scrollDist=null},_deinitItem:function(e){this.removeAllListeners(e),t.removeData(e,"drag")}},{minMouseDist:1,windowScrollTargetSize:25,defaults:{handle:null,axis:null,ignoreHandleSelector:"input, textarea, button, select, .btn",onDragStart:t.noop,onDrag:t.noop,onDragStop:t.noop}}),Garnish.CheckboxSelect=Garnish.Base.extend({$container:null,$all:null,$options:null,init:function(e){this.$container=t(e),this.$container.data("checkboxSelect")&&(Garnish.log("Double-instantiating a checkbox select on an element"),this.$container.data("checkbox-select").destroy()),this.$container.data("checkboxSelect",this);var i=this.$container.find("input");this.$all=i.filter(".all:first"),this.$options=i.not(this.$all),this.addListener(this.$all,"change","onAllChange")},onAllChange:function(){var t=this.$all.prop("checked");this.$options.prop({checked:t,disabled:t})},destroy:function(){this.$container.removeData("checkboxSelect"),this.base()}}),Garnish.ContextMenu=Garnish.Base.extend({$target:null,options:null,$menu:null,showingMenu:!1,init:function(e,i,s){this.$target=t(e),this.$target.data("contextmenu")&&(Garnish.log("Double-instantiating a context menu on an element"),this.$target.data("contextmenu").destroy()),this.$target.data("contextmenu",this),this.options=i,this.setSettings(s,Garnish.ContextMenu.defaults),Garnish.ContextMenu.counter++,this.enable()},buildMenu:function(){this.$menu=t('<div class="'+this.settings.menuClass+'" style="display: none" />');var e=t("<ul/>").appendTo(this.$menu);for(var i in this.options){var s=this.options[i];if("-"==s)t("<hr/>").appendTo(this.$menu),e=t("<ul/>").appendTo(this.$menu);else{var n=t("<li></li>").appendTo(e),h=t("<a>"+s.label+"</a>").appendTo(n);"function"==typeof s.onClick&&function(e,i){setTimeout(t.proxy(function(){e.mousedown(t.proxy(function(e){this.hideMenu(),i.call(this.currentTarget,t.extend(e,{currentTarget:this.currentTarget}))},this))},this),1)}.call(this,h,s.onClick)}}},showMenu:function(e){"mousedown"==e.type&&e.which!=Garnish.SECONDARY_CLICK||("contextmenu"==e.type&&e.preventDefault(),this.showing&&e.currentTarget==this.currentTarget||(this.currentTarget=e.currentTarget,this.$menu||this.buildMenu(),this.$menu.appendTo(document.body),this.$menu.show(),this.$menu.css({left:e.pageX+1,top:e.pageY-4}),this.showing=!0,setTimeout(t.proxy(function(){this.addListener(Garnish.$doc,"mousedown","hideMenu")},this),0)))},hideMenu:function(){this.removeListener(Garnish.$doc,"mousedown"),this.$menu.hide(),this.showing=!1},enable:function(){this.addListener(this.$target,"contextmenu,mousedown","showMenu")},disable:function(){this.removeListener(this.$target,"contextmenu,mousedown")},destroy:function(){this.$target.removeData("contextmenu"),this.base()}},{defaults:{menuClass:"menu"},counter:0}),Garnish.Drag=Garnish.BaseDrag.extend({targetItemWidth:null,targetItemHeight:null,targetItemPositionInDraggee:null,$draggee:null,otherItems:null,totalOtherItems:null,helpers:null,helperTargets:null,helperPositions:null,helperLagIncrement:null,updateHelperPosProxy:null,updateHelperPosFrame:null,lastMouseX:null,lastMouseY:null,_returningHelpersToDraggees:!1,init:function(e,i){"undefined"==typeof i&&t.isPlainObject(e)&&(i=e,e=null),i=t.extend({},Garnish.Drag.defaults,i),this.base(e,i)},allowDragging:function(){return!this._returningHelpersToDraggees},startDragging:function(){this.helpers=[],this.helperTargets=[],this.helperPositions=[],this.lastMouseX=this.lastMouseY=null,this.targetItemWidth=this.$targetItem.outerWidth(),this.targetItemHeight=this.$targetItem.outerHeight(),this.draggeeDisplay=this.$targetItem.css("display"),this.setDraggee(this.findDraggee()),this.otherItems=[];for(var e=0;e<this.$items.length;e++){var i=this.$items[e];t.inArray(i,this.$draggee)==-1&&this.otherItems.push(i)}this.totalOtherItems=this.otherItems.length,this.updateHelperPosProxy||(this.updateHelperPosProxy=t.proxy(this,"_updateHelperPos")),this.helperLagIncrement=1==this.helpers.length?0:this.settings.helperLagIncrementDividend/(this.helpers.length-1),this.updateHelperPosFrame=Garnish.requestAnimationFrame(this.updateHelperPosProxy),this.base()},setDraggee:function(e){if(this.targetItemPositionInDraggee=t.inArray(this.$targetItem[0],e.add(this.$targetItem[0])),this.$draggee=t([this.$targetItem[0]].concat(e.not(this.$targetItem).toArray())),this.settings.singleHelper)this._createHelper(0);else for(var i=0;i<this.$draggee.length;i++)this._createHelper(i);this.settings.removeDraggee?this.$draggee.hide():this.settings.collapseDraggees?(this.$targetItem.css("visibility","hidden"),this.$draggee.not(this.$targetItem).hide()):this.$draggee.css("visibility","hidden")},appendDraggee:function(e){if(e.length){if(!this.settings.collapseDraggees)var i=this.$draggee.length;if(this.$draggee=t(this.$draggee.toArray().concat(e.toArray())),!this.settings.collapseDraggees)for(var s=this.$draggee.length,n=i;n<s;n++)this._createHelper(n);this.settings.removeDraggee||this.settings.collapseDraggees?e.hide():e.css("visibility","hidden")}},drag:function(t){this.draggeeVirtualMidpointX=this.mouseX-this.mouseOffsetX+this.targetItemWidth/2,this.draggeeVirtualMidpointY=this.mouseY-this.mouseOffsetY+this.targetItemHeight/2,this.base(t)},stopDragging:function(){Garnish.cancelAnimationFrame(this.updateHelperPosFrame),this.base()},findDraggee:function(){switch(typeof this.settings.filter){case"function":return this.settings.filter();case"string":return this.$items.filter(this.settings.filter);default:return this.$targetItem}},getHelperTargetX:function(){return this.mouseX-this.mouseOffsetX},getHelperTargetY:function(){return this.mouseY-this.mouseOffsetY},returnHelpersToDraggees:function(){this._returningHelpersToDraggees=!0;for(var e=0;e<this.helpers.length;e++){var i=this.$draggee.eq(e),s=this.helpers[e];i.css({display:this.draggeeDisplay,visibility:"hidden"});var n=i.offset();if(0==e)var h=t.proxy(this,"_showDraggee");else var h=null;s.velocity({left:n.left,top:n.top},Garnish.FX_DURATION,h)}},onReturnHelpersToDraggees:function(){Garnish.requestAnimationFrame(t.proxy(function(){this.trigger("returnHelpersToDraggees"),this.settings.onReturnHelpersToDraggees()},this))},_createHelper:function(e){var i=this.$draggee.eq(e),s=i.clone().addClass("draghelper");this.settings.copyDraggeeInputValuesToHelper&&Garnish.copyInputValues(i,s),s.find("[name]").attr("name",""),s.css({width:i.width()+1,height:i.height(),margin:0}),this.settings.helper&&(s="function"==typeof this.settings.helper?this.settings.helper(s):t(this.settings.helper).append(s)),s.appendTo(Garnish.$bod);var n=this._getHelperTarget(e);s.css({position:"absolute",top:n.top,left:n.left,zIndex:this.settings.helperBaseZindex+this.$draggee.length-e,opacity:this.settings.helperOpacity}),this.helperPositions[e]={top:n.top,left:n.left},this.helpers.push(s)},_updateHelperPos:function(){if(this.mouseX!==this.lastMouseX||this.mouseY!==this.lastMouseY){for(this._updateHelperPos._i=0;this._updateHelperPos._i<this.helpers.length;this._updateHelperPos._i++)this.helperTargets[this._updateHelperPos._i]=this._getHelperTarget(this._updateHelperPos._i);this.lastMouseX=this.mouseX,this.lastMouseY=this.mouseY}for(this._updateHelperPos._j=0;this._updateHelperPos._j<this.helpers.length;this._updateHelperPos._j++)this._updateHelperPos._lag=this.settings.helperLagBase+this.helperLagIncrement*this._updateHelperPos._j,this.helperPositions[this._updateHelperPos._j]={left:this.helperPositions[this._updateHelperPos._j].left+(this.helperTargets[this._updateHelperPos._j].left-this.helperPositions[this._updateHelperPos._j].left)/this._updateHelperPos._lag,top:this.helperPositions[this._updateHelperPos._j].top+(this.helperTargets[this._updateHelperPos._j].top-this.helperPositions[this._updateHelperPos._j].top)/this._updateHelperPos._lag},this.helpers[this._updateHelperPos._j].css(this.helperPositions[this._updateHelperPos._j]);this.updateHelperPosFrame=Garnish.requestAnimationFrame(this.updateHelperPosProxy)},_getHelperTarget:function(t){return{left:this.getHelperTargetX()+this.settings.helperSpacingX*t,top:this.getHelperTargetY()+this.settings.helperSpacingY*t}},_showDraggee:function(){for(var t=0;t<this.helpers.length;t++)this.helpers[t].remove();this.helpers=null,this.$draggee.show().css("visibility","inherit"),this.onReturnHelpersToDraggees(),this._returningHelpersToDraggees=!1}},{defaults:{filter:null,singleHelper:!1,collapseDraggees:!1,removeDraggee:!1,copyDraggeeInputValuesToHelper:!1,helperOpacity:1,helper:null,helperBaseZindex:1e3,helperLagBase:1,helperLagIncrementDividend:1.5,helperSpacingX:5,helperSpacingY:5,onReturnHelpersToDraggees:t.noop}}),Garnish.DragDrop=Garnish.Drag.extend({$dropTargets:null,$activeDropTarget:null,init:function(e){e=t.extend({},Garnish.DragDrop.defaults,e),this.base(e)},updateDropTargets:function(){this.settings.dropTargets&&("function"==typeof this.settings.dropTargets?this.$dropTargets=t(this.settings.dropTargets()):this.$dropTargets=t(this.settings.dropTargets),this.$dropTargets.length||(this.$dropTargets=null))},onDragStart:function(){this.updateDropTargets(),this.$activeDropTarget=null,this.base()},onDrag:function(){if(this.$dropTargets){for(this.onDrag._activeDropTarget=null,this.onDrag._i=0;this.onDrag._i<this.$dropTargets.length;this.onDrag._i++)if(this.onDrag._elem=this.$dropTargets[this.onDrag._i],Garnish.hitTest(this.mouseX,this.mouseY,this.onDrag._elem)){this.onDrag._activeDropTarget=this.onDrag._elem;break}(this.$activeDropTarget&&this.onDrag._activeDropTarget!=this.$activeDropTarget[0]||!this.$activeDropTarget&&null!==this.onDrag._activeDropTarget)&&(this.$activeDropTarget&&this.$activeDropTarget.removeClass(this.settings.activeDropTargetClass),this.onDrag._activeDropTarget?this.$activeDropTarget=t(this.onDrag._activeDropTarget).addClass(this.settings.activeDropTargetClass):this.$activeDropTarget=null,this.settings.onDropTargetChange(this.$activeDropTarget))}this.base()},onDragStop:function(){this.$dropTargets&&this.$activeDropTarget&&this.$activeDropTarget.removeClass(this.settings.activeDropTargetClass),this.base()},fadeOutHelpers:function(){for(var t=0;t<this.helpers.length;t++)!function(t){t.velocity("fadeOut",{duration:Garnish.FX_DURATION,complete:function(){t.remove()}})}(this.helpers[t])}},{defaults:{dropTargets:null,onDropTargetChange:t.noop,activeDropTargetClass:"active"}}),Garnish.DragMove=Garnish.BaseDrag.extend({onDrag:function(t,e){this.$targetItem.css({left:this.mouseX-this.mouseOffsetX,top:this.mouseY-this.mouseOffsetY})}}),Garnish.DragSort=Garnish.Drag.extend({$heightedContainer:null,$insertion:null,insertionVisible:!1,oldDraggeeIndexes:null,newDraggeeIndexes:null,closestItem:null,_midpointVersion:0,_$prevItem:null,init:function(e,i){"undefined"==typeof i&&t.isPlainObject(e)&&(i=e,e=null),i=t.extend({},Garnish.DragSort.defaults,i),this.base(e,i)},createInsertion:function(){if(this.settings.insertion)return t("function"==typeof this.settings.insertion?this.settings.insertion(this.$draggee):this.settings.insertion)},getHelperTargetX:function(){return 1!=this.settings.magnetStrength?(this.getHelperTargetX._draggeeOffsetX=this.$draggee.offset().left,this.getHelperTargetX._draggeeOffsetX+(this.mouseX-this.mouseOffsetX-this.getHelperTargetX._draggeeOffsetX)/this.settings.magnetStrength):this.base()},getHelperTargetY:function(){return 1!=this.settings.magnetStrength?(this.getHelperTargetY._draggeeOffsetY=this.$draggee.offset().top,this.getHelperTargetY._draggeeOffsetY+(this.mouseY-this.mouseOffsetY-this.getHelperTargetY._draggeeOffsetY)/this.settings.magnetStrength):this.base()},canInsertBefore:function(t){return!0},canInsertAfter:function(t){return!0},onDragStart:function(){if(this.oldDraggeeIndexes=this._getDraggeeIndexes(),this.settings.moveTargetItemToFront&&this.$draggee.length>1&&this._getItemIndex(this.$draggee[0])>this._getItemIndex(this.$draggee[1])&&this.$draggee.first().insertBefore(this.$draggee[1]),this.$insertion=this.createInsertion(),this._placeInsertionWithDraggee(),this.closestItem=null,this._clearMidpoints(),this.settings.container)for(this.$heightedContainer=t(this.settings.container);!this.$heightedContainer.height();)this.$heightedContainer=this.$heightedContainer.parent();this.base()},onDrag:function(){this.$heightedContainer&&!Garnish.hitTest(this.mouseX,this.mouseY,this.$heightedContainer)?this.closestItem&&(this.closestItem=null,this._removeInsertion()):this.closestItem!==(this.closestItem=this._getClosestItem())&&null!==this.closestItem&&this._updateInsertion(),this.base()},onDragStop:function(){this._removeInsertion(),this.settings.moveTargetItemToFront||0==this.targetItemPositionInDraggee||this.$targetItem.insertAfter(this.$draggee.eq(this.targetItemPositionInDraggee)),this.returnHelpersToDraggees(),this.base(),this.$items=t().add(this.$items),this.newDraggeeIndexes=this._getDraggeeIndexes(),this.newDraggeeIndexes.join(",")!=this.oldDraggeeIndexes.join(",")&&this.onSortChange()},onInsertionPointChange:function(){Garnish.requestAnimationFrame(t.proxy(function(){this.trigger("insertionPointChange"),this.settings.onInsertionPointChange()},this))},onSortChange:function(){Garnish.requestAnimationFrame(t.proxy(function(){this.trigger("sortChange"),this.settings.onSortChange()},this))},_getItemIndex:function(e){
  return t.inArray(e,this.$items)},_getDraggeeIndexes:function(){for(var t=[],e=0;e<this.$draggee.length;e++)t.push(this._getItemIndex(this.$draggee[e]));return t},_getClosestItem:function(){for(this._getClosestItem._closestItem=null,this.settings.removeDraggee?this.insertionVisible&&this._testForClosestItem(this.$insertion[0]):this._testForClosestItem(this.$draggee[0]),this._getClosestItem._closestItem&&(this._getClosestItem._midpoint=this._getItemMidpoint(this._getClosestItem._closestItem)),this.settings.axis!=Garnish.Y_AXIS&&(this._getClosestItem._startXDist=this._getClosestItem._lastXDist=this._getClosestItem._closestItem?Math.abs(this._getClosestItem._midpoint.x-this.draggeeVirtualMidpointX):null),this.settings.axis!=Garnish.X_AXIS&&(this._getClosestItem._startYDist=this._getClosestItem._lastYDist=this._getClosestItem._closestItem?Math.abs(this._getClosestItem._midpoint.y-this.draggeeVirtualMidpointY):null),this._getClosestItem._$otherItem=this.$draggee.first().prev();this._getClosestItem._$otherItem.length&&(this._getClosestItem._midpoint=this._getItemMidpoint(this._getClosestItem._$otherItem[0]),this.settings.axis!=Garnish.Y_AXIS&&(this._getClosestItem._xDist=Math.abs(this._getClosestItem._midpoint.x-this.draggeeVirtualMidpointX)),this.settings.axis!=Garnish.X_AXIS&&(this._getClosestItem._yDist=Math.abs(this._getClosestItem._midpoint.y-this.draggeeVirtualMidpointY)),!(this.settings.axis==Garnish.Y_AXIS||null!==this._getClosestItem._lastXDist&&this._getClosestItem._xDist>this._getClosestItem._lastXDist)||!(this.settings.axis==Garnish.X_AXIS||null!==this._getClosestItem._lastYDist&&this._getClosestItem._yDist>this._getClosestItem._lastYDist));)this.settings.axis!=Garnish.Y_AXIS&&(this._getClosestItem._lastXDist=this._getClosestItem._xDist),this.settings.axis!=Garnish.X_AXIS&&(this._getClosestItem._lastYDist=this._getClosestItem._yDist),this.canInsertBefore(this._getClosestItem._$otherItem)&&this._testForClosestItem(this._getClosestItem._$otherItem[0]),this._getClosestItem._$otherItem=this._getClosestItem._$otherItem.prev();for(this.settings.axis!=Garnish.Y_AXIS&&(this._getClosestItem._lastXDist=this._getClosestItem._startXDist),this.settings.axis!=Garnish.X_AXIS&&(this._getClosestItem._lastYDist=this._getClosestItem._startYDist),this._getClosestItem._$otherItem=this.$draggee.last().next();this._getClosestItem._$otherItem.length&&(this._getClosestItem._midpoint=this._getItemMidpoint(this._getClosestItem._$otherItem[0]),this.settings.axis!=Garnish.Y_AXIS&&(this._getClosestItem._xDist=Math.abs(this._getClosestItem._midpoint.x-this.draggeeVirtualMidpointX)),this.settings.axis!=Garnish.X_AXIS&&(this._getClosestItem._yDist=Math.abs(this._getClosestItem._midpoint.y-this.draggeeVirtualMidpointY)),!(this.settings.axis==Garnish.Y_AXIS||null!==this._getClosestItem._lastXDist&&this._getClosestItem._xDist>this._getClosestItem._lastXDist)||!(this.settings.axis==Garnish.X_AXIS||null!==this._getClosestItem._lastYDist&&this._getClosestItem._yDist>this._getClosestItem._lastYDist));)this.settings.axis!=Garnish.Y_AXIS&&(this._getClosestItem._lastXDist=this._getClosestItem._xDist),this.settings.axis!=Garnish.X_AXIS&&(this._getClosestItem._lastYDist=this._getClosestItem._yDist),this.canInsertAfter(this._getClosestItem._$otherItem)&&this._testForClosestItem(this._getClosestItem._$otherItem[0]),this._getClosestItem._$otherItem=this._getClosestItem._$otherItem.next();return this._getClosestItem._closestItem==this.$draggee[0]||this.insertionVisible&&this._getClosestItem._closestItem==this.$insertion[0]?null:this._getClosestItem._closestItem},_clearMidpoints:function(){this._midpointVersion++,this._$prevItem=null},_getItemMidpoint:function(e){return t.data(e,"midpointVersion")!=this._midpointVersion&&(this._getItemMidpoint._repositionDraggee=!this.settings.axis&&(!this.settings.removeDraggee||this.insertionVisible)&&e!=this.$draggee[0]&&(!this.$insertion||e!=this.$insertion.get(0)),this._getItemMidpoint._repositionDraggee?(this._$prevItem||(this._$prevItem=(this.insertionVisible?this.$insertion:this.$draggee).first().prev()),this._moveDraggeeToItem(e),this.settings.removeDraggee?this._getItemMidpoint._$item=this.$insertion:this._getItemMidpoint._$item=this.$draggee):this._getItemMidpoint._$item=t(e),this._getItemMidpoint._offset=this._getItemMidpoint._$item.offset(),t.data(e,"midpoint",{x:this._getItemMidpoint._offset.left+this._getItemMidpoint._$item.outerWidth()/2,y:this._getItemMidpoint._offset.top+this._getItemMidpoint._$item.outerHeight()/2}),t.data(e,"midpointVersion",this._midpointVersion),delete this._getItemMidpoint._$item,delete this._getItemMidpoint._offset,this._getItemMidpoint._repositionDraggee&&(this._$prevItem.length?this.$draggee.insertAfter(this._$prevItem):this.$draggee.prependTo(this.$draggee.parent()),this._placeInsertionWithDraggee())),t.data(e,"midpoint")},_testForClosestItem:function(t){this._testForClosestItem._midpoint=this._getItemMidpoint(t),this._testForClosestItem._mouseDistX=Math.abs(this._testForClosestItem._midpoint.x-this.draggeeVirtualMidpointX),this._testForClosestItem._mouseDistY=Math.abs(this._testForClosestItem._midpoint.y-this.draggeeVirtualMidpointY),(null===this._getClosestItem._closestItem||this._testForClosestItem._mouseDistY<this._getClosestItem._closestItemMouseDistY||this._testForClosestItem._mouseDistY==this._getClosestItem._closestItemMouseDistY&&this._testForClosestItem._mouseDistX<=this._getClosestItem._closestItemMouseDistX)&&(this._getClosestItem._closestItem=t,this._getClosestItem._closestItemMouseDistX=this._testForClosestItem._mouseDistX,this._getClosestItem._closestItemMouseDistY=this._testForClosestItem._mouseDistY)},_updateInsertion:function(){this.closestItem&&this._moveDraggeeToItem(this.closestItem),this._clearMidpoints(),this.onInsertionPointChange()},_moveDraggeeToItem:function(e){this.$draggee.index()<t(e).index()?this.$draggee.insertAfter(e):this.$draggee.insertBefore(e),this._placeInsertionWithDraggee()},_placeInsertionWithDraggee:function(){this.$insertion&&(this.$insertion.insertBefore(this.$draggee.first()),this.insertionVisible=!0)},_removeInsertion:function(){this.insertionVisible&&(this.$insertion.remove(),this.insertionVisible=!1)}},{defaults:{container:null,insertion:null,moveTargetItemToFront:!1,magnetStrength:1,onInsertionPointChange:t.noop,onSortChange:t.noop}}),Garnish.EscManager=Garnish.Base.extend({handlers:null,init:function(){this.handlers=[],this.addListener(Garnish.$bod,"keyup",function(t){t.keyCode==Garnish.ESC_KEY&&this.escapeLatest(t)})},register:function(t,e){this.handlers.push({obj:t,func:e})},unregister:function(t){for(var e=this.handlers.length-1;e>=0;e--)this.handlers[e].obj==t&&this.handlers.splice(e,1)},escapeLatest:function(t){if(this.handlers.length){var e=this.handlers.pop();if("function"==typeof e.func)var i=e.func;else var i=e.obj[e.func];i.call(e.obj,t),"function"==typeof e.obj.trigger&&e.obj.trigger("escape")}}}),Garnish.escManager=new Garnish.EscManager,Garnish.HUD=Garnish.Base.extend({$trigger:null,$fixedTriggerParent:null,$hud:null,$tip:null,$body:null,$header:null,$footer:null,$mainContainer:null,$main:null,$shade:null,showing:!1,orientation:null,init:function(e,i,s){this.$trigger=t(e),this.setSettings(s,Garnish.HUD.defaults),this.on("show",this.settings.onShow),this.on("hide",this.settings.onHide),this.on("submit",this.settings.onSubmit),"undefined"==typeof Garnish.HUD.activeHUDs&&(Garnish.HUD.activeHUDs={}),this.$shade=t("<div/>",{"class":this.settings.shadeClass}),this.$hud=t("<div/>",{"class":this.settings.hudClass}),this.$tip=t("<div/>",{"class":this.settings.tipClass}).appendTo(this.$hud),this.$body=t("<form/>",{"class":this.settings.bodyClass}).appendTo(this.$hud),this.$mainContainer=t("<div/>",{"class":this.settings.mainContainerClass}).appendTo(this.$body),this.$main=t("<div/>",{"class":this.settings.mainClass}).appendTo(this.$mainContainer),this.updateBody(i);var n=this.$trigger;do{if("fixed"==n.css("position")){this.$fixedTriggerParent=n;break}n=n.offsetParent()}while(n.length&&"HTML"!=n.prop("nodeName"));this.$fixedTriggerParent?this.$hud.css("position","fixed"):this.$hud.css("position","absolute"),this.show(),this.addListener(this.$body,"submit","_handleSubmit"),this.addListener(this.$shade,"tap","hide"),this.$fixedTriggerParent||Garnish.$scrollContainer[0]==Garnish.$win[0]||this.addListener(Garnish.$scrollContainer,"scroll","updateSizeAndPosition"),this.settings.closeBtn&&this.addListener(this.settings.closeBtn,"activate","hide"),this.addListener(Garnish.$win,"resize","updateSizeAndPosition")},updateBody:function(t){this.removeListener(this.$main,"resize"),this.$main.html(""),this.$header&&(this.$hud.removeClass("has-header"),this.$header.remove(),this.$header=null),this.$footer&&(this.$hud.removeClass("has-footer"),this.$footer.remove(),this.$footer=null),this.$main.append(t);var e=this.$main.find("."+this.settings.headerClass+":first"),i=this.$main.find("."+this.settings.footerClass+":first");e.length&&(this.$header=e.insertBefore(this.$mainContainer),this.$hud.addClass("has-header")),i.length&&(this.$footer=i.insertAfter(this.$mainContainer),this.$hud.addClass("has-footer"))},show:function(e){if(e&&e.stopPropagation&&e.stopPropagation(),!this.showing){if(this.settings.closeOtherHUDs)for(var i in Garnish.HUD.activeHUDs)Garnish.HUD.activeHUDs[i].hide();this.$hud.css("top",Garnish.$scrollContainer.scrollTop()),this.$shade.appendTo(Garnish.$bod),this.$hud.appendTo(Garnish.$bod),this.$hud.show(),this.updateSizeAndPosition(),this.$shade.show(),this.showing=!0,Garnish.HUD.activeHUDs[this._namespace]=this,Garnish.escManager.register(this,"hide"),this.onShow(),Garnish.requestAnimationFrame(t.proxy(this,"updateSizeAndPosition")),this.enable()}},onShow:function(){this.trigger("show")},updateSizeAndPosition:function(){this.removeListener(this.$main,"resize");var e,i,s,n,h,o,r,a,l,g,d,u;e=Garnish.$win.width(),i=Garnish.$win.height(),o=Garnish.$win.scrollLeft(),r=Garnish.$win.scrollTop(),s=this.$trigger.outerWidth(),n=this.$trigger.outerHeight(),h=this.$trigger.offset(),this.$fixedTriggerParent?(h.left-=o,h.top-=r,a=h,o=0,r=0,l=0,g=0):(a=Garnish.getOffset(this.$trigger),l=Garnish.$scrollContainer.scrollLeft(),g=Garnish.$scrollContainer.scrollTop()),h.right=h.left+s,h.bottom=h.top+n,a.right=a.left+s,a.bottom=a.top+n,this.$hud.css({width:""}),this.$mainContainer.css({height:"","overflow-x":"","overflow-y":""}),d=this.$body.width(),u=this.$body.height();var c={bottom:i+g-a.bottom,top:a.top-g,right:e+l-a.right,left:a.left-l};this.orientation=null;for(var p=0;p<this.settings.orientations.length;p++){var f=this.settings.orientations[p],m="top"==f||"bottom"==f?u:d;if(c[f]-(this.settings.windowSpacing+this.settings.triggerSpacing)>=m){this.orientation=f;break}(!this.orientation||c[f]>c[this.orientation])&&(this.orientation=f)}this.orientation&&t.inArray(this.orientation,["bottom","top","right","left"])!=-1||(this.orientation="bottom"),this.tipClass&&this.$tip.removeClass(this.tipClass),this.tipClass=this.settings.tipClass+"-"+Garnish.HUD.tipClasses[this.orientation],this.$tip.addClass(this.tipClass);var $,_;if("top"==this.orientation||"bottom"==this.orientation?($=e-2*this.settings.windowSpacing,_=c[this.orientation]-this.settings.windowSpacing-this.settings.triggerSpacing):($=c[this.orientation]-this.settings.windowSpacing-this.settings.triggerSpacing,_=i-2*this.settings.windowSpacing),$<this.settings.minBodyWidth&&($=this.settings.minBodyWidth),_<this.settings.minBodyHeight&&(_=this.settings.minBodyHeight),(d>$||d<this.settings.minBodyWidth)&&(d=d>$?$:this.settings.minBodyWidth,this.$hud.width(d),this.$main.outerWidth()>$&&this.$mainContainer.css("overflow-x","scroll"),u=this.$body.height()),u>_||u<this.settings.minBodyHeight){u=u>_?_:this.settings.minBodyHeight;var v=u;this.$header&&(v-=this.$header.outerHeight()),this.$footer&&(v-=this.$footer.outerHeight()),this.$mainContainer.height(v),this.$main.outerHeight()>v&&this.$mainContainer.css("overflow-y","scroll")}if("top"==this.orientation||"bottom"==this.orientation){var I=e+o-(d+this.settings.windowSpacing),b=o+this.settings.windowSpacing,w=h.left+Math.round(s/2),x=w-Math.round(d/2);x>I&&(x=I),x<b&&(x=b),this.$hud.css("left",x);var y=w-x-this.settings.tipWidth/2;if(this.$tip.css({left:y,top:""}),"top"==this.orientation){var D=h.top-(u+this.settings.triggerSpacing);this.$hud.css("top",D)}else{var D=h.bottom+this.settings.triggerSpacing;this.$hud.css("top",D)}}else{var C=i+r-(u+this.settings.windowSpacing),T=r+this.settings.windowSpacing,w=h.top+Math.round(n/2),D=w-Math.round(u/2);D>C&&(D=C),D<T&&(D=T),this.$hud.css("top",D);var G=w-D-this.settings.tipWidth/2;if(this.$tip.css({top:G,left:""}),"left"==this.orientation){var x=h.left-(d+this.settings.triggerSpacing);this.$hud.css("left",x)}else{var x=h.right+this.settings.triggerSpacing;this.$hud.css("left",x)}}Garnish.requestAnimationFrame(t.proxy(function(){this.addListener(this.$main,"resize","updateSizeAndPosition")},this))},hide:function(){this.disable(),this.$hud.hide(),this.$shade.hide(),this.showing=!1,delete Garnish.HUD.activeHUDs[this._namespace],Garnish.escManager.unregister(this),this.onHide()},onHide:function(){this.trigger("hide")},toggle:function(){this.showing?this.hide():this.show()},submit:function(){this.onSubmit()},onSubmit:function(){this.trigger("submit")},_handleSubmit:function(t){t.preventDefault(),this.submit()}},{tipClasses:{bottom:"top",top:"bottom",right:"left",left:"right"},defaults:{shadeClass:"hud-shade",hudClass:"hud",tipClass:"tip",bodyClass:"body",headerClass:"hud-header",footerClass:"hud-footer",mainContainerClass:"main-container",mainClass:"main",orientations:["bottom","top","right","left"],triggerSpacing:10,windowSpacing:10,tipWidth:30,minBodyWidth:200,minBodyHeight:0,onShow:t.noop,onHide:t.noop,onSubmit:t.noop,closeBtn:null,closeOtherHUDs:!0}}),Garnish.Menu=Garnish.Base.extend({settings:null,$container:null,$options:null,$anchor:null,menuId:null,_windowWidth:null,_windowHeight:null,_windowScrollLeft:null,_windowScrollTop:null,_anchorOffset:null,_anchorWidth:null,_anchorHeight:null,_anchorOffsetRight:null,_anchorOffsetBottom:null,_menuWidth:null,_menuHeight:null,init:function(e,i){this.setSettings(i,Garnish.Menu.defaults),this.$container=t(e),this.$options=t(),this.addOptions(this.$container.find("a")),this.menuId="menu"+this._namespace,this.$menuList=t("ul",this.$container),this.$menuList.attr({role:"listbox",id:this.menuId,"aria-hidden":"true"}),this.settings.attachToElement&&(this.settings.anchor=this.settings.attachToElement,Garnish.log("The 'attachToElement' setting is deprecated. Use 'anchor' instead.")),this.settings.anchor&&(this.$anchor=t(this.settings.anchor)),this.addListener(this.$container,"mousedown",function(t){t.stopPropagation(),t.preventDefault()})},addOptions:function(e){this.$options=this.$options.add(e),e.data("menu",this),e.each(t.proxy(function(e,i){t(i).attr({role:"option",tabindex:"-1",id:this.menuId+"-option-"+e})},this)),this.addListener(e,"click","selectOption")},setPositionRelativeToAnchor:function(){this._windowWidth=Garnish.$win.width(),this._windowHeight=Garnish.$win.height(),this._windowScrollLeft=Garnish.$win.scrollLeft(),this._windowScrollTop=Garnish.$win.scrollTop(),this._anchorOffset=this.$anchor.offset(),this._anchorWidth=this.$anchor.outerWidth(),this._anchorHeight=this.$anchor.outerHeight(),this._anchorOffsetRight=this._anchorOffset.left+this._anchorHeight,this._anchorOffsetBottom=this._anchorOffset.top+this._anchorHeight,this.$container.css("minWidth",0),this.$container.css("minWidth",this._anchorWidth-(this.$container.outerWidth()-this.$container.width())),this._menuWidth=this.$container.outerWidth(),this._menuHeight=this.$container.outerHeight();var t=this._anchorOffset.top-this._windowScrollTop,e=this._windowHeight+this._windowScrollTop-this._anchorOffsetBottom;e>=this._menuHeight||e>=t||t<this._menuHeight?this.$container.css("top",this._anchorOffsetBottom):this.$container.css("top",this._anchorOffset.top-this._menuHeight);var i=this.$container.data("align");if("left"!=i&&"center"!=i&&"right"!=i&&(i="left"),"center"==i)this._alignCenter();else{var s=this._windowWidth+this._windowScrollLeft-(this._anchorOffset.left+this._menuWidth),n=this._anchorOffsetRight-this._menuWidth;"right"==i&&n>=0||s<0?this._alignRight():this._alignLeft()}delete this._windowWidth,delete this._windowHeight,delete this._windowScrollLeft,delete this._windowScrollTop,delete this._anchorOffset,delete this._anchorWidth,delete this._anchorHeight,delete this._anchorOffsetRight,delete this._anchorOffsetBottom,delete this._menuWidth,delete this._menuHeight},show:function(){this.$container.appendTo(Garnish.$bod),this.$anchor&&this.setPositionRelativeToAnchor(),this.$container.velocity("stop"),this.$container.css({opacity:1,display:"block"}),this.$menuList.attr("aria-hidden","false"),Garnish.escManager.register(this,"hide")},hide:function(){this.$menuList.attr("aria-hidden","true"),this.$container.velocity("fadeOut",{duration:Garnish.FX_DURATION},t.proxy(function(){this.$container.detach()},this)),Garnish.escManager.unregister(this),this.trigger("hide")},selectOption:function(t){this.settings.onOptionSelect(t.currentTarget),this.trigger("optionselect",{selectedOption:t.currentTarget}),this.hide()},_alignLeft:function(){this.$container.css({left:this._anchorOffset.left,right:"auto"})},_alignRight:function(){this.$container.css({right:this._windowWidth-(this._anchorOffset.left+this._anchorWidth),left:"auto"})},_alignCenter:function(){var t=Math.round(this._anchorOffset.left+this._anchorWidth/2-this._menuWidth/2);t<0&&(t=0),this.$container.css("left",t)}},{defaults:{anchor:null,onOptionSelect:t.noop}}),Garnish.MenuBtn=Garnish.Base.extend({$btn:null,menu:null,showingMenu:!1,disabled:!0,init:function(e,i){if(this.$btn=t(e),this.$btn.data("menubtn")){var s=this.$btn.data("menubtn").menu.$container;Garnish.log("Double-instantiating a menu button on an element"),this.$btn.data("menubtn").destroy()}else var s=this.$btn.next(".menu").detach();this.$btn.data("menubtn",this),this.setSettings(i,Garnish.MenuBtn.defaults),this.menu=new Garnish.Menu(s,{anchor:this.settings.menuAnchor||this.$btn,onOptionSelect:t.proxy(this,"onOptionSelect")}),this.$btn.attr({tabindex:0,role:"combobox","aria-owns":this.menu.menuId,"aria-haspopup":"true","aria-expanded":"false"}),this.menu.on("hide",t.proxy(this,"onMenuHide")),this.addListener(this.$btn,"mousedown","onMouseDown"),this.addListener(this.$btn,"keydown","onKeyDown"),this.addListener(this.$btn,"blur","onBlur"),this.enable()},onBlur:function(t){this.showingMenu&&this.hideMenu()},onKeyDown:function(e){switch(e.keyCode){case Garnish.RETURN_KEY:e.preventDefault();var i=this.menu.$options.filter(".hover");i.length>0&&i.get(0).click();break;case Garnish.SPACE_KEY:if(e.preventDefault(),!this.showingMenu){this.showMenu();var s=this.menu.$options.filter(".sel:first");s.length>0||(s=this.menu.$options.first()),this.focusOption(s)}break;case Garnish.DOWN_KEY:e.preventDefault();var s;this.showingMenu?(t.each(this.menu.$options,t.proxy(function(e,i){s||t(i).hasClass("hover")&&e+1<this.menu.$options.length&&(s=t(this.menu.$options[e+1]))},this)),s||(s=t(this.menu.$options[0]))):(this.showMenu(),s=this.menu.$options.filter(".sel:first"),0==s.length&&(s=this.menu.$options.first())),this.focusOption(s);break;case Garnish.UP_KEY:e.preventDefault();var s;this.showingMenu?(t.each(this.menu.$options,t.proxy(function(e,i){s||t(i).hasClass("hover")&&e-1>=0&&(s=t(this.menu.$options[e-1]))},this)),s||(s=t(this.menu.$options[this.menu.$options.length-1]))):(this.showMenu(),s=this.menu.$options.filter(".sel:first"),0==s.length&&(s=this.menu.$options.last())),this.focusOption(s)}},focusOption:function(t){this.menu.$options.removeClass("hover"),t.addClass("hover"),this.menu.$menuList.attr("aria-activedescendant",t.attr("id")),this.$btn.attr("aria-activedescendant",t.attr("id"))},onMouseDown:function(t){t.which!=Garnish.PRIMARY_CLICK||Garnish.isCtrlKeyPressed(t)||(t.preventDefault(),this.showingMenu?this.hideMenu():this.showMenu())},showMenu:function(){this.disabled||(this.menu.show(),this.$btn.addClass("active"),this.$btn.trigger("focus"),this.$btn.attr("aria-expanded","true"),this.showingMenu=!0,setTimeout(t.proxy(function(){this.addListener(Garnish.$doc,"mousedown","onMouseDown")},this),1))},hideMenu:function(){this.menu.hide(),this.$btn.attr("aria-expanded","false")},onMenuHide:function(){this.$btn.removeClass("active"),this.showingMenu=!1,this.removeListener(Garnish.$doc,"mousedown")},onOptionSelect:function(t){this.settings.onOptionSelect(t),this.trigger("optionSelect",{option:t})},enable:function(){this.disabled=!1},disable:function(){this.disabled=!0},destroy:function(){this.$btn.removeData("menubtn"),this.base()}},{defaults:{menuAnchor:null,onOptionSelect:t.noop}}),Garnish.MixedInput=Garnish.Base.extend({$container:null,elements:null,focussedElement:null,blurTimeout:null,init:function(e,i){this.$container=t(e),this.setSettings(i,Garnish.MixedInput.defaults),this.elements=[],this.$container.attr("tabindex",0),this.addListener(this.$container,"focus","onFocus")},getElementIndex:function(e){return t.inArray(e,this.elements)},isText:function(t){return"INPUT"==t.prop("nodeName")},onFocus:function(t){if(this.elements.length){var e=this.elements[0];this.setFocus(e),this.setCarotPos(e,0)}else this.addTextElement()},addTextElement:function(t){var e=new h(this);return this.addElement(e.$input,t),e},addElement:function(e,i){if("undefined"==typeof i)if(this.focussedElement){var s=this.focussedElement,n=this.getElementIndex(s);if(this.isText(s)){var o=s.prop("selectionStart"),r=s.prop("selectionEnd"),a=s.val(),l=a.substring(0,o),g=a.substr(r);if(l&&g){s.val(l).trigger("change");var d=new h(this);d.$input.val(g).trigger("change"),this.addElement(d.$input,n+1),i=n+1}else i=l?n+1:n}else i=n+1}else i=this.elements.length;"undefined"!=typeof this.elements[i]?(e.insertBefore(this.elements[i]),this.elements.splice(i,0,e)):(i=this.elements.length,this.$container.append(e),this.elements.push(e)),this.isText(e)||(0!=i&&this.isText(this.elements[i-1])||(this.addTextElement(i),i++),i!=this.elements.length-1&&this.isText(this.elements[i+1])||this.addTextElement(i+1)),this.addListener(e,"click",function(){this.setFocus(e)}),setTimeout(t.proxy(function(){this.setFocus(e)},this),1)},removeElement:function(t){var e=this.getElementIndex(t);if(e!=-1){if(this.elements.splice(e,1),!this.isText(t)){var i=this.elements[e-1],s=this.elements[e];if(this.isText(i)&&this.isText(s)){var n=i.val(),h=n+s.val();i.val(h).trigger("change"),this.removeElement(s),this.setFocus(i),this.setCarotPos(i,n.length)}}t.remove()}},setFocus:function(e){this.$container.addClass("focus"),this.focussedElement?this.blurFocussedElement():this.$container.attr("tabindex","-1"),e.attr("tabindex","0"),e.focus(),this.focussedElement=e,this.addListener(e,"blur",function(){this.blurTimeout=setTimeout(t.proxy(function(){this.focussedElement==e&&(this.blurFocussedElement(),this.focussedElement=null,this.$container.removeClass("focus"),this.$container.attr("tabindex","0"))},this),1)})},blurFocussedElement:function(){this.removeListener(this.focussedElement,"blur"),this.focussedElement.attr("tabindex","-1")},focusPreviousElement:function(t){var e=this.getElementIndex(t);if(e>0){var i=this.elements[e-1];if(this.setFocus(i),this.isText(i)){var s=i.val().length;this.setCarotPos(i,s)}}},focusNextElement:function(t){var e=this.getElementIndex(t);if(e<this.elements.length-1){var i=this.elements[e+1];this.setFocus(i),this.isText(i)&&this.setCarotPos(i,0)}},setCarotPos:function(t,e){t.prop("selectionStart",e),t.prop("selectionEnd",e)}});var h=Garnish.Base.extend({parentInput:null,$input:null,$stage:null,val:null,focussed:!1,interval:null,init:function(e){this.parentInput=e,this.$input=t('<input type="text"/>').appendTo(this.parentInput.$container),this.$input.css("margin-right",2-h.padding+"px"),this.setWidth(),this.addListener(this.$input,"focus","onFocus"),this.addListener(this.$input,"blur","onBlur"),this.addListener(this.$input,"keydown","onKeyDown"),this.addListener(this.$input,"change","checkInput")},getIndex:function(){return this.parentInput.getElementIndex(this.$input)},buildStage:function(){this.$stage=t("<stage/>").appendTo(Garnish.$bod),this.$stage.css({position:"absolute",top:-9999,left:-9999,wordWrap:"nowrap"}),Garnish.copyTextStyles(this.$input,this.$stage)},getTextWidth:function(t){return this.$stage||this.buildStage(),t&&(t=t.replace(/&/g,"&amp;"),t=t.replace(/</g,"&lt;"),t=t.replace(/>/g,"&gt;"),t=t.replace(/ /g,"&nbsp;")),this.$stage.html(t),this.stageWidth=this.$stage.width(),this.stageWidth},onFocus:function(){this.focussed=!0,this.interval=setInterval(t.proxy(this,"checkInput"),Garnish.NiceText.interval),this.checkInput()},onBlur:function(){this.focussed=!1,clearInterval(this.interval),this.checkInput()},onKeyDown:function(e){switch(setTimeout(t.proxy(this,"checkInput"),1),e.keyCode){case Garnish.LEFT_KEY:0==this.$input.prop("selectionStart")&&0==this.$input.prop("selectionEnd")&&this.parentInput.focusPreviousElement(this.$input);break;case Garnish.RIGHT_KEY:this.$input.prop("selectionStart")==this.val.length&&this.$input.prop("selectionEnd")==this.val.length&&this.parentInput.focusNextElement(this.$input);break;case Garnish.DELETE_KEY:0==this.$input.prop("selectionStart")&&0==this.$input.prop("selectionEnd")&&(this.parentInput.focusPreviousElement(this.$input),e.preventDefault())}},getVal:function(){return this.val=this.$input.val(),this.val},setVal:function(t){this.$input.val(t),this.checkInput()},checkInput:function(){var t=this.val!==this.getVal();return t&&(this.setWidth(),this.onChange()),t},setWidth:function(){if(this.stageWidth!==this.getTextWidth(this.val)){var t=this.stageWidth+h.padding;this.$input.width(t)}},onChange:t.noop},{padding:20});Garnish.Modal=Garnish.Base.extend({$container:null,$shade:null,visible:!1,dragger:null,desiredWidth:null,desiredHeight:null,resizeDragger:null,resizeStartWidth:null,resizeStartHeight:null,init:function(e,i){"undefined"==typeof i&&t.isPlainObject(e)&&(i=e,e=null),this.setSettings(i,Garnish.Modal.defaults),this.$shade=t('<div class="'+this.settings.shadeClass+'"/>'),e?this.$shade.insertBefore(e):this.$shade.appendTo(Garnish.$bod),e&&(this.setContainer(e),this.settings.autoShow&&this.show()),Garnish.Modal.instances.push(this)},setContainer:function(e){if(this.$container=t(e),this.$container.data("modal")&&(Garnish.log("Double-instantiating a modal on an element"),this.$container.data("modal").destroy()),this.$container.data("modal",this),this.settings.draggable&&(this.dragger=new Garnish.DragMove(this.$container,{handle:this.settings.dragHandleSelector?this.$container.find(this.settings.dragHandleSelector):this.$container})),this.settings.resizable){var i=t('<div class="resizehandle"/>').appendTo(this.$container);this.resizeDragger=new Garnish.BaseDrag(i,{onDragStart:t.proxy(this,"_handleResizeStart"),onDrag:t.proxy(this,"_handleResize")})}this.addListener(this.$container,"click",function(t){t.stopPropagation()}),this.visible&&this.show()},show:function(){this.settings.closeOtherModals&&Garnish.Modal.visibleModal&&Garnish.Modal.visibleModal!=this&&Garnish.Modal.visibleModal.hide(),this.$container&&(this.$shade.appendTo(Garnish.$bod),this.$container.appendTo(Garnish.$bod),this.$container.show(),this.updateSizeAndPosition(),this.$shade.velocity("fadeIn",{duration:50}),this.$container.delay(50).velocity("fadeIn",{complete:t.proxy(this,"onFadeIn")}),this.settings.hideOnShadeClick&&this.addListener(this.$shade,"click","hide"),this.addListener(Garnish.$win,"resize","updateSizeAndPosition")),this.enable(),this.settings.hideOnEsc&&Garnish.escManager.register(this,"hide"),this.visible||(this.visible=!0,Garnish.Modal.visibleModal=this,this.trigger("show"),this.settings.onShow())},quickShow:function(){this.show(),this.$container&&(this.$container.velocity("stop"),this.$container.show().css("opacity",1),this.$shade.velocity("stop"),this.$shade.show().css("opacity",1))},hide:function(e){this.disable(),e&&e.stopPropagation(),this.$container&&(this.$container.velocity("fadeOut",{duration:Garnish.FX_DURATION}),this.$shade.velocity("fadeOut",{duration:Garnish.FX_DURATION,complete:t.proxy(this,"onFadeOut")}),this.settings.hideOnShadeClick&&this.removeListener(this.$shade,"click"),this.removeListener(Garnish.$win,"resize")),this.visible=!1,Garnish.Modal.visibleModal=null,this.settings.hideOnEsc&&Garnish.escManager.unregister(this),this.trigger("hide"),this.settings.onHide()},quickHide:function(){this.hide(),this.$container&&(this.$container.velocity("stop"),this.$container.css("opacity",0).hide(),this.$shade.velocity("stop"),this.$shade.css("opacity",0).hide())},updateSizeAndPosition:function(){this.$container&&(this.$container.css({width:this.desiredWidth?Math.max(this.desiredWidth,200):"",height:this.desiredHeight?Math.max(this.desiredHeight,200):"","min-width":"","min-height":""}),this.updateSizeAndPosition._windowWidth=Garnish.$win.width(),this.updateSizeAndPosition._width=Math.min(this.getWidth(),this.updateSizeAndPosition._windowWidth-2*this.settings.minGutter),this.$container.css({width:this.updateSizeAndPosition._width,"min-width":this.updateSizeAndPosition._width,left:Math.round((this.updateSizeAndPosition._windowWidth-this.updateSizeAndPosition._width)/2)}),this.updateSizeAndPosition._windowHeight=Garnish.$win.height(),this.updateSizeAndPosition._height=Math.min(this.getHeight(),this.updateSizeAndPosition._windowHeight-2*this.settings.minGutter),this.$container.css({height:this.updateSizeAndPosition._height,"min-height":this.updateSizeAndPosition._height,top:Math.round((this.updateSizeAndPosition._windowHeight-this.updateSizeAndPosition._height)/2)}))},onFadeIn:function(){this.trigger("fadeIn"),this.settings.onFadeIn()},onFadeOut:function(){this.trigger("fadeOut"),this.settings.onFadeOut()},getHeight:function(){if(!this.$container)throw"Attempted to get the height of a modal whose container has not been set.";return this.visible||this.$container.show(),this.getHeight._height=this.$container.outerHeight(),this.visible||this.$container.hide(),this.getHeight._height},getWidth:function(){if(!this.$container)throw"Attempted to get the width of a modal whose container has not been set.";return this.visible||this.$container.show(),this.getWidth._width=this.$container.outerWidth()+1,this.visible||this.$container.hide(),this.getWidth._width},_handleResizeStart:function(){this.resizeStartWidth=this.getWidth(),this.resizeStartHeight=this.getHeight()},_handleResize:function(){Garnish.ltr?this.desiredWidth=this.resizeStartWidth+2*this.resizeDragger.mouseDistX:this.desiredWidth=this.resizeStartWidth-2*this.resizeDragger.mouseDistX,this.desiredHeight=this.resizeStartHeight+2*this.resizeDragger.mouseDistY,this.updateSizeAndPosition()},destroy:function(){this.$container&&this.$container.removeData("modal").remove(),this.dragger&&this.dragger.destroy(),this.resizeDragger&&this.resizeDragger.destroy(),this.base()}},{relativeElemPadding:8,defaults:{autoShow:!0,draggable:!1,dragHandleSelector:null,resizable:!1,minGutter:10,onShow:t.noop,onHide:t.noop,onFadeIn:t.noop,onFadeOut:t.noop,closeOtherModals:!1,hideOnEsc:!0,hideOnShadeClick:!0,shadeClass:"modal-shade"},instances:[],visibleModal:null}),Garnish.NiceText=Garnish.Base.extend({$input:null,$hint:null,$stage:null,$charsLeft:null,autoHeight:null,maxLength:null,showCharsLeft:!1,showingHint:!1,val:null,inputBoxSizing:"content-box",width:null,height:null,minHeight:null,initialized:!1,init:function(e,i){this.$input=t(e),this.settings=t.extend({},Garnish.NiceText.defaults,i),this.isVisible()?this.initialize():this.addListener(Garnish.$win,"resize","initializeIfVisible")},isVisible:function(){return this.$input.height()>0},initialize:function(){this.initialized||(this.initialized=!0,this.removeListener(Garnish.$win,"resize"),this.maxLength=this.$input.attr("maxlength"),this.maxLength&&(this.maxLength=parseInt(this.maxLength)),this.maxLength&&(this.settings.showCharsLeft||Garnish.hasAttr(this.$input,"data-show-chars-left"))&&(this.showCharsLeft=!0,
  this.$input.removeAttr("maxlength")),this.$input.data("nicetext")&&(Garnish.log("Double-instantiating a transparent text input on an element"),this.$input.data("nicetext").destroy()),this.$input.data("nicetext",this),this.getVal(),this.autoHeight=this.settings.autoHeight&&"TEXTAREA"==this.$input.prop("nodeName"),this.autoHeight&&(this.minHeight=this.getHeightForValue(""),this.updateHeight(),this.width=this.$input.width(),this.addListener(Garnish.$win,"resize","updateHeightIfWidthChanged")),this.settings.hint&&(this.$hintContainer=t('<div class="texthint-container"/>').insertBefore(this.$input),this.$hint=t('<div class="texthint">'+this.settings.hint+"</div>").appendTo(this.$hintContainer),this.$hint.css({top:parseInt(this.$input.css("borderTopWidth"))+parseInt(this.$input.css("paddingTop")),left:parseInt(this.$input.css("borderLeftWidth"))+parseInt(this.$input.css("paddingLeft"))+1}),Garnish.copyTextStyles(this.$input,this.$hint),this.val?this.$hint.hide():this.showingHint=!0,this.addListener(this.$hint,"mousedown",function(t){t.preventDefault(),this.$input.focus()})),this.showCharsLeft&&(this.$charsLeft=t('<div class="'+this.settings.charsLeftClass+'"/>').insertAfter(this.$input),this.updateCharsLeft()),this.addListener(this.$input,"textchange","onTextChange"))},initializeIfVisible:function(){this.isVisible()&&this.initialize()},getVal:function(){return this.val=this.$input.val(),this.val},showHint:function(){this.$hint.velocity("fadeIn",{complete:Garnish.NiceText.hintFadeDuration}),this.showingHint=!0},hideHint:function(){this.$hint.velocity("fadeOut",{complete:Garnish.NiceText.hintFadeDuration}),this.showingHint=!1},onTextChange:function(){this.getVal(),this.$hint&&(this.showingHint&&this.val?this.hideHint():this.showingHint||this.val||this.showHint()),this.autoHeight&&this.updateHeight(),this.showCharsLeft&&this.updateCharsLeft()},buildStage:function(){this.$stage=t("<stage/>").appendTo(Garnish.$bod),this.$stage.css({display:"block",position:"absolute",top:-9999,left:-9999}),this.inputBoxSizing=this.$input.css("box-sizing"),"border-box"==this.inputBoxSizing&&this.$stage.css({"border-top":this.$input.css("border-top"),"border-right":this.$input.css("border-right"),"border-bottom":this.$input.css("border-bottom"),"border-left":this.$input.css("border-left"),"padding-top":this.$input.css("padding-top"),"padding-right":this.$input.css("padding-right"),"padding-bottom":this.$input.css("padding-bottom"),"padding-left":this.$input.css("padding-left"),"-webkit-box-sizing":this.inputBoxSizing,"-moz-box-sizing":this.inputBoxSizing,"box-sizing":this.inputBoxSizing}),Garnish.copyTextStyles(this.$input,this.$stage)},getHeightForValue:function(t){if(this.$stage||this.buildStage(),"border-box"==this.inputBoxSizing?this.$stage.css("width",this.$input.outerWidth()):this.$stage.css("width",this.$input.width()),t)t=t.replace(/&/g,"&amp;"),t=t.replace(/</g,"&lt;"),t=t.replace(/>/g,"&gt;"),t=t.replace(/ {2,}/g,function(t){for(var e="",i=0;i<t.length-1;i++)e+="&nbsp;";return e+" "}),t=t.replace(/[\n\r]$/g,"<br/>&nbps;"),t=t.replace(/[\n\r]/g,"<br/>");else{t="&nbsp;";for(var e=1;e<this.$input.prop("rows");e++)t+="<br/>&nbsp;"}return this.$stage.html(t),"border-box"==this.inputBoxSizing?this.getHeightForValue._height=this.$stage.outerHeight():this.getHeightForValue._height=this.$stage.height(),this.minHeight&&this.getHeightForValue._height<this.minHeight&&(this.getHeightForValue._height=this.minHeight),this.getHeightForValue._height},updateHeight:function(){this.height!==(this.height=this.getHeightForValue(this.val))&&(this.$input.css("min-height",this.height),this.initialized&&this.onHeightChange())},updateHeightIfWidthChanged:function(){this.isVisible()&&this.width!==(this.width=this.$input.width())&&this.width&&this.updateHeight()},onHeightChange:function(){this.settings.onHeightChange()},updateCharsLeft:function(){this.updateCharsLeft._charsLeft=this.maxLength-this.val.length,this.$charsLeft.text(this.updateCharsLeft._charsLeft),this.updateCharsLeft._charsLeft>=0?this.$charsLeft.removeClass(this.settings.negativeCharsLeftClass):this.$charsLeft.addClass(this.settings.negativeCharsLeftClass)},destroy:function(){this.$input.removeData("nicetext"),this.$hint&&this.$hint.remove(),this.$stage&&this.$stage.remove(),this.base()}},{interval:100,hintFadeDuration:50,defaults:{autoHeight:!0,showCharsLeft:!1,charsLeftClass:"chars-left",negativeCharsLeftClass:"negative-chars-left",onHeightChange:t.noop}}),Garnish.Pill=Garnish.Base.extend({$outerContainer:null,$innerContainer:null,$btns:null,$selectedBtn:null,$input:null,init:function(e){this.$outerContainer=t(e),this.$outerContainer.data("pill")&&(Garnish.log("Double-instantiating a pill on an element"),this.$outerContainer.data("pill").destroy()),this.$outerContainer.data("pill",this),this.$innerContainer=this.$outerContainer.find(".btngroup:first"),this.$btns=this.$innerContainer.find(".btn"),this.$selectedBtn=this.$btns.filter(".active:first"),this.$input=this.$outerContainer.find("input:first"),Garnish.preventOutlineOnMouseFocus(this.$innerContainer),this.addListener(this.$btns,"mousedown","onMouseDown"),this.addListener(this.$innerContainer,"keydown","onKeyDown")},select:function(e){this.$selectedBtn.removeClass("active");var i=t(e);i.addClass("active"),this.$input.val(i.attr("data-value")),this.$selectedBtn=i},selectNext:function(){if(this.$selectedBtn.length){var t=this._getSelectedBtnIndex()+1;"undefined"!=typeof this.$btns[t]&&this.select(this.$btns[t])}else this.select(this.$btns[this.$btns.length-1])},selectPrev:function(){if(this.$selectedBtn.length){var t=this._getSelectedBtnIndex()-1;"undefined"!=typeof this.$btns[t]&&this.select(this.$btns[t])}else this.select(this.$btns[0])},onMouseDown:function(t){this.select(t.currentTarget)},_getSelectedBtnIndex:function(){return"undefined"!=typeof this.$selectedBtn[0]?t.inArray(this.$selectedBtn[0],this.$btns):-1},onKeyDown:function(t){switch(t.keyCode){case Garnish.RIGHT_KEY:Garnish.ltr?this.selectNext():this.selectPrev(),t.preventDefault();break;case Garnish.LEFT_KEY:Garnish.ltr?this.selectPrev():this.selectNext(),t.preventDefault()}},destroy:function(){this.$outerContainer.removeData("pill"),this.base()}}),Garnish.Select=Garnish.Base.extend({$container:null,$items:null,$selectedItems:null,mousedownTarget:null,mouseUpTimeout:null,callbackFrame:null,$focusable:null,$first:null,first:null,$last:null,last:null,init:function(e,i,s){this.$container=t(e),"undefined"==typeof i&&t.isPlainObject(e)?(s=e,e=null,i=null):"undefined"==typeof s&&t.isPlainObject(i)&&(s=i,i=null),this.$container.data("select")&&(Garnish.log("Double-instantiating a select on an element"),this.$container.data("select").destroy()),this.$container.data("select",this),this.setSettings(s,Garnish.Select.defaults),this.$items=t(),this.$selectedItems=t(),this.addItems(i),this.settings.allowEmpty&&!this.settings.checkboxMode&&this.addListener(this.$container,"click",function(t){this.ignoreClick?this.ignoreClick=!1:this.deselectAll(!0)})},getItemIndex:function(t){return this.$items.index(t[0])},isSelected:function(e){if(Garnish.isJquery(e)){if(!e[0])return!1;e=e[0]}return t.inArray(e,this.$selectedItems)!=-1},selectItem:function(t,e,i){this.settings.multi||this.deselectAll(),this.$first=this.$last=t,this.first=this.last=this.getItemIndex(t),e&&(this.setFocusableItem(t),this.focusItem(t,i)),this._selectItems(t)},selectAll:function(){this.settings.multi&&this.$items.length&&(this.first=0,this.last=this.$items.length-1,this.$first=this.$items.eq(this.first),this.$last=this.$items.eq(this.last),this._selectItems(this.$items))},selectRange:function(t,e){if(!this.settings.multi)return this.selectItem(t,!0);if(this.deselectAll(),this.$last=t,this.last=this.getItemIndex(t),this.setFocusableItem(t),this.focusItem(t,e),this.first<this.last)var i=this.first,s=this.last+1;else var i=this.last,s=this.first+1;this._selectItems(this.$items.slice(i,s))},deselectItem:function(t){var e=this.getItemIndex(t);this.first===e&&(this.$first=this.first=null),this.last===e&&(this.$last=this.last=null),this._deselectItems(t)},deselectAll:function(t){t&&(this.$first=this.first=this.$last=this.last=null),this._deselectItems(this.$items)},deselectOthers:function(t){this.deselectAll(),this.selectItem(t,!0)},toggleItem:function(t,e){this.isSelected(t)?this._canDeselect(t)&&this.deselectItem(t,!0):this.selectItem(t,!0,e)},clearMouseUpTimeout:function(){clearTimeout(this.mouseUpTimeout)},getFirstItem:function(){if(this.$items.length)return this.$items.first()},getLastItem:function(){if(this.$items.length)return this.$items.last()},isPreviousItem:function(t){return t>0},isNextItem:function(t){return t<this.$items.length-1},getPreviousItem:function(t){if(this.isPreviousItem(t))return this.$items.eq(t-1)},getNextItem:function(t){if(this.isNextItem(t))return this.$items.eq(t+1)},getItemToTheLeft:function(t){var e=Garnish.ltr?"Previous":"Next";if(this["is"+e+"Item"](t)){if(this.settings.horizontal)return this["get"+e+"Item"](t);if(!this.settings.vertical)return this.getClosestItem(t,Garnish.X_AXIS,"<")}},getItemToTheRight:function(t){var e=Garnish.ltr?"Next":"Previous";if(this["is"+e+"Item"](t)){if(this.settings.horizontal)return this["get"+e+"Item"](t);if(!this.settings.vertical)return this.getClosestItem(t,Garnish.X_AXIS,">")}},getItemAbove:function(t){if(this.isPreviousItem(t)){if(this.settings.vertical)return this.getPreviousItem(t);if(!this.settings.horizontal)return this.getClosestItem(t,Garnish.Y_AXIS,"<")}},getItemBelow:function(t){if(this.isNextItem(t)){if(this.settings.vertical)return this.getNextItem(t);if(!this.settings.horizontal)return this.getClosestItem(t,Garnish.Y_AXIS,">")}},getClosestItem:function(t,e,i){var s=Garnish.Select.closestItemAxisProps[e],n=Garnish.Select.closestItemDirectionProps[i],h=this.$items.eq(t),o=h.offset(),r=o[s.midpointOffset]+Math.round(h[s.midpointSizeFunc]()/2),a=null,l=null,g=null;if(Garnish.rtl&&e==Garnish.X_AXIS)var d=n.step*-1;else var d=n.step;for(var u=t+d;"undefined"!=typeof this.$items[u];u+=d){var c=this.$items.eq(u),p=c.offset();if(n.isNextRow(p[s.rowOffset],o[s.rowOffset])){if(null===a)a=p[s.rowOffset];else if(p[s.rowOffset]!=a)break;var f=p[s.midpointOffset]+Math.round(c[s.midpointSizeFunc]()/2),m=Math.abs(r-f);if(!(null===l||m<l))break;l=m,g=c}else if(n.isWrongDirection(p[s.rowOffset],o[s.rowOffset]))break}return g},getFurthestItemToTheLeft:function(t){return this.getFurthestItem(t,"ToTheLeft")},getFurthestItemToTheRight:function(t){return this.getFurthestItem(t,"ToTheRight")},getFurthestItemAbove:function(t){return this.getFurthestItem(t,"Above")},getFurthestItemBelow:function(t){return this.getFurthestItem(t,"Below")},getFurthestItem:function(t,e){for(var i,s;s=this["getItem"+e](t);)i=s,t=this.getItemIndex(i);return i},get totalSelected(){return this.getTotalSelected()},getTotalSelected:function(){return this.$selectedItems.length},addItems:function(e){for(var i=t(e),s=0;s<i.length;s++){var n=i[s];if(t.data(n,"select")&&(Garnish.log("Element was added to more than one selector"),t.data(n,"select").removeItems(n)),t.data(n,"select",this),this.settings.handle){if("object"==typeof this.settings.handle)var h=t(this.settings.handle);else if("string"==typeof this.settings.handle)var h=t(n).find(this.settings.handle);else if("function"==typeof this.settings.handle)var h=t(this.settings.handle(n))}else var h=t(n);t.data(n,"select-handle",h),h.data("select-item",n),this.addListener(h,"mousedown","onMouseDown"),this.addListener(h,"mouseup","onMouseUp"),this.addListener(h,"click",function(t){this.ignoreClick=!0}),this.addListener(n,"keydown","onKeyDown")}this.$items=this.$items.add(i),this.updateIndexes()},removeItems:function(e){e=t.makeArray(e);for(var i=!1,s=!1,n=0;n<e.length;n++){var h=e[n],o=t.inArray(h,this.$items);if(o!=-1){this._deinitItem(h),this.$items.splice(o,1),i=!0;var r=t.inArray(h,this.$selectedItems);r!=-1&&(this.$selectedItems.splice(r,1),s=!0)}}i&&(this.updateIndexes(),s&&(t(e).removeClass(this.settings.selectedClass),this.onSelectionChange()))},removeAllItems:function(){for(var e=0;e<this.$items.length;e++)this._deinitItem(this.$items[e]);this.$items=t(),this.$selectedItems=t(),this.updateIndexes()},updateIndexes:function(){null!==this.first?(this.first=this.getItemIndex(this.$first),this.setFocusableItem(this.$first)):this.$items.length&&this.setFocusableItem(t(this.$items[0])),null!==this.last&&(this.last=this.getItemIndex(this.$last))},resetItemOrder:function(){this.$items=t().add(this.$items),this.$selectedItems=t().add(this.$selectedItems),this.updateIndexes()},setFocusableItem:function(t){this.$focusable&&this.$focusable.removeAttr("tabindex"),this.$focusable=t.attr("tabindex","0")},focusItem:function(t,e){if(e){var i=Garnish.$doc.scrollLeft(),s=Garnish.$doc.scrollTop();t.focus(),window.scrollTo(i,s)}else t.focus()},getSelectedItems:function(){return this.$selectedItems},destroy:function(){this.$container.removeData("select"),this.removeAllItems(),this.base()},onMouseDown:function(e){if(e.which==Garnish.PRIMARY_CLICK&&(!this.settings.filter||t(e.target).is(this.settings.filter))){this.mousedownTarget=e.currentTarget;var i=t(t.data(e.currentTarget,"select-item"));null!==this.first&&e.shiftKey?this.selectRange(i,!0):this._actAsCheckbox(e)&&this.toggleItem(i,!0)}},onMouseUp:function(e){if(e.which==Garnish.PRIMARY_CLICK&&(!this.settings.filter||t(e.target).is(this.settings.filter))){var i=t(t.data(e.currentTarget,"select-item"));this._actAsCheckbox(e)||e.shiftKey||e.currentTarget!=this.mousedownTarget||(this.isSelected(i)?(this.clearMouseUpTimeout(),this.mouseUpTimeout=setTimeout(t.proxy(function(){this.deselectOthers(i)},this),300)):(this.deselectAll(),this.selectItem(i,!0,!0)))}},onKeyDown:function(e){if(e.target==e.currentTarget){var i=Garnish.isCtrlKeyPressed(e);if(this.settings.checkboxMode&&this.$focusable.length){var s=t.inArray(this.$focusable[0],this.$items);s==-1&&(s=0)}else var s=e.shiftKey?this.last:this.first;switch(e.keyCode){case Garnish.LEFT_KEY:if(e.preventDefault(),null===this.first)if(Garnish.ltr)var n=this.getLastItem();else var n=this.getFirstItem();else if(i)var n=this.getFurthestItemToTheLeft(s);else var n=this.getItemToTheLeft(s);break;case Garnish.RIGHT_KEY:if(e.preventDefault(),null===this.first)if(Garnish.ltr)var n=this.getFirstItem();else var n=this.getLastItem();else if(i)var n=this.getFurthestItemToTheRight(s);else var n=this.getItemToTheRight(s);break;case Garnish.UP_KEY:if(e.preventDefault(),null===this.first){if(this.$focusable)var n=this.$focusable.prev();if(!this.$focusable||!n.length)var n=this.getLastItem()}else{if(i)var n=this.getFurthestItemAbove(s);else var n=this.getItemAbove(s);n||(n=this.getFirstItem())}break;case Garnish.DOWN_KEY:if(e.preventDefault(),null===this.first){if(this.$focusable)var n=this.$focusable.next();if(!this.$focusable||!n.length)var n=this.getFirstItem()}else{if(i)var n=this.getFurthestItemBelow(s);else var n=this.getItemBelow(s);n||(n=this.getLastItem())}break;case Garnish.SPACE_KEY:i||(e.preventDefault(),this.isSelected(this.$focusable)?this._canDeselect(this.$focusable)&&this.deselectItem(this.$focusable):this.selectItem(this.$focusable,!0));break;case Garnish.A_KEY:i&&(e.preventDefault(),this.selectAll())}n&&n.length&&(this.settings.checkboxMode?(this.setFocusableItem(n),n.focus()):null!==this.first&&e.shiftKey?this.selectRange(n):(this.deselectAll(),this.selectItem(n,!0)))}},onSelectionChange:function(){this.callbackFrame&&(Garnish.cancelAnimationFrame(this.callbackFrame),this.callbackFrame=null),this.callbackFrame=Garnish.requestAnimationFrame(t.proxy(function(){this.callbackFrame=null,this.trigger("selectionChange"),this.settings.onSelectionChange()},this))},_actAsCheckbox:function(t){return Garnish.isCtrlKeyPressed(t)?!this.settings.checkboxMode:this.settings.checkboxMode},_canDeselect:function(t){return this.settings.allowEmpty||this.totalSelected>t.length},_selectItems:function(t){t.addClass(this.settings.selectedClass),this.$selectedItems=this.$selectedItems.add(t),this.onSelectionChange()},_deselectItems:function(t){t.removeClass(this.settings.selectedClass),this.$selectedItems=this.$selectedItems.not(t),this.onSelectionChange()},_deinitItem:function(e){var i=t.data(e,"select-handle");i&&(i.removeData("select-item"),this.removeAllListeners(i)),t.removeData(e,"select"),t.removeData(e,"select-handle")}},{defaults:{selectedClass:"sel",multi:!1,allowEmpty:!0,vertical:!1,horizontal:!1,handle:null,filter:null,checkboxMode:!1,onSelectionChange:t.noop},closestItemAxisProps:{x:{midpointOffset:"top",midpointSizeFunc:"outerHeight",rowOffset:"left"},y:{midpointOffset:"left",midpointSizeFunc:"outerWidth",rowOffset:"top"}},closestItemDirectionProps:{"<":{step:-1,isNextRow:function(t,e){return t<e},isWrongDirection:function(t,e){return t>e}},">":{step:1,isNextRow:function(t,e){return t>e},isWrongDirection:function(t,e){return t<e}}}}),Garnish.SelectMenu=Garnish.Menu.extend({init:function(e,i,s,n){"function"==typeof s&&(n=s,s={}),s=t.extend({},Garnish.SelectMenu.defaults,s),this.base(e,i,s,n),this.selected=-1},build:function(){this.base(),this.selected!=-1&&this._addSelectedOptionClass(this.selected)},select:function(e){e!=this.selected&&(this.dom.ul&&(this.selected!=-1&&(this.dom.options[this.selected].className=""),this._addSelectedOptionClass(e)),this.selected=e,this.setBtnText(t(this.options[e].label).text()),this.base(e))},_addSelectedOptionClass:function(t){this.dom.options[t].className="sel"},setBtnText:function(t){this.dom.$btnLabel.text(t)}},{defaults:{ulClass:"menu select"}})}(jQuery);
  //# sourceMappingURL=garnish.min.map
  