| 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 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1229 // Whether or not we should send the initial 'GetSyncMessage' to the backend | 1229 // Whether or not we should send the initial 'GetSyncMessage' to the backend |
| 1230 // depends on the value of the attribue 'syncispresent' which the backend sets | 1230 // depends on the value of the attribue 'syncispresent' which the backend sets |
| 1231 // to indicate if there is code in the backend which is capable of processing | 1231 // to indicate if there is code in the backend which is capable of processing |
| 1232 // this message. This attribute is loaded by the JSTemplate and therefore we | 1232 // this message. This attribute is loaded by the JSTemplate and therefore we |
| 1233 // must make sure we check the attribute after the DOM is loaded. | 1233 // must make sure we check the attribute after the DOM is loaded. |
| 1234 document.addEventListener('DOMContentLoaded', | 1234 document.addEventListener('DOMContentLoaded', |
| 1235 callGetSyncMessageIfSyncIsPresent); | 1235 callGetSyncMessageIfSyncIsPresent); |
| 1236 | 1236 |
| 1237 // This link allows user to make new tab page as homepage from the new tab | 1237 // This link allows user to make new tab page as homepage from the new tab |
| 1238 // page itself (without going to Options dialog box). | 1238 // page itself (without going to Options dialog box). |
| 1239 document.addEventListener('DOMContentLoaded', showSetAsHomepageLink); | 1239 document.addEventListener('DOMContentLoaded', showSetAsHomePageLink); |
| 1240 | 1240 |
| 1241 /** | 1241 /** |
| 1242 * The sync code is not yet built by default on all platforms so we have to | 1242 * The sync code is not yet built by default on all platforms so we have to |
| 1243 * make sure we don't send the initial sync message to the backend unless the | 1243 * make sure we don't send the initial sync message to the backend unless the |
| 1244 * backend told us that the sync code is present. | 1244 * backend told us that the sync code is present. |
| 1245 */ | 1245 */ |
| 1246 function callGetSyncMessageIfSyncIsPresent() { | 1246 function callGetSyncMessageIfSyncIsPresent() { |
| 1247 if (document.documentElement.getAttribute('syncispresent') == 'true') { | 1247 if (document.documentElement.getAttribute('syncispresent') == 'true') { |
| 1248 chrome.send('GetSyncMessage'); | 1248 chrome.send('GetSyncMessage'); |
| 1249 } | 1249 } |
| 1250 } | 1250 } |
| 1251 | 1251 |
| 1252 function setAsHomePageLinkClicked(e) { | 1252 function setAsHomePageLinkClicked(e) { |
| 1253 chrome.send('SetHomepageLinkClicked'); | 1253 chrome.send('setHomePage'); |
| 1254 e.preventDefault(); | 1254 e.preventDefault(); |
| 1255 } | 1255 } |
| 1256 | 1256 |
| 1257 function showSetAsHomepageLink() { | 1257 function showSetAsHomePageLink() { |
| 1258 var setAsHomepageElement = $('set-as-homepage'); | 1258 var setAsHomePageElement = $('set-as-home-page'); |
| 1259 var style = setAsHomepageElement.style; | 1259 var style = setAsHomePageElement.style; |
| 1260 if (document.documentElement.getAttribute('showsetashomepage') != 'true') { | 1260 if (document.documentElement.getAttribute('showsetashomepage') != 'true') { |
| 1261 // Hide the section (if new tab page is already homepage). | 1261 // Hide the section (if new tab page is already homepage). |
| 1262 return; | 1262 return; |
| 1263 } | 1263 } |
| 1264 | 1264 |
| 1265 style.display = 'block'; | 1265 style.display = 'block'; |
| 1266 var buttonElement = setAsHomepageElement.firstElementChild; | 1266 var buttonElement = setAsHomePageElement.firstElementChild; |
| 1267 buttonElement.addEventListener('click', setAsHomePageLinkClicked); | 1267 buttonElement.addEventListener('click', setAsHomePageLinkClicked); |
| 1268 } | 1268 } |
| 1269 | 1269 |
| 1270 function onHomePageSet(data) { |
| 1271 $('set-as-home-page').style.display = 'none'; |
| 1272 showNotification(data[0], data[1]); |
| 1273 } |
| 1274 |
| 1270 function hideAllMenus() { | 1275 function hideAllMenus() { |
| 1271 optionMenu.hide(); | 1276 optionMenu.hide(); |
| 1272 } | 1277 } |
| 1273 | 1278 |
| 1274 window.addEventListener('blur', hideAllMenus); | 1279 window.addEventListener('blur', hideAllMenus); |
| 1275 window.addEventListener('keydown', function(e) { | 1280 window.addEventListener('keydown', function(e) { |
| 1276 if (e.keyIdentifier == 'Alt' || e.keyIdentifier == 'Meta') { | 1281 if (e.keyIdentifier == 'Alt' || e.keyIdentifier == 'Meta') { |
| 1277 hideAllMenus(); | 1282 hideAllMenus(); |
| 1278 } | 1283 } |
| 1279 }, true); | 1284 }, true); |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1575 function fixLinkUnderline(el) { | 1580 function fixLinkUnderline(el) { |
| 1576 var span = document.createElement('span'); | 1581 var span = document.createElement('span'); |
| 1577 span.className = 'link-color'; | 1582 span.className = 'link-color'; |
| 1578 while (el.hasChildNodes()) { | 1583 while (el.hasChildNodes()) { |
| 1579 span.appendChild(el.firstChild); | 1584 span.appendChild(el.firstChild); |
| 1580 } | 1585 } |
| 1581 el.appendChild(span); | 1586 el.appendChild(span); |
| 1582 } | 1587 } |
| 1583 | 1588 |
| 1584 updateAttribution(); | 1589 updateAttribution(); |
| OLD | NEW |