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

Unified Diff: third_party/google_input_tools/src/chrome/os/inputview/elements/content/menuview.js

Issue 899673003: Uprev Google Input Tools. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
Index: third_party/google_input_tools/src/chrome/os/inputview/elements/content/menuview.js
diff --git a/third_party/google_input_tools/src/chrome/os/inputview/elements/content/menuview.js b/third_party/google_input_tools/src/chrome/os/inputview/elements/content/menuview.js
index dd5ed6b31f9f178bd3dd9d34fbcf27e2202747f6..c332665e7967adeab21731aa55aa7e4f09b0250e 100644
--- a/third_party/google_input_tools/src/chrome/os/inputview/elements/content/menuview.js
+++ b/third_party/google_input_tools/src/chrome/os/inputview/elements/content/menuview.js
@@ -15,6 +15,7 @@ goog.provide('i18n.input.chrome.inputview.elements.content.MenuView');
goog.require('goog.a11y.aria');
goog.require('goog.a11y.aria.State');
+goog.require('goog.array');
goog.require('goog.dom.TagName');
goog.require('goog.dom.classlist');
goog.require('goog.style');
@@ -80,11 +81,20 @@ MenuView.MAXIMAL_VISIBLE_IMES_ = 3;
/**
* The width of the popup menu.
+ * The total width include padding is 300px, the padding left is 41px.
*
* @type {number}
* @private
*/
-MenuView.WIDTH_ = 300;
+MenuView.width_ = 300;
+
+
+/**
+ * The padding-left of the menu item.
+ *
+ * @private {number}
+ */
+MenuView.paddingLeft_ = 0;
/**
@@ -150,6 +160,11 @@ MenuView.prototype.enterDocument = function() {
MenuView.prototype.show = function(key, currentKeysetId, isCompact,
enableCompactLayout, currentInputMethod, inputMethods, hasHwt,
enableSettings, hasEmoji) {
+ if (i18n.input.chrome.inputview.GlobalFlags.isQPInputView) {
+ // Temporary overwrites the value for material design.
+ MenuView.width_ = 259;
+ MenuView.paddingLeft_ = 41;
+ }
var ElementType = i18n.input.chrome.inputview.elements.ElementType;
var dom = this.getDomHelper();
if (key.type != ElementType.MENU_KEY) {
@@ -222,7 +237,7 @@ MenuView.prototype.addInputMethodItems_ = function(currentInputMethod,
inputMethod['name'];
if (currentInputMethod == inputMethod['id']) {
ariaLabel = chrome.i18n.getMessage('CURRENT_KEYBOARD_PREFIX') +
- inputMethod['name'];
+ inputMethod['name'];
}
var imeItem = new MenuItem(String(i), listItem, MenuItem.Type.LIST_ITEM,
ariaLabel);
@@ -230,14 +245,16 @@ MenuView.prototype.addInputMethodItems_ = function(currentInputMethod,
if (currentInputMethod == inputMethod['id']) {
imeItem.check();
}
- goog.style.setSize(imeItem.getElement(), MenuView.WIDTH_,
+ goog.style.setSize(imeItem.getElement(),
+ (MenuView.width_ + MenuView.paddingLeft_),
MenuView.LIST_ITEM_HEIGHT_);
}
var containerHeight = inputMethods.length > MenuView.MAXIMAL_VISIBLE_IMES_ ?
MenuView.LIST_ITEM_HEIGHT_ * MenuView.MAXIMAL_VISIBLE_IMES_ :
MenuView.LIST_ITEM_HEIGHT_ * inputMethods.length;
- goog.style.setSize(container, MenuView.WIDTH_, containerHeight);
+ goog.style.setSize(container, MenuView.width_ + MenuView.paddingLeft_,
+ containerHeight);
dom.appendChild(this.getElement(), container);
return containerHeight;
@@ -293,7 +310,7 @@ MenuView.prototype.addLayoutSwitcherItem_ = function(key, currentKeysetId,
chrome.i18n.getMessage('SWITCH_TO_COMPACT_LAYOUT'));
}
layoutSwitcherItem.render(this.getElement());
- goog.style.setSize(layoutSwitcherItem.getElement(), MenuView.WIDTH_,
+ goog.style.setSize(layoutSwitcherItem.getElement(), MenuView.width_,
MenuView.LIST_ITEM_HEIGHT_);
return MenuView.LIST_ITEM_HEIGHT_;
@@ -347,15 +364,17 @@ MenuView.prototype.addFooterItems_ = function(hasHwt, enableSettings,
// Sets footer itmes' width.
var elems = dom.getChildren(footer);
var len = elems.length;
- var subWidth = Math.ceil(MenuView.WIDTH_ / len);
+ var subWidth = Math.ceil((MenuView.width_ + MenuView.paddingLeft_) / len);
var i = 0;
for (; i < len - 1; i++) {
elems[i].style.width = subWidth + 'px';
}
- elems[i].style.width = (MenuView.WIDTH_ - subWidth * (len - 1)) + 'px';
+ elems[i].style.width = (MenuView.width_ + MenuView.paddingLeft_ -
+ subWidth * (len - 1)) + 'px';
dom.appendChild(this.getElement(), footer);
- goog.style.setSize(footer, MenuView.WIDTH_, MenuView.LIST_ITEM_HEIGHT_);
+ goog.style.setSize(footer, (MenuView.width_ + MenuView.paddingLeft_),
+ MenuView.LIST_ITEM_HEIGHT_);
return MenuView.LIST_ITEM_HEIGHT_;
};

Powered by Google App Engine
This is Rietveld 408576698