OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 applySuggestion: function(input, suggestion, isIntermediate) { }, | 430 applySuggestion: function(input, suggestion, isIntermediate) { }, |
431 | 431 |
432 /** | 432 /** |
433 * @param {!HTMLInputElement} input | 433 * @param {!HTMLInputElement} input |
434 */ | 434 */ |
435 unapplySuggestion: function(input) { } | 435 unapplySuggestion: function(input) { } |
436 } | 436 } |
437 | 437 |
438 /** | 438 /** |
439 * @constructor | 439 * @constructor |
| 440 * @extends {WebInspector.Object} |
440 * @implements {WebInspector.FilterUI} | 441 * @implements {WebInspector.FilterUI} |
441 * @extends {WebInspector.Object} | 442 * @param {!Array.<!WebInspector.NamedBitSetFilterUI.Item>} items |
| 443 * @param {!WebInspector.Setting=} setting |
442 */ | 444 */ |
443 WebInspector.NamedBitSetFilterUI = function() | 445 WebInspector.NamedBitSetFilterUI = function(items, setting) |
444 { | 446 { |
445 this._filtersElement = document.createElement("div"); | 447 this._filtersElement = document.createElement("div"); |
446 this._filtersElement.className = "filter-bitset-filter status-bar-item"; | 448 this._filtersElement.className = "filter-bitset-filter status-bar-item"; |
447 this._filtersElement.title = WebInspector.UIString("Use %s Click to select m
ultiple types.", WebInspector.KeyboardShortcut.shortcutToString("", WebInspector
.KeyboardShortcut.Modifiers.CtrlOrMeta)); | 449 this._filtersElement.title = WebInspector.UIString("Use %s Click to select m
ultiple types.", WebInspector.KeyboardShortcut.shortcutToString("", WebInspector
.KeyboardShortcut.Modifiers.CtrlOrMeta)); |
448 | 450 |
449 this._allowedTypes = {}; | 451 this._allowedTypes = {}; |
450 this._typeFilterElements = {}; | 452 this._typeFilterElements = {}; |
451 this.addBit(WebInspector.NamedBitSetFilterUI.ALL_TYPES, WebInspector.UIStrin
g("All")); | 453 this._addBit(WebInspector.NamedBitSetFilterUI.ALL_TYPES, WebInspector.UIStri
ng("All")); |
452 this._filtersElement.createChild("div", "filter-bitset-filter-divider"); | 454 this._filtersElement.createChild("div", "filter-bitset-filter-divider"); |
453 this._toggleTypeFilter(WebInspector.NamedBitSetFilterUI.ALL_TYPES, false); | 455 |
| 456 for (var i = 0; i < items.length; ++i) |
| 457 this._addBit(items[i].name, items[i].label); |
| 458 |
| 459 if (setting) { |
| 460 this._setting = setting; |
| 461 setting.addChangeListener(this._settingChanged.bind(this)); |
| 462 this._settingChanged(); |
| 463 } else { |
| 464 this._toggleTypeFilter(WebInspector.NamedBitSetFilterUI.ALL_TYPES, false
); |
| 465 } |
454 } | 466 } |
455 | 467 |
| 468 /** @typedef {{name: string, label: string}} */ |
| 469 WebInspector.NamedBitSetFilterUI.Item; |
| 470 |
456 WebInspector.NamedBitSetFilterUI.ALL_TYPES = "all"; | 471 WebInspector.NamedBitSetFilterUI.ALL_TYPES = "all"; |
457 | 472 |
458 WebInspector.NamedBitSetFilterUI.prototype = { | 473 WebInspector.NamedBitSetFilterUI.prototype = { |
459 /** | 474 /** |
460 * @return {boolean} | 475 * @return {boolean} |
461 */ | 476 */ |
462 isActive: function() | 477 isActive: function() |
463 { | 478 { |
464 return !this._allowedTypes[WebInspector.NamedBitSetFilterUI.ALL_TYPES]; | 479 return !this._allowedTypes[WebInspector.NamedBitSetFilterUI.ALL_TYPES]; |
465 }, | 480 }, |
466 | 481 |
467 /** | 482 /** |
468 * @param {!WebInspector.Setting} setting | |
469 */ | |
470 bindSetting: function(setting) | |
471 { | |
472 console.assert(!this._setting); | |
473 this._setting = setting; | |
474 setting.addChangeListener(this._settingChanged.bind(this)); | |
475 this._settingChanged(); | |
476 }, | |
477 | |
478 /** | |
479 * @return {!Element} | 483 * @return {!Element} |
480 */ | 484 */ |
481 element: function() | 485 element: function() |
482 { | 486 { |
483 return this._filtersElement; | 487 return this._filtersElement; |
484 }, | 488 }, |
485 | 489 |
486 /** | 490 /** |
487 * @param {string} typeName | 491 * @param {string} typeName |
488 * @return {boolean} | 492 * @return {boolean} |
(...skipping 22 matching lines...) Expand all Loading... |
511 } | 515 } |
512 for (var typeName in this._typeFilterElements) | 516 for (var typeName in this._typeFilterElements) |
513 this._typeFilterElements[typeName].classList.toggle("selected", this
._allowedTypes[typeName]); | 517 this._typeFilterElements[typeName].classList.toggle("selected", this
._allowedTypes[typeName]); |
514 this.dispatchEventToListeners(WebInspector.FilterUI.Events.FilterChanged
, null); | 518 this.dispatchEventToListeners(WebInspector.FilterUI.Events.FilterChanged
, null); |
515 }, | 519 }, |
516 | 520 |
517 /** | 521 /** |
518 * @param {string} name | 522 * @param {string} name |
519 * @param {string} label | 523 * @param {string} label |
520 */ | 524 */ |
521 addBit: function(name, label) | 525 _addBit: function(name, label) |
522 { | 526 { |
523 var typeFilterElement = this._filtersElement.createChild("li", name); | 527 var typeFilterElement = this._filtersElement.createChild("li", name); |
524 typeFilterElement.typeName = name; | 528 typeFilterElement.typeName = name; |
525 typeFilterElement.createTextChild(label); | 529 typeFilterElement.createTextChild(label); |
526 typeFilterElement.addEventListener("click", this._onTypeFilterClicked.bi
nd(this), false); | 530 typeFilterElement.addEventListener("click", this._onTypeFilterClicked.bi
nd(this), false); |
527 this._typeFilterElements[name] = typeFilterElement; | 531 this._typeFilterElements[name] = typeFilterElement; |
528 }, | 532 }, |
529 | 533 |
530 /** | 534 /** |
531 * @param {!Event} e | 535 * @param {!Event} e |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 var label = this._filterElement.createChild("label"); | 738 var label = this._filterElement.createChild("label"); |
735 var checkBorder = label.createChild("div", "checkbox-filter-checkbox"); | 739 var checkBorder = label.createChild("div", "checkbox-filter-checkbox"); |
736 this._checkElement = checkBorder.createChild("div", "checkbox-filter-che
ckbox-check"); | 740 this._checkElement = checkBorder.createChild("div", "checkbox-filter-che
ckbox-check"); |
737 this._filterElement.addEventListener("click", this._onClick.bind(this),
false); | 741 this._filterElement.addEventListener("click", this._onClick.bind(this),
false); |
738 var typeElement = label.createChild("span", "type"); | 742 var typeElement = label.createChild("span", "type"); |
739 typeElement.textContent = title; | 743 typeElement.textContent = title; |
740 }, | 744 }, |
741 | 745 |
742 __proto__: WebInspector.Object.prototype | 746 __proto__: WebInspector.Object.prototype |
743 } | 747 } |
OLD | NEW |