| OLD | NEW |
| 1 | 1 |
| 2 // Helpers | 2 // Helpers |
| 3 | 3 |
| 4 // TODO(arv): Remove these when classList is available in HTML5. | 4 // TODO(arv): Remove these when classList is available in HTML5. |
| 5 // https://bugs.webkit.org/show_bug.cgi?id=20709 | 5 // https://bugs.webkit.org/show_bug.cgi?id=20709 |
| 6 function hasClass(el, name) { | 6 function hasClass(el, name) { |
| 7 return el.nodeType == 1 && el.className.split(/\s+/).indexOf(name) != -1; | 7 return el.nodeType == 1 && el.className.split(/\s+/).indexOf(name) != -1; |
| 8 } | 8 } |
| 9 | 9 |
| 10 function addClass(el, name) { | 10 function addClass(el, name) { |
| (...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1236 // to indicate if there is code in the backend which is capable of processing | 1236 // to indicate if there is code in the backend which is capable of processing |
| 1237 // this message. This attribute is loaded by the JSTemplate and therefore we | 1237 // this message. This attribute is loaded by the JSTemplate and therefore we |
| 1238 // must make sure we check the attribute after the DOM is loaded. | 1238 // must make sure we check the attribute after the DOM is loaded. |
| 1239 document.addEventListener('DOMContentLoaded', | 1239 document.addEventListener('DOMContentLoaded', |
| 1240 callGetSyncMessageIfSyncIsPresent); | 1240 callGetSyncMessageIfSyncIsPresent); |
| 1241 | 1241 |
| 1242 // This link allows user to make new tab page as homepage from the new tab | 1242 // This link allows user to make new tab page as homepage from the new tab |
| 1243 // page itself (without going to Options dialog box). | 1243 // page itself (without going to Options dialog box). |
| 1244 document.addEventListener('DOMContentLoaded', showSetAsHomePageLink); | 1244 document.addEventListener('DOMContentLoaded', showSetAsHomePageLink); |
| 1245 | 1245 |
| 1246 // Set up links and text-decoration for promotional message. |
| 1247 document.addEventListener('DOMContentLoaded', setUpPromoMessage); |
| 1248 |
| 1246 /** | 1249 /** |
| 1247 * The sync code is not yet built by default on all platforms so we have to | 1250 * The sync code is not yet built by default on all platforms so we have to |
| 1248 * make sure we don't send the initial sync message to the backend unless the | 1251 * make sure we don't send the initial sync message to the backend unless the |
| 1249 * backend told us that the sync code is present. | 1252 * backend told us that the sync code is present. |
| 1250 */ | 1253 */ |
| 1251 function callGetSyncMessageIfSyncIsPresent() { | 1254 function callGetSyncMessageIfSyncIsPresent() { |
| 1252 if (document.documentElement.getAttribute('syncispresent') == 'true') { | 1255 if (document.documentElement.getAttribute('syncispresent') == 'true') { |
| 1253 chrome.send('GetSyncMessage'); | 1256 chrome.send('GetSyncMessage'); |
| 1254 } | 1257 } |
| 1255 } | 1258 } |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1588 while (el.hasChildNodes()) { | 1591 while (el.hasChildNodes()) { |
| 1589 span.appendChild(el.firstChild); | 1592 span.appendChild(el.firstChild); |
| 1590 } | 1593 } |
| 1591 el.appendChild(span); | 1594 el.appendChild(span); |
| 1592 } | 1595 } |
| 1593 | 1596 |
| 1594 updateAttribution(); | 1597 updateAttribution(); |
| 1595 | 1598 |
| 1596 // Closes the promo line when close button is clicked. | 1599 // Closes the promo line when close button is clicked. |
| 1597 $('promo-close').onclick = function (e) { | 1600 $('promo-close').onclick = function (e) { |
| 1598 $('footer').className = 'hide-footer'; | 1601 $('promo-line').className = 'hide-promo-line'; |
| 1599 chrome.send('stopPromoLineMessage'); | 1602 chrome.send('stopPromoLineMessage'); |
| 1600 e.preventDefault(); | 1603 e.preventDefault(); |
| 1601 }; | 1604 }; |
| 1605 |
| 1606 // Set bookmark sync button to start bookmark sync process on click; also set |
| 1607 // link underline colors correctly. |
| 1608 function setUpPromoMessage() { |
| 1609 var syncButton = document.querySelector('#promo-message button'); |
| 1610 syncButton.className = 'sync-button link'; |
| 1611 syncButton.onclick = syncSectionLinkClicked; |
| 1612 fixLinkUnderlines($('promo-message')); |
| 1613 } |
| 1614 |
| 1615 // A Windows-specific Webkit bug adds padding to buttons and will push the |
| 1616 // bookmark sync button in the promo message too far to the right unless we |
| 1617 // use this fix. See https://bugs.webkit.org/show_bug.cgi?id=31703 |
| 1618 if (navigator.platform == 'Win32') { |
| 1619 addClass(document.body, 'win-button-padding-bug'); |
| 1620 } |
| OLD | NEW |