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

Side by Side Diff: ui/webui/resources/js/cr/ui/page_manager/page_manager.js

Issue 2603443002: Clang format JS: Disallow single line functions, conditionals, loops, and switch statements (Closed)
Patch Set: update c/b/r/ as well Created 3 years, 12 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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('cr.ui.pageManager', function() { 5 cr.define('cr.ui.pageManager', function() {
6 /** 6 /**
7 * PageManager contains a list of root Page and overlay Page objects and 7 * PageManager contains a list of root Page and overlay Page objects and
8 * handles "navigation" by showing and hiding these pages and overlays. On 8 * handles "navigation" by showing and hiding these pages and overlays. On
9 * initial load, PageManager can use the path to open the correct hierarchy 9 * initial load, PageManager can use the path to open the correct hierarchy
10 * of pages and overlay(s). Handlers for user events, like pressing buttons, 10 * of pages and overlay(s). Handlers for user events, like pressing buttons,
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 updateRootPageFreezeState: function() { 440 updateRootPageFreezeState: function() {
441 var topPage = this.getTopmostVisiblePage(); 441 var topPage = this.getTopmostVisiblePage();
442 if (topPage) 442 if (topPage)
443 this.setRootPageFrozen_(topPage.isOverlay); 443 this.setRootPageFrozen_(topPage.isOverlay);
444 }, 444 },
445 445
446 /** 446 /**
447 * Change the horizontal offset used to reposition elements while showing an 447 * Change the horizontal offset used to reposition elements while showing an
448 * overlay from the default. 448 * overlay from the default.
449 */ 449 */
450 set horizontalOffset(value) { this.horizontalOffset_ = value; }, 450 set horizontalOffset(value) {
451 this.horizontalOffset_ = value;
452 },
451 453
452 /** 454 /**
453 * @param {!cr.ui.pageManager.PageManager.Observer} observer The observer to 455 * @param {!cr.ui.pageManager.PageManager.Observer} observer The observer to
454 * register. 456 * register.
455 */ 457 */
456 addObserver: function(observer) { this.observers_.push(observer); }, 458 addObserver: function(observer) {
459 this.observers_.push(observer);
460 },
457 461
458 /** 462 /**
459 * Shows a registered overlay page. Does not update history. 463 * Shows a registered overlay page. Does not update history.
460 * @param {string} overlayName Page name. 464 * @param {string} overlayName Page name.
461 * @param {string} hash The hash state to associate with the overlay. 465 * @param {string} hash The hash state to associate with the overlay.
462 * @param {cr.ui.pageManager.Page} rootPage The currently visible root-level 466 * @param {cr.ui.pageManager.Page} rootPage The currently visible root-level
463 * page. 467 * page.
464 * @return {boolean} Whether we showed an overlay. 468 * @return {boolean} Whether we showed an overlay.
465 * @private 469 * @private
466 */ 470 */
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 } 506 }
503 507
504 return true; 508 return true;
505 }, 509 },
506 510
507 /** 511 /**
508 * Returns whether or not an overlay is visible. 512 * Returns whether or not an overlay is visible.
509 * @return {boolean} True if an overlay is visible. 513 * @return {boolean} True if an overlay is visible.
510 * @private 514 * @private
511 */ 515 */
512 isOverlayVisible_: function() { return this.getVisibleOverlay_() != null; }, 516 isOverlayVisible_: function() {
517 return this.getVisibleOverlay_() != null;
518 },
513 519
514 /** 520 /**
515 * Returns the currently visible overlay, or null if no page is visible. 521 * Returns the currently visible overlay, or null if no page is visible.
516 * @return {cr.ui.pageManager.Page} The visible overlay. 522 * @return {cr.ui.pageManager.Page} The visible overlay.
517 * @private 523 * @private
518 */ 524 */
519 getVisibleOverlay_: function() { 525 getVisibleOverlay_: function() {
520 var topmostPage = null; 526 var topmostPage = null;
521 for (var name in this.registeredOverlayPages) { 527 for (var name in this.registeredOverlayPages) {
522 var page = this.registeredOverlayPages[name]; 528 var page = this.registeredOverlayPages[name];
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 container.style.right = ''; 672 container.style.right = '';
667 container.style.width = ''; 673 container.style.width = '';
668 } 674 }
669 }, 675 },
670 676
671 /** 677 /**
672 * Called when the page is scrolled; moves elements that are position:fixed 678 * Called when the page is scrolled; moves elements that are position:fixed
673 * but should only behave as if they are fixed for vertical scrolling. 679 * but should only behave as if they are fixed for vertical scrolling.
674 * @private 680 * @private
675 */ 681 */
676 handleScroll_: function() { this.updateAllFrozenElementPositions_(); }, 682 handleScroll_: function() {
683 this.updateAllFrozenElementPositions_();
684 },
677 685
678 /** 686 /**
679 * Updates all frozen pages to match the horizontal scroll position. 687 * Updates all frozen pages to match the horizontal scroll position.
680 * @private 688 * @private
681 */ 689 */
682 updateAllFrozenElementPositions_: function() { 690 updateAllFrozenElementPositions_: function() {
683 var frozenElements = document.querySelectorAll('.frozen'); 691 var frozenElements = document.querySelectorAll('.frozen');
684 for (var i = 0; i < frozenElements.length; i++) 692 for (var i = 0; i < frozenElements.length; i++)
685 this.updateFrozenElementHorizontalPosition_(frozenElements[i]); 693 this.updateFrozenElementHorizontalPosition_(frozenElements[i]);
686 }, 694 },
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 * Called when a page is navigated to. 750 * Called when a page is navigated to.
743 * @param {string} path The path of the page being visited. 751 * @param {string} path The path of the page being visited.
744 * @param {boolean} replace If true, allow no history events to be created. 752 * @param {boolean} replace If true, allow no history events to be created.
745 */ 753 */
746 updateHistory: function(path, replace) {}, 754 updateHistory: function(path, replace) {},
747 }; 755 };
748 756
749 // Export 757 // Export
750 return {PageManager: PageManager}; 758 return {PageManager: PageManager};
751 }); 759 });
OLDNEW
« no previous file with comments | « ui/webui/resources/js/cr/ui/page_manager/page.js ('k') | ui/webui/resources/js/cr/ui/repeating_button.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698