📄 container.js
字号:
*/ this.unsubscribeFromConfigEvent = function(key, handler, obj) { key = key.toLowerCase(); var property = config[key]; if (typeof property != 'undefined' && property.event) { return property.event.unsubscribe(handler, obj); } else { return false; } }; /** * Returns a string representation of the Config object * @method toString * @return {String} The Config object in string format. */ this.toString = function() { var output = "Config"; if (this.owner) { output += " [" + this.owner.toString() + "]"; } return output; }; /** * Returns a string representation of the Config object's current CustomEvent queue * @method outputEventQueue * @return {String} The string list of CustomEvents currently queued for execution */ this.outputEventQueue = function() { var output = ""; for (var q=0;q<eventQueue.length;q++) { var queueItem = eventQueue[q]; if (queueItem) { output += queueItem[0] + "=" + queueItem[1] + ", "; } } return output; };};/*** Checks to determine if a particular function/Object pair are already subscribed to the specified CustomEvent* @method YAHOO.util.Config.alreadySubscribed* @static* @param {YAHOO.util.CustomEvent} evt The CustomEvent for which to check the subscriptions* @param {Function} fn The function to look for in the subscribers list* @param {Object} obj The execution scope Object for the subscription* @return {Boolean} true, if the function/Object pair is already subscribed to the CustomEvent passed in*/YAHOO.util.Config.alreadySubscribed = function(evt, fn, obj) { for (var e=0;e<evt.subscribers.length;e++) { var subsc = evt.subscribers[e]; if (subsc && subsc.obj == obj && subsc.fn == fn) { return true; } } return false;};/*** The Container family of components is designed to enable developers to create different kinds of content-containing modules on the web. Module and Overlay are the most basic containers, and they can be used directly or extended to build custom containers. Also part of the Container family are four UI controls that extend Module and Overlay: Tooltip, Panel, Dialog, and SimpleDialog.* @module container* @title Container* @requires yahoo,dom,event,dragdrop,animation*//*** Module is a JavaScript representation of the Standard Module Format. Standard Module Format is a simple standard for markup containers where child nodes representing the header, body, and footer of the content are denoted using the CSS classes "hd", "bd", and "ft" respectively. Module is the base class for all other classes in the YUI Container package.* @namespace YAHOO.widget* @class Module* @constructor* @param {String} el The element ID representing the Module <em>OR</em>* @param {HTMLElement} el The element representing the Module* @param {Object} userConfig The configuration Object literal containing the configuration that should be set for this module. See configuration documentation for more details.*/YAHOO.widget.Module = function(el, userConfig) { if (el) { this.init(el, userConfig); }};/*** Constant representing the prefix path to use for non-secure images* @property YAHOO.widget.Module.IMG_ROOT* @static* @final* @type String*/YAHOO.widget.Module.IMG_ROOT = "http://us.i1.yimg.com/us.yimg.com/i/";/*** Constant representing the prefix path to use for securely served images* @property YAHOO.widget.Module.IMG_ROOT_SSL* @static* @final* @type String*/YAHOO.widget.Module.IMG_ROOT_SSL = "https://a248.e.akamai.net/sec.yimg.com/i/";/*** Constant for the default CSS class name that represents a Module* @property YAHOO.widget.Module.CSS_MODULE* @static* @final* @type String*/YAHOO.widget.Module.CSS_MODULE = "module";/*** Constant representing the module header* @property YAHOO.widget.Module.CSS_HEADER* @static* @final* @type String*/YAHOO.widget.Module.CSS_HEADER = "hd";/*** Constant representing the module body* @property YAHOO.widget.Module.CSS_BODY* @static* @final* @type String*/YAHOO.widget.Module.CSS_BODY = "bd";/*** Constant representing the module footer* @property YAHOO.widget.Module.CSS_FOOTER* @static* @final* @type String*/YAHOO.widget.Module.CSS_FOOTER = "ft";/*** Constant representing the url for the "src" attribute of the iframe used to monitor changes to the browser's base font size* @property YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL* @static* @final* @type String*/YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL = "javascript:false;";/*** Singleton CustomEvent fired when the font size is changed in the browser.* Opera's "zoom" functionality currently does not support text size detection.* @event YAHOO.widget.Module.textResizeEvent*/ YAHOO.widget.Module.textResizeEvent = new YAHOO.util.CustomEvent("textResize");YAHOO.widget.Module.prototype = { /** * The class's constructor function * @property contructor * @type Function */ constructor : YAHOO.widget.Module, /** * The main module element that contains the header, body, and footer * @property element * @type HTMLElement */ element : null, /** * The header element, denoted with CSS class "hd" * @property header * @type HTMLElement */ header : null, /** * The body element, denoted with CSS class "bd" * @property body * @type HTMLElement */ body : null, /** * The footer element, denoted with CSS class "ft" * @property footer * @type HTMLElement */ footer : null, /** * The id of the element * @property id * @type String */ id : null, /** * The String representing the image root * @property imageRoot * @type String */ imageRoot : YAHOO.widget.Module.IMG_ROOT, /** * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class. * @method initEvents */ initEvents : function() { /** * CustomEvent fired prior to class initalization. * @event beforeInitEvent * @param {class} classRef class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module) */ this.beforeInitEvent = new YAHOO.util.CustomEvent("beforeInit"); /** * CustomEvent fired after class initalization. * @event initEvent * @param {class} classRef class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module) */ this.initEvent = new YAHOO.util.CustomEvent("init"); /** * CustomEvent fired when the Module is appended to the DOM * @event appendEvent */ this.appendEvent = new YAHOO.util.CustomEvent("append"); /** * CustomEvent fired before the Module is rendered * @event beforeRenderEvent */ this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender"); /** * CustomEvent fired after the Module is rendered * @event renderEvent */ this.renderEvent = new YAHOO.util.CustomEvent("render"); /** * CustomEvent fired when the header content of the Module is modified * @event changeHeaderEvent * @param {String/HTMLElement} content String/element representing the new header content */ this.changeHeaderEvent = new YAHOO.util.CustomEvent("changeHeader"); /** * CustomEvent fired when the body content of the Module is modified * @event changeBodyEvent * @param {String/HTMLElement} content String/element representing the new body content */ this.changeBodyEvent = new YAHOO.util.CustomEvent("changeBody"); /** * CustomEvent fired when the footer content of the Module is modified * @event changeFooterEvent * @param {String/HTMLElement} content String/element representing the new footer content */ this.changeFooterEvent = new YAHOO.util.CustomEvent("changeFooter"); /** * CustomEvent fired when the content of the Module is modified * @event changeContentEvent */ this.changeContentEvent = new YAHOO.util.CustomEvent("changeContent"); /** * CustomEvent fired when the Module is destroyed * @event destroyEvent */ this.destroyEvent = new YAHOO.util.CustomEvent("destroy"); /** * CustomEvent fired before the Module is shown * @event beforeShowEvent */ this.beforeShowEvent = new YAHOO.util.CustomEvent("beforeShow"); /** * CustomEvent fired after the Module is shown * @event showEvent */ this.showEvent = new YAHOO.util.CustomEvent("show"); /** * CustomEvent fired before the Module is hidden * @event beforeHideEvent */ this.beforeHideEvent = new YAHOO.util.CustomEvent("beforeHide"); /** * CustomEvent fired after the Module is hidden * @event hideEvent */ this.hideEvent = new YAHOO.util.CustomEvent("hide"); }, /** * String representing the current user-agent platform * @property platform * @type String */ platform : function() { var ua = navigator.userAgent.toLowerCase(); if (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1) { return "windows"; } else if (ua.indexOf("macintosh") != -1) { return "mac"; } else { return false; } }(), /** * String representing the current user-agent browser * @property browser * @type String */ browser : function() { var ua = navigator.userAgent.toLowerCase(); if (ua.indexOf('opera')!=-1) { // Opera (check first in case of spoof) return 'opera'; } else if (ua.indexOf('msie 7')!=-1) { // IE7 return 'ie7'; } else if (ua.indexOf('msie') !=-1) { // IE return 'ie'; } else if (ua.indexOf('safari')!=-1) { // Safari (check before Gecko because it includes "like Gecko") return 'safari'; } else if (ua.indexOf('gecko') != -1) { // Gecko return 'gecko'; } else { return false; } }(), /** * Boolean representing whether or not the current browsing context is secure (https) * @property isSecure * @type Boolean */ isSecure : function() { if (window.location.href.toLowerCase().indexOf("https") === 0) { return true; } else { return false; } }(), /** * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class. */ initDefaultConfig : function() { // Add properties // /** * Specifies whether the Module is visible on the page. * @config visible * @type Boolean * @default true */ this.cfg.addProperty("visible", { value:true, handler:this.configVisible, validator:this.cfg.checkBoolean } ); /** * Object or array of objects representing the ContainerEffect classes that are active for animating the container. * @config effect * @type Object * @default null */ this.cfg.addProperty("effect", { suppressEvent:true, supercedes:["visible"] } ); /** * Specifies whether to create a special proxy iframe to monitor for user font resizing in the document * @config monitorresize * @type Boolean * @default true */ this.cfg.addProperty("monitorresize", { value:true, handler:this.configMonitorResize } ); }, /** * The Module class's initialization method, which is executed for Module and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present. * @method init * @param {String} el The element ID representing the Module <em>OR</em> * @param {HTMLElement} el The element representing the Module * @param {Object} userConfig The configuration Object literal containing the configuration that should be set for this module. See configuration documentation for more details. */ init : function(el, userConfig) { this.initEvents(); this.beforeInitEvent.fire(YAHOO.widget.Module); /** * The Module's Config object used for monitoring configuration properties. * @property cfg * @type YAHOO.util.Config */ this.cfg = new YAHOO.util.Config(this); if (this.isSecure) { this.imageRoot = YAHOO.widget.Module.IMG_ROOT_SSL; } if (typeof el == "string") { var elId = el; el = document.getElementById(el); if (! el) { el = document.createElement("DIV"); el.id = elId; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -