| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 | 50 |
| 51 /** | 51 /** |
| 52 * @param {!UI.Action} action | 52 * @param {!UI.Action} action |
| 53 * @param {!Array<!UI.ToolbarButton>=} toggledOptions | 53 * @param {!Array<!UI.ToolbarButton>=} toggledOptions |
| 54 * @param {!Array<!UI.ToolbarButton>=} untoggledOptions | 54 * @param {!Array<!UI.ToolbarButton>=} untoggledOptions |
| 55 * @return {!UI.ToolbarItem} | 55 * @return {!UI.ToolbarItem} |
| 56 */ | 56 */ |
| 57 static createActionButton(action, toggledOptions, untoggledOptions) { | 57 static createActionButton(action, toggledOptions, untoggledOptions) { |
| 58 var button = new UI.ToolbarToggle(action.title(), action.icon(), action.togg
ledIcon()); | 58 var button = new UI.ToolbarToggle(action.title(), action.icon(), action.togg
ledIcon()); |
| 59 button.setToggleWithRedColor(action.toggleWithRedColor()); | 59 button.setToggleWithRedColor(action.toggleWithRedColor()); |
| 60 button.addEventListener(UI.ToolbarButton.Events.Click, action.execute, actio
n); | 60 button.addEventListener('click', action.execute, action); |
| 61 action.addEventListener(UI.Action.Events.Enabled, enabledChanged); | 61 action.addEventListener(UI.Action.Events.Enabled, enabledChanged); |
| 62 action.addEventListener(UI.Action.Events.Toggled, toggled); | 62 action.addEventListener(UI.Action.Events.Toggled, toggled); |
| 63 /** @type {?UI.LongClickController} */ | 63 /** @type {?UI.LongClickController} */ |
| 64 var longClickController = null; | 64 var longClickController = null; |
| 65 /** @type {?Array<!UI.ToolbarButton>} */ | 65 /** @type {?Array<!UI.ToolbarButton>} */ |
| 66 var longClickButtons = null; | 66 var longClickButtons = null; |
| 67 /** @type {?Element} */ | 67 /** @type {?Element} */ |
| 68 var longClickGlyph = null; | 68 var longClickGlyph = null; |
| 69 toggled(); | 69 toggled(); |
| 70 return button; | 70 return button; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 100 longClickGlyph.remove(); | 100 longClickGlyph.remove(); |
| 101 longClickGlyph = null; | 101 longClickGlyph = null; |
| 102 longClickButtons = null; | 102 longClickButtons = null; |
| 103 } | 103 } |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 | 106 |
| 107 function showOptions() { | 107 function showOptions() { |
| 108 var buttons = longClickButtons.slice(); | 108 var buttons = longClickButtons.slice(); |
| 109 var mainButtonClone = new UI.ToolbarToggle(action.title(), action.icon(),
action.toggledIcon()); | 109 var mainButtonClone = new UI.ToolbarToggle(action.title(), action.icon(),
action.toggledIcon()); |
| 110 mainButtonClone.addEventListener(UI.ToolbarButton.Events.Click, clicked); | 110 mainButtonClone.addEventListener('click', clicked); |
| 111 | 111 |
| 112 /** | 112 /** |
| 113 * @param {!Common.Event} event | 113 * @param {!Common.Event} event |
| 114 */ | 114 */ |
| 115 function clicked(event) { | 115 function clicked(event) { |
| 116 button._clicked(/** @type {!Event} */ (event.data)); | 116 button._clicked(/** @type {!Event} */ (event.data)); |
| 117 } | 117 } |
| 118 | 118 |
| 119 mainButtonClone.setToggled(action.toggled()); | 119 mainButtonClone.setToggled(action.toggled()); |
| 120 buttons.push(mainButtonClone); | 120 buttons.push(mainButtonClone); |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 var dropdownArrowIcon = UI.Icon.create('smallicon-dropdown-arrow', 'toolbar-
dropdown-arrow'); | 504 var dropdownArrowIcon = UI.Icon.create('smallicon-dropdown-arrow', 'toolbar-
dropdown-arrow'); |
| 505 this.element.appendChild(dropdownArrowIcon); | 505 this.element.appendChild(dropdownArrowIcon); |
| 506 if (width) | 506 if (width) |
| 507 this.element.style.width = width + 'px'; | 507 this.element.style.width = width + 'px'; |
| 508 } | 508 } |
| 509 | 509 |
| 510 /** | 510 /** |
| 511 * @param {!Event} event | 511 * @param {!Event} event |
| 512 */ | 512 */ |
| 513 _clicked(event) { | 513 _clicked(event) { |
| 514 this.dispatchEventToListeners(UI.ToolbarButton.Events.Click, event); | 514 var defaultPrevented = this.dispatchEventToListeners('click', event); |
| 515 event.consume(defaultPrevented); |
| 515 } | 516 } |
| 516 | 517 |
| 517 /** | 518 /** |
| 518 * @param {!Event} event | 519 * @param {!Event} event |
| 519 */ | 520 */ |
| 520 _mouseDown(event) { | 521 _mouseDown(event) { |
| 521 this.dispatchEventToListeners(UI.ToolbarButton.Events.MouseDown, event); | 522 this.dispatchEventToListeners('mousedown', event); |
| 522 } | 523 } |
| 523 | 524 |
| 524 /** | 525 /** |
| 525 * @param {!Event} event | 526 * @param {!Event} event |
| 526 */ | 527 */ |
| 527 _mouseUp(event) { | 528 _mouseUp(event) { |
| 528 this.dispatchEventToListeners(UI.ToolbarButton.Events.MouseUp, event); | 529 this.dispatchEventToListeners('mouseup', event); |
| 529 } | 530 } |
| 530 }; | 531 }; |
| 531 | 532 |
| 532 UI.ToolbarButton.Events = { | |
| 533 Click: Symbol('Click'), | |
| 534 MouseDown: Symbol('MouseDown'), | |
| 535 MouseUp: Symbol('MouseUp') | |
| 536 }; | |
| 537 | |
| 538 /** | 533 /** |
| 539 * @unrestricted | 534 * @unrestricted |
| 540 */ | 535 */ |
| 541 UI.ToolbarInput = class extends UI.ToolbarItem { | 536 UI.ToolbarInput = class extends UI.ToolbarItem { |
| 542 /** | 537 /** |
| 543 * @param {string=} placeholder | 538 * @param {string=} placeholder |
| 544 * @param {number=} growFactor | 539 * @param {number=} growFactor |
| 545 */ | 540 */ |
| 546 constructor(placeholder, growFactor) { | 541 constructor(placeholder, growFactor) { |
| 547 super(createElementWithClass('input', 'toolbar-item')); | 542 super(createElementWithClass('input', 'toolbar-item')); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 567 value() { | 562 value() { |
| 568 return this.element.value; | 563 return this.element.value; |
| 569 } | 564 } |
| 570 | 565 |
| 571 _onChangeCallback() { | 566 _onChangeCallback() { |
| 572 this.dispatchEventToListeners(UI.ToolbarInput.Event.TextChanged, this.elemen
t.value); | 567 this.dispatchEventToListeners(UI.ToolbarInput.Event.TextChanged, this.elemen
t.value); |
| 573 } | 568 } |
| 574 }; | 569 }; |
| 575 | 570 |
| 576 UI.ToolbarInput.Event = { | 571 UI.ToolbarInput.Event = { |
| 577 TextChanged: Symbol('TextChanged') | 572 TextChanged: 'TextChanged' |
| 578 }; | 573 }; |
| 579 | 574 |
| 580 /** | 575 /** |
| 581 * @unrestricted | 576 * @unrestricted |
| 582 */ | 577 */ |
| 583 UI.ToolbarToggle = class extends UI.ToolbarButton { | 578 UI.ToolbarToggle = class extends UI.ToolbarButton { |
| 584 /** | 579 /** |
| 585 * @param {string} title | 580 * @param {string} title |
| 586 * @param {string=} glyph | 581 * @param {string=} glyph |
| 587 * @param {string=} toggledGlyph | 582 * @param {string=} toggledGlyph |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 return this.inputElement.checked; | 896 return this.inputElement.checked; |
| 902 } | 897 } |
| 903 | 898 |
| 904 /** | 899 /** |
| 905 * @param {boolean} value | 900 * @param {boolean} value |
| 906 */ | 901 */ |
| 907 setChecked(value) { | 902 setChecked(value) { |
| 908 this.inputElement.checked = value; | 903 this.inputElement.checked = value; |
| 909 } | 904 } |
| 910 }; | 905 }; |
| OLD | NEW |