| 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 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 button.addEventListener("click", onClickBound, this); | 603 button.addEventListener("click", onClickBound, this); |
| 604 this._buttons.push(button); | 604 this._buttons.push(button); |
| 605 } | 605 } |
| 606 | 606 |
| 607 this._currentStateSetting = currentStateSetting; | 607 this._currentStateSetting = currentStateSetting; |
| 608 this._lastStateSetting = lastStateSetting; | 608 this._lastStateSetting = lastStateSetting; |
| 609 this._stateChangedCallback = stateChangedCallback; | 609 this._stateChangedCallback = stateChangedCallback; |
| 610 this.setLongClickOptionsEnabled(this._createOptions.bind(this)); | 610 this.setLongClickOptionsEnabled(this._createOptions.bind(this)); |
| 611 | 611 |
| 612 this._currentState = null; | 612 this._currentState = null; |
| 613 this.toggleState(this._defaultState()); | |
| 614 } | 613 } |
| 615 | 614 |
| 616 WebInspector.StatusBarStatesSettingButton.prototype = { | 615 WebInspector.StatusBarStatesSettingButton.prototype = { |
| 617 /** | 616 /** |
| 618 * @param {!WebInspector.Event} e | 617 * @param {!WebInspector.Event} e |
| 619 */ | 618 */ |
| 620 _onClick: function(e) | 619 _onClick: function(e) |
| 621 { | 620 { |
| 622 this.toggleState(e.target.state); | 621 this.toggleState(e.target.state); |
| 623 }, | 622 }, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 636 this._currentStateSetting.set(this._currentState); | 635 this._currentStateSetting.set(this._currentState); |
| 637 | 636 |
| 638 if (this._stateChangedCallback) | 637 if (this._stateChangedCallback) |
| 639 this._stateChangedCallback(state); | 638 this._stateChangedCallback(state); |
| 640 | 639 |
| 641 var defaultState = this._defaultState(); | 640 var defaultState = this._defaultState(); |
| 642 this.state = defaultState; | 641 this.state = defaultState; |
| 643 this.title = this._buttons[this._states.indexOf(defaultState)].title; | 642 this.title = this._buttons[this._states.indexOf(defaultState)].title; |
| 644 }, | 643 }, |
| 645 | 644 |
| 645 toggleInitialState: function() |
| 646 { |
| 647 if (this._currentState === null) |
| 648 this.toggleState(this._defaultState()); |
| 649 }, |
| 650 |
| 646 /** | 651 /** |
| 647 * @return {string} | 652 * @return {string} |
| 648 */ | 653 */ |
| 649 _defaultState: function() | 654 _defaultState: function() |
| 650 { | 655 { |
| 651 // Not yet initialized - load from setting. | 656 // Not yet initialized - load from setting. |
| 652 if (!this._currentState) { | 657 if (!this._currentState) { |
| 653 var state = this._currentStateSetting.get(); | 658 var state = this._currentStateSetting.get(); |
| 654 return this._states.indexOf(state) >= 0 ? state : this._states[0]; | 659 return this._states.indexOf(state) >= 0 ? state : this._states[0]; |
| 655 } | 660 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 670 var options = []; | 675 var options = []; |
| 671 for (var index = 0; index < this._states.length; index++) { | 676 for (var index = 0; index < this._states.length; index++) { |
| 672 if (this._states[index] !== this.state && this._states[index] !== th
is._currentState) | 677 if (this._states[index] !== this.state && this._states[index] !== th
is._currentState) |
| 673 options.push(this._buttons[index]); | 678 options.push(this._buttons[index]); |
| 674 } | 679 } |
| 675 return options; | 680 return options; |
| 676 }, | 681 }, |
| 677 | 682 |
| 678 __proto__: WebInspector.StatusBarButton.prototype | 683 __proto__: WebInspector.StatusBarButton.prototype |
| 679 } | 684 } |
| OLD | NEW |