OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 /** | 5 /** |
6 * @fileoverview Page switcher | 6 * @fileoverview Page switcher |
7 * This is the class for the left and right navigation arrows that switch | 7 * This is the class for the left and right navigation arrows that switch |
8 * between pages. | 8 * between pages. |
9 */ | 9 */ |
10 cr.define('ntp4', function() { | 10 cr.define('ntp4', function() { |
11 | 11 |
12 function PageSwitcher() { | 12 function PageSwitcher() { |
13 } | 13 } |
14 | 14 |
15 PageSwitcher.template = { | 15 PageSwitcher.template = { |
16 __proto__: HTMLButtonElement.prototype, | 16 __proto__: HTMLButtonElement.prototype, |
17 | 17 |
18 decorate: function(el) { | 18 decorate: function(el) { |
19 el.__proto__ = PageSwitcher.template; | 19 el.__proto__ = PageSwitcher.template; |
20 | 20 |
21 el.addEventListener('click', el.activate_); | 21 el.addEventListener('click', el.activate_); |
22 el.addEventListener('mousewheel', el.onMouseWheel_); | 22 el.addEventListener('mousewheel', el.onMouseWheel_); |
23 | 23 |
24 el.direction_ = el.id == 'page-switcher-start' ? -1 : 1; | 24 el.direction_ = el.id == 'page-switcher-start' ? -1 : 1; |
25 | 25 |
26 el.dragWrapper_ = new DragWrapper(el, el); | 26 el.dragWrapper_ = new cr.ui.DragWrapper(el, el); |
27 }, | 27 }, |
28 | 28 |
29 /** | 29 /** |
30 * Activate the switcher (go to the next card). | 30 * Activate the switcher (go to the next card). |
31 * @private | 31 * @private |
32 */ | 32 */ |
33 activate_: function() { | 33 activate_: function() { |
34 var cardSlider = ntp4.getCardSlider(); | 34 var cardSlider = ntp4.getCardSlider(); |
35 cardSlider.selectCard(cardSlider.currentCard + this.direction_, true); | 35 cardSlider.selectCard(cardSlider.currentCard + this.direction_, true); |
36 }, | 36 }, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 this.dragNavTimeout_ = null; | 109 this.dragNavTimeout_ = null; |
110 } | 110 } |
111 }, | 111 }, |
112 | 112 |
113 }; | 113 }; |
114 | 114 |
115 return { | 115 return { |
116 initializePageSwitcher: PageSwitcher.template.decorate | 116 initializePageSwitcher: PageSwitcher.template.decorate |
117 } | 117 } |
118 }); | 118 }); |
OLD | NEW |