| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 var loading = true; | 5 var loading = true; |
| 6 | 6 |
| 7 function updateSimpleSection(id, section) { | 7 function updateSimpleSection(id, section) { |
| 8 if (shownSections & section) | 8 if (shownSections & section) |
| 9 $(id).classList.remove('hidden'); | 9 $(id).classList.remove('hidden'); |
| 10 else | 10 else |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 executeItem: function(item) { | 580 executeItem: function(item) { |
| 581 var command = item.getAttribute('command'); | 581 var command = item.getAttribute('command'); |
| 582 if (command in this.commands) { | 582 if (command in this.commands) { |
| 583 this.commands[command].call(this, item); | 583 this.commands[command].call(this, item); |
| 584 } | 584 } |
| 585 | 585 |
| 586 this.hide(); | 586 this.hide(); |
| 587 } | 587 } |
| 588 }; | 588 }; |
| 589 | 589 |
| 590 // TODO(aa): The 'clear-all-blacklisted' feature needs to move into a menu in |
| 591 // the most visited section. |
| 592 /* |
| 590 var optionMenu = new OptionMenu($('option-button'), $('option-menu')); | 593 var optionMenu = new OptionMenu($('option-button'), $('option-menu')); |
| 591 optionMenu.commands = { | 594 optionMenu.commands = { |
| 592 'clear-all-blacklisted' : function() { | 595 'clear-all-blacklisted' : function() { |
| 593 mostVisited.clearAllBlacklisted(); | 596 mostVisited.clearAllBlacklisted(); |
| 594 chrome.send('getMostVisited'); | 597 chrome.send('getMostVisited'); |
| 595 }, | 598 }, |
| 596 'show': function(item) { | 599 'show': function(item) { |
| 597 var section = Section[item.getAttribute('section')]; | 600 var section = Section[item.getAttribute('section')]; |
| 598 showSection(section); | 601 showSection(section); |
| 599 saveShownSections(); | 602 saveShownSections(); |
| 600 }, | 603 }, |
| 601 'hide': function(item) { | 604 'hide': function(item) { |
| 602 var section = Section[item.getAttribute('section')]; | 605 var section = Section[item.getAttribute('section')]; |
| 603 hideSection(section); | 606 hideSection(section); |
| 604 saveShownSections(); | 607 saveShownSections(); |
| 605 } | 608 } |
| 606 }; | 609 }; |
| 610 */ |
| 607 | 611 |
| 608 $('main').addEventListener('click', function(e) { | 612 $('main').addEventListener('click', function(e) { |
| 609 if (e.target.tagName == 'H2') { | 613 var p = e.target; |
| 610 var p = e.target.parentNode; | 614 while (p && p.tagName != 'H2') { |
| 615 p = p.parentNode; |
| 616 } |
| 617 |
| 618 if (p) { |
| 619 p = p.parentNode; |
| 611 var section = p.getAttribute('section'); | 620 var section = p.getAttribute('section'); |
| 612 if (section) { | 621 if (section) { |
| 613 if (shownSections & Section[section]) | 622 if (shownSections & Section[section]) |
| 614 hideSection(Section[section]); | 623 hideSection(Section[section]); |
| 615 else | 624 else |
| 616 showSection(Section[section]); | 625 showSection(Section[section]); |
| 617 saveShownSections(); | 626 saveShownSections(); |
| 618 } | 627 } |
| 619 } | 628 } |
| 620 }); | 629 }); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 * make sure we don't send the initial sync message to the backend unless the | 808 * make sure we don't send the initial sync message to the backend unless the |
| 800 * backend told us that the sync code is present. | 809 * backend told us that the sync code is present. |
| 801 */ | 810 */ |
| 802 function callGetSyncMessageIfSyncIsPresent() { | 811 function callGetSyncMessageIfSyncIsPresent() { |
| 803 if (document.documentElement.getAttribute('syncispresent') == 'true') { | 812 if (document.documentElement.getAttribute('syncispresent') == 'true') { |
| 804 chrome.send('GetSyncMessage'); | 813 chrome.send('GetSyncMessage'); |
| 805 } | 814 } |
| 806 } | 815 } |
| 807 | 816 |
| 808 function hideAllMenus() { | 817 function hideAllMenus() { |
| 809 optionMenu.hide(); | 818 // TODO(aa): See comment in definition of optionMenu. |
| 819 //optionMenu.hide(); |
| 810 } | 820 } |
| 811 | 821 |
| 812 window.addEventListener('blur', hideAllMenus); | 822 window.addEventListener('blur', hideAllMenus); |
| 813 window.addEventListener('keydown', function(e) { | 823 window.addEventListener('keydown', function(e) { |
| 814 if (e.keyIdentifier == 'Alt' || e.keyIdentifier == 'Meta') { | 824 if (e.keyIdentifier == 'Alt' || e.keyIdentifier == 'Meta') { |
| 815 hideAllMenus(); | 825 hideAllMenus(); |
| 816 } | 826 } |
| 817 }, true); | 827 }, true); |
| 818 | 828 |
| 819 // Tooltip for elements that have text that overflows. | 829 // Tooltip for elements that have text that overflows. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 window.setTimeout(function() { | 887 window.setTimeout(function() { |
| 878 mostVisited.ensureSmallGridCorrect(); | 888 mostVisited.ensureSmallGridCorrect(); |
| 879 document.body.classList.remove('loading'); | 889 document.body.classList.remove('loading'); |
| 880 }, 1); | 890 }, 1); |
| 881 | 891 |
| 882 // Only show the first run notification if first run. | 892 // Only show the first run notification if first run. |
| 883 if (firstRun) { | 893 if (firstRun) { |
| 884 showFirstRunNotification(); | 894 showFirstRunNotification(); |
| 885 } | 895 } |
| 886 } | 896 } |
| OLD | NEW |