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

Unified Diff: chrome/browser/resources/chromeos/login/network_dropdown.js

Issue 7982002: [cros,webui] Adds scrollbar for the network drop-down controller. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added ellipsis for title, fixed width problems Created 9 years, 3 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: chrome/browser/resources/chromeos/login/network_dropdown.js
diff --git a/chrome/browser/resources/chromeos/login/network_dropdown.js b/chrome/browser/resources/chromeos/login/network_dropdown.js
index c1c513c72e679e30bae9d87639b6eadaaa87a1b0..6f009af78316201b17391b1342b226c23a35e769 100644
--- a/chrome/browser/resources/chromeos/login/network_dropdown.js
+++ b/chrome/browser/resources/chromeos/login/network_dropdown.js
@@ -24,17 +24,39 @@ cr.define('cr.ui', function() {
this.selectedItem = null;
// First item which could be selected.
this.firstItem = null;
+ // Whether scroll has just happened.
+ this.scrollJustHappened = false;
+ },
+
+ scrollAction: function(item) {
Nikita (slow) 2011/09/21 10:44:25 nit: Function comment.
altimofeev 2011/09/21 11:49:53 Done.
+ var thisTop = this.scrollTop;
+ var thisBottom = thisTop + this.offsetHeight;
+ var itemTop = item.offsetTop;
+ var itemBottom = itemTop + item.offsetHeight;
+ if (itemTop <= thisTop) return -1;
+ if (itemBottom >= thisBottom) return 1;
+ return 0;
},
/**
* Selects new item.
* @param {!Object} selectedItem Item to be selected.
+ * @param {boolean} mouseOver Is mouseover event triggered?
*/
- selectItem: function(selectedItem) {
+ selectItem: function(selectedItem, mouseOver) {
+ if (mouseOver && this.scrollJustHappened) {
+ this.scrollJustHappened = false;
+ return;
+ }
if (this.selectedItem)
this.selectedItem.classList.remove('hover');
selectedItem.classList.add('hover');
this.selectedItem = selectedItem;
+ var action = this.scrollAction(selectedItem);
+ if (action != 0) {
+ selectedItem.scrollIntoView(action < 0);
+ this.scrollJustHappened = true;
+ }
}
};
@@ -76,7 +98,7 @@ cr.define('cr.ui', function() {
this.firstElementChild.hidden = !show;
this.container.hidden = !show;
if (show)
- this.container.selectItem(this.container.firstItem);
+ this.container.selectItem(this.container.firstItem, false);
},
/**
@@ -122,7 +144,7 @@ cr.define('cr.ui', function() {
}
this.createItem_(this.container, item);
}
- this.container.selectItem(this.container.firstItem);
+ this.container.selectItem(this.container.firstItem, false);
},
/**
@@ -181,7 +203,7 @@ cr.define('cr.ui', function() {
this.parentNode.parentNode.titleButton.focus();
});
wrapperDiv.addEventListener('mouseover', function f(e) {
- this.parentNode.selectItem(this);
+ this.parentNode.selectItem(this, true);
});
itemElement = wrapperDiv;
}
@@ -264,7 +286,7 @@ cr.define('cr.ui', function() {
if (!selected)
selected = this.container.lastElementChild;
} while (selected.iid < 0);
- this.container.selectItem(selected);
+ this.container.selectItem(selected, false);
break;
}
case 40: { // Key down.
@@ -273,7 +295,7 @@ cr.define('cr.ui', function() {
if (!selected)
selected = this.container.firstItem;
} while (selected.iid < 0);
- this.container.selectItem(selected);
+ this.container.selectItem(selected, false);
break;
}
case 27: { // Esc.

Powered by Google App Engine
This is Rietveld 408576698