|
|
|
 |
 |
Исходник |
 |
|
 |
 |
|
Автор:
|
|
|
Название:
|
Доступ к ASPxComboBox из Яваскрипта: ломаем дальше методом полного анализа объекта (элемент управления из библиотеки Developer Express, диапазон версий 7.2.x.x ... 7.3.x.x) |
|
Дата:
|
11 January 2008 |
|
Описание: |
Предыдущий быстрый способ взлома хотя и работает, но некрасив и малофункционален. Поэтому я приглашаю тусовку не останавливаться на достигнутом и попытаться доломать проклятых буржуев до конца. В этом нам поможет так называемый метод полного анализа объекта - Яваскрипт позволяет разложить любой объект по косточкам - единственное надо применять его точечно чтобы не утонуть в море информации. |
| |
Разместить ссылку на этот исходник в форуме вы можете вставив в текст сообщения
следующую строку:
[CODEPOST ID=222]Доступ к ASPxComboBox из Яваскрипта: ломаем дальше методом полного анализа объекта (элемент управления из библиотеки Developer Express, диапазон версий 7.2.x.x ... 7.3.x.x)[/CODEPOST] |
| Оценка: |
Проголосовало 3 посетителей, средняя оценка 1.67 |
| Оценить: |
|
1 В чём состоит способ полного анализа объекта? Это цикл for(var name in Объект).
2
3 1. Создаём обработчик события SelectedIndexChanged:
4
5 <dxe:ASPxComboBox ID="ASPxComboBox1" runat="server" CssFilePath="~/App_Themes/Glass/{0}/styles.css"
6 CssPostfix="Glass" ImageFolder="~/App_Themes/Glass/{0}/" Width="100%" ValueType="System.String">
7 <ValidationSettings>
8 <ErrorFrameStyle ImageSpacing="4px">
9 <ErrorTextPaddings PaddingLeft="4px" />
10 </ErrorFrameStyle>
11 <ErrorImage Height="14px" Url="~/App_Themes/Glass/Editors/edtError.png" Width="14px" />
12 </ValidationSettings>
13 <ClientSideEvents SelectedIndexChanged="function(s, e)
14 {
15 var names='';
16 var i=0;
17 for(var name in s)
18 {
19 i++;
20 names+='='+i+'='+'\n'+name+'='+s[name]+'\n';
21 }
22 document.getElementById('TextBox1').innerHTML=names;
23 }" />
24 </dxe:ASPxComboBox>
25
26 Ну и зацениваем содержимое TextBox1. Там, как Вы догадываетесь, много интересного, но самое интересное вот это:
27
28 name=ASPxComboBox1
29
30 А это означает, что в любом месте Яваскрипта можно обращаться к комбобоксу напрямую по имени ASPxComboBox1.
31
32 2. Продолжаем взлом. Добавляем в обработчик первоначальной загрузки цикл for(var name in ASPxComboBox1):
33
34 // Функция первоначальной загрузки
35 function fLoad()
36 {
37 ...
38 var names='';
39 var i=0;
40 for(var name in ASPxComboBox1)
41 {
42 i++;
43 names+='='+i+'='+'\n'+name+'='+ASPxComboBox1[name]+'\n';
44 }
45 document.getElementById('TextBox1').innerHTML=names;
46 ...
47 }
48
49 Сравниваем объекты s и ASPxComboBox1. Почти совпадают. У s 274 подобъекта, а у ASPxComboBox1 - 271.
50
51 3. Анализируем, проверяем на практике и делаем выводы.
52
53 Соответствие DropDownList -> ASPxComboBox
54 document.getElementById("DropDownList1") соответствует ASPxComboBox1
55 .selectedIndex соответствует .GetSelectedIndex или .GetListBoxControl().GetSelectedIndexInternal()
56 .options соответствует .GetItem()
57 .options[i].value соответствует .GetItem(i).value
58 .options[i].text соответствует .GetItem(i).text
59 Обратите внимание на круглые скобки. Это не опечатка - Девэксп решил заново изобрести велосипед и запендюрил функции вместо массивов - ничего не поделаешь.
60
61 4. Кроме гетеров имеются соответствующие сетеры. Полный список подобъектов, выводимый методом полного анализа for(var name in ASPxComboBox1), приводится ниже:
62
63 =1=
64 constructor=function () {
65 if (ret.preparing) {
66 return delete ret.preparing;
67 }
68 if (ret.constr) {
69 this.constructor = ret;
70 ret.constr.apply(this, arguments);
71 }
72 }
73 =2=
74 name=ASPxComboBox1
75 =3=
76 uniqueID=ASPxComboBox1
77 =4=
78 autoPostBack=false
79 =5=
80 callBack=function (arg) {
81 WebForm_DoCallback("ASPxComboBox1", arg, aspxCallback, "ASPxComboBox1", aspxCallbackError, true);
82 }
83 =6=
84 allowMultipleCallbacks=false
85 =7=
86 requestCount=0
87 =8=
88 isInitialized=false
89 =9=
90 leadingAfterInitCall=false
91 =10=
92 sizeCorrectedOnce=false
93 =11=
94 serverEvents=
95 =12=
96 mainElement=null
97 =13=
98 Init=[object Object]
99 =14=
100 BeginCallback=[object Object]
101 =15=
102 EndCallback=[object Object]
103 =16=
104 inputElement=null
105 =17=
106 convertEmptyStringToNull=true
107 =18=
108 widthCorrectionRequired=false
109 =19=
110 heightCorrectionRequired=false
111 =20=
112 initialErrorText=
113 =21=
114 causesValidation=false
115 =22=
116 validationGroup=
117 =23=
118 sendPostBackWithValidation=null
119 =24=
120 customValidationEnabled=false
121 =25=
122 validationPatterns=null
123 =26=
124 setFocusOnError=false
125 =27=
126 errorDisplayMode=it
127 =28=
128 errorText=
129 =29=
130 isValid=true
131 =30=
132 errorImageIsAssigned=false
133 =31=
134 GotFocus=[object Object]
135 =32=
136 LostFocus=[object Object]
137 =33=
138 Validation=[object Object]
139 =34=
140 ValueChanged=[object Object]
141 =35=
142 KeyDown=[object Object]
143 =36=
144 KeyPress=[object Object]
145 =37=
146 KeyUp=[object Object]
147 =38=
148 TextChanged=[object Object]
149 =39=
150 ButtonClick=[object Object]
151 =40=
152 DropDown=[object Object]
153 =41=
154 CloseUp=[object Object]
155 =42=
156 ddHeightCache=-10000
157 =43=
158 ddWidthCache=-10000
159 =44=
160 dropDownButtonIndex=-1
161 =45=
162 droppedDown=false
163 =46=
164 lastSuccessText=
165 =47=
166 SelectedIndexChanged=[object Object]
167 =48=
168 filterTimerId=-1
169 =49=
170 lbEventLockCount=0
171 =50=
172 isCallbackMode=false
173 =51=
174 isPerformCallback=false
175 =52=
176 changeSelectAfterCallback=0
177 =53=
178 isFilterEnabled=false
179 =54=
180 isEnterLocked=false
181 =55=
182 filter=
183 =56=
184 isToolBarItem=false
185 =57=
186 isDropDownListStyle=true
187 =58=
188 dropDownHeight=
189 =59=
190 dropDownWidth=
191 =60=
192 listBox=null
193 =61=
194 lastSuccessValue=
195 =62=
196 islastSuccessValueInit=false
197 =63=
198 Initialize=function () {
199 var lb = this.GetListBoxControl();
200 if (_aspxIsExists(lb)) {
201 lb.ownerName = this.name;
202 }
203 var mainElement = this.GetMainElement();
204 var input = this.FindInputElement();
205 var ddbutton = this.GetDropDownButton();
206 if (_aspxIsExists(ddbutton)) {
207 _aspxAttachEventToElement(ddbutton, "mousemove", _aspxCBDDButtonMMove);
208 }
209 if (this.isFilterEnabled) {
210 _aspxAttachEventToElement(input, "keyup", _aspxCBKeyUp);
211 }
212 if (this.isDropDownListStyle && __aspxIE) {
213 _aspxPreventElementDragAndSelect(mainElement, true);
214 _aspxPreventElementDragAndSelect(input, true);
215 if (_aspxIsExists(ddbutton)) {
216 _aspxPreventElementDragAndSelect(ddbutton, true);
217 }
218 }
219 if (this.isToolBarItem) {
220 mainElement.unselectable = "on";
221 input.unselectable = "on";
222 input.offsetParent.unselectable = "on";
223 if (_aspxIsExists(ddbutton)) {
224 ddbutton.unselectable = "on";
225 }
226 if (_aspxIsExists(lb)) {
227 var table = lb.GetListTable();
228 for (var i = 0; i < table.rows.length; i++) {
229 for (var j = 0; j < table.rows[i].cells.length; j++) {
230 table.rows[i].cells[j].unselectable = "on";
231 }
232 }
233 }
234 }
235 this.RemoveRaisePSValidationFromListBox();
236 this.RedirectStandardValidators();
237 this.UpdateValueInput();
238 this.InitDropDownSize();
239 ASPxClientDropDownEdit.prototype.Initialize.call(this);
240 }
241 =64=
242 CorrectSize=function (checkSizeCorrectedFlag) {
243 if (checkSizeCorrectedFlag && this.sizeCorrectedOnce ||
244 !this.IsVisible()) {
245 return;
246 }
247 ASPxClientEdit.prototype.CorrectSize.call(this, checkSizeCorrectedFlag);
248 this.ddHeightCache = __aspxInvalidDimension;
249 this.ddWidthCache = __aspxInvalidDimension;
250 }
251 =65=
252 EnableStyleControllerForDDButton=function () {
253 var element = this.GetDropDownButton();
254 if (_aspxIsExists(element)) {
255 var controller = aspxGetStateController();
256 this.ReplaceElementControlStyleItem(controller.hoverItems, element, this.ddButtonHoverStyle);
257 this.ReplaceElementControlStyleItem(controller.pressedItems, element, this.ddButtonPressedStyle);
258 this.ReplaceElementControlStyleItem(controller.selectedItems, element, this.ddButtonSelectedStyle);
259 }
260 }
261 =66=
262 DisableStyleControllerForDDButton=function () {
263 var element = this.GetDropDownButton();
264 if (_aspxIsExists(element)) {
265 var controller = aspxGetStateController();
266 this.ddButtonHoverStyle = this.ReplaceElementControlStyleItem(controller.hoverItems, element, null);
267 this.ddButtonPressedStyle = this.ReplaceElementControlStyleItem(controller.pressedItems, element, null);
268 this.ddButtonSelectedStyle = this.ReplaceElementControlStyleItem(controller.selectedItems, element, null);
269 }
270 }
271 =67=
272 ReplaceElementControlStyleItem=function (items, element, newStyleItem) {
273 var styleItem = items[element.id];
274 items[element.id] = newStyleItem;
275 return styleItem;
276 }
277 =68=
278 RemoveRaisePSValidationFromListBox=function () {
279 var listBox = this.GetListBoxControl();
280 if (_aspxIsExists(listBox)) {
281 listBox.RaisePersonalStandardValidation = function () {};
282 }
283 }
284 =69=
285 RedirectStandardValidators=function () {
286 var valueInput = this.GetValueInput();
287 if (_aspxIsExistsElement(valueInput) &&
288 _aspxIsExists(valueInput.Validators)) {
289 for (var i = 0; i < valueInput.Validators.length; i++) {
290 valueInput.Validators[i].controltovalidate = valueInput.id;
291 }
292 }
293 }
294 =70=
295 DropDownButtonPush=function () {
296 if (__aspxIE || __aspxOpera) {
297 this.DropDownButtonPushCommon();
298 } else {
299 this.DropDownButtonPushMozilla();
300 }
301 }
302 =71=
303 DropDownButtonPop=function () {
304 if (__aspxIE || __aspxOpera) {
305 this.DropDownButtonPopCommon();
306 } else {
307 this.DropDownButtonPopMozilla();
308 }
309 }
310 =72=
311 DropDownButtonPushCommon=function () {
312 if (this.droppedDown) {
313 return;
314 }
315 var buttonElement = this.GetDropDownButton();
316 if (_aspxIsExists(buttonElement)) {
317 var controller = aspxGetStateController();
318 controller.SetCurrentHoverElement(null);
319 var element = controller.GetPressedElement(buttonElement);
320 if (_aspxIsExists(element)) {
321 controller.DoSetPressedState(element);
322 }
323 }
324 }
325 =73=
326 DropDownButtonPopCommon=function () {
327 if (!this.droppedDown) {
328 return;
329 }
330 var buttonElement = this.GetDropDownButton();
331 if (_aspxIsExists(buttonElement)) {
332 var controller = aspxGetStateController();
333 var element = controller.GetPressedElement(buttonElement);
334 if (_aspxIsExists(element)) {
335 controller.DoClearPressedState(element);
336 }
337 }
338 }
339 =74=
340 DropDownButtonPushMozilla=function () {
341 if (this.droppedDown) {
342 return;
343 }
344 this.DisableStyleControllerForDDButton();
345 var controller = aspxGetStateController();
346 controller.savedCurrentPressedElement = null;
347 }
348 =75=
349 DropDownButtonPopMozilla=function () {
350 if (!this.droppedDown) {
351 return;
352 }
353 this.EnableStyleControllerForDDButton();
354 var controller = aspxGetStateController();
355 var buttonElement = this.GetDropDownButton();
356 if (_aspxIsExists(buttonElement)) {
357 var element = controller.GetPressedElement(buttonElement);
358 if (_aspxIsExists(element)) {
359 controller.DoClearPressedState(element);
360 }
361 controller.currentPressedElement = null;
362 element = controller.GetHoverElement(buttonElement);
363 if (_aspxIsExists(element)) {
364 controller.SetCurrentHoverElement(element);
365 }
366 }
367 }
368 =76=
369 FindItemIndexByText=function (lb, text) {
370 if (!_aspxIsExists(lb)) {
371 return;
372 }
373 for (var i = 0; i < lb.GetItemCount(); i++) {
374 if (lb.GetItem(i).text == text) {
375 return i;
376 }
377 }
378 return -1;
379 }
380 =77=
381 GetValueInputToValidate=function () {
382 return this.GetValueInput();
383 }
384 =78=
385 GetValueInput=function () {
386 return document.getElementById(this.name + "_" + __aspxCCValueInputSuffix);
387 }
388 =79=
389 GetListBoxControl=function () {
390 if (!_aspxIsExistsElement(this.listBox)) {
391 var name = this.GetDropDownInnerControlName(__aspxListBoxNameSuffix);
392 this.listBox = aspxGetControlCollection().Get(name);
393 }
394 return this.listBox;
395 }
396 =80=
397 GetListBoxScrollDivElement=function () {
398 return this.GetListBoxControl().GetScrollDivElement();
399 }
400 =81=
401 GetDropDownHeight=function () {
402 return this.ddHeightCache != __aspxInvalidDimension ? this.ddHeightCache : this.InitListBoxHeight();
403 }
404 =82=
405 GetDropDownWidth=function () {
406 return this.ddWidthCache != __aspxInvalidDimension ? this.ddWidthCache : this.InitListBoxWidth();
407 }
408 =83=
409 SetText=function (text) {
410 var lb = this.GetListBoxControl();
411 var index = this.FindItemIndexByText(lb, text);
412 this.SelectIndex(index);
413 this.SetTextInternal(text);
414 this.lastSuccessText = text;
415 this.lastSuccessValue = index >= 0 ? lb.GetValue() : text;
416 this.islastSuccessValueInit = true;
417 }
418 =84=
419 GetValue=function () {
420 return this.islastSuccessValueInit ? this.lastSuccessValue : this.GetValueInternal();
421 }
422 =85=
423 GetValueInternal=function () {
424 var text = ASPxClientDropDownEdit.prototype.GetValue.call(this);
425 var lb = this.GetListBoxControl();
426 if (_aspxIsExists(lb)) {
427 var index = this.FindItemIndexByText(lb, text);
428 lb.SelectIndex(index, false);
429 if (index != -1) {
430 return lb.GetValue();
431 }
432 }
433 return text;
434 }
435 =86=
436 SetValue=function (value) {
437 var lb = this.GetListBoxControl();
438 lb.SetValue(value);
439 var item = lb.GetSelectedItem();
440 var text = _aspxIsExists(item) ? item.text : value;
441 this.SetTextInternal(text);
442 this.lastSuccessText = text;
443 this.lastSuccessValue = item != null ? item.value : text;
444 this.islastSuccessValueInit = true;
445 this.UpdateValueInput();
446 }
447 =87=
448 UpdateValueInput=function () {
449 var input = this.GetValueInput();
450 var value = this.GetValue();
451 input.value = value != null ? value : "";
452 }
453 =88=
454 CollectionChanged=function () {
455 if (this.GetListBoxControl().APILockCount == 0) {
456 this.InitDropDownSize();
457 }
458 }
459 =89=
460 InitDropDownSize=function () {
461 var pc = this.GetPopupControl();
462 if (_aspxIsExists(pc) && this.IsDisplayed()) {
463 var pcwElement = pc.GetWindowElement(-1);
464 if (_aspxIsExistsElement(pcwElement)) {
465 var isPcwDisplayad = _aspxGetElementDisplay(pcwElement);
466 if (!isPcwDisplayad) {
467 pc.SetWindowDisplay(-1, true);
468 }
469 this.ddHeightCache = this.InitListBoxHeight();
470 this.ddWidthCache = this.InitListBoxWidth();
471 pc.SetSize(this.ddWidthCache, this.ddHeightCache);
472 if (!isPcwDisplayad) {
473 pc.SetWindowDisplay(-1, false);
474 }
475 }
476 }
477 }
478 =90=
479 InitListBoxHeight=function () {
480 var lbScrollDiv = this.GetListBoxScrollDivElement();
481 var height = this.dropDownHeight;
482 var lb = this.GetListBoxControl();
483 var lbHeight = 0;
484 if (height == "") {
485 var listHeight = lb.GetListTableHeight();
486 var count = lb.GetItemCount();
487 if (count > 7) {
488 height = listHeight / count * 7 + "px";
489 } else {
490 height = count == 0 ? "0px" : listHeight + "px";
491 }
492 lbScrollDiv.style.height = height;
493 lbHeight = lbScrollDiv.offsetHeight;
494 } else {
495 var lbMainElement = lb.GetMainElement();
496 lbMainElement.style.height = "0px";
497 lbScrollDiv.style.height = "0px";
498 lbMainElement.style.height = height;
499 var trueLbOffsetHeight = lbMainElement.offsetHeight;
500 var trueLbClientHeight = lbMainElement.clientHeight;
501 lbScrollDiv.style.height = lbMainElement.clientHeight + "px";
502 lbHeightCorrection = lbMainElement.offsetHeight - trueLbOffsetHeight;
503 lbScrollDiv.style.height = trueLbClientHeight - lbHeightCorrection + "px";
504 lbHeight = lbMainElement.offsetHeight;
505 }
506 lb.InitializePageSize();
507 return lbHeight;
508 }
509 =91=
510 InitListBoxWidth=function () {
511 var mainElement = this.GetMainElement();
512 var lb = this.GetListBoxControl();
513 var lbMainElement = lb.GetMainElement();
514 var lbScrollDiv = this.GetListBoxScrollDivElement();
515 var lbTable = lb.GetListTable();
516 lbMainElement.style.width = "";
517 lbScrollDiv.style.width = "100%";
518 if (this.dropDownWidth != "") {
519 lbMainElement.style.width = this.dropDownWidth;
520 lbScrollDiv.style.width = lbMainElement.clientWidth + "px";
521 var difference = lbTable.offsetWidth - lbScrollDiv.clientWidth;
522 if (!__aspxIE && difference > 0) {
523 lbMainElement.style.width = lbMainElement.offsetWidth + difference + "px";
524 lbScrollDiv.style.width = lbMainElement.clientWidth + "px";
525 }
526 } else {
527 var pc = this.GetPopupControl();
528 var width = lbTable.offsetWidth;
529 var scrollWidth = lb.GetVerticalScrollBarWidth();
530 var isBrowserPutScrollOnContent = !__aspxIE || __aspxIE55;
531 var isBrowserAbleAnimScroll = !__aspxMozilla || __aspxFirefox || !pc.enableAnimation;
532 if (isBrowserPutScrollOnContent && isBrowserAbleAnimScroll) {
533 width += scrollWidth;
534 }
535 lbScrollDiv.style.width = width + "px";
536 if (__aspxFirefox &&
537 lbMainElement.offsetWidth < lbScrollDiv.offsetWidth) {
538 lbMainElement.style.width = "0%";
539 }
540 var widthDifference = mainElement.offsetWidth - lbMainElement.offsetWidth;
541 if (widthDifference > 0) {
542 lbScrollDiv.style.width = width + widthDifference + "px";
543 var twoBorderSize = lbMainElement.offsetWidth - lbMainElement.clientWidth;
544 lbMainElement.style.width = width + widthDifference + twoBorderSize + "px";
545 }
546 }
547 return lbScrollDiv.offsetWidth;
548 }
549 =92=
550 SelectIndex=function (index) {
551 var lb = this.GetListBoxControl();
552 var isSelectionChanged = lb.SelectIndex(index, false);
553 var item = lb.GetSelectedItem();
554 var text = item != null ? item.text : "";
555 if (isSelectionChanged) {
556 this.SetTextInternal(text);
557 this.lastSuccessText = text;
558 this.lastSuccessValue = item != null ? item.value : text;
559 this.islastSuccessValueInit = true;
560 }
561 return isSelectionChanged;
562 }
563 =93=
564 SelectIndexSilent=function (lb, index) {
565 this.lbEventLockCount++;
566 lb.SelectIndexInternal(index);
567 this.lbEventLockCount--;
568 }
569 =94=
570 SelectInputText=function () {
571 var input = this.GetInputElement();
572 _aspxSetInputSelection(input, 0, input.value.length);
573 }
574 =95=
575 ShowDropDownArea=function (isRaiseEvent) {
576 var lb = this.GetListBoxControl();
577 if (!_aspxIsExists(lb) || lb.GetItemCount() == 0) {
578 return;
579 }
580 var pc = this.GetPopupControl();
581 ASPxClientDropDownEdit.prototype.ShowDropDownArea.call(this, isRaiseEvent);
582 if (__aspxMozilla && pc.enableAnimation) {
583 this.DisableLBDivOverflow();
584 window.setTimeout(_aspxCBMozillaOverflowOn, pc.animationMaxDelay / 2, this.name);
585 }
586 var text = ASPxClientDropDownEdit.prototype.GetValue.call(this);
587 var lbItem = lb.GetSelectedItem();
588 var lbText = lbItem != null ? lbItem.text : "";
589 if (text != lbText && text != null && lbText != "") {
590 var newSelectedIndex = this.FindItemIndexByText(lb, text);
591 lb.SelectIndex(newSelectedIndex, false);
592 }
593 lb.EnsureSelectedItemVisible();
594 lb.CallbackSpaceInit();
595 }
596 =96=
597 HideDropDownArea=function (isRaiseEvent) {
598 this.DropDownButtonPop();
599 this.FilteringStop();
600 ASPxClientDropDownEdit.prototype.HideDropDownArea.call(this, isRaiseEvent);
601 }
602 =97=
603 EnableLBDivOverflow=function () {
604 var divElement = this.GetListBoxScrollDivElement();
605 divElement.style.overflow = "auto";
606 }
607 =98=
608 DisableLBDivOverflow=function () {
609 var divElement = this.GetListBoxScrollDivElement();
610 divElement.style.overflow = "hidden";
611 }
612 =99=
613 OnFiltering=function (evt) {
614 if (this.isFilterEnabled &&
615 evt.keyCode != 16 && !evt.ctrlKey && !evt.altKey) {
616 _aspxClearTimer(this.filterTimerId);
617 var input = this.FindInputElement();
618 var newFilter = input.value.toLowerCase();
619 if (evt.keyCode == 8 &&
620 _aspxHasInputSelection(input) && newFilter == this.filter) {
621 this.FilteringBackspace(false);
622 } else if (this.IsFilterKeycode(evt.keyCode)) {
623 this.FilterByTimer();
624 }
625 }
626 }
627 =100=
628 FilterByTimer=function () {
629 this.isEnterLocked = true;
630 this.filterTimerId = _aspxSetTimeout("_aspxCBFilterByTimer('" + this.name + "')", 100);
631 }
632 =101=
633 EnshureShowDropDownArea=function () {
634 if (!this.droppedDown) {
635 this.ShowDropDownArea(true);
636 }
637 }
638 =102=
639 Filtering=function () {
640 var input = this.FindInputElement();
641 var newFilter = input.value.toLowerCase();
642 if (this.filter != newFilter || this.isDropDownListStyle) {
643 this.filter = newFilter;
644 this.EnshureShowDropDownArea();
645 if (this.isCallbackMode) {
646 this.FilteringOnServer();
647 } else {
648 this.FilteringOnClient(input);
649 }
650 } else {
651 this.isEnterLocked = false;
652 }
653 }
654 =103=
655 FilteringBackspace=function (isBefore) {
656 if (this.isFilterEnabled) {
657 var input = this.FindInputElement();
658 if (!isBefore) {
659 var text = input.value;
660 var newInput = text.substring(0, text.length - 1);
661 input.value = newInput;
662 this.FilterByTimer();
663 }
664 return _aspxHasInputSelection(input);
665 }
666 return false;
667 }
668 =104=
669 GetCallbackArguments=function () {
670 var args = this.GetCallbackArgumentsChild();
671 if (this.isCallbackMode) {
672 args += this.GetCallbackArgumentsInternal();
673 }
674 return args;
675 }
676 =105=
677 GetCallbackArgumentsInternal=function () {
678 var args = "";
679 if (this.filter != "") {
680 args = this.GetCallbackArgumentFilter(this.filter);
681 }
682 return args;
683 }
684 =106=
685 GetCallbackArgumentFilter=function (value) {
686 var callbackPrefix = this.isDropDownListStyle ? __aspxCorrectFilterCallbackPrefix : __aspxLoadFilteredItemsCallbackPrefix;
687 return this.FormatCallbackArg(callbackPrefix, value);
688 }
689 =107=
690 GetCallbackArgumentsChild=function () {
691 var lb = this.GetListBoxControl();
692 return lb.GetCallbackArguments();
693 }
694 =108=
695 FilteringOnServer=function () {
696 if (!this.InCallback()) {
697 this.GetListBoxControl().ClearItems();
698 this.SendCallback();
699 }
700 }
701 =109=
702 FilteringOnClient=function (input) {
703 var filter = this.filter.toLowerCase();
704 var lb = this.GetListBoxControl();
705 var listTable = lb.GetListTable();
706 var count = lb.GetItemCount();
707 var text = "";
708 var isSatisfy = false;
709 var isFirstSatisfyItemFinded = false;
710 if (this.isDropDownListStyle) {
711 var coincide = new Array(count);
712 var maxCoincide = 0;
713 for (var i = count - 1; i >= 0; i--) {
714 coincide[i] = this.GetCoincideCharCount(lb.GetItem(i).text.toLowerCase(), filter);
715 if (coincide[i] > maxCoincide) {
716 maxCoincide = coincide[i];
717 }
718 }
719 filter = filter.substr(0, maxCoincide);
720 this.GetInputElement().value = filter;
721 }
722 for (var i = 0; i < count; i++) {
723 text = lb.GetItem(i).text;
724 isSatisfy = this.isDropDownListStyle ? coincide[i] == maxCoincide : text.toLowerCase().indexOf(filter) == 0;
725 _aspxSetElementDisplay(listTable.rows[i], isSatisfy);
726 if (!isFirstSatisfyItemFinded && isSatisfy) {
727 var isTextClearing = !this.isDropDownListStyle &&
728 this.filter == "" && this.filter != text;
729 if (!isTextClearing) {
730 this.FilteringHighlightComplitedText(i, text);
731 }
732 this.SelectIndexSilent(lb, isTextClearing ? -1 : i);
733 isFirstSatisfyItemFinded = true;
734 }
735 }
736 if (this.isDropDownListStyle) {
737 this.filter = filter;
738 }
739 if (!isFirstSatisfyItemFinded) {
740 this.HideDropDownArea(true);
741 }
742 this.isEnterLocked = false;
743 }
744 =110=
745 GetCoincideCharCount=function (text, filter) {
746 while (filter != "" && text.indexOf(filter) != 0) {
747 filter = filter.slice(0, -1);
748 }
749 return filter.length;
750 }
751 =111=
752 FilteringHighlightComplitedText=function (index, filterItemText) {
753 var lb = this.GetListBoxControl();
754 var input = this.FindInputElement();
755 var text = input.value;
756 var valueLenght = text.length;
757 var itemTextLenght = filterItemText.length;
758 input.value = filterItemText;
759 _aspxSetInputSelection(input, valueLenght, itemTextLenght);
760 }
761 =112=
762 FilteringStop=function () {
763 if (this.isFilterEnabled) {
764 this.isEnterLocked = false;
765 if (!this.isCallbackMode) {
766 this.FilteringStopClient();
767 }
768 }
769 }
770 =113=
771 FilteringStopClient=function () {
772 var lb = this.GetListBoxControl();
773 var listTable = lb.GetListTable();
774 var count = lb.GetItemCount();
775 for (var i = 0; i < count; i++) {
776 _aspxSetElementDisplay(listTable.rows[i], true);
777 }
778 }
779 =114=
780 IsFilterKeycode=function (keyCode) {
781 return keyCode == 8 || keyCode == 32 || keyCode > 45;
782 }
783 =115=
784 ShowLoadingPanel=function () {
785 var lb = this.GetListBoxControl();
786 var loadingParentElement = lb.GetScrollDivElement().parentNode;
787 this.loadingDivElement = this.CreateLoadingDiv(loadingParentElement);
788 this.loadingPanelElement = this.CreateLoadingPanelWithAbsolutePosition(loadingParentElement, loadingParentElement);
789 }
790 =116=
791 HideLoadingPanel=function () {
792 if (_aspxIsExistsElement(this.loadingPanelElement)) {
793 this.loadingPanelElement.parentNode.removeChild(this.loadingPanelElement);
794 this.loadingPanelElement = null;
795 }
796 if (_aspxIsExistsElement(this.loadingDivElement)) {
797 this.loadingDivElement.parentNode.removeChild(this.loadingDivElement);
798 this.loadingDivElement = null;
799 }
800 }
801 =117=
802 FormatCallbackArg=function (prefix, arg) {
803 if (arg == null) {
804 return "";
805 }
806 if (!_aspxIsExists(arg.length) && _aspxIsExists(arg.value)) {
807 arg = arg.value;
808 }
809 if (arg == null || arg == "") {
810 return "";
811 }
812 return prefix + "|" + arg.length + ";" + arg + ";";
813 }
814 =118=
815 OnAfterCallback=function () {
816 this.CollectionChanged();
817 this.HideLoadingPanel();
818 this.isPerformCallback = false;
819 }
820 =119=
821 OnCallback=function (result) {
822 this.GetListBoxControl().OnCallback(result);
823 this.OnCallbackInternal(result);
824 this.OnAfterCallback();
825 }
826 =120=
827 OnCallbackError=function (result) {
828 this.GetListBoxControl().OnCallbackError(result);
829 this.OnAfterCallback();
830 }
831 =121=
832 OnCallbackInternal=function (result) {
833 this.OnFilterCallback(result);
834 if (this.changeSelectAfterCallback > 0) {
835 var lb = this.GetListBoxControl();
836 this.SelectNeighbourInternal(lb, lb.GetSelectedIndexInternal() + this.changeSelectAfterCallback);
837 this.changeSelectAfterCallback = 0;
838 }
839 }
840 =122=
841 OnFilterCallback=function (result) {
| | | |