home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Narzedzia / AIMP2 / aimp_2.61.583.exe / $TEMP / YandexPackSetup.msi / fil8049A1C41F24F9814B6309E2B851A81F < prev    next >
Text File  |  2010-07-12  |  2KB  |  62 lines

  1.  
  2. XB.UI.Behaviour.Button = XB.UI.Behaviour.IWithAction.extend({
  3.     nodeName: "toolbarbutton",
  4.     
  5.     appendDropDownMenu: function XBUIButton_appendDropDownMenu(menuBehaviour) {
  6.         this._dropDownMenu = menuBehaviour;
  7.         this._updateButtonType();
  8.     },
  9.     
  10.     removeDropDownMenu: function XBUIButton_appendDropDownMenu(menuBehaviour) {
  11.         if (this._dropDownMenu == menuBehaviour) {
  12.             delete this._dropDownMenu;
  13.             this._updateButtonType();
  14.         }
  15.     },
  16.     
  17.     addAction: function (action) {
  18.         this.base(action);
  19.         this._updateButtonType();
  20.     },
  21.     
  22.     removeAction: function (action) {
  23.         this.base(action);
  24.         this._updateButtonType();
  25.     },
  26.     
  27.     addURL: function (url) {
  28.         this.base(url);
  29.         this._updateButtonType();
  30.     },
  31.     
  32.     removeURL: function (url) {
  33.         this.base(url);
  34.         this._updateButtonType();
  35.     },
  36.     
  37.     onAction: function(event) {
  38.         this.base(event);
  39.         
  40.         if (event.type != "command")
  41.             return;
  42.         
  43.         if (!this._action && !this._url && this._dropDownMenu) {
  44.             let btnBox = this.node.boxObject;
  45.             if (btnBox) {
  46.                 let btnX = btnBox.x;
  47.                 let btnY = btnBox.y;
  48.                 this._dropDownMenu.node.openPopup(null, "", btnX, btnY + btnBox.height, false, false);
  49.             }
  50.             else
  51.                 this._dropDownMenu.node.openPopup(this.node, "after_start", 0, 0, false, false);
  52.         }
  53.     },
  54.     
  55.     _updateButtonType: function () {
  56.         if ((this._action || this._url) && this._dropDownMenu)
  57.             this.node.setAttribute("type", "menu-button");
  58.         else
  59.             this.node.removeAttribute("type");
  60.     }
  61. });
  62.