/* *+------------------------------------------------------------------------+ *| Licensed Materials - Property of IBM *| BI and PM: prmt *| (C) Copyright IBM Corp. 2002, 2011 *| *| US Government Users Restricted Rights - Use, duplication or *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *| *+------------------------------------------------------------------------+ */ /* CMultipleTextPicker.js This script is used to provide interactivity for the multiple select textBox prompt component. This component is a combination of the date picker and a list box. */ //Constructor to create a checkboxlist component // oTextPicker: the text picker control // oLstChoices: the name of the select form control // oSubmit: the form control to submit selections to the server // bRequired: is this a required field true/false // sSubmitType: submit this as a standard form, or as XML // oErrorFeedback: object used to provide validation feedback // oSizer: image object used to control the minimum size of the list // oInsertButton: the insert button // oRemoveButton: the remove button 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(); //resize the list if necessary if(oSizer) { this.m_oSizer = oSizer; this.m_oLstChoices.style.width='auto'; setTimeout("resizeCMultipleTextPickerINSTANCES()",1); } //check the states of the insert and remove buttons this.checkInsertRemove(); } CMultipleTextPicker.prototype = new CPromptControl(); //select all items function CMultipleTextPicker_selectAll() { for (var i=0; i < this.m_oLstChoices.options.length; i++) { this.m_oLstChoices.options[i].selected = true; } //check the states of the insert and remove buttons this.checkInsertRemove(); } //remove selection from all items function CMultipleTextPicker_deSelectAll() { for (var i=0; i < this.m_oLstChoices.options.length; i++) { this.m_oLstChoices.options[i].selected = false; } //check the states of the insert and remove buttons this.checkInsertRemove(); } //insert values from the picker control function CMultipleTextPicker_insert() { var sInsertText = this.m_oTextPicker.sGetValue(); var sDisplayValue = this.m_oTextPicker.sGetFormatValue(); if (sInsertText) { //determine whether this is a single value or multiple values 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); } //clear the choices from the text box this.m_oTextPicker.clear(); } this.checkData(); setTimeout("resizeCMultipleTextPickerINSTANCES()",1); //check the states of the insert and remove buttons this.checkInsertRemove(); } //remove selections from the list of choices function CMultipleTextPicker_remove() { this.removeSelectedChoices(); setTimeout("resizeCMultipleTextPickerINSTANCES()",1); //check the states of the insert and remove buttons this.checkInsertRemove(); } CMultipleTextPicker.prototype = new CPromptControl(); //perform any special processing for the server. //this function will wrap all list items in XML. //This is required for cases where the unselected items need //to be submitted too. function CMultipleTextPicker_preProcess() { var i=0; if (this.m_sSubmitType == K_PRMT_sXML) { //convert the data to XML and submit var sURLValues = K_PRMT_sEMPTY; if (this.m_oLstChoices.options.length > 0) { for(i = 0; i < this.m_oLstChoices.options.length; i ++) { sURLValues += '