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

Unified Diff: chrome/browser/resources/ntp4/dot_list.js

Issue 8423055: [Aura] Initial app list webui. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove grabber.js Created 9 years, 1 month 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/ntp4/card_slider.js ('k') | chrome/browser/resources/ntp4/drag_wrapper.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/ntp4/dot_list.js
diff --git a/chrome/browser/resources/ntp4/dot_list.js b/chrome/browser/resources/ntp4/dot_list.js
new file mode 100644
index 0000000000000000000000000000000000000000..45b615af5f6ffc2cc0e9ae4217ce754718b12f3e
--- /dev/null
+++ b/chrome/browser/resources/ntp4/dot_list.js
@@ -0,0 +1,80 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @fileoverview DotList implementation
+ */
+
+cr.define('ntp4', function() {
+ 'use strict';
+
+ /**
+ * Live list of the navigation dots.
+ * @type {!NodeList|undefined}
+ */
+ var navDots;
+
+ /**
+ * Creates a new DotList object.
+ * @constructor
+ * @extends {HTMLUListElement}
+ */
+ var DotList = cr.ui.define('ul');
+
+ DotList.prototype = {
+ __proto__: HTMLUListElement.prototype,
+
+ /** @inheritDoc */
+ decorate: function() {
+ this.addEventListener('keydown', this.onKeyDown_.bind(this));
+ navDots = this.getElementsByClassName('dot');
+ },
+
+ /**
+ * Live list of the navigation dots.
+ * @type {!NodeList|undefined}
+ */
+ get dots() {
+ return navDots;
+ },
+
+ /**
+ * Handler for key events on the dot list. These keys will change the focus
+ * element.
+ * @param {Event} e The KeyboardEvent.
+ */
+ onKeyDown_: function(e) {
+ if (e.metaKey || e.shiftKey || e.altKey || e.ctrlKey)
+ return;
+
+ var direction = 0;
+ if (e.keyIdentifier == 'Left')
+ direction = -1;
+ else if (e.keyIdentifier == 'Right')
+ direction = 1;
+ else
+ return;
+
+ var focusDot = this.querySelector('.dot:focus');
+ if (!focusDot)
+ return;
+ var focusIndex = Array.prototype.indexOf.call(navDots, focusDot);
+ var newFocusIndex = focusIndex + direction;
+ if (focusIndex == newFocusIndex)
+ return;
+
+ newFocusIndex = (newFocusIndex + navDots.length) % navDots.length;
+ navDots[newFocusIndex].tabIndex = 3;
+ navDots[newFocusIndex].focus();
+ focusDot.tabIndex = -1;
+
+ e.stopPropagation();
+ e.preventDefault();
+ }
+ };
+
+ return {
+ DotList: DotList
+ };
+});
« no previous file with comments | « chrome/browser/resources/ntp4/card_slider.js ('k') | chrome/browser/resources/ntp4/drag_wrapper.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698