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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/View.js

Issue 2867133002: DevTools: Let the drawer tabs be reordered (Closed)
Patch Set: showView Created 3 years, 6 months 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
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/ui/TabbedPane.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 /** 4 /**
5 * @interface 5 * @interface
6 */ 6 */
7 UI.View = function() {}; 7 UI.View = function() {};
8 8
9 UI.View.prototype = { 9 UI.View.prototype = {
10 /** 10 /**
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 } 705 }
706 } else if (insertBefore) { 706 } else if (insertBefore) {
707 for (var i = 0; i < tabIds.length; ++i) { 707 for (var i = 0; i < tabIds.length; ++i) {
708 if (tabIds[i] === insertBefore.viewId()) { 708 if (tabIds[i] === insertBefore.viewId()) {
709 index = i; 709 index = i;
710 break; 710 break;
711 } 711 }
712 } 712 }
713 } 713 }
714 this._appendTab(view, index); 714 this._appendTab(view, index);
715
716 if (view.isCloseable()) {
717 var tabs = this._closeableTabSetting.get();
718 var tabId = view.viewId();
719 if (!tabs[tabId]) {
720 tabs[tabId] = true;
721 this._closeableTabSetting.set(tabs);
722 }
723 }
724 this._persistTabOrder();
715 } 725 }
716 726
717 /** 727 /**
718 * @override 728 * @override
719 * @param {!UI.View} view 729 * @param {!UI.View} view
720 * @param {?UI.View=} insertBefore 730 * @param {?UI.View=} insertBefore
721 * @param {boolean=} userGesture 731 * @param {boolean=} userGesture
722 * @return {!Promise} 732 * @return {!Promise}
723 */ 733 */
724 showView(view, insertBefore, userGesture) { 734 showView(view, insertBefore, userGesture) {
(...skipping 18 matching lines...) Expand all
743 this._tabbedPane.closeTab(view.viewId()); 753 this._tabbedPane.closeTab(view.viewId());
744 } 754 }
745 755
746 /** 756 /**
747 * @param {!Common.Event} event 757 * @param {!Common.Event} event
748 */ 758 */
749 _tabSelected(event) { 759 _tabSelected(event) {
750 var tabId = /** @type {string} */ (event.data.tabId); 760 var tabId = /** @type {string} */ (event.data.tabId);
751 if (this._lastSelectedTabSetting && event.data['isUserGesture']) 761 if (this._lastSelectedTabSetting && event.data['isUserGesture'])
752 this._lastSelectedTabSetting.set(tabId); 762 this._lastSelectedTabSetting.set(tabId);
753 var view = this._views.get(tabId);
754 if (!view)
755 return;
756
757 if (view.isCloseable()) {
758 var tabs = this._closeableTabSetting.get();
759 if (!tabs[tabId]) {
760 tabs[tabId] = true;
761 this._closeableTabSetting.set(tabs);
762 }
763 }
764 } 763 }
765 764
766 /** 765 /**
767 * @param {!Common.Event} event 766 * @param {!Common.Event} event
768 */ 767 */
769 _tabClosed(event) { 768 _tabClosed(event) {
770 var id = /** @type {string} */ (event.data['tabId']); 769 var id = /** @type {string} */ (event.data['tabId']);
771 var tabs = this._closeableTabSetting.get(); 770 var tabs = this._closeableTabSetting.get();
772 if (tabs[id]) { 771 if (tabs[id]) {
773 delete tabs[id]; 772 delete tabs[id];
774 this._closeableTabSetting.set(tabs); 773 this._closeableTabSetting.set(tabs);
775 } 774 }
776 } 775 }
777 776
778 /** 777 _persistTabOrder() {
779 * @param {!Common.Event} event
780 */
781 _persistTabOrder(event) {
782 var tabIds = this._tabbedPane.tabIds(); 778 var tabIds = this._tabbedPane.tabIds();
783 var tabOrders = {}; 779 var tabOrders = {};
784 for (var i = 0; i < tabIds.length; i++) 780 for (var i = 0; i < tabIds.length; i++)
785 tabOrders[tabIds[i]] = (i + 1) * UI.ViewManager._TabbedLocation.orderStep; 781 tabOrders[tabIds[i]] = (i + 1) * UI.ViewManager._TabbedLocation.orderStep;
786 this._tabOrderSetting.set(tabOrders); 782 this._tabOrderSetting.set(tabOrders);
787 } 783 }
788 }; 784 };
789 785
790 UI.ViewManager._TabbedLocation.orderStep = 10; // Keep in sync with descriptors . 786 UI.ViewManager._TabbedLocation.orderStep = 10; // Keep in sync with descriptors .
791 787
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 appendApplicableItems(locationName) { 862 appendApplicableItems(locationName) {
867 for (var view of this._manager._viewsForLocation(locationName)) 863 for (var view of this._manager._viewsForLocation(locationName))
868 this.appendView(view); 864 this.appendView(view);
869 } 865 }
870 }; 866 };
871 867
872 /** 868 /**
873 * @type {!UI.ViewManager} 869 * @type {!UI.ViewManager}
874 */ 870 */
875 UI.viewManager; 871 UI.viewManager;
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/front_end/ui/TabbedPane.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698