3 Copyright 2012 Yahoo! Inc. All rights reserved.
4 Licensed under the BSD License.
5 http://yuilibrary.com/license/
7 YUI.add('button-plugin', function(Y) {
12 * @module button-plugin
18 * @param config {Object} Configuration object
21 function ButtonPlugin(config) {
22 ButtonPlugin.superclass.constructor.apply(this, arguments);
25 Y.extend(ButtonPlugin, Y.ButtonCore, {
28 * @method _afterNodeGet
29 * @param name {string}
32 _afterNodeGet: function (name) {
33 // TODO: point to method (_uiSetLabel, etc) instead of getter/setter
34 var ATTRS = this.constructor.ATTRS,
35 fn = ATTRS[name] && ATTRS[name].getter && this[ATTRS[name].getter];
38 return new Y.Do.AlterReturn('get ' + name, fn.call(this));
43 * @method _afterNodeSet
44 * @param name {String}
48 _afterNodeSet: function (name, val) {
49 var ATTRS = this.constructor.ATTRS,
50 fn = ATTRS[name] && ATTRS[name].setter && this[ATTRS[name].setter];
59 * @param config {Object}
62 _initNode: function(config) {
63 var node = config.host;
66 Y.Do.after(this._afterNodeGet, node, 'get', this);
67 Y.Do.after(this._afterNodeSet, node, 'set', this);
75 // Nothing to do, but things are happier with it here
81 * Attribute configuration.
88 ATTRS: Y.merge(Y.ButtonCore.ATTRS),
91 * Name of this component.
100 * Namespace of this component.
112 * @description A factory that plugs a Y.Node instance with Y.Plugin.Button
113 * @param node {Object}
114 * @param config {Object}
115 * @returns {Object} A plugged Y.Node instance
118 ButtonPlugin.createNode = function(node, config) {
121 if (node && !config) {
122 if (! (node.nodeType || node.getDOMNode || typeof node == 'string')) {
124 node = config.srcNode;
128 config = config || {};
129 template = config.template || Y.Plugin.Button.prototype.TEMPLATE;
130 node = node || config.srcNode || Y.DOM.create(template);
132 return Y.one(node).plug(Y.Plugin.Button, config);
135 Y.namespace('Plugin').Button = ButtonPlugin;
138 }, '3.5.1' ,{requires:['button-core', 'cssbutton', 'node-pluginhost']});