Widget-Buttons.js revision 24239fbd51e8a8f750ee83979f39b19e3c9150ec
/**
* "widget-autohide" is a widget-level plugin that allows widgets to be hidden
* when certain events occur.
*
* By default, the widget will be hidden when the following events occur
* <ul>
* <li>something is clicked outside the widget's bounding box</li>
* <li>something is focussed outside the widget's bounding box</li>
* <li>the escape key is pressed</li>
* </ul>
*
* Events can be added or removed from this list through the "hideOn" attribute.
* The following code demonstrates how to do this. Suppose I want to close the widget when
* another node is resized.
* <code>widget.plug(Y.Plugin.Autohide, {hideOn: [{node: resize, eventName: 'resize:end'}]});</code>.
* The hideOn attribute must be an array of objects. For more details on this attribute, refer to the API docs for it.
*
* This module was originally part of the overlay-extras package by Eric Ferraiuolo but was promoted and abstracted
* into the core library.
*
* @module widget-autohide
* @author eferraiuolo, tilomitra
* @since 3.4.0
*/
var BOUNDING_BOX = "boundingBox",
VISIBLE = "visible",
CLICK = "click",
RENDER_UI = "renderUI",
BIND_UI = "bindUI",
SYNC_UI = "syncUI",
BTN = "button",
BTN_CONTENT = "button-content",
BTN_WRAPPER = "button-wrapper",
BUTTON_CHANGE = "buttonsChange",
function WidgetButtons(config) {
}
WidgetButtons.ATTRS = {
buttons: {
//available options are: value, href, defaultFn
value: [
{
defaultFn: function(e) {
alert("Close was clicked");
},
}
// {
// value: "Ok",
// defaultFn: function(e) {
// alert("Ok was clicked");
// },
// section: Y.WidgetStdMod.FOOTER
// }
],
}
};
};
defaultTemplate: "<a href={href} class='"+WidgetButtons.BUTTON_CLASS_NAMES.button+"'><span class='"+WidgetButtons.BUTTON_CLASS_NAMES.Content+"'>{value}</a>",
};
// *** Instance Members *** //
_hdBtnNode : null,
_ftBtnNode : null,
_buttonsArray : [],
_uiHandlesButtons : [],
_renderUIButtons : function () {
this._removeButtonNode(true,true);
this._createButtons();
},
_bindUIButtons : function () {
var self = this;
Y.each(this._buttonsArray, function(o) {
});
},
_syncUIButtons : function () {
if (this._hdBtnNode.hasChildNodes()) {
}
if (this._ftBtnNode.hasChildNodes()) {
}
},
_createButtons : function () {
template = '',
html = '',
node,
self = this;
});
//create Y.Node instance of button
//push the node onto an array of all the buttons
//append it to the wrapper node
}
}
else {
Y.log("Warning: One of the buttons did not have the specified sections property.");
}
});
return true;
},
//object with properties node, cb
_hookEventsToButton : function (o) {
},
_afterButtonsChange : function (e) {
Y.log(e);
this._detachEventsFromButtons();
this._renderUIButtons();
this._bindUIButtons();
this._syncUIButtons();
},
if (fromHd && this._hdBtnNode) {
this._hdBtnNode.remove();
}
}
if (fromFt && this._ftBtnNode) {
this._ftBtnNode.remove();
}
}
},
_detachEventsFromButtons : function () {
Y.each(this._uiHandlesButtons, function(h){
h.detach();
});
this._uiHandlesButtons = [];
}
}