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

Side by Side Diff: chrome/browser/resources/options/options_page.js

Issue 10907148: Implement popup bubbles for the controlled setting indicator (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: All comments addressed. Created 8 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 cr.define('options', function() { 5 cr.define('options', function() {
6 ///////////////////////////////////////////////////////////////////////////// 6 /////////////////////////////////////////////////////////////////////////////
7 // OptionsPage class: 7 // OptionsPage class:
8 8
9 /** 9 /**
10 * Base class for options page. 10 * Base class for options page.
11 * @constructor 11 * @constructor
12 * @param {string} name Options page name. 12 * @param {string} name Options page name.
13 * @param {string} title Options page title, used for history. 13 * @param {string} title Options page title, used for history.
14 * @extends {EventTarget} 14 * @extends {EventTarget}
15 */ 15 */
16 function OptionsPage(name, title, pageDivName) { 16 function OptionsPage(name, title, pageDivName) {
17 this.name = name; 17 this.name = name;
18 this.title = title; 18 this.title = title;
19 this.pageDivName = pageDivName; 19 this.pageDivName = pageDivName;
20 this.pageDiv = $(this.pageDivName); 20 this.pageDiv = $(this.pageDivName);
21 this.tab = null; 21 this.tab = null;
22 this.lastFocusedElement = null; 22 this.lastFocusedElement = null;
23 } 23 }
24 24
25 /** @const */ var HORIZONTAL_OFFSET = 155; 25 /** @const */ var HORIZONTAL_OFFSET = 155;
26 26
27 /** 27 /**
28 * This is the absolute difference maintained between standard and 28 * This is the absolute difference maintained between standard and
29 * fixed-width font sizes. Refer http://crbug.com/91922. 29 * fixed-width font sizes. Refer http://crbug.com/91922.
30 * @const
30 */ 31 */
31 OptionsPage.SIZE_DIFFERENCE_FIXED_STANDARD = 3; 32 OptionsPage.SIZE_DIFFERENCE_FIXED_STANDARD = 3;
32 33
33 /** 34 /**
34 * Main level option pages. Maps lower-case page names to the respective page 35 * Main level option pages. Maps lower-case page names to the respective page
35 * object. 36 * object.
36 * @protected 37 * @protected
37 */ 38 */
38 OptionsPage.registeredPages = {}; 39 OptionsPage.registeredPages = {};
39 40
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 * @param {Object=} opt_propertyBag An optional bag of properties including 76 * @param {Object=} opt_propertyBag An optional bag of properties including
76 * replaceState (if history state should be replaced instead of pushed). 77 * replaceState (if history state should be replaced instead of pushed).
77 * @private 78 * @private
78 */ 79 */
79 OptionsPage.showPageByName = function(pageName, 80 OptionsPage.showPageByName = function(pageName,
80 updateHistory, 81 updateHistory,
81 opt_propertyBag) { 82 opt_propertyBag) {
82 // If |opt_propertyBag| is non-truthy, homogenize to object. 83 // If |opt_propertyBag| is non-truthy, homogenize to object.
83 opt_propertyBag = opt_propertyBag || {}; 84 opt_propertyBag = opt_propertyBag || {};
84 85
86 // If a bubble is currently being shown, hide it.
87 this.hideBubble();
88
85 // Find the currently visible root-level page. 89 // Find the currently visible root-level page.
86 var rootPage = null; 90 var rootPage = null;
87 for (var name in this.registeredPages) { 91 for (var name in this.registeredPages) {
88 var page = this.registeredPages[name]; 92 var page = this.registeredPages[name];
89 if (page.visible && !page.parentPage) { 93 if (page.visible && !page.parentPage) {
90 rootPage = page; 94 rootPage = page;
91 break; 95 break;
92 } 96 }
93 } 97 }
94 98
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 /** 376 /**
373 * Returns the topmost visible page, or null if no page is visible. 377 * Returns the topmost visible page, or null if no page is visible.
374 * @return {OptionPage} The topmost visible page. 378 * @return {OptionPage} The topmost visible page.
375 */ 379 */
376 OptionsPage.getTopmostVisiblePage = function() { 380 OptionsPage.getTopmostVisiblePage = function() {
377 // Check overlays first since they're top-most if visible. 381 // Check overlays first since they're top-most if visible.
378 return this.getVisibleOverlay_() || this.getTopmostVisibleNonOverlayPage_(); 382 return this.getVisibleOverlay_() || this.getTopmostVisibleNonOverlayPage_();
379 }; 383 };
380 384
381 /** 385 /**
386 * Returns the currently visible bubble, or null if no bubble is visible.
387 * @return {OptionsBubble} The bubble currently being shown.
388 */
389 OptionsPage.getVisibleBubble = function() {
390 var bubble = OptionsPage.bubble_;
391 return bubble && !bubble.hidden ? bubble : null;
392 };
393
394 /**
395 * Shows an informational bubble displaying |content| and pointing at the
396 * |anchor| element. If |content| has focusable elements, they join the
397 * current page's tab order as siblings of |anchor|.
398 * @param {HTMLDivElement} content The content of the bubble.
399 * @param {HTMLElement} anchor The element at which the bubble points.
400 */
401 OptionsPage.showBubble = function(content, anchor) {
402 OptionsPage.hideBubble();
403
404 var bubble = new options.OptionsBubble;
405 bubble.anchorNode = anchor;
406 bubble.arrowLocation = cr.ui.ArrowLocation.TOP_END;
407 bubble.content = content;
408 bubble.show();
409 OptionsPage.bubble_ = bubble;
410 };
411
412 /**
413 * Hides the currently visible bubble, if any.
414 */
415 OptionsPage.hideBubble = function() {
416 if (OptionsPage.bubble_)
417 OptionsPage.bubble_.hide();
418 };
419
420 /**
382 * Updates managed banner visibility state based on the topmost page. 421 * Updates managed banner visibility state based on the topmost page.
383 */ 422 */
384 OptionsPage.updateManagedBannerVisibility = function() { 423 OptionsPage.updateManagedBannerVisibility = function() {
385 var topPage = this.getTopmostVisiblePage(); 424 var topPage = this.getTopmostVisiblePage();
386 if (topPage) 425 if (topPage)
387 topPage.updateManagedBannerVisibility(); 426 topPage.updateManagedBannerVisibility();
388 }; 427 };
389 428
390 /** 429 /**
391 * Shows the tab contents for the given navigation tab. 430 * Shows the tab contents for the given navigation tab.
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 canShowPage: function() { 939 canShowPage: function() {
901 return true; 940 return true;
902 }, 941 },
903 }; 942 };
904 943
905 // Export 944 // Export
906 return { 945 return {
907 OptionsPage: OptionsPage 946 OptionsPage: OptionsPage
908 }; 947 };
909 }); 948 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/options_page.css ('k') | chrome/browser/resources/shared/css/bubble.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698