From 4dbb3cc13be3da8edb68014512e0f8f67cd6fded Mon Sep 17 00:00:00 2001 From: lochemage Date: Sat, 7 Mar 2015 22:57:15 -0800 Subject: [PATCH] Greatly improved the way splitters move when they carry other splitters nested within. --- Build/wcDocker.js | 63 ++++++++++++++++++++++++++++++------------- Build/wcDocker.min.js | 2 +- Code/splitter.js | 62 ++++++++++++++++++++++++++++++------------ 3 files changed, 91 insertions(+), 36 deletions(-) diff --git a/Build/wcDocker.js b/Build/wcDocker.js index 6c8d2c40..a7474509 100644 --- a/Build/wcDocker.js +++ b/Build/wcDocker.js @@ -1308,7 +1308,6 @@ wcDocker.prototype = { y: event.clientY, }; self._draggingSplitter.__moveBar(mouse); - self._draggingSplitter.__update(); } else if (self._draggingFrameSizer) { var mouse = { x: event.clientX, @@ -4267,12 +4266,12 @@ wcSplitter.prototype = { // value If supplied, assigns a new splitter percentage (0-1). // Returns: // number The current position. - pos: function(value) { + pos: function(value, opt_update) { if (typeof value === 'undefined') { return this._pos; } this._pos = value; - this.__update(); + this.__update(opt_update); if (this._parent instanceof wcPanel) { this._parent.__trigger(wcDocker.EVENT_UPDATED); @@ -4309,7 +4308,7 @@ wcSplitter.prototype = { } } } - this.__update(); + // this.__update(); return false; }, @@ -4395,7 +4394,8 @@ wcSplitter.prototype = { }, // Updates the size of the splitter. - __update: function() { + __update: function(opt_fromOrientation, opt_fromPane, opt_oldSize) { + var width = this.$container.width(); var height = this.$container.height(); @@ -4455,7 +4455,32 @@ wcSplitter.prototype = { } } - if (this._orientation) { + if (opt_fromOrientation === this._orientation) { + var pos = opt_oldSize * this._pos; + var size = -1; + switch (opt_fromOrientation) { + case wcDocker.ORIENTATION_HORIZONTAL: + size = width; + break; + case wcDocker.ORIENTATION_VERTICAL: + size = height; + break; + default: break; + } + + if (size > -1) { + if (opt_fromPane) { + pos = opt_oldSize - pos; + } + this._pos = pos / size; + if (opt_fromPane) { + this._pos = 1.0 - this._pos; + } + } + } + + var oldSize = []; + if (this._orientation === wcDocker.ORIENTATION_HORIZONTAL) { var size = width * this._pos; if (minSize) { @@ -4465,8 +4490,10 @@ wcSplitter.prototype = { size = Math.min(maxSize.x, size); } - // Bar is top to bottom + oldSize.push(this.$pane[0].width()); + oldSize.push(this.$pane[1].width()); + // Bar is top to bottom this.$bar.css('left', size+2); this.$bar.css('top', '0px'); this.$bar.css('height', height-2); @@ -4486,8 +4513,10 @@ wcSplitter.prototype = { size = Math.min(maxSize.y, size); } - // Bar is left to right + oldSize.push(this.$pane[0].height()); + oldSize.push(this.$pane[1].height()); + // Bar is left to right this.$bar.css('top', size+2); this.$bar.css('left', '0px'); this.$bar.css('width', width-2); @@ -4499,11 +4528,12 @@ wcSplitter.prototype = { this.$pane[1].css('height', height - size - 6); } - if (this._pane[0]) { - this._pane[0].__update(); - } - if (this._pane[1]) { - this._pane[1].__update(); + if (opt_fromOrientation !== undefined) { + this._pane[0] && this._pane[0].__update(this._orientation, 0, oldSize[0]); + this._pane[1] && this._pane[1].__update(this._orientation, 1, oldSize[1]); + } else { + this._pane[0] && this._pane[0].__update(); + this._pane[1] && this._pane[1].__update(); } }, @@ -4549,13 +4579,10 @@ wcSplitter.prototype = { mouse.x -= offset.left; mouse.y -= offset.top; - var minSize = this.__minPos(); - var maxSize = this.__maxPos(); - if (this._orientation) { - this.pos((mouse.x-3) / width); + this.pos((mouse.x-3) / width, 2); } else { - this.pos((mouse.y-3) / height); + this.pos((mouse.y-3) / height, 2); } }, diff --git a/Build/wcDocker.min.js b/Build/wcDocker.min.js index 42855242..c166a3e4 100644 --- a/Build/wcDocker.min.js +++ b/Build/wcDocker.min.js @@ -14,4 +14,4 @@ * GPL v3 http://opensource.org/licenses/GPL-3.0 * */ -function wcDocker(e,t){this.$container=$(e).addClass("wcDocker"),this.$transition=$('
'),this.$container.append(this.$transition),this._events={},this._placeholderPanel=null,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')),!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._curTab===-1&&f._panelList.length&&(f._curTab=0),f.__updateTabs();if(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),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,t,n):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(),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;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 o=0;o');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)})(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 .wcFrameButton",function(){e.$container.addClass("wcDisableSelection")}),$("body").on("click",".wcFrame > .wcFrameButton",function(){e.$container.removeClass("wcDisableSelection");for(var t=0;t .wcFrameButton",function(){e.$container.removeClass("wcDisableSelection");for(var t=0;t1&&e._draggingFrameTab)){e._draggingFrame.__shadow(!0);if(!i)for(var o=0;o
'),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 instanceof wcPanel){var r=n._parent;if(r instanceof wcFrame){r.addPanel(e);return}}else if(n instanceof wcFrame){n.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)},__addPlaceholder:function(e){this._placeholderPanel&&console.log("WARNING: wcDocker creating placeholder panel when one already exists"),this._placeholderPanel=new wcPanel(wcDocker.PANEL_PLACEHOLDER_NAME,{}),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,wcDocker.DOCK_STACKED,e):this.__addPanelAlone(this._placeholderPanel,wcDocker.DOCK_TOP),this.__update()}},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._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=$('
'),this.$table.append($("")),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:$(""),x:0,y:0})}if(!this._batchProcess){var i=this.$table.find("tbody");$(".wcDockerTransition").append(i);var s=$("");for(var n=0;n"),s.append(o)),o.append(u.$el))}}this.$table.append(s),i.remove()}},__mergeGrid:function(e,t,n,r){for(var i=0;i1&&(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=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(this._parent instanceof wcPanel&&this._parent._isPlaceholder)return n.anchor(e,{x:a.left,y:a.top,w:o,h:u,loc:wcDocker.DOCK_TOP,item:this,self:!1}),!0;if(o=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.$icon.removeClass(),this.$icon.addClass("wcTabIcon "+e)},faicon:function(e){this.$icon||(this.$icon=$("
")),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=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 .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.$title=$('
'),this.$tabScroll=$('
'),this.$center=$('
'),this.$tabLeft=$('
<
'),this.$tabRight=$('
>
'),this.$close=$('
X
'),this.$title.append(this.$tabScroll),this.$frame.append(this.$close),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.$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'+a.title()+"
");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=$('
'),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;um&&(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;ug){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"),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($('
')),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=$('
');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){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;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(){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=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($('
')),this.$pane.push($('
')),this.$bar=$('
'),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-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.$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=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)}},onUpdate:function(){this.__update()},onClosed:function(){this.destroy()},__init:function(){this.$frame=$('
'),this.$title=$('
'),this.$tabScroll=$('
'),this.$center=$('
'),this.$tabLeft=$('
<
'),this.$tabRight=$('
>
'),this.$close=$('
X
'),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._layoutList[s].name+"
");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=$('
'),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;sp&&(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;sd){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._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=$('