OLD | NEW |
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 <include src="extension_error.js"></include> | 5 <include src="extension_error.js"></include> |
6 | 6 |
7 cr.define('options', function() { | 7 cr.define('options', function() { |
8 'use strict'; | 8 'use strict'; |
9 | 9 |
10 /** | 10 /** |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // Iterate over the extension data and add each item to the list. | 52 // Iterate over the extension data and add each item to the list. |
53 this.data_.extensions.forEach(this.createNode_, this); | 53 this.data_.extensions.forEach(this.createNode_, this); |
54 | 54 |
55 var idToHighlight = this.getIdQueryParam_(); | 55 var idToHighlight = this.getIdQueryParam_(); |
56 if (idToHighlight && $(idToHighlight)) { | 56 if (idToHighlight && $(idToHighlight)) { |
57 // Scroll offset should be calculated slightly higher than the actual | 57 // Scroll offset should be calculated slightly higher than the actual |
58 // offset of the element being scrolled to, so that it ends up not all | 58 // offset of the element being scrolled to, so that it ends up not all |
59 // the way at the top. That way it is clear that there are more elements | 59 // the way at the top. That way it is clear that there are more elements |
60 // above the element being scrolled to. | 60 // above the element being scrolled to. |
61 var scrollFudge = 1.2; | 61 var scrollFudge = 1.2; |
62 document.documentElement.scrollTop = $(idToHighlight).offsetTop - | 62 var scrollTop = |
63 scrollFudge * $(idToHighlight).clientHeight; | 63 $(idToHighlight).offsetTop - scrollFudge * |
| 64 $(idToHighlight).clientHeight; |
| 65 setScrollTopForDocument(document, scrollTop); |
64 } | 66 } |
65 | 67 |
66 if (this.data_.extensions.length == 0) | 68 if (this.data_.extensions.length == 0) |
67 this.classList.add('empty-extension-list'); | 69 this.classList.add('empty-extension-list'); |
68 else | 70 else |
69 this.classList.remove('empty-extension-list'); | 71 this.classList.remove('empty-extension-list'); |
70 }, | 72 }, |
71 | 73 |
72 /** | 74 /** |
73 * Synthesizes and initializes an HTML element for the extension metadata | 75 * Synthesizes and initializes an HTML element for the extension metadata |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 } | 331 } |
330 | 332 |
331 this.appendChild(node); | 333 this.appendChild(node); |
332 if (location.hash.substr(1) == extension.id) { | 334 if (location.hash.substr(1) == extension.id) { |
333 // Scroll beneath the fixed header so that the extension is not | 335 // Scroll beneath the fixed header so that the extension is not |
334 // obscured. | 336 // obscured. |
335 var topScroll = node.offsetTop - $('page-header').offsetHeight; | 337 var topScroll = node.offsetTop - $('page-header').offsetHeight; |
336 var pad = parseInt(getComputedStyle(node, null).marginTop, 10); | 338 var pad = parseInt(getComputedStyle(node, null).marginTop, 10); |
337 if (!isNaN(pad)) | 339 if (!isNaN(pad)) |
338 topScroll -= pad / 2; | 340 topScroll -= pad / 2; |
339 document.documentElement.scrollTop = topScroll; | 341 setScrollTopForDocument(document, topScroll); |
340 } | 342 } |
341 }, | 343 }, |
342 }; | 344 }; |
343 | 345 |
344 return { | 346 return { |
345 ExtensionsList: ExtensionsList | 347 ExtensionsList: ExtensionsList |
346 }; | 348 }; |
347 }); | 349 }); |
OLD | NEW |