src/cm/media/js/lib/yui/yui_3.10.3/build/button-plugin/button-plugin-debug.js
changeset 525 89ef5ed3c48b
equal deleted inserted replaced
524:322d0feea350 525:89ef5ed3c48b
       
     1 /*
       
     2 YUI 3.10.3 (build 2fb5187)
       
     3 Copyright 2013 Yahoo! Inc. All rights reserved.
       
     4 Licensed under the BSD License.
       
     5 http://yuilibrary.com/license/
       
     6 */
       
     7 
       
     8 YUI.add('button-plugin', function (Y, NAME) {
       
     9 
       
    10 /**
       
    11 * A Button Plugin
       
    12 *
       
    13 * @module button-plugin
       
    14 * @since 3.5.0
       
    15 */
       
    16 
       
    17 /**
       
    18 * @class Button
       
    19 * @param config {Object} Configuration object
       
    20 * @extends ButtonCore
       
    21 * @constructor
       
    22 * @namespace Plugin
       
    23 */
       
    24 function ButtonPlugin() {
       
    25     ButtonPlugin.superclass.constructor.apply(this, arguments);
       
    26 }
       
    27 
       
    28 Y.extend(ButtonPlugin, Y.ButtonCore, {
       
    29     
       
    30     /**
       
    31     * @method _afterNodeGet
       
    32     * @param name {string}
       
    33     * @private
       
    34     */
       
    35     _afterNodeGet: function (name) {
       
    36         // TODO: point to method (_uiSetLabel, etc) instead of getter/setter
       
    37         var ATTRS = this.constructor.ATTRS,
       
    38             fn = ATTRS[name] && ATTRS[name].getter && this[ATTRS[name].getter];
       
    39             
       
    40         if (fn) {
       
    41             return new Y.Do.AlterReturn('get ' + name, fn.call(this));
       
    42         }
       
    43     },
       
    44 
       
    45     /**
       
    46     * @method _afterNodeSet
       
    47     * @param name {String}
       
    48     * @param val {String}
       
    49     * @private
       
    50     */
       
    51     _afterNodeSet: function (name, val) {
       
    52         var ATTRS = this.constructor.ATTRS,
       
    53             fn = ATTRS[name] && ATTRS[name].setter && this[ATTRS[name].setter];
       
    54             
       
    55         if (fn) {
       
    56             fn.call(this, val);
       
    57         }
       
    58     },
       
    59 
       
    60     /**
       
    61     * @method _initNode
       
    62     * @param config {Object}
       
    63     * @private
       
    64     */
       
    65     _initNode: function(config) {
       
    66         var node = config.host;
       
    67         this._host = node;
       
    68         
       
    69         Y.Do.after(this._afterNodeGet, node, 'get', this);
       
    70         Y.Do.after(this._afterNodeSet, node, 'set', this);
       
    71     },
       
    72 
       
    73     /**
       
    74     * @method destroy
       
    75     * @private
       
    76     */
       
    77     destroy: function(){
       
    78         // Nothing to do, but things are happier with it here
       
    79     }
       
    80     
       
    81 }, {
       
    82     
       
    83     /**
       
    84     * Attribute configuration.
       
    85     *
       
    86     * @property ATTRS
       
    87     * @type {Object}
       
    88     * @private
       
    89     * @static
       
    90     */
       
    91     ATTRS: Y.merge(Y.ButtonCore.ATTRS),
       
    92     
       
    93     /**
       
    94     * Name of this component.
       
    95     *
       
    96     * @property NAME
       
    97     * @type String
       
    98     * @static
       
    99     */
       
   100     NAME: 'buttonPlugin',
       
   101     
       
   102     /**
       
   103     * Namespace of this component.
       
   104     *
       
   105     * @property NS
       
   106     * @type String
       
   107     * @static
       
   108     */
       
   109     NS: 'button'
       
   110     
       
   111 });
       
   112 
       
   113 /**
       
   114 * @method createNode
       
   115 * @description A factory that plugs a Y.Node instance with Y.Plugin.Button
       
   116 * @param node {Object}
       
   117 * @param config {Object}
       
   118 * @return {Object} A plugged Y.Node instance
       
   119 * @public
       
   120 */
       
   121 ButtonPlugin.createNode = function(node, config) {
       
   122     var template;
       
   123 
       
   124     if (node && !config) {
       
   125         if (! (node.nodeType || node.getDOMNode || typeof node === 'string')) {
       
   126             config = node;
       
   127             node = config.srcNode;
       
   128         }
       
   129     }
       
   130 
       
   131     config   = config || {};
       
   132     template = config.template || Y.Plugin.Button.prototype.TEMPLATE;
       
   133     node     = node || config.srcNode || Y.DOM.create(template);
       
   134 
       
   135     return Y.one(node).plug(Y.Plugin.Button, config);
       
   136 };
       
   137 
       
   138 Y.namespace('Plugin').Button = ButtonPlugin;
       
   139 
       
   140 
       
   141 }, '3.10.3', {"requires": ["button-core", "cssbutton", "node-pluginhost"]});