OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). | 3 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). |
4 * Copyright (C) 2009 Joseph Pecoraro | 4 * Copyright (C) 2009 Joseph Pecoraro |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * | 9 * |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 return searchableView.handleCancelSearchShortcut(); | 579 return searchableView.handleCancelSearchShortcut(); |
580 case 'main.search-in-panel.find-next': | 580 case 'main.search-in-panel.find-next': |
581 return searchableView.handleFindNextShortcut(); | 581 return searchableView.handleFindNextShortcut(); |
582 case 'main.search-in-panel.find-previous': | 582 case 'main.search-in-panel.find-previous': |
583 return searchableView.handleFindPreviousShortcut(); | 583 return searchableView.handleFindPreviousShortcut(); |
584 } | 584 } |
585 return false; | 585 return false; |
586 } | 586 } |
587 }; | 587 }; |
588 | 588 |
589 | |
590 /** | |
591 * @implements {UI.ToolbarItem.Provider} | |
592 * @unrestricted | |
593 */ | |
594 Main.Main.WarningErrorCounter = class { | |
595 constructor() { | |
596 Main.Main.WarningErrorCounter._instanceForTest = this; | |
597 | |
598 this._counter = createElement('div'); | |
599 this._counter.addEventListener('click', Common.console.show.bind(Common.cons
ole), false); | |
600 this._toolbarItem = new UI.ToolbarItem(this._counter); | |
601 var shadowRoot = UI.createShadowRootWithCoreStyles(this._counter, 'main/erro
rWarningCounter.css'); | |
602 | |
603 this._errors = this._createItem(shadowRoot, 'smallicon-error'); | |
604 this._warnings = this._createItem(shadowRoot, 'smallicon-warning'); | |
605 this._titles = []; | |
606 | |
607 ConsoleModel.consoleModel.addEventListener(ConsoleModel.ConsoleModel.Events.
ConsoleCleared, this._update, this); | |
608 ConsoleModel.consoleModel.addEventListener(ConsoleModel.ConsoleModel.Events.
MessageAdded, this._update, this); | |
609 ConsoleModel.consoleModel.addEventListener(ConsoleModel.ConsoleModel.Events.
MessageUpdated, this._update, this); | |
610 this._update(); | |
611 } | |
612 | |
613 /** | |
614 * @param {!Node} shadowRoot | |
615 * @param {string} iconType | |
616 * @return {!{item: !Element, text: !Element}} | |
617 */ | |
618 _createItem(shadowRoot, iconType) { | |
619 var item = createElementWithClass('span', 'counter-item'); | |
620 var icon = item.createChild('label', '', 'dt-icon-label'); | |
621 icon.type = iconType; | |
622 var text = icon.createChild('span'); | |
623 shadowRoot.appendChild(item); | |
624 return {item: item, text: text}; | |
625 } | |
626 | |
627 /** | |
628 * @param {!{item: !Element, text: !Element}} item | |
629 * @param {number} count | |
630 * @param {boolean} first | |
631 * @param {string} title | |
632 */ | |
633 _updateItem(item, count, first, title) { | |
634 item.item.classList.toggle('hidden', !count); | |
635 item.item.classList.toggle('counter-item-first', first); | |
636 item.text.textContent = count; | |
637 if (count) | |
638 this._titles.push(title); | |
639 } | |
640 | |
641 _update() { | |
642 var errors = ConsoleModel.consoleModel.errors(); | |
643 var warnings = ConsoleModel.consoleModel.warnings(); | |
644 | |
645 this._titles = []; | |
646 this._toolbarItem.setVisible(!!(errors || warnings)); | |
647 this._updateItem(this._errors, errors, false, Common.UIString(errors === 1 ?
'%d error' : '%d errors', errors)); | |
648 this._updateItem( | |
649 this._warnings, warnings, !errors, Common.UIString(warnings === 1 ? '%d
warning' : '%d warnings', warnings)); | |
650 this._counter.title = this._titles.join(', '); | |
651 UI.inspectorView.toolbarItemResized(); | |
652 } | |
653 | |
654 /** | |
655 * @override | |
656 * @return {?UI.ToolbarItem} | |
657 */ | |
658 item() { | |
659 return this._toolbarItem; | |
660 } | |
661 }; | |
662 | |
663 /** | 589 /** |
664 * @implements {UI.ToolbarItem.Provider} | 590 * @implements {UI.ToolbarItem.Provider} |
665 */ | 591 */ |
666 Main.Main.MainMenuItem = class { | 592 Main.Main.MainMenuItem = class { |
667 constructor() { | 593 constructor() { |
668 this._item = new UI.ToolbarMenuButton(this._handleContextMenu.bind(this), tr
ue); | 594 this._item = new UI.ToolbarMenuButton(this._handleContextMenu.bind(this), tr
ue); |
669 this._item.setTitle(Common.UIString('Customize and control DevTools')); | 595 this._item.setTitle(Common.UIString('Customize and control DevTools')); |
670 } | 596 } |
671 | 597 |
672 /** | 598 /** |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1003 * @override | 929 * @override |
1004 * @return {?Element} | 930 * @return {?Element} |
1005 */ | 931 */ |
1006 settingElement() { | 932 settingElement() { |
1007 return UI.SettingsUI.createSettingCheckbox( | 933 return UI.SettingsUI.createSettingCheckbox( |
1008 Common.UIString('Show rulers'), Common.moduleSetting('showMetricsRulers'
)); | 934 Common.UIString('Show rulers'), Common.moduleSetting('showMetricsRulers'
)); |
1009 } | 935 } |
1010 }; | 936 }; |
1011 | 937 |
1012 new Main.Main(); | 938 new Main.Main(); |
OLD | NEW |