Skip to content
This repository
Browse code

Fix problem with DropDown's focus

  • Loading branch information...
commit 63f8c0628f40b9befec0674a08ac72216d3cd0f8 1 parent 4d04436
SergeyPensov authored
207 openFaces/source/META-INF/resources/openfaces/input/dropDownField.js
@@ -11,24 +11,21 @@
11 11 */
12 12
13 13 O$.DropDownField = {
14   - _init: function(dropDownId, popupTimeout, listAlignment, rolloverPopupItemClass, itemValues, customValueAllowed,
15   - required, suggestionMode, suggestionDelay, suggestionMinChars, manualListOpeningAllowed,
16   - autoCompleteOn, totalItemCount, pageSize, popupTableStructureAndStyleParams, cachingAllowed,
17   - itemPresentationColumn, changeValueOnSelect) {
  14 + _init:function (dropDownId, popupTimeout, listAlignment, rolloverPopupItemClass, itemValues, customValueAllowed, required, suggestionMode, suggestionDelay, suggestionMinChars, manualListOpeningAllowed, autoCompleteOn, totalItemCount, pageSize, popupTableStructureAndStyleParams, cachingAllowed, itemPresentationColumn, changeValueOnSelect) {
18 15 var dropDown = O$(dropDownId);
19 16 var super_ = O$.extend(dropDown, {
20   - _listAlignment: listAlignment,
21   - _customValueAllowed: customValueAllowed,
22   - _required: required,
23   - _manualListOpeningAllowed: manualListOpeningAllowed,
24   - _keyNavigationStarted: false,
25   - _popupTimeout: popupTimeout,
26   - _highlightedItemIndex: -1,
27   - _cachingAllowed: cachingAllowed,
28   - _itemPresentation: O$(dropDownId + "::itemPresentation"),
29   - _itemPresentationContainer: O$(dropDownId + "::itemPresentation::container"),
30   - _itemPresentationColumn: itemPresentationColumn,
31   - _fieldContainer: O$(dropDownId + "::field::container"),
  17 + _listAlignment:listAlignment,
  18 + _customValueAllowed:customValueAllowed,
  19 + _required:required,
  20 + _manualListOpeningAllowed:manualListOpeningAllowed,
  21 + _keyNavigationStarted:false,
  22 + _popupTimeout:popupTimeout,
  23 + _highlightedItemIndex:-1,
  24 + _cachingAllowed:cachingAllowed,
  25 + _itemPresentation:O$(dropDownId + "::itemPresentation"),
  26 + _itemPresentationContainer:O$(dropDownId + "::itemPresentation::container"),
  27 + _itemPresentationColumn:itemPresentationColumn,
  28 + _fieldContainer:O$(dropDownId + "::field::container"),
32 29 _changeValueOnSelect:changeValueOnSelect,
33 30
34 31 _showPresentationPromptText:function (promptText) {
@@ -65,13 +62,13 @@ O$.DropDownField = {
65 62 O$.excludeClassNames(tdElemnt, [rowTable._selectionClass, oddRowClassName]);
66 63 tdElemnt.style.borderBottom = "";
67 64 }
68   - if (itemPresentation.childNodes.length == 1){
  65 + if (itemPresentation.childNodes.length == 1) {
69 66 itemPresentation.childNodes[0].style.borderRight = "";
70 67 }
71 68 }
72 69 },
73 70
74   - _initListStyles: function() {
  71 + _initListStyles:function () {
75 72 var oldCursor = document.body.style.cursor;
76 73 document.body.style.cursor = "progress";
77 74 O$.initUnloadableComponent(innerTable);
@@ -86,18 +83,18 @@ O$.DropDownField = {
86 83 O$.repaintWindowForSafari(true);
87 84 },
88 85
89   - _getFirstVisibleItemIndex: function() {
  86 + _getFirstVisibleItemIndex:function () {
90 87 return O$.DropDownField._getNeighboringVisibleItem(dropDown, -1, false);
91 88 },
92 89
93   - _getLastVisibleItemIndex: function() {
  90 + _getLastVisibleItemIndex:function () {
94 91 return O$.DropDownField._getNeighboringVisibleItem(dropDown, dropDown._items.length, true);
95 92 },
96 93
97   - _getItemVerticalBounds: function(itemIndex) {
  94 + _getItemVerticalBounds:function (itemIndex) {
98 95 var firstItemIndex = dropDown._getFirstVisibleItemIndex();
99 96 if (firstItemIndex == -1)
100   - return {top : 0, bottom : 0};
  97 + return {top:0, bottom:0};
101 98 var firstItem = dropDown._items[firstItemIndex];
102 99 var item = dropDown._items[itemIndex];
103 100 if (!item && firstItem) {
@@ -105,10 +102,10 @@ O$.DropDownField = {
105 102 }
106 103 var itemTop = O$.getElementPos(item).y - O$.getElementPos(innerTable).y;
107 104 var itemBottom = itemTop + item.offsetHeight;
108   - return {top : itemTop, bottom : itemBottom};
  105 + return {top:itemTop, bottom:itemBottom};
109 106 },
110 107
111   - _getItemIndexAtY: function(y, searchFromIndex, searchUpwards) {
  108 + _getItemIndexAtY:function (y, searchFromIndex, searchUpwards) {
112 109 for (var i = searchFromIndex, count = dropDown._items.length; i < count && i >= 0; searchUpwards ? i-- : i++) {
113 110 if (!dropDown._items[i]._isVisible())
114 111 continue;
@@ -119,7 +116,7 @@ O$.DropDownField = {
119 116 return -1;
120 117 },
121 118
122   - _scrollToHighlightedItem: function() {
  119 + _scrollToHighlightedItem:function () {
123 120 if (dropDown._highlightedItemIndex == -1) {
124 121 popup.scrollTop = 0;
125 122 return;
@@ -150,16 +147,16 @@ O$.DropDownField = {
150 147 }
151 148 },
152 149
153   - _addCachedSuggestions: function(filterCriterionText, newRows, newRowsToStylesMap, newRowCellsToStylesMap, itemValues, appendItems) {
  150 + _addCachedSuggestions:function (filterCriterionText, newRows, newRowsToStylesMap, newRowCellsToStylesMap, itemValues, appendItems) {
154 151 var cacheMapKey = filterCriterionText ? filterCriterionText.toLowerCase() : "";
155 152 if (!dropDown._cachedSuggestionLists)
156 153 dropDown._cachedSuggestionLists = [];
157 154 if (!appendItems || !dropDown._cachedSuggestionLists[cacheMapKey]) {
158 155 dropDown._cachedSuggestionLists[cacheMapKey] = {
159   - rows: newRows,
160   - rowsToStylesMap: newRowsToStylesMap,
161   - cellsToStylesMap: newRowCellsToStylesMap,
162   - values: itemValues};
  156 + rows:newRows,
  157 + rowsToStylesMap:newRowsToStylesMap,
  158 + cellsToStylesMap:newRowCellsToStylesMap,
  159 + values:itemValues};
163 160 return 0;
164 161 } else {
165 162 var suggestionsData = dropDown._cachedSuggestionLists[cacheMapKey];
@@ -172,12 +169,12 @@ O$.DropDownField = {
172 169 }
173 170 },
174 171
175   - _filterCriterion: null,
176   - _getFilterCriterion: function() {
  172 + _filterCriterion:null,
  173 + _getFilterCriterion:function () {
177 174 return dropDown._filterCriterion;
178 175 },
179 176
180   - _checkAdditionalPageNeeded: function(forceReload, loadFullList) {
  177 + _checkAdditionalPageNeeded:function (forceReload, loadFullList) {
181 178 if (suggestionMode != "custom" || (dropDown._cachingAllowed && dropDown._filterCriterion)) return;
182 179 var itemsLoaded = forceReload ? 0 : dropDown._items.length;
183 180 if (totalItemCount != -1) {
@@ -205,7 +202,7 @@ O$.DropDownField = {
205 202 O$.DropDownField._filteredItemsLoaded);
206 203 },
207 204
208   - _setFilterCriterion: function(text, autoCompletionAllowedForThisKey) {
  205 + _setFilterCriterion:function (text, autoCompletionAllowedForThisKey) {
209 206 if (dropDown._filterCriterion == text)
210 207 return;
211 208 dropDown._filterCriterion = text;
@@ -224,12 +221,12 @@ O$.DropDownField = {
224 221 }
225 222 },
226 223
227   - _clearSuggestions: function() {
  224 + _clearSuggestions:function () {
228 225 dropDown._filterCriterion = dropDown._field.value;
229 226 dropDown._showSuggestions(dropDown._field.value, null, false);
230 227 },
231 228
232   - _showSuggestions: function(text, cachedSuggestions, autoCompletionAllowedForThisKey, itemsAppended) {
  229 + _showSuggestions:function (text, cachedSuggestions, autoCompletionAllowedForThisKey, itemsAppended) {
233 230 var innerTable = O$(dropDown.id + "--popup::innerTable");
234 231 if (itemsAppended == undefined) {
235 232 dropDown._setHighlightedItemIndex(-1);
@@ -255,7 +252,7 @@ O$.DropDownField = {
255 252 },
256 253
257 254
258   - _showCachedSuggestions: function (text, autoCompletionAllowedForThisKey, itemsLoadedCallback, itemsAppended) {
  255 + _showCachedSuggestions:function (text, autoCompletionAllowedForThisKey, itemsLoadedCallback, itemsAppended) {
259 256 var cacheMapKey = text ? text.toLowerCase() : "";
260 257 var cachedSuggestions = dropDown._cachedSuggestionLists ? dropDown._cachedSuggestionLists[cacheMapKey] : null;
261 258 if (!cachedSuggestions)
@@ -269,7 +266,7 @@ O$.DropDownField = {
269 266 return true;
270 267 },
271 268
272   - _completeShowingSuggestions: function(text, autoCompletionAllowedForThisKey) {
  269 + _completeShowingSuggestions:function (text, autoCompletionAllowedForThisKey) {
273 270 if (dropDown.isOpened())
274 271 O$.DropDown._initPopup(dropDown);
275 272
@@ -321,7 +318,7 @@ O$.DropDownField = {
321 318 dropDown._scrollToHighlightedItem();
322 319 },
323 320
324   - _filterItems: function() {
  321 + _filterItems:function () {
325 322 function shouldItemBeIncluded(item, filterText) {
326 323 if (suggestionMode == "none" || suggestionMode == "all" || !filterText)
327 324 return true;
@@ -353,7 +350,7 @@ O$.DropDownField = {
353 350 O$.repaintWindowForSafari(true);
354 351
355 352 },
356   - _setHighlightedItemIndex: function(index) {
  353 + _setHighlightedItemIndex:function (index) {
357 354 function setItemSelected(itemIndex, selected) {
358 355 var item = dropDown._items[itemIndex];
359 356 O$.assert(item, "setItemSelected: couldn't find item at index: " + itemIndex);
@@ -377,31 +374,31 @@ O$.DropDownField = {
377 374 }
378 375 },
379 376
380   - _getHighlightedItemIndex: function() {
  377 + _getHighlightedItemIndex:function () {
381 378 return dropDown._highlightedItemIndex;
382 379 },
383   - _initItems: function(itemValues, fromIndex) {
  380 + _initItems:function (itemValues, fromIndex) {
384 381 for (var i = fromIndex, count = dropDown._items.length; i < count; i++) {
385 382 var item = dropDown._items[i];
386 383 var itemData = itemValues[i];
387 384 O$.extend(item, {
388   - _itemValue: itemData[0],
389   - _itemLabel: itemData.length == 2 ? itemData[1] : itemData[0],
  385 + _itemValue:itemData[0],
  386 + _itemLabel:itemData.length == 2 ? itemData[1] : itemData[0],
390 387
391   - onmouseover: function() {
  388 + onmouseover:function () {
392 389 dropDown._setHighlightedItemIndex(this._index);
393 390 },
394   - onmousemove: function() {
  391 + onmousemove:function () {
395 392 dropDown._setHighlightedItemIndex(this._index);
396 393 },
397   - onclick: function() {
  394 + onclick:function () {
398 395 O$.DropDownField._itemClicked(dropDown, this);
399 396 },
400   - onmouseup: function() {
  397 + onmouseup:function () {
401 398 O$.DropDownField._itemClicked(dropDown, this);
402 399 },
403 400
404   - _select: function() {
  401 + _select:function () {
405 402 var text = this._itemLabel;
406 403 var itemValue = this._itemValue;
407 404 dropDown._setValue(text, itemValue);
@@ -413,7 +410,7 @@ O$.DropDownField = {
413 410 }
414 411 },
415 412
416   - _selectCurrentValue: function(e) {
  413 + _selectCurrentValue:function (e) {
417 414 dropDown._checkFieldValueAgainstList(true);
418 415 if (field.value != dropDown.value) {
419 416 dropDown._setValue(field.value, undefined, false, e); // the case for clipboard-pasted text
@@ -422,7 +419,7 @@ O$.DropDownField = {
422 419 }
423 420 },
424 421
425   - _fireOnChangeIfChanged: function() {
  422 + _fireOnChangeIfChanged:function () {
426 423 if (dropDown._lastOnchangeItemLabel != dropDown.value/* ||
427 424 dropDown._lastOnchangeItemValue != dropDown._selectedItemValue*/) {
428 425 clearSuggestionTimer();
@@ -450,14 +447,14 @@ O$.DropDownField = {
450 447 }
451 448 },
452 449
453   - _checkFieldValueAgainstList: function(allowAsynchronousFilterSetting) {
  450 + _checkFieldValueAgainstList:function (allowAsynchronousFilterSetting) {
454 451 if (dropDown._customValueAllowed)
455 452 return;
456   - var preferredText = dropDown._field._oldValue != undefined?dropDown._field._oldValue : "";
  453 + var preferredText = dropDown._field._oldValue != undefined ? dropDown._field._oldValue : "";
457 454 if (field.value != preferredText) {
458 455 field.value = preferredText;
459 456 if (allowAsynchronousFilterSetting)
460   - setTimeout(function() {
  457 + setTimeout(function () {
461 458 dropDown._setFilterCriterion(null);
462 459 }, 1);
463 460 else
@@ -466,18 +463,18 @@ O$.DropDownField = {
466 463 }
467 464 },
468 465
469   - getValue: function () {
  466 + getValue:function () {
470 467 return dropDown.value;
471 468 },
472 469
473   - setValue: function (text) {
  470 + setValue:function (text) {
474 471 dropDown._setValue(text);
475 472 },
476 473
477 474 _setItemPresentationValue:function () {
478 475
479 476 var selectedItem = dropDown._getSelectedItem();
480   - if (!selectedItem){
  477 + if (!selectedItem) {
481 478 dropDown._showPresentationPromptText(dropDown._promptText);
482 479 return;
483 480 }
@@ -499,11 +496,11 @@ O$.DropDownField = {
499 496 if (dropDown._itemPresentationColumn < newItemPresentationContentNode.childNodes.length)
500 497 itemPresentation.appendChild(newItemPresentationContentNode.childNodes[dropDown._itemPresentationColumn]);
501 498 }
502   - O$.setElementSize(dropDown._itemPresentationContainer, {height : dropDown.offsetHeight-2});
  499 + O$.setElementSize(dropDown._itemPresentationContainer, {height:dropDown.offsetHeight - 2});
503 500 dropDown._copyClassesToItemPresentation();
504 501 },
505 502
506   - _setValue: function (text, itemValue, onChangeDisabled, initiatingEvent) {
  503 + _setValue:function (text, itemValue, onChangeDisabled, initiatingEvent) {
507 504 if (text) { // retain only the first line because user can't enter new-line anyway
508 505 var idx = text.indexOf("\n");
509 506 if (idx != -1)
@@ -522,7 +519,7 @@ O$.DropDownField = {
522 519 if (existingListItemRequired) {
523 520 if (itemValue == undefined) {
524 521 var item = dropDown._findItemByLabel(text);
525   - if (!item){
  522 + if (!item) {
526 523 return; // retain old value when setting a value not from the list
527 524 }
528 525 itemValue = item._itemValue;
@@ -562,7 +559,7 @@ O$.DropDownField = {
562 559 }
563 560 },
564 561
565   - dropDown: function () {
  562 + dropDown:function () {
566 563 if (dropDown.isOpened())
567 564 return false;
568 565 popup._prepareForRearrangementBeforeShowing();
@@ -573,7 +570,7 @@ O$.DropDownField = {
573 570 return true;
574 571 },
575 572
576   - closeUp: function () {
  573 + closeUp:function () {
577 574 if (!dropDown.isOpened())
578 575 return false;
579 576 popup.hide();
@@ -581,11 +578,11 @@ O$.DropDownField = {
581 578 return true;
582 579 },
583 580
584   - isOpened: function () {
  581 + isOpened:function () {
585 582 return popup.isVisible();
586 583 },
587 584
588   - _getSelectedItem: function() {
  585 + _getSelectedItem:function () {
589 586 var selectedItem = null;
590 587 var currentValue = dropDown._selectedItemValue;
591 588 if (currentValue != undefined) {
@@ -600,12 +597,12 @@ O$.DropDownField = {
600 597 return selectedItem;
601 598 },
602 599
603   - _highlightSelectedItem: function() {
  600 + _highlightSelectedItem:function () {
604 601 var itemToHighlight = dropDown._getSelectedItem();
605 602 dropDown._setHighlightedItemIndex(itemToHighlight ? itemToHighlight._index : -1);
606 603 },
607 604
608   - _findItemByLabel: function (text) {
  605 + _findItemByLabel:function (text) {
609 606 function itemByLabel(text, caseSensitive) {
610 607 for (var i = 0, count = dropDown._items.length; i < count; i++) {
611 608 var item = dropDown._items[i];
@@ -622,7 +619,7 @@ O$.DropDownField = {
622 619 return item;
623 620 },
624 621
625   - _showHidePopup: function () {
  622 + _showHidePopup:function () {
626 623 if (dropDown.isOpened())
627 624 dropDown.closeUp();
628 625 else {
@@ -644,7 +641,7 @@ O$.DropDownField = {
644 641 }
645 642 },
646 643
647   - _visibilityChangeListener: function() {
  644 + _visibilityChangeListener:function () {
648 645 if (popup.isVisible()) {
649 646 if (dropDown.ondropdown)
650 647 dropDown.ondropdown();
@@ -663,15 +660,15 @@ O$.DropDownField = {
663 660 }
664 661 },
665 662
666   - setDisabled: function(disabled) {
  663 + setDisabled:function (disabled) {
667 664 super_.setDisabled.call(this, disabled);
668 665 },
669 666
670   - _setCustomEvents: function(events) {
  667 + _setCustomEvents:function (events) {
671 668 O$.extend(this, events);
672 669 },
673 670
674   - _selectValueByKeyCode: function (keyCode) {
  671 + _selectValueByKeyCode:function (keyCode) {
675 672 var currentItemIndex = dropDown._getHighlightedItemIndex();
676 673 if (keyCode == 13 || (dropDown._changeValueOnSelect && (keyCode == 38 || keyCode == 40))) {
677 674 if (currentItemIndex == -1) {
@@ -694,7 +691,7 @@ O$.DropDownField = {
694 691 var itemPresentation = dropDown._itemPresentation;
695 692 field._oldValue = field.value;
696 693 // Switch off browser input field autocomplete
697   - field.setAttribute("autocomplete","off");
  694 + field.setAttribute("autocomplete", "off");
698 695
699 696 if (itemPresentation) {
700 697 O$.extend(field, {
@@ -777,7 +774,7 @@ O$.DropDownField = {
777 774 field._hide();
778 775 }
779 776
780   - popup.onscroll = function() {
  777 + popup.onscroll = function () {
781 778 dropDown._checkAdditionalPageNeeded()
782 779 };
783 780 O$.addUnloadHandler(dropDown, function () {
@@ -807,14 +804,14 @@ O$.DropDownField = {
807 804 }
808 805 if (!O$.isSafari()) { // safari can't scroll popup with focus reacquiring functionality
809 806 if (O$.isMozillaFF() || O$.isExplorer()) {
810   - popup.onmousedown = function() {
  807 + popup.onmousedown = function () {
811 808 dropDown._reacquireFocus = true;
812 809 };
813 810 O$.addUnloadHandler(dropDown, function () {
814 811 popup.onmousedown = null;
815 812 });
816 813 } else {
817   - popup.onfocus = function() {
  814 + popup.onfocus = function () {
818 815 dropDown.focus();
819 816 };
820 817 O$.addUnloadHandler(dropDown, function () {
@@ -865,7 +862,7 @@ O$.DropDownField = {
865 862 field._onchangeFlag = true;
866 863 }
867 864
868   - field.onfocus = function() {
  865 + field.onfocus = function () {
869 866 dropDown._ddf_focused = true;
870 867 if (dropDown._blurWaiter) {
871 868 dropDown._blurWaiter = undefined;
@@ -879,14 +876,15 @@ O$.DropDownField = {
879 876 field.onkeydown = null;
880 877 });
881 878
882   - field.onblur = function(e) {
  879 + field.onblur = function (e) {
883 880 if (itemPresentation)
884   - field._cancelChanges();
  881 + if (!dropDown.isOpened())
  882 + field._cancelChanges();
885 883 dropDown._ddf_focused = false;
886 884 if (dropDown._blurWaiter)
887 885 clearTimeout(dropDown._blurWaiter);
888 886 if (!dropDown._reacquireFocus)
889   - dropDown._blurWaiter = setTimeout(function() {
  887 + dropDown._blurWaiter = setTimeout(function () {
890 888 if (field.value != dropDown._promptText) {
891 889 var currentTime = new Date().getTime();
892 890 if (dropDown._lastItemClickTime && currentTime - dropDown._lastItemClickTime < 200)
@@ -909,7 +907,6 @@ O$.DropDownField = {
909 907 var keyCode = evt.keyCode;
910 908 var autoCompletionAllowedForThisKey = keyCode != 8 && keyCode != 46;
911 909 // Backspace, Del
912   -
913 910 if (field._hidden)
914 911 field.value = "";
915 912 var valueBefore = field.value;
@@ -922,7 +919,7 @@ O$.DropDownField = {
922 919 }
923 920
924 921 field._onchangeFlag = false;
925   - setTimeout(function() {
  922 + setTimeout(function () {
926 923 var valueAfter = field.value;
927 924 if (valueBefore == valueAfter)
928 925 return;
@@ -932,7 +929,7 @@ O$.DropDownField = {
932 929 if (suggestionMode == "none") {
933 930 if (autoCompleteOn && autoCompletionAllowedForThisKey) {
934 931 clearSuggestionTimer();
935   - var completeText = function() {
  932 + var completeText = function () {
936 933 dropDown._currentSuggestionTimeoutId = null;
937 934
938 935 var continuationLength = 0;
@@ -980,7 +977,7 @@ O$.DropDownField = {
980 977 }
981 978
982 979 clearSuggestionTimer();
983   - dropDown._currentSuggestionTimeoutId = setTimeout(function() {
  980 + dropDown._currentSuggestionTimeoutId = setTimeout(function () {
984 981 dropDown._currentSuggestionTimeoutId = null;
985 982 dropDown._setFilterCriterion(field.value, autoCompletionAllowedForThisKey);
986 983 }, suggestionDelay);
@@ -996,7 +993,7 @@ O$.DropDownField = {
996 993 return;
997 994 }
998 995 field._skipRepetitiveOnkeydown = true;
999   - setTimeout(function() {
  996 + setTimeout(function () {
1000 997 field._skipRepetitiveOnkeydown = undefined;
1001 998 }, 1);
1002 999 }
@@ -1013,7 +1010,7 @@ O$.DropDownField = {
1013 1010
1014 1011 popup._addVisibilityChangeListener(dropDown._visibilityChangeListener);
1015 1012 dropDown._clientValueFunctionExists = true;
1016   - dropDown._clientValueFunction = function() {
  1013 + dropDown._clientValueFunction = function () {
1017 1014 if (dropDown._skipValidation) {
1018 1015 return dropDown._initialText;
1019 1016 }
@@ -1038,7 +1035,7 @@ O$.DropDownField = {
1038 1035 };
1039 1036 },
1040 1037
1041   - _onLoadHandler: function(controlId) {
  1038 + _onLoadHandler:function (controlId) {
1042 1039 var dropDown = O$(controlId);
1043 1040
1044 1041 var button = dropDown._button;
@@ -1049,7 +1046,7 @@ O$.DropDownField = {
1049 1046
1050 1047 // Workaround for IE (dropdown field expands when field width is 100% and styles are applied by js on mouseover/mouseout)
1051 1048 if (O$.isExplorer() && (dropDown._fieldClass != dropDown._rolloverFieldClass || dropDown._containerClass != dropDown._rolloverContainerClass)) {
1052   - setTimeout(function() {
  1049 + setTimeout(function () {
1053 1050 O$.DropDownField._fixSize(dropDown);
1054 1051 }, 100);
1055 1052 }
@@ -1062,20 +1059,20 @@ O$.DropDownField = {
1062 1059
1063 1060 },
1064 1061
1065   - _fixSize: function(dropDown) {
  1062 + _fixSize:function (dropDown) {
1066 1063 var field = dropDown._field;
1067 1064 if (field.clientWidth > 0) {
1068 1065 var tdCell = field.parentNode;
1069 1066 field.style.width = tdCell.offsetWidth + "px";
1070 1067 O$.repaintAreaForOpera(dropDown, true);
1071 1068 } else {
1072   - setTimeout(function() {
  1069 + setTimeout(function () {
1073 1070 O$.DropDownField._fixSize(dropDown);
1074 1071 }, 200);
1075 1072 }
1076 1073 },
1077 1074
1078   - _keyPressHandler: function(e) {
  1075 + _keyPressHandler:function (e) {
1079 1076 var evt = O$.getEvent(e);
1080 1077 var needCancelBubble = false;
1081 1078 var keyCode = evt.keyCode;
@@ -1092,7 +1089,7 @@ O$.DropDownField = {
1092 1089 dropDown._keyNavigationStarted = false;
1093 1090 popup.hide();
1094 1091 var currentItemIndex = dropDown._getHighlightedItemIndex();
1095   - if (dropDown._itemPresentation){
  1092 + if (dropDown._itemPresentation) {
1096 1093 if (currentItemIndex == -1) {
1097 1094 dropDown._field._cancelChanges();
1098 1095 } else {
@@ -1119,7 +1116,7 @@ O$.DropDownField = {
1119 1116 },
1120 1117
1121 1118
1122   - _getNeighboringVisibleItem: function(dropDown, itemIndex, searchUpwards) {
  1119 + _getNeighboringVisibleItem:function (dropDown, itemIndex, searchUpwards) {
1123 1120 var itemCount = dropDown._items.length;
1124 1121 var i = itemIndex;
1125 1122 if (searchUpwards)
@@ -1138,7 +1135,7 @@ O$.DropDownField = {
1138 1135 return itemIndex;
1139 1136 },
1140 1137
1141   - _keyDownHandler: function(e) {
  1138 + _keyDownHandler:function (e) {
1142 1139 var evt = O$.getEvent(e);
1143 1140 var keyCode = evt.keyCode;
1144 1141 var dropDown = this._dropDown;
@@ -1151,7 +1148,7 @@ O$.DropDownField = {
1151 1148 if (!dropDown._manualListOpeningAllowed || dropDown._disabled)
1152 1149 return true;
1153 1150 dropDown.dropDown();
1154   - dropDown._checkAdditionalPageNeeded(!dropDown._cachingAllowed,true);
  1151 + dropDown._checkAdditionalPageNeeded(!dropDown._cachingAllowed, true);
1155 1152 O$.cancelEvent(e);
1156 1153 } else {
1157 1154 // Change selected index
@@ -1225,32 +1222,32 @@ O$.DropDownField = {
1225 1222 return true;
1226 1223 },
1227 1224
1228   - _itemClicked: function(dropDown, dropDownItem) {
  1225 + _itemClicked:function (dropDown, dropDownItem) {
1229 1226 dropDown._lastItemClickTime = new Date().getTime();
1230 1227 dropDown.closeUp();
1231 1228 dropDown.focus();
1232 1229 if (dropDown._dropDownMouseOut)
1233 1230 dropDown._dropDownMouseOut();
1234   - setTimeout(function() {
  1231 + setTimeout(function () {
1235 1232 dropDownItem._select();
1236 1233 }, 1);
1237 1234 // for JSFC-1624 to work under IE (focus-tracker doesn't save focus if submit is going from onchange and change is made with mouse)
1238 1235 },
1239 1236
1240   - _closeOnTimeout: function(controlId) {
  1237 + _closeOnTimeout:function (controlId) {
1241 1238 var dropDown = O$(controlId);
1242 1239 if (dropDown._popupCloseTimer) {
1243 1240 clearTimeout(dropDown._popupCloseTimer);
1244 1241 }
1245 1242 if (!dropDown._keyNavigationStarted) {
1246   - dropDown._popupCloseTimer = setTimeout(function() {
  1243 + dropDown._popupCloseTimer = setTimeout(function () {
1247 1244 var popup = dropDown._popup;
1248 1245 popup.hide();
1249 1246 }, dropDown._popupTimeout);
1250 1247 }
1251 1248 },
1252 1249
1253   - _prepareListElements: function(dropDown) {
  1250 + _prepareListElements:function (dropDown) {
1254 1251 var itemList = [];
1255 1252 for (var index = 0, item; item = O$(dropDown.id + "--popup::popupItem" + index); index++) {
1256 1253 item._index = index;
@@ -1259,7 +1256,7 @@ O$.DropDownField = {
1259 1256 return itemList;
1260 1257 },
1261 1258
1262   - _filteredItemsLoaded: function(dropDownField, portionName, portionHTML, portionScripts) {
  1259 + _filteredItemsLoaded:function (dropDownField, portionName, portionHTML, portionScripts) {
1263 1260 var sepIdx = portionName.indexOf(":");
1264 1261 var filterCriterionStr = portionName.substring(sepIdx + 1);
1265 1262 var filterCriterion;
@@ -1270,7 +1267,7 @@ O$.DropDownField = {
1270 1267 filterCriterion = filterCriterionStr.substring(1, filterCriterionStr.length - 1);
1271 1268 }
1272 1269
1273   - var cacheOnly = !(filterCriterion == null || dropDownField._field.value == (filterCriterion || ""));
  1270 + var cacheOnly = !(filterCriterion == null || dropDownField._field.value == (filterCriterion || ""));
1274 1271
1275 1272 var tempDiv = document.createElement("div");
1276 1273 tempDiv.style.display = "none";
@@ -1282,12 +1279,12 @@ O$.DropDownField = {
1282 1279 var children = tableBody.childNodes;
1283 1280 var newNodes = [];
1284 1281 var i, count;
1285   - for (i = 0,count = children.length; i < count; i++) {
  1282 + for (i = 0, count = children.length; i < count; i++) {
1286 1283 var child = children[i];
1287 1284 newNodes.push(child);
1288 1285 }
1289 1286 var newRows = [];
1290   - for (i = 0,count = newNodes.length; i < count; i++) {
  1287 + for (i = 0, count = newNodes.length; i < count; i++) {
1291 1288 var newNode = newNodes[i];
1292 1289 if (!newNode || !newNode.tagName)
1293 1290 continue;
@@ -1297,7 +1294,7 @@ O$.DropDownField = {
1297 1294 }
1298 1295 }
1299 1296
1300   - dropDownField.__acceptLoadedItems = function(newRowsToStylesMap, newRowCellsToStylesMap, itemValues, appendItems) {
  1297 + dropDownField.__acceptLoadedItems = function (newRowsToStylesMap, newRowCellsToStylesMap, itemValues, appendItems) {
1301 1298 dropDownField.__acceptLoadedItems = undefined;
1302 1299 var prevSuggestionCount = dropDownField._addCachedSuggestions(filterCriterion, newRows, newRowsToStylesMap, newRowCellsToStylesMap, itemValues, appendItems);
1303 1300 if (!appendItems && cacheOnly)
@@ -1316,7 +1313,7 @@ O$.DropDownField = {
1316 1313
1317 1314 },
1318 1315
1319   - _acceptLoadedItems: function(dropDownFieldId, newItemParams) {
  1316 + _acceptLoadedItems:function (dropDownFieldId, newItemParams) {
1320 1317 var dropDownField = O$(dropDownFieldId);
1321 1318 dropDownField.__acceptLoadedItems.apply(dropDownField, newItemParams);
1322 1319 }

0 comments on commit 63f8c06

Please sign in to comment.
Something went wrong with that request. Please try again.