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

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: new violations found after rebase 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. 12 * @param {string} name Options page name.
13 * @param {string} title Options page title, used for navigation bar 13 * @param {string} title Options page title, used for navigation bar.
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 } 22 }
23 23
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 */ 193 */
194 OptionsPage.setTitle_ = function(title) { 194 OptionsPage.setTitle_ = function(title) {
195 uber.invokeMethodOnParent('setTitle', {title: title}); 195 uber.invokeMethodOnParent('setTitle', {title: title});
196 }; 196 };
197 197
198 /** 198 /**
199 * Updates the visibility and stacking order of the subpage backdrop 199 * Updates the visibility and stacking order of the subpage backdrop
200 * according to which subpage is topmost and visible. 200 * according to which subpage is topmost and visible.
201 * @private 201 * @private
202 */ 202 */
203 OptionsPage.updateSubpageBackdrop_ = function () { 203 OptionsPage.updateSubpageBackdrop_ = function() {
204 var topmostPage = OptionsPage.getTopmostVisibleNonOverlayPage_(); 204 var topmostPage = OptionsPage.getTopmostVisibleNonOverlayPage_();
205 var nestingLevel = topmostPage ? topmostPage.nestingLevel : 0; 205 var nestingLevel = topmostPage ? topmostPage.nestingLevel : 0;
206 206
207 var subpageBackdrop = $('subpage-backdrop'); 207 var subpageBackdrop = $('subpage-backdrop');
208 if (nestingLevel > 0) { 208 if (nestingLevel > 0) {
209 var container = $('subpage-sheet-container-' + nestingLevel); 209 var container = $('subpage-sheet-container-' + nestingLevel);
210 subpageBackdrop.style.zIndex = 210 subpageBackdrop.style.zIndex =
211 parseInt(window.getComputedStyle(container).zIndex) - 1; 211 parseInt(window.getComputedStyle(container).zIndex) - 1;
212 subpageBackdrop.hidden = false; 212 subpageBackdrop.hidden = false;
213 } else { 213 } else {
214 subpageBackdrop.hidden = true; 214 subpageBackdrop.hidden = true;
215 } 215 }
216 }; 216 };
217 217
218 /** 218 /**
219 * Scrolls the page to the correct position (the top when opening a subpage, 219 * Scrolls the page to the correct position (the top when opening a subpage,
220 * or the old scroll position a previously hidden subpage becomes visible). 220 * or the old scroll position a previously hidden subpage becomes visible).
221 * @private 221 * @private
222 */ 222 */
223 OptionsPage.updateScrollPosition_ = function () { 223 OptionsPage.updateScrollPosition_ = function() {
224 var topmostPage = OptionsPage.getTopmostVisibleNonOverlayPage_(); 224 var topmostPage = OptionsPage.getTopmostVisibleNonOverlayPage_();
225 var nestingLevel = topmostPage ? topmostPage.nestingLevel : 0; 225 var nestingLevel = topmostPage ? topmostPage.nestingLevel : 0;
226 226
227 var container = (nestingLevel > 0) ? 227 var container = (nestingLevel > 0) ?
228 $('subpage-sheet-container-' + nestingLevel) : $('page-container'); 228 $('subpage-sheet-container-' + nestingLevel) : $('page-container');
229 229
230 var scrollTop = container.oldScrollTop || 0; 230 var scrollTop = container.oldScrollTop || 0;
231 container.oldScrollTop = undefined; 231 container.oldScrollTop = undefined;
232 window.scroll(document.body.scrollLeft, scrollTop); 232 window.scroll(document.body.scrollLeft, scrollTop);
233 }; 233 };
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 overlay.didClosePage(); 568 overlay.didClosePage();
569 }; 569 };
570 570
571 /** 571 /**
572 * Freezes/unfreezes the scroll position of given level's page container. 572 * Freezes/unfreezes the scroll position of given level's page container.
573 * @param {boolean} freeze Whether the page should be frozen. 573 * @param {boolean} freeze Whether the page should be frozen.
574 * @param {number} level The level to freeze/unfreeze. 574 * @param {number} level The level to freeze/unfreeze.
575 * @private 575 * @private
576 */ 576 */
577 OptionsPage.setPageFrozenAtLevel_ = function(freeze, level) { 577 OptionsPage.setPageFrozenAtLevel_ = function(freeze, level) {
578 var container = level == 0 ? $('page-container') 578 var container = level == 0 ? $('page-container') :
579 : $('subpage-sheet-container-' + level); 579 $('subpage-sheet-container-' + level);
580 580
581 if (container.classList.contains('frozen') == freeze) 581 if (container.classList.contains('frozen') == freeze)
582 return; 582 return;
583 583
584 if (freeze) { 584 if (freeze) {
585 // Lock the width, since auto width computation may change. 585 // Lock the width, since auto width computation may change.
586 container.style.width = window.getComputedStyle(container).width; 586 container.style.width = window.getComputedStyle(container).width;
587 container.oldScrollTop = document.body.scrollTop; 587 container.oldScrollTop = document.body.scrollTop;
588 container.classList.add('frozen'); 588 container.classList.add('frozen');
589 var verticalPosition = 589 var verticalPosition =
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 var adjust = isRTL() ? 1 : -1; 752 var adjust = isRTL() ? 1 : -1;
753 var marginStart = document.body.scrollLeft * adjust + 'px'; 753 var marginStart = document.body.scrollLeft * adjust + 'px';
754 for (var i = 0; i < this.fixedHeaders_.length; ++i) 754 for (var i = 0; i < this.fixedHeaders_.length; ++i)
755 this.fixedHeaders_[i].style.webkitMarginStart = marginStart; 755 this.fixedHeaders_[i].style.webkitMarginStart = marginStart;
756 756
757 uber.invokeMethodOnParent('adjustToScroll', document.body.scrollLeft); 757 uber.invokeMethodOnParent('adjustToScroll', document.body.scrollLeft);
758 }; 758 };
759 759
760 /** 760 /**
761 * Updates the given frozen element to match the horizontal scroll position. 761 * Updates the given frozen element to match the horizontal scroll position.
762 * @param {HTMLElement} e The frozen element to update 762 * @param {HTMLElement} e The frozen element to update.
763 * @private 763 * @private
764 */ 764 */
765 OptionsPage.updateFrozenElementHorizontalPosition_ = function(e) { 765 OptionsPage.updateFrozenElementHorizontalPosition_ = function(e) {
766 if (isRTL()) 766 if (isRTL())
767 e.style.right = HORIZONTAL_OFFSET + 'px'; 767 e.style.right = HORIZONTAL_OFFSET + 'px';
768 else 768 else
769 e.style.left = HORIZONTAL_OFFSET - document.body.scrollLeft + 'px'; 769 e.style.left = HORIZONTAL_OFFSET - document.body.scrollLeft + 'px';
770 }; 770 };
771 771
772 /** 772 /**
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 * remain a top-level page even if sub-pages change. 1077 * remain a top-level page even if sub-pages change.
1078 * @type {boolean} True if this page is sticky. 1078 * @type {boolean} True if this page is sticky.
1079 */ 1079 */
1080 get sticky() { 1080 get sticky() {
1081 return false; 1081 return false;
1082 }, 1082 },
1083 1083
1084 /** 1084 /**
1085 * Checks whether this page is an ancestor of the given page in terms of 1085 * Checks whether this page is an ancestor of the given page in terms of
1086 * subpage nesting. 1086 * subpage nesting.
1087 * @param {OptionsPage} page 1087 * @param {OptionsPage} page The potential descendent of this page.
1088 * @return {boolean} True if this page is nested under |page| 1088 * @return {boolean} True if |page| is nested under this page.
1089 */ 1089 */
1090 isAncestorOfPage: function(page) { 1090 isAncestorOfPage: function(page) {
1091 var parent = page.parentPage; 1091 var parent = page.parentPage;
1092 while (parent) { 1092 while (parent) {
1093 if (parent == this) 1093 if (parent == this)
1094 return true; 1094 return true;
1095 parent = parent.parentPage; 1095 parent = parent.parentPage;
1096 } 1096 }
1097 return false; 1097 return false;
1098 }, 1098 },
1099 1099
1100 /** 1100 /**
1101 * Whether it should be possible to show the page. 1101 * Whether it should be possible to show the page.
1102 * @return {boolean} True if the page should be shown 1102 * @return {boolean} True if the page should be shown.
1103 */ 1103 */
1104 canShowPage: function() { 1104 canShowPage: function() {
1105 return true; 1105 return true;
1106 }, 1106 },
1107 }; 1107 };
1108 1108
1109 // Export 1109 // Export
1110 return { 1110 return {
1111 OptionsPage: OptionsPage 1111 OptionsPage: OptionsPage
1112 }; 1112 };
1113 }); 1113 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/options2/options.js ('k') | chrome/browser/resources/options2/password_manager.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698