/*! * 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
'),this.$outer.append(this.$loading);var r=$('
');typeof t!="number"&&(t=.4),r.css("opacity",t),this.$loading.append(r);var i=$('
');this.$loading.append(i);if(e){var s=$(''+e+"");this.$loading.append(s)}typeof n!="number"&&(n=1),i.css("opacity",n),s&&s.css("opacity",n)}},finishLoading:function(e){if(this.$loading)if(e>0){var t=this;this.$loading.fadeOut(e,function(){t.$loading.remove(),t.$loading=null})}else this.$loading.remove(),this.$loading=null},on:function(e,t){return e?(this._events[e]||(this._events[e]=[]),this._events[e].indexOf(t)!==-1?!1:(this._events[e].push(t),!0)):!1},off:function(e,t){if(typeof e=="undefined"){this._events={};return}if(this._events[e])if(typeof t=="undefined")this._events[e]=[];else for(var n=0;n0&&r.findPanels(c.name).length>=c.options.limit)continue;var h=null,p=null,d=c.name;c.options&&(c.options.faicon&&(p=c.options.faicon),c.options.icon&&(h=c.options.icon),c.options.title&&(d=c.options.title)),l[c.name]={name:d,icon:h,faicon:p,className:"wcMenuCreatePanel"}}}var v=0,m={},g=t;typeof t=="function"&&(g=t(e,i));for(var u=0;u');i.prepend(s),r.icon&&s.addClass(r.icon),r.faicon&&s.addClass("fa fa-menu fa-"+r.faicon+" fa-lg fa-fw");if(i.hasClass("context-menu-submenu")){var o=$('
');i.append(o)}}r.items&&u(r.items)}})(t)})(S)},hide:function(e){r._ghost&&(r._ghost.destroy(),r._ghost=!1)}},animation:{duration:250,show:"fadeIn",hide:"fadeOut"},reposition:!1,autoHide:!0,zIndex:200,items:S}}})},bypassMenu:function(){this._menuTimer&&clearTimeout(this._menuTimer);for(var e in $.contextMenu.menus){var t=$.contextMenu.menus[e].selector;$(t).contextMenu(!1)}var n=this;this._menuTimer=setTimeout(function(){for(var e in $.contextMenu.menus){var t=$.contextMenu.menus[e].selector;$(t).contextMenu(!0)}n._menuTimer=null},0)},save:function(){var e={};e.floating=[];for(var t=0;t-1){if(e._draggingFrame._panelList.length===1)return;for(var r=0;r1&&e._draggingFrameTab,e._draggingFrameTopper)){e._draggingFrame.__shadow(!0),e.__focus();if(!l)for(var h=0;h0;var u=e._draggingFrame.__rect();e._ghost=new wcGhost(u,n,e),e._draggingFrame.__checkAnchorDrop(n,!0,e._ghost,!0,e._draggingFrameTopper),e.trigger(wcDocker.EVENT.BEGIN_DOCK)}break}for(var r=0;r .wcFrameButton",p),$("body").on("touchstart",".wcFrameButtonBar > .wcFrameButton",p),$("body").on("mousedown",".wcFrameTitleBar",y),$("body").on("touchstart",".wcFrameTitleBar",y),$("body").on("mousedown",".wcSplitterBar",g),$("body").on("touchstart",".wcSplitterBar",g),$("body").on("mousedown",".wcPanelTab",S),$("body").on("touchstart",".wcPanelTab",S),$("body").on("mouseup",".wcPanelTab",m),$("body").on("touchend",".wcPanelTab",m),$("body").on("mousedown",".wcLayout",b),$("body").on("touchstart",".wcLayout",b),$("body").on("mousedown",".wcFrameEdge",w),$("body").on("touchstart",".wcFrameEdge",w),$("body").on("mousedown",".wcCreatePanel",E),$("body").on("touchstart",".wcCreatePanel",E),$("body").on("mouseup",n),$("body").on("touchend",n),$("body").on("click",".wcCustomTab .wcFrameButton",d),$("body").on("click",".wcFrameButtonBar > .wcFrameButton",v),$("body").on("keyup",x);var r=(new Date).getTime(),i=null,s=0},__testLoadFinished:function(){for(var e=0;e>>0,n=Number(arguments[1])||0;n=n<0?Math.ceil(n):Math.floor(n),n<0&&(n+=t);for(;n",n[0]);return e>4?e:undefined}();if(e<9)this._canOrientTabs=!1;else{function t(){var e="transform WebkitTransform MozTransform OTransform msTransform".split(" "),t=document.createElement("div");for(var n=0;n
'),a.$frame.prepend(a.$modalBlocker),e.moveable(!1),a.$frame.addClass("wcModal"),this._modalList.push(a));if(r){var f=a.pos(undefined,undefined,!0);r.hasOwnProperty("x")&&(f.x=r.x+r.w/2),r.hasOwnProperty("y")&&(f.y=r.y+r.h/2),a.pos(f.x,f.y,!0),a._size={x:r.w,y:r.h}}return}if(n){var l=n._parent,c=n;while(!(l instanceof wcSplitter||l instanceof wcDocker))c=l,l=l._parent;if(l instanceof wcSplitter){var h,p=l.pane(0),d=l.pane(1),v={x:-1,y:-1};p===c?(h=new wcSplitter(this.$transition,l,t!==wcDocker.DOCK.BOTTOM&&t!==wcDocker.DOCK.TOP),v.x=l.$pane[0].width(),v.y=l.$pane[0].height(),l.pane(0,h)):(h=new wcSplitter(this.$transition,l,t!==wcDocker.DOCK.BOTTOM&&t!==wcDocker.DOCK.TOP),v.x=l.$pane[1].width(),v.y=l.$pane[1].height(),l.pane(1,h));if(h){h.scrollable(0,!1,!1),h.scrollable(1,!1,!1),r||(r={w:e._size.x,h:e._size.y});if(r){r.w<0&&(r.w=v.x/2),r.h<0&&(r.h=v.y/2);switch(t){case wcDocker.DOCK.LEFT:h.pos(r.w/v.x);break;case wcDocker.DOCK.RIGHT:h.pos(1-r.w/v.x);break;case wcDocker.DOCK.TOP:h.pos(r.h/v.y);break;case wcDocker.DOCK.BOTTOM:h.pos(1-r.h/v.y)}}else h.pos(.5);a=new wcFrame(this.$transition,h,!1),this._frameList.push(a),t===wcDocker.DOCK.LEFT||t===wcDocker.DOCK.TOP?(h.pane(0,a),h.pane(1,c)):(h.pane(0,c),h.pane(1,a)),a.addPanel(e)}return}}var m=this,g=this.$container,a=new wcFrame(this.$transition,m,!1);this._frameList.push(a);if(!m._root)m._root=a,a.__container(g);else{var h=new wcSplitter(g,m,t!==wcDocker.DOCK.BOTTOM&&t!==wcDocker.DOCK.TOP);if(h){a._parent=h,h.scrollable(0,!1,!1),h.scrollable(1,!1,!1);var v={x:g.width(),y:g.height()};if(!r)h.__findBestPos();else{r.w<0&&(r.w=v.x/2),r.h<0&&(r.h=v.y/2);switch(t){case wcDocker.DOCK.LEFT:h.pos(r.w/v.x);break;case wcDocker.DOCK.RIGHT:h.pos(1-r.w/v.x);break;case wcDocker.DOCK.TOP:h.pos(r.h/v.y);break;case wcDocker.DOCK.BOTTOM:h.pos(1-r.h/v.y)}}t===wcDocker.DOCK.LEFT||t===wcDocker.DOCK.TOP?(h.pane(0,a),h.pane(1,m._root)):(h.pane(0,m._root),h.pane(1,a)),m._root=h}}a.addPanel(e)},__addCollapser:function(e,t){var n=null;if(t){var r=t._parent,i=t;while(!(r instanceof wcSplitter||r instanceof wcDocker))i=r,r=r._parent;var s=new wcSplitter(this.$transition,r,e!==wcDocker.DOCK.BOTTOM&&e!==wcDocker.DOCK.TOP);r instanceof wcDocker&&(this._root=s,s.__container(this.$container));if(r instanceof wcSplitter){var o=r.left(),u=r.right(),a={x:-1,y:-1};o===i?(a.x=r.$pane[0].width(),a.y=r.$pane[0].height(),r.pane(0,s)):(s=new wcSplitter(this.$transition,r,e!==wcDocker.DOCK.BOTTOM&&e!==wcDocker.DOCK.TOP),a.x=r.$pane[1].width(),a.y=r.$pane[1].height(),r.pane(1,s))}if(s){s.scrollable(0,!1,!1),s.scrollable(1,!1,!1),n=new wcCollapser(this.$transition,s,e);switch(e){case wcDocker.DOCK.TOP:case wcDocker.DOCK.LEFT:s.pos(0);break;case wcDocker.DOCK.BOTTOM:case wcDocker.DOCK.RIGHT:s.pos(1)}e===wcDocker.DOCK.LEFT||e===wcDocker.DOCK.TOP?(s.pane(0,n),s.pane(1,i)):(s.pane(0,i),s.pane(1,n))}}return n},__addPlaceholder:function(e){this._placeholderPanel&&console.log("WARNING: wcDocker creating placeholder panel when one already exists"),this._placeholderPanel=new wcPanel(wcDocker.PANEL_PLACEHOLDER,{}),this._placeholderPanel._isPlaceholder=!0,this._placeholderPanel._parent=this,this._placeholderPanel.__container(this.$transition),this._placeholderPanel._panelObject=new function(e){e.title(!1),e.closeable(!1)}(this._placeholderPanel),e?this.__addPanelGrouped(this._placeholderPanel,e):this.__addPanelAlone(this._placeholderPanel,wcDocker.DOCK.TOP),this.__update()},__stringToPercent:function(e,t){if(typeof e=="string"){if(e.indexOf("%",e.length-1)!==-1)return parseFloat(e)/100;if(e.indexOf("px",e.length-2)!==-1)return parseFloat(e)/t}return parseFloat(e)},__stringToPixel:function(e,t){if(typeof e=="string"){if(e.indexOf("%",e.length-1)!==-1)return parseFloat(e)/100*t;if(e.indexOf("px",e.length-2)!==-1)return parseFloat(e)}return parseFloat(e)}},wcGhost.prototype={update:function(e){this.__move(e);for(var t=0;tn.x&&e.y>n.y&&e.xn.x&&e.y>n.y&&e.x').css("opacity",0).css("top",e.y+"px").css("left",e.x+"px").css("width",e.w+"px").css("height",e.h+"px"),this._anchorMouse={x:e.x-t.x,y:e.y-t.y},this._rect={x:-this._anchorMouse.x,y:-this._anchorMouse.y,w:e.w,h:e.h},$("body").append(this.$ghost),this.anchor(t,e)},__move:function(e){if(this._anchor)return;var t=parseInt(this.$ghost.css("left")),n=parseInt(this.$ghost.css("top"));t=e.x+this._anchorMouse.x,n=e.y+this._anchorMouse.y,this.$ghost.css("left",t+"px"),this.$ghost.css("top",n+"px")},__rect:function(){return this._rect},__destroy:function(){this.$ghost.stop().animate({opacity:0},{duration:175,complete:function(){$(this).remove()}})}},wcLayout.prototype={addItem:function(e,t,n,r,i){if(typeof t=="undefined"||t<0)t=0;if(typeof n=="undefined"||n<0)n=0;if(typeof r=="undefined"||r<=0)r=1;if(typeof i=="undefined"||i<=0)i=1;this.__resizeGrid(t+r-1,n+i-1);if(r>1||i>1)if(!this.__mergeGrid(t,n,r,i))return!1;return this._grid[n][t].$el.append($(e)),this.item(t,n)},item:function(e,t){if(t>=this._grid.length)return!1;if(e>=this._grid[t].length)return!1;var n=this,r={$:n._grid[t][e].$el,css:function(i,s){if(n._grid[t][e].$el){if(s===undefined)return n._grid[t][e].$el.css(i);n._grid[t][e].$el.css(i,s)}return r},stretch:function(i,s){return n.itemStretch(e,t,i,s),r}};return r},itemStretch:function(e,t,n,r){var i=this._batchProcess;this._batchProcess=!0,this.__resizeGrid(e,t);var s=this._grid[t][e];return s.x<0||s.y<0?!1:(n!==undefined&&(s.sx=n),r!==undefined&&(s.sy=r),this._batchProcess=i,i||this.__resizeGrid(0,0),!0)},clear:function(){var e=this.showGrid(),t=this.gridSpacing(),n=this.gridAlternate();this.$table.remove(),this.__init(),this.showGrid(e),this.gridSpacing(t),this.gridAlternate(n),this._grid=[]},startBatch:function(){this._batchProcess=!0},finishBatch:function(){this._batchProcess=!1,this.__resizeGrid(0,0)},showGrid:function(e){return typeof e!="undefined"&&this.$table.toggleClass("wcLayoutGrid",e),this.$table.hasClass("wcLayoutGrid")},gridSpacing:function(e){return typeof e!="undefined"&&this.$table.css("border-spacing",e+"px"),parseInt(this.$table.css("border-spacing"))},gridAlternate:function(e){return typeof e!="undefined"&&this.$table.toggleClass("wcLayoutGridAlternate",e),this.$table.hasClass("wcLayoutGridAlternate")},scene:function(){return console.log("wcLayout.scene() has been deprecated, please use wcLayout.$table instead. This function will be removed in the next version."),this.$table},__init:function(){this.$table=$('
'),this.$table.append($("")),this.__container(this.$container)},__update:function(){},__resizeGrid:function(e,t){for(var n=0;n<=t;++n){if(this._grid.length<=n){var r=[];r.$row=$(""),this._grid.push(r)}for(var i=0;i<=e;++i)this._grid[n].length<=i&&this._grid[n].push({$el:$(""),x:0,y:0,sx:"",sy:""})}if(!this._batchProcess){var s=this.$table.find("tbody");$(".wcDockerTransition").append(s);var o=$("");for(var n=0;n1&&(o.$el.attr("colspan",""+n),o.x=n-1),r>1&&(o.$el.attr("rowspan",""+r),o.y=r-1);for(var i=0;i=d.top&&e.y<=d.top+p&&e.x>=d.left+c&&e.x<=d.left+c+v)return n.anchor(e,{x:d.left-2,y:d.top-2,w:h/3,h:p,loc:wcDocker.DOCK.LEFT,item:n._inner,self:!1}),!0;if(e.y>=d.top&&e.y<=d.top+p&&e.x>=d.left+h-v-c&&e.x<=d.left+h-c)return n.anchor(e,{x:d.left+h-h/3-2,y:d.top-2,w:h/3,h:p,loc:wcDocker.DOCK.RIGHT,item:n._inner,self:!1}),!0;if(e.y>=d.top+c&&e.y<=d.top+c+v&&e.x>=d.left&&e.x<=d.left+h)return n.anchor(e,{x:d.left-2,y:d.top-2,w:h,h:p/3,loc:wcDocker.DOCK.TOP,item:n._inner,self:!1}),!0;if(e.y>=d.top+p-c-v&&e.y<=d.top+p-c&&e.x>=d.left&&e.x<=d.left+h)return n.anchor(e,{x:d.left-2,y:d.top+p-p/3-2,w:h,h:p/3,loc:wcDocker.DOCK.BOTTOM,item:n._inner,self:!1}),!0}if(s){if((!u||u===wcDocker.TAB.TOP)&&e.y>=l.top&&e.y<=l.top+c&&e.x>=l.left&&e.x<=l.left+a)return n.anchor(e,{x:l.left-2,y:l.top-2,w:a,h:c-2,loc:wcDocker.DOCK.STACKED,tab:wcDocker.TAB.TOP,item:this,self:t===wcDocker.TAB.TOP||o&&t}),!0;if(this._parent.docker()._canOrientTabs){if((!u||u===wcDocker.TAB.BOTTOM)&&e.y>=l.top+f-c&&e.y<=l.top+f&&e.x>=l.left&&e.x<=l.left+a)return n.anchor(e,{x:l.left-2,y:l.top+f-c-2,w:a,h:c,loc:wcDocker.DOCK.STACKED,tab:wcDocker.TAB.BOTTOM,item:this,self:t===wcDocker.TAB.BOTTOM}),!0;if((!u||u===wcDocker.TAB.LEFT)&&e.y>=l.top&&e.y<=l.top+f&&e.x>=l.left&&e.x<=l.left+c)return n.anchor(e,{x:l.left-2,y:l.top-2,w:c-2,h:f,loc:wcDocker.DOCK.STACKED,tab:wcDocker.TAB.LEFT,item:this,self:t===wcDocker.TAB.LEFT}),!0;if((!u||u===wcDocker.TAB.RIGHT)&&e.y>=l.top&&e.y<=l.top+f&&e.x>=l.left+a-c&&e.x<=l.left+a)return n.anchor(e,{x:l.left+a-c-2,y:l.top-2,w:c,h:f,loc:wcDocker.DOCK.STACKED,tab:wcDocker.TAB.RIGHT,item:this,self:t===wcDocker.TAB.RIGHT}),!0}}if(!r)return!1;if(this._parent instanceof wcPanel&&this._parent._isPlaceholder)return n.anchor(e,{x:l.left-2,y:l.top-2,w:a,h:f,loc:wcDocker.DOCK.TOP,item:this,self:!1}),!0;if(a=l.top&&e.y<=l.top+f*.25&&e.x>=l.left&&e.x<=l.left+a)return n.anchor(e,{x:l.left-2,y:l.top-2,w:a,h:f*.5,loc:wcDocker.DOCK.TOP,item:this,self:!1}),!0;if(e.y>=l.top+f*.75&&e.y<=l.top+f&&e.x>=l.left&&e.x<=l.left+a)return n.anchor(e,{x:l.left-2,y:l.top+(f-f*.5)-2,w:a,h:f*.5,loc:wcDocker.DOCK.BOTTOM,item:this,self:!1}),!0}if(e.y>=l.top&&e.y<=l.top+f){if(e.x>=l.left&&e.x<=l.left+a*.25)return n.anchor(e,{x:l.left-2,y:l.top-2,w:a*.5,h:f,loc:wcDocker.DOCK.LEFT,item:this,self:!1}),!0;if(e.x>=l.left+a*.75&&e.x<=l.left+a)return n.anchor(e,{x:l.left+a*.5-2,y:l.top-2,w:a*.5,h:f,loc:wcDocker.DOCK.RIGHT,item:this,self:!1}),!0}if(a>=f){if(e.y>=l.top&&e.y<=l.top+f*.25&&e.x>=l.left&&e.x<=l.left+a)return n.anchor(e,{x:l.left-2,y:l.top-2,w:a,h:f*.5,loc:wcDocker.DOCK.TOP,item:this,self:!1}),!0;if(e.y>=l.top+f*.75&&e.y<=l.top+f&&e.x>=l.left&&e.x<=l.left+a)return n.anchor(e,{x:l.left-2,y:l.top+(f-f*.5)-2,w:a,h:f*.5,loc:wcDocker.DOCK.BOTTOM,item:this,self:!1}),!0}return!1},__container:function(e){return typeof e=="undefined"?this.$container:(this.$container=e,this.$container?this.$container.append(this.$table):this.$table.remove(),this.$container)},__destroy:function(){this.__container(null),this._parent=null,this.clear(),this.$table.remove(),this.$table=null}},wcPanel.prototype={docker:function(){var e=this._parent;while(e&&!(e instanceof wcDocker))e=e._parent;return e},title:function(e){return typeof e!="undefined"&&(e===!1?(this._titleVisible=!1,this.$titleText.html(this._type)):(this._title=e,this.$titleText.html(e)),this.$icon&&this.$titleText.prepend(this.$icon),this._parent instanceof wcFrame&&this._parent.__updateTabs()),this._title},info:function(){return this.docker().panelTypeInfo(this._type)},layout:function(){return this._layout},focus:function(e){var t=this.docker();if(t){t.__focus(this._parent,e);for(var n=0;n"),this.$titleText.prepend(this.$icon)),this.$icon.removeClass(),this.$icon.addClass("wcTabIcon "+e),this._parent instanceof wcFrame&&this._parent.__updateTabs()},faicon:function(e){this.$icon||(this.$icon=$("
"),this.$titleText.prepend(this.$icon)),this.$icon.removeClass(),this.$icon.addClass("wcTabIcon fa fa-fw fa-"+e),this._parent instanceof wcFrame&&this._parent.__updateTabs()},scrollable:function(e,t){return typeof e!="undefined"&&(this._scrollable.x=e?!0:!1,this._scrollable.y=t?!0:!1),{x:this._scrollable.x,y:this._scrollable.y}},scroll:function(e,t,n){return this.$container?(typeof e!="undefined"&&(n?this.$container.parent().stop().animate({scrollLeft:e,scrollTop:t},n):(this.$container.parent().scrollLeft(e),this.$container.parent().scrollTop(t))),{x:this.$container.parent().scrollLeft(),y:this.$container.parent().scrollTop()}):{x:0,y:0}},collapsible:function(e){return typeof e!="undefined"&&(this._collapsible=e?!0:!1),this._collapsible},overflowVisible:function(e){return typeof e!="undefined"&&(this._overflowVisible=e?!0:!1),this._overflowVisible},resizeVisible:function(e){return typeof e!="undefined"&&(this._resizeVisible=e?!0:!1),this._resizeVisible},moveable:function(e){return typeof e!="undefined"&&(this._moveable=e?!0:!1,this.$title.toggleClass("wcNotMoveable",!this._moveable)),this._moveable},closeable:function(e){return typeof e!="undefined"&&(this._closeable=e?!0:!1,this._parent&&this._parent.__update()),this._closeable},close:function(){this._parent&&this._parent.$close.click()},startLoading:function(e,t,n){if(!this.$loading){this.$loading=$('
'),this.$container.append(this.$loading);var r=$('
');typeof t!="number"&&(t=.4),this.$loading.append(r);var i=$('
');this.$loading.append(i);if(e){var s=$(''+e+"");this.$loading.append(s)}typeof n!="number"&&(n=1),this.docker().$loading&&(t=0,n=0),r.css("opacity",t),i.css("opacity",n),s&&s.css("opacity",n)}},finishLoading:function(e){if(this.$loading)if(e>0){var t=this;this.$loading.fadeOut(e,function(){t.$loading.remove(),t.$loading=null,t.docker().__testLoadFinished()})}else this.$loading.remove(),this.$loading=null,this.docker().__testLoadFinished()},on:function(e,t){return e?(this._events[e]||(this._events[e]=[]),this._events[e].indexOf(t)!==-1?!1:(this._events[e].push(t),!0)):!1},off:function(e,t){if(typeof e=="undefined"){this._events={};return}if(this._events[e])if(typeof t=="undefined")this._events[e]=[];else for(var n=0;n'),this.$titleText=$("
"+this._title+"
"),this.$title.append(this.$titleText),this._options.hasOwnProperty("title")&&this.title(this._options.title),this._options.icon&&this.icon(this._options.icon),this._options.faicon&&this.faicon(this._options.faicon)},__update:function(){var e=this.docker();if(!e)return;this._layout.__update();if(!this.$container)return;this._resizeVisible?this._parent.$frame.removeClass("wcHideOnResize"):this._parent.$frame.addClass("wcHideOnResize");if(!this._initialized){this._initialized=!0;var t=this;setTimeout(function(){t.__trigger(wcDocker.EVENT.INIT),e.__testLoadFinished()},0)}else this.__trigger(wcDocker.EVENT.UPDATED);var n=this.$container.width(),r=this.$container.height();if(this._actualSize.x!==n||this._actualSize.y!==r)this._actualSize.x=n,this._actualSize.y=r,this._resizeData.time=new Date,this._resizeData.timeout||(this._resizeData.timeout=!0,setTimeout(this.__resizeEnd.bind(this),this._resizeData.delta),this.__trigger(wcDocker.EVENT.RESIZE_STARTED,{width:this._actualSize.x,height:this._actualSize.y})),this.__trigger(wcDocker.EVENT.RESIZED,{width:this._actualSize.x,height:this._actualSize.y});var i=this.$container.offset();if(this._actualPos.x!==i.left||this._actualPos.y!==i.top)this._actualPos.x=i.left,this._actualPos.y=i.top,this._moveData.time=new Date,this._moveData.timeout||(this._moveData.timeout=!0,setTimeout(this.__moveEnd.bind(this),this._moveData.delta),this.__trigger(wcDocker.EVENT.MOVE_STARTED,{x:this._actualPos.x,y:this._actualPos.y})),this.__trigger(wcDocker.EVENT.MOVED,{x:this._actualPos.x,y:this._actualPos.y})},__resizeEnd:function(){new Date-this._resizeData.time=t&&this._curTab--,this._panelList[t].__container(null),this._panelList[t]._parent=null,this._panelList.splice(t,1);break}return this._curTab===-1&&!this.collapse()&&this._panelList.length&&(this._curTab=0),this.__updateTabs(),this._panelList.length>0},panel:function(e,t){return typeof e!="undefined"&&(this.isCollapser()&&e===this._curTab&&(this.collapse(),e=-1),e .wcTabScroller > .wcPanelTab[id="'+this._curTab+'"]').removeClass("wcPanelTabActive"),this.$center.children('.wcPanelTabContent[id="'+this._curTab+'"]').addClass("wcPanelTabContentHidden"),this._curTab!==e&&this.collapse(),this._curTab=e,e>-1&&(this.$tabBar.find('> .wcTabScroller > .wcPanelTab[id="'+e+'"]').addClass("wcPanelTabActive"),this.$center.children('.wcPanelTabContent[id="'+e+'"]').removeClass("wcPanelTabContentHidden"),this.expand()),this.__updateTabs(t))),this._curTab>-1&&this._curTab'),this.$title=$('
'),this.$titleBar=$('
'),this.$tabBar=$('
'),this.$tabScroll=$('
'),this.$center=$('
'),this.$tabLeft=$('
<
'),this.$tabRight=$('
>
'),this.$close=$('
X
'),this.$collapse=$('
C
'),this.$buttonBar=$('
'),this.$tabButtonBar=$('
'),this.$tabBar.append(this.$tabScroll),this.$tabBar.append(this.$tabButtonBar),this.$frame.append(this.$buttonBar),this.$buttonBar.append(this.$close),this.$buttonBar.append(this.$collapse),this.$frame.append(this.$center),this._isFloating&&(this.$top=$('
').css("top","-6px").css("left","0px").css("right","0px"),this.$bottom=$('
').css("bottom","-6px").css("left","0px").css("right","0px"),this.$left=$('
').css("left","-6px").css("top","0px").css("bottom","0px"),this.$right=$('
').css("right","-6px").css("top","0px").css("bottom","0px"),this.$corner1=$('
').css("top","-6px").css("left","-6px"),this.$corner2=$('
').css("top","-6px").css("right","-6px"),this.$corner3=$('
').css("bottom","-6px").css("right","-6px"),this.$corner4=$('
').css("bottom","-6px").css("left","-6px"),this.$frame.append(this.$top),this.$frame.append(this.$bottom),this.$frame.append(this.$left),this.$frame.append(this.$right),this.$frame.append(this.$corner1),this.$frame.append(this.$corner2),this.$frame.append(this.$corner3),this.$frame.append(this.$corner4)),this.__container(this.$container),this._isFloating&&this.$frame.addClass("wcFloating"),this.$center.scroll(this.__scrolled.bind(this))},__update:function(){var e=this.$container.width(),t=this.$container.height();if(this._isFloating){var n=this._pos.x*e-this._size.x/2,r=this._pos.y*t-this._size.y/2;r<0&&(r=0),n+this._size.x/2<0&&(n=-this._size.x/2),n+this._size.x/2>e&&(n=e-this._size.x/2),r+parseInt(this.$center.css("top"))>t&&(r=t-parseInt(this.$center.css("top"))),this.$frame.css("left",n+"px"),this.$frame.css("top",r+"px"),this.$frame.css("width",this._size.x+"px"),this.$frame.css("height",this._size.y+"px")}if(e!==this._lastSize.x||t!==this._lastSize.y)this._lastSize.x=e,this._lastSize.y=t,this._resizeData.time=new Date,this._resizeData.timeout||(this._resizeData.timeout=!0,setTimeout(this.__resizeEnd.bind(this),this._resizeData.delta));this.__onTabChange()},__resizeEnd:function(){this.__updateTabs(),new Date-this._resizeData.time1||this._isFloating||this.isCollapser(),u=this;this.isCollapser()?this.$tabBar.addClass("wcNotMoveable"):(this.$titleBar.removeClass("wcNotMoveable"),this.$tabBar.removeClass("wcNotMoveable")),this.$center.children(".wcPanelTabContent").each(function(){$(this).addClass("wcPanelTabContentHidden wcPanelTabUnused")}),this._titleVisible=!0,this.$title.html("");for(var a=0;a'),this.$center.append(c)),f.__container(c),f._parent=this;var h=this._curTab===a;f.isVisible()!==h&&n.push({panel:f,isVisible:h}),c.removeClass("wcPanelTabUnused");if(h){l&&l.addClass("wcPanelTabActive"),c.removeClass("wcPanelTabContentHidden"),this.$title.html(f.title());if(f.$icon){var p=f.$icon.clone();this.$title.prepend(p)}}l&&(i=t(l)-s,r.push(i),i+=l.outerWidth())}var d=this.$titleBar,v=0;if(this._titleVisible){this.$frame.parent()||this.$center.css("top","");switch(this._tabOrientation){case wcDocker.TAB.TOP:this.$frame.prepend(this.$tabBar),this.$titleBar.remove(),this.$tabBar.addClass("wcTabTop").removeClass("wcTabLeft wcTabRight wcTabBottom"),o?this.$title.remove():this.$tabBar.prepend(this.$title),d=this.$tabBar,this.$center.css("left",0).css("right",0).css("bottom",0),v=this.$center.width();break;case wcDocker.TAB.BOTTOM:this.$frame.prepend(this.$titleBar),this.$titleBar.append(this.$title);if(o){var m=this.$titleBar.height();this.$frame.append(this.$tabBar),this.$tabBar.addClass("wcTabBottom").removeClass("wcTabTop wcTabLeft wcTabRight"),this.$center.css("left",0).css("right",0).css("bottom",m)}else this.$tabBar.remove();v=this.$center.width();break;case wcDocker.TAB.LEFT:this.$frame.prepend(this.$titleBar),this.$titleBar.append(this.$title);if(o){var m=this.$titleBar.height();this.$frame.append(this.$tabBar),this.$tabBar.addClass("wcTabLeft").removeClass("wcTabTop wcTabRight wcTabBottom"),this.$center.css("left",m).css("right",0).css("bottom",0)}else this.$tabBar.remove();v=this.$center.height();break;case wcDocker.TAB.RIGHT:this.$frame.prepend(this.$titleBar),this.$titleBar.append(this.$title);if(o){var m=this.$titleBar.height();this.$frame.append(this.$tabBar),this.$tabBar.addClass("wcTabRight").removeClass("wcTabTop wcTabLeft wcTabBottom"),this.$center.css("left",0).css("right",m).css("bottom",0)}else this.$tabBar.remove();v=this.$center.height()}o||this.$center.css("left",0).css("right",0).css("bottom",0)}else this.$titleBar.remove(),this.$tabBar.remove(),this.$center.css("top",0).css("left",0).css("right",0).css("bottom",0);this.$center.children(".wcPanelTabUnused").each(function(){$(this).remove()});if(this._titleVisible){var g=this.__onTabChange();if(e)for(var a=0;aE&&(this._tabScrollPos=b-E+this.LEFT_TAB_BUFFER);break}this._canScrollTabs=!1;if(i>v-g){this._canScrollTabs=this._titleVisible,this._canScrollTabs&&(this.$tabButtonBar.append(this.$tabRight),this.$tabButtonBar.append(this.$tabLeft),g+=this.$tabRight.outerWidth(),g+=this.$tabLeft.outerWidth());var S=i-(v-g)/2;if(this._tabScrollPos>S){var x=this.$tabScroll.children();for(var a=0;aS){this._tabScrollPos=i-this.LEFT_TAB_BUFFER,this._tabScrollPos<0&&(this._tabScrollPos=0);break}}}}else this._tabScrollPos=0,this.$tabLeft.remove(),this.$tabRight.remove();this.$tabScroll.stop().animate({left:-this._tabScrollPos+"px"},"fast");for(var a=0;a.5&&a.bottom>.95?(f="bottom.",l="wcCollapseBottom"):a.left<=.05?(f="left side.",l="wcCollapseLeft"):a.right>=.95?(f="right side.",l="wcCollapseRight"):a.bottom>.95&&(f="bottom.",l="wcCollapseBottom");if(f){var s=this.$collapse.children("div");s[0].className="fa fa-sign-in",s.addClass(l),s.addClass("wcCollapsible"),this.$collapse.show(),this.$collapse.attr("title","Collapse this panel into the "+f),e+=this.$collapse.outerWidth()}}for(var c=0;c"),d=h.className;p.addClass("wcFrameButton"),h.isTogglable&&(p.addClass("wcFrameButtonToggler"),h.isToggled&&(p.addClass("wcFrameButtonToggled"),d=h.toggleClassName||d)),p.attr("title",h.tip),p.data("name",h.name),p.text(h.text),d&&p.prepend($('
')),this._buttonList.push(p),this.$buttonBar.append(p),e+=p.outerWidth()}}this._canScrollTabs&&(this.$tabButtonBar.append(this.$tabRight),this.$tabButtonBar.append(this.$tabLeft),t+=this.$tabRight.outerWidth()+this.$tabLeft.outerWidth());if(this._titleVisible){this.$buttonBar.css("right","");switch(this._tabOrientation){case wcDocker.TAB.RIGHT:this.$buttonBar.css("right",this.$tabBar.height());case wcDocker.TAB.LEFT:this.$tabBar.css("width",this.$center.height()+this.$tabBar.height());break;case wcDocker.TAB.TOP:case wcDocker.TAB.BOTTOM:this.$tabBar.css("width",this.$center.width());break;default:}}n.__update(),this.$center.scrollLeft(n._scroll.x),this.$center.scrollTop(n._scroll.y)}return this.$buttonBar.css("min-width",e).css("width",e),this.$tabButtonBar.css("min-width",t).css("width",t),this._tabOrientation===wcDocker.TAB.TOP?(this.$tabButtonBar.css("right",e),e+t):(this.$tabButtonBar.css("right",0),t)},__scrolled:function(){var e=this.panel();e._scroll.x=this.$center.scrollLeft(),e._scroll.y=this.$center.scrollTop(),e.__trigger(wcDocker.EVENT.SCROLLED)},__focus:function(e){if(e){var t=$('
');this.$frame.append(t),t.animate({opacity:.25},100).animate({opacity:0},100).animate({opacity:.1},50).animate({opacity:0},50).queue(function(e){t.remove(),e()})}},__move:function(e){var t=this.$container.width(),n=this.$container.height();this._pos.x=(e.x+this._anchorMouse.x)/t,this._pos.y=(e.y+this._anchorMouse.y)/n},__anchorMove:function(e){var t=this.$container.width(),n=this.$container.height();this._anchorMouse.x=this._pos.x*t-e.x,this._anchorMouse.y=this._pos.y*n-e.y},__tabMove:function(e,t){if(e>=0&&e=0&&t .wcTabScroller > .wcPanelTab[id="'+t+'"]')[0]}return!1},__checkAnchorDrop:function(e,t,n,r,i){var s=this.panel();return s&&s.moveable()?s.layout().__checkAnchorDrop(e,t&&this._tabOrientation,n,!this._isFloating&&!this.isCollapser()&&r,this.$frame,s.moveable()&&s.title(),i,this.isCollapser()?this._tabOrientation:undefined):!1},__resize:function(e,t){var n=this.$container.width(),r=this.$container.height(),i=this.$container.offset();t.x-=i.left,t.y-=i.top;var s=this.minSize(),o=this.maxSize(),u={x:this._pos.x*n-this._size.x/2,y:this._pos.y*r-this._size.y/2};for(var a=0;ao.y&&(u.y+=this._size.y-o.y,this._size.y=o.y);break;case"bottom":this._size.y=t.y-4-u.y,this._size.yo.y&&(this._size.y=o.y);break;case"left":this._size.x+=u.x-t.x-2,u.x=t.x+2,this._size.xo.x&&(u.x+=this._size.x-o.x,this._size.x=o.x);break;case"right":this._size.x=t.x-4-u.x,this._size.xo.x&&(this._size.x=o.x)}this._pos.x=(u.x+this._size.x/2)/n,this._pos.y=(u.y+this._size.y/2)/r}},__shadow:function(e){if(e)this.$shadower||(this.$shadower=$('
'),this.$frame.append(this.$shadower),this.$shadower.animate({opacity:.5},300));else if(this.$shadower){var t=this;this.$shadower.animate({opacity:0},300).queue(function(e){t.$shadower.remove(),t.$shadower=null,e()})}},__rect:function(){if(this.isCollapser())return this._parent.__rect();var e=this.$frame.offset(),t=this.$frame.width(),n=this.$frame.height();return{x:e.left,y:e.top,w:t,h:n}},__container:function(e){return typeof e=="undefined"?this.$container:(this.$container=e,this.$container?this.$container.append(this.$frame):this.$frame.remove(),this.$container)},__destroy:function(){this._curTab=-1;for(var e=0;en._posTarget&&(n._pos-=(n._pos-n._posTarget)/5,n._pos<=n._posTarget+.01&&(n._pos=n._posTarget)),n._pos=n._posTarget-.01&&(n._pos=n._posTarget)),n.__update(),n._pos==n._posTarget&&(t&&t(),e(),clearInterval(n._anim),n._anim=0)},5)}),this.$bar.dequeue()},pane:function(e,t){if(e>=0&&e<2){if(typeof t=="undefined")return this._pane[e];if(t)return this._pane[e]=t,t._parent=this,t.__container(this.$pane[e]),this._pane[0]&&this._pane[1]&&this.__update(),t;this._pane[e]&&(this._pane[e].__container(null),this._pane[e]=!1)}return!1},left:function(e){return this.pane(0,e)},right:function(e){return this.pane(1,e)},top:function(e){return this.pane(0,e)},bottom:function(e){return this.pane(1,e)},scrollable:function(e,t,n){return typeof t!="undefined"&&this.$pane[e].toggleClass("wcScrollableX",t),typeof n!="undefined"&&this.$pane[e].toggleClass("wcScrollableY",n),{x:this.$pane[e].hasClass("wcScrollableX"),y:this.$pane[e].hasClass("wcScrollableY")}},destroy:function(e){var t=this.docker();if(t){var n=this.docker()._splitterList.indexOf(this);n>-1&&this.docker()._splitterList.splice(n,1)}e===undefined||e?this.__destroy():this.__container(null)},__init:function(){this.$pane.push($('
')),this.$pane.push($('
')),this.$bar=$('
'),this._orientation?this.$bar.addClass("wcTall").addClass("wcSplitterBarV"):this.$bar.addClass("wcWide").addClass("wcSplitterBarH"),this.__container(this.$container);if(this._parent instanceof wcPanel){this._boundEvents.push({event:wcDocker.EVENT.UPDATED,handler:this.__update.bind(this)}),this._boundEvents.push({event:wcDocker.EVENT.CLOSED,handler:this.destroy.bind(this)});for(var e=0;e'),this.__container(this.$container);var e=this.docker();this._splitter=new wcSplitter(e.$container,this,this._orientation),this._drawer=new wcDrawer(e.$transition,this._splitter,this._position);switch(this._position){case wcDocker.DOCK.LEFT:this._splitter.pane(0,this._drawer),this._splitter.$pane[1].remove(),this._splitter.$pane[0].addClass("wcDrawer"),this._splitter.pos(0);break;case wcDocker.DOCK.RIGHT:case wcDocker.DOCK.BOTTOM:this._splitter.pane(1,this._drawer),this._splitter.$pane[0].remove(),this._splitter.$pane[1].addClass("wcDrawer"),this._splitter.pos(1)}this._parent.$bar.addClass("wcSplitterHidden")},__update:function(e){this._splitter.__update(),this.__adjustSize()},__adjustSize:function(){this._drawer._frame._panelList.length?this._size=this._drawer._frame.$tabBar.outerHeight():this._size=0},__rect:function(){return this._drawer.__rect()},__save:function(){var e={};return e.size=this._size,e.drawer=this._drawer.__save(),e},__restore:function(e,t){this._size=e.size,this._drawer.__restore(e.drawer,t),this.__adjustSize()},__container:function(e){return typeof e=="undefined"?this.$container:(this.$container=e,this.$container?this.$container.append(this.$frame):this.$frame.remove(),this.$container)},__destroy:function(){this._splitter&&(this._splitter.__destroy(),this._splitter=null,this._frame=null),this.__container(null),this._parent=null}},wcDrawer.prototype={docker:function(){var e=this._parent;while(e&&!(e instanceof wcDocker))e=e._parent;return e},collapse:function(e){if(this._expanded){var t=this._frame.panel();if(t){var n=this._parent.pos();this._position!==wcDocker.DOCK.LEFT&&(n=1-n);var r;this._position===wcDocker.DOCK.BOTTOM?(r=this.docker().$container.height(),t._size.y=n*r):(r=this.docker().$container.width(),t._size.x=n*r)}this._expanded=!1;if(e)switch(this._position){case wcDocker.DOCK.TOP:case wcDocker.DOCK.LEFT:this._parent.pos(0);break;case wcDocker.DOCK.RIGHT:case wcDocker.DOCK.BOTTOM:this._parent.pos(1)}else{this._sliding=!0;var i=this,s=function(){i._sliding=!1,i._parent.__update()};switch(this._position){case wcDocker.DOCK.TOP:case wcDocker.DOCK.LEFT:this._parent.animPos(0,s);break;case wcDocker.DOCK.RIGHT:case wcDocker.DOCK.BOTTOM:this._parent.animPos(1,s)}}}},expand:function(){if(!this._expanded){this._expanded=!0,this._sliding=!0;var e=this._frame.panel();if(e){var t,n;this._position===wcDocker.DOCK.BOTTOM?(t=e._size.y,n=this.docker().$container.height()):(t=e._size.x,n=this.docker().$container.width()),this._position!==wcDocker.DOCK.LEFT&&(t=n-t),t/=n;var r=this;this._parent.animPos(t,function(){r._sliding=!1,r._parent.__update()})}}},isExpanded:function(){return this._expanded},minSize:function(){return this._expanded?this._root&&typeof this._root.minSize=="function"?this._root.minSize():{x:100,y:100}:(this.__adjustCollapsedSize(),{x:this._closeSize,y:this._closeSize})},maxSize:function(){var e=this._orientation===wcDocker.ORIENTATION.HORIZONTAL?!0:!1;return this._expanded||this._sliding?this._root&&typeof this._root.maxSize=="function"?{x:e?this._root.maxSize().x:Infinity,y:e?Infinity:this._root.maxSize().y}:{x:Infinity,y:Infinity}:(this.__adjustCollapsedSize(),{x:e?this._closeSize:Infinity,y:e?Infinity:this._closeSize})},__init:function(){this.$frame=$('
'),this.__container(this.$container),this._frame=new wcFrame(this.$frame,this,!1),this._frame.tabOrientation(this._position)},__update:function(e){this.__adjustCollapsedSize(),this._frame.__update()},__adjustCollapsedSize:function(){this._frame._panelList.length?(this._closeSize=this._frame.$tabBar.outerHeight(),this._parent.$bar.removeClass("wcSplitterHidden")):(this._closeSize=0,this._parent.$bar.addClass("wcSplitterHidden"))},__rect:function(){var e=this.$frame.offset(),t=this.$frame.width(),n=this.$frame.height(),r=this._frame.panel();return r&&(this._position===wcDocker.DOCK.BOTTOM?(n=r._size.y,t/=3):(t=r._size.x,n/=3)),{x:e.left,y:e.top,w:t,h:n}},__save:function(){var e={};return e.closeSize=this._closeSize,e.frame=this._frame.__save(),e},__restore:function(e,t){this._closeSize=e.closeSize,this._frame.__restore(e.frame,t),this.__adjustCollapsedSize()},__container:function(e){return typeof e=="undefined"?this.$container:(this.$container=e,this.$container?this.$container.append(this.$frame):this.$frame.remove(),this.$container)},__destroy:function(){this._frame&&(this._frame.__destroy(),this._frame=null),this.__container(null),this._parent=null}},wcTabFrame.prototype={LEFT_TAB_BUFFER:15,docker:function(){var e=this._parent;while(e&&!(e instanceof wcDocker))e=e._parent;return e},destroy:function(){this.__destroy()},tabOrientation:function(e){return e!==undefined&&this._tabOrientation!==e&&this.docker()._canOrientTabs&&(this._tabOrientation=e,this.__updateTabs(),this.__updateTabs()),this._tabOrientation},addTab:function(e,t){var n=new wcLayout(".wcDockerTransition",this._parent);return n.name=e,n._scrollable={x:!0,y:!0},n._scroll={x:0,y:0},n._closeable=!1,n._overflowVisible=!1,typeof t=="undefined"?this._layoutList.push(n):this._layoutList.splice(t,0,n),this._curTab===-1&&this._layoutList.length&&(this._curTab=0),this.__updateTabs(),n},removeTab:function(e){if(e>-1&&e=e&&(this._curTab--,this._curTab<0&&(this._curTab=0)),this.__updateTabs(),this._parent.__trigger(wcDocker.EVENT.CUSTOM_TAB_CLOSED,{obj:this,name:t,index:e}),!0}return!1},tab:function(e,t){if(typeof e!="undefined"&&e>-1&&e .wcTabScroller > .wcPanelTab[id="'+this._curTab+'"]').removeClass("wcPanelTabActive"),this.$center.children('.wcPanelTabContent[id="'+this._curTab+'"]').addClass("wcPanelTabContentHidden"),this._curTab=e,this.$tabBar.find('> .wcTabScroller > .wcPanelTab[id="'+e+'"]').addClass("wcPanelTabActive"),this.$center.children('.wcPanelTabContent[id="'+e+'"]').removeClass("wcPanelTabContentHidden"),this.__updateTabs(t);var n=this._layoutList[this._curTab].name;this._parent.__trigger(wcDocker.EVENT.CUSTOM_TAB_CHANGED,{obj:this,name:n,index:e})}return this._curTab},layout:function(e){return e>-1&&e=0&&e=0&&t .wcTabScroller > .wcPanelTab[id="'+t+'"]')[0]}return!1},moveable:function(e){return typeof e!="undefined"&&(this._moveable=e),this._moveable},closeable:function(e,t){if(e>-1&&e-1&&e-1&&e-1&&e")),n.$icon.removeClass(),n.$icon.addClass("wcTabIcon "+t)}},faicon:function(e,t){if(e>-1&&e")),n.$icon.removeClass(),n.$icon.addClass("fa fa-fw fa-"+t)}},__init:function(){this.$frame=$('
'),this.$tabBar=$('
'),this.$tabScroll=$('
'),this.$center=$('
'),this.$tabLeft=$('
<
'),this.$tabRight=$('
>
'),this.$close=$('
X
'),this.$buttonBar=$('
'),this.$tabBar.append(this.$tabScroll),this.$tabBar.append(this.$buttonBar),this.$buttonBar.append(this.$close),this.$frame.append(this.$center),this.$frame.append(this.$tabBar),this.__container(this.$container),this._boundEvents.push({event:wcDocker.EVENT.UPDATED,handler:this.update.bind(this)}),this._boundEvents.push({event:wcDocker.EVENT.CLOSED,handler:this.destroy.bind(this)});for(var e=0;e
'+this._layoutList[o].name+"
");this._moveable&&u.addClass("wcCustomTabMoveable"),this.$tabScroll.append(u),this._layoutList[o].$icon&&u.find("div").prepend(this._layoutList[o].$icon);var a=this.$center.children('.wcPanelTabContent[id="'+o+'"]');a.length||(a=$('
'),this.$center.append(a)),this._layoutList[o].__container(a),this._layoutList[o]._parent=this;var f=this._curTab===o;a.removeClass("wcPanelTabUnused"),f&&(u.addClass("wcPanelTabActive"),a.removeClass("wcPanelTabContentHidden")),r=t(u)-i,n.push(r),r+=u.outerWidth()}var l=0,c=this.$tabBar.height();switch(this._tabOrientation){case wcDocker.TAB.TOP:this.$tabBar.addClass("wcTabTop").removeClass("wcTabLeft wcTabRight wcTabBottom"),this.$center.css("top",c).css("left",0).css("right",0).css("bottom",0),l=this.$center.width();break;case wcDocker.TAB.BOTTOM:this.$tabBar.addClass("wcTabBottom").removeClass("wcTabTop wcTabLeft wcTabRight"),this.$center.css("top",0).css("left",0).css("right",0).css("bottom",c),l=this.$center.width();break;case wcDocker.TAB.LEFT:this.$tabBar.addClass("wcTabLeft").removeClass("wcTabTop wcTabRight wcTabBottom"),this.$center.css("top",0).css("left",c).css("right",0).css("bottom",0),l=this.$center.height();break;case wcDocker.TAB.RIGHT:this.$tabBar.addClass("wcTabRight").removeClass("wcTabTop wcTabLeft wcTabBottom"),this.$center.css("top",0).css("left",0).css("right",c).css("bottom",0),l=this.$center.height()}this.$center.children(".wcPanelTabUnused").each(function(){$(this).remove()});var h=this.__onTabChange();if(e)for(var o=0;om&&(this._tabScrollPos=d-m+this.LEFT_TAB_BUFFER);break}this._canScrollTabs=!1;if(r>l-h){this._canScrollTabs=!0,this.$buttonBar.append(this.$tabRight),this.$buttonBar.append(this.$tabLeft),h+=this.$tabRight.outerWidth(),h+=this.$tabLeft.outerWidth();var g=r-(l-h)/2;if(this._tabScrollPos>g){var y=this.$tabScroll.children();for(var o=0;og){this._tabScrollPos=r-this.LEFT_TAB_BUFFER,this._tabScrollPos<0&&(this._tabScrollPos=0);break}}}}else this._tabScrollPos=0,this.$tabLeft.remove(),this.$tabRight.remove();this.$tabScroll.stop().animate({left:-this._tabScrollPos+"px"},"fast")},__onTabChange:function(){var e=0,t=this.layout(this._curTab);if(t){this.$center.toggleClass("wcScrollableX",t._scrollable.x),this.$center.toggleClass("wcScrollableY",t._scrollable.y),this.$center.toggleClass("wcOverflowVisible",t._overflowVisible),this.$tabLeft.remove(),this.$tabRight.remove(),t._closeable?(this.$close.show(),e+=this.$close.outerWidth()):this.$close.hide(),this._canScrollTabs&&(this.$tabBar.append(this.$tabRight),this.$tabBar.append(this.$tabLeft),e+=this.$tabRight.outerWidth()+this.$tabLeft.outerWidth());switch(this._tabOrientation){case wcDocker.TAB.RIGHT:case wcDocker.TAB.LEFT:this.$tabBar.css("width",this.$center.height());break;case wcDocker.TAB.TOP:case wcDocker.TAB.BOTTOM:this.$tabBar.css("width",this.$center.width());default:}this.$center.scrollLeft(t._scroll.x),this.$center.scrollTop(t._scroll.y)}return this.$buttonBar.css("min-width",e).css("width",e),e},__scrolled:function(){var e=this.layout(this._curTab);e._scroll.x=this.$center.scrollLeft(),e._scroll.y=this.$center.scrollTop()},__container:function(e){return typeof e=="undefined"?this.$container:(this.$container=e,this.$container?this.$container.append(this.$frame):this.$frame.remove(),this.$container)},__destroy:function(){var e=this.docker();if(e){var t=e._tabList.indexOf(this);t>-1&&e._tabList.splice(t,1)}while(this._boundEvents.length)this._parent.off(this._boundEvents[0].event,this._boundEvents[0].handler),this._boundEvents.shift();this._curTab=-1;for(var n=0;niFrames not supported on your device!"),this.$frame.prepend(this.$iFrame),this.__onMoved(),this._window=this.$iFrame[0].contentWindow||this.$iFrame[0],this.__updateFrame(),this._window.location.replace(e),this.$iFrame[0].focus(),this.$iFrame.hover(this.__onHoverEnter.bind(this),this.__onHoverExit.bind(this));var t=this;this.$iFrame.load(function(){for(var e=0;eiFrames not supported on your device!"),this.$frame.prepend(this.$iFrame),this.__onMoved(),this._window=this.$iFrame[0].contentWindow||this.$iFrame[0],this.__updateFrame(),this._window.document.open(),this._window.document.write(e),this._window.document.close(),this.$iFrame[0].focus(),this.$iFrame.hover(this.__onHoverEnter.bind(this),this.__onHoverExit.bind(this));var t=this;this.$iFrame.load(function(){for(var e=0;eiFrames not supported on your device!"),this.$frame.prepend(this.$iFrame),this.__onMoved(),this._window=this.$iFrame[0].contentWindow||this.$iFrame[0],this.__updateFrame(),this.$iFrame[0].srcdoc=e,this.$iFrame[0].focus(),this.$iFrame.hover(this.__onHoverEnter.bind(this),this.__onHoverExit.bind(this));var t=this;this.$iFrame.load(function(){for(var e=0;e'),this.$focus=$('
'),this._panel.docker().$container.append(this.$frame),this.$frame.append(this.$focus),this._boundEvents.push({event:wcDocker.EVENT.VISIBILITY_CHANGED,handler:this.__onVisibilityChanged.bind(this)}),this._boundEvents.push({event:wcDocker.EVENT.BEGIN_DOCK,handler:this.__onBeginDock.bind(this)}),this._boundEvents.push({event:wcDocker.EVENT.END_DOCK,handler:this.__onEndDock.bind(this)}),this._boundEvents.push({event:wcDocker.EVENT.MOVE_STARTED,handler:this.__onMoveStarted.bind(this)}),this._boundEvents.push({event:wcDocker.EVENT.RESIZE_STARTED,handler:this.__onMoveStarted.bind(this)}),this._boundEvents.push({event:wcDocker.EVENT.MOVE_ENDED,handler:this.__onMoveFinished.bind(this)}),this._boundEvents.push({event:wcDocker.EVENT.RESIZE_ENDED,handler:this.__onMoveFinished.bind(this)}),this._boundEvents.push({event:wcDocker.EVENT.MOVED,handler:this.__onMoved.bind(this)}),this._boundEvents.push({event:wcDocker.EVENT.RESIZED,handler:this.__onMoved.bind(this)}),this._boundEvents.push({event:wcDocker.EVENT.ATTACHED,handler:this.__updateFrame.bind(this)}),this._boundEvents.push({event:wcDocker.EVENT.DETACHED,handler:this.__updateFrame.bind(this)}),this._boundEvents.push({event:wcDocker.EVENT.GAIN_FOCUS,handler:this.__updateFrame.bind(this)}),this._boundEvents.push({event:wcDocker.EVENT.LOST_FOCUS,handler:this.__updateFrame.bind(this)}),this._boundEvents.push({event:wcDocker.EVENT.CLOSED,handler:this.__onClosed.bind(this)});for(var e=0;e