home *** CD-ROM | disk | FTP | other *** search
-
- XB.UI.Behaviour.Button = XB.UI.Behaviour.IWithAction.extend({
- nodeName: "toolbarbutton",
-
- appendDropDownMenu: function XBUIButton_appendDropDownMenu(menuBehaviour) {
- this._dropDownMenu = menuBehaviour;
- this._updateButtonType();
- },
-
- removeDropDownMenu: function XBUIButton_appendDropDownMenu(menuBehaviour) {
- if (this._dropDownMenu == menuBehaviour) {
- delete this._dropDownMenu;
- this._updateButtonType();
- }
- },
-
- addAction: function (action) {
- this.base(action);
- this._updateButtonType();
- },
-
- removeAction: function (action) {
- this.base(action);
- this._updateButtonType();
- },
-
- addURL: function (url) {
- this.base(url);
- this._updateButtonType();
- },
-
- removeURL: function (url) {
- this.base(url);
- this._updateButtonType();
- },
-
- onAction: function(event) {
- this.base(event);
-
- if (event.type != "command")
- return;
-
- if (!this._action && !this._url && this._dropDownMenu) {
- let btnBox = this.node.boxObject;
- if (btnBox) {
- let btnX = btnBox.x;
- let btnY = btnBox.y;
- this._dropDownMenu.node.openPopup(null, "", btnX, btnY + btnBox.height, false, false);
- }
- else
- this._dropDownMenu.node.openPopup(this.node, "after_start", 0, 0, false, false);
- }
- },
-
- _updateButtonType: function () {
- if ((this._action || this._url) && this._dropDownMenu)
- this.node.setAttribute("type", "menu-button");
- else
- this.node.removeAttribute("type");
- }
- });
-