| Index: chrome/browser/resources/chromeos/menu.js
|
| diff --git a/chrome/browser/resources/chromeos/menu.js b/chrome/browser/resources/chromeos/menu.js
|
| index 68fc48e04026b9805f465d3db122ec041f1d96dc..598e58bfdc3b34bd3ede4eb9548dab0c49b8e853 100644
|
| --- a/chrome/browser/resources/chromeos/menu.js
|
| +++ b/chrome/browser/resources/chromeos/menu.js
|
| @@ -33,7 +33,7 @@ function sendActivate(index, mode) {
|
| var MenuItem = cr.ui.define('div');
|
|
|
| MenuItem.prototype = {
|
| - __proto__ : HTMLDivElement.prototype,
|
| + __proto__: HTMLDivElement.prototype,
|
|
|
| /**
|
| * Decorates the menu item element.
|
| @@ -190,57 +190,51 @@ Menu.prototype = {
|
| * Configuration object.
|
| * @type {Object}
|
| */
|
| - config_ : null,
|
| + config_: null,
|
|
|
| /**
|
| * Currently selected menu item.
|
| * @type {MenuItem}
|
| */
|
| - current_ : null,
|
| + current_: null,
|
|
|
| /**
|
| * Timers for opening/closing submenu.
|
| * @type {number}
|
| */
|
| - openSubmenuTimer_ : 0,
|
| - closeSubmenuTimer_ : 0,
|
| + openSubmenuTimer_: 0,
|
| + closeSubmenuTimer_: 0,
|
|
|
| /**
|
| * Auto scroll timer.
|
| * @type {number}
|
| */
|
| - scrollTimer_ : 0,
|
| + scrollTimer_: 0,
|
|
|
| /**
|
| * Pointer to a submenu currently shown, if any.
|
| * @type {MenuItem}
|
| */
|
| - submenuShown_ : null,
|
| + submenuShown_: null,
|
|
|
| /**
|
| * True if this menu is root.
|
| * @type {boolean}
|
| */
|
| - isRoot_ : false,
|
| -
|
| - /**
|
| - * Scrollable Viewport.
|
| - * @type {HTMLElement}
|
| - */
|
| - viewpotr_ : null,
|
| + isRoot_: false,
|
|
|
| /**
|
| * Total hight of scroll buttons. Used to adjust the height of
|
| * viewport in order to show scroll bottons without scrollbar.
|
| * @type {number}
|
| */
|
| - buttonHeight_ : 0,
|
| + buttonHeight_: 0,
|
|
|
| /**
|
| * True to enable scroll button.
|
| * @type {boolean}
|
| */
|
| - scrollEnabled : false,
|
| + scrollEnabled: false,
|
|
|
| /**
|
| * Decorates the menu element.
|
| @@ -269,8 +263,8 @@ Menu.prototype = {
|
| window.addEventListener('resize', this.onResize_.bind(this));
|
|
|
| // Setup scroll events.
|
| - var up = document.getElementById('scroll-up');
|
| - var down = document.getElementById('scroll-down');
|
| + var up = $('scroll-up');
|
| + var down = $('scroll-down');
|
| up.addEventListener('mouseout', this.stopScroll_.bind(this));
|
| down.addEventListener('mouseout', this.stopScroll_.bind(this));
|
| var menu = this;
|
| @@ -320,7 +314,7 @@ Menu.prototype = {
|
| },
|
|
|
| /**
|
| - * Returns the index of the {@code item}.
|
| + * @return {number} The index of the {@code item}.
|
| */
|
| getMenuItemIndexOf: function(item) {
|
| return this.items_.indexOf(item);
|
| @@ -331,6 +325,7 @@ Menu.prototype = {
|
| * of MenuItem, or any HTMLElement that implements {@code init},
|
| * {@code activate} methods as well as {@code selected} attribute.
|
| * @param {Object} attrs The menu item's properties passed from C++.
|
| + * @return {MenuItem} The created menu item.
|
| */
|
| createMenuItem: function(attrs) {
|
| return new MenuItem();
|
| @@ -362,7 +357,7 @@ Menu.prototype = {
|
| showSelection: function() {
|
| if (this.current_) {
|
| this.current_.selected = true;
|
| - } else {
|
| + } else {
|
| this.findNextEnabled_(1).selected = true;
|
| }
|
| },
|
| @@ -467,7 +462,7 @@ Menu.prototype = {
|
| case 'U+0009': // tab
|
| break;
|
| case 'U+001B': // escape
|
| - chrome.send('close_all', []);
|
| + chrome.send('close_all');
|
| break;
|
| case 'Enter':
|
| case 'U+0020': // space
|
| @@ -513,8 +508,8 @@ Menu.prototype = {
|
| },
|
|
|
| onResize_: function() {
|
| - var up = document.getElementById('scroll-up');
|
| - var down = document.getElementById('scroll-down');
|
| + var up = $('scroll-up');
|
| + var down = $('scroll-down');
|
| // this needs to be < 2 as empty page has height of 1.
|
| if (window.innerHeight < 2) {
|
| // menu window is not visible yet. just hide buttons.
|
| @@ -549,7 +544,7 @@ Menu.prototype = {
|
| closeSubmenu_: function(item) {
|
| this.submenuShown_ = null;
|
| this.cancelSubmenuTimer_();
|
| - chrome.send('close_submenu', []);
|
| + chrome.send('close_submenu');
|
| },
|
|
|
| /**
|
| @@ -562,7 +557,7 @@ Menu.prototype = {
|
| if (this.current_) {
|
| this.current_.selected = false;
|
| }
|
| - chrome.send('move_to_parent', []);
|
| + chrome.send('move_to_parent');
|
| }
|
| },
|
|
|
| @@ -571,21 +566,21 @@ Menu.prototype = {
|
| * menu is a submenu.
|
| * @private
|
| */
|
| - moveToSubmenu_: function () {
|
| + moveToSubmenu_: function() {
|
| var current = this.current_;
|
| if (current && current.attrs.type == 'submenu') {
|
| this.openSubmenu(current);
|
| - chrome.send('move_to_submenu', []);
|
| + chrome.send('move_to_submenu');
|
| }
|
| },
|
|
|
| /**
|
| - * Find a next selectable item. If nothing is selected, the 1st
|
| - * selectable item will be chosen. Returns null if nothing is
|
| - * selectable.
|
| + * Finds the next selectable item. If nothing is selected, the first
|
| + * selectable item will be chosen. Returns null if nothing is selectable.
|
| * @param {number} incr Specifies the direction to search, 1 to
|
| - * downwards and -1 for upwards.
|
| + * downwards and -1 for upwards.
|
| * @private
|
| + * @return {MenuItem} The next selectable item.
|
| */
|
| findNextEnabled_: function(incr) {
|
| var len = this.items_.length;
|
| @@ -636,7 +631,7 @@ Menu.prototype = {
|
| * Stops auto scroll.
|
| * @private
|
| */
|
| - stopScroll_: function () {
|
| + stopScroll_: function() {
|
| clearTimeout(this.scrollTimer_);
|
| this.scrollTimer_ = 0;
|
| },
|
| @@ -645,30 +640,31 @@ Menu.prototype = {
|
| * Scrolls the viewport to make the selected item visible.
|
| * @private
|
| */
|
| - makeSelectedItemVisible_: function(){
|
| + makeSelectedItemVisible_: function() {
|
| this.current_.scrollIntoViewIfNeeded(false);
|
| },
|
| };
|
|
|
| /**
|
| * functions to be called from C++.
|
| + * @param {Object} config The viewport configuration.
|
| */
|
| function init(config) {
|
| - document.getElementById('viewport').init(config);
|
| + $('viewport').init(config);
|
| }
|
|
|
| function selectItem() {
|
| - document.getElementById('viewport').showSelection();
|
| + $('viewport').showSelection();
|
| }
|
|
|
| function updateModel(model) {
|
| - document.getElementById('viewport').updateModel(model);
|
| + $('viewport').updateModel(model);
|
| }
|
|
|
| function modelUpdated() {
|
| - chrome.send('model_updated', []);
|
| + chrome.send('model_updated');
|
| }
|
|
|
| function enableScroll(enabled) {
|
| - document.getElementById('viewport').scrollEnabled = enabled;
|
| + $('viewport').scrollEnabled = enabled;
|
| }
|
|
|