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

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

Issue 9316086: Fix JavaScript errors in options2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use list join Created 8 years, 10 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, also defines id of the div element 12 * @param {string} name Options page name, also defines id of the div element
13 * containing the options view and the name of options page navigation bar 13 * containing the options view and the name of options page navigation bar
14 * item as name+'PageNav'. 14 * item as name+'PageNav'.
15 * @param {string} title Options page title, used for navigation bar 15 * @param {string} title Options page title, used for navigation bar.
16 * @extends {EventTarget} 16 * @extends {EventTarget}
17 */ 17 */
18 function OptionsPage(name, title, pageDivName) { 18 function OptionsPage(name, title, pageDivName) {
19 this.name = name; 19 this.name = name;
20 this.title = title; 20 this.title = title;
21 this.pageDivName = pageDivName; 21 this.pageDivName = pageDivName;
22 this.pageDiv = $(this.pageDivName); 22 this.pageDiv = $(this.pageDivName);
23 this.tab = null; 23 this.tab = null;
24 } 24 }
25 25
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 */ 195 */
196 OptionsPage.setTitle_ = function(title) { 196 OptionsPage.setTitle_ = function(title) {
197 uber.invokeMethodOnParent('setTitle', {title: title}); 197 uber.invokeMethodOnParent('setTitle', {title: title});
198 }; 198 };
199 199
200 /** 200 /**
201 * Updates the visibility and stacking order of the subpage backdrop 201 * Updates the visibility and stacking order of the subpage backdrop
202 * according to which subpage is topmost and visible. 202 * according to which subpage is topmost and visible.
203 * @private 203 * @private
204 */ 204 */
205 OptionsPage.updateSubpageBackdrop_ = function () { 205 OptionsPage.updateSubpageBackdrop_ = function() {
206 var topmostPage = OptionsPage.getTopmostVisibleNonOverlayPage_(); 206 var topmostPage = OptionsPage.getTopmostVisibleNonOverlayPage_();
207 var nestingLevel = topmostPage ? topmostPage.nestingLevel : 0; 207 var nestingLevel = topmostPage ? topmostPage.nestingLevel : 0;
208 208
209 var subpageBackdrop = $('subpage-backdrop'); 209 var subpageBackdrop = $('subpage-backdrop');
210 if (nestingLevel > 0) { 210 if (nestingLevel > 0) {
211 var container = $('subpage-sheet-container-' + nestingLevel); 211 var container = $('subpage-sheet-container-' + nestingLevel);
212 subpageBackdrop.style.zIndex = 212 subpageBackdrop.style.zIndex =
213 parseInt(window.getComputedStyle(container).zIndex) - 1; 213 parseInt(window.getComputedStyle(container).zIndex) - 1;
214 subpageBackdrop.hidden = false; 214 subpageBackdrop.hidden = false;
215 } else { 215 } else {
216 subpageBackdrop.hidden = true; 216 subpageBackdrop.hidden = true;
217 } 217 }
218 }; 218 };
219 219
220 /** 220 /**
221 * Scrolls the page to the correct position (the top when opening a subpage, 221 * Scrolls the page to the correct position (the top when opening a subpage,
222 * or the old scroll position a previously hidden subpage becomes visible). 222 * or the old scroll position a previously hidden subpage becomes visible).
223 * @private 223 * @private
224 */ 224 */
225 OptionsPage.updateScrollPosition_ = function () { 225 OptionsPage.updateScrollPosition_ = function() {
226 var topmostPage = OptionsPage.getTopmostVisibleNonOverlayPage_(); 226 var topmostPage = OptionsPage.getTopmostVisibleNonOverlayPage_();
227 var nestingLevel = topmostPage ? topmostPage.nestingLevel : 0; 227 var nestingLevel = topmostPage ? topmostPage.nestingLevel : 0;
228 228
229 var container = (nestingLevel > 0) ? 229 var container = (nestingLevel > 0) ?
230 $('subpage-sheet-container-' + nestingLevel) : $('page-container'); 230 $('subpage-sheet-container-' + nestingLevel) : $('page-container');
231 231
232 var scrollTop = container.oldScrollTop || 0; 232 var scrollTop = container.oldScrollTop || 0;
233 container.oldScrollTop = undefined; 233 container.oldScrollTop = undefined;
234 window.scroll(document.body.scrollLeft, scrollTop); 234 window.scroll(document.body.scrollLeft, scrollTop);
235 }; 235 };
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 overlay.didClosePage(); 570 overlay.didClosePage();
571 }; 571 };
572 572
573 /** 573 /**
574 * Freezes/unfreezes the scroll position of given level's page container. 574 * Freezes/unfreezes the scroll position of given level's page container.
575 * @param {boolean} freeze Whether the page should be frozen. 575 * @param {boolean} freeze Whether the page should be frozen.
576 * @param {number} level The level to freeze/unfreeze. 576 * @param {number} level The level to freeze/unfreeze.
577 * @private 577 * @private
578 */ 578 */
579 OptionsPage.setPageFrozenAtLevel_ = function(freeze, level) { 579 OptionsPage.setPageFrozenAtLevel_ = function(freeze, level) {
580 var container = level == 0 ? $('page-container') 580 var container = level == 0 ? $('page-container') :
581 : $('subpage-sheet-container-' + level); 581 $('subpage-sheet-container-' + level);
582 582
583 if (container.classList.contains('frozen') == freeze) 583 if (container.classList.contains('frozen') == freeze)
584 return; 584 return;
585 585
586 if (freeze) { 586 if (freeze) {
587 // Lock the width, since auto width computation may change. 587 // Lock the width, since auto width computation may change.
588 container.style.width = window.getComputedStyle(container).width; 588 container.style.width = window.getComputedStyle(container).width;
589 container.oldScrollTop = document.body.scrollTop; 589 container.oldScrollTop = document.body.scrollTop;
590 container.classList.add('frozen'); 590 container.classList.add('frozen');
591 var verticalPosition = 591 var verticalPosition =
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 var adjust = isRTL() ? 1 : -1; 730 var adjust = isRTL() ? 1 : -1;
731 var marginStart = document.body.scrollLeft * adjust + 'px'; 731 var marginStart = document.body.scrollLeft * adjust + 'px';
732 for (var i = 0; i < this.fixedHeaders_.length; ++i) 732 for (var i = 0; i < this.fixedHeaders_.length; ++i)
733 this.fixedHeaders_[i].style.webkitMarginStart = marginStart; 733 this.fixedHeaders_[i].style.webkitMarginStart = marginStart;
734 734
735 uber.invokeMethodOnParent('adjustToScroll', document.body.scrollLeft); 735 uber.invokeMethodOnParent('adjustToScroll', document.body.scrollLeft);
736 }; 736 };
737 737
738 /** 738 /**
739 * Updates the given frozen element to match the horizontal scroll position. 739 * Updates the given frozen element to match the horizontal scroll position.
740 * @param {HTMLElement} e The frozen element to update 740 * @param {HTMLElement} e The frozen element to update.
741 * @private 741 * @private
742 */ 742 */
743 OptionsPage.updateFrozenElementHorizontalPosition_ = function(e) { 743 OptionsPage.updateFrozenElementHorizontalPosition_ = function(e) {
744 if (isRTL()) 744 if (isRTL())
745 e.style.right = HORIZONTAL_OFFSET + 'px'; 745 e.style.right = HORIZONTAL_OFFSET + 'px';
746 else 746 else
747 e.style.left = HORIZONTAL_OFFSET - document.body.scrollLeft + 'px'; 747 e.style.left = HORIZONTAL_OFFSET - document.body.scrollLeft + 'px';
748 }; 748 };
749 749
750 /** 750 /**
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 * remain a top-level page even if sub-pages change. 1076 * remain a top-level page even if sub-pages change.
1077 * @type {boolean} True if this page is sticky. 1077 * @type {boolean} True if this page is sticky.
1078 */ 1078 */
1079 get sticky() { 1079 get sticky() {
1080 return false; 1080 return false;
1081 }, 1081 },
1082 1082
1083 /** 1083 /**
1084 * Checks whether this page is an ancestor of the given page in terms of 1084 * Checks whether this page is an ancestor of the given page in terms of
1085 * subpage nesting. 1085 * subpage nesting.
1086 * @param {OptionsPage} page 1086 * @param {OptionsPage} page The potential descendent of this page.
1087 * @return {boolean} True if this page is nested under |page| 1087 * @return {boolean} True if |page| is nested under this page.
1088 */ 1088 */
1089 isAncestorOfPage: function(page) { 1089 isAncestorOfPage: function(page) {
1090 var parent = page.parentPage; 1090 var parent = page.parentPage;
1091 while (parent) { 1091 while (parent) {
1092 if (parent == this) 1092 if (parent == this)
1093 return true; 1093 return true;
1094 parent = parent.parentPage; 1094 parent = parent.parentPage;
1095 } 1095 }
1096 return false; 1096 return false;
1097 }, 1097 },
1098 1098
1099 /** 1099 /**
1100 * Whether it should be possible to show the page. 1100 * Whether it should be possible to show the page.
1101 * @return {boolean} True if the page should be shown 1101 * @return {boolean} True if the page should be shown.
1102 */ 1102 */
1103 canShowPage: function() { 1103 canShowPage: function() {
1104 return true; 1104 return true;
1105 }, 1105 },
1106 }; 1106 };
1107 1107
1108 // Export 1108 // Export
1109 return { 1109 return {
1110 OptionsPage: OptionsPage 1110 OptionsPage: OptionsPage
1111 }; 1111 };
1112 }); 1112 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698