Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Unified Diff: chrome/browser/resources/new_new_tab.js

Issue 164378: Merge 22704 - NNTP: Add a menu item that allows the user to restore all black... (Closed) Base URL: svn://chrome-svn/chrome/branches/195/src/
Patch Set: Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/new_new_tab.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/new_new_tab.js
===================================================================
--- chrome/browser/resources/new_new_tab.js (revision 23151)
+++ chrome/browser/resources/new_new_tab.js (working copy)
@@ -748,11 +748,14 @@
var menuItems = $('option-menu').children;
for (var i = 0; i < menuItems.length; i++) {
var item = menuItems[i];
- var section = Section[item.getAttribute('section')];
- var show = item.getAttribute('show') == 'true';
- // Hide show items if already shown. Hide hide items if already hidden.
- var hideMenuItem = show == !!(shownSections & section);
- item.style.display = hideMenuItem ? 'none' : '';
+ var command = item.getAttribute('command');
+ if (command == 'show' || command == 'hide') {
+ var show = command == 'show';
+ var section = Section[item.getAttribute('section')];
+ // Hide show items if already shown. Hide hide items if already hidden.
+ var hideMenuItem = show == !!(shownSections & section);
+ item.style.display = hideMenuItem ? 'none' : '';
+ }
}
}
@@ -895,8 +898,12 @@
handleMouseOver: function(e) {
var el = e.target;
- var index = Array.prototype.indexOf.call(this.menu.children, el);
- this.setSelectedIndex(index);
+ if (!el.hasAttribute('command')) {
+ this.setSelectedIndex(-1);
+ } else {
+ var index = Array.prototype.indexOf.call(this.menu.children, el);
+ this.setSelectedIndex(index);
+ }
},
handleMouseOut: function(e) {
@@ -925,7 +932,8 @@
while (true) {
i = (i + m + len) % len;
item = children[i];
- if (item && item.style.display != 'none') {
+ if (item && item.hasAttribute('command') &&
+ item.style.display != 'none') {
break;
}
}
@@ -990,20 +998,32 @@
},
executeItem: function(item) {
- var section = Section[item.getAttribute('section')];
- var show = item.getAttribute('show') == 'true';
- if (show) {
- showSection(section);
- } else {
- hideSection(section);
+ var command = item.getAttribute('command');
+ if (command in this.commands) {
+ this.commands[command].call(this, item);
}
this.hide();
- saveShownSections();
}
};
var optionMenu = new OptionMenu($('option-button'), $('option-menu'));
+optionMenu.commands = {
+ 'clear-all-blacklisted' : function() {
+ mostVisited.clearAllBlacklisted();
+ chrome.send('getMostVisited');
+ },
+ 'show': function(item) {
+ var section = Section[item.getAttribute('section')];
+ showSection(section);
+ saveShownSections();
+ },
+ 'hide': function(item) {
+ var section = Section[item.getAttribute('section')];
+ hideSection(section);
+ saveShownSections();
+ }
+};
$('most-visited').addEventListener('click', function(e) {
var target = e.target;
Property changes on: chrome\browser\resources\new_new_tab.js
___________________________________________________________________
Modified: svn:mergeinfo
Merged /trunk/src/chrome/browser/resources/new_new_tab.js:r22704
« no previous file with comments | « chrome/browser/resources/new_new_tab.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698