| OLD | NEW |
| (Empty) |
| 1 /* Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 Use of this source code is governed by a BSD-style license that can be | |
| 3 found in the LICENSE file. | |
| 4 */ | |
| 5 | |
| 6 <include src="../../../../ui/webui/resources/js/util.js"> | |
| 7 <include src="../../../../ui/webui/resources/js/load_time_data.js"> | |
| 8 | |
| 9 /** | |
| 10 * The amount of delay to use in the opt-in action in order to give time for | |
| 11 * the fade-out animation to execute, before navigating to the opt-in URL, | |
| 12 * in milliseconds. | |
| 13 * @const | |
| 14 */ | |
| 15 var OPT_IN_DELAY_MS = 65; | |
| 16 | |
| 17 /** | |
| 18 * Once the DOM is loaded, determine if the header image is to be kept and | |
| 19 * register a handler to add the 'hide' class to the container element in order | |
| 20 * to hide it. | |
| 21 */ | |
| 22 document.addEventListener('DOMContentLoaded', function(event) { | |
| 23 if (config['hideHeader']) { | |
| 24 removeHeaderImages(); | |
| 25 } | |
| 26 $('optin-button').addEventListener('click', function() { | |
| 27 $('container').classList.add('hide'); | |
| 28 setTimeout(function() { | |
| 29 location.hash = 'optin'; | |
| 30 }, OPT_IN_DELAY_MS); | |
| 31 }); | |
| 32 $('optout-button').addEventListener('click', function() { | |
| 33 location.hash = 'optout'; | |
| 34 }); | |
| 35 }); | |
| 36 | |
| 37 /** | |
| 38 * Returns the height of the content. Method called from Chrome to properly size | |
| 39 * the view embedding it. | |
| 40 * @return {number} The height of the content, in pixels. | |
| 41 */ | |
| 42 function getContentHeight() { | |
| 43 return $('container').clientHeight; | |
| 44 } | |
| 45 | |
| 46 /** | |
| 47 * Removes all header images from the promo. | |
| 48 */ | |
| 49 function removeHeaderImages() { | |
| 50 var images = document.querySelectorAll('.header-image'); | |
| 51 for (var i = 0, length = images.length; i < length; i++) { | |
| 52 var image = images[i]; | |
| 53 var parent = image.parentElement; | |
| 54 if (parent) { | |
| 55 parent.removeChild(image); | |
| 56 } | |
| 57 } | |
| 58 } | |
| OLD | NEW |