/* *+------------------------------------------------------------------------+ *| 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. *| *+------------------------------------------------------------------------+ */ /* CMultipleIntervalPicker.js This script is used to provide interactivity for the multiple select selectInterval prompt component. This component is a combination of the interval picker and a list box. */ //Constructor to create a checkboxlist component // oIntervalPicker: the interval 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 function CMultipleIntervalPicker(oIntervalPicker, oLstChoices, oSubmit, bRequired, sSubmitType, oErrorFeedback, oSizer, oInsertButton, oRemoveButton, sCVId) { this.setCVId(sCVId); this.m_oIntervalPicker = oIntervalPicker; 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.resizeList(); } //check the states of the insert and remove buttons this.checkInsertRemove(); } CMultipleIntervalPicker.prototype = new CPromptControl(); //add an item to the list without any checking by the control //this method provides an efficient way to add items, but //the update() method should be called to clean up the control //when finished adding function CMultipleIntervalPicker_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); } } //clean up the control function CMultipleIntervalPicker_update() { this.checkData(); this.resizeList(); this.resizeList(); //check the states of the insert and remove buttons this.checkInsertRemove(); } //select all items function CMultipleIntervalPicker_selectAll() { for (var i=0; i < this.m_oLstChoices.options.length; i++) { this.m_oLstChoices.options[i].selected = true; } this.checkData(); //check the states of the insert and remove buttons this.checkInsertRemove(); } //remove selection from all items function CMultipleIntervalPicker_deSelectAll() { for (var i=0; i < this.m_oLstChoices.options.length; i++) { this.m_oLstChoices.options[i].selected = false; } this.checkData(); //check the states of the insert and remove buttons this.checkInsertRemove(); } //insert values from the picker control function CMultipleIntervalPicker_insert() { var sInsertInterval = this.m_oIntervalPicker.sGetInterval(); var sInsertFormatInterval = this.m_oIntervalPicker.sGetFormatInterval(); this.m_oLstChoices.options[this.m_oLstChoices.options.length] = new Option(sInsertFormatInterval, sInsertInterval, false, false); this.checkData(); this.resizeList(); this.resizeList(); } //remove selections from the list of choices function CMultipleIntervalPicker_remove() { this.removeSelectedChoices(); } //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 CMultipleIntervalPicker_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 += '