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

Side by Side Diff: chrome/browser/resources/new_new_tab.js

Issue 164172: Merge 22567 - NNTP: Fix window tooltip so that it is not shown out of place.... (Closed) Base URL: svn://chrome-svn/chrome/branches/195/src/
Patch Set: Created 11 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Modified: svn:mergeinfo
Merged /trunk/src/chrome/browser/resources/new_new_tab.js:r22567
OLDNEW
1 1
2 // Helpers 2 // Helpers
3 3
4 function $(id) { 4 function $(id) {
5 return document.getElementById(id); 5 return document.getElementById(id);
6 } 6 }
7 7
8 // TODO(arv): Remove these when classList is available in HTML5. 8 // TODO(arv): Remove these when classList is available in HTML5.
9 // https://bugs.webkit.org/show_bug.cgi?id=20709 9 // https://bugs.webkit.org/show_bug.cgi?id=20709
10 function hasClass(el, name) { 10 function hasClass(el, name) {
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 this.button.onkeydown = bind(this.handleKeyDown, this); 898 this.button.onkeydown = bind(this.handleKeyDown, this);
899 this.boundHideMenu_ = bind(this.hide, this); 899 this.boundHideMenu_ = bind(this.hide, this);
900 this.boundMaybeHide_ = bind(this.maybeHide_, this); 900 this.boundMaybeHide_ = bind(this.maybeHide_, this);
901 this.menu.onmouseover = bind(this.handleMouseOver, this); 901 this.menu.onmouseover = bind(this.handleMouseOver, this);
902 this.menu.onmouseout = bind(this.handleMouseOut, this); 902 this.menu.onmouseout = bind(this.handleMouseOut, this);
903 this.menu.onmouseup = bind(this.handleMouseUp, this); 903 this.menu.onmouseup = bind(this.handleMouseUp, this);
904 } 904 }
905 905
906 OptionMenu.prototype = { 906 OptionMenu.prototype = {
907 show: function() { 907 show: function() {
908 windowTooltip.hide();
909
910 this.menu.style.display = 'block'; 908 this.menu.style.display = 'block';
911 this.button.focus(); 909 this.button.focus();
912 910
913 // Listen to document and window events so that we hide the menu when the 911 // Listen to document and window events so that we hide the menu when the
914 // user clicks outside the menu or tabs away or the whole window is blurred. 912 // user clicks outside the menu or tabs away or the whole window is blurred.
915 document.addEventListener('focus', this.boundMaybeHide_, true); 913 document.addEventListener('focus', this.boundMaybeHide_, true);
916 document.addEventListener('mousedown', this.boundMaybeHide_, true); 914 document.addEventListener('mousedown', this.boundMaybeHide_, true);
917 }, 915 },
918 916
919 hide: function() { 917 hide: function() {
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 } 1135 }
1138 1136
1139 WindowTooltip.trackMouseMove_ = function(e) { 1137 WindowTooltip.trackMouseMove_ = function(e) {
1140 WindowTooltip.clientX = e.clientX; 1138 WindowTooltip.clientX = e.clientX;
1141 WindowTooltip.clientY = e.clientY; 1139 WindowTooltip.clientY = e.clientY;
1142 }; 1140 };
1143 1141
1144 WindowTooltip.prototype = { 1142 WindowTooltip.prototype = {
1145 timer: 0, 1143 timer: 0,
1146 handleMouseOver: function(e, linkEl, tabs) { 1144 handleMouseOver: function(e, linkEl, tabs) {
1147 document.addEventListener('mousemove', WindowTooltip.trackMouseMove_); 1145 this.linkEl_ = linkEl;
1146 if (e.type == 'mouseover') {
1147 this.linkEl_.addEventListener('mousemove', WindowTooltip.trackMouseMove_);
1148 this.linkEl_.addEventListener('mouseout', this.boundHandleMouseOut_);
1149 } else { // focus
1150 this.linkEl_.addEventListener('blur', this.boundHide_);
1151 }
1148 this.timer = window.setTimeout(bind(this.show, this, e.type, linkEl, tabs), 1152 this.timer = window.setTimeout(bind(this.show, this, e.type, linkEl, tabs),
1149 300); 1153 300);
1150 }, 1154 },
1151 show: function(type, linkEl, tabs) { 1155 show: function(type, linkEl, tabs) {
1152 document.removeEventListener('mousemove', WindowTooltip.trackMouseMove_); 1156 this.linkEl_.removeEventListener('mousemove',
1157 WindowTooltip.trackMouseMove_);
1153 clearTimeout(this.timer); 1158 clearTimeout(this.timer);
1154 1159
1155 processData('#window-tooltip', tabs); 1160 processData('#window-tooltip', tabs);
1156 var rect = linkEl.getBoundingClientRect(); 1161 var rect = linkEl.getBoundingClientRect();
1157 var bodyRect = document.body.getBoundingClientRect() 1162 var bodyRect = document.body.getBoundingClientRect()
1158 var rtl = document.documentElement.dir == 'rtl'; 1163 var rtl = document.documentElement.dir == 'rtl';
1159 1164
1160 this.tooltipEl.style.display = 'block'; 1165 this.tooltipEl.style.display = 'block';
1161 1166
1162 // When focused show below, like a drop down menu. 1167 // When focused show below, like a drop down menu.
1163 if (type == 'focus') { 1168 if (type == 'focus') {
1164 this.tooltipEl.style.left = (rtl ? 1169 this.tooltipEl.style.left = (rtl ?
1165 rect.left + bodyRect.left + rect.width - this.tooltipEl.offsetWidth : 1170 rect.left + bodyRect.left + rect.width - this.tooltipEl.offsetWidth :
1166 rect.left + bodyRect.left) + 'px'; 1171 rect.left + bodyRect.left) + 'px';
1167 this.tooltipEl.style.top = rect.top + bodyRect.top + rect.height + 'px'; 1172 this.tooltipEl.style.top = rect.top + bodyRect.top + rect.height + 'px';
1168 } else { 1173 } else {
1169 this.tooltipEl.style.left = bodyRect.left + (rtl ? 1174 this.tooltipEl.style.left = bodyRect.left + (rtl ?
1170 WindowTooltip.clientX - this.tooltipEl.offsetWidth : 1175 WindowTooltip.clientX - this.tooltipEl.offsetWidth :
1171 WindowTooltip.clientX) + 'px'; 1176 WindowTooltip.clientX) + 'px';
1172 // Offset like a tooltip 1177 // Offset like a tooltip
1173 this.tooltipEl.style.top = 20 + WindowTooltip.clientY + bodyRect.top + 1178 this.tooltipEl.style.top = 20 + WindowTooltip.clientY + bodyRect.top +
1174 'px'; 1179 'px';
1175 } 1180 }
1176
1177 if (type == 'focus') {
1178 linkEl.onblur = this.boundHide_;
1179 } else { // mouseover
1180 linkEl.onmouseout = this.boundHandleMouseOut_;
1181 }
1182 }, 1181 },
1183 handleMouseOut: function(e) { 1182 handleMouseOut: function(e) {
1184 // Don't hide when move to another item in the link. 1183 // Don't hide when move to another item in the link.
1185 var f = function(el) { 1184 var f = function(el) {
1186 return el.tabItems !== undefined; 1185 return el.tabItems !== undefined;
1187 }; 1186 };
1188 var el = findAncestor(e.target, f); 1187 var el = findAncestor(e.target, f);
1189 var relatedEl = findAncestor(e.relatedTarget, f); 1188 var relatedEl = findAncestor(e.relatedTarget, f);
1190 if (el && el != relatedEl) { 1189 if (el && el != relatedEl) {
1191 this.hide(); 1190 this.hide();
1192 } 1191 }
1193 }, 1192 },
1194 hide: function() { 1193 hide: function() {
1195 window.clearTimeout(this.timer); 1194 window.clearTimeout(this.timer);
1196 document.removeEventListener('mousemove', WindowTooltip.trackMouseMove_); 1195 this.linkEl_.removeEventListener('mousemove',
1196 WindowTooltip.trackMouseMove_);
1197 this.linkEl_.removeEventListener('mouseout', this.boundHandleMouseOut_);
1198 this.linkEl_.removeEventListener('blur', this.boundHide_);
1199 this.linkEl_ = null;
1200
1197 this.tooltipEl.style.display = 'none'; 1201 this.tooltipEl.style.display = 'none';
1198 } 1202 }
1199 }; 1203 };
1200 1204
1201 var windowTooltip = new WindowTooltip($('window-tooltip')); 1205 var windowTooltip = new WindowTooltip($('window-tooltip'));
1202 1206
1203 function getCheckboxHandler(section) { 1207 function getCheckboxHandler(section) {
1204 return function(e) { 1208 return function(e) {
1205 if (e.type == 'keydown') { 1209 if (e.type == 'keydown') {
1206 if (e.keyIdentifier == 'Enter') { 1210 if (e.keyIdentifier == 'Enter') {
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 el.addEventListener('dragover', bind(this.handleDragOver, this)); 1431 el.addEventListener('dragover', bind(this.handleDragOver, this));
1428 el.addEventListener('dragleave', bind(this.handleDragLeave, this)); 1432 el.addEventListener('dragleave', bind(this.handleDragLeave, this));
1429 el.addEventListener('drop', bind(this.handleDrop, this)); 1433 el.addEventListener('drop', bind(this.handleDrop, this));
1430 el.addEventListener('dragend', bind(this.handleDragEnd, this)); 1434 el.addEventListener('dragend', bind(this.handleDragEnd, this));
1431 el.addEventListener('drag', bind(this.handleDrag, this)); 1435 el.addEventListener('drag', bind(this.handleDrag, this));
1432 el.addEventListener('mousedown', bind(this.handleMouseDown, this)); 1436 el.addEventListener('mousedown', bind(this.handleMouseDown, this));
1433 } 1437 }
1434 }; 1438 };
1435 1439
1436 dnd.init(); 1440 dnd.init();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698