123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303 |
- var CMultipleTextPicker_INSTANCES = new Array();
- function CMultipleTextPicker(oTextPicker, oLstChoices, oSubmit, bRequired, sSubmitType, oErrorFeedback, oSizer, oInsertButton, oRemoveButton, sCVId)
- {
- this.setCVId(sCVId);
- CMultipleTextPicker_INSTANCES[CMultipleTextPicker_INSTANCES.length] = this;
- this.m_oTextPicker = oTextPicker;
- this.m_oLstChoices = oLstChoices;
- this.m_oSubmit = oSubmit;
- this.m_bRequired = bRequired;
- this.m_bValid = false;
- this.m_sSubmitType = sSubmitType;
- this.m_oErrorFeedback = oErrorFeedback;
- if (oInsertButton)
- {
- this.m_oInsertButton = oInsertButton;
- }
- if (oRemoveButton)
- {
- this.m_oRemoveButton = oRemoveButton;
- }
- this.checkData();
-
- if(oSizer)
- {
- this.m_oSizer = oSizer;
- this.m_oLstChoices.style.width='auto';
- setTimeout("resizeCMultipleTextPickerINSTANCES()",1);
- }
-
- this.checkInsertRemove();
- }
- CMultipleTextPicker.prototype = new CPromptControl();
- function CMultipleTextPicker_selectAll()
- {
- for (var i=0; i < this.m_oLstChoices.options.length; i++)
- {
- this.m_oLstChoices.options[i].selected = true;
- }
-
- this.checkInsertRemove();
- }
- function CMultipleTextPicker_deSelectAll()
- {
- for (var i=0; i < this.m_oLstChoices.options.length; i++)
- {
- this.m_oLstChoices.options[i].selected = false;
- }
-
- this.checkInsertRemove();
- }
- function CMultipleTextPicker_insert()
- {
- var sInsertText = this.m_oTextPicker.sGetValue();
- var sDisplayValue = this.m_oTextPicker.sGetFormatValue();
- if (sInsertText)
- {
-
- var rMultiline = /[\n\f\r]+/;
- var arInsertText = sInsertText.replace(/[\n\f\r\s]+$/,'').split(rMultiline);
- if (arInsertText.length > 1)
- {
- for (var i=0; i < arInsertText.length; i++)
- {
- var sFormatValue = getFormatByDataType(arInsertText[i], this.m_oTextPicker.m_sDataType, this.m_oTextPicker.m_bIsCurrency);
- this.m_oLstChoices.options[this.m_oLstChoices.options.length] = new Option(sFormatValue, arInsertText[i], false, false);
- }
- }
- else
- {
- this.m_oLstChoices.options[this.m_oLstChoices.options.length] = new Option(sDisplayValue, sInsertText, false, false);
- }
-
- this.m_oTextPicker.clear();
- }
- this.checkData();
- setTimeout("resizeCMultipleTextPickerINSTANCES()",1);
-
- this.checkInsertRemove();
- }
- function CMultipleTextPicker_remove()
- {
- this.removeSelectedChoices();
- setTimeout("resizeCMultipleTextPickerINSTANCES()",1);
-
- this.checkInsertRemove();
- }
- CMultipleTextPicker.prototype = new CPromptControl();
- function CMultipleTextPicker_preProcess()
- {
- var i=0;
- if (this.m_sSubmitType == K_PRMT_sXML)
- {
-
- var sURLValues = K_PRMT_sEMPTY;
- if (this.m_oLstChoices.options.length > 0)
- {
- for(i = 0; i < this.m_oLstChoices.options.length; i ++)
- {
- sURLValues += '<selectOption';
- sURLValues += ' displayValue="' + sXmlEncode(this.m_oLstChoices.options[i].text) +'"';
- sURLValues += ' useValue="' + sXmlEncode(this.m_oLstChoices.options[i].value) + '"';
- if (this.m_oLstChoices.options[i].selected == true)
- {
- sURLValues += ' selected="true" />';
- }
- else
- {
- sURLValues += ' selected="false" />';
- }
- }
- }
- addSelectChoices(this.m_oSubmit, sURLValues);
- }
- else
- {
-
- for(i = 0; i < this.m_oLstChoices.options.length; i ++)
- {
- this.m_oLstChoices.options[i].selected = true;
- }
- }
- }
- function CMultipleTextPicker_checkData()
- {
- if ((this.m_bRequired == true) && (this.m_oLstChoices.options.length === 0))
- {
- this.m_bValid = false;
- this.checkFail();
- return false;
- }
- else
- {
- this.m_bValid = true;
- this.checkPass();
- return true;
- }
- }
- function CMultipleTextPicker_resizeList()
- {
- if (this.m_oErrorFeedback)
- {
- if(this.m_oLstChoices.style.tableLayout!='fixed')
- {
- this.m_oLstChoices.style.width='auto';
- }
- if (this.m_oLstChoices.offsetWidth < 200)
- {
- this.m_oLstChoices.style.width='200px';
- }
- this.m_oErrorFeedback.style.width = this.m_oLstChoices.offsetWidth + 'px';
- }
- }
- function CMultipleTextPicker_checkInsertRemove()
- {
- if (this.m_oInsertButton)
- {
- if ((this.m_oTextPicker.getValid() == true) && this.m_oTextPicker.hasValue())
- {
- this.m_oInsertButton.disabled = false;
- }
- else
- {
- this.m_oInsertButton.disabled = true;
- this.m_oInsertButton.className = "clsInsertRemoveButton";
- }
- }
- if (this.m_oRemoveButton)
- {
- if (this.m_oLstChoices.selectedIndex == -1)
- {
- this.m_oRemoveButton.disabled = true;
- this.m_oRemoveButton.className = "clsInsertRemoveButton";
- }
- else
- {
- this.m_oRemoveButton.disabled = false;
- }
- }
- }
- function CMultipleTextPicker_add(sDisplayValue, sInsertText)
- {
- this.m_oLstChoices.options[this.m_oLstChoices.options.length] = new Option(sDisplayValue, sInsertText, false, false);
- this.checkData();
- setTimeout("resizeCMultipleTextPickerINSTANCES()",1);
-
- this.checkInsertRemove();
- }
- function CMultipleTextPicker_addNoUpdate(sDisplayValue, sInsertText, sel)
- {
- sDisplayValue = sDecodeU003( sDisplayValue );
- sInsertText = sDecodeU003( sInsertText );
- if (sel == true) {
- this.m_oLstChoices.options[this.m_oLstChoices.options.length] = new Option(sDisplayValue, sInsertText, true, true);
- }
- else {
- this.m_oLstChoices.options[this.m_oLstChoices.options.length] = new Option(sDisplayValue, sInsertText, false, false);
- }
- }
- function CMultipleTextPicker_update()
- {
- this.checkData();
- setTimeout("resizeCMultipleTextPickerINSTANCES()",1);
-
- this.checkInsertRemove();
- }
- CMultipleTextPicker.prototype.selectAll = CMultipleTextPicker_selectAll;
- CMultipleTextPicker.prototype.deSelectAll = CMultipleTextPicker_deSelectAll;
- CMultipleTextPicker.prototype.insert = CMultipleTextPicker_insert;
- CMultipleTextPicker.prototype.remove = CMultipleTextPicker_remove;
- CMultipleTextPicker.prototype.preProcess = CMultipleTextPicker_preProcess;
- CMultipleTextPicker.prototype.checkData = CMultipleTextPicker_checkData;
- CMultipleTextPicker.prototype.resizeList = CMultipleTextPicker_resizeList;
- CMultipleTextPicker.prototype.checkInsertRemove = CMultipleTextPicker_checkInsertRemove;
- CMultipleTextPicker.prototype.add = CMultipleTextPicker_add;
- CMultipleTextPicker.prototype.addNoUpdate = CMultipleTextPicker_addNoUpdate;
- CMultipleTextPicker.prototype.update = CMultipleTextPicker_update;
- function resizeCMultipleTextPickerINSTANCES() {
- if (typeof CMultipleTextPicker_INSTANCES == K_PRMT_sOBJECT && CMultipleTextPicker_INSTANCES.length) {
- for (var i = 0; i < CMultipleTextPicker_INSTANCES.length; i++) {
- CMultipleTextPicker_INSTANCES[i].resizeList();
- }
- }
- }
|