| OLD | NEW |
| 1 "use strict"; | 1 "use strict"; |
| 2 /* | 2 /* |
| 3 * Copyright (C) 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 var contentElements = this._containerElement.getElementsByClassName("content
"); | 130 var contentElements = this._containerElement.getElementsByClassName("content
"); |
| 131 for (var i=0; i < contentElements.length; ++i) { | 131 for (var i=0; i < contentElements.length; ++i) { |
| 132 maxContentWidth = Math.max(maxContentWidth, contentElements[i].offsetWid
th); | 132 maxContentWidth = Math.max(maxContentWidth, contentElements[i].offsetWid
th); |
| 133 } | 133 } |
| 134 this._containerElement.classList.remove("measuring-width"); | 134 this._containerElement.classList.remove("measuring-width"); |
| 135 return maxContentWidth; | 135 return maxContentWidth; |
| 136 }; | 136 }; |
| 137 | 137 |
| 138 SuggestionPicker.prototype._fixWindowSize = function() { | 138 SuggestionPicker.prototype._fixWindowSize = function() { |
| 139 var ListBorder = 2; | 139 var ListBorder = 2; |
| 140 var zoom = this._config.zoomFactor; |
| 140 var desiredWindowWidth = this._measureMaxContentWidth() + ListBorder; | 141 var desiredWindowWidth = this._measureMaxContentWidth() + ListBorder; |
| 141 if (typeof this._config.inputWidth === "number") | 142 if (typeof this._config.inputWidth === "number") |
| 142 desiredWindowWidth = Math.max(this._config.inputWidth, desiredWindowWidt
h); | 143 desiredWindowWidth = Math.max(this._config.inputWidth / zoom, desiredWin
dowWidth); |
| 143 var totalHeight = ListBorder; | 144 var totalHeight = ListBorder; |
| 144 var maxHeight = 0; | 145 var maxHeight = 0; |
| 145 var entryCount = 0; | 146 var entryCount = 0; |
| 146 for (var i = 0; i < this._containerElement.childNodes.length; ++i) { | 147 for (var i = 0; i < this._containerElement.childNodes.length; ++i) { |
| 147 var node = this._containerElement.childNodes[i]; | 148 var node = this._containerElement.childNodes[i]; |
| 148 if (node.classList.contains(SuggestionPicker.ListEntryClass)) | 149 if (node.classList.contains(SuggestionPicker.ListEntryClass)) |
| 149 entryCount++; | 150 entryCount++; |
| 150 totalHeight += node.offsetHeight; | 151 totalHeight += node.offsetHeight; |
| 151 if (maxHeight === 0 && entryCount == SuggestionPicker.NumberOfVisibleEnt
ries) | 152 if (maxHeight === 0 && entryCount == SuggestionPicker.NumberOfVisibleEnt
ries) |
| 152 maxHeight = totalHeight; | 153 maxHeight = totalHeight; |
| 153 } | 154 } |
| 154 var desiredWindowHeight = totalHeight; | 155 var desiredWindowHeight = totalHeight; |
| 155 if (maxHeight !== 0 && totalHeight > maxHeight) { | 156 if (maxHeight !== 0 && totalHeight > maxHeight) { |
| 156 this._containerElement.style.maxHeight = (maxHeight - ListBorder) + "px"
; | 157 this._containerElement.style.maxHeight = (maxHeight - ListBorder) + "px"
; |
| 157 desiredWindowWidth += getScrollbarWidth(); | 158 desiredWindowWidth += getScrollbarWidth(); |
| 158 desiredWindowHeight = maxHeight; | 159 desiredWindowHeight = maxHeight; |
| 159 this._containerElement.style.overflowY = "scroll"; | 160 this._containerElement.style.overflowY = "scroll"; |
| 160 } | 161 } |
| 161 | 162 |
| 162 var windowRect = adjustWindowRect(desiredWindowWidth, desiredWindowHeight, d
esiredWindowWidth, 0); | 163 var windowRect = adjustWindowRect(desiredWindowWidth * zoom, desiredWindowHe
ight * zoom, desiredWindowWidth * zoom, 0); |
| 163 this._containerElement.style.height = (windowRect.height - ListBorder) + "px
"; | 164 this._containerElement.style.height = (windowRect.height / zoom - ListBorder
) + "px"; |
| 164 setWindowRect(windowRect); | 165 setWindowRect(windowRect); |
| 165 }; | 166 }; |
| 166 | 167 |
| 167 SuggestionPicker.prototype._layout = function() { | 168 SuggestionPicker.prototype._layout = function() { |
| 168 if (this._config.isRTL) | 169 if (this._config.isRTL) |
| 169 this._element.classList.add("rtl"); | 170 this._element.classList.add("rtl"); |
| 170 if (this._config.isLocaleRTL) | 171 if (this._config.isLocaleRTL) |
| 171 this._element.classList.add("locale-rtl"); | 172 this._element.classList.add("locale-rtl"); |
| 172 this._containerElement = createElement("ul", "suggestion-list"); | 173 this._containerElement = createElement("ul", "suggestion-list"); |
| 173 this._containerElement.addEventListener("click", this._handleEntryClick.bind
(this), false); | 174 this._containerElement.addEventListener("click", this._handleEntryClick.bind
(this), false); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 /** | 317 /** |
| 317 * @param {!Event} event | 318 * @param {!Event} event |
| 318 */ | 319 */ |
| 319 SuggestionPicker.prototype._handleMouseOut = function(event) { | 320 SuggestionPicker.prototype._handleMouseOut = function(event) { |
| 320 if (!document.activeElement.classList.contains(SuggestionPicker.ListEntryCla
ss)) | 321 if (!document.activeElement.classList.contains(SuggestionPicker.ListEntryCla
ss)) |
| 321 return; | 322 return; |
| 322 this._isFocusByMouse = false; | 323 this._isFocusByMouse = false; |
| 323 document.activeElement.blur(); | 324 document.activeElement.blur(); |
| 324 event.preventDefault(); | 325 event.preventDefault(); |
| 325 }; | 326 }; |
| OLD | NEW |