📄 bordercontainer.js
字号:
if(!dojo._hasResource["dijit.layout.BorderContainer"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.dojo._hasResource["dijit.layout.BorderContainer"] = true;dojo.provide("dijit.layout.BorderContainer");dojo.require("dijit.layout._LayoutWidget");dojo.require("dojo.cookie");dojo.declare( "dijit.layout.BorderContainer",// [dijit._Widget, dijit._Container, dijit._Contained], dijit.layout._LayoutWidget,{ // summary: // Provides layout in 5 regions, a center and borders along its 4 sides. // // description: // A BorderContainer is a box with a specified size (like style="width: 500px; height: 500px;"), // that contains a child widget marked region="center" and optionally children widgets marked // region equal to "top", "bottom", "leading", "trailing", "left" or "right". // Children along the edges will be laid out according to width or height dimensions. The remaining // space is designated for the center region. // The outer size must be specified on the BorderContainer node. Width must be specified for the sides // and height for the top and bottom, respectively. No dimensions should be specified on the center; // it will fill the remaining space. Regions named "leading" and "trailing" may be used just like // "left" and "right" except that they will be reversed in right-to-left environments. // Optional splitters may be specified on the edge widgets only to make them resizable by the user. // // example: // | <style> // | html, body { height: 100%; width: 100%; } // | </style> // | <div dojoType="BorderContainer" design="sidebar" style="width: 100%; height: 100%"> // | <div dojoType="ContentPane" region="top">header text</div> // | <div dojoType="ContentPane" region="right" style="width: 200px;">table of contents</div> // | <div dojoType="ContentPane" region="center">client area</div> // | </div> // // design: String // choose which design is used for the layout: "headline" (default) where the top and bottom extend // the full width of the container, or "sidebar" where the left and right sides extend from top to bottom. design: "headline", // liveSplitters: Boolean // specifies whether splitters resize as you drag (true) or only upon mouseup (false) liveSplitters: true, // persist: Boolean // Save splitter positions in a cookie. persist: false, // Boolean // _splitterClass: String // Optional hook to override the default Splitter widget used by BorderContainer _splitterClass: "dijit.layout._Splitter", postCreate: function(){ this.inherited(arguments); this._splitters = {}; this._splitterThickness = {}; dojo.addClass(this.domNode, "dijitBorderContainer"); }, startup: function(){ if(this._started){ return; } dojo.forEach(this.getChildren(), this._setupChild, this); this.inherited(arguments); }, _setupChild: function(/*Widget*/child){ var region = child.region; if(region){// dojo.addClass(child.domNode, "dijitBorderContainerPane"); child.domNode.style.position = "absolute"; // bill says not to set this in CSS, since we can't keep others // from destroying the class list var ltr = this.isLeftToRight(); if(region == "leading"){ region = ltr ? "left" : "right"; } if(region == "trailing"){ region = ltr ? "right" : "left"; } this["_"+region] = child.domNode; this["_"+region+"Widget"] = child; if(child.splitter){ var _Splitter = dojo.getObject(this._splitterClass); var flip = {left:'right', right:'left', top:'bottom', bottom:'top', leading:'trailing', trailing:'leading'}; var oppNodeList = dojo.query('[region=' + flip[child.region] + ']', this.domNode); var splitter = new _Splitter({ container: this, child: child, region: region, oppNode: oppNodeList[0], live: this.liveSplitters }); this._splitters[region] = splitter.domNode; dojo.place(splitter.domNode, child.domNode, "after"); this._computeSplitterThickness(region); } child.region = region; } }, _computeSplitterThickness: function(region){ var re = new RegExp("top|bottom"); this._splitterThickness[region] = dojo.marginBox(this._splitters[region])[(re.test(region) ? 'h' : 'w')]; }, layout: function(){ this._layoutChildren(); }, addChild: function(/*Widget*/ child, /*Integer?*/ insertIndex){ this.inherited(arguments); this._setupChild(child); if(this._started){ this._layoutChildren(); //OPT } }, removeChild: function(/*Widget*/ child){ var region = child.region; var splitter = this._splitters[region]; if(splitter){ dijit.byNode(splitter).destroy(); delete this._splitters[region]; delete this._splitterThickness[region]; } this.inherited(arguments); delete this["_"+region]; delete this["_" +region+"Widget"]; if(this._started){ this._layoutChildren(child.region); } }, _layoutChildren: function(/*String?*/changedRegion){ var sidebarLayout = (this.design == "sidebar"); var topHeight = 0, bottomHeight = 0, leftWidth = 0, rightWidth = 0; var topStyle = {}, leftStyle = {}, rightStyle = {}, bottomStyle = {}, centerStyle = (this._center && this._center.style) || {}; var changedSide = /left|right/.test(changedRegion); var layoutSides = !changedRegion || (!changedSide && !sidebarLayout); var layoutTopBottom = !changedRegion || (changedSide && sidebarLayout); if(this._top){ topStyle = layoutTopBottom && this._top.style; topHeight = dojo.marginBox(this._top).h; } if(this._left){ leftStyle = layoutSides && this._left.style; leftWidth = dojo.marginBox(this._left).w; } if(this._right){ rightStyle = layoutSides && this._right.style; rightWidth = dojo.marginBox(this._right).w; } if(this._bottom){ bottomStyle = layoutTopBottom && this._bottom.style; bottomHeight = dojo.marginBox(this._bottom).h; } var splitters = this._splitters; var topSplitter = splitters.top; var bottomSplitter = splitters.bottom; var leftSplitter = splitters.left; var rightSplitter = splitters.right; var splitterThickness = this._splitterThickness; var topSplitterThickness = splitterThickness.top || 0; var leftSplitterThickness = splitterThickness.left || 0; var rightSplitterThickness = splitterThickness.right || 0; var bottomSplitterThickness = splitterThickness.bottom || 0; // Check for race condition where CSS hasn't finished loading, so // the splitter width == the viewport width (#5824) if(leftSplitterThickness > 50 || rightSplitterThickness > 50){ setTimeout(dojo.hitch(this, function(){ for(var region in this._splitters){ this._computeSplitterThickness(region); } this._layoutChildren(); }), 50); return false; } var splitterBounds = { left: (sidebarLayout ? leftWidth + leftSplitterThickness: "0") + "px", right: (sidebarLayout ? rightWidth + rightSplitterThickness: "0") + "px" }; if(topSplitter){ dojo.mixin(topSplitter.style, splitterBounds); topSplitter.style.top = topHeight + "px"; } if(bottomSplitter){ dojo.mixin(bottomSplitter.style, splitterBounds); bottomSplitter.style.bottom = bottomHeight + "px"; } splitterBounds = { top: (sidebarLayout ? "0" : topHeight + topSplitterThickness) + "px", bottom: (sidebarLayout ? "0" : bottomHeight + bottomSplitterThickness) + "px" }; if(leftSplitter){ dojo.mixin(leftSplitter.style, splitterBounds); leftSplitter.style.left = leftWidth + "px"; } if(rightSplitter){ dojo.mixin(rightSplitter.style, splitterBounds); rightSplitter.style.right = rightWidth + "px"; } dojo.mixin(centerStyle, { top: topHeight + topSplitterThickness + "px", left: leftWidth + leftSplitterThickness + "px", right: rightWidth + rightSplitterThickness + "px", bottom: bottomHeight + bottomSplitterThickness + "px" }); var bounds = { top: sidebarLayout ? "0" : centerStyle.top, bottom: sidebarLayout ? "0" : centerStyle.bottom }; dojo.mixin(leftStyle, bounds); dojo.mixin(rightStyle, bounds); leftStyle.left = rightStyle.right = topStyle.top = bottomStyle.bottom = "0"; if(sidebarLayout){ topStyle.left = bottomStyle.left = leftWidth + (this.isLeftToRight() ? leftSplitterThickness : 0) + "px"; topStyle.right = bottomStyle.right = rightWidth + (this.isLeftToRight() ? 0 : rightSplitterThickness) + "px"; }else{ topStyle.left = topStyle.right = bottomStyle.left = bottomStyle.right = "0"; } // Nodes in IE respond to t/l/b/r, and TEXTAREA doesn't respond in any browser var janky = dojo.isIE || dojo.some(this.getChildren(), function(child){ return child.domNode.tagName == "TEXTAREA"; }); if(janky){ // Set the size of the children the old fashioned way, by calling // childNode.resize({h: int, w: int}) for each child node) var borderBox = function(n, b){ n=dojo.byId(n); var s = dojo.getComputedStyle(n); if(!b){ return dojo._getBorderBox(n, s); } var me = dojo._getMarginExtents(n, s); dojo._setMarginBox(n, b.l, b.t, b.w + me.w, b.h + me.h, s); return null; }; var resizeWidget = function(widget, dim){ if(widget){ widget.resize ? widget.resize(dim) : dojo.marginBox(widget.domNode, dim); } }; // TODO: use dim passed in to resize() (see _LayoutWidget.js resize()) // Then can make borderBox setBorderBox(), since no longer need to ever get the borderBox() size var thisBorderBox = borderBox(this.domNode);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -