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