Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: Source/devtools/front_end/ui/StatusBarButton.js

Issue 720223002: DevTools: only allow status bar items in status bars. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebaselined Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/devtools/front_end/ui/FilterBar.js ('k') | Source/devtools/front_end/ui/filter.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 /** 31 /**
32 * @constructor 32 * @constructor
33 * @extends {WebInspector.Object} 33 * @extends {WebInspector.Object}
34 * @param {string} elementType 34 * @param {!Element} element
35 */ 35 */
36 WebInspector.StatusBarItem = function(elementType) 36 WebInspector.StatusBarItem = function(element)
37 { 37 {
38 this.element = createElement(elementType); 38 this.element = element;
39 this.element.classList.add("status-bar-item");
39 this._enabled = true; 40 this._enabled = true;
40 this._visible = true; 41 this._visible = true;
41 } 42 }
42 43
43 WebInspector.StatusBarItem.prototype = { 44 WebInspector.StatusBarItem.prototype = {
44 /** 45 /**
45 * @param {boolean} value 46 * @param {boolean} value
46 */ 47 */
47 setEnabled: function(value) 48 setEnabled: function(value)
48 { 49 {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 } 81 }
81 82
82 /** 83 /**
83 * @constructor 84 * @constructor
84 * @extends {WebInspector.StatusBarItem} 85 * @extends {WebInspector.StatusBarItem}
85 * @param {!Array.<string>} counters 86 * @param {!Array.<string>} counters
86 * @param {string=} className 87 * @param {string=} className
87 */ 88 */
88 WebInspector.StatusBarCounter = function(counters, className) 89 WebInspector.StatusBarCounter = function(counters, className)
89 { 90 {
90 WebInspector.StatusBarItem.call(this, "div"); 91 WebInspector.StatusBarItem.call(this, createElementWithClass("div", "status- bar-counter hidden"));
91 this.element.className = "status-bar-item status-bar-counter hidden";
92 if (className) 92 if (className)
93 this.element.classList.add(className); 93 this.element.classList.add(className);
94 this.element.addEventListener("click", this._clicked.bind(this), false); 94 this.element.addEventListener("click", this._clicked.bind(this), false);
95 /** @type {!Array.<!{element: !Element, counter: string, value: number, titl e: string}>} */ 95 /** @type {!Array.<!{element: !Element, counter: string, value: number, titl e: string}>} */
96 this._counters = []; 96 this._counters = [];
97 for (var i = 0; i < counters.length; ++i) { 97 for (var i = 0; i < counters.length; ++i) {
98 var element = this.element.createChild("span", "status-bar-counter-item" ); 98 var element = this.element.createChild("span", "status-bar-counter-item" );
99 element.createChild("div", counters[i]); 99 element.createChild("div", counters[i]);
100 element.createChild("span"); 100 element.createChild("span");
101 this._counters.push({counter: counters[i], element: element, value: 0, t itle: ""}); 101 this._counters.push({counter: counters[i], element: element, value: 0, t itle: ""});
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 } 158 }
159 159
160 /** 160 /**
161 * @constructor 161 * @constructor
162 * @extends {WebInspector.StatusBarItem} 162 * @extends {WebInspector.StatusBarItem}
163 * @param {string} text 163 * @param {string} text
164 * @param {string=} className 164 * @param {string=} className
165 */ 165 */
166 WebInspector.StatusBarText = function(text, className) 166 WebInspector.StatusBarText = function(text, className)
167 { 167 {
168 WebInspector.StatusBarItem.call(this, "span"); 168 WebInspector.StatusBarItem.call(this, createElementWithClass("span", "status -bar-text"));
169 this.element.className = "status-bar-item status-bar-text";
170 if (className) 169 if (className)
171 this.element.classList.add(className); 170 this.element.classList.add(className);
172 this.element.textContent = text; 171 this.element.textContent = text;
173 } 172 }
174 173
175 WebInspector.StatusBarText.prototype = { 174 WebInspector.StatusBarText.prototype = {
176 /** 175 /**
177 * @param {string} text 176 * @param {string} text
178 */ 177 */
179 setText: function(text) 178 setText: function(text)
180 { 179 {
181 this.element.textContent = text; 180 this.element.textContent = text;
182 }, 181 },
183 182
184 __proto__: WebInspector.StatusBarItem.prototype 183 __proto__: WebInspector.StatusBarItem.prototype
185 } 184 }
186 185
187 /** 186 /**
188 * @constructor 187 * @constructor
189 * @extends {WebInspector.StatusBarItem} 188 * @extends {WebInspector.StatusBarItem}
190 * @param {string=} placeholder 189 * @param {string=} placeholder
191 * @param {number=} width 190 * @param {number=} width
192 */ 191 */
193 WebInspector.StatusBarInput = function(placeholder, width) 192 WebInspector.StatusBarInput = function(placeholder, width)
194 { 193 {
195 WebInspector.StatusBarItem.call(this, "input"); 194 WebInspector.StatusBarItem.call(this, createElementWithClass("input", "statu s-bar-item"));
196 this.element.className = "status-bar-item";
197 this.element.addEventListener("input", this._onChangeCallback.bind(this), fa lse); 195 this.element.addEventListener("input", this._onChangeCallback.bind(this), fa lse);
198 if (width) 196 if (width)
199 this.element.style.width = width + "px"; 197 this.element.style.width = width + "px";
200 if (placeholder) 198 if (placeholder)
201 this.element.setAttribute("placeholder", placeholder); 199 this.element.setAttribute("placeholder", placeholder);
202 this._value = ""; 200 this._value = "";
203 } 201 }
204 202
205 WebInspector.StatusBarInput.Event = { 203 WebInspector.StatusBarInput.Event = {
206 TextChanged: "TextChanged" 204 TextChanged: "TextChanged"
(...skipping 27 matching lines...) Expand all
234 232
235 /** 233 /**
236 * @constructor 234 * @constructor
237 * @extends {WebInspector.StatusBarItem} 235 * @extends {WebInspector.StatusBarItem}
238 * @param {string} title 236 * @param {string} title
239 * @param {string} className 237 * @param {string} className
240 * @param {number=} states 238 * @param {number=} states
241 */ 239 */
242 WebInspector.StatusBarButtonBase = function(title, className, states) 240 WebInspector.StatusBarButtonBase = function(title, className, states)
243 { 241 {
244 WebInspector.StatusBarItem.call(this, "button"); 242 WebInspector.StatusBarItem.call(this, createElementWithClass("button", class Name + " status-bar-item"));
245 this.element.className = className + " status-bar-item";
246 this.element.addEventListener("click", this._clicked.bind(this), false); 243 this.element.addEventListener("click", this._clicked.bind(this), false);
247 this._longClickController = new WebInspector.LongClickController(this.elemen t); 244 this._longClickController = new WebInspector.LongClickController(this.elemen t);
248 this._longClickController.addEventListener(WebInspector.LongClickController. Events.LongClick, this._onLongClick.bind(this)); 245 this._longClickController.addEventListener(WebInspector.LongClickController. Events.LongClick, this._onLongClick.bind(this));
249 this._longClickController.addEventListener(WebInspector.LongClickController. Events.LongPress, this._onLongPress.bind(this)); 246 this._longClickController.addEventListener(WebInspector.LongClickController. Events.LongPress, this._onLongPress.bind(this));
250 247
251 this._states = states; 248 this._states = states;
252 if (!states) 249 if (!states)
253 this._states = 2; 250 this._states = 2;
254 251
255 if (states == 2) 252 if (states == 2)
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 * @constructor 472 * @constructor
476 * @extends {WebInspector.StatusBarButtonBase} 473 * @extends {WebInspector.StatusBarButtonBase}
477 * @param {string} title 474 * @param {string} title
478 * @param {string} className 475 * @param {string} className
479 * @param {number=} states 476 * @param {number=} states
480 */ 477 */
481 WebInspector.StatusBarButton = function(title, className, states) 478 WebInspector.StatusBarButton = function(title, className, states)
482 { 479 {
483 WebInspector.StatusBarButtonBase.call(this, title, className, states); 480 WebInspector.StatusBarButtonBase.call(this, title, className, states);
484 481
485 this.element.createChild("div", "glyph"); 482 this._glyphElement = this.element.createChild("div", "glyph");
486 } 483 }
487 484
488 WebInspector.StatusBarButton.prototype = { 485 WebInspector.StatusBarButton.prototype = {
486 /**
487 * @param {string} iconURL
488 */
489 setBackgroundImage: function(iconURL)
490 {
491 this.element.style.backgroundImage = "url(" + iconURL + ")";
492 this._glyphElement.classList.add("hidden");
493 },
494
489 __proto__: WebInspector.StatusBarButtonBase.prototype 495 __proto__: WebInspector.StatusBarButtonBase.prototype
490 } 496 }
491 497
492 /** 498 /**
493 * @constructor 499 * @constructor
500 * @param {!Element} parentElement
501 */
502 WebInspector.StatusBar = function(parentElement)
503 {
504 /** @type {!Array.<!WebInspector.StatusBarItem>} */
505 this._items = [];
506 this.element = parentElement.createChild("div", "status-bar");
507 }
508
509 WebInspector.StatusBar.prototype = {
510 /**
511 * @param {boolean} enabled
512 */
513 setEnabled: function(enabled)
514 {
515 for (var item of this._items)
516 item.setEnabled(enabled);
517 },
518
519 /**
520 * @param {!WebInspector.StatusBarItem} item
521 */
522 appendStatusBarItem: function(item)
523 {
524 this._items.push(item);
525 this.element.appendChild(item.element);
526 },
527
528 removeStatusBarItems: function()
529 {
530 this._items = [];
531 this.element.removeChildren();
532 }
533 }
534
535 /**
536 * @constructor
537 * @extends {WebInspector.StatusBarItem}
538 */
539 WebInspector.StatusBarSeparator = function()
540 {
541 WebInspector.StatusBarItem.call(this, createElementWithClass("div", "status- bar-divider"));
542 }
543
544 WebInspector.StatusBarSeparator.prototype = {
545 __proto__: WebInspector.StatusBarItem.prototype
546 }
547
548 /**
549 * @constructor
494 * @extends {WebInspector.StatusBarButtonBase} 550 * @extends {WebInspector.StatusBarButtonBase}
495 * @param {string} title 551 * @param {string} title
496 * @param {string} className 552 * @param {string} className
497 * @param {string} text 553 * @param {string} text
498 * @param {number=} states 554 * @param {number=} states
499 */ 555 */
500 WebInspector.StatusBarTextButton = function(title, className, text, states) 556 WebInspector.StatusBarTextButton = function(title, className, text, states)
501 { 557 {
502 WebInspector.StatusBarButtonBase.call(this, title, className, states); 558 WebInspector.StatusBarButtonBase.call(this, title, className, states);
503 559
(...skipping 20 matching lines...) Expand all
524 } 580 }
525 581
526 /** 582 /**
527 * @constructor 583 * @constructor
528 * @extends {WebInspector.StatusBarItem} 584 * @extends {WebInspector.StatusBarItem}
529 * @param {?function(!Event)} changeHandler 585 * @param {?function(!Event)} changeHandler
530 * @param {string=} className 586 * @param {string=} className
531 */ 587 */
532 WebInspector.StatusBarComboBox = function(changeHandler, className) 588 WebInspector.StatusBarComboBox = function(changeHandler, className)
533 { 589 {
534 WebInspector.StatusBarItem.call(this, "span"); 590 WebInspector.StatusBarItem.call(this, createElementWithClass("span", "status -bar-select-container"));
535 this.element.className = "status-bar-select-container";
536 591
537 this._selectElement = this.element.createChild("select", "status-bar-item"); 592 this._selectElement = this.element.createChild("select", "status-bar-item");
538 this.element.createChild("div", "status-bar-select-arrow"); 593 this.element.createChild("div", "status-bar-select-arrow");
539 if (changeHandler) 594 if (changeHandler)
540 this._selectElement.addEventListener("change", changeHandler, false); 595 this._selectElement.addEventListener("change", changeHandler, false);
541 if (className) 596 if (className)
542 this._selectElement.classList.add(className); 597 this._selectElement.classList.add(className);
543 } 598 }
544 599
545 WebInspector.StatusBarComboBox.prototype = { 600 WebInspector.StatusBarComboBox.prototype = {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 { 693 {
639 return this._selectElement.selectedIndex; 694 return this._selectElement.selectedIndex;
640 }, 695 },
641 696
642 __proto__: WebInspector.StatusBarItem.prototype 697 __proto__: WebInspector.StatusBarItem.prototype
643 } 698 }
644 699
645 /** 700 /**
646 * @constructor 701 * @constructor
647 * @extends {WebInspector.StatusBarItem} 702 * @extends {WebInspector.StatusBarItem}
648 * @param {string} title 703 * @param {string} text
704 * @param {string=} title
705 * @param {!WebInspector.Setting=} setting
649 */ 706 */
650 WebInspector.StatusBarCheckbox = function(title) 707 WebInspector.StatusBarCheckbox = function(text, title, setting)
651 { 708 {
652 WebInspector.StatusBarItem.call(this, "label"); 709 WebInspector.StatusBarItem.call(this, createElementWithClass("label", "check box"));
653 this.element.classList.add("status-bar-item", "checkbox");
654 this.inputElement = this.element.createChild("input"); 710 this.inputElement = this.element.createChild("input");
655 this.inputElement.type = "checkbox"; 711 this.inputElement.type = "checkbox";
656 this.element.createTextChild(title); 712 this.element.createTextChild(text);
713 if (title)
714 this.element.title = title;
715 if (setting)
716 WebInspector.SettingsUI.bindCheckbox(this.inputElement, setting);
657 } 717 }
658 718
659 WebInspector.StatusBarCheckbox.prototype = { 719 WebInspector.StatusBarCheckbox.prototype = {
660 /** 720 /**
661 * @return {boolean} 721 * @return {boolean}
662 */ 722 */
663 checked: function() 723 checked: function()
664 { 724 {
665 return this.inputElement.checked; 725 return this.inputElement.checked;
666 }, 726 },
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 var options = []; 815 var options = [];
756 for (var index = 0; index < this._states.length; index++) { 816 for (var index = 0; index < this._states.length; index++) {
757 if (this._states[index] !== this.state() && this._states[index] !== this._currentState) 817 if (this._states[index] !== this.state() && this._states[index] !== this._currentState)
758 options.push(this._buttons[index]); 818 options.push(this._buttons[index]);
759 } 819 }
760 return options; 820 return options;
761 }, 821 },
762 822
763 __proto__: WebInspector.StatusBarButton.prototype 823 __proto__: WebInspector.StatusBarButton.prototype
764 } 824 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/ui/FilterBar.js ('k') | Source/devtools/front_end/ui/filter.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698