17 lines
		
	
	
		
			71 KiB
		
	
	
	
		
			JavaScript
		
	
	
		
			Executable File
		
	
			
		
		
	
	
			17 lines
		
	
	
		
			71 KiB
		
	
	
	
		
			JavaScript
		
	
	
		
			Executable File
		
	
/*!
 | 
						|
 * 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@gmail.com)
 | 
						|
 * 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.$container=$(e).addClass("wcDocker"),this.$transition=$('<div class="wcDockerTransition"></div>'),this.$container.append(this.$transition),this._events={},this._root=null,this._frameList=[],this._floatingList=[],this._modalList=[],this._focusFrame=null,this._splitterList=[],this._tabList=[],this._dockPanelTypeList=[],this._draggingSplitter=null,this._draggingFrame=null,this._draggingFrameSizer=null,this._draggingFrameTab=null,this._draggingCustomTabFrame=null,this._ghost=null,this._menuTimer=0,this._resizeData={time:-1,timeout:!1,delta:150},this._defaultOptions={allowContextMenu:!0},this._options={};for(var n in this._defaultOptions)this._options[n]=this._defaultOptions[n];for(var n in t)this._options[n]=t[n];this.__init()}function wcGhost(e,t,n){this.$ghost=null,this._rect,this._anchorMouse=!1,this._anchor=null,this._docker=n,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,t.icon&&this.icon(t.icon),t.faicon&&this.faicon(t.faicon),this._panelObject=null,this._initialized=!1,this._type=e,this._title=e,this._titleVisible=!0,t.title&&this.title(t.title),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._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.$tabScroll=null,this.$center=null,this.$tabLeft=null,this.$tabRight=null,this.$close=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.$shadower=null,this.$modalBlocker=null,this._canScrollTabs=!1,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._findBestPos=!1,this._boundEvents=[],this.__init(),this.docker()._splitterList.push(this)}function wcTabFrame(e,t){this.$container=$(e),this._parent=t,this.$frame=null,this.$title=null,this.$tabScroll=null,this.$center=null,this.$tabLeft=null,this.$tabRight=null,this.$close=null,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._window=null,this._isAttached=!0,this._hasFocus=!1,this._boundEvents=[],this.__init()}Function.prototype.bind||(Function.prototype.bind=function(e){if(typeof this!="function")throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var t=Array.prototype.slice.call(arguments,1),n=this,r=function(){},i=function(){return n.apply(this instanceof r&&e?this:e,t.concat(Array.prototype.slice.call(arguments)))};return r.prototype=this.prototype,i.prototype=new r,i}),Array.prototype.indexOf||(Array.prototype.indexOf=function(e){var t=this.length>>>0,n=Number(arguments[1])||0;n=n<0?Math.ceil(n):Math.floor(n),n<0&&(n+=t);for(;n<t;n++)if(n in this&&this[n]===e)return n;return-1}),wcDocker.DOCK_MODAL="modal",wcDocker.DOCK_FLOAT="float",wcDocker.DOCK_TOP="top",wcDocker.DOCK_LEFT="left",wcDocker.DOCK_RIGHT="right",wcDocker.DOCK_BOTTOM="bottom",wcDocker.DOCK_STACKED="stacked",wcDocker.EVENT_INIT="panelInit",wcDocker.EVENT_UPDATED="panelUpdated",wcDocker.EVENT_VISIBILITY_CHANGED="panelVisibilityChanged",wcDocker.EVENT_BEGIN_DOCK="panelBeginDock",wcDocker.EVENT_END_DOCK="panelEndDock",wcDocker.EVENT_GAIN_FOCUS="panelGainFocus",wcDocker.EVENT_LOST_FOCUS="panelLostFocus",wcDocker.EVENT_CLOSED="panelClosed",wcDocker.EVENT_BUTTON="panelButton",wcDocker.EVENT_ATTACHED="panelAttached",wcDocker.EVENT_DETACHED="panelDetached",wcDocker.EVENT_MOVE_STARTED="panelMoveStarted",wcDocker.EVENT_MOVE_ENDED="panelMoveEnded",wcDocker.EVENT_MOVED="panelMoved",wcDocker.EVENT_RESIZE_STARTED="panelResizeStarted",wcDocker.EVENT_RESIZE_ENDED="panelResizeEnded",wcDocker.EVENT_RESIZED="panelResized",wcDocker.EVENT_SCROLLED="panelScrolled",wcDocker.EVENT_SAVE_LAYOUT="layoutSave",wcDocker.EVENT_RESTORE_LAYOUT="layoutRestore",wcDocker.EVENT_CUSTOM_TAB_CHANGED="customTabChanged",wcDocker.EVENT_CUSTOM_TAB_CLOSED="customTabClosed",wcDocker.ORIENTATION_VERTICAL=!1,wcDocker.ORIENTATION_HORIZONTAL=!0,wcDocker.prototype={registerPanelType:function(e,t,n){var r=t;typeof r=="function"&&(r={onCreate:t}),typeof n!="undefined"&&(r.isPrivate=n),$.isEmptyObject(r)&&(r=null);for(var i=0;i<this._dockPanelTypeList.length;++i)if(this._dockPanelTypeList[i].name===e)return!1;this._dockPanelTypeList.push({name:e,options:r});var s=$("menu").find("menu");return s.append($('<menuitem label="'+e+'">')),!0},panelTypes:function(e){var t=[];for(var n=0;n<this._dockPanelTypeList.length;++n)(e||!this._dockPanelTypeList[n].options.isPrivate)&&t.push(this._dockPanelTypeList[n].name);return t},panelTypeInfo:function(e){for(var t=0;t<this._dockPanelTypeList.length;++t)if(this._dockPanelTypeList[t].name==e)return this._dockPanelTypeList[t].options;return!1},addPanel:function(e,t,n,r){for(var i=0;i<this._dockPanelTypeList.length;++i)if(this._dockPanelTypeList[i].name===e){var s=this._dockPanelTypeList[i],o=new wcPanel(e,s.options);o._parent=this,o.__container(this.$transition);var u=s.options&&s.options.options||{};return o._panelObject=new s.options.onCreate(o,u),t===wcDocker.DOCK_STACKED?this.__addPanelGrouped(o,t,n):this.__addPanelAlone(o,t,n,r),this.__update(),o}return!1},removePanel:function(e){if(!e)return!1;if(this.__isLastPanel(e))return!1;var t=e._parent;if(t instanceof wcFrame){e.__trigger(wcDocker.EVENT_CLOSED);if(!t.removePanel(e)){var n=this._floatingList.indexOf(t);n!==-1&&this._floatingList.splice(n,1),n=this._frameList.indexOf(t),n!==-1&&this._frameList.splice(n,1),n=this._modalList.indexOf(t),n!==-1&&this._modalList.splice(n,1),this._modalList.length?this.__focus(this._modalList[this._modalList.length-1]):this._floatingList.length&&this.__focus(this._floatingList[this._floatingList.length-1]);var r=t._parent;if(r instanceof wcSplitter){r.__removeChild(t);var i;r.pane(0)?(i=r.pane(0),r._pane[0]=null):(i=r.pane(1),r._pane[1]=null),i.__container(this.$transition),i._parent=null,n=this._splitterList.indexOf(r),n!==-1&&this._splitterList.splice(n,1);var s=r._parent;parentContainer=r.__container(),r.__destroy(),s instanceof wcSplitter?(s.__removeChild(r),s.pane(0)?s.pane(1,i):s.pane(0,i)):s===this&&(this._root=i,i._parent=this,i.__container(parentContainer)),this.__update()}else t===this._root&&(this._root=null);this._focusFrame===t&&(this._focusFrame=null),t.__destroy()}return e.__destroy(),!0}return!1},movePanel:function(e,t,n,r){if(this.__isLastPanel(e))return e;var i=e.$container;e._parent instanceof wcFrame&&(i=e._parent.$frame);var s=i.offset(),o=i.width(),u=i.height(),a=e._parent,f=!1;a instanceof wcFrame&&(f=a._isFloating);if(a instanceof wcFrame){for(var l=0;l<a._panelList.length;++l)if(a._panelList[l]===e){a._curTab>=l&&a._curTab--,e.__container(this.$transition),e._parent=null,a._panelList.splice(l,1);break}a._curTab===-1&&a._panelList.length&&(a._curTab=0),a.__updateTabs();if(a._panelList.length===0){var c=this._floatingList.indexOf(a);c!==-1&&this._floatingList.splice(c,1),c=this._frameList.indexOf(a),c!==-1&&this._frameList.splice(c,1);var h=a._parent;if(h instanceof wcSplitter){h.__removeChild(a);var p;h.pane(0)?(p=h.pane(0),h._pane[0]=null):(p=h.pane(1),h._pane[1]=null),p.__container(this.$transition),p._parent=null,c=this._splitterList.indexOf(h),c!==-1&&this._splitterList.splice(c,1);var d=h._parent;parentContainer=h.__container(),h.__destroy(),d instanceof wcSplitter?(d.__removeChild(h),d.pane(0)?d.pane(1,p):d.pane(0,p)):d===this&&(this._root=p,p._parent=this,p.__container(parentContainer)),this.__update()}this._focusFrame===a&&(this._focusFrame=null),a.__destroy()}}e.initSize(o,u),t===wcDocker.DOCK_STACKED?this.__addPanelGrouped(e,t,n):this.__addPanelAlone(e,t,n,r);var v=e._parent;return v instanceof wcFrame&&v._panelList.length===1&&v.pos(s.left+o/2+20,s.top+u/2+20,!0),this.__update(),v instanceof wcFrame&&f!==v._isFloating&&(v._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._frameList.length;++n){var r=this._frameList[n];for(var i=0;i<r._panelList.length;++i){var s=r._panelList[i];(!e||s._type===e)&&t.push(s)}}return t},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._events[e].length;++n)if(this._events[e][n]===t){this._events[e].splice(n,1);break}},trigger:function(e,t){if(!e)return!1;for(var n=0;n<this._frameList.length;++n){var r=this._frameList[n];for(var i=0;i<r._panelList.length;++i){var s=r._panelList[i];s.__trigger(e,t)}}this.__trigger(e,t)},basicMenu:function(e,t,n){var r=this;$.contextMenu({selector:e,build:function(e,i){var s;for(var o=0;o<r._frameList.length;++o){var u=e.hasClass("wcFrame")&&e||e.parents(".wcFrame");if(r._frameList[o].$frame[0]===u[0]){s=r._frameList[o];break}}var a={x:i.clientX,y:i.clientY},f=!1;a.y-s.$frame.offset().top<=20&&(f=!0);var l={};for(var o=0;o<r._dockPanelTypeList.length;++o){var c=r._dockPanelTypeList[o];if(!c.options.isPrivate){if(c.options.limit>0&&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 o=0;o<g.length;++o){if($.isEmptyObject(g[o])){m["sep"+v++]="---------";continue}var y=g[o].callback;y&&function(e,t){e.callback=function(e,n){var i=null,s=n.$trigger.parents(".wcFrame").first();if(s.length)for(var o=0;o<r._frameList.length;++o)s[0]===r._frameList[o].$frame[0]&&(i=r._frameList[o].panel());t(e,n,i)}}(g[o],y),m[g[o].name]=g[o]}var b=m;if(n){$.isEmptyObject(m)||(b["sep"+v++]="---------"),f?(b["Close Panel"]={name:"Close Tab",faicon:"close",disabled:!s.panel().closeable()||r.__isLastPanel(s.panel())},s._isFloating||(b["Detach Panel"]={name:"Detach Tab",faicon:"level-down",disabled:!s.panel().moveable()||r.__isLastPanel(s.panel())}),b["sep"+v++]="---------",b.fold1={name:"Add Tab",faicon:"columns",items:l,disabled:!s.panel()._titleVisible||!!s._isFloating&&r._modalList.indexOf(s)!==-1,className:"wcMenuCreatePanel"},b["sep"+v++]="---------",b["Flash Panel"]={name:"Flash Panel",faicon:"lightbulb-o"}):(b["Close Panel"]={name:"Close Panel",faicon:"close",disabled:!s.panel().closeable()||r.__isLastPanel(s.panel())},s._isFloating||(b["Detach Panel"]={name:"Detach Panel",faicon:"level-down",disabled:!s.panel().moveable()||r.__isLastPanel(s.panel())}),b["sep"+v++]="---------",b.fold1={name:"Insert Panel",faicon:"columns",items:l,disabled:!!s._isFloating||!s.panel().moveable(),className:"wcMenuCreatePanel"},b["sep"+v++]="---------",b["Flash Panel"]={name:"Flash Panel",faicon:"lightbulb-o"});if(!s._isFloating&&s.panel().moveable()){var w=s.__rect();r._ghost=new wcGhost(w,a,r),s.__checkAnchorDrop(a,!1,r._ghost,!0),r._ghost.$ghost.hide()}}return{callback:function(e,t){if(e==="Close Panel")setTimeout(function(){s.panel().close()},10);else if(e==="Detach Panel")r.movePanel(s.panel(),wcDocker.DOCK_FLOAT,!1);else if(e==="Flash Panel")r.__focus(s,!0);else if(s&&r._ghost){var n=r._ghost.anchor(),i=r.addPanel(e,n.loc,s.panel(),r._ghost.rect());i.focus()}},events:{show:function(e){(function(t){var n={},r=e.$menu.find(".context-menu-item");for(var i=0;i<r.length;++i){var s=$(r[i]),o=s.find("span");o.length&&(n[o[0].innerHTML]=s)}(function u(e){for(var t in e){var r=e[t],i=n[r.name];if(i){var s=$('<div class="wcMenuIcon">');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=$('<div class="wcMenuSubMenu fa fa-caret-right fa-lg">');i.append(o)}}r.items&&u(r.items)}})(t)})(b)},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:b}}})},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<this._floatingList.length;++t)e.floating.push(this._floatingList[t].__save());return e.root=this._root.__save(),JSON.stringify(e,function(e,t){return t==Infinity?"Infinity":t})},restore:function(e){var t=JSON.parse(e,function(e,t){return t==="Infinity"?Infinity:t});this.clear(),this._root=this.__create(t.root,this,this.$container),this._root.__restore(t.root,this);for(var n=0;n<t.floating.length;++n){var r=this.__create(t.floating[n],this,this.$container);r.__restore(t.floating[n],this)}this.__update()},clear:function(){this._root=null;for(var e=0;e<this._splitterList.length;++e)this._splitterList[e].__destroy();for(var e=0;e<this._frameList.length;++e)this._frameList[e].__destroy();while(this._frameList.length)this._frameList.pop();while(this._floatingList.length)this._floatingList.pop();while(this._splitterList.length)this._splitterList.pop()},__init:function(){this._root=null;var e=this;$(window).resize(e.__resize.bind(e)),this._options.allowContextMenu&&this.basicMenu(".wcFrame",[],!0);var t;$("body").on("contextmenu","a, img",function(){return t&&clearTimeout(t),$(".wcFrame").contextMenu(!1),t=setTimeout(function(){$(".wcFrame").contextMenu(!0),t=null},100),!0}),$("body").on("contextmenu",".wcSplitterBar",function(){return!1}),$("body").on("mouseenter",".wcMenuCreatePanel",function(){e._ghost&&e._ghost.$ghost.stop().fadeIn(200)}),$("body").on("mouseleave",".wcMenuCreatePanel",function(){e._ghost&&e._ghost.$ghost.stop().fadeOut(200)}),$("body").on("mousedown",".wcModalBlocker",function(t){e._modalList.length&&e._modalList[e._modalList.length-1].__focus(!0)}),$("body").on("mousedown",".wcPanelTab",function(e){e.preventDefault(),e.returnValue=!1}),$("body").on("selectstart",".wcFrameTitle, .wcPanelTab, .wcFrameButton",function(e){e.preventDefault()}),$("body").on("mousedown",".wcFrame > .wcFrameButton",function(){e.$container.addClass("wcDisableSelection")}),$("body").on("click",".wcFrame > .wcFrameButton",function(){e.$container.removeClass("wcDisableSelection");for(var t=0;t<e._frameList.length;++t){var n=e._frameList[t];if(n.$close[0]===this){var r=n.panel();e.removePanel(r),e.__update();return}if(n.$tabLeft[0]===this){n._tabScrollPos-=n.$title.width()/2,n._tabScrollPos<0&&(n._tabScrollPos=0),n.__updateTabs();return}if(n.$tabRight[0]===this){n._tabScrollPos+=n.$title.width()/2,n.__updateTabs();return}for(var i=0;i<n._buttonList.length;++i)if(n._buttonList[i][0]===this){var s=n._buttonList[i],o={name:s.data("name"),isToggled:!1};s.hasClass("wcFrameButtonToggler")&&(s.toggleClass("wcFrameButtonToggled"),s.hasClass("wcFrameButtonToggled")&&(o.isToggled=!0));var r=n.panel();r.buttonState(o.name,o.isToggled),r.__trigger(wcDocker.EVENT_BUTTON,o);return}}}),$("body").on("click",".wcCustomTab > .wcFrameButton",function(){e.$container.removeClass("wcDisableSelection");for(var t=0;t<e._tabList.length;++t){var n=e._tabList[t];if(n.$close[0]===this){var r=n.tab();n.removeTab(r);return}if(n.$tabLeft[0]===this){n._tabScrollPos-=n.$title.width()/2,n._tabScrollPos<0&&(n._tabScrollPos=0),n.__updateTabs();return}if(n.$tabRight[0]===this){n._tabScrollPos+=n.$title.width()/2,n.__updateTabs();return}}}),$("body").on("mouseup",".wcPanelTab",function(t){if(t.which!==2)return;var n=parseInt($(this).attr("id"));for(var r=0;r<e._frameList.length;++r){var i=e._frameList[r];if(i.$title[0]===$(this).parents(".wcFrameTitle")[0]){var s=i._panelList[n];e._removingPanel===s&&(e.removePanel(s),e.__update());return}}}),$("body").on("mousedown",".wcSplitterBar",function(t){if(t.which!==1)return!0;e.$container.addClass("wcDisableSelection");for(var n=0;n<e._splitterList.length;++n)if(e._splitterList[n].$bar[0]===this){e._draggingSplitter=e._splitterList[n],e._draggingSplitter.$pane[0].addClass("wcResizing"),e._draggingSplitter.$pane[1].addClass("wcResizing");break}return!0}),$("body").on("mousedown",".wcFrameTitle",function(t){if(t.which===3)return!0;if($(t.target).hasClass("wcFrameButton"))return!1;e.$container.addClass("wcDisableSelection");for(var n=0;n<e._frameList.length;++n)if(e._frameList[n].$title[0]==this){e._draggingFrame=e._frameList[n];var r={x:t.clientX,y:t.clientY};e._draggingFrame.__anchorMove(r);var i=$(t.target).hasClass("wcPanelTab")?$(t.target):$(t.target).parent(".wcPanelTab");if(i&&i.length){var s=parseInt(i.attr("id"));e._draggingFrame.panel(s,!0),e._draggingFrameTab=i[0]}if(!e._draggingFrame.$title.hasClass("wcNotMoveable")&&!i.hasClass("wcNotMoveable")&&(!e._draggingFrame._isFloating||t.which!==1||e._draggingFrameTab)){var o=e._draggingFrame.__rect();e._ghost=new wcGhost(o,r,e),e._draggingFrame.__checkAnchorDrop(r,!0,e._ghost,!0),e.trigger(wcDocker.EVENT_BEGIN_DOCK)}break}for(var n=0;n<e._tabList.length;++n)if(e._tabList[n].$title[0]==this){e._draggingCustomTabFrame=e._tabList[n];var i=$(t.target).hasClass("wcPanelTab")?$(t.target):$(t.target).parent(".wcPanelTab");if(i&&i.length){var s=parseInt(i.attr("id"));e._draggingCustomTabFrame.tab(s,!0),e._draggingFrameTab=i[0]}break}return e._draggingFrame&&e.__focus(e._draggingFrame),!0}),$("body").on("mousedown",".wcLayout",function(t){if(t.which===3)return!0;for(var n=0;n<e._frameList.length;++n)if(e._frameList[n].panel().layout().scene()[0]==this){setTimeout(function(){e.__focus(e._frameList[n])},10);break}return!0}),$("body").on("mousedown",".wcFrameEdge",function(t){if(t.which===3)return!0;e.$container.addClass("wcDisableSelection");for(var n=0;n<e._frameList.length;++n)if(e._frameList[n]._isFloating){if(e._frameList[n].$top[0]==this){e._draggingFrame=e._frameList[n],e._draggingFrameSizer=["top"];break}if(e._frameList[n].$bottom[0]==this){e._draggingFrame=e._frameList[n],e._draggingFrameSizer=["bottom"];break}if(e._frameList[n].$left[0]==this){e._draggingFrame=e._frameList[n],e._draggingFrameSizer=["left"];break}if(e._frameList[n].$right[0]==this){e._draggingFrame=e._frameList[n],e._draggingFrameSizer=["right"];break}if(e._frameList[n].$corner1[0]==this){e._draggingFrame=e._frameList[n],e._draggingFrameSizer=["top","left"];break}if(e._frameList[n].$corner2[0]==this){e._draggingFrame=e._frameList[n],e._draggingFrameSizer=["top","right"];break}if(e._frameList[n].$corner3[0]==this){e._draggingFrame=e._frameList[n],e._draggingFrameSizer=["bottom","right"];break}if(e._frameList[n].$corner4[0]==this){e._draggingFrame=e._frameList[n],e._draggingFrameSizer=["bottom","left"];break}}return e._draggingFrame&&e.__focus(e._draggingFrame),!0}),$("body").on("mousemove",function(t){if(t.which===3)return!0;if(e._draggingSplitter){var n={x:t.clientX,y:t.clientY};e._draggingSplitter.__moveBar(n),e._draggingSplitter.__update()}else if(e._draggingFrameSizer){var n={x:t.clientX,y:t.clientY},r=e.$container.offset();n.x+=r.left,n.y+=r.top,e._draggingFrame.__resize(e._draggingFrameSizer,n),e._draggingFrame.__update()}else if(e._draggingFrame){var n={x:t.clientX,y:t.clientY};if(e._ghost){e._ghost.__move(n);var i=!e._draggingFrame._isFloating&&t.which!==1,s=!1;if(!e._draggingFrame.__checkAnchorDrop(n,!0,e._ghost,e._draggingFrame._panelList.length>1&&e._draggingFrameTab)){e._draggingFrame.__shadow(!0);if(!i)for(var o=0;o<e._frameList.length;++o)if(e._frameList[o]!==e._draggingFrame&&e._frameList[o].__checkAnchorDrop(n,!1,e._ghost,!0))return;e._ghost.anchor(n,null)}else{e._draggingFrame.__shadow(!1);var u=$(t.target).hasClass("wcPanelTab")?$(t.target):$(t.target).parent(".wcPanelTab");e._draggingFrameTab&&u&&u.length&&e._draggingFrameTab!==t.target&&(e._draggingFrameTab=e._draggingFrame.__tabMove(parseInt($(e._draggingFrameTab).attr("id")),parseInt(u.attr("id"))))}}else e._draggingFrameTab||(e._draggingFrame.__move(n),e._draggingFrame.__update())}else if(e._draggingCustomTabFrame){var u=$(t.target).hasClass("wcPanelTab")?$(t.target):$(t.target).parent(".wcPanelTab");e._draggingFrameTab&&u&&u.length&&e._draggingFrameTab!==t.target&&(e._draggingFrameTab=e._draggingCustomTabFrame.moveTab(parseInt($(e._draggingFrameTab).attr("id")),parseInt(u.attr("id"))))}return!0}),$("body").on("mouseup",function(t){if(t.which===3)return!0;e.$container.removeClass("wcDisableSelection");if(e._draggingFrame)for(var n=0;n<e._frameList.length;++n)e._frameList[n].__shadow(!1);if(e._ghost&&e._draggingFrame){var r=e._ghost.anchor();if(!r){var i=e._draggingFrame._curTab;e._draggingFrameTab||e._draggingFrame.panel(0);var s={x:t.clientX,y:t.clientY};if(e._draggingFrameTab||!e.__isLastFrame(e._draggingFrame)){var o=e.movePanel(e._draggingFrame.panel(),wcDocker.DOCK_FLOAT);if(!e._draggingFrameTab)while(e._draggingFrame.panel())e.movePanel(e._draggingFrame.panel(),wcDocker.DOCK_STACKED,o);var u=o._parent;u instanceof wcFrame&&(u.pos(s.x,s.y+e._ghost.__rect().h/2-10,!0),u.panel(i),u._size.x=e._ghost.__rect().w,u._size.y=e._ghost.__rect().h),u.__update()}}else if(!r.self){var i=e._draggingFrame._curTab;e._draggingFrameTab||e._draggingFrame.panel(0);var o;r.item&&(o=r.item._parent);if(o===e._draggingFrame.panel())for(var n=0;n<e._draggingFrame._panelList.length;++n)if(o!==e._draggingFrame._panelList[n]){o=e._draggingFrame._panelList[n],i--;break}o=e.movePanel(e._draggingFrame.panel(),r.loc,o,e._ghost.rect()),o._parent.panel(o._parent._panelList.length-1,!0);if(!e._draggingFrameTab)while(e._draggingFrame.panel())e.movePanel(e._draggingFrame.panel(),wcDocker.DOCK_STACKED,o,e._ghost.rect());else{var u=o._parent;u instanceof wcFrame&&(i+=u._panelList.length)}var u=o._parent;u instanceof wcFrame&&u.panel(i)}e._ghost.destroy(),e._ghost=null,e.trigger(wcDocker.EVENT_END_DOCK)}return e._draggingSplitter&&(e._draggingSplitter.$pane[0].removeClass("wcResizing"),e._draggingSplitter.$pane[1].removeClass("wcResizing")),e._draggingSplitter=null,e._draggingFrame=null,e._draggingFrameSizer=null,e._draggingFrameTab=null,e._draggingCustomTabFrame=null,e._removingPanel=null,!0}),$("body").on("mousedown",".wcPanelTab",function(t){if(t.which!==2)return;var n=parseInt($(this).attr("id"));for(var r=0;r<e._frameList.length;++r){var i=e._frameList[r];if(i.$title[0]===$(this).parents(".wcFrameTitle")[0]){var s=i._panelList[n];e._removingPanel=s;return}}})},__update:function(){this._root&&this._root.__update();for(var e=0;e<this._floatingList.length;++e)this._floatingList[e].__update()},__resize:function(e){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)),this.__trigger(wcDocker.EVENT_RESIZED),this.__update()},__resizeEnd:function(){new Date-this._resizeData.time<this._resizeData.delta?setTimeout(this.__resizeEnd.bind(this),this._resizeData.delta):(this._resizeData.timeout=!1,this.__trigger(wcDocker.EVENT_RESIZE_ENDED))},__focus:function(e,t){var n=this._focusFrame!=e;this._focusFrame&&(this._focusFrame._isFloating&&this._focusFrame.$frame.removeClass("wcFloatingFocus"),this._focusFrame.__trigger(wcDocker.EVENT_LOST_FOCUS),this._focusFrame=null),this._focusFrame=e,this._focusFrame&&(this._focusFrame._isFloating&&(this._focusFrame.$frame.addClass("wcFloatingFocus"),n&&$("body").append(this._focusFrame.$frame)),this._focusFrame.__focus(t),this._focusFrame.__trigger(wcDocker.EVENT_GAIN_FOCUS))},__trigger:function(e,t){if(!e)return;if(this._events[e])for(var n=0;n<this._events[e].length;++n)this._events[e][n].call(this,t)},__isLastPanel:function(e){for(var t=0;t<this._frameList.length;++t){var n=this._frameList[t];if(n._isFloating)continue;for(var r=0;r<n._panelList.length;++r){var i=n._panelList[r];if(i!==e&&i.moveable())return!1}}return!0},__isLastFrame:function(e){for(var t=0;t<this._frameList.length;++t){var n=this._frameList[t];if(n._isFloating||n===e)continue;for(var r=0;r<n._panelList.length;++r){var i=n._panelList[r];if(i.moveable())return!1}}return!0},__create:function(e,t,n){switch(e.type){case"wcSplitter":var r=new wcSplitter(n,t,e.horizontal);return r.scrollable(0,!1,!1),r.scrollable(1,!1,!1),r;case"wcFrame":var i=new wcFrame(n,t,e.floating);return this._frameList.push(i),e.floating&&this._floatingList.push(i),i;case"wcPanel":for(var s=0;s<this._dockPanelTypeList.length;++s)if(this._dockPanelTypeList[s].name===e.panelType){var o=new wcPanel(e.panelType,this._dockPanelTypeList[s].options);o._parent=t,o.__container(this.$transition);var u=this._dockPanelTypeList[s].options&&this._dockPanelTypeList[s].options.options||{};o._panelObject=new this._dockPanelTypeList[s].options.onCreate(o,u),o.__container(n);break}return o}return null},__addPanelAlone:function(e,t,n,r){if(t===wcDocker.DOCK_FLOAT||t===wcDocker.DOCK_MODAL){var i=new wcFrame(this.$container,this,!0);this._frameList.push(i),this._floatingList.push(i),this.__focus(i),i.addPanel(e),i.pos(e._pos.x,e._pos.y,!1),t===wcDocker.DOCK_MODAL&&(i.$modalBlocker=$('<div class="wcModalBlocker"></div>'),i.$frame.prepend(i.$modalBlocker),e.moveable(!1),i.$frame.addClass("wcModal"),this._modalList.push(i)),r&&(r.hasOwnProperty("x")&&r.hasOwnProperty("y")&&i.pos(r.x+r.w/2,r.y+r.h/2,!0),i._size={x:r.w,y:r.h});return}if(n){var s=n._parent;if(s instanceof wcFrame){var o=s._parent;if(o instanceof wcSplitter){var u,a=o.pane(0),f=o.pane(1),l={x:-1,y:-1};a===s?(u=new wcSplitter(this.$transition,o,t!==wcDocker.DOCK_BOTTOM&&t!==wcDocker.DOCK_TOP),o.pane(0,u),l.x=o.$pane[0].width(),l.y=o.$pane[0].height()):(u=new wcSplitter(this.$transition,o,t!==wcDocker.DOCK_BOTTOM&&t!==wcDocker.DOCK_TOP),o.pane(1,u),l.x=o.$pane[1].width(),l.y=o.$pane[1].height()),u&&(u.scrollable(0,!1,!1),u.scrollable(1,!1,!1),i=new wcFrame(this.$transition,u,!1),this._frameList.push(i),t===wcDocker.DOCK_LEFT||t===wcDocker.DOCK_TOP?(u.pane(0,i),u.pane(1,s)):(u.pane(0,s),u.pane(1,i)),r||(r={w:e._size.x,h:e._size.y}),r?(r.w<0&&(r.w=l.x/2),r.h<0&&(r.h=l.y/2),t===wcDocker.DOCK_LEFT?u.pos(r.w/l.x):t===wcDocker.DOCK_RIGHT?u.pos(1-r.w/l.x):t===wcDocker.DOCK_TOP?u.pos(r.h/l.y):u.pos(1-r.h/l.y)):u.pos(.5),i.addPanel(e));return}}}var i=new wcFrame(this.$transition,this,!1);this._frameList.push(i);if(!this._root)this._root=i,i.__container(this.$container);else{var u=new wcSplitter(this.$container,this,t!==wcDocker.DOCK_BOTTOM&&t!==wcDocker.DOCK_TOP);if(u){i._parent=u,u.scrollable(0,!1,!1),u.scrollable(1,!1,!1);var l={x:this.$container.width(),y:this.$container.height()};t===wcDocker.DOCK_LEFT||t===wcDocker.DOCK_TOP?(u.pane(0,i),u.pane(1,this._root)):(u.pane(0,this._root),u.pane(1,i)),r?(r.w<0&&(r.w=l.x/2),r.h<0&&(r.h=l.y/2),t===wcDocker.DOCK_LEFT?u.pos(r.w/l.x):t===wcDocker.DOCK_RIGHT?u.pos(1-r.w/l.x):t===wcDocker.DOCK_TOP?u.pos(r.h/l.y):u.pos(1-r.h/l.y)):u.__findBestPos(),this._root=u}}i.addPanel(e)},__addPanelGrouped:function(e,t,n){function s(n){if(n instanceof wcSplitter){var r=n.pane(0),o=n.pane(1);if(n.orientation()===i){if(r instanceof wcFrame&&(t===wcDocker.DOCK_LEFT||t===wcDocker.DOCK_TOP))return r.addPanel(e),!0;if(o instanceof wcFrame&&(t===wcDocker.DOCK_RIGHT||t===wcDocker.DOCK_BOTTOM))return o.addPanel(e),!0}return r instanceof wcFrame?s.call(this,o):s.call(this,r)}return!1}if(n){var r=n._parent;if(r instanceof wcFrame){r.addPanel(e);return}}if(t===wcDocker.DOCK_FLOAT){var r;this._floatingList.length&&(r=this._floatingList[this._floatingList.length-1]);if(!r){this.__addPanelAlone(e,t);return}r.addPanel(e);return}var i=t!==wcDocker.DOCK_BOTTOM;s.call(this,this._root)||this.__addPanelAlone(e,t)}},wcGhost.prototype={update:function(e){this.__move(e);for(var t=0;t<this._docker._floatingList.length;++t){var n=this._docker._floatingList[t].__rect();if(e.x>n.x&&e.y>n.y&&e.x<n.x+n.w&&e.y<n.y+n.h){this._docker._floatingList[t].__checkAnchorDrop(e,!1,this,!0)?this._anchor.panel=this._docker._floatingList[t].panel():this.anchor(e,null);return}}for(var t=0;t<this._docker._frameList.length;++t){var n=this._docker._frameList[t].__rect();if(e.x>n.x&&e.y>n.y&&e.x<n.x+n.w&&e.y<n.y+n.h){this._docker._frameList[t].__checkAnchorDrop(e,!1,this,!0)?this._anchor.panel=this._docker._frameList[t].panel():this.anchor(e,null);return}}},anchor:function(e,t){if(typeof e=="undefined")return this._anchor;if(t&&this._anchor&&t.loc===this._anchor.loc&&t.item===this._anchor.item)return;var n={x:parseInt(this.$ghost.css("left")),y:parseInt(this.$ghost.css("top")),w:parseInt(this.$ghost.css("width")),h:parseInt(this.$ghost.css("height"))};this._anchorMouse={x:n.x-e.x,y:n.y-e.y},this._rect.x=-this._anchorMouse.x,this._rect.y=-this._anchorMouse.y;if(!t){if(!this._anchor)return;this._anchor=null,this.$ghost.show(),this.$ghost.stop().animate({opacity:.3,"margin-left":this._rect.x-this._rect.w/2+"px","margin-top":this._rect.y-10+"px",width:this._rect.w+"px",height:this._rect.h+"px"},150);return}this._anchor=t;var r=.8;t.self&&t.loc===wcDocker.DOCK_STACKED?(r=0,this.$ghost.hide()):this.$ghost.show(),this.$ghost.stop().animate({opacity:r,"margin-left":"2px","margin-top":"2px",border:"0px",left:t.x+"px",top:t.y+"px",width:t.w+"px",height:t.h+"px"},150)},rect:function(){return{x:this.$ghost.offset().left,y:this.$ghost.offset().top,w:parseInt(this.$ghost.css("width")),h:parseInt(this.$ghost.css("height"))}},destroy:function(){this.__destroy()},__init:function(e,t){this.$ghost=$('<div class="wcGhost">').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._grid[n][t].$el},item:function(e,t){return t>=this._grid.length?null:e>=this._grid[t].length?null:this._grid[t][e].$el},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 this.$table},__init:function(){this.$table=$('<table class="wcLayout wcWide wcTall"></table>'),this.$table.append($("<tbody></tbody>")),this.__container(this.$container)},__update:function(){},__resizeGrid:function(e,t){for(var n=0;n<=t;++n){this._grid.length<=n&&this._grid.push([]);for(var r=0;r<=e;++r)this._grid[n].length<=r&&this._grid[n].push({$el:$("<td>"),x:0,y:0})}if(!this._batchProcess){var i=this.$table.find("tbody");$(".wcDockerTransition").append(i);var s=$("<tbody>");for(var n=0;n<this._grid.length;++n){var o=null;for(var r=0;r<this._grid[n].length;++r){var u=this._grid[n][r];u.$el&&(o||(o=$("<tr>"),s.append(o)),o.append(u.$el))}}this.$table.append(s),i.remove()}},__mergeGrid:function(e,t,n,r){for(var i=0;i<r;++i)for(var s=0;s<n;++s){var o=this._grid[t+i][e+s];if(!o.$el||o.x!==0||o.y!==0)return!1}var o=this._grid[t][e];n>1&&(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<r;++i)for(var s=0;s<n;++s)if(i!==0||s!==0){var o=this._grid[t+i][e+s];o.$el.remove(),o.$el=null,o.x=-s,o.y=-i}return!0},__checkAnchorDrop:function(e,t,n,r,i,s){var o=i.width(),u=i.height(),a=i.offset(),f=i.find(".wcFrameTitle").height();s||(f=0);if(t&&e.y>=a.top&&e.y<=a.top+f&&e.x>=a.left&&e.x<=a.left+o)return n.anchor(e,{x:a.left,y:a.top,w:o,h:f-2,loc:wcDocker.DOCK_STACKED,item:this,self:!0}),!0;if(s&&e.y>=a.top&&e.y<=a.top+f&&e.x>=a.left&&e.x<=a.left+o)return n.anchor(e,{x:a.left,y:a.top,w:o,h:f-2,loc:wcDocker.DOCK_STACKED,item:this,self:!1}),!0;if(!r)return!1;if(o<u){if(e.y>=a.top&&e.y<=a.top+u*.25&&e.x>=a.left&&e.x<=a.left+o)return n.anchor(e,{x:a.left,y:a.top,w:o,h:u*.5,loc:wcDocker.DOCK_TOP,item:this,self:!1}),!0;if(e.y>=a.top+u*.75&&e.y<=a.top+u&&e.x>=a.left&&e.x<=a.left+o)return n.anchor(e,{x:a.left,y:a.top+(u-u*.5),w:o,h:u*.5,loc:wcDocker.DOCK_BOTTOM,item:this,self:!1}),!0}if(e.y>=a.top&&e.y<=a.top+u){if(e.x>=a.left&&e.x<=a.left+o*.25)return n.anchor(e,{x:a.left,y:a.top,w:o*.5,h:u,loc:wcDocker.DOCK_LEFT,item:this,self:!1}),!0;if(e.x>=a.left+o*.75&&e.x<=a.left+o)return n.anchor(e,{x:a.left+o*.5,y:a.top,w:o*.5,h:u,loc:wcDocker.DOCK_RIGHT,item:this,self:!1}),!0}if(o>=u){if(e.y>=a.top&&e.y<=a.top+u*.25&&e.x>=a.left&&e.x<=a.left+o)return n.anchor(e,{x:a.left,y:a.top,w:o,h:u*.5,loc:wcDocker.DOCK_TOP,item:this,self:!1}),!0;if(e.y>=a.top+u*.75&&e.y<=a.top+u&&e.x>=a.left&&e.x<=a.left+o)return n.anchor(e,{x:a.left,y:a.top+(u-u*.5),w:o,h:u*.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._title=e,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._parent._panelList.length;++n)if(this._parent._panelList[n]===this){this._parent.panel(n);break}}},isVisible:function(){return this._isVisible},addButton:function(e,t,n,r,i,s){return this._buttonList.push({name:e,className:t,toggleClassName:s,text:n,tip:r,isTogglable:i,isToggled:!1}),this._parent instanceof wcFrame&&this._parent.__update(),this._buttonList.length-1},removeButton:function(e){for(var t=0;t<this._buttonList.length;++t)if(this._buttonList[t].name===e)return this._buttonList.splice(t,1),this._parent instanceof wcFrame&&this._parent.__onTabChange(),this._parent instanceof wcFrame&&this._parent.__update(),!0;return!1},buttonState:function(e,t){for(var n=0;n<this._buttonList.length;++n)if(this._buttonList[n].name===e)return typeof t!="undefined"&&(this._buttonList[n].isToggled=t,this._parent instanceof wcFrame&&this._parent.__onTabChange()),this._parent instanceof wcFrame&&this._parent.__update(),this._buttonList[n].isToggled;return!1},initPos:function(e,t){if(typeof e!="undefined"){var n=this.docker();n?(this._pos.x=this.__stringToPercent(e,n.$container.width()),this._pos.y=this.__stringToPercent(t,n.$container.height())):(this._pos.x=e,this._pos.y=t)}return{x:this._pos.x,y:this._pos.y}},initSize:function(e,t){if(typeof e!="undefined"){var n=this.docker();n?(this._size.x=this.__stringToPixel(e,n.$container.width()),this._size.y=this.__stringToPixel(t,n.$container.height())):(this._size.x=e,this._size.y=t)}return{x:this._size.x,y:this._size.y}},minSize:function(e,t){if(typeof e!="undefined"){var n=this.docker();n?(this._minSize.x=this.__stringToPixel(e,n.$container.width()),this._minSize.y=this.__stringToPixel(t,n.$container.height())):(this._minSize.x=e,this._minSize.y=t)}return this._minSize},maxSize:function(e,t){if(typeof e!="undefined"){var n=this.docker();n?(this._maxSize.x=this.__stringToPixel(e,n.$container.width()),this._maxSize.y=this.__stringToPixel(t,n.$container.height())):(this._maxSize.x=e,this._maxSize.y=t)}return this._maxSize},width:function(){return this.$container?this.$container.width():0},height:function(){return this.$container?this.$container.height():0},icon:function(e){this.$icon||(this.$icon=$("<div>")),this.$icon.removeClass(),this.$icon.addClass("wcTabIcon "+e)},faicon:function(e){this.$icon||(this.$icon=$("<div>")),this.$icon.removeClass(),this.$icon.addClass("fa fa-fw fa-"+e)},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}},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},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}},moveable:function(e){return typeof e!="undefined"&&(this._moveable=e?!0:!1),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()},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._events[e].length;++n)if(this._events[e][n]===t){this._events[e].splice(n,1);break}},trigger:function(e,t){var n=this.docker();n&&n.trigger(e,t)},__init:function(){this._layout=new wcLayout(this.$container,this)},__update:function(){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 e=this;setTimeout(function(){e.__trigger(wcDocker.EVENT_INIT)},0)}this.__trigger(wcDocker.EVENT_UPDATED);var t=this.$container.width(),n=this.$container.height();if(this._actualSize.x!==t||this._actualSize.y!==n)this._actualSize.x=t,this._actualSize.y=n,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)),this.__trigger(wcDocker.EVENT_RESIZED);var r=this.$container.offset();if(this._actualPos.x!==r.left||this._actualPos.y!==r.top)this._actualPos.x=r.left,this._actualPos.y=r.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)),this.__trigger(wcDocker.EVENT_MOVED)},__resizeEnd:function(){new Date-this._resizeData.time<this._resizeData.delta?setTimeout(this.__resizeEnd.bind(this),this._resizeData.delta):(this._resizeData.timeout=!1,this.__trigger(wcDocker.EVENT_RESIZE_ENDED))},__moveEnd:function(){new Date-this._moveData.time<this._moveData.delta?setTimeout(this.__moveEnd.bind(this),this._moveData.delta):(this._moveData.timeout=!1,this.__trigger(wcDocker.EVENT_MOVE_ENDED))},__isVisible:function(e){this._isVisible!==e&&(this._isVisible=e,this.__trigger(wcDocker.EVENT_VISIBILITY_CHANGED))},__save:function(){var e={};return e.type="wcPanel",e.panelType=this._type,e.customData={},this.__trigger(wcDocker.EVENT_SAVE_LAYOUT,e.customData),e},__restore:function(e,t){this.__trigger(wcDocker.EVENT_RESTORE_LAYOUT,e.customData)},__trigger:function(e,t){if(!e)return!1;if(this._events[e])for(var n=0;n<this._events[e].length;++n)this._events[e][n].call(this,t)},__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)},__rect:function(){var e=this.$container.offset(),t=this.$container.width(),n=this.$container.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._layout.__container(this.$container):this._layout.__container(null),this.$container)},__destroy:function(){this._panelObject=null,this.off(),this.__container(null),this._parent=null}},wcFrame.prototype={LEFT_TAB_BUFFER:15,pos:function(e,t,n){var r=this.$container.width(),i=this.$container.height();if(typeof e=="undefined")return n?{x:this._pos.x*r,y:this._pos.y*i}:{x:this._pos.x,y:this._pos.y};n?(this._pos.x=e/r,this._pos.y=t/i):(this._pos.x=e,this._pos.y=t)},initSize:function(){var e={x:-1,y:-1};for(var t=0;t<this._panelList.length;++t)e.x<this._panelList[t].initSize().x&&(e.x=this._panelList[t].initSize().x),e.y<this._panelList[t].initSize().y&&(e.y=this._panelList[t].initSize().y);return e.x<0||e.y<0?!1:e},minSize:function(){var e={x:0,y:0};for(var t=0;t<this._panelList.length;++t)e.x=Math.max(e.x,this._panelList[t].minSize().x),e.y=Math.max(e.y,this._panelList[t].minSize().y);return e},maxSize:function(){var e={x:Infinity,y:Infinity};for(var t=0;t<this._panelList.length;++t)e.x=Math.min(e.x,this._panelList[t].maxSize().x),e.y=Math.min(e.y,this._panelList[t].maxSize().y);return e},addPanel:function(e,t){var n=this._panelList.indexOf(e);n!==-1&&this._panelList.splice(n,1),typeof t=="undefined"?this._panelList.push(e):this._panelList.splice(t,0,e),this._curTab===-1&&this._panelList.length&&(this._curTab=0,this._size=this.initSize()),this.__updateTabs()},removePanel:function(e){for(var t=0;t<this._panelList.length;++t)if(this._panelList[t]===e){this._curTab>=t&&this._curTab--,this._panelList[t].__container(null),this._panelList[t]._parent=null,this._panelList.splice(t,1);break}return this._curTab===-1&&this._panelList.length&&(this._curTab=0),this.__updateTabs(),this._panelList.length>0},panel:function(e,t){return typeof e!="undefined"&&e>-1&&e<this._panelList.length&&(this.$title.find('> .wcTabScroller > .wcPanelTab[id="'+this._curTab+'"]').removeClass("wcPanelTabActive"),this.$center.children('.wcPanelTabContent[id="'+this._curTab+'"]').addClass("wcPanelTabContentHidden"),this._curTab=e,this.$title.find('> .wcTabScroller > .wcPanelTab[id="'+e+'"]').addClass("wcPanelTabActive"),this.$center.children('.wcPanelTabContent[id="'+e+'"]').removeClass("wcPanelTabContentHidden"),this.__updateTabs(t)),this._curTab>-1&&this._curTab<this._panelList.length?this._panelList[this._curTab]:!1},__init:function(){this.$frame=$('<div class="wcFrame wcWide wcTall wcPanelBackground">'),this.$title=$('<div class="wcFrameTitle">'),this.$tabScroll=$('<div class="wcTabScroller">'),this.$center=$('<div class="wcFrameCenter wcWide">'),this.$tabLeft=$('<div class="wcFrameButton" title="Scroll tabs to the left."><span class="fa fa-arrow-left"></span><</div>'),this.$tabRight=$('<div class="wcFrameButton" title="Scroll tabs to the right."><span class="fa fa-arrow-right"></span>></div>'),this.$close=$('<div class="wcFrameButton" title="Close the currently active panel tab"><div class="fa fa-close"></div>X</div>'),this.$title.append(this.$tabScroll),this.$frame.append(this.$close),this._isFloating&&(this.$top=$('<div class="wcFrameEdgeH wcFrameEdge"></div>').css("top","-6px").css("left","0px").css("right","0px"),this.$bottom=$('<div class="wcFrameEdgeH wcFrameEdge"></div>').css("bottom","-6px").css("left","0px").css("right","0px"),this.$left=$('<div class="wcFrameEdgeV wcFrameEdge"></div>').css("left","-6px").css("top","0px").css("bottom","0px"),this.$right=$('<div class="wcFrameEdgeV wcFrameEdge"></div>').css("right","-6px").css("top","0px").css("bottom","0px"),this.$corner1=$('<div class="wcFrameCornerNW wcFrameEdge"></div>').css("top","-6px").css("left","-6px"),this.$corner2=$('<div class="wcFrameCornerNE wcFrameEdge"></div>').css("top","-6px").css("right","-6px"),this.$corner3=$('<div class="wcFrameCornerNW wcFrameEdge"></div>').css("bottom","-6px").css("right","-6px"),this.$corner4=$('<div class="wcFrameCornerNE wcFrameEdge"></div>').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.$frame.append(this.$center),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.time<this._resizeData.delta?setTimeout(this.__resizeEnd.bind(this),this._resizeData.delta):this._resizeData.timeout=!1},__trigger:function(e,t){for(var n=0;n<this._panelList.length;++n)this._panelList[n].__trigger(e,t)},__save:function(){var e={};e.type="wcFrame",e.floating=this._isFloating,e.isFocus=this.$frame.hasClass("wcFloatingFocus"),e.pos={x:this._pos.x,y:this._pos.y},e.size={x:this._size.x,y:this._size.y},e.tab=this._curTab,e.panels=[];for(var t=0;t<this._panelList.length;++t)e.panels.push(this._panelList[t].__save());return e},__restore:function(e,t){this._isFloating=e.floating,this._pos.x=e.pos.x,this._pos.y=e.pos.y,this._size.x=e.size.x,this._size.y=e.size.y,this._curTab=e.tab;for(var n=0;n<e.panels.length;++n){var r=t.__create(e.panels[n],this,this.$center);r.__restore(e.panels[n],t),this._panelList.push(r)}this.__update(),e.isFocus&&this.$frame.addClass("wcFloatingFocus")},__updateTabs:function(e){this.$tabScroll.empty();var t=[],n=[],r=0,i=this.$tabScroll.offset().left,s=this;this.$title.removeClass("wcNotMoveable"),this.$center.children(".wcPanelTabContent").each(function(){$(this).addClass("wcPanelTabContentHidden wcPanelTabUnused")});var o=!0;for(var u=0;u<this._panelList.length;++u){var a=this._panelList[u],f=$('<div id="'+u+'" class="wcPanelTab">'+a.title()+"</div>");this.$tabScroll.append(f),a.$icon&&f.prepend(a.$icon),f.toggleClass("wcNotMoveable",!a.moveable()),a.moveable()||this.$title.addClass("wcNotMoveable"),a._titleVisible||(o=!1);var l=this.$center.children('.wcPanelTabContent[id="'+u+'"]');l.length||(l=$('<div class="wcPanelTabContent wcPanelBackground wcPanelTabContentHidden" id="'+u+'">'),this.$center.append(l)),a.__container(l),a._parent=this;var c=this._curTab===u;a.isVisible()!==c&&t.push({panel:a,isVisible:c}),l.removeClass("wcPanelTabUnused"),c&&(f.addClass("wcPanelTabActive"),l.removeClass("wcPanelTabContentHidden")),r=f.offset().left-i,n.push(r),r+=f.outerWidth()}o?(this.$frame.prepend(this.$title),this.$frame.parent()||this.$center.css("top","")):(this.$title.remove(),this.$center.css("top","0px")),this.$center.children(".wcPanelTabUnused").each(function(){$(this).remove()});if(o){var h=this.__onTabChange();if(e)for(var u=0;u<n.length;++u)if(u===this._curTab){var p=n[u],d=r;u+1<n.length&&(d=n[u+1]);var v=-parseInt(this.$tabScroll.css("left")),m=this.$title.width()-h;p<v?(this._tabScrollPos=p-this.LEFT_TAB_BUFFER,this._tabScrollPos<0&&(this._tabScrollPos=0)):d-v>m&&(this._tabScrollPos=d-m+this.LEFT_TAB_BUFFER);break}this._canScrollTabs=!1;if(r>this.$title.width()-h){this._canScrollTabs=o,this.$frame.append(this.$tabRight),this.$frame.append(this.$tabLeft);var g=r-(this.$title.width()-h)/2;if(this._tabScrollPos>g){var y=this.$tabScroll.children();for(var u=0;u<y.length;++u){var f=$(y[u]);r=f.offset().left-i;if(r+f.outerWidth()>g){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");for(var u=0;u<t.length;++u)t[u].panel.__isVisible(t[u].isVisible)}},__onTabChange:function(){var e=0,t=this.panel();if(t){var n=t.scrollable();this.$center.toggleClass("wcScrollableX",n.x),this.$center.toggleClass("wcScrollableY",n.y);var r=t.overflowVisible();this.$center.toggleClass("wcOverflowVisible",r),this.$tabLeft.remove(),this.$tabRight.remove();while(this._buttonList.length)this._buttonList.pop().remove();t.closeable()?(this.$close.show(),e+=this.$close.outerWidth()):this.$close.hide();for(var i=0;i<t._buttonList.length;++i){var s=t._buttonList[i],o=$("<div>"),u=s.className;o.addClass("wcFrameButton"),s.isTogglable&&(o.addClass("wcFrameButtonToggler"),s.isToggled&&(o.addClass("wcFrameButtonToggled"),u=s.toggleClassName||u)),o.attr("title",s.tip),o.data("name",s.name),o.text(s.text),u&&o.prepend($('<div class="'+u+'">')),this._buttonList.push(o),this.$frame.append(o),e+=o.outerWidth()}this._canScrollTabs&&(this.$frame.append(this.$tabRight),this.$frame.append(this.$tabLeft),e+=this.$tabRight.outerWidth()+this.$tabLeft.outerWidth()),t.__update(),this.$center.scrollLeft(t._scroll.x),this.$center.scrollTop(t._scroll.y)}return e},__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=$('<div class="wcFrameFlasher">');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<this._panelList.length&&t>=0&&t<this._panelList.length){var n=this._panelList.splice(e,1);return this._panelList.splice(t,0,n[0]),this._curTab===e&&(this._curTab=t),this.__updateTabs(),this.$title.find('> .wcTabScroller > .wcPanelTab[id="'+t+'"]')[0]}return!1},__checkAnchorDrop:function(e,t,n,r){var i=this.panel();return i&&i.moveable()?i.layout().__checkAnchorDrop(e,t,n,!this._isFloating&&r,this.$frame,i.moveable()&&i.title()):!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;a<e.length;++a){switch(e[a]){case"top":this._size.y+=u.y-t.y-2,u.y=t.y+2,this._size.y<s.y&&(u.y+=this._size.y-s.y,this._size.y=s.y),this._size.y>o.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.y<s.y&&(this._size.y=s.y),this._size.y>o.y&&(this._size.y=o.y);break;case"left":this._size.x+=u.x-t.x-2,u.x=t.x+2,this._size.x<s.x&&(u.x+=this._size.x-s.x,this._size.x=s.x),this._size.x>o.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.x<s.x&&(this._size.x=s.x),this._size.x>o.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=$('<div class="wcFrameShadower">'),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(){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;e<this._panelList.length;++e)this._panelList[e].__destroy();while(this._panelList.length)this._panelList.pop();this.$modalBlocker&&(this.$modalBlocker.remove(),this.$modalBlocker=null),this.__container(null),this._parent=null}},wcSplitter.prototype={initLayouts:function(){var e=new wcLayout(this.$pane[0],this),t=new wcLayout(this.$pane[1],this);this.pane(0,e),this.pane(1,t)},docker:function(){var e=this._parent;while(e&&!(e instanceof wcDocker))e=e._parent;return e},orientation:function(e){if(typeof e=="undefined")return this._orientation;this._orientation!=e&&(this._orientation=e,this._orientation?(this.$pane[0].removeClass("wcWide").addClass("wcTall"),this.$pane[1].removeClass("wcWide").addClass("wcTall"),this.$bar.removeClass("wcWide").removeClass("wcSplitterBarH").addClass("wcTall").addClass("wcSplitterBarV")):(this.$pane[0].removeClass("wcTall").addClass("wcWide"),this.$pane[1].removeClass("wcTall").addClass("wcWide"),this.$bar.removeClass("wcTall").removeClass("wcSplitterBarV").addClass("wcWide").addClass("wcSplitterBarH")),this.$pane[0].css("top","").css("left","").css("width","").css("height",""),this.$pane[1].css("top","").css("left","").css("width","").css("height",""),this.$bar.css("top","").css("left","").css("width","").css("height",""),this.__update())},minSize:function(){var e,t;return this._pane[0]&&typeof this._pane[0].minSize=="function"&&(e=this._pane[0].minSize()),this._pane[1]&&typeof this._pane[1].minSize=="function"&&(t=this._pane[1].minSize()),e&&t?(this._orientation?(e.x+=t.x,e.y=Math.max(e.y,t.y)):(e.y+=t.y,e.x=Math.max(e.x,t.x)),e):e?e:t?t:!1},maxSize:function(){var e,t;return this._pane[0]&&typeof this._pane[0].maxSize=="function"&&(e=this._pane[0].maxSize()),this._pane[1]&&typeof this._pane[1].maxSize=="function"&&(t=this._pane[1].maxSize()),e&&t?(this._orientation?(e.x+=t.x,e.y=Math.min(e.y,t.y)):(e.y+=t.y,e.x=Math.min(e.x,t.x)),e):e?e:t?t:!1},pos:function(e){return typeof e=="undefined"?this._pos:(this._pos=e,this.__update(),this._parent instanceof wcPanel&&this._parent.__trigger(wcDocker.EVENT_UPDATED),this._pos)},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 this.__update(),!1},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)}typeof e=="undefined"||e?this.__destroy():this.__container(null)},onUpdate:function(){this.__update()},onClosed:function(){this.destroy()},__init:function(){this.$pane.push($('<div class="wcLayoutPane wcScrollableX wcScrollableY">')),this.$pane.push($('<div class="wcLayoutPane wcScrollableX wcScrollableY">')),this.$bar=$('<div class="wcSplitterBar">'),this._orientation?(this.$pane[0].addClass("wcTall"),this.$pane[1].addClass("wcTall"),this.$bar.addClass("wcTall").addClass("wcSplitterBarV")):(this.$pane[0].addClass("wcWide"),this.$pane[1].addClass("wcWide"),this.$bar.addClass("wcWide").addClass("wcSplitterBarH")),this.__container(this.$container);if(this._parent instanceof wcPanel){this._boundEvents.push({event:wcDocker.EVENT_UPDATED,handler:this.onUpdate.bind(this)}),this._boundEvents.push({event:wcDocker.EVENT_CLOSED,handler:this.onClosed.bind(this)});for(var e=0;e<this._boundEvents.length;++e)this._parent.on(this._boundEvents[e].event,this._boundEvents[e].handler)}},__update:function(){var e=this.$container.width(),t=this.$container.height(),n=this.__minPos(),r=this.__maxPos();if(this._findBestPos){this._findBestPos=!1;var i,s;this._pane[0]&&typeof this._pane[0].initSize=="function"&&(i=this._pane[0].initSize(),i&&(i.x<0&&(i.x=e/2),i.y<0&&(i.y=t/2))),this._pane[1]&&typeof this._pane[1].initSize=="function"&&(s=this._pane[1].initSize(),s&&(s.x<0&&(s.x=e/2),s.y<0&&(s.y=t/2),s.x=e-s.x,s.y=t-s.y));var o;i&&s?o={x:Math.min(i.x,s.x),y:Math.min(i.y,s.y)}:i?o=i:s&&(o=s),o&&(this._orientation?this._pos=o.x/e:this._pos=o.y/t)}if(this._orientation){var o=e*this._pos;n&&(o=Math.max(n.x,o)),r&&(o=Math.min(r.x,o)),this.$bar.css("left",o+2),this.$bar.css("top","0px"),this.$bar.css("height",t-2),this.$pane[0].css("width",o+2),this.$pane[0].css("left","0px"),this.$pane[0].css("right",""),this.$pane[1].css("left",""),this.$pane[1].css("right","0px"),this.$pane[1].css("width",e-o-6)}else{var o=t*this._pos;n&&(o=Math.max(n.y,o)),r&&(o=Math.min(r.y,o)),this.$bar.css("top",o+2),this.$bar.css("left","0px"),this.$bar.css("width",e-2),this.$pane[0].css("height",o+2),this.$pane[0].css("top","0px"),this.$pane[0].css("bottom",""),this.$pane[1].css("top",""),this.$pane[1].css("bottom","0px"),this.$pane[1].css("height",t-o-6)}this._pane[0]&&this._pane[0].__update(),this._pane[1]&&this._pane[1].__update()},__save:function(){var e={};return e.type="wcSplitter",e.horizontal=this._orientation,e.pane0=this._pane[0]?this._pane[0].__save():null,e.pane1=this._pane[1]?this._pane[1].__save():null,e.pos=this._pos,e},__restore:function(e,t){this._pos=e.pos,e.pane0&&(this._pane[0]=t.__create(e.pane0,this,this.$pane[0]),this._pane[0].__restore(e.pane0,t)),e.pane1&&(this._pane[1]=t.__create(e.pane1,this,this.$pane[1]),this._pane[1].__restore(e.pane1,t))},__findBestPos:function(){this._findBestPos=!0},__moveBar:function(e){var t=this.$container.width(),n=this.$container.height(),r=this.$container.offset();e.x-=r.left,e.y-=r.top;var i=this.__minPos(),s=this.__maxPos();this._orientation?this.pos((e.x-3)/t):this.pos((e.y-3)/n)},__minPos:function(){var e=this.$container.width(),t=this.$container.height(),n;this._pane[0]&&typeof this._pane[0].minSize=="function"?n=this._pane[0].minSize():n={x:50,y:50};var r;return this._pane[1]&&typeof this._pane[1].maxSize=="function"?r=this._pane[1].maxSize():r={x:e,y:t},r.x=e-Math.min(r.x,e),r.y=t-Math.min(r.y,t),n.x=Math.max(n.x,r.x),n.y=Math.max(n.y,r.y),n},__maxPos:function(){var e=this.$container.width(),t=this.$container.height(),n;this._pane[0]&&typeof this._pane[0].maxSize=="function"?n=this._pane[0].maxSize():n={x:e,y:t};var r;return this._pane[1]&&typeof this._pane[1].minSize=="function"?r=this._pane[1].minSize():r={x:50,y:50},r.x=e-r.x,r.y=t-r.y,n.x=Math.min(r.x,n.x),n.y=Math.min(r.y,n.y),n},__container:function(e){return typeof e=="undefined"?this.$container:(this.$container=e,this.$container?(this.$container.append(this.$pane[0]),this.$container.append(this.$pane[1]),this.$container.append(this.$bar)):(this.$pane[0].remove(),this.$pane[1].remove(),this.$bar.remove()),this.$container)},__removeChild:function(e){if(this._pane[0]===e)this._pane[0]=!1;else{if(this._pane[1]!==e)return;this._pane[1]=!1}e&&(e.__container(null),e._parent=null)},__destroy:function(){while(this._boundEvents.length)this._parent.off(this._boundEvents[0].event,this._boundEvents[0].handler),this._boundEvents.pop();this._pane[0]&&(this._pane[0].__destroy(),this._pane[0]=null),this._pane[1]&&(this._pane[1].__destroy(),this._pane[1]=null),this.__container(null),this._parent=!1}},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()},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<this._layoutList.length){var t=this._layoutList[e].name;return this._layoutList[e].__destroy(),this._layoutList.splice(e,1),this._curTab>=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<this._layoutList.length){this.$title.find('> .wcTabScroller > .wcPanelTab[id="'+this._curTab+'"]').removeClass("wcPanelTabActive"),this.$center.children('.wcPanelTabContent[id="'+this._curTab+'"]').addClass("wcPanelTabContentHidden"),this._curTab=e,this.$title.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<this._layoutList.length?this._layoutList[e]:!1},moveTab:function(e,t){if(e>=0&&e<this._layoutList.length&&t>=0&&t<this._layoutList.length){var n=this._layoutList.splice(e,1);return this._layoutList.splice(t,0,n[0]),this._curTab===e&&(this._curTab=t),this.__updateTabs(),this.$title.find('> .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<this._layoutList.length){var n=this._layoutList[e];return typeof t!="undefined"&&(n._closeable=t),n._closeable}return!1},scrollable:function(e,t,n){if(e>-1&&e<this._layoutList.length){var r=this._layoutList[e],i=!1;return typeof t!="undefined"&&(r._scrollable.x=t,i=!0),typeof n!="undefined"&&(r._scrollable.y=n,i=!0),i&&this.__onTabChange(),{x:r._scrollable.x,y:r._scrollable.y}}return!1},overflowVisible:function(e,t){if(e>-1&&e<this._layoutList.length){var n=this._layoutList[e];return typeof overflow!="undefined"&&(n._overflowVisible=overflow,this.__onTabChange()),n._overflowVisible}return!1},icon:function(e,t){if(e>-1&&e<this._layoutList.length){var n=this._layoutList[e];n.$icon||(n.$icon=$("<div>")),n.$icon.removeClass(),n.$icon.addClass("wcTabIcon "+t)}},faicon:function(e,t){if(e>-1&&e<this._layoutList.length){var n=this._layoutList[e];n.$icon||(n.$icon=$("<div>")),n.$icon.removeClass(),n.$icon.addClass("fa fa-fw fa-"+t)}},onUpdate:function(){this.__update()},onClosed:function(){this.destroy()},__init:function(){this.$frame=$('<div class="wcCustomTab wcWide wcTall wcPanelBackground">'),this.$title=$('<div class="wcFrameTitle wcCustomTabTitle">'),this.$tabScroll=$('<div class="wcTabScroller">'),this.$center=$('<div class="wcFrameCenter wcWide">'),this.$tabLeft=$('<div class="wcFrameButton" title="Scroll tabs to the left."><span class="fa fa-arrow-left"></span><</div>'),this.$tabRight=$('<div class="wcFrameButton" title="Scroll tabs to the right."><span class="fa fa-arrow-right"></span>></div>'),this.$close=$('<div class="wcFrameButton" title="Close the currently active panel tab"><span class="fa fa-close"></span>X</div>'),this.$frame.append(this.$title),this.$title.append(this.$tabScroll),this.$frame.append(this.$center),this.__container(this.$container),this._boundEvents.push({event:wcDocker.EVENT_UPDATED,handler:this.onUpdate.bind(this)}),this._boundEvents.push({event:wcDocker.EVENT_CLOSED,handler:this.onClosed.bind(this)});for(var e=0;e<this._boundEvents.length;++e)this._parent.on(this._boundEvents[e].event,this._boundEvents[e].handler);var t=this.docker();t&&t._tabList.push(this)},__update:function(){this.__updateTabs()},__updateTabs:function(e){this.$tabScroll.empty();var t=[],n=0,r=this.$tabScroll.offset().left,i=this;this.$center.children(".wcPanelTabContent").each(function(){$(this).addClass("wcPanelTabContentHidden wcPanelTabUnused")});for(var s=0;s<this._layoutList.length;++s){var o=$('<div id="'+s+'" class="wcPanelTab">'+this._layoutList[s].name+"</div>");this._moveable&&o.addClass("wcCustomTabMoveable"),this.$tabScroll.append(o),this._layoutList[s].$icon&&o.prepend(this._layoutList[s].$icon);var u=this.$center.children('.wcPanelTabContent[id="'+s+'"]');u.length||(u=$('<div class="wcPanelTabContent wcPanelTabContentHidden" id="'+s+'">'),this.$center.append(u)),this._layoutList[s].__container(u),this._layoutList[s]._parent=this;var a=this._curTab===s;u.removeClass("wcPanelTabUnused"),a&&(o.addClass("wcPanelTabActive"),u.removeClass("wcPanelTabContentHidden")),n=o.offset().left-r,t.push(n),n+=o.outerWidth()}this.$center.children(".wcPanelTabUnused").each(function(){$(this).remove()});var f=this.__onTabChange();if(e)for(var s=0;s<t.length;++s)if(s===this._curTab){var l=t[s],c=n;s+1<t.length&&(c=t[s+1]);var h=-parseInt(this.$tabScroll.css("left")),p=this.$title.width()-f;l<h?(this._tabScrollPos=l-this.LEFT_TAB_BUFFER,this._tabScrollPos<0&&(this._tabScrollPos=0)):c-h>p&&(this._tabScrollPos=c-p+this.LEFT_TAB_BUFFER);break}this._canScrollTabs=!1;if(n>this.$title.width()-f){this._canScrollTabs=!0,this.$frame.append(this.$tabRight),this.$frame.append(this.$tabLeft);var d=n-(this.$title.width()-f)/2;if(this._tabScrollPos>d){var v=this.$tabScroll.children();for(var s=0;s<v.length;++s){var o=$(v[s]);n=o.offset().left-r;if(n+o.outerWidth()>d){this._tabScrollPos=n-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);return 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.$frame.append(this.$close),e+=this.$close.outerWidth()):this.$close.remove(),this._canScrollTabs&&(this.$frame.append(this.$tabRight),this.$frame.append(this.$tabLeft),e+=this.$tabRight.outerWidth()+this.$tabLeft.outerWidth()),this.$center.scrollLeft(t._scroll.x),this.$center.scrollTop(t._scroll.y)),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.pop();this._curTab=-1;for(var n=0;n<this._layoutList.length;++n)this._layoutList[n].__destroy();while(this._layoutList.length)this._layoutList.pop();this.__container(null),this._parent=null}},wcIFrame.prototype={docker:function(){var e=this._panel;while(e&&!(e instanceof wcDocker))e=e._parent;return e},openURL:function(e){this.__clearFrame(),this.$frame=$('<iframe class="wcIFrame">'),this._panel.docker().$container.append(this.$frame),this.onMoved(),this._window=this.$frame[0].contentWindow||this.$frame[0],this.__updateFrame(),this._window.location.replace(e)},openHTML:function(e){this.__clearFrame(),this.$frame=$('<iframe class="wcIFrame">'),this._panel.docker().$container.append(this.$frame),this.onMoved(),this._window=this.$frame[0].contentWindow||this.$frame[0],this.__updateFrame(),this._boundEvents=[],this._window.document.open(),this._window.document.write(e),this._window.document.close()},show:function(){this.$frame&&this.$frame.removeClass("wcIFrameHidden")},hide:function(){this.$frame&&this.$frame.addClass("wcIFrameHidden")},window:function(){return this._window},destroy:function(){while(this._boundEvents.length)this._panel.off(this._boundEvents[0].event,this._boundEvents[0].handler),this._boundEvents.pop();this.__clearFrame(),this._panel=null,this._layout=null,this.$container=null},onVisibilityChanged:function(){this.__updateFrame()},onBeginDock:function(){this.$frame&&this.$frame.addClass("wcIFrameMoving")},onEndDock:function(){this.$frame&&this._hasFocus&&this.$frame.removeClass("wcIFrameMoving")},onMoveStarted:function(){this.$frame&&this.$frame.addClass("wcIFrameMoving")},onMoveFinished:function(){this.$frame&&this.$frame.removeClass("wcIFrameMoving")},onMoved:function(){if(this.$frame){var e=this.$container.offset(),t=this.$container.width(),n=this.$container.height();this.$frame.css("left",e.left),this.$frame.css("top",e.top),this.$frame.css("width",t),this.$frame.css("height",n)}},onAttached:function(){this._isAttached=!0,this.__updateFrame()},onDetached:function(){this._isAttached=!1,this.__updateFrame()},onGainFocus:function(){this._hasFocus=!0,this.__updateFrame()},onLostFocus:function(){this._hasFocus=!1,this.__updateFrame()},onClosed:function(){this.destroy()},__clearFrame:function(){this.$frame&&(this.$frame[0].srcdoc="",this.$frame.remove(),this.$frame=null,this._window=null)},__updateFrame:function(){this.$frame&&(this.$frame.toggleClass("wcIFrameFloating",!this._isAttached),this._isAttached?this.$frame.removeClass("wcIFrameFloatingFocus"):this.$frame.toggleClass("wcIFrameFloatingFocus",this._hasFocus),this.$frame.toggleClass("wcIFramePanelHidden",!this._panel.isVisible()))},__init:function(){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.onAttached.bind(this)}),this._boundEvents.push({event:wcDocker.EVENT_DETACHED,handler:this.onDetached.bind(this)}),this._boundEvents.push({event:wcDocker.EVENT_GAIN_FOCUS,handler:this.onGainFocus.bind(this)}),this._boundEvents.push({event:wcDocker.EVENT_LOST_FOCUS,handler:this.onLostFocus.bind(this)}),this._boundEvents.push({event:wcDocker.EVENT_CLOSED,handler:this.onClosed.bind(this)});for(var e=0;e<this._boundEvents.length;++e)this._panel.on(this._boundEvents[e].event,this._boundEvents[e].handler)}} |