📄 layout-debug.js
字号:
if (this._rendered) { this.resize(); } return unit; }, /** * @private * @method _createUnits * @description Private method to create units from the config that was passed in. */ _createUnits: function() { var units = this.get('units'); for (var i in units) { if (Lang.hasOwnProperty(units, i)) { this.addUnit(units[i]); } } }, /** * @method resize * @param {Boolean} set If set to false, it will NOT set the size, just perform the calculations (used for collapsing units) * @description Starts the chain of resize routines that will resize all the units. * @return {<a href="YAHOO.widget.Layout.html">YAHOO.widget.Layout</a>} The Layout instance */ resize: function(set) { set = ((set === false) ? false : true); if (set) { var retVal = this.fireEvent('beforeResize'); if (retVal === false) { set = false; } if (this.browser.ie) { if (this._isBody) { Dom.removeClass(document.documentElement, 'yui-layout'); Dom.addClass(document.documentElement, 'yui-layout'); } else { this.removeClass('yui-layout'); this.addClass('yui-layout'); } } } this._setBodySize(set); if (set) { this.fireEvent('resize', { target: this, sizes: this._sizes }); } return this; }, /** * @private * @method _setupBodyElements * @description Sets up the main doc element when using the body as the main element. */ _setupBodyElements: function() { this._doc = Dom.get('layout-doc'); if (!this._doc) { this._doc = document.createElement('div'); this._doc.id = 'layout-doc'; if (document.body.firstChild) { document.body.insertBefore(this._doc, document.body.firstChild); } else { document.body.appendChild(this._doc); } } this._createUnits(); this._setBodySize(); Event.on(window, 'resize', this.resize, this, true); Dom.addClass(this._doc, 'yui-layout-doc'); }, /** * @private * @method _setupElements * @description Sets up the main doc element when not using the body as the main element. */ _setupElements: function() { this._doc = this.getElementsByClassName('yui-layout-doc')[0]; if (!this._doc) { this._doc = document.createElement('div'); this.get('element').appendChild(this._doc); } this._createUnits(); this._setBodySize(); Dom.addClass(this._doc, 'yui-layout-doc'); }, /** * @private * @property _isBody * @description Flag to determine if we are using the body as the root element. * @type Boolean */ _isBody: null, /** * @private * @property _doc * @description Reference to the root element * @type HTMLElement */ _doc: null, /** * @private * @method init * @description The Layout class' initialization method */ init: function(p_oElement, p_oAttributes) { YAHOO.log('init', 'info', 'Layout'); this._zIndex = 0; Layout.superclass.init.call(this, p_oElement, p_oAttributes); if (this.get('parent')) { this._zIndex = this.get('parent')._zIndex + 10; } this._sizes = {}; this._units = {}; var id = p_oElement; if (!Lang.isString(id)) { id = Dom.generateId(id); } Layout._instances[id] = this; }, /** * @method render * @description This method starts the render process, applying classnames and creating elements * @return {<a href="YAHOO.widget.Layout.html">YAHOO.widget.Layout</a>} The Layout instance */ render: function() { YAHOO.log('Render', 'info', 'Layout'); this._stamp(); var el = this.get('element'); if (el && el.tagName && (el.tagName.toLowerCase() == 'body')) { this._isBody = true; Dom.addClass(document.body, 'yui-layout'); if (Dom.hasClass(document.body, 'yui-skin-sam')) { //Move the class up so we can have a css chain Dom.addClass(document.documentElement, 'yui-skin-sam'); Dom.removeClass(document.body, 'yui-skin-sam'); } this._setupBodyElements(); } else { this._isBody = false; this.addClass('yui-layout'); this._setupElements(); } this.resize(); this._rendered = true; this.fireEvent('render'); return this; }, /** * @private * @method _stamp * @description Stamps the root node with a secure classname for ease of use. Also sets the this.browser.standardsMode variable. */ _stamp: function() { if (document.compatMode == 'CSS1Compat') { this.browser.standardsMode = true; } if (window.location.href.toLowerCase().indexOf("https") === 0) { Dom.addClass(document.documentElement, 'secure'); this.browser.secure = true; } }, /** * @private * @method initAttributes * @description Processes the config */ initAttributes: function(attr) { Layout.superclass.initAttributes.call(this, attr); /** * @attribute units * @description An array of config definitions for the LayoutUnits to add to this layout * @type Array */ this.setAttributeConfig('units', { writeOnce: true, validator: YAHOO.lang.isArray, value: attr.units || [] }); /** * @attribute minHeight * @description The minimum height in pixels * @type Number */ this.setAttributeConfig('minHeight', { value: attr.minHeight || false, validator: YAHOO.lang.isNumber }); /** * @attribute minWidth * @description The minimum width in pixels * @type Number */ this.setAttributeConfig('minWidth', { value: attr.minWidth || false, validator: YAHOO.lang.isNumber }); /** * @attribute height * @description The height in pixels * @type Number */ this.setAttributeConfig('height', { value: attr.height || false, validator: YAHOO.lang.isNumber, method: function(h) { this.setStyle('height', h + 'px'); } }); /** * @attribute width * @description The width in pixels * @type Number */ this.setAttributeConfig('width', { value: attr.width || false, validator: YAHOO.lang.isNumber, method: function(w) { this.setStyle('width', w + 'px'); } }); /** * @attribute parent * @description If this layout is to be used as a child of another Layout instance, this config will bind the resize events together. * @type Object YAHOO.widget.Layout */ this.setAttributeConfig('parent', { writeOnce: true, value: attr.parent || false, method: function(p) { if (p) { p.on('resize', this.resize, this, true); } } }); }, /** * @method destroy * @description Removes this layout from the page and destroys all units that it contains. This will destroy all data inside the layout and it's children. */ destroy: function() { var par = this.get('parent'); if (par) { par.removeListener('resize', this.resize, this, true); } Event.removeListener(window, 'resize', this.resize, this, true); this.unsubscribeAll(); for (var u in this._units) { if (Lang.hasOwnProperty(this._units, u)) { if (this._units[u]) { this._units[u].destroy(true); } } } Event.purgeElement(this.get('element')); this.get('parentNode').removeChild(this.get('element')); delete YAHOO.widget.Layout._instances[this.get('id')]; //Brutal Object Destroy for (var i in this) { if (Lang.hasOwnProperty(this, i)) { this[i] = null; delete this[i]; } } if (par) { par.resize(); } }, /** * @method toString * @description Returns a string representing the Layout. * @return {String} */ toString: function() { if (this.get) { return 'Layout #' + this.get('id'); } return 'Layout'; } }); /** * @event resize * @description Fired when this.resize is called * @type YAHOO.util.CustomEvent */ /** * @event startResize * @description Fired when the Resize Utility for a Unit fires it's startResize Event. * @type YAHOO.util.CustomEvent */ /** * @event beforeResize * @description Firef at the beginning of the resize method. If you return false, the resize is cancelled. * @type YAHOO.util.CustomEvent */ /** * @event render * @description Fired after the render method completes. * @type YAHOO.util.CustomEvent */ YAHOO.widget.Layout = Layout;})();/** * @description <p>Provides a fixed position unit containing a header, body and footer for use with a YAHOO.widget.Layout instance.</p> * @namespace YAHOO.widget * @requires yahoo, dom, element, event, layout * @optional animation, dragdrop, selector * @beta */(function() { var Dom = YAHOO.util.Dom, Sel = YAHOO.util.Selector, Event = YAHOO.util.Event, Lang = YAHOO.lang; /** * @constructor * @class LayoutUnit * @extends YAHOO.util.Element * @description <p>Provides a fixed position unit containing a header, body and footer for use with a YAHOO.widget.Layout instance.</p> * @param {String/HTMLElement} el The element to make a unit. * @param {Object} attrs Object liternal containing configuration parameters. */ var LayoutUnit = function(el, config) { var oConfig = { element: el, attributes: config || {} }; LayoutUnit.superclass.constructor.call(this, oConfig.element, oConfig.attributes); }; /** * @private * @static * @property _instances * @description Internal hash table for all layout unit instances * @type Object */ LayoutUnit._instances = {};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -