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 // Dependencies that we should remove/formalize: | 5 // Dependencies that we should remove/formalize: |
6 // ../shared/js/class_list.js | 6 // ../shared/js/class_list.js |
7 // util.js | 7 // util.js |
8 // | 8 // |
9 // afterTransition | 9 // afterTransition |
10 // chrome.send | 10 // chrome.send |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 this.createThumbnails_(); | 50 this.createThumbnails_(); |
51 this.applyMostVisitedRects_(); | 51 this.applyMostVisitedRects_(); |
52 | 52 |
53 el.addEventListener('click', bind(this.handleClick_, this)); | 53 el.addEventListener('click', bind(this.handleClick_, this)); |
54 el.addEventListener('keydown', bind(this.handleKeyDown_, this)); | 54 el.addEventListener('keydown', bind(this.handleKeyDown_, this)); |
55 | 55 |
56 document.addEventListener('DOMContentLoaded', | 56 document.addEventListener('DOMContentLoaded', |
57 bind(this.ensureSmallGridCorrect, this)); | 57 bind(this.ensureSmallGridCorrect, this)); |
58 | 58 |
| 59 // Commands |
| 60 document.addEventListener('command', bind(this.handleCommand_, this)); |
| 61 document.addEventListener('canExecute', bind(this.handleCanExecute_, this)); |
| 62 |
59 // DND | 63 // DND |
60 el.addEventListener('dragstart', bind(this.handleDragStart_, this)); | 64 el.addEventListener('dragstart', bind(this.handleDragStart_, this)); |
61 el.addEventListener('dragenter', bind(this.handleDragEnter_, this)); | 65 el.addEventListener('dragenter', bind(this.handleDragEnter_, this)); |
62 el.addEventListener('dragover', bind(this.handleDragOver_, this)); | 66 el.addEventListener('dragover', bind(this.handleDragOver_, this)); |
63 el.addEventListener('dragleave', bind(this.handleDragLeave_, this)); | 67 el.addEventListener('dragleave', bind(this.handleDragLeave_, this)); |
64 el.addEventListener('drop', bind(this.handleDrop_, this)); | 68 el.addEventListener('drop', bind(this.handleDrop_, this)); |
65 el.addEventListener('dragend', bind(this.handleDragEnd_, this)); | 69 el.addEventListener('dragend', bind(this.handleDragEnd_, this)); |
66 el.addEventListener('drag', bind(this.handleDrag_, this)); | 70 el.addEventListener('drag', bind(this.handleDrag_, this)); |
67 el.addEventListener('mousedown', bind(this.handleMouseDown_, this)); | 71 el.addEventListener('mousedown', bind(this.handleMouseDown_, this)); |
68 } | 72 } |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 // Work around for http://crbug.com/25329 | 297 // Work around for http://crbug.com/25329 |
294 ensureSmallGridCorrect: function(expected) { | 298 ensureSmallGridCorrect: function(expected) { |
295 if (expected != this.useSmallGrid) | 299 if (expected != this.useSmallGrid) |
296 this.applyMostVisitedRects_(); | 300 this.applyMostVisitedRects_(); |
297 }, | 301 }, |
298 | 302 |
299 getRectByIndex_: function(index) { | 303 getRectByIndex_: function(index) { |
300 return this.getMostVisitedLayoutRects_()[index]; | 304 return this.getMostVisitedLayoutRects_()[index]; |
301 }, | 305 }, |
302 | 306 |
| 307 // Commands |
| 308 |
| 309 handleCommand_: function(e) { |
| 310 var commandId = e.command.id; |
| 311 switch (commandId) { |
| 312 case 'clear-all-blacklisted': |
| 313 this.clearAllBlacklisted(); |
| 314 chrome.send('getMostVisited'); |
| 315 break; |
| 316 } |
| 317 }, |
| 318 |
| 319 handleCanExecute_: function(e) { |
| 320 if (e.command.id == 'clear-all-blacklisted') |
| 321 e.canExecute = true; |
| 322 }, |
| 323 |
303 // DND | 324 // DND |
304 | 325 |
305 currentOverItem_: null, | 326 currentOverItem_: null, |
306 get currentOverItem() { | 327 get currentOverItem() { |
307 return this.currentOverItem_; | 328 return this.currentOverItem_; |
308 }, | 329 }, |
309 set currentOverItem(item) { | 330 set currentOverItem(item) { |
310 var style; | 331 var style; |
311 if (item != this.currentOverItem_) { | 332 if (item != this.currentOverItem_) { |
312 if (this.currentOverItem_) { | 333 if (this.currentOverItem_) { |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 handleKeyDown_: function(e) { | 628 handleKeyDown_: function(e) { |
608 if (!IS_MAC && e.keyCode == 46 || // Del | 629 if (!IS_MAC && e.keyCode == 46 || // Del |
609 IS_MAC && e.metaKey && e.keyCode == 8) { // Cmd + Backspace | 630 IS_MAC && e.metaKey && e.keyCode == 8) { // Cmd + Backspace |
610 this.blacklist(e.target); | 631 this.blacklist(e.target); |
611 } | 632 } |
612 } | 633 } |
613 }; | 634 }; |
614 | 635 |
615 return MostVisited; | 636 return MostVisited; |
616 })(); | 637 })(); |
OLD | NEW |