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 = $(idToHighlight).offsetTop - scrollFudge * $(idToHighlig ht).clientHeight; |
Dan Beam
2013/11/11 23:46:46
80 col wrap
| |
63 scrollFudge * $(idToHighlight).clientHeight; | 63 setScrollTopForDocument(document, scrollTop); |
64 } | 64 } |
65 | 65 |
66 if (this.data_.extensions.length == 0) | 66 if (this.data_.extensions.length == 0) |
67 this.classList.add('empty-extension-list'); | 67 this.classList.add('empty-extension-list'); |
68 else | 68 else |
69 this.classList.remove('empty-extension-list'); | 69 this.classList.remove('empty-extension-list'); |
70 }, | 70 }, |
71 | 71 |
72 /** | 72 /** |
73 * Synthesizes and initializes an HTML element for the extension metadata | 73 * Synthesizes and initializes an HTML element for the extension metadata |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
329 } | 329 } |
330 | 330 |
331 this.appendChild(node); | 331 this.appendChild(node); |
332 if (location.hash.substr(1) == extension.id) { | 332 if (location.hash.substr(1) == extension.id) { |
333 // Scroll beneath the fixed header so that the extension is not | 333 // Scroll beneath the fixed header so that the extension is not |
334 // obscured. | 334 // obscured. |
335 var topScroll = node.offsetTop - $('page-header').offsetHeight; | 335 var topScroll = node.offsetTop - $('page-header').offsetHeight; |
336 var pad = parseInt(getComputedStyle(node, null).marginTop, 10); | 336 var pad = parseInt(getComputedStyle(node, null).marginTop, 10); |
337 if (!isNaN(pad)) | 337 if (!isNaN(pad)) |
338 topScroll -= pad / 2; | 338 topScroll -= pad / 2; |
339 document.documentElement.scrollTop = topScroll; | 339 setScrollTopForDocument(document, topScroll); |
340 } | 340 } |
341 }, | 341 }, |
342 }; | 342 }; |
343 | 343 |
344 return { | 344 return { |
345 ExtensionsList: ExtensionsList | 345 ExtensionsList: ExtensionsList |
346 }; | 346 }; |
347 }); | 347 }); |
OLD | NEW |