/*!
* Web Cabin Docker - Docking Layout Interface.
*
* Dependancies:
* JQuery 1.11.1
* JQuery-contextMenu 1.6.6
* font-awesome 4.2.0
*
* Author: Jeff Houde (lochemage@webcabin.org)
* Web: http://docker.webcabin.org/
*
* Licensed under
* MIT License http://www.opensource.org/licenses/mit-license
* GPL v3 http://opensource.org/licenses/GPL-3.0
*
*/
function wcDocker(e,t){this.$outer=$(e),this.$container=$('
'),this.$transition=$('
'),this.$loading=null,this.$outer.append(this.$container),this.$container.append(this.$transition),this._canOrientTabs=!0,this._events={},this._root=null,this._frameList=[],this._floatingList=[],this._modalList=[],this._focusFrame=null,this._placeholderPanel=null,this._contextTimer=0,this._dirty=!1,this._splitterList=[],this._tabList=[],this._collapser={},this._dockPanelTypeList=[],this._creatingPanel=!1,this._draggingSplitter=null,this._draggingFrame=null,this._draggingFrameSizer=null,this._draggingFrameTab=null,this._draggingFrameTopper=!1,this._draggingCustomTabFrame=null,this._ghost=null,this._menuTimer=0,this._mouseOrigin={x:0,y:0},this._resizeData={time:-1,timeout:!1,delta:150};var n={themePath:"Themes",theme:"default",loadingClass:"fa fa-spinner fa-pulse",allowContextMenu:!0,hideOnResize:!1,allowCollapse:!0,responseRate:10};this._options={};for(var r in n)this._options[r]=n[r];for(var r in t)this._options[r]=t[r];this.__init()}function wcGhost(e,t,n){this.$ghost=null,this._rect,this._anchorMouse=!1,this._anchor=null,this._docker=n,this._outer=n.__findInner(),this._outer instanceof wcSplitter&&(this._inner=this._outer.right()),this.__init(e,t)}function wcLayout(e,t){this.$container=$(e),this._parent=t,this._batchProcess=!1,this._grid=[],this.$table=null,this.__init()}function wcPanel(e,t){this.$container=null,this._parent=null,this.$icon=null,this.$title=null,this.$titleText=null,this.$loading=null,this._panelObject=null,this._initialized=!1,this._type=e,this._title=e,this._titleVisible=!0,this._options=t,this._layout=null,this._buttonList=[],this._actualPos={x:.5,y:.5},this._actualSize={x:0,y:0},this._resizeData={time:-1,timeout:!1,delta:150},this._pos={x:.5,y:.5},this._moveData={time:-1,timeout:!1,delta:150},this._size={x:-1,y:-1},this._minSize={x:100,y:100},this._maxSize={x:Infinity,y:Infinity},this._scroll={x:0,y:0},this._scrollable={x:!0,y:!0},this._collapsible=!0,this._overflowVisible=!1,this._moveable=!0,this._closeable=!0,this._resizeVisible=!0,this._isVisible=!1,this._events={},this.__init()}function wcFrame(e,t,n){this.$container=$(e),this._parent=t,this._isFloating=n,this.$frame=null,this.$title=null,this.$titleBar=null,this.$tabBar=null,this.$tabScroll=null,this.$center=null,this.$tabLeft=null,this.$tabRight=null,this.$close=null,this.$collapse=null,this.$top=null,this.$bottom=null,this.$left=null,this.$right=null,this.$corner1=null,this.$corner2=null,this.$corner3=null,this.$corner4=null,this.$buttonBar=null,this.$shadower=null,this.$modalBlocker=null,this._titleVisible=!0,this._canScrollTabs=!1,this._tabOrientation=wcDocker.TAB.TOP,this._tabScrollPos=0,this._curTab=-1,this._panelList=[],this._buttonList=[],this._resizeData={time:-1,timeout:!1,delta:150},this._pos={x:.5,y:.5},this._size={x:400,y:400},this._lastSize={x:400,y:400},this._anchorMouse={x:0,y:0},this.__init()}function wcSplitter(e,t,n){this.$container=$(e),this._parent=t,this._orientation=n,this._pane=[!1,!1],this.$pane=[],this.$bar=null,this._pos=.5,this._posTarget=.5,this._pixelPos=-1,this._findBestPos=!1,this._anim=0,this._boundEvents=[],this.__init(),this.docker()._splitterList.push(this)}function wcCollapser(e,t,n){this.$container=$(e),this.$frame=null,this._position=n,this._parent=t,this._splitter=null,this._drawer=null,this._size=0,this._orientation=this._position===wcDocker.DOCK.LEFT||this._position===wcDocker.DOCK.RIGHT?wcDocker.ORIENTATION.HORIZONTAL:wcDocker.ORIENTATION.VERTICAL,this.__init()}function wcDrawer(e,t,n){this.$container=$(e),this.$frame=null,this._position=n,this._parent=t,this._frame=null,this._closeSize=0,this._expanded=!1,this._sliding=!1,this._orientation=this._position===wcDocker.DOCK.LEFT||this._position===wcDocker.DOCK.RIGHT?wcDocker.ORIENTATION.HORIZONTAL:wcDocker.ORIENTATION.VERTICAL,this.__init()}function wcTabFrame(e,t){this.$container=$(e),this._parent=t,this.$frame=null,this.$tabBar=null,this.$tabScroll=null,this.$center=null,this.$tabLeft=null,this.$tabRight=null,this.$close=null,this._tabOrientation=wcDocker.TAB.TOP,this._canScrollTabs=!1,this._tabScrollPos=0,this._curTab=-1,this._layoutList=[],this._moveable=!0,this._boundEvents=[],this.__init()}function wcIFrame(e,t){this._panel=t,this._layout=t.layout(),this.$container=$(e),this.$frame=null,this.$focus=null,this.$iFrame=null,this._window=null,this._isDocking=!1,this._isHovering=!1,this._boundEvents=[],this._onLoadFuncs=[],this.__init()}wcDocker.DOCK={MODAL:"modal",FLOAT:"float",TOP:"top",LEFT:"left",RIGHT:"right",BOTTOM:"bottom",STACKED:"stacked"},wcDocker.EVENT={INIT:"panelInit",LOADED:"dockerLoaded",UPDATED:"panelUpdated",VISIBILITY_CHANGED:"panelVisibilityChanged",BEGIN_DOCK:"panelBeginDock",END_DOCK:"panelEndDock",GAIN_FOCUS:"panelGainFocus",LOST_FOCUS:"panelLostFocus",CLOSED:"panelClosed",BUTTON:"panelButton",ATTACHED:"panelAttached",DETACHED:"panelDetached",MOVE_STARTED:"panelMoveStarted",MOVE_ENDED:"panelMoveEnded",MOVED:"panelMoved",RESIZE_STARTED:"panelResizeStarted",RESIZE_ENDED:"panelResizeEnded",RESIZED:"panelResized",SCROLLED:"panelScrolled",SAVE_LAYOUT:"layoutSave",RESTORE_LAYOUT:"layoutRestore",CUSTOM_TAB_CHANGED:"customTabChanged",CUSTOM_TAB_CLOSED:"customTabClosed"},wcDocker.PANEL_PLACEHOLDER="__wcDockerPlaceholderPanel",wcDocker.COLLAPSED="__wcDockerCollapsedPanel",wcDocker.ORIENTATION={VERTICAL:!1,HORIZONTAL:!0},wcDocker.TAB={TOP:"top",LEFT:"left",RIGHT:"right",BOTTOM:"bottom"},wcDocker.prototype={themePath:function(e){return e!==undefined&&(this._options.themePath=e),this._options.themePath},theme:function(e){if(e!==undefined){var t=$("#wcTheme"),n=(new Date).getTime(),r=e.indexOf(".css");r>-1&&(e=e.substring(0,r));var i=$('');this._options.theme=e;var s=this;i[0].onload=function(){t.remove(),s.__update()},$("head").append(i)}return this._options.theme},isCollapseEnabled:function(){return this._canOrientTabs&&this._options.allowCollapse},registerPanelType:function(e,t,n){var r=t;typeof r=="function"&&(r={onCreate:t},console.log("WARNING: Passing in the creation function directly to wcDocker.registerPanelType parameter 2 is now deprecated and will be removed in the next version! Please use the preferred options object instead.")),typeof n!="undefined"&&(r.isPrivate=n,console.log("WARNING: Passing in the isPrivate flag to wcDocker.registerPanelType parameter 3 is now deprecated and will be removed in the next version! Please use the preferred options object instead.")),$.isEmptyObject(r)&&(r=null);for(var i=0;i')),!0},panelTypes:function(e){var t=[];for(var n=0;n=c&&f._curTab--,e.__container(this.$transition),e._parent=null,f._panelList.splice(c,1);break}!f.isCollapser()&&f._curTab===-1&&f._panelList.length&&(f._curTab=0),f.__updateTabs(),f.collapse();if(!f.isCollapser()&&f._panelList.length===0)if(i)this.__addPlaceholder(f);else{var h=this._floatingList.indexOf(f);h!==-1&&this._floatingList.splice(h,1),h=this._frameList.indexOf(f),h!==-1&&this._frameList.splice(h,1);var p=f._parent;if(p instanceof wcSplitter){p.__removeChild(f);var d;p.pane(0)?(d=p.pane(0),p._pane[0]=null):(d=p.pane(1),p._pane[1]=null),n===p&&(n._shift=d),d.__container(this.$transition),d._parent=null,h=this._splitterList.indexOf(p),h!==-1&&this._splitterList.splice(h,1);var v=p._parent;parentContainer=p.__container(),p.__destroy(),v instanceof wcSplitter?(v.__removeChild(p),v.pane(0)?v.pane(1,d):v.pane(0,d)):v===this&&(this._root=d,d._parent=this,d.__container(parentContainer)),this.__update()}this._focusFrame===f&&(this._focusFrame=null),f.__destroy()}}e.initSize(u,a),t===wcDocker.DOCK.STACKED?this.__addPanelGrouped(e,n,r):this.__addPanelAlone(e,t,n,r),n==this._placeholderPanel&&(this.removePanel(this._placeholderPanel),this._placeholderPanel=null);var m=e._parent;return m instanceof wcFrame&&m._panelList.length===1&&m.pos(o.left+u/2+20,o.top+a/2+20,!0),this.__update(!0),m instanceof wcFrame&&l!==m._isFloating&&(m._isFloating?e.__trigger(wcDocker.EVENT.DETACHED):e.__trigger(wcDocker.EVENT.ATTACHED)),e.__trigger(wcDocker.EVENT.MOVED),e},findPanels:function(e){var t=[];for(var n=0;n