/** * formView.js */ //hideToolbar is defined in formView.html, this is for other html file call this js file. var hideToolbar; var isShippoCancel = false; var DEFAULT_LU_MAX_ROWS = 500; var auditTriggerInfo = {}; var isMobileChrome = (/Mobile/i.test(navigator.userAgent) && /Chrome/i.test(navigator.userAgent)) || (/Mozilla\/5.0/.test(navigator.userAgent) && ((/Android/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent)) || /HeyTapBrowser/.test(navigator.userAgent))); //var indexOfArrIgnoreCase = (arr, value) => arr.findIndex(item => value.toLowerCase() === item.toLowerCase()); not support in ie if(hideToolbar == undefined) { hideToolbar = false; } if(typeof formLinkDeviceMode == 'undefined') { formLinkDeviceMode = false; } var actionClickInfo = undefined; if(authNS && authNS.currentUser && authNS.currentUser.dateFormat == 'dd/MM/yyyy'){ DEFAULT_DATE_FORMAT = "dd/mm/yyyy"; }else if(waDateFormat == 'dd/MM/yyyy'){ DEFAULT_DATE_FORMAT = "dd/mm/yyyy"; } var shippoApiKeyDebug = false; // CO-3906 var DEFAULT_DATE_TIME_FORMAT_CAL_12H = DEFAULT_DATE_FORMAT + ' ' + DEFAULT_TIME_FORMAT_12H; var DEFAULT_DATE_TIME_FORMAT_CAL_24H = DEFAULT_DATE_FORMAT + ' ' + DEFAULT_TIME_FORMAT_24H; var DEFAULT_TIME_FORMAT_CAL_12H = DEFAULT_TIME_FORMAT_12H; var DEFAULT_TIME_FORMAT_CAL_24H = DEFAULT_TIME_FORMAT_24H; if(authNS && authNS.currentUser && authNS.currentUser.timeFormat == 'hh:mm aa'){ DEFAULT_TIME_FORMAT_12H = "hh:MM TT"; DEFAULT_TIME_FORMAT_24H = "HH:MM"; }else if(waTimeFormat == 'hh:mm aa'){ DEFAULT_TIME_FORMAT_12H = "hh:MM TT"; DEFAULT_TIME_FORMAT_24H = "HH:MM"; } DEFAULT_DATE_TIME_FORMAT_12H = DEFAULT_DATE_FORMAT + ' ' + DEFAULT_TIME_FORMAT_12H; DEFAULT_DATE_TIME_FORMAT_24H = DEFAULT_DATE_FORMAT + ' ' + DEFAULT_TIME_FORMAT_24H; var DEFAULT_TIME_FORMAT_24H_HHMMSS = 'hh:mm:ss'; var DEFAULT_TIME_FORMAT_24H_HHMM = 'hh:mm'; function isRunEvent(event){ if(event.type == "beforeinput"){ if(!isMobileChrome){ return false; } if(event.originalEvent){ if(event.originalEvent.data != null){ var keyCode = ('' + event.originalEvent.data).charCodeAt(0); event.which = keyCode; event.keyCode = keyCode; event.charCode = keyCode; }else{ return false; } } }else if(event.type != "beforeinput" && isMobileChrome){ return false; } return true; } function addToRetrieveControlDataChange(ctrlPropreties, parentProperties){ if(!fvDataNS.isRetrieve || !ctrlPropreties.calculateExpression){ return; } if(ctrlPropreties.calculateExpression.hasNickNameFunction === true || ctrlPropreties.calculateExpression.hasMobileIdFunction === true || ctrlPropreties.calculateExpression.hasMobileEmailFunction === true){ if(!fvDataNS.currentForm.retrieveControlDataChange){ fvDataNS.currentForm.retrieveControlDataChange = []; } fvDataNS.currentForm.retrieveControlDataChange.push({type: 'calculate', ctrlPropreties: ctrlPropreties, parentProperties: parentProperties}); } } function indexOfArrIgnoreCase(arr, value){ if(arr == undefined || value == undefined){ return -1; } for(var i=0; i 0){ var arr = url.split('/resourceFile?blobKey='); arr[0] = ''; url = arr.join('/resourceFile?blobKey='); var w = window.open(url,name,'width=600,height=400'); var arr2 = url.split('blobName='); if(arr2.length==2){ setTimeout(function(event){ w.document.title = arr2[1]; },1000); } w.focus(); }else{ var w = window.open(url,name,'width=600,height=400'); w.focus(); } /*var linkDown = $('Download Here'); linkDown.attr('href', url); $('body').append(linkDown); linkDown[0].click(); linkDown.remove();*/ } catch(e){} } function setTableRowNotEmptyClass($control, ctrlPropreties){ var $parentRow = $($control.parents('tr')[0]); if(ctrlPropreties.autoAction === false && $parentRow.hasClass('last-row')){ ctrlPropreties.autoAction = true; //if(ctrlPropreties.val != null && ctrlPropreties.val != '' && ctrlPropreties.defaultValue != ctrlPropreties.val){ $parentRow.addClass('showRow'); var ctrlTable = $($control.parents('.ctrlTable.auto-add-new-row')[0]); if(ctrlTable.length>0){ ctrlTable.trigger('table_add_empty_row'); } //} }else{ ctrlPropreties.autoAction = true; } } function clearLuCondition(control, $parent){ if(isVersion(VERSION_DISPLAY_FIRST_MATCHING) && $parent.isDisplayFirstMatching != undefined && $parent.isDisplayFirstMatching.value == true){ if($parent.isAllowEdit && $parent.isAllowEdit.value == true){ //Change in CO-5172: Meade: Lookup Condition NOT Working with //control.find('.controlData input, .controlData textarea').trigger('changeDataSource', [undefined, true]); } } } function validateLKDisabled($parent, firstMatching, ctrlDisabled){ var isAllowEdit = false; var useMatching = false; if(isVersion(VERSION_DISPLAY_FIRST_MATCHING)){ try{ if($parent.isDisplayFirstMatching.value == true){ useMatching = true; isAllowEdit = $parent.isAllowEdit.value; } } catch(e){} try{ if($parent.isShowListMatching.value == true){ useMatching = true; isAllowEdit = $parent.isAllowEdit2.value; } } catch(e){} } var disableFlg = false; if(useMatching){ if(!isAllowEdit && firstMatching){ disableFlg = true; } } else{ disableFlg = ctrlDisabled; } return disableFlg; } function validateLKFirstMatching($parent, arrLookup){ var isDisplayFirstMatching = undefined; try{ if(isVersion(VERSION_DISPLAY_FIRST_MATCHING) && $parent.isDisplayFirstMatching != undefined && $parent.isDisplayFirstMatching.value == true){ isDisplayFirstMatching = true; } // CO-2741 if(isVersion(VERSION_DISPLAY_LIST_MATCHING)){ var arrMatch = []; if(arrLookup != undefined){ arrMatch = arrLookup; } else if(autoCompleteArray != undefined && autoCompleteArray[$parent.name.value] != undefined && autoCompleteArray[$parent.name.value][0] != undefined){ arrMatch = autoCompleteArray[$parent.name.value]; } if($parent.isShowListMatching != undefined && $parent.isShowListMatching.value == true){ if(arrMatch.length > 1){ isDisplayFirstMatching = false; } else{ isDisplayFirstMatching = true; } } } } catch(e){} return isDisplayFirstMatching; } function setFirstMatching(ctrl, $parent, autoCompleteArray){ var arrMatch = []; if(autoCompleteArray != undefined && autoCompleteArray[$parent.name.value] != undefined && autoCompleteArray[$parent.name.value][0] != undefined){ arrMatch = autoCompleteArray[$parent.name.value]; } var isDisplayFirstMatching = validateLKFirstMatching($parent, arrMatch); if(isDisplayFirstMatching != undefined && true == isDisplayFirstMatching){ if(arrMatch.length > 0){ ctrl.val(autoCompleteArray[$parent.name.value][0]).change(); return true; }else{ // co-3218 ctrl.val('').change(); } } else{ ctrl.val('').change(); } /* co-2719 else{ if(!fvDataNS.isLoading){ ctrl.val(''); } }*/ return false; } // ===================== CO-4022 function calculateHideIfConds(ctrlPropreties){ var resultFlg = false; try{ var ctrlType = ctrlPropreties.ctrlType; var proVal = ctrlPropreties.val; if(ctrlPropreties.hideIfCmpVal == undefined){ if(CONST_CTRL_TYPE_INPUTACTION === ctrlType && 'click' == proVal){ return true; } else if(CONST_CTRL_TYPE_INPUTSELECTMANY === ctrlType && proVal != undefined && proVal != ''){ // has value return true; } else{ return false; } } var condObj = ctrlPropreties.hideIfCmpVal.value; var condVal = condObj.val; var operator = condObj.condition; var operation1 = ''; var operation2 = ''; if(proVal == undefined){ proVal = ''; } if(condVal == undefined){ condVal = ''; } if(CONST_CTRL_TYPE_INPUTDATE == ctrlType || CONST_CTRL_TYPE_INPUTCALCULATE == ctrlType){ var kind = ctrlPropreties.kind || CONST_VALUE_DATE_SPACE_TIME; if(kind == CONST_VALUE_DATE){ if(proVal != ''){ var date = parseDateTFormat(proVal, CONST_VALUE_DATE); proVal = date.getTime(); } if(condVal != ''){ var date2 = parseDateTFormat(condVal, CONST_VALUE_DATE); condVal = date2.getTime(); } }else if(kind == CONST_VALUE_TIME){ if(proVal != ''){ var date = parseDateTFormat(proVal, CONST_VALUE_TIME); proVal = date.getTime(); } if(condVal != ''){ var date2 = parseDateTFormat(condVal, CONST_VALUE_TIME); condVal = date2.getTime(); } }else if(kind == CONST_VALUE_DATE_SPACE_TIME){ if(proVal != ''){ var date = parseDateTFormat(proVal, CONST_VALUE_DATE_SPACE_TIME); proVal = date.getTime(); } if(condVal != ''){ var date2 = parseDateTFormat(condVal, CONST_VALUE_DATE_SPACE_TIME); condVal = date2.getTime(); } } else if(kind == CONST_CTRL_KIND_NUMBER){ if(proVal != ''){ proVal = parseFloat(proVal); } if(condVal != ''){ condVal = parseFloat(condVal); } } } else if(CONST_CTRL_TYPE_INPUT_NUMERIC == ctrlType || CONST_CTRL_TYPE_INPUTCOUNTER == ctrlType || CONST_CTRL_TYPE_INPUTTRENDS == ctrlType || CONST_CTRL_TYPE_INPUTSCORESUMMARY == ctrlType){ if(proVal != ''){ proVal = parseFloat(proVal); } if(condVal != ''){ condVal = parseFloat(condVal); } } else if(CONST_CTRL_TYPE_INPUTSELECTMANY == ctrlType){ // TODO } if('equal' === operator){ resultFlg = (proVal == condVal); } else if('not_equal' === operator){ resultFlg = (proVal != condVal); } else if('is_empty' === operator){ resultFlg = (proVal == ''); } else if('not_is_empty' === operator){ resultFlg = (proVal != ''); } else if('less_than' === operator){ resultFlg = (proVal < condVal); } else if('less_than_or_equal' === operator){ resultFlg = (proVal <= condVal); } else if('greater_than' === operator){ resultFlg = (proVal > condVal); } else if('greater_than_or_equal' === operator){ resultFlg = (proVal >= condVal); } } catch(e){ } return resultFlg; } function executeCalculateHideIfConds(ctrlPropreties){ try{ if(ctrlPropreties.hideIfFields && ctrlPropreties.hideIfFields.value.length > 0){ var isHideIfCond = calculateHideIfConds(ctrlPropreties); if(!fvDataNS.hideIfHiddenMap){ fvDataNS.hideIfHiddenMap = {}; } _.each(ctrlPropreties.hideIfFields.value, function(field){ var ctrlIdMaps = fvDataNS.ctrlIdMap[field.text.val]; _.each(ctrlIdMaps, function(ctrl){ var tmpCtrlPropreties = fvDataNS.dataArray[ctrl]; if (tmpCtrlPropreties) { if(!fvDataNS.hideIfHiddenMap[tmpCtrlPropreties.classPath]){ fvDataNS.hideIfHiddenMap[tmpCtrlPropreties.classPath] = []; } if (tmpCtrlPropreties.parentName == ctrlPropreties.parentName) { if (tmpCtrlPropreties.classPath.indexOf(ctrlPropreties.parrentProperties + ' ') == 0) { if(isHideIfCond == false){ const index = fvDataNS.hideIfHiddenMap[tmpCtrlPropreties.classPath].indexOf(ctrlPropreties.classPath); if(index>=0){ fvDataNS.hideIfHiddenMap[tmpCtrlPropreties.classPath].splice(index, 1); } if(fvDataNS.hideIfHiddenMap[tmpCtrlPropreties.classPath].length == 0){ tmpCtrlPropreties.isHideIf = isHideIfCond; } }else{ tmpCtrlPropreties.isHideIf = isHideIfCond; fvDataNS.hideIfHiddenMap[tmpCtrlPropreties.classPath].push(ctrlPropreties.classPath); } } } else { if(isHideIfCond == false){ const index = fvDataNS.hideIfHiddenMap[tmpCtrlPropreties.classPath].indexOf(ctrlPropreties.classPath); if(index>=0){ fvDataNS.hideIfHiddenMap[tmpCtrlPropreties.classPath].splice(index, 1); } if(fvDataNS.hideIfHiddenMap[tmpCtrlPropreties.classPath].length == 0){ tmpCtrlPropreties.isHideIf = isHideIfCond; } }else{ tmpCtrlPropreties.isHideIf = isHideIfCond; fvDataNS.hideIfHiddenMap[tmpCtrlPropreties.classPath].push(ctrlPropreties.classPath); } } } }); }); } } catch(e){} } // ============================ function executeCalculateRelevanceConds(ctrlPropreties){ if(ctrlPropreties.relevancecondsExpression != undefined && ctrlPropreties.relevancecondsExpression != '' && ctrlPropreties.relevancecondsExpression.relevanceCondString != undefined && ctrlPropreties.relevancecondsExpression.relevanceCondString != ''){ var relevanceValue = calculateRelevanceConds(ctrlPropreties.relevancecondsExpression, ctrlPropreties, fvDataNS.inputData); var isCtrlHiddenTmp = ctrlPropreties.isCtrlHidden; if(relevanceValue){ ctrlPropreties.isCtrlHidden = false; }else{ ctrlPropreties.isCtrlHidden = true; } if(isCtrlHiddenTmp != ctrlPropreties.isCtrlHidden){ ctrlPropreties.isCtrlHiddenChanged = true; }else{ ctrlPropreties.isCtrlHiddenChanged = false; } if(ctrlPropreties.ctrlType == CONST_CTRL_TYPE_CTRLTABLE && ctrlPropreties.classPath.endsWith('_loop_1')){ var parentProperties = fvDataNS.dataArray[ctrlPropreties.parrentProperties + ' ' + ctrlPropreties.name]; if(parentProperties){ parentProperties.isCtrlHidden = ctrlPropreties.isCtrlHidden; parentProperties.isCtrlHiddenChanged = ctrlPropreties.isCtrlHiddenChanged; } } return true; } return false; } function executeCalculateReadOnlyIfConds(ctrlPropreties){ if(ctrlPropreties.readOnlyIfcondsExpression != undefined && ctrlPropreties.readOnlyIfcondsExpression != '' && ctrlPropreties.readOnlyIfcondsExpression.relevanceCondString != undefined && ctrlPropreties.readOnlyIfcondsExpression.relevanceCondString != ''){ var readOnlyIfValue = culateReadOnlyIfConds(ctrlPropreties.readOnlyIfcondsExpression, ctrlPropreties, fvDataNS.inputData); if(readOnlyIfValue){ ctrlPropreties.isCtrlReadOnly = true; }else{ ctrlPropreties.isCtrlReadOnly = false; } return true; } return false; } function setControlSecurityOption($parent, $control){ if(isVersion(VERSION_TEXT_SECURITY) && $parent.encryptField && $parent.encryptField.value){ if(!isTabletPreview){ if(isEnableWhenUserProperty(CONST_FIELDENCRYPTION + CONST_DOUBLE_DOLLAR + CONST_VALUE_TRUE_STR)){ $control.addClass(CONST_CSS_CLASS_SECURITY); } }else{ var currentUser = getParent().authNS.currentUser; if(currentUser){ authNS.currentUser[CONST_ADVANCED_SECURITY] = currentUser[CONST_ADVANCED_SECURITY]; authNS.currentUser[CONST_FIELDENCRYPTION] = currentUser[CONST_FIELDENCRYPTION]; } if(isEnableWhenUserProperty(CONST_FIELDENCRYPTION + CONST_DOUBLE_DOLLAR + CONST_VALUE_TRUE_STR)){ $control.addClass(CONST_CSS_CLASS_SECURITY); } } } } /** * Get actual current []Border around heading of control */ function getActualBorderAroundHeading4WA(properties) { // Get appearance information var apperance = LABEL_CONSTANTS_VALUE_OPTION_BUILD_FORM_APPEARANCE_DEFAULT; if (properties.apperance !== undefined) { apperance = properties.apperance.value; } if (apperance === LABEL_CONSTANTS_VALUE_OPTION_BUILD_FORM_APPEARANCE_CUSTOM) { if (properties.shadedHeadings !== undefined && properties.shadedHeadings.value !== undefined) { var sHds = properties.shadedHeadings.value; if (sHds.isBorderAroundHeading === true) { return true; } } } // Process by Form Settings else { if (glbBuildFormSettingsWA.isBorderAroundHeading === true) { return true; } } // Default is not border around headings return false; } /** * Process binding event for IfThenElse features in each controls * @param $parent * @param ctrlPropreties */ function processBindingIfThenElseActionEvent($parent, ctrlPropreties) { // Apply If .. Then .. Else in WebApps GUI if (isVersion(VERSION_IF_THEN_ELSE)) { // Check if this question has using the [x]If Then Else if ($parent.isShowITE && $parent.isShowITE.value === true && $parent.iteConditions && $parent.iteConditions.value) { addToCtrlIdRefForIfThenElse($parent.iteConditions.value, ctrlPropreties.classPath); ctrlPropreties.ifThenElseExpression = ifThenElseToExpression(ctrlPropreties.id, $parent.iteConditions); } } } /** * Process binding event for SkipIf features in each controls * @param $parent * @param ctrlPropreties */ function processBindingSkipIfActionEvent($parent, ctrlPropreties) { // Apply skip if in WebApps GUI if (isVersion(VERSION_SKIP_IF)) { // Check if this question has using the [x]Skip if if ($parent.isShowSkipIf && $parent.isShowSkipIf.value === true && $parent.skipIfConditions && $parent.skipIfConditions.value) { addToCtrlIdRefForSkipIf($parent.skipIfConditions.value, ctrlPropreties.classPath, ctrlPropreties.id); ctrlPropreties.skipIfExpression = skipIfToExpression(ctrlPropreties.id, $parent.skipIfConditions); ctrlPropreties.isShowSkipIf = true; } } } function processBindingDestinationActionEvent($parent, ctrlPropreties) { if ($parent.destinationdataconds && $parent.destinationdataconds.value) { addToCtrlIdRefForDestination($parent.destinationdataconds.value, ctrlPropreties.classPath, ctrlPropreties.id); } } function setAutonumTrigger(properties, control, ctrlPropreties){ try{ if(fvDataNS.autonumDevice && fvDataNS.autonumDevice[properties.autoNumberTriggerType.value] && fvDataNS.autonumDevice[properties.autoNumberTriggerType.value][ctrlPropreties.name]){ ctrlPropreties.isValueChange = true; ctrlPropreties.val = fvDataNS.autonumDevice[properties.autoNumberTriggerType.value][ctrlPropreties.name]; control.find('.controlData input').val(ctrlPropreties.val); //fvDataNS.isExecuteControlChangeRunning = false; executeControlChange(ctrlPropreties.classPath); } } catch(e){} } function initAutonumTrigger(properties, control, ctrlPropreties){ if(properties.autoNumberType && properties.autoNumberType.value == 'OnDevice' && properties.autoNumberTriggerType != undefined && properties.autoNumberTriggerType.value){ var autoNumTrigger = properties.autoNumberTriggerType.value; ctrlPropreties.autoNumTrigger = autoNumTrigger; if(fvDataNS.autoStampTriggerMap[autoNumTrigger] == undefined){ fvDataNS.autoStampTriggerMap[autoNumTrigger] = {}; } if(autoNumTrigger == '2'){ // Trigger when a specified question is answered for the first time if(properties.autoNumTriggerQues != undefined && properties.autoNumTriggerQues.value){ if(fvDataNS.autoStampTriggerMap[autoNumTrigger][properties.autoNumTriggerQues.value] == undefined){ fvDataNS.autoStampTriggerMap[autoNumTrigger][properties.autoNumTriggerQues.value] = {}; } if(!fvDataNS.isLoading){ fvDataNS.autoStampTriggerMap[autoNumTrigger][properties.autoNumTriggerQues.value][ctrlPropreties.classPath] = false; }else{ var itemProperties = getPropertiesByID(properties.autoNumTriggerQues.value); if(itemProperties != undefined){ if(isEditLoading() && (itemProperties.val || '') != ''){ fvDataNS.autoStampTriggerMap[autoNumTrigger][properties.autoNumTriggerQues.value][ctrlPropreties.classPath] = true; }else{ fvDataNS.autoStampTriggerMap[autoNumTrigger][properties.autoNumTriggerQues.value][ctrlPropreties.classPath] = false; } }else{ fvDataNS.autoStampTriggerMap[autoNumTrigger][properties.autoNumTriggerQues.value][ctrlPropreties.classPath] = false; } } } } else if(autoNumTrigger == '4'){ // Trigger when a specified page is displayed for the first time if(properties.autoNumTriggerPages != undefined && properties.autoNumTriggerPages.value){ if(fvDataNS.autoStampTriggerMap[autoNumTrigger][properties.autoNumTriggerPages.value] == undefined){ fvDataNS.autoStampTriggerMap[autoNumTrigger][properties.autoNumTriggerPages.value] = {}; } fvDataNS.autoStampTriggerMap[autoNumTrigger][properties.autoNumTriggerPages.value][ctrlPropreties.classPath] = false; } } else if(autoNumTrigger == '8'){ // Trigger when the form is opened for the first var isTrigger = true; if(fvDataNS.incomplete){ isTrigger = false; } if(fvDataNS.currentForm.editRecordData){ isTrigger = false; } if(ctrlPropreties.skipByCtrls != undefined && ctrlPropreties.skipByCtrls.length > 0){ isTrigger = false; }else{ if(ctrlPropreties.isCtrlHidden){ isTrigger = false; } } if(control.parents('.hideControl').length > 0){ isTrigger = false; } if(getValueOrEmpty(ctrlPropreties.val) != '' && !ctrlPropreties.isAllowEdit){ isTrigger = false; } if(isTrigger){ //control.find('.controlData input').trigger('setAutoStamp'); fvDataNS.autoStampTriggerMap[autoNumTrigger][ctrlPropreties.classPath] = false; } } else if(autoNumTrigger == '16'){ // Trigger when the form is saved as complete ctrlPropreties.autoStamp = true; fvDataNS.autoStampTriggerMap[autoNumTrigger][ctrlPropreties.classPath] = false; } } } function initRetrieveAutorun(properties, control, ctrlPropreties){ if(//ctrlPropreties.isModifyOnly != undefined //&& ctrlPropreties.isModifyOnly == false // not Modify only ctrlPropreties.autoActionStampTriggerRetrieve != undefined && (ctrlPropreties.autoActionStampTriggerRetrieve == '2' // specific question || ctrlPropreties.autoActionStampTriggerRetrieve == '8') ){ if(true == ctrlPropreties.hideRetrieveButtonAuto){ //control.addClass('hideOnMobileApp'); control.addClass('hideRetrieveButtonAuto'); } var retrieveTrigger = ctrlPropreties.autoActionStampTriggerRetrieve; ctrlPropreties.retrieveTrigger = retrieveTrigger; if(fvDataNS.autoStampTriggerMap[retrieveTrigger] == undefined){ fvDataNS.autoStampTriggerMap[retrieveTrigger] = {}; } if(retrieveTrigger == '2'){ // Trigger when a specified question is answered for the first time if(ctrlPropreties.autoActionStampQuestionTriggerRetrieve != undefined){ if(fvDataNS.autoStampTriggerMap[retrieveTrigger][ctrlPropreties.autoActionStampQuestionTriggerRetrieve] == undefined){ fvDataNS.autoStampTriggerMap[retrieveTrigger][ctrlPropreties.autoActionStampQuestionTriggerRetrieve] = {}; } if(!fvDataNS.isLoading){ fvDataNS.autoStampTriggerMap[retrieveTrigger][ctrlPropreties.autoActionStampQuestionTriggerRetrieve][ctrlPropreties.classPath] = false; }else{ var itemProperties = getPropertiesByID(ctrlPropreties.autoActionStampQuestionTriggerRetrieve); if(itemProperties != undefined){ if(isEditLoading() && (itemProperties.val || '') != ''){ fvDataNS.autoStampTriggerMap[retrieveTrigger][ctrlPropreties.autoActionStampQuestionTriggerRetrieve][ctrlPropreties.classPath] = true; }else{ fvDataNS.autoStampTriggerMap[retrieveTrigger][ctrlPropreties.autoActionStampQuestionTriggerRetrieve][ctrlPropreties.classPath] = false; } }else{ fvDataNS.autoStampTriggerMap[retrieveTrigger][ctrlPropreties.autoActionStampQuestionTriggerRetrieve][ctrlPropreties.classPath] = false; } } } } else if(retrieveTrigger == '8'){ // Trigger when the form is opened for the first var isTrigger = true; if(fvDataNS.incomplete){ isTrigger = false; } if(fvDataNS.currentForm.editRecordData){ isTrigger = false; } if(ctrlPropreties.skipByCtrls != undefined && ctrlPropreties.skipByCtrls.length > 0){ isTrigger = false; }else{ if(ctrlPropreties.isCtrlHidden){ isTrigger = false; } } if(control.parents('.hideControl').length > 0){ isTrigger = false; } if(getValueOrEmpty(ctrlPropreties.val) != '' && !ctrlPropreties.isAllowEdit){ isTrigger = false; } if('autoRun' != ctrlPropreties.retrieveKind) { isTrigger = false; } if(isTrigger){ //$(control.find('.controlData .actionBtn')[0]).trigger('click'); //fvDataNS.autoStampTriggerMap[retrieveTrigger][ctrlPropreties.classPath] = false; if(!fvDataNS.autoStampTriggerMap) { fvDataNS.autoStampTriggerMap = {}; fvDataNS.autoStampTriggerRunnedMap = {}; } if(!fvDataNS.autoStampTriggerMap[retrieveTrigger]) { fvDataNS.autoStampTriggerMap[retrieveTrigger] = {}; } if(!fvDataNS.autoStampTriggerMap[retrieveTrigger]['' + ctrlPropreties.id]) { fvDataNS.autoStampTriggerMap[retrieveTrigger]['' + ctrlPropreties.id] = {}; } fvDataNS.autoStampTriggerMap[retrieveTrigger]['' + ctrlPropreties.id][ctrlPropreties.classPath] = true; fvDataNS.autoStampTriggerMap[retrieveTrigger]['' + ctrlPropreties.id]['retrieveTrigger'] = true; } } } if(//ctrlPropreties.isModifyOnly != undefined //&& ctrlPropreties.isModifyOnly == false // not Modify only ctrlPropreties.autoActionStampTriggerModify != undefined && (ctrlPropreties.autoActionStampTriggerModify == '2' // specific question || ctrlPropreties.autoActionStampTriggerModify == '8')// open form ){ // if(true == ctrlPropreties.hideRetrieveButtonAuto){ // //control.addClass('hideOnMobileApp'); // control.addClass('hideRetrieveButtonAuto'); // } var modifyTrigger = ctrlPropreties.autoActionStampTriggerModify; ctrlPropreties.modifyTrigger = modifyTrigger; if(fvDataNS.autoStampTriggerMap[modifyTrigger] == undefined){ fvDataNS.autoStampTriggerMap[modifyTrigger] = {}; } if(modifyTrigger == '2'){ // Trigger when a specified question is answered for the first time if(ctrlPropreties.autoActionStampQuestionTriggerModify != undefined){ if(fvDataNS.autoStampTriggerMap[modifyTrigger][ctrlPropreties.autoActionStampQuestionTriggerModify] == undefined){ fvDataNS.autoStampTriggerMap[modifyTrigger][ctrlPropreties.autoActionStampQuestionTriggerModify] = {}; } if(!fvDataNS.isLoading){ fvDataNS.autoStampTriggerMap[modifyTrigger][ctrlPropreties.autoActionStampQuestionTriggerModify][ctrlPropreties.classPath] = false; }else{ var itemProperties = getPropertiesByID(ctrlPropreties.autoActionStampQuestionTriggerModify); if(itemProperties != undefined){ if(isEditLoading() && (itemProperties.val || '') != ''){ fvDataNS.autoStampTriggerMap[modifyTrigger][ctrlPropreties.autoActionStampQuestionTriggerModify][ctrlPropreties.classPath] = true; }else{ fvDataNS.autoStampTriggerMap[modifyTrigger][ctrlPropreties.autoActionStampQuestionTriggerModify][ctrlPropreties.classPath] = false; } }else{ fvDataNS.autoStampTriggerMap[modifyTrigger][ctrlPropreties.autoActionStampQuestionTriggerModify][ctrlPropreties.classPath] = false; } } } } else if(modifyTrigger == '8'){ // Trigger when the form is opened for the first var isTrigger = true; if(fvDataNS.incomplete){ isTrigger = false; } if(fvDataNS.currentForm.editRecordData){ isTrigger = false; } if(ctrlPropreties.skipByCtrls != undefined && ctrlPropreties.skipByCtrls.length > 0){ isTrigger = false; }else{ if(ctrlPropreties.isCtrlHidden){ isTrigger = false; } } if(control.parents('.hideControl').length > 0){ isTrigger = false; } // if(getValueOrEmpty(ctrlPropreties.val) != '' && !ctrlPropreties.isAllowEdit){ // isTrigger = false; // } if('autoRun' != ctrlPropreties.modifyKind) { isTrigger = false; } if(isTrigger){ //$(control.find('.controlData .actionBtn')[0]).trigger('click', {isModify:true}); //fvDataNS.autoStampTriggerMap[modifyTrigger][ctrlPropreties.classPath] = false; if(!fvDataNS.autoStampTriggerMap) { fvDataNS.autoStampTriggerMap = {}; fvDataNS.autoStampTriggerRunnedMap = {}; } if(!fvDataNS.autoStampTriggerMap[modifyTrigger]) { fvDataNS.autoStampTriggerMap[modifyTrigger] = {}; } if(!fvDataNS.autoStampTriggerMap[modifyTrigger]['' + ctrlPropreties.id]) { fvDataNS.autoStampTriggerMap[modifyTrigger]['' + ctrlPropreties.id] = {}; } fvDataNS.autoStampTriggerMap[modifyTrigger]['' + ctrlPropreties.id][ctrlPropreties.classPath] = true; fvDataNS.autoStampTriggerMap[modifyTrigger]['' + ctrlPropreties.id]['modifyTrigger'] = true; } } } } function initWeekEndingDate(properties, control, ctrlPropreties){ if(!isVersion(VERSION_SET_WEEK_ENDING_DATE)){ return; } if(!properties.isSetWeekEndingDate || properties.isSetWeekEndingDate.value != true){ return; } if(!properties.weekEndingDateType || properties.weekEndingDateType.value != CONST_VALUE_OTHER){ return; } if(!properties.weekEndingDateField || !properties.weekEndingDateField.value || properties.weekEndingDateField.value == ''){ return; } ctrlPropreties.isSetWeekEndingDate = properties.isSetWeekEndingDate.value; ctrlPropreties.weekEndingDateType = properties.weekEndingDateType.value; ctrlPropreties.weekEndingDateField = properties.weekEndingDateField.value; if(fvDataNS.weekEndingDateTriggerMap == undefined){ fvDataNS.weekEndingDateTriggerMap = {}; } if(fvDataNS.weekEndingDateTriggerMap[ctrlPropreties.weekEndingDateField] == undefined){ fvDataNS.weekEndingDateTriggerMap[ctrlPropreties.weekEndingDateField] = {}; } fvDataNS.weekEndingDateTriggerMap[ctrlPropreties.weekEndingDateField][ctrlPropreties.classPath] = true; } function initMonthEndingDate(properties, control, ctrlPropreties){ if(!isVersion(VERSION_SET_MONTH_ENDING_DATE)){ return; } if(!properties.isSetMonthEndingDate || properties.isSetMonthEndingDate.value != true){ return; } if(!properties.monthEndingDateType || properties.monthEndingDateType.value != CONST_VALUE_OTHER){ return; } if(!properties.monthEndingDateField || !properties.monthEndingDateField.value || properties.monthEndingDateField.value == ''){ return; } ctrlPropreties.isSetMonthEndingDate = properties.isSetMonthEndingDate.value; ctrlPropreties.monthEndingDateType = properties.monthEndingDateType.value; ctrlPropreties.monthEndingDateField = properties.monthEndingDateField.value; if(fvDataNS.monthEndingDateTriggerMap == undefined){ fvDataNS.monthEndingDateTriggerMap = {}; } if(fvDataNS.monthEndingDateTriggerMap[ctrlPropreties.monthEndingDateField] == undefined){ fvDataNS.monthEndingDateTriggerMap[ctrlPropreties.monthEndingDateField] = {}; } fvDataNS.monthEndingDateTriggerMap[ctrlPropreties.monthEndingDateField][ctrlPropreties.classPath] = true; } function addToSkipList(ctrlPropreties){ if(isVersion(VERSION_JUMP_WHEN_OPEN)){ if(!fvDataNS.hasSkipConditionArray){ fvDataNS.hasSkipConditionArray = []; } if(!ctrlPropreties){ return; } if(ctrlPropreties.isShowSkipIf || (ctrlPropreties.skipcondsExpression && ctrlPropreties.skipcondsExpression.skipcondsString && ctrlPropreties.skipcondsExpression.skipcondsString != '')){ fvDataNS.hasSkipConditionArray.push(ctrlPropreties.classPath); } } } /*****************************************************************************************************************/ /*Start******************************************load data ctrl***************************************************/ /*****************************************************************************************************************/ // Control not apply remove border answer var CONTROL_NOT_APPLY_REMOVE_BORDER_ANSWER = 'inputPageBreak,group,ctrlTable,ctrlPOD,inputFacingTable,ctrlScoreTable,ctrlGrid,'; // Control for applying : Answer Color for Web forms GUI var CONTROL_APPLY_ANSWER_COLOR_GUI = 'inputText,inputNumeric,inputLocation,inputNumbering,inputDate,inputLocation,inputBarcode,inputEmailReport,inputLookup,inputLFBluetooth,inputCalculate,inputNFC,inputCounter,inputTrends,inputPayment,inputNewPayment,'; function fillDataControlFV($this, ctrlType, config, properties, ctrlPropreties){ $this.data('odkControl-properties', properties); $this.data('odkControl-ctrlPropreties', ctrlPropreties); if(ctrlType == CONST_CTRL_TYPE_SCORESUMMARY){ if(isVersion(VERSION_TOOL_NEW_JUSTIFICATION)){ if(properties.justificationCaption == undefined){ properties.justificationCaption = { value: ctrlPropreties.justificationCaption}; } if(properties.justificationHint == undefined){ properties.justificationHint = { value: ctrlPropreties.justificationHint}; } } } applyJustification($this, properties); // Fix bug 0024941: Shaded headings in "Custom" do not work with Score summary widget. var isScoreSummaryField = false; var $thisObjectScoreSummary = null; var orientationchangeHandle = function(){ if($this.parents('.waDisTable').length > 0 || $this.parents('.sentToEmailBar').length > 0 || $this.parents('.sentToSMSBar').length > 0 || $this.parents('.waDisSendType').length > 0){ // CO-812 fix problem with zoom in/out return; } if(ctrlType == 'inputPageBreak'){ $this.css('width', fvDataNS.ctrlPageWidth + "px"); if(properties.isUtilizingFullScr != undefined && properties.isUtilizingFullScr.value){ if(!$this.find('table').hasClass('dont_resize')){ $this.find('table').css('width', fvDataNS.ctrlPageWidth + "px"); } } }else{ $this.css('width', fvDataNS.ctrlWidth + "px"); if(properties.isUtilizingFullScr != undefined && properties.isUtilizingFullScr.value){ if(!$this.find('table').hasClass('dont_resize')){ $this.find('table').css('width', fvDataNS.ctrlWidth + "px"); } // if(properties.columnsSpaceType && properties.columnsSpaceType.value == '2'){ if(properties.adjustWidthNormal && properties.adjustWidthNormal.value){ if(!$this.find('table').hasClass('dont_resize')){ if(properties.isApplyForScreen && properties.isApplyForScreen.value//table && properties.applyScreenSize && properties.applyScreenSize.value && getParent() && getParent().previewMode && getParent().previewMode.size && parseFloat(properties.applyScreenSize.value) > parseFloat(getParent().previewMode.size) ) { var value = parseFloat(properties.adjustWidth.value); value = Math.round(value * fvDataNS.ctrlWidth/100); $this.find('table').css('width', value + "px"); } else if(properties.isIgnoreGrid && properties.isIgnoreGrid.value//grid && properties.ignoreScreenSize && properties.ignoreScreenSize.value && getParent() && getParent().previewMode && getParent().previewMode.size && parseFloat(properties.ignoreScreenSize.value) > parseFloat(getParent().previewMode.size) && properties.stackedExpand && properties.stackedExpand.value == 'expand') { var value = parseFloat(properties.adjustWidth.value); value = Math.round(value * fvDataNS.ctrlWidth/100); $this.find('table').css('width', value + "px"); } else { var value = parseFloat(properties.adjustWidthNormal.value); value = Math.round(value * fvDataNS.ctrlWidth/100); $this.find('table').css('width', value + "px"); } } } // } } } } $this.off('orientationchange').on('orientationchange', orientationchangeHandle); orientationchangeHandle(); fvDataNS.dataArray[ctrlPropreties.classPath] = ctrlPropreties; /*if(isVersion(VERSION_NEW_WEB_APP)){ addFormCtrl(fvDataNS.newFormInfo, $this, ctrlPropreties); }*/ if(ctrlType == CONST_CTRL_TYPE_CTRLTABLE || ctrlType == CONST_CTRL_TYPE_CTRLREPEATABLESUMMARY){ const replaced = ctrlPropreties.classPath.substring(0, ctrlPropreties.classPath.lastIndexOf("_loop_1")); fvDataNS.ctrlArray[replaced] = $this; }else{ fvDataNS.ctrlArray[ctrlPropreties.classPath] = $this; } if(fvDataNS.ctrlIdMap[ctrlPropreties.id] == undefined){ fvDataNS.ctrlIdMap[ctrlPropreties.id] = {}; } fvDataNS.ctrlIdMap[ctrlPropreties.id][ctrlPropreties.classPath] = ctrlPropreties.classPath; if(isVersion(VERSION_REMOVE_SPACE_WEBAPP)){ if(properties.removeSpaceAbove && properties.removeSpaceAbove.value){ $this.addClass('no-padding-top'); // Move process code to ScoreSummary region // if(ctrlType == CONST_CTRL_TYPE_INPUTSCORESUMMARY){ // $('.formView .scoreSummary').addClass('no-padding-top'); // } } if(properties.removeSpaceBelow && properties.removeSpaceBelow.value){ $this.addClass('no-padding-bottom'); // Move process code to ScoreSummary region // if(ctrlType == CONST_CTRL_TYPE_INPUTSCORESUMMARY){ // $('.formView .scoreSummary').addClass('no-padding-bottom'); // } } } if(ctrlPropreties.skipByCtrls != undefined && ctrlPropreties.skipByCtrls.length > 0){ if(ctrlType == 'inputPageBreak'){ }else{ $this.addClass(CONST_CLASS_HIDE_CONTROL); } }else{ if(ctrlPropreties.isCtrlHidden){ $this.addClass(CONST_CLASS_HIDE_CONTROL); }else{ $this.removeClass(CONST_CLASS_HIDE_CONTROL); } } if(properties.readOnly != undefined && properties.readOnly.value != undefined && properties.readOnly.value){ ctrlPropreties.readOnly = true; }else{ ctrlPropreties.readOnly = false; } if(isTurnOffSelectionOutline(properties)){ $this.addClass("TurnOffOutline"); } // The AnswerColor will be processed in function formViewUtils.applyAnswerColorClass() // if(properties.answerColor && properties.answerColor.value && properties.answerColor.value.isAnswerColor == true){ // $this.find('input, textarea').css('cssText', 'color: ' + (properties.answerColor.value.answerTextColor || LBL_DEFAULT_ANSWER_TEXT_COLOR) + ' !important'); // } $this.find('.ctrlHref').attr('id', 'ctrlHref_' + ctrlPropreties.ctrlDataId); $this.find('.controlData').attr('id', 'ctrlDataId_' + ctrlPropreties.ctrlDataId); setControlSecurityOption(properties, $this); if(ctrlType == CONST_CTRL_TYPE_INPUTACTION){ fvEditorsInputAction(properties, $this, ctrlType, ctrlPropreties); if(properties.imgActionParamDesQuesFlg != undefined && properties.imgActionParamDesQuesFlg.value){ ctrlPropreties.imgActionParamDesQuesFlg = true; }else{ ctrlPropreties.imgActionParamDesQuesFlg = false; } if(isVersion(VERSION_ACTION_BTN_AUTO_STAMP)){ if(properties.autoActionStampTrigger != undefined && properties.autoActionStampTrigger.value != '' && properties.autoActionStampTrigger.value != lbl_sel_question && properties.actionKind && CONST_TYPE_AUTO_RUN == properties.actionKind.value){ ctrlPropreties.autoActionStampTrigger = properties.autoActionStampTrigger.value; ctrlPropreties.autoActionStampQuestionTrigger = properties.autoActionStampQuestionTrigger.value; var autoStampTrigger = ctrlPropreties.autoActionStampTrigger; if(fvDataNS.autoStampTriggerMap[autoStampTrigger] == undefined){ fvDataNS.autoStampTriggerMap[autoStampTrigger] = {}; } switch(autoStampTrigger){ case CONST_WHEN_A_FIELD_IS_ENTERED : case CONST_AUTO_RUN_WHEN_RETRIEVE_HAS_DATA : case CONST_AUTO_RUN_WHEN_RETRIEVE_HAS_NO_DATA : // Trigger when a specified question is answered if(properties.autoActionStampQuestionTrigger != undefined && properties.autoActionStampQuestionTrigger.value){ if(fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoActionStampQuestionTrigger.value] == undefined){ fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoActionStampQuestionTrigger.value] = {}; } fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoActionStampQuestionTrigger.value][ctrlPropreties.classPath] = false; } break; } } } }else if(ctrlType == CONST_CTRL_TYPE_INPUTPAYMENT){ fvEditorsInputPayment(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == 'inputSaveAndSend'){ fvEditorsInputSaveAndSend(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == 'inputPageBreak'){ fvEditorsInputPageBreak(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == 'inputLabel'){ fvEditorsInputLabel(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUT_TEXT){ fvEditorsInputText(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUT_NUMERIC){ fvEditorsInputNumeric(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTNEWPAYMENT){ fvEditorsInputNewPayment(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTNUMBERING){ fvEditorsInputNumbering(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTTRENDS){ fvEditorsInputTrends(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTCOUNTER){ fvEditorsInputCounter(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTDATE){ if(isVersion(VERSION_ALLOW_EDIT_OPT)){ if(properties.isAllowEdit.value == undefined){ properties.isAllowEdit.value = true; } if(properties.isAllowEdit && properties.isAllowEdit.value){ ctrlPropreties.isAllowEdit = properties.isAllowEdit.value; } } fvEditorsInputDate(properties, $this, ctrlType, ctrlPropreties); if(properties.autoStamp != undefined && properties.autoStamp.value){ ctrlPropreties.autoStamp = true; }else{ ctrlPropreties.autoStamp = false; } if(ctrlPropreties.autoStamp && properties.autoStampTrigger != undefined && properties.autoStampTrigger.value){ var autoStampTrigger = properties.autoStampTrigger.value; ctrlPropreties.autoStampTrigger = autoStampTrigger; if(fvDataNS.autoStampTriggerMap[autoStampTrigger] == undefined){ fvDataNS.autoStampTriggerMap[autoStampTrigger] = {}; } if(autoStampTrigger == '2'){ // Trigger when a specified question is answered for the first time if(properties.autoStampTrigger2Ques != undefined && properties.autoStampTrigger2Ques.value){ if(fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoStampTrigger2Ques.value] == undefined){ fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoStampTrigger2Ques.value] = {}; } if(!fvDataNS.isLoading){ fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoStampTrigger2Ques.value][ctrlPropreties.classPath] = false; }else{ var itemProperties = getPropertiesByID(properties.autoStampTrigger2Ques.value); if(itemProperties != undefined){ if(isEditLoading() && (itemProperties.val || '') != ''){ fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoStampTrigger2Ques.value][ctrlPropreties.classPath] = true; }else{ fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoStampTrigger2Ques.value][ctrlPropreties.classPath] = false; } }else{ fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoStampTrigger2Ques.value][ctrlPropreties.classPath] = false; } } } }else if(autoStampTrigger == '4'){ // Trigger when a specified page is displayed for the first time if(properties.autoStampTrigger4Ques != undefined && properties.autoStampTrigger4Ques.value){ if(fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoStampTrigger4Ques.value] == undefined){ fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoStampTrigger4Ques.value] = {}; } fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoStampTrigger4Ques.value][ctrlPropreties.classPath] = false; } }else if(autoStampTrigger == '8'){ // Trigger when the form is opened for the first var isTrigger = true; if(fvDataNS.incomplete){ isTrigger = false; } if(fvDataNS.currentForm.editRecordData){ isTrigger = false; } if(ctrlPropreties.skipByCtrls != undefined && ctrlPropreties.skipByCtrls.length > 0){ isTrigger = false; }else{ if(ctrlPropreties.isCtrlHidden){ isTrigger = false; } } if($this.parents('.hideControl').length > 0){ isTrigger = false; } if(getValueOrEmpty(ctrlPropreties.val) != '' && !ctrlPropreties.isAllowEdit){ isTrigger = false; } if(isTrigger){ fvDataNS.autoStampTriggerMap[autoStampTrigger][ctrlPropreties.classPath] = false; //$this.find('.controlData input').trigger('setAutoStamp'); } }else if(autoStampTrigger == '16'){ // Trigger when the form is saved as complete fvDataNS.autoStampTriggerMap[autoStampTrigger][ctrlPropreties.classPath] = false; } } $this.find('.controlData .viewDateControl input').prop('disabled', true); }else if(ctrlType == CONST_CTRL_TYPE_INPUTSELECTONE){ fvEditorsInputSelectOne(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTSELECTMANY){ fvEditorsInputSelectMany(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTSCOREONE){ fvEditorsInputScoreOne(properties, $this, ctrlType, ctrlPropreties); $('.formView .scoreSummary').trigger('appendScoreSummaryDataRow', properties.scoreCategory.value); if(getValueOrEmpty(ctrlPropreties.val) != ''){ var scoreDataRow = $('.scoreSummary .category_' + replaceNonAlphaNumericChar(ctrlPropreties.scoreCategory)); scoreDataRow.trigger('calculateDataChange', ctrlPropreties); } }else if(ctrlType == CONST_CTRL_TYPE_INPUTLOCATION){ fvEditorsInputLocation(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTBARCODE){ fvEditorsInputBarcode(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTNFC){ fvEditorsInputNFC(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTFORWARD){ fvEditorsInputForward(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == mdi_kind_inputImage){ fvEditorsInputImage(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == mdi_kind_inputAudio){ fvEditorsInputAudio(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == mdi_kind_inputVideo){ fvEditorsInputVideo(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == mdi_kind_inputSketch){ fvEditorsInputSketch(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == mdi_kind_inputSignature){ fvEditorsInputSignature(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_GROUP){ fvEditorsGroup(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTEMAILREPORT){ fvEditorsInputEmailReport(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTCALCULATE){ fvEditorsInputCalculate(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_CTRLTABLE){ fvEditorsCtrlTable(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_CTRLPOD){ fvEditorsCtrlPOD(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTLOOKUP){ fvEditorsInputLookup(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTLFBLUETOOTH){ fvEditorsInputLFBluetooth(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == 'inputFacingTable'){ fvEditorsInputFacingTable(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_CTRLSCORETABLE){ fvEditorsCtrlScoreTable(properties, $this, ctrlType, ctrlPropreties); fvDataNS.scrtAndGrdNameMap.push(properties.name); }else if(ctrlType == CONST_CTRL_TYPE_CTRLGRID){ fvEditorsCtrlGrid(properties, $this, ctrlType, ctrlPropreties); fvDataNS.scrtAndGrdNameMap.push(properties.name); }else if(ctrlType == CONST_CTRL_TYPE_SCORESUMMARY){ fvEditorsScoreSummary(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTSCORESUMMARY){ // Fix bug 0024941: Shaded headings in "Custom" do not work with Score summary widget. isScoreSummaryField = true; $thisObjectScoreSummary = $('.formView .scoreSummary'); // Apply spacing for ScoreSummary if(isVersion(VERSION_REMOVE_SPACE_WEBAPP)){ if(properties.removeSpaceAbove && properties.removeSpaceAbove.value){ $thisObjectScoreSummary.addClass('no-padding-top'); } if(properties.removeSpaceBelow && properties.removeSpaceBelow.value){ $this.addClass('no-padding-bottom'); $thisObjectScoreSummary.addClass('no-padding-bottom'); } } if(properties.summaryCategory && properties.summaryCategory.value != ''){ ctrlPropreties.summaryCategory = properties.summaryCategory.value; }else{ ctrlPropreties.summaryCategory = ''; } if(valueOrEmpty(ctrlPropreties.summaryCategory) == ''){ $this.addClass('forAllCategory'); }else{ $this.attr('data-category', ctrlPropreties.summaryCategory); $this.empty().append($thisObjectScoreSummary.find('div.ctrlHref').clone()); $this.addClass(CONST_CSS_CLASS_HIDE_SESSION); var tr = $this.find('tbody tr'); for(var i = 0; i= 0) // Ignore Label/Dummy Label/inputAction if (CONTROL_NOT_APPLY_REMOVE_BORDER_ANSWER.indexOf(ctrlType+',') < 0) { // if (properties.removeAnswerBorder !== undefined // && properties.removeAnswerBorder.value === true) { // // Apply remove answer // $this.addClass('removeBorderAroundAnswerOUT'); // // // Check if the current header has border or not // if (false === getActualBorderAroundHeading4WA(properties)) { // $this.addClass('removeBrdArdAnswr_NoBorderHeadings'); // } // } formViewUtils.applyRemoveBorderAroundAnswer(properties, $this, ctrlType, ctrlPropreties); } } // Process Answer Color for Web forms GUI if (isVersion(VERSION_ANSWER_COLOR)) { if (CONTROL_APPLY_ANSWER_COLOR_GUI.indexOf(ctrlType+',') >= 0) { formViewUtils.applyAnswerColorClass(properties, $this, ctrlType, ctrlPropreties); } } $this.attr('tabindex', 0).attr('classPath', ctrlPropreties.classPath); /*$this.find('input, textarea').keydown(function(objEvent) { if (objEvent.keyCode == 9) { //tab pressed fvDataNS.jumpToId1 = 'tab' } });*/ if(isVersion(VERSION_5_0) && parseFloat(fvDataNS.currentForm.formVersion) >= 3.0){ //$this.find('input, textarea, select').blur(function(event) $this.blur(function(event) { if(!$this.hasClass(CONST_CSS_CLASS_CTRL_SELECTED) && !$this.hasClass('ctrl_cap_selected')){ executeSkipChange(ctrlPropreties); } }); } /* co-1566, co1567 $this.find('.jqTransformCheckboxWrapper, .jqTransformRadioWrapper').click(function(){ $('.formView .fvWorkspaceScrollArea .selected_border').removeClass('selected_border'); });*/ switch (ctrlType) { case CONST_CTRL_TYPE_GROUP: case CONST_CTRL_TYPE_CTRLTABLE: case CONST_CTRL_TYPE_CTRLPOD: case CONST_CTRL_TYPE_CTRLGRID: case CONST_CTRL_TYPE_CTRLSCORETABLE: case "inputPageBreak": break; default: $this.find('.select-able').focus(function(){ if(!fvDataNS.isExecuteControlChangeRunning){ setListCtrlDataChange(ctrlPropreties.classPath, false, ctrlPropreties.val); } }).click(function(){ if(!$this.hasClass('ignore_focus') && properties.id.value != 'dispatchMobileGroup' && properties.id.value != 'dispatchUID' && properties.id.value != 'dispatchUName' && properties.id.value != 'dispatchUTime' && properties.id.value != 'dispatchUTime2' && properties.id.value != 'dispatchUTime3' && properties.id.value != 'dispatchUDura' && properties.id.value != 'dispatchUDuraMin'){//$this, ctrlType, config, properties, ctrlPropreties fvCtrlFocus($this, false); } }); $this.keydown(function(objEvent) { var keyCode = objEvent.keyCode || objEvent.which; if (keyCode == 9) { //tab pressed var ret = toNextCtrl(this, objEvent, ctrlPropreties); objEvent.preventDefault(); return ret; }else if(isReadOnlyApply(properties) || (ctrlPropreties.ctrlType != CONST_CTRL_TYPE_INPUT_TEXT && ctrlPropreties.ctrlType != CONST_CTRL_TYPE_INPUTEMAILREPORT)){ return toNextCtrl(this, objEvent, ctrlPropreties); } }); }; var hint = $this.find('.controlHint'); if(ctrlType != 'inputLabel' && hint.text() == ''){ hint.addClass('hintEmpty'); } $this.off('Skip_Relevance_Change_New').on('Skip_Relevance_Change_New', function(event, addToChangeList){ if(executeCalculateRelevanceConds(ctrlPropreties)){ if((ctrlType == CONST_CTRL_TYPE_INPUTLOOKUP || ctrlType == CONST_CTRL_TYPE_INPUTLFBLUETOOTH) && !ctrlPropreties.isCtrlHidden && ctrlPropreties.isCtrlHiddenChanged){ $this.find('.controlData input, .controlData textarea').trigger('changeDataSource'); } //$('.fvMainWrapper .fvWorkspace .fvCtrlID_' + ctrlPropreties.id).trigger('fvCtrlShowHideChange', addToChangeList); $this.trigger('fvCtrlShowHideChange', addToChangeList); } executeCalculateHideIfConds(ctrlPropreties); event.stopPropagation(); }); executeCalculateRelevanceConds(ctrlPropreties); // CO-4022: Hide if if(properties.hideIfFields){ // properties.hideIfCmpVal, button control not have hideIfCmpVal ctrlPropreties.hideIfCmpVal = properties.hideIfCmpVal; ctrlPropreties.hideIfFields = properties.hideIfFields; addToCtrlIdRefForHideIf(ctrlPropreties.hideIfFields.value, ctrlPropreties.id); } $this.off('ReadOnlyIf_Change_New').on('ReadOnlyIf_Change_New', function(event, addToChangeList){ if(executeCalculateReadOnlyIfConds(ctrlPropreties)){ //$('.fvMainWrapper .fvWorkspace .fvCtrlID_' + ctrlPropreties.id).trigger('checkAndSetReadOnly'); $this.trigger('checkAndSetReadOnly'); } event.stopPropagation(); }); executeCalculateReadOnlyIfConds(ctrlPropreties); // Apply If .. Then .. Else in WebApps GUI if (isVersion(VERSION_IF_THEN_ELSE)) { $this.off('If_Then_Else_ChangeEvent').on('If_Then_Else_ChangeEvent', function(event, addToChangeList){ // Ignore process with question do not condition ifThenElseExpression if (ctrlPropreties.ifThenElseExpression) { var iteValueCheck = calculateIfThenElseConds(ctrlPropreties.ifThenElseExpression, ctrlPropreties, fvDataNS.inputData); //console.log('iteValueCheck 1 : ' + iteValueCheck); } event.stopPropagation(); }).trigger('If_Then_Else_ChangeEvent'); } // PCA-178: Web App support for Shading and Spacing (custom options) if (isVersion(VERSION_SHADINGS_AND_BUTTON_TEXT_WEB_APP)) { // PCA-293: Webapp/Preview - Apply new block formats for all widgets. // Always add the common class for making the same layout between SHADING & NO SHADING if (ctrlType === CONST_CTRL_TYPE_GROUP) { $this.addClass('layoutControlCommonWA4Group'); } else if (ctrlType !== CONST_CTRL_TYPE_INPUT_TEXT){ // Normal cases $this.addClass('layoutControlCommonWA'); // Fix bug 0024941: Shaded headings in "Custom" do not work with Score summary widget. if (isScoreSummaryField === true && $thisObjectScoreSummary) { $thisObjectScoreSummary.addClass('layoutControlCommonWA'); } } // Fix bug 0024941: Shaded headings in "Custom" do not work with Score summary widget. if (isScoreSummaryField === true && $thisObjectScoreSummary) { applyShadingAndButtonTextWACustomOptions($thisObjectScoreSummary, hint, properties, ctrlType); } else { applyShadingAndButtonTextWACustomOptions($this, hint, properties, ctrlType); } //applyShadingAndButtonTextWACustomOptions($this, hint, properties, ctrlType); } clearCtrlChange(ctrlPropreties); }; /*****************************************************************************************************************/ /*End********************************************load data ctrl **************************************************/ /*****************************************************************************************************************/ // Apply gray filter for ActionPrint WebClient only function applyGrayFilter4ActionPrintWebClient(currentValueOfButton, arrJQuerySelect) { // PCA-625 : Form Preview | Action Button - Addition, to add printing support for Web Client Only // (Just disable the Print action button in Preview.) try { var isNeedDisabledBtnAction = false; // Disable button inside Form > Preview if (currentValueOfButton === CONST_ACTION_PRINT) { // Trigger event print WebApps GUI (ignore Form Preview) var url = window.location.toString(); if (url.indexOf('fnId=preview_tablet') > 0 && url.indexOf('/preview') > 0 ) { // Do nothing because we are in Form Preview writeToLogInfoRequired('Process disable button inside Form Preview ...'); isNeedDisabledBtnAction = true; } } if (isNeedDisabledBtnAction === true) { var grayFilter = '-webkit-filter: grayscale(1) !important;'; grayFilter += '-moz-filter: grayscale(1) !important;'; grayFilter += '-ms-filter: grayscale(1) !important;'; grayFilter += 'filter: grayscale(1) !important;'; grayFilter += 'filter: gray !important;'; /* Firefox 10+, Firefox on Android */ grayFilter += 'filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale");'; grayFilter += 'color: gray !important;'; grayFilter += 'cursor: default !important;'; grayFilter += '-webkit-filter: grayscale(100%); !important'; // var arrJQuerySelect = new Array(); // arrJQuerySelect.push($control); // arrJQuerySelect.push($control.find('.actionLabelText')); // arrJQuerySelect.push($control.find('.controlLabel')); // arrJQuerySelect.push($control.find('.actionBtn')); for (var t = 0; t < arrJQuerySelect.length; t++) { var objQuery = arrJQuerySelect[t]; var objQueryCss = objQuery.attr('style'); if (!objQueryCss || objQueryCss === null) { objQueryCss = ''; } objQuery.attr('style', objQueryCss.toString() + ';' + grayFilter); } } } catch (e) { } } /*****************************************************************************************************************/ /*Start******************************************load data ctrl table*********************************************/ /*****************************************************************************************************************/ function fillDataControlTableFV($this, ctrlType, properties, ctrlPropreties){ $this.data('odkControl-properties', properties); $this.data('odkControl-ctrlPropreties', ctrlPropreties); applyJustification($this, properties); fvDataNS.dataArray[ctrlPropreties.classPath] = ctrlPropreties; /*if(isVersion(VERSION_NEW_WEB_APP)){ addFormCtrl(fvDataNS.newFormInfo, $this, ctrlPropreties); }*/ fvDataNS.ctrlArray[ctrlPropreties.classPath] = $this; if(fvDataNS.ctrlIdMap[ctrlPropreties.id] == undefined){ fvDataNS.ctrlIdMap[ctrlPropreties.id] = {}; } if(ctrlPropreties.parrentProperties.endsWith('_loop_1')){ var tmp = ctrlPropreties.classPath; var index = 1; while(fvDataNS.ctrlIdMap[ctrlPropreties.id][tmp] != undefined){ delete fvDataNS.ctrlIdMap[ctrlPropreties.id][tmp]; var pos = ctrlPropreties.parrentProperties.lastIndexOf('_loop_1'); index++; tmp = ctrlPropreties.parrentProperties.slice(0, pos) + '_loop_' + index + ' ' + ctrlPropreties.name; } } fvDataNS.ctrlIdMap[ctrlPropreties.id][ctrlPropreties.classPath] = ctrlPropreties.classPath; if(ctrlPropreties.skipByCtrls != undefined && ctrlPropreties.skipByCtrls.length > 0){ $this.addClass(CONST_CLASS_HIDE_CONTROL); }else{ if(ctrlPropreties.isCtrlHidden){ $this.addClass(CONST_CLASS_HIDE_CONTROL); }else{ $this.removeClass(CONST_CLASS_HIDE_CONTROL); } } if(properties.readOnly != undefined && properties.readOnly.value != undefined && properties.readOnly.value){ ctrlPropreties.readOnly = true; }else{ ctrlPropreties.readOnly = false; } if(isTurnOffSelectionOutline(properties)){ $this.addClass("TurnOffOutline"); } // The AnswerColor will be processed in function formViewUtils.applyAnswerColorClass() // if(properties.answerColor && properties.answerColor.value && properties.answerColor.value.isAnswerColor == true){ // $this.find('input, textarea').css('cssText', 'color: ' + (properties.answerColor.value.answerTextColor || LBL_DEFAULT_ANSWER_TEXT_COLOR) + ' !important'); // } else { // // Process Answer Color for Web forms GUI // // Process by Form Settings // if (glbBuildFormSettingsWA.isAnswerColor) { // $this.find('input, textarea').css('cssText', 'color: ' + glbBuildFormSettingsWA.answerColor + ' !important;'); // } // } /*fix bug 0027005: Calculation adds the hidden numeric value even though the relevance condition is not met*/ var parrentProperties = fvDataNS.dataArray[ctrlPropreties.parrentProperties]; if(isControlHidden(parrentProperties)){ ctrlPropreties.isParentCtrlHidden = true; } $this.find('.ctrlHref').attr('id', 'ctrlHref_' + ctrlPropreties.ctrlDataId); $this.find('.controlData').attr('id', 'ctrlDataId_' + ctrlPropreties.ctrlDataId); setControlSecurityOption(properties, $this); if(ctrlType == 'inputPageBreak'){ }else if(ctrlType == 'inputLabel'){ }else if(ctrlType == CONST_CTRL_TYPE_INPUT_TEXT){ fvEditorsTableInputText(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUT_NUMERIC){ fvEditorsTableInputNumeric(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTNEWPAYMENT){ }else if(ctrlType == CONST_CTRL_TYPE_INPUTTRENDS){ fvEditorsTableInputTrends(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTCOUNTER){ fvEditorsTableInputCounter(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTDATE){ if(isVersion(VERSION_ALLOW_EDIT_OPT)){ if(properties.isAllowEdit.value == undefined){ properties.isAllowEdit.value = true; } if(properties.isAllowEdit && properties.isAllowEdit.value){ ctrlPropreties.isAllowEdit = properties.isAllowEdit.value; } } fvEditorsTableInputDate(properties, $this, ctrlType, ctrlPropreties); if(properties.autoStamp != undefined && properties.autoStamp.value){ ctrlPropreties.autoStamp = true; }else{ ctrlPropreties.autoStamp = false; } if(ctrlPropreties.autoStamp && properties.autoStampTrigger != undefined && properties.autoStampTrigger.value){ var autoStampTrigger = properties.autoStampTrigger.value; ctrlPropreties.autoStampTrigger = autoStampTrigger; if(fvDataNS.autoStampTriggerMap[autoStampTrigger] == undefined){ fvDataNS.autoStampTriggerMap[autoStampTrigger] = {}; } if(fvDataNS.listCtrlSetAutoStamp && fvDataNS.listCtrlSetAutoStamp[ctrlPropreties.classPath] !== undefined){ fvDataNS.listCtrlSetAutoStamp[ctrlPropreties.classPath] = undefined; } if(autoStampTrigger == '2'){ // Trigger when a specified question is answered for the first time if(properties.autoStampTrigger2Ques != undefined && properties.autoStampTrigger2Ques.value){ if(fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoStampTrigger2Ques.value] == undefined){ fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoStampTrigger2Ques.value] = {}; } var triger2Ques = properties.autoStampTrigger2Ques.value; var autoStampTrigger2QuesProperties = getPropertiesByID(properties.autoStampTrigger2Ques.value); if(autoStampTrigger2QuesProperties && autoStampTrigger2QuesProperties.parentName == ctrlPropreties.parentName){ triger2Ques = properties.autoStampTrigger2Ques.value + "_" + ctrlPropreties.parrentProperties; if(fvDataNS.autoStampTriggerMap[autoStampTrigger][triger2Ques] == undefined){ fvDataNS.autoStampTriggerMap[autoStampTrigger][triger2Ques] = {}; } } if(!fvDataNS.isLoading){ fvDataNS.autoStampTriggerMap[autoStampTrigger][triger2Ques][ctrlPropreties.classPath] = false; }else{ var itemProperties = getPropertiesByID(properties.autoStampTrigger2Ques.value); if(itemProperties != undefined){ if(isEditLoading() && (itemProperties.val || '') != ''){ fvDataNS.autoStampTriggerMap[autoStampTrigger][triger2Ques][ctrlPropreties.classPath] = true; }else{ fvDataNS.autoStampTriggerMap[autoStampTrigger][triger2Ques][ctrlPropreties.classPath] = false; } }else{ fvDataNS.autoStampTriggerMap[autoStampTrigger][triger2Ques][ctrlPropreties.classPath] = false; } } } }else if(autoStampTrigger == '4'){ // Trigger when a specified page is displayed for the first time if(properties.autoStampTrigger4Ques != undefined && properties.autoStampTrigger4Ques.value){ if(fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoStampTrigger4Ques.value] == undefined){ fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoStampTrigger4Ques.value] = {}; } var triger4Ques = properties.autoStampTrigger4Ques.value; var autoStampTrigger2QuesProperties = getPropertiesByID(properties.autoStampTrigger4Ques.value); if(autoStampTrigger2QuesProperties && autoStampTrigger2QuesProperties.parentName == ctrlPropreties.parentName){ triger4Ques = properties.autoStampTrigger4Ques.value + "_" + ctrlPropreties.parrentProperties; if(fvDataNS.autoStampTriggerMap[autoStampTrigger][triger4Ques] == undefined){ fvDataNS.autoStampTriggerMap[autoStampTrigger][triger4Ques] = {}; } } fvDataNS.autoStampTriggerMap[autoStampTrigger][triger4Ques][ctrlPropreties.classPath] = false; } }else if(autoStampTrigger == '8'){ // Trigger when the form is opened for the first var isTrigger = true; if(fvDataNS.incomplete){ isTrigger = false; } if(fvDataNS.currentForm.editRecordData){ isTrigger = false; } if(ctrlPropreties.skipByCtrls != undefined && ctrlPropreties.skipByCtrls.length > 0){ isTrigger = false; }else{ if(ctrlPropreties.isCtrlHidden){ isTrigger = false; } } if($this.parents('.hideControl').length > 0){ isTrigger = false; } if(getValueOrEmpty(ctrlPropreties.val) != '' && !ctrlPropreties.isAllowEdit){ isTrigger = false; } if(isTrigger){ fvDataNS.autoStampTriggerMap[autoStampTrigger][ctrlPropreties.classPath] = false; //$this.find('.controlData input').trigger('setAutoStamp'); } }else if(autoStampTrigger == '16'){ // Trigger when the form is saved as complete fvDataNS.autoStampTriggerMap[autoStampTrigger][ctrlPropreties.classPath] = false; } } }else if(ctrlType == CONST_CTRL_TYPE_INPUTSELECTONE){ fvEditorsTableInputSelectOne(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTSELECTMANY){ fvEditorsTableInputSelectMany(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTSCOREONE){ fvEditorsTableInputScoreOne(properties, $this, ctrlType, ctrlPropreties); $('.formView .scoreSummary').trigger('appendScoreSummaryDataRow', properties.scoreCategory.value); if(getValueOrEmpty(ctrlPropreties.val) != ''){ var scoreDataRow = $('.scoreSummary .category_' + replaceNonAlphaNumericChar(ctrlPropreties.scoreCategory)); scoreDataRow.trigger('calculateDataChange', ctrlPropreties); } }else if(ctrlType == CONST_CTRL_TYPE_INPUTLOCATION){ fvEditorsTableInputLocation(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTBARCODE){ fvEditorsTableInputBarcode(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTNFC){ fvEditorsTableInputNFC(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == mdi_kind_inputImage){ fvEditorsTableInputImage(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_IMAGE_VIEWER){ fvEditorsTableInputImageViewer(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTATTACHMENT){ fvEditorsTableInputAttachment(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == mdi_kind_inputAudio){ }else if(ctrlType == mdi_kind_inputVideo){ }else if(ctrlType == mdi_kind_inputSketch){ }else if(ctrlType == mdi_kind_inputSignature){ fvEditorsTableInputSignature(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_GROUP){ }else if(ctrlType == CONST_CTRL_TYPE_INPUTEMAILREPORT){ }else if(ctrlType == CONST_CTRL_TYPE_INPUTCALCULATE){ fvEditorsTableInputCalculate(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTLOOKUP){ fvEditorsTableInputLookup(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTLFBLUETOOTH){ fvEditorsTableInputLFBluetooth(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_CTRLTABLE){ }else if(ctrlType == CONST_CTRL_TYPE_CTRLPOD){ }else if(ctrlType == CONST_CTRL_TYPE_INPUTACTION){ fvEditorsTableInputAction(properties, $this, ctrlType, ctrlPropreties); if(isVersion(VERSION_ACTION_BTN_AUTO_STAMP)){ if(properties.autoActionStampTrigger != undefined && properties.autoActionStampTrigger.value != '' && properties.autoActionStampTrigger.value != lbl_sel_question && properties.actionKind && CONST_TYPE_AUTO_RUN == properties.actionKind.value){ ctrlPropreties.autoActionStampTrigger = properties.autoActionStampTrigger.value; ctrlPropreties.autoActionStampQuestionTrigger = properties.autoActionStampQuestionTrigger.value; var autoStampTrigger = ctrlPropreties.autoActionStampTrigger; if(fvDataNS.autoStampTriggerMap[autoStampTrigger] == undefined){ fvDataNS.autoStampTriggerMap[autoStampTrigger] = {}; } switch(autoStampTrigger){ case CONST_WHEN_A_FIELD_IS_ENTERED : // Trigger when a specified question is answered if(properties.autoActionStampQuestionTrigger != undefined && properties.autoActionStampQuestionTrigger.value){ if(fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoActionStampQuestionTrigger.value] == undefined){ fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoActionStampQuestionTrigger.value] = {}; } fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoActionStampQuestionTrigger.value][ctrlPropreties.classPath] = false; } break; } } } } processBindingDestinationActionEvent(properties, ctrlPropreties); addToSkipList(ctrlPropreties); $this.attr('tabindex', 0).attr('classPath', ctrlPropreties.classPath); $this.click(function(event){ if(!event || event.cancelable == undefined){ // this is trigger event return; } if(!$(this).hasClass('ignore_focus')){ fvCtrlFocus(this, false); } }) .keydown(function(objEvent) { var keyCode = objEvent.keyCode || objEvent.which; if (keyCode == 9) { //tab pressed return toNextCtrl(this, objEvent, ctrlPropreties); }else if(isReadOnlyApply(properties) || (ctrlPropreties.ctrlType != CONST_CTRL_TYPE_INPUT_TEXT && ctrlPropreties.ctrlType != CONST_CTRL_TYPE_INPUTEMAILREPORT)){ return toNextCtrl(this, objEvent, ctrlPropreties); } }); if(isVersion(VERSION_5_0) && parseFloat(fvDataNS.currentForm.formVersion) >= 3.0){ //$this.find('input, textarea, select').blur(function(event) $this.blur(function(event) { executeSkipChange(ctrlPropreties); }); } $this.off('Skip_Relevance_Change_New').on('Skip_Relevance_Change_New', function(event, addToChangeList){ if(executeCalculateRelevanceConds(ctrlPropreties)){ if((ctrlType == CONST_CTRL_TYPE_INPUTLOOKUP || ctrlType == CONST_CTRL_TYPE_INPUTLFBLUETOOTH) && !ctrlPropreties.isCtrlHidden && ctrlPropreties.isCtrlHiddenChanged){ $this.find('.controlData input, .controlData textarea').trigger('changeDataSource'); } //$('.fvMainWrapper .fvWorkspace .fvCtrlID_' + ctrlPropreties.id).trigger('fvCtrlShowHideChange', addToChangeList); $this.trigger('fvCtrlShowHideChange', addToChangeList); } executeCalculateHideIfConds(ctrlPropreties); event.stopPropagation(); }); executeCalculateRelevanceConds(ctrlPropreties); // CO-4022: Hide if if(properties.hideIfFields){ // properties.hideIfCmpVal ctrlPropreties.hideIfCmpVal = properties.hideIfCmpVal; ctrlPropreties.hideIfFields = properties.hideIfFields; addToCtrlIdRefForHideIf(ctrlPropreties.hideIfFields.value, ctrlPropreties.id); } $this.off('ReadOnlyIf_Change_New').on('ReadOnlyIf_Change_New', function(event, addToChangeList){ if(executeCalculateReadOnlyIfConds(ctrlPropreties)){ //$('.fvMainWrapper .fvWorkspace .fvCtrlID_' + ctrlPropreties.id).trigger('checkAndSetReadOnly'); $this.trigger('checkAndSetReadOnly'); } event.stopPropagation(); }); executeCalculateReadOnlyIfConds(ctrlPropreties); // Apply If .. Then .. Else in WebApps GUI if (isVersion(VERSION_IF_THEN_ELSE)) { $this.off('If_Then_Else_ChangeEvent').on('If_Then_Else_ChangeEvent', function(event, addToChangeList){ // Ignore process with question do not condition ifThenElseExpression if (ctrlPropreties.ifThenElseExpression && ctrlPropreties.ifThenElseExpression != '') { var iteValueCheck = calculateIfThenElseConds(ctrlPropreties.ifThenElseExpression, ctrlPropreties, fvDataNS.inputData); //console.log('iteValueCheck 2 : ' + iteValueCheck); } event.stopPropagation(); }); } // Apply Shading and Button Text color (https://doforms.atlassian.net/browse/PCA-145) if (isVersion(VERSION_SHADINGS_AND_BUTTON_TEXT_WEB_APP)) { // Apply shading of button controls if (glbBuildFormSettingsWA.isButtonShades === true) { // Add the main class about shading $this.addClass('shadingButtonCtrlBackgrnd'); // Add the main class for color choosing $this.addClass('shadingButtonCtrlColorBackgrnd'); $this.attr('shadingButtonCtrlColorBackgrnd', CONST_VALUE_TRUE_STR); // CO-3718, 3502 if(properties.ofRequired && '2' === properties.ofRequired.value //&& '2' === properties.ofSource.value && getParent().dispatchFlg == true){ $this.parent().css('vertical-align', 'top'); $this.addClass('shadingControlBackground'); $this.find('.controlLabel').hide(); //$this.find('.controlLabel').attr('style', 'cursor: default; font-weight: bold !important'); $this.find('.controlData').attr('style', 'padding: 0px;'); if('2' === properties.ofSource.value){ $this.find('.inputinner_textarea').attr('style', 'border: none;'); } else{ $this.find('.inputinner_textarea').attr('style', 'border-top: 0px; border-left: 0px; border-right: 0px;'); } } } } clearCtrlChange(ctrlPropreties); // Apply []Remove border around answer if (isVersion(VERSION_REMOVE_ANSW_BORDER)) { // if (properties.removeAnswerBorder !== undefined // && properties.removeAnswerBorder.value === true) { // // Apply remove answer // $this.addClass('removeBorderAroundAnswer'); // } // Ignore Label/Dummy Label/inputAction if (CONTROL_NOT_APPLY_REMOVE_BORDER_ANSWER.indexOf(ctrlType+',') < 0) { formViewUtils.applyRemoveBorderAroundAnswerTABLE(properties, $this, ctrlType, ctrlPropreties); } } // Process Answer Color for Web forms GUI if (isVersion(VERSION_ANSWER_COLOR)) { // if (CONTROL_APPLY_ANSWER_COLOR_GUI.indexOf(ctrlType+',') >= 0) { // formViewUtils.applyAnswerColorClass(properties, $this, ctrlType, ctrlPropreties); // } // // Apply AnswerColor + Shade Headings for element in table //if(!$this.parents('.ctrlTable').hasClass('useShadedRowColumn')){ formViewUtils.applyAnswerColorAndShading4TableElement(properties, $this, ctrlType, ctrlPropreties); //} } var hint = $this.find('.controlHint'); applyShadingAndButtonTextWACustomOptions($this, hint, properties, ctrlType); if(properties && properties.defaultValue && properties.defaultValue.value){ ctrlPropreties.defaultValue = properties.defaultValue.value; } //setTableRowNotEmptyClass($this, ctrlPropreties); }; /*****************************************************************************************************************/ /*End********************************************load data ctrl table*********************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************load data ctrl POD*********************************************/ /*****************************************************************************************************************/ function fillDataControlPODFV($this, ctrlType, properties, ctrlPropreties){ $this.data('odkControl-properties', properties); $this.data('odkControl-ctrlPropreties', ctrlPropreties); applyJustification($this, properties); fvDataNS.dataArray[ctrlPropreties.classPath] = ctrlPropreties; fvDataNS.ctrlArray[ctrlPropreties.classPath] = $this; if(fvDataNS.ctrlIdMap[ctrlPropreties.id] == undefined){ fvDataNS.ctrlIdMap[ctrlPropreties.id] = {}; } fvDataNS.ctrlIdMap[ctrlPropreties.id][ctrlPropreties.classPath] = ctrlPropreties.classPath; if(ctrlPropreties.skipByCtrls != undefined && ctrlPropreties.skipByCtrls.length > 0){ $this.addClass(CONST_CLASS_HIDE_CONTROL); }else{ if(ctrlPropreties.isCtrlHidden){ $this.addClass(CONST_CLASS_HIDE_CONTROL); }else{ $this.removeClass(CONST_CLASS_HIDE_CONTROL); } } if(properties.readOnly != undefined && properties.readOnly.value != undefined && properties.readOnly.value){ ctrlPropreties.readOnly = true; }else{ ctrlPropreties.readOnly = false; } if(isTurnOffSelectionOutline(properties)){ $this.addClass("TurnOffOutline"); } // The AnswerColor will be processed in function formViewUtils.applyAnswerColorClass() // if(properties.answerColor && properties.answerColor.value && properties.answerColor.value.isAnswerColor == true){ // $this.find('input, textarea').css('cssText', 'color: ' + (properties.answerColor.value.answerTextColor || LBL_DEFAULT_ANSWER_TEXT_COLOR) + ' !important'); // } /*fix bug 0027005: Calculation adds the hidden numeric value even though the relevance condition is not met*/ var parrentProperties = fvDataNS.dataArray[ctrlPropreties.parrentProperties]; if(isControlHidden(parrentProperties)){ ctrlPropreties.isParentCtrlHidden = true; } $this.find('.ctrlHref').attr('id', 'ctrlHref_' + ctrlPropreties.ctrlDataId); $this.find('.controlData').attr('id', 'ctrlDataId_' + ctrlPropreties.ctrlDataId); setControlSecurityOption(properties, $this); if(ctrlType == 'inputPageBreak'){ }else if(ctrlType == 'inputLabel'){ }else if(ctrlType == CONST_CTRL_TYPE_INPUT_TEXT){ fvEditorsPODInputText(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUT_NUMERIC){ fvEditorsPODInputNumeric(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTNEWPAYMENT){ }else if(ctrlType == CONST_CTRL_TYPE_INPUTTRENDS){ }else if(ctrlType == CONST_CTRL_TYPE_INPUTCOUNTER){ }else if(ctrlType == CONST_CTRL_TYPE_INPUTDATE){ }else if(ctrlType == CONST_CTRL_TYPE_INPUTSELECTONE){ fvEditorsPODInputSelectOne(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTSELECTMANY){ fvEditorsPODInputSelectMany(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTSCOREONE){ }else if(ctrlType == CONST_CTRL_TYPE_INPUTLOCATION){ }else if(ctrlType == CONST_CTRL_TYPE_INPUTBARCODE){ }else if(ctrlType == CONST_CTRL_TYPE_INPUTNFC){ }else if(ctrlType == mdi_kind_inputImage){ }else if(ctrlType == mdi_kind_inputAudio){ }else if(ctrlType == mdi_kind_inputVideo){ }else if(ctrlType == mdi_kind_inputSketch){ }else if(ctrlType == mdi_kind_inputSignature){ }else if(ctrlType == CONST_CTRL_TYPE_GROUP){ }else if(ctrlType == CONST_CTRL_TYPE_INPUTEMAILREPORT){ }else if(ctrlType == CONST_CTRL_TYPE_INPUTCALCULATE){ }else if(ctrlType == CONST_CTRL_TYPE_INPUTLOOKUP){ }else if(ctrlType == CONST_CTRL_TYPE_INPUTLFBLUETOOTH){ }else if(ctrlType == CONST_CTRL_TYPE_CTRLTABLE){ }else if(ctrlType == CONST_CTRL_TYPE_CTRLPOD){ }else if(ctrlType == CONST_CTRL_TYPE_INPUTACTION){ fvEditorsPODInputAction(properties, $this, ctrlType, ctrlPropreties); if(isVersion(VERSION_ACTION_BTN_AUTO_STAMP)){ if(properties.autoActionStampTrigger != undefined && properties.autoActionStampTrigger.value != '' && properties.autoActionStampTrigger.value != lbl_sel_question && properties.actionKind && CONST_TYPE_AUTO_RUN == properties.actionKind.value){ ctrlPropreties.autoActionStampTrigger = properties.autoActionStampTrigger.value; ctrlPropreties.autoActionStampQuestionTrigger = properties.autoActionStampQuestionTrigger.value; var autoStampTrigger = ctrlPropreties.autoActionStampTrigger; if(fvDataNS.autoStampTriggerMap[autoStampTrigger] == undefined){ fvDataNS.autoStampTriggerMap[autoStampTrigger] = {}; } switch(autoStampTrigger){ case CONST_WHEN_A_FIELD_IS_ENTERED : // Trigger when a specified question is answered if(properties.autoActionStampQuestionTrigger != undefined && properties.autoActionStampQuestionTrigger.value){ if(fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoActionStampQuestionTrigger.value] == undefined){ fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoActionStampQuestionTrigger.value] = {}; } fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoActionStampQuestionTrigger.value][ctrlPropreties.classPath] = false; } break; } } } }else if(ctrlType == CONST_CTRL_TYPE_IMAGE_VIEWER){ }else if(ctrlType == CONST_CTRL_TYPE_INPUTATTACHMENT){ } processBindingDestinationActionEvent(properties, ctrlPropreties); addToSkipList(ctrlPropreties); $this.attr('tabindex', 0).attr('classPath', ctrlPropreties.classPath); $this.click(function(event){ if(!event || event.cancelable == undefined){ // this is trigger event return; } if(!$(this).hasClass('ignore_focus')){ fvCtrlFocus(this, false); } }) .keydown(function(objEvent) { var keyCode = objEvent.keyCode || objEvent.which; if (keyCode == 9) { //tab pressed return toNextCtrl(this, objEvent, ctrlPropreties); }else if(isReadOnlyApply(properties) || (ctrlPropreties.ctrlType != CONST_CTRL_TYPE_INPUT_TEXT && ctrlPropreties.ctrlType != CONST_CTRL_TYPE_INPUTEMAILREPORT)){ return toNextCtrl(this, objEvent, ctrlPropreties); } }); if(isVersion(VERSION_5_0) && parseFloat(fvDataNS.currentForm.formVersion) >= 3.0){ //$this.find('input, textarea, select').blur(function(event) $this.blur(function(event) { executeSkipChange(ctrlPropreties); }); } $this.off('Skip_Relevance_Change_New').on('Skip_Relevance_Change_New', function(event, addToChangeList){ if(executeCalculateRelevanceConds(ctrlPropreties)){ if((ctrlType == CONST_CTRL_TYPE_INPUTLOOKUP || ctrlType == CONST_CTRL_TYPE_INPUTLFBLUETOOTH) && !ctrlPropreties.isCtrlHidden && ctrlPropreties.isCtrlHiddenChanged){ $this.find('.controlData input, .controlData textarea').trigger('changeDataSource'); } //$('.fvMainWrapper .fvWorkspace .fvCtrlID_' + ctrlPropreties.id).trigger('fvCtrlShowHideChange', addToChangeList); $this.trigger('fvCtrlShowHideChange', addToChangeList); } event.stopPropagation(); }); executeCalculateRelevanceConds(ctrlPropreties); $this.off('ReadOnlyIf_Change_New').on('ReadOnlyIf_Change_New', function(event, addToChangeList){ if(executeCalculateReadOnlyIfConds(ctrlPropreties)){ //$('.fvMainWrapper .fvWorkspace .fvCtrlID_' + ctrlPropreties.id).trigger('checkAndSetReadOnly'); $this.trigger('checkAndSetReadOnly'); } event.stopPropagation(); }); executeCalculateReadOnlyIfConds(ctrlPropreties); // Apply If .. Then .. Else in WebApps GUI if (isVersion(VERSION_IF_THEN_ELSE)) { $this.off('If_Then_Else_ChangeEvent').on('If_Then_Else_ChangeEvent', function(event, addToChangeList){ // Ignore process with question do not condition ifThenElseExpression if (ctrlPropreties.ifThenElseExpression && ctrlPropreties.ifThenElseExpression != '') { var iteValueCheck = calculateIfThenElseConds(ctrlPropreties.ifThenElseExpression, ctrlPropreties, fvDataNS.inputData); } event.stopPropagation(); }); } // Apply Shading and Button Text color (https://doforms.atlassian.net/browse/PCA-145) if (isVersion(VERSION_SHADINGS_AND_BUTTON_TEXT_WEB_APP)) { // Apply shading of button controls if (glbBuildFormSettingsWA.isButtonShades === true) { // Add the main class about shading $this.addClass('shadingButtonCtrlBackgrnd'); // Add the main class for color choosing $this.addClass('shadingButtonCtrlColorBackgrnd'); $this.attr('shadingButtonCtrlColorBackgrnd', CONST_VALUE_TRUE_STR); } } clearCtrlChange(ctrlPropreties); }; /*****************************************************************************************************************/ /*End********************************************load data ctrl pod*********************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************load data ctrl score table***************************************/ /*****************************************************************************************************************/ function fillDataControlScoreTableFV($this, ctrlType, properties, ctrlPropreties){ var isComment = false; if(ctrlPropreties.id != undefined && ctrlPropreties.id.toString().endsWith('__comment')){ $this.data('odkControl-properties-comment', properties); $this.data('odkControl-ctrlPropreties-comment', ctrlPropreties); isComment = true; }else{ $this.data('odkControl-properties', properties); $this.data('odkControl-ctrlPropreties', ctrlPropreties); applyJustification($this, properties); } fvDataNS.dataArray[ctrlPropreties.classPath] = ctrlPropreties; /*if(isVersion(VERSION_NEW_WEB_APP)){ addFormCtrl(fvDataNS.newFormInfo, $this, ctrlPropreties); }*/ fvDataNS.ctrlArray[ctrlPropreties.classPath] = $this; if(fvDataNS.ctrlIdMap[ctrlPropreties.id] == undefined){ fvDataNS.ctrlIdMap[ctrlPropreties.id] = {}; } fvDataNS.ctrlIdMap[ctrlPropreties.id][ctrlPropreties.classPath] = ctrlPropreties.classPath; if(ctrlPropreties.skipByCtrls != undefined && ctrlPropreties.skipByCtrls.length > 0){ $this.addClass(CONST_CLASS_HIDE_CONTROL); }else{ if(ctrlPropreties.isCtrlHidden){ $this.addClass(CONST_CLASS_HIDE_CONTROL); }else{ $this.removeClass(CONST_CLASS_HIDE_CONTROL); } } if(properties.readOnly != undefined && properties.readOnly.value != undefined && properties.readOnly.value){ ctrlPropreties.readOnly = true; }else{ ctrlPropreties.readOnly = false; } // The AnswerColor will be processed in function formViewUtils.applyAnswerColorClass() // if(properties.answerColor && properties.answerColor.value && properties.answerColor.value.isAnswerColor == true){ // $this.find('input, textarea').css('cssText', 'color: ' + (properties.answerColor.value.answerTextColor || LBL_DEFAULT_ANSWER_TEXT_COLOR) + ' !important'); // } /*fix bug 0027005: Calculation adds the hidden numeric value even though the relevance condition is not met*/ var parrentProperties = fvDataNS.dataArray[ctrlPropreties.parrentProperties]; if(isControlHidden(parrentProperties)){ ctrlPropreties.isParentCtrlHidden = true; } if(isTurnOffSelectionOutline(properties)){ $this.addClass("TurnOffOutline"); } $this.attr('id', 'ctrlDataId_' + ctrlPropreties.ctrlDataId); if(ctrlType == 'inputPageBreak'){ }else if(ctrlType == 'inputLabel'){ }else if(ctrlType == CONST_CTRL_TYPE_INPUT_TEXT){ }else if(ctrlType == CONST_CTRL_TYPE_INPUT_NUMERIC){ }else if(ctrlType == CONST_CTRL_TYPE_INPUTNEWPAYMENT){ }else if(ctrlType == CONST_CTRL_TYPE_INPUTNUMBERING){ }else if(ctrlType == CONST_CTRL_TYPE_INPUTTRENDS){ }else if(ctrlType == CONST_CTRL_TYPE_INPUTDATE){ }else if(ctrlType == CONST_CTRL_TYPE_INPUTSELECTONE){ fvEditorsScoreTableInputSelectOne(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTSELECTMANY){ fvEditorsScoreTableInputSelectMany(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTSCOREONE){ fvEditorsScoreTableInputScoreOne(properties, $this, ctrlType, ctrlPropreties); $('.formView .scoreSummary').trigger('appendScoreSummaryDataRow', properties.scoreCategory.value); if(getValueOrEmpty(ctrlPropreties.val) != ''){ var scoreDataRow = $('.scoreSummary .category_' + replaceNonAlphaNumericChar(ctrlPropreties.scoreCategory)); scoreDataRow.trigger('calculateDataChange', ctrlPropreties); } }else if(ctrlType == 'inputScoreTable_Comment'){ fvEditorsScoreTableInputScoreTable_Comment(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTLOCATION){ }else if(ctrlType == CONST_CTRL_TYPE_INPUTBARCODE){ }else if(ctrlType == mdi_kind_inputImage){ }else if(ctrlType == mdi_kind_inputAudio){ }else if(ctrlType == mdi_kind_inputVideo){ }else if(ctrlType == mdi_kind_inputSketch){ }else if(ctrlType == mdi_kind_inputSignature){ }else if(ctrlType == CONST_CTRL_TYPE_GROUP){ }else if(ctrlType == CONST_CTRL_TYPE_INPUTEMAILREPORT){ }else if(ctrlType == CONST_CTRL_TYPE_INPUTCALCULATE){ }else if(ctrlType == CONST_CTRL_TYPE_INPUTLOOKUP){ }else if(ctrlType == CONST_CTRL_TYPE_INPUTLFBLUETOOTH){ }else if(ctrlType == CONST_CTRL_TYPE_CTRLTABLE){ }else if(ctrlType == CONST_CTRL_TYPE_CTRLPOD){ }else if(ctrlType == CONST_CTRL_TYPE_IMAGE_VIEWER){ }else if(ctrlType == CONST_CTRL_TYPE_INPUTATTACHMENT){ } $this.find('.ctrlHref').attr('id', 'ctrlHref_' + ctrlPropreties.ctrlDataId); $this.attr('tabindex', 0).attr('classPath', ctrlPropreties.classPath); if(('' + ctrlPropreties.id).indexOf('__comment') >= 0){ return; }else{ $this.find('.select-able').focus(function(){ if(!fvDataNS.isExecuteControlChangeRunning){ setListCtrlDataChange(ctrlPropreties.classPath, false, ctrlPropreties.val); } if(!$this.hasClass('ignore_focus')){ fvCtrlFocus($this, false); } }).click(function(){ if(!$this.hasClass('ignore_focus')){ fvCtrlFocus($this, false); } }); $this.keydown(function(objEvent) { var keyCode = objEvent.keyCode || objEvent.which; if (keyCode == 9) { //tab pressed return toNextCtrl(this, objEvent, ctrlPropreties); }else if(isReadOnlyApply(properties) || (ctrlPropreties.ctrlType != CONST_CTRL_TYPE_INPUT_TEXT && ctrlPropreties.ctrlType != CONST_CTRL_TYPE_INPUTEMAILREPORT)){ var tmpCtrl = $(this).find('td div.ctrlScoreTable_comment textarea'); if(tmpCtrl.length <= 0 || !tmpCtrl.is(':focus')){ return toNextCtrl(this, objEvent, ctrlPropreties); } } }); } processBindingDestinationActionEvent(properties, ctrlPropreties); addToSkipList(ctrlPropreties); if(isVersion(VERSION_5_0) && parseFloat(fvDataNS.currentForm.formVersion) >= 3.0){ //$this.find('input, textarea, select').blur(function(event) $this.blur(function(event) { executeSkipChange(ctrlPropreties); }); } $this.off('Skip_Relevance_Change_New').on('Skip_Relevance_Change_New', function(event, addToChangeList){ if(executeCalculateRelevanceConds(ctrlPropreties)){ if((ctrlType == CONST_CTRL_TYPE_INPUTLOOKUP || ctrlType == CONST_CTRL_TYPE_INPUTLFBLUETOOTH) && !ctrlPropreties.isCtrlHidden && ctrlPropreties.isCtrlHiddenChanged){ $this.find('.controlData input, .controlData textarea').trigger('changeDataSource'); } $('.fvMainWrapper .fvWorkspace .fvCtrlID_' + ctrlPropreties.id).trigger('fvCtrlShowHideChange', addToChangeList); $('.fvMainWrapper .fvWorkspace .fvCtrlID_' + ctrlPropreties.id + '__comment').trigger('fvCtrlShowHideChange', ctrlPropreties.isCtrlHidden); } event.stopPropagation(); }); executeCalculateRelevanceConds(ctrlPropreties); $this.off('ReadOnlyIf_Change_New').on('ReadOnlyIf_Change_New', function(event, addToChangeList){ if(executeCalculateReadOnlyIfConds(ctrlPropreties)){ $('.fvMainWrapper .fvWorkspace .fvCtrlID_' + ctrlPropreties.id).trigger('checkAndSetReadOnly'); $('.fvMainWrapper .fvWorkspace .fvCtrlID_' + ctrlPropreties.id + '__comment').trigger('checkAndSetReadOnly'); } event.stopPropagation(); }); executeCalculateReadOnlyIfConds(ctrlPropreties); // Apply If .. Then .. Else in WebApps GUI if (isVersion(VERSION_IF_THEN_ELSE)) { $this.off('If_Then_Else_ChangeEvent').on('If_Then_Else_ChangeEvent', function(event, addToChangeList){ // Ignore process with question do not condition ifThenElseExpression if (ctrlPropreties.ifThenElseExpression && ctrlPropreties.ifThenElseExpression != '') { var iteValueCheck = calculateIfThenElseConds(ctrlPropreties.ifThenElseExpression, ctrlPropreties, fvDataNS.inputData); //console.log('iteValueCheck 4 : ' + iteValueCheck); } event.stopPropagation(); }); } // Apply Shading and Button Text color (https://doforms.atlassian.net/browse/PCA-145) if (isVersion(VERSION_SHADINGS_AND_BUTTON_TEXT_WEB_APP)) { // Apply shading of button controls if (glbBuildFormSettingsWA.isButtonShades === true) { // Add the main class about shading $this.addClass('shadingButtonCtrlBackgrnd'); // Add the main class for color choosing $this.addClass('shadingButtonCtrlColorBackgrnd'); $this.attr('shadingButtonCtrlColorBackgrnd', CONST_VALUE_TRUE_STR); } } clearCtrlChange(ctrlPropreties); }; /*****************************************************************************************************************/ /*End********************************************load data ctrl score table***************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************load data ctrl Grid**********************************************/ /*****************************************************************************************************************/ var GRID_CONTROL_APPLY_REMOVE_BORDER_ANSWER = ''; //Ignore Label/Dummy Label/inputAction in []Remove border around answer var GRID_CONTROL_NOT_APPLY_REMOVE_BORDER_ANSWER = 'inputLabel,inputAction,'; function fillDataControlGridFV($this, ctrlType, properties, ctrlPropreties){ $this.data('odkControl-properties', properties); $this.data('odkControl-ctrlPropreties', ctrlPropreties); applyJustification($this, properties); fvDataNS.dataArray[ctrlPropreties.classPath] = ctrlPropreties; if(ctrlPropreties.parrentProperties != CONST_DATA){ var tmp = ctrlPropreties.classPath.replace(CONST_SPACE + ctrlPropreties.parentName + CONST_SPACE, CONST_SPACE); if(tmp != ctrlPropreties.classPath){ fvDataNS.dataArray[tmp] = ctrlPropreties; } } /*if(isVersion(VERSION_NEW_WEB_APP)){ addFormCtrl(fvDataNS.newFormInfo, $this, ctrlPropreties); }*/ fvDataNS.ctrlArray[ctrlPropreties.classPath] = $this; if(fvDataNS.ctrlIdMap[ctrlPropreties.id] == undefined){ fvDataNS.ctrlIdMap[ctrlPropreties.id] = {}; } fvDataNS.ctrlIdMap[ctrlPropreties.id][ctrlPropreties.classPath] = ctrlPropreties.classPath; if(ctrlPropreties.skipByCtrls != undefined && ctrlPropreties.skipByCtrls.length > 0){ $this.addClass(CONST_CLASS_HIDE_CONTROL); }else{ if(ctrlPropreties.isCtrlHidden){ $this.addClass(CONST_CLASS_HIDE_CONTROL); }else{ $this.removeClass(CONST_CLASS_HIDE_CONTROL); } } if(properties.readOnly != undefined && properties.readOnly.value != undefined && properties.readOnly.value){ ctrlPropreties.readOnly = true; }else{ ctrlPropreties.readOnly = false; } // The AnswerColor will be processed in function formViewUtils.applyAnswerColorClass() // if (properties.apperance && properties.apperance.value === LABEL_CONSTANTS_VALUE_OPTION_BUILD_FORM_APPEARANCE_CUSTOM) { // if(properties.answerColor && properties.answerColor.value && properties.answerColor.value.isAnswerColor == true){ // $this.find('input, textarea').css('cssText', 'color: ' + (properties.answerColor.value.answerTextColor || LBL_DEFAULT_ANSWER_TEXT_COLOR) + ' !important'); // } // } /*fix bug 0027005: Calculation adds the hidden numeric value even though the relevance condition is not met*/ var parrentProperties = fvDataNS.dataArray[ctrlPropreties.parrentProperties]; if(isControlHidden(parrentProperties)){ ctrlPropreties.isParentCtrlHidden = true; } var cellClass = "gridCell_" + ctrlPropreties.row + '_' + ctrlPropreties.col; $this.addClass(cellClass); $this.find('.ctrlHref').attr('id', 'ctrlHref_' + ctrlPropreties.ctrlDataId); $this.find('.controlData').attr('id', 'ctrlDataId_' + ctrlPropreties.ctrlDataId); // Fix error on Firefox, // Issue : Fwd: Skype Tonight (Thu, 21 Jul 2016) // 10.) Check form bug “Order Form FS 5” in doForms demo account $this.parent().addClass('haveBorder4GridCell'); if(isTurnOffSelectionOutline(properties)){ $this.parent().addClass("TurnOffOutline"); } setControlSecurityOption(properties, $this); if(ctrlType == 'inputPageBreak'){ }else if(ctrlType == 'inputLabel'){ fvEditorsGridInputLabel(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUT_TEXT){ fvEditorsGridInputText(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUT_NUMERIC){ fvEditorsGridInputNumeric(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTNEWPAYMENT){ fvEditorsGridInputNewPayment(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTNUMBERING){ fvEditorsGridInputNumbering(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTTRENDS){ fvEditorsGridInputTrends(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTCOUNTER){ fvEditorsGridInputCounter(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTDATE){ if(isVersion(VERSION_ALLOW_EDIT_OPT)){ if(properties.isAllowEdit.value == undefined){ properties.isAllowEdit.value = true; } if(properties.isAllowEdit && properties.isAllowEdit.value){ ctrlPropreties.isAllowEdit = properties.isAllowEdit.value; } } fvEditorsGridInputDate(properties, $this, ctrlType, ctrlPropreties); if(properties.autoStamp != undefined && properties.autoStamp.value){ ctrlPropreties.autoStamp = true; }else{ ctrlPropreties.autoStamp = false; } if(ctrlPropreties.autoStamp && properties.autoStampTrigger != undefined && properties.autoStampTrigger.value){ var autoStampTrigger = properties.autoStampTrigger.value; ctrlPropreties.autoStampTrigger = autoStampTrigger; if(fvDataNS.autoStampTriggerMap[autoStampTrigger] == undefined){ fvDataNS.autoStampTriggerMap[autoStampTrigger] = {}; } if(autoStampTrigger == '2'){ // Trigger when a specified question is answered for the first time if(properties.autoStampTrigger2Ques != undefined && properties.autoStampTrigger2Ques.value){ if(fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoStampTrigger2Ques.value] == undefined){ fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoStampTrigger2Ques.value] = {}; } if(!fvDataNS.isLoading){ fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoStampTrigger2Ques.value][ctrlPropreties.classPath] = false; }else{ var itemProperties = getPropertiesByID(properties.autoStampTrigger2Ques.value); if(itemProperties != undefined){ if(isEditLoading() && (itemProperties.val || '') != ''){ fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoStampTrigger2Ques.value][ctrlPropreties.classPath] = true; }else{ fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoStampTrigger2Ques.value][ctrlPropreties.classPath] = false; } }else{ fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoStampTrigger2Ques.value][ctrlPropreties.classPath] = false; } } } }else if(autoStampTrigger == '4'){ // Trigger when a specified page is displayed for the first time if(properties.autoStampTrigger4Ques != undefined && properties.autoStampTrigger4Ques.value){ if(fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoStampTrigger4Ques.value] == undefined){ fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoStampTrigger4Ques.value] = {}; } fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoStampTrigger4Ques.value][ctrlPropreties.classPath] = false; } }else if(autoStampTrigger == '8'){ // Trigger when the form is opened for the first var isTrigger = true; if(fvDataNS.incomplete){ isTrigger = false; } if(fvDataNS.currentForm.editRecordData){ isTrigger = false; } if(ctrlPropreties.skipByCtrls != undefined && ctrlPropreties.skipByCtrls.length > 0){ isTrigger = false; }else{ if(ctrlPropreties.isCtrlHidden){ isTrigger = false; } } if($this.parents('.hideControl').length > 0){ isTrigger = false; } if(getValueOrEmpty(ctrlPropreties.val) != '' && !ctrlPropreties.isAllowEdit){ isTrigger = false; } if(isTrigger){ fvDataNS.autoStampTriggerMap[autoStampTrigger][ctrlPropreties.classPath] = false; //$this.find('.controlData input').trigger('setAutoStamp'); } }else if(autoStampTrigger == '16'){ // Trigger when the form is saved as complete fvDataNS.autoStampTriggerMap[autoStampTrigger][ctrlPropreties.classPath] = false; } } }else if(ctrlType == CONST_CTRL_TYPE_INPUTSELECTONE){ fvEditorsGridInputSelectOne(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTSELECTMANY){ fvEditorsGridInputSelectMany(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTSCOREONE){ fvEditorsGridInputScoreOne(properties, $this, ctrlType, ctrlPropreties); $('.formView .scoreSummary').trigger('appendScoreSummaryDataRow', properties.scoreCategory.value); if(getValueOrEmpty(ctrlPropreties.val) != ''){ var scoreDataRow = $('.scoreSummary .category_' + replaceNonAlphaNumericChar(ctrlPropreties.scoreCategory)); scoreDataRow.trigger('calculateDataChange', ctrlPropreties); } }else if(ctrlType == 'inputScoreTable_Comment'){ }else if(ctrlType == CONST_CTRL_TYPE_INPUTLOCATION){ fvEditorsGridInputLocation(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTBARCODE){ fvEditorsGridInputBarcode(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTNFC){ fvEditorsGridInputNFC(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == mdi_kind_inputImage){ fvEditorsGridInputImage(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_IMAGE_VIEWER){ fvEditorsGridInputImageViewer(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTATTACHMENT){ fvEditorsGridInputAttachment(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == mdi_kind_inputAudio){ }else if(ctrlType == mdi_kind_inputVideo){ }else if(ctrlType == mdi_kind_inputSketch){ }else if(ctrlType == mdi_kind_inputSignature){ fvEditorsGridInputSignature(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_GROUP){ }else if(ctrlType == CONST_CTRL_TYPE_INPUTEMAILREPORT){ }else if(ctrlType == CONST_CTRL_TYPE_INPUTCALCULATE){ fvEditorsGridInputCalculate(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTLOOKUP){ fvEditorsGridInputLookup(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_INPUTLFBLUETOOTH){ fvEditorsGridInputLFBluetooth(properties, $this, ctrlType, ctrlPropreties); }else if(ctrlType == CONST_CTRL_TYPE_CTRLTABLE){ }else if(ctrlType == CONST_CTRL_TYPE_CTRLPOD){ }else if(ctrlType == CONST_CTRL_TYPE_INPUTACTION){ fvEditorsGridInputAction(properties, $this, ctrlType, ctrlPropreties); if(isVersion(VERSION_ACTION_BTN_AUTO_STAMP)){ if(properties.autoActionStampTrigger != undefined && properties.autoActionStampTrigger.value != '' && properties.autoActionStampTrigger.value != lbl_sel_question && properties.actionKind && CONST_TYPE_AUTO_RUN == properties.actionKind.value){ ctrlPropreties.autoActionStampTrigger = properties.autoActionStampTrigger.value; ctrlPropreties.autoActionStampQuestionTrigger = properties.autoActionStampQuestionTrigger.value; var autoStampTrigger = ctrlPropreties.autoActionStampTrigger; if(fvDataNS.autoStampTriggerMap[autoStampTrigger] == undefined){ fvDataNS.autoStampTriggerMap[autoStampTrigger] = {}; } switch(autoStampTrigger){ case CONST_WHEN_A_FIELD_IS_ENTERED : // Trigger when a specified question is answered if(properties.autoActionStampQuestionTrigger != undefined && properties.autoActionStampQuestionTrigger.value){ if(fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoActionStampQuestionTrigger.value] == undefined){ fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoActionStampQuestionTrigger.value] = {}; } fvDataNS.autoStampTriggerMap[autoStampTrigger][properties.autoActionStampQuestionTrigger.value][ctrlPropreties.classPath] = false; } break; } } } }else if(ctrlType == CONST_CTRL_TYPE_INPUTPAYMENT){ fvEditorsGridInputPayment(properties, $this, ctrlType, ctrlPropreties); } processBindingDestinationActionEvent(properties, ctrlPropreties); addToSkipList(ctrlPropreties); // Apply []Remove border around answer if (isVersion(VERSION_REMOVE_ANSW_BORDER)) { //if (GRID_CONTROL_APPLY_REMOVE_BORDER_ANSWER.indexOf(ctrlType) >= 0) // Ignore Label/Dummy Label/inputAction if (GRID_CONTROL_NOT_APPLY_REMOVE_BORDER_ANSWER.indexOf(ctrlType+',') < 0) { // if (properties.removeAnswerBorder !== undefined // && properties.removeAnswerBorder.value === true) { // // Apply remove answer // $this.parent().addClass('removeBorderAroundAnswer'); // } formViewUtils.applyRemoveBorderAroundAnswerGRID(properties, $this, ctrlType, ctrlPropreties); } } // Process Answer Color for Web forms GUI if (isVersion(VERSION_ANSWER_COLOR)) { if (CONTROL_APPLY_ANSWER_COLOR_GUI.indexOf(ctrlType+',') >= 0) { formViewUtils.applyAnswerColorClass(properties, $this, ctrlType, ctrlPropreties); } } $this.attr('tabindex', 0).attr('classPath', ctrlPropreties.classPath); $this.click(function(event){ if(!event || event.cancelable == undefined){ // this is trigger event return; } if(!$(this).hasClass('ignore_focus')){ fvCtrlFocus(this, false); } }) .keydown(function(objEvent) { var keyCode = objEvent.keyCode || objEvent.which; if (keyCode == 9) { //tab pressed return toNextCtrl(this, objEvent, ctrlPropreties); }else if(isReadOnlyApply(properties) || (ctrlPropreties.ctrlType != CONST_CTRL_TYPE_INPUT_TEXT && ctrlPropreties.ctrlType != CONST_CTRL_TYPE_INPUTEMAILREPORT)){ return toNextCtrl(this, objEvent, ctrlPropreties); } }); if(isVersion(VERSION_5_0) && parseFloat(fvDataNS.currentForm.formVersion) >= 3.0){ //$this.find('input, textarea, select').blur(function(event) $this.blur(function(event) { executeSkipChange(ctrlPropreties); }); } $this.off('Skip_Relevance_Change_New').on('Skip_Relevance_Change_New', function(event, addToChangeList){ if(executeCalculateRelevanceConds(ctrlPropreties)){ if((ctrlType == CONST_CTRL_TYPE_INPUTLOOKUP || ctrlType == CONST_CTRL_TYPE_INPUTLFBLUETOOTH) && !ctrlPropreties.isCtrlHidden && ctrlPropreties.isCtrlHiddenChanged){ $this.find('.controlData input, .controlData textarea').trigger('changeDataSource'); } //$('.fvMainWrapper .fvWorkspace .fvCtrlID_' + ctrlPropreties.id).trigger('fvCtrlShowHideChange', addToChangeList); $this.trigger('fvCtrlShowHideChange', addToChangeList); } executeCalculateHideIfConds(ctrlPropreties); event.stopPropagation(); }); executeCalculateRelevanceConds(ctrlPropreties); // CO-4022: Hide if if(properties.hideIfFields){ // properties.hideIfCmpVal ctrlPropreties.hideIfCmpVal = properties.hideIfCmpVal; ctrlPropreties.hideIfFields = properties.hideIfFields; addToCtrlIdRefForHideIf(ctrlPropreties.hideIfFields.value, ctrlPropreties.id); } $this.off('ReadOnlyIf_Change_New').on('ReadOnlyIf_Change_New', function(event, addToChangeList){ if(executeCalculateReadOnlyIfConds(ctrlPropreties)){ //$('.fvMainWrapper .fvWorkspace .fvCtrlID_' + ctrlPropreties.id).trigger('checkAndSetReadOnly'); $this.trigger('checkAndSetReadOnly'); } event.stopPropagation(); }); executeCalculateReadOnlyIfConds(ctrlPropreties); // Apply If .. Then .. Else in WebApps GUI if (isVersion(VERSION_IF_THEN_ELSE)) { $this.off('If_Then_Else_ChangeEvent').on('If_Then_Else_ChangeEvent', function(event, addToChangeList){ // Ignore process with question do not condition ifThenElseExpression if (ctrlPropreties.ifThenElseExpression && ctrlPropreties.ifThenElseExpression != '' && (!ctrlPropreties.isParentCtrlHidden && !isControlHidden(ctrlPropreties))) { var iteValueCheck = calculateIfThenElseConds(ctrlPropreties.ifThenElseExpression, ctrlPropreties, fvDataNS.inputData); //console.log('iteValueCheck 5 : ' + iteValueCheck); } event.stopPropagation(); }); } // Apply Shading and Button Text color (https://doforms.atlassian.net/browse/PCA-145) if (isVersion(VERSION_SHADINGS_AND_BUTTON_TEXT_WEB_APP)) { // // 0025944: image text of Action button does not show // Apply shading of button controls if (glbBuildFormSettingsWA.isButtonShades === true) { // Add the main class about shading $this.addClass('shadingButtonCtrlBackgrnd'); // Add the main class for color choosing $this.addClass('shadingButtonCtrlColorBackgrnd'); $this.attr('shadingButtonCtrlColorBackgrnd', CONST_VALUE_TRUE_STR); // CO-3718, 3502 if(properties.ofRequired && '2' === properties.ofRequired.value //&& '2' === properties.ofSource.value && getParent().dispatchFlg == true){ $this.parent().css('vertical-align', 'top'); $this.addClass('shadingControlBackground'); $this.find('.controlLabel').attr('style', 'cursor: default; font-weight: bold !important'); } } var hint = $this.find('.controlHint'); // 0025944: image text of Action button does not show //applyShadingAndButtonTextWACustomOptions($this, hint, properties, ctrlType); applyButtonTextWACustomOptionsOnly($this, hint, properties, ctrlType); } clearCtrlChange(ctrlPropreties); }; /** * Adjust layout of Image/Button in Signature of Table/Grid * @param $control * @author tdchien * @since 24-Feb-2016 */ function adjustLayoutOfImageAndButtonInSignature($control, controlStructure) { var objTableCell = $control.parent(); // Default use Pointer objTableCell.css('cursor', 'pointer'); // Check if the control has []One-Time Signature Capture or not var objImage = $control.find('.imageOfSignatureCustom'); var objButton= $control.find('.buttonOfSignatureCustom'); // Process when image exist or not var isEditMode = false; var objImageCheck = objImage.find('img').first(); var urlImage = objImageCheck.attr('src'); // Check URL of image if (urlImage && urlImage !== null && urlImage !== '') { // Have image <=> edit mode isEditMode = true; // Force the color of cell into WHITE var cellObject = objImage.parentsUntil('td').last().parent(); var styleCss = cellObject.attr('style'); if (!styleCss || styleCss === null) { styleCss = ' background: white !important;'; } else { styleCss += '; background: white !important;'; } // Adjust style CSS again ... cellObject.attr('style', styleCss); cellObject.addClass('forceSignatureBackgroundColor'); } // Get current column width //var objColumn = $control.parentsUntil('td').last().parent(); var columnWidth = $control.width(); var columnHeight = $control.height(); //writeToLogInfo('columnWidth : ' + columnWidth + ' >> class : ' + $control.attr('class')); var maxWidthStr = ''; var maxHeightStr = ''; // With all cases, we will remove class noImage objImageCheck.removeClass(CONST_CLASS_NO_IMAGE); // Add case <=> Hide image + Button Sign 100% if (isEditMode === false) { objImage.hide(); objButton.show(); objButton.attr('style', 'width:100% !important'); } else { var isAllowEditOption = true; // Check flag : isAllowEditOption if (controlStructure && controlStructure.isAllowEditOption !== undefined && controlStructure.isAllowEditOption.value !== undefined ) { isAllowEditOption = controlStructure.isAllowEditOption.value; } else if (controlStructure && controlStructure.isOneTimeSignatureCapture && controlStructure.isOneTimeSignatureCapture.value === true) { // Get data from isOneTimeSignatureCapture isAllowEditOption = false; } // Edit Mode, process based on other settings if (isAllowEditOption === false) { // Hide button because we don't need it more. maxWidthStr = 'max-width: ' + (columnWidth - 8) + 'px !important;'; objImage.show(); objButton.remove(); // Set normal curspor for current cell objTableCell.css('cursor', 'default'); $control.css('cursor', 'default'); // Remove event fancy box $control.off('click.fb'); } else { // Remove the class edit mode objImage.addClass('editMode'); objButton.addClass('editMode'); //maxWidthStr = 'max-width: ' + (columnWidth - 57) + 'px !important;'; maxWidthStr = 'max-width: ' + (columnWidth - 47) + 'px !important;'; //objButton.attr('style', 'width:30px !important'); objImage.show(); objButton.show(); } // Setting width for Image // Process Size option if (objImageCheck.hasClass('LargeImageOfSignature')) { // Setting height of current signature maxHeightStr = 'max-height:44px !important;'; } else { maxHeightStr = 'max-height:28px !important;'; } objImage.attr('style', 'padding-top: 2px !important;'); // 0027038: Signature displays not good when signing near the bottom of signature popup // Special treating with Signature inside Grid // ctrlGrid_inputSignature var styleHeight = maxWidthStr + maxHeightStr + 'height: ' + columnHeight + 'px !important;'; if (objTableCell.find('.ctrlGrid_inputSignature.inputSignature').length > 0) { var objNoImageView = objTableCell.find('.imageOfSignatureCustom img.noImage'); if (objNoImageView.length <= 0) { styleHeight = maxWidthStr + maxHeightStr + ' margin-bottom:6px !important;'; } } //objImageCheck.attr('style', maxWidthStr + maxHeightStr + 'height: ' + columnHeight + 'px !important;'); objImageCheck.attr('style', styleHeight); // 0026687: Signature in Grid/Table: layout is not good if Allow edit option is unchecked and draw at the lowest point if (isAllowEditOption === false) { // Only process in Grid if ($control.hasClass('ctrlGrid_inputSignature')) { //objImage.attr('style', 'margin-top: -6px; margin-bottom: -7px;'); objImage.attr('style', 'margin-top: 1px; margin-bottom: 1px;'); objImage.removeClass('btn_contain').addClass('btn_contain_DELETE'); } } // Special treating with Grid // if (isEditMode === true && objImage.hasClass('editMode') // && $control.hasClass('ctrlGrid_inputSignature')) { // // Calculate the width of controlDataWrapper // //var totalWidth = objImage.outerWidth() + objButton.outerWidth(); // //writeToLogInfo('totalWidth : ' + totalWidth); // //$control.find('.controlDataWrapper').height(columnHeight); // } } } /** * Process size options (Small/Large) of Signature inside Grid/Table * @param $control * @param controlStructure * @author tdchien * @since 24-Feb-2016 */ function adjustSizeOptions4SignatureInGridTable($control, controlStructure) { var sizeOptions = 'Small'; if (controlStructure.sizeOptions && controlStructure.sizeOptions.value === 'Large') { sizeOptions = 'Large'; } if (sizeOptions === 'Large') { $control.find('.imageOfSignatureCustom img').addClass('LargeImageOfSignature'); // Sign button region $control.find('.signButton4SignatureRegion').addClass('LargeImageOfSignature'); } if ($control.hasClass('ctrlGrid_inputSignature')) { $control.parent().css('vertical-align', 'middle'); } } /** * Adjust for option []Allow edit of Signature outside * @param $control * @author tdchien * @since 03-Mar-2016 */ function adjustSignatureOutside4AllowEdit($control, controlStructure) { var objTableCell = $control.parent(); // Default use Pointer //objTableCell.css('cursor', 'pointer'); var objImage = $control.find('#img_uploadDataLink'); if (objImage.hasClass(CONST_CLASS_NO_IMAGE)) { // Do nothing return; } var isAllowEditOption = true; // Check flag : isAllowEditOption if (controlStructure && controlStructure.isAllowEditOption !== undefined && controlStructure.isAllowEditOption.value !== undefined ) { isAllowEditOption = controlStructure.isAllowEditOption.value; } else if (controlStructure && controlStructure.isOneTimeSignatureCapture && controlStructure.isOneTimeSignatureCapture.value === true) { // Get data from isOneTimeSignatureCapture isAllowEditOption = false; } // Edit Mode + []Allow edit // if (controlStructure // && controlStructure.isOneTimeSignatureCapture // && controlStructure.isOneTimeSignatureCapture.value === true) { if (isAllowEditOption === false) { var urlImage = objImage.attr('src'); // Check URL of image if (urlImage && urlImage !== null && urlImage !== '') { // Remove button [Edit], [Clear] $control.find('.signButton4Signature,.clearImgBtn').hide(); // Create the border bottom of Signature layout $control.find('.controlData').css('border-bottom', '1px solid ' + FORMVIEW_BORDER_COLOR); // Set normal curspor for current cell var btnSign = $control.find('.controlData #btn_contain a.signButton4Signature'); var regOmageContain = $control.find('.controlData .imageContain'); // Use all control for fancy box regOmageContain.add(btnSign).css('cursor', 'default') .off('click.fb'); } } } /** * Adjust for option Display > []Clear button * @param $control * @author tdchien * @since 03-Mar-2016 */ function adjustImage4ShowClearButton($control, controlStructure) { // Apply change request email : Fwd: RE: on clear in image (3/5/2016 7:34 AM) // Always show Clear button in Build Forms for Images /* var isShowClearBtn = false; // Edit Mode + []Allow edit if (controlStructure && controlStructure.dispClearBtn && controlStructure.dispClearBtn.value === true) { isShowClearBtn = true; } // Remove button [Clear] if needed if (isShowClearBtn === false) { var objClearBtn = $control.find('.clearImgBtn'); var styleCss = objClearBtn.attr('style'); if (!styleCss || styleCss === null) { styleCss = 'display:none !important;'; } else { styleCss += '; display:none !important; '; } objClearBtn.attr('style', styleCss); } */ } /*****************************************************************************************************************/ /*End********************************************load data ctrl Grid**********************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************inputPageBreak***************************************************/ /*****************************************************************************************************************/ var fvEditorsInputPageBreak = function($parent, $control, ctrlType, ctrlPropreties){ // label var label = getValueOrEmpty($parent.label.value.eng); if(label == ''){ label = $('.fvWorkspace .inputPageBreak').length + 1; } if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } // Expand page in Web App if($parent.autoExpandPageWA != undefined && $parent.autoExpandPageWA.value == true){ $control.find('.hideShowDetailBtn').removeClass('showDetailBtn').addClass('hideDetailBtn'); $control.find('.fvPageDetail').removeClass('hidePageDetail'); }else{ $control.find('.fvPageDetail').addClass('hidePageDetail'); } $control.find('.controlLabel').empty().append(label); $control.find('.pageBreak').click(function(event){ hideShowDetailBtnClick($control); }); // hideInMobile $control.off('checkAndSetHide').on('checkAndSetHide', function() { execShowHideWebAppControl($control, $parent) }); $control.trigger('checkAndSetHide'); //if(isTabletPreview){ if($('.fvWorkspace .inputPageBreak.page-active').length == 0){ if(!$control.hasClass(CONST_CLASS_HIDE_CONTROL) && !$control.hasClass(CONST_HIDEONMOBILEAPP)){ $control.addClass('page-active'); //$('#pageMenuIcon').removeClass(CONST_CSS_CLASS_HIDE_SESSION); //$('.pageMenuIconText').removeClass(CONST_CSS_CLASS_HIDE_SESSION); } } //} // relevanceconds addToCtrlIdRefForRelevance($parent.isShowRelevanceCondition, $parent.relevanceconds.value, ctrlPropreties.classPath); ctrlPropreties.relevancecondsExpression = relevancecondsToExpression($parent.id, $parent.isShowRelevanceCondition, $parent.relevanceconds); } /*****************************************************************************************************************/ /*End********************************************inputPageBreak***************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************inputLabel*******************************************************/ /*****************************************************************************************************************/ var fvEditorsInputLabel = function($parent, $control, ctrlType, ctrlPropreties){ // hintLink ctrlPropreties.hintLink = $parent.hintLink.value; if($parent.hintLink.value == undefined || $parent.hintLink.value == ''){ $control.find('.controlInfo .controlImage').addClass(CONST_CLASS_HIDE_CONTROL); }else{ var isFitToScreen = false; if(isVersion(VERSION_LABEL_FIT_SCREEN)){ if($parent.isFitToScreen && $parent.isFitToScreen.value){ $control.find('.controlInfo .controlImage img').css('width', '100%'); isFitToScreen = true; } } if($parent.hintLink.value.indexOf('/imageViewer?blobKey=') >= 0){ if(!isFitToScreen){ $control.find('.controlInfo img').attr('src', $parent.hintLink.value + "&maxWidth=" + fvDataNS.ctrlWidth); $control.find('.controlInfo img').off('orientationchange').on('orientationchange', function(){ $(this).attr('src', $parent.hintLink.value + "&maxWidth=" + fvDataNS.ctrlWidth); }); }else{ $control.find('.controlInfo img').attr('src', $parent.hintLink.value); } }else{ if(!isFitToScreen){ $control.find('.controlInfo img').attr('src', $parent.hintLink.value + "&maxWidth=" + fvDataNS.ctrlWidth); $control.find('.controlInfo img').off('orientationchange').on('orientationchange', function(){ $(this).attr('src', $parent.hintLink.value + "&maxWidth=" + fvDataNS.ctrlWidth); }); }else{ $control.find('.controlInfo img').attr('src', $parent.hintLink.value); } } // Fix issue : Invalid space height in Label Image if ($parent.hintLink.value !== '') { $control.addClass('removeMinHeightDefault'); } else { $control.removeClass('removeMinHeightDefault'); } } if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } // label // Fix 0025734: Label - Shading doesnt' work in case Don't input value into Caption and Hint or Image on Build Form var labelCaptionVal = getValueOrEmpty($parent.label.value.eng); $control.find('.controlLabel').empty().append(removeUnsupportHTML(labelCaptionVal)); // hint // Fix 0025734: Label - Shading doesnt' work in case Don't input value into Caption and Hint or Image on Build Form var labelHintVal = getValueOrEmpty($parent.hint.value.eng); $control.find('.controlHint').empty().append(removeUnsupportHTML(labelHintVal)); if(labelCaptionVal == '' && labelHintVal == ''){ if(!($parent.hintLink.value == undefined || $parent.hintLink.value == '')){ $control.find('.controlInfo .textInfo').addClass(CONST_CSS_CLASS_HIDE_SESSION); } $control.find('.controlImage').css('padding-top', '0px'); } // Fix 0025734: Label - Shading doesnt' work in case Don't input value into Caption and Hint or Image on Build Form var objCntrlLabel = $control.find('.controlLabel'); if((labelCaptionVal) == '' && (labelHintVal) == ''){ labelCaptionVal = ' '; objCntrlLabel.empty().append(removeUnsupportHTML(labelCaptionVal)); } // Add padding-top for Label Caption (if needed) if (labelCaptionVal != '') { var styleOfCtrlLbl = objCntrlLabel.attr('style').toString(); // Fix customer's ticket : Refrigerant activity report is not centered in the colored bar top to bottom. Please fix asap. // (Thu, 10 Dec 2015 23:33:55 +0700) objCntrlLabel.attr('style', styleOfCtrlLbl + '; padding-top:6px !important; '); } if((labelCaptionVal) == '' && (labelHintVal) == ''){ $control.find('.textInfo').empty(); $control.find('.controlImage').addClass('clear-padding-top'); } // imgJustify if($parent.imgJustify.value == undefined || $parent.imgJustify.value == 'Center'){ $control.find('.controlLabel').addClass('controlTextCenter'); $control.find('.controlHint').addClass('controlTextCenter'); // $control.find('.controlInfo .controlImage img').addClass('imgJustifyCenter'); // CO-2725 remove }else if($parent.imgJustify.value != undefined && $parent.imgJustify.value == 'Right'){ $control.find('.controlLabel').addClass('controlTextRight'); $control.find('.controlHint').addClass('controlTextRight'); // $control.find('.controlInfo .controlImage img').addClass('imgJustifyRight'); // CO-2725 remove }else{ $control.find('.controlLabel').addClass('controlTextLeft'); $control.find('.controlHint').addClass('controlTextLeft'); // $control.find('.controlInfo .controlImage img').addClass('imgJustifyLeft'); // CO-2725 remove } // START CO-2725 $control.find('.controlInfo .controlImage img').addClass('imgJustifyLeft'); // Default | always left if($parent.justificationImage && $parent.justificationImage.value) { if($parent.justificationImage.value == '1') { $control.find('.controlInfo .controlImage img').addClass('imgJustifyCenter'); } else if($parent.justificationImage.value == '2') { $control.find('.controlInfo .controlImage img').addClass('imgJustifyRight'); } } // END CO-2725 // hideInMobile $control.off('checkAndSetHide').on('checkAndSetHide', function() { execShowHideWebAppControl($control, $parent, true); }); $control.trigger('checkAndSetHide'); // relevanceconds addToCtrlIdRefForRelevance($parent.isShowRelevanceCondition, $parent.relevanceconds.value, ctrlPropreties.classPath); if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath); } ctrlPropreties.relevancecondsExpression = relevancecondsToExpression($parent.id, $parent.isShowRelevanceCondition, $parent.relevanceconds); ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); // Apply shading + color for label // https://doforms.atlassian.net/browse/PCA-145 (Implement Shading for webapp) applyShadingAndColor4LabelInWebAppsFV($parent, $control); } /*****************************************************************************************************************/ /*End********************************************inputLabel*******************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************inputText********************************************************/ /*****************************************************************************************************************/ var fvEditorsInputText = function($parent, $control, ctrlType, ctrlPropreties){ // defaultValue var defaultValue; if(ctrlPropreties.val == undefined){ defaultValue = getValueOrEmpty($parent.defaultValue.value); setCtrlPropretiesValue(ctrlPropreties, defaultValue, true); fvEditorsSetDefaultValue(ctrlPropreties); }else{ defaultValue = ctrlPropreties.val; } /*var title = ''; if($parent.defaultValue.value != undefined && $parent.defaultValue.value != ''){ title = 'Default value : ' + $parent.defaultValue.value; }*/ var formatKind = undefined; var phoneFormatKind = undefined; var lockNumericKeyboard = false; var customFormat = undefined; if($parent.socialSecurityFormat && $parent.socialSecurityFormat.value){ formatKind = CONST_FORMAT_KIND_SOCIAL; }else if($parent.phoneNoFormat && $parent.phoneNoFormat.value){ formatKind = CONST_FORMAT_KIND_PHONE; phoneFormatKind = $parent.phoneFormatKind.value; }else if($parent.isCustomFormat && $parent.isCustomFormat.value){ formatKind = CONST_FORMAT_KIND_CUSTOM; if($parent.txtCustomFormatVal){ customFormat = $parent.txtCustomFormatVal.value; }else{ customFormat = ''; } if($parent.customFormatTextChar){ ctrlPropreties.textChar = $parent.customFormatTextChar.value; }else{ ctrlPropreties.textChar = 'a'; } if($parent.customFormatNumChar){ ctrlPropreties.numChar = $parent.customFormatNumChar.value; }else{ ctrlPropreties.numChar = 'n'; } } ctrlPropreties.formatKind = formatKind; ctrlPropreties.customFormat = customFormat; ctrlPropreties.phoneFormatKind = phoneFormatKind; if(isVersion(VERSION_DUPLICAT_CHECK) && $parent.duplicateCheck && $parent.duplicateCheck.value){ ctrlPropreties.duplicateCheck = $parent.duplicateCheck.value; ctrlPropreties.duplicateCheckField = $parent.duplicateCheckField.value; } var showSynbols = false; if($parent.lockNumericKeyboard && $parent.lockNumericKeyboard.value == true){ lockNumericKeyboard = true; if($parent.showSynbols && $parent.showSynbols.value == true){ showSynbols = true; } } if($parent.isCustomFormat && $parent.isCustomFormat.value && $parent.isShowCustomFormat && $parent.isShowCustomFormat.value){ $control.find('.controlData textarea').attr('placeholder', $parent.txtCustomFormatVal?$parent.txtCustomFormatVal.value:''); } $control.find('.controlData textarea') .addClass('inpCtrlID_' + ctrlPropreties.id) //.attr('title', title) .val(formatTextDisplay(defaultValue, formatKind, phoneFormatKind, $parent)) .off('setLookupValue').on('setLookupValue', function(event, value, isSearchUndValue){ if(!isControlHiddenByRelevance(ctrlPropreties)){ setLookupValue($(this), ctrlType, $parent, value, isSearchUndValue); ctrlPropreties.formatedValue = $(this).val(); if(value != ctrlPropreties.lastParseValue){ ctrlPropreties.lastParseValue = value; parseTextData($(this), $parent, ctrlPropreties.val, ctrlPropreties.parrentProperties); } } }); if(ctrlPropreties.length && ctrlPropreties.length.max && ctrlPropreties.length.cannotExceedMaximum) { $control.find('.controlData textarea').attr('maxlength',ctrlPropreties.length.max); } ctrlPropreties.formatedValue = $control.find('.controlData textarea').val(); // CO-3260 Field in view data adding values automatically fixFormatTextData($control.find('.controlData textarea'), ctrlPropreties, formatKind, phoneFormatKind); // label $control.find('.controlLabel').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.label.value.eng))); $control.off('checkAndSetRequired').on('checkAndSetRequired', function() { fvAppendRequired($parent, $control.find('.controlLabel')); }); $control.trigger('checkAndSetRequired'); // hint $control.find('.controlHint').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.hint.value.eng))); // hideInMobile $control.off('checkAndSetHide').on('checkAndSetHide', function() { execShowHideWebAppControl($control, $parent) }); $control.trigger('checkAndSetHide'); // upper case if($parent.uppercaseLock && $parent.uppercaseLock.value){ ctrlPropreties.uppercaseLock = $parent.uppercaseLock.value; $control.addClass('uppercase'); } if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } // readOnly // if(isReadOnlyApply($parent)){ // $control.find('.controlData textarea').prop('disabled', true); // $control.find('.inputinner_textarea').addClass('ctrlReadOnly'); // // // Fix bug 0018825: Read Only control is same as normal control! // $control.addClass('ctrlReadOnly'); // } $control.off('checkAndSetReadOnly').on('checkAndSetReadOnly', function() { if(isReadOnlyApply($parent) || ctrlPropreties.isCtrlReadOnly == true){ $($control).find('.controlData textarea').prop('disabled', true); $($control).find('.inputinner_textarea').addClass('ctrlReadOnly'); // Fix bug 0018825: Read Only control is same as normal control! $($control).addClass('ctrlReadOnly'); } else { $($control).find('.controlData textarea').prop('disabled', false); $($control).find('.inputinner_textarea').removeClass('ctrlReadOnly'); // Fix bug 0018825: Read Only control is same as normal control! $($control).removeClass('ctrlReadOnly'); } }); if($($control).attr('id') == 'fvCtrlID_dispatchSubjectEmailOfSendTo') { $($control).off('checkAndSetReadOnly'); } $control.trigger('checkAndSetReadOnly', $parent); if(isVersion(VERSION_NOFL)){ // Number of lines if($parent.numberOfLine != undefined){ var numberOfLine = parseInt($parent.numberOfLine.value, 10); if(numberOfLine > 1){ $control.find('textarea').css('height', 'inherit').attr('rows', $parent.numberOfLine.value); } } } $control.off('clearData').on('clearData', function(event, setDefaultValue){ var $ctrl = $(this).find('.controlData textarea'); if(setDefaultValue){ $ctrl.val(getValueOrEmpty($parent.defaultValue.value)); }else{ $ctrl.val(''); } setCtrlPropretiesValue(ctrlPropreties, $ctrl.val()); ctrlPropreties.formatedValue = $ctrl.val(); //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); var ctrlValue = ctrlPropreties.val; if(ctrlValue != ctrlPropreties.lastParseValue){ ctrlPropreties.lastParseValue = ctrlValue; parseTextData($(this), $parent, ctrlPropreties.val, ctrlPropreties.parrentProperties); } }); $control.off('Control_Update').on('Control_Update', function(event){ event.stopPropagation(); if(fvDataNS.dontCallTrigger) return; return controlUpdate($parent, ctrlPropreties); }); $control.find('.controlData textarea') .keyup(function(event) { var ignoreAutoFillFormat = false; if(isPressBackspace(event)) { ignoreAutoFillFormat = true; var isIgnoreBackspace = false; switch(formatKind){ case CONST_FORMAT_KIND_SOCIAL: case CONST_FORMAT_KIND_PHONE: break; case CONST_FORMAT_KIND_CUSTOM: var textChar = undefined; var numChar = undefined; if(ctrlPropreties.textChar == undefined){ if($parent.customFormatTextChar){ textChar = $parent.customFormatTextChar.value; } if(textChar == undefined || textChar == ''){ textChar = 'a'; } ctrlPropreties.textChar = textChar; }else{ textChar = ctrlPropreties.textChar; } if(ctrlPropreties.numChar == undefined){ if($parent.customFormatNumChar){ numChar = $parent.customFormatNumChar.value; } if(numChar == undefined || numChar == ''){ numChar = 'n'; } ctrlPropreties.numChar = numChar; }else{ numChar = ctrlPropreties.numChar; } isIgnoreBackspace = !isCorrectFormat($(this).val(), customFormat, textChar, numChar); } if(isIgnoreBackspace){ var selectionStart = this.selectionStart; $(this).val(ctrlPropreties.formatedValue); this.selectionStart = this.selectionEnd = selectionStart+1; event.preventDefault(); return false; } } if($(this).val() == ctrlPropreties.formatedValue){ ignoreAutoFillFormat = true; } processTextKeyUp(this, ctrlPropreties, formatKind, phoneFormatKind, ignoreAutoFillFormat); if(isVersion(VERSION_UPPERCASE_LOCK) && ctrlPropreties.uppercaseLock){ var curPos = {selectionStart: this.selectionStart, selectionEnd: this.selectionEnd}; $(this).val($(this).val().toUpperCase()); this.selectionStart = curPos.selectionStart; this.selectionEnd = curPos.selectionEnd; } ctrlPropreties.formatedValue = $(this).val(); fvDataNS.ignoreLostFocus = false; }) .attr("autocomplete", "off") .on("beforeinput keypress", function(event){ if(!isRunEvent(event)){ return; } if(lockNumericKeyboard){ if(showSynbols){ if(!onlyNumberDigit(this, event)) event.preventDefault(); }else{ if(!onlyNumberDigitAndSymbols(this, event)) event.preventDefault(); } } var ctrlValue = ctrlPropreties.val; textValidateMaxLength($parent, ctrlValue, $control.find('.controlInfMsg'), event); switch(formatKind){ case CONST_FORMAT_KIND_SOCIAL: case CONST_FORMAT_KIND_PHONE: if(!isValidLength(this, event, formatKind, phoneFormatKind)){ event.preventDefault(); return true; }else{ if(!onlyNumberDigit(this,event)){ event.preventDefault(); } return true } break; case CONST_FORMAT_KIND_CUSTOM: var textChar = undefined; var numChar = undefined; if(ctrlPropreties.textChar == undefined){ if($parent.customFormatTextChar){ textChar = $parent.customFormatTextChar.value; } if(textChar == undefined || textChar == ''){ textChar = 'a'; } ctrlPropreties.textChar = textChar; }else{ textChar = ctrlPropreties.textChar; } if(ctrlPropreties.numChar == undefined){ if($parent.customFormatNumChar){ numChar = $parent.customFormatNumChar.value; } if(numChar == undefined || numChar == ''){ numChar = 'n'; } ctrlPropreties.numChar = numChar; }else{ numChar = ctrlPropreties.numChar; } if(onlyNumberDigitCustomFormat(this, event, customFormat, textChar, numChar)){ return true; }else{ if(!onlyNumberDigitCustomFormatIgnoreSpecialChar(this, event, customFormat, textChar, numChar)){ event.preventDefault(); } return true } } }) .change(function(event) { if(!fvDataNS.ignoreLostFocus){ ctrlPropreties.formatedValue = $(this).val(); setTextValueWithoutFormat(ctrlPropreties, $(this).val(), formatKind); executeControlChange(ctrlPropreties.classPath); initLatLngFromAddress(ctrlPropreties); // CO-4372 return; }else{ fvDataNS.ignoreLostFocus = false; } }) .blur(function(event) { var ctrlValue = ctrlPropreties.val; $(this).val(formatTextDisplay(ctrlValue, formatKind, phoneFormatKind)); ctrlPropreties.formatedValue = $(this).val(); textValidateError($parent, ctrlValue, $control.find('.controlInfMsg') , ctrlPropreties, $control); // CO-4054: New text setting - check duplicates start if(isVersion(VERSION_DUPLICAT_CHECK) && ctrlPropreties.duplicateCheck){ var duplicateCheckFieldId = ctrlPropreties.duplicateCheckField; if(duplicateCheckFieldId){ var ctrlNamesObj = fvDataNS.ctrlIdMap[duplicateCheckFieldId]; var ctrlNames = Object.keys(ctrlNamesObj); var duplicateError = false; var objTmp; ctrlNames.forEach(function(itemName){ if(duplicateError){ return false; } objTmp = fvDataNS.dataArray[itemName]; if(objTmp == undefined){ return true; } if(ctrlPropreties.val == objTmp.val){ duplicateError = true; return false; } }); if(duplicateError){ showDuplicateError(getControlLabel(objTmp), $control.find('.controlInfMsg'), undefined, objTmp.parentKind == 'table'); } } } //CO-4054: New text setting - check duplicates end if(ctrlValue != ctrlPropreties.lastParseValue){ ctrlPropreties.lastParseValue = ctrlValue; parseTextData($(this), $parent, ctrlValue, ctrlPropreties.parrentProperties); } executeSkipChange(ctrlPropreties); }).off("drop, paste").on("drop, paste",function(e) { // disable paste function if lockNumericKeyboard if(lockNumericKeyboard){ e.preventDefault(); } }); // relevanceconds addToCtrlIdRefForRelevance($parent.isShowRelevanceCondition, $parent.relevanceconds.value, ctrlPropreties.classPath); if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } ctrlPropreties.relevancecondsExpression = relevancecondsToExpression($parent.id, $parent.isShowRelevanceCondition, $parent.relevanceconds); ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); ctrlPropreties.skipcondsExpression = skipcondsToExpression($parent.id, $parent.isShowSkipCondition, $parent.skipconds, ctrlType); // Apply If .. Then .. Else in WebApps GUI (binding events) processBindingIfThenElseActionEvent($parent, ctrlPropreties); // Apply Skip If in WebApps GUI (binding events) processBindingSkipIfActionEvent($parent, ctrlPropreties); } /*****************************************************************************************************************/ /*End********************************************inputText********************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************inputNumeric*****************************************************/ /*****************************************************************************************************************/ var fvEditorsInputNumeric = function($parent, $control, ctrlType, ctrlPropreties){ // defaultValue var defaultValue; if(ctrlPropreties.val == undefined){ defaultValue = getValueOrEmpty($parent.defaultValue.value); setCtrlPropretiesValue(ctrlPropreties, defaultValue, true); fvEditorsSetDefaultValue(ctrlPropreties); }else{ defaultValue = ctrlPropreties.val; } /*var title = ''; if($parent.defaultValue.value != undefined && $parent.defaultValue.value != ''){ title = 'Default value : ' + $parent.defaultValue.value; }*/ $control.find('.currencyContain').removeClass('currencyContain'); var useCurencySymbol = ''; // useCurrentcySymbol if($parent.useCurrentcySymbol.value != undefined && $parent.useCurrentcySymbol.value == true){ if($parent.currency.value != undefined){ useCurencySymbol = $parent.currency.value; } } formatNumberForDisplay($control.find('.controlData input'), $parent, defaultValue, ctrlPropreties.roundDown); $control.find('.controlData input') .addClass('inpCtrlID_' + ctrlPropreties.id) //.attr('title', title) //.val(formatNumber(defaultValue, useCurencySymbol, $parent.kind.value)) .off('setLookupValue').on('setLookupValue', function(event, value, isSearchUndValue){ if(!isControlHiddenByRelevance(ctrlPropreties)){ setLookupValue($(this), ctrlType, $parent, value, isSearchUndValue); } }); cleanDecNum($control.find('.controlData input')[0]); if(isEncryptedFormat($parent)){ formatEncryptedValue($parent, $control, defaultValue); } else{ var value = getRealNumberValue($control.find('.controlData input'), useCurencySymbol); if($parent.kind.value == 'Percent'){ value = getPercentValue(value); } setCtrlPropretiesValue(ctrlPropreties, value, true); } // label $control.find('.controlLabel').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.label.value.eng))); $control.off('checkAndSetRequired').on('checkAndSetRequired', function() { fvAppendRequired($parent, $control.find('.controlLabel')); }); $control.trigger('checkAndSetRequired'); // hint $control.find('.controlHint').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.hint.value.eng))); // hideInMobile $control.off('checkAndSetHide').on('checkAndSetHide', function() { execShowHideWebAppControl($control, $parent) }); $control.trigger('checkAndSetHide'); if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } // ctrlKind ctrlPropreties.kind = $parent.kind.value; // readOnly $control.off('checkAndSetReadOnly').on('checkAndSetReadOnly', function() { if(isReadOnlyApply($parent) || ctrlPropreties.isCtrlReadOnly == true){ $control.find('.controlData input').prop('disabled', true); $control.find('.inputinner').addClass('ctrlReadOnly'); } else { $control.find('.controlData input').prop('disabled', false); $control.find('.inputinner').removeClass('ctrlReadOnly'); } }); $control.trigger('checkAndSetReadOnly', $parent); // new { $control.off('clearData').on('clearData', function(event, setDefaultValue){ var $ctrl = $(this).find('.controlData input'); if(setDefaultValue){ $ctrl.val(getValueOrEmpty($parent.defaultValue.value)); cleanDecNum(this); }else{ $ctrl.val(''); } setCtrlPropretiesValue(ctrlPropreties, $ctrl.val()); //$control.trigger('Control_Update'); //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); $ctrl.trigger('blur'); }); $control.off('Control_Update').on('Control_Update', function(event){ event.stopPropagation(); if(fvDataNS.dontCallTrigger) return; return controlUpdate($parent, ctrlPropreties); }); $control.find('.controlData input') .keyup(function(event) { pointNotAtFirst(this, event); cleanDecNum(this); fvDataNS.ignoreLostFocus = false; var value = $(this).val(); if($parent.kind.value == 'Percent'){ value = getPercentValue(value); } setCtrlPropretiesValue(ctrlPropreties, value); fvDataNS.ignoreLostFocus = false; //$(this).change(); }) .attr("autocomplete", "off") .on("beforeinput keypress", function(event){ if(!isRunEvent(event)){ return; } if(event.ctrlKey == true && (event.charCode == 118 || event.charCode == 99 || event.charCode == 120)){ return; } if($parent.kind.value == 'Decimal'){ if(!inputTextOnlyDecimalNumber(this, event, DECINAM_MAXLENGTH)) event.preventDefault(); }else if($parent.kind.value == 'Percent'){ if(!inputTextOnlyDecimalNumber(this, event, DECINAM_MAXLENGTH)) event.preventDefault(); }else{ return onlyIntegerNumber(this,event, INTEGER_MAXLENGTH); } }) .off("drop").on("drop",function(e) { // disable drop function e.preventDefault(); }) .off('input propertychange').on('input propertychange', function(e) { if($parent.kind.value == 'Decimal'){ onlyNumber_Propertychange($(this), ctrlPropreties, 'Decimal', DECINAM_MAXLENGTH); }else if($parent.kind.value == 'Percent'){ onlyNumber_Propertychange($(this), ctrlPropreties, 'Decimal', DECINAM_MAXLENGTH); }else{ onlyNumber_Propertychange($(this), ctrlPropreties, 'Integer', INTEGER_MAXLENGTH); } }) .change(function(event) { if(!fvDataNS.ignoreLostFocus){ // Get actual value, not value inside Numeric Input Field // Fix bug 0019061: Integer - The message check range out disappear when user focus to another question // We have to plus empty string to convert ctrlPropreties.val into string value var isNegative = isNegativeNumber($(this)); var value = curencyToNumber($(this).val()); if($parent.kind.value == 'Percent'){ value = getPercentValue(value); } if(value > 0 && isNegative){ value = -value; } setCtrlPropretiesValue(ctrlPropreties, value + ''); //$control.trigger('Control_Update'); //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); return; }else{ fvDataNS.ignoreLostFocus = false; } }) .blur(function(event){ if(isNaN($(this).val()) && $(this).val().match(/^[+-]?[0.]+$/)){ $(this).val(''); setCtrlPropretiesValue(ctrlPropreties, $(this).val()); }else{ $(this).change(); } var isError = false; var ctrlValue = ctrlPropreties.val; formatNumberForDisplay($(this), $parent, ctrlValue, ctrlPropreties.roundDown); numberValidateError($parent, ctrlPropreties, $control.find('.controlInfMsg'), $control); executeSkipChange(ctrlPropreties); initLatLngFromAddress(ctrlPropreties); // CO-4372 }) .focus(function(event){ //$(this).val(curencyToNumber($(this).val())); $(this).removeClass('negativeFormat'); var ctrlValue = ctrlPropreties.val; if($parent.kind.value == 'Percent'){ ctrlValue = x100(parseFloat(ctrlValue)); if(isNaN(ctrlValue)){ ctrlValue = ''; } } if($(this).val() != ctrlValue){ $(this).val(ctrlValue); this.selectionStart = this.selectionEnd = $(this).val().length; } }); } // relevanceconds addToCtrlIdRefForRelevance($parent.isShowRelevanceCondition, $parent.relevanceconds.value, ctrlPropreties.classPath); if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } ctrlPropreties.relevancecondsExpression = relevancecondsToExpression($parent.id, $parent.isShowRelevanceCondition, $parent.relevanceconds); ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); //ctrlPropreties.skipcondsExpression = skipcondsToExpression($parent.id, $parent.isShowSkipCondition, $parent.skipconds, ctrlType); // Apply If .. Then .. Else in WebApps GUI (binding events) processBindingIfThenElseActionEvent($parent, ctrlPropreties); // Apply Skip If in WebApps GUI (binding events) processBindingSkipIfActionEvent($parent, ctrlPropreties); } /*****************************************************************************************************************/ /*End********************************************inputNumeric*****************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************inputNewPayment**************************************************/ /*****************************************************************************************************************/ var fvEditorsInputNewPayment = function($parent, $control, ctrlType, ctrlPropreties){ // defaultValue var defaultValue; if(ctrlPropreties.val == undefined){ defaultValue = ''; setCtrlPropretiesValue(ctrlPropreties, defaultValue, true); fvEditorsSetDefaultValue(ctrlPropreties); }else{ defaultValue = ctrlPropreties.val; } if(!isTabletPreview){ if($parent.paymentType != undefined && $parent.paymentType.value == CONST_PAYMENT_TYPE_AUTOMATED){ if($parent.propay.value == CONST_VALUE_TRUE_STR){ $control.addClass('notSupportControl'); return; } } } $control.find('.controlData input') .addClass('inpCtrlID_' + ctrlPropreties.id) //.attr('title', title) .val(formatCreditNumberDisplay(defaultValue)) .off('setLookupValue').on('setLookupValue', function(event, value, isSearchUndValue){ if(!isControlHiddenByRelevance(ctrlPropreties)){ setLookupValue($(this), ctrlType, $parent, value, isSearchUndValue, undefined, ctrlPropreties); } }); // label $control.find('.controlLabel').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.label.value.eng))); $control.off('checkAndSetRequired').on('checkAndSetRequired', function() { fvAppendRequired($parent, $control.find('.controlLabel')); }); $control.trigger('checkAndSetRequired'); // hint $control.find('.controlHint').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.hint.value.eng))); // hideInMobile $control.off('checkAndSetHide').on('checkAndSetHide', function() { execShowHideWebAppControl($control, $parent) }); $control.trigger('checkAndSetHide'); if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } // readOnly $control.off('checkAndSetReadOnly').on('checkAndSetReadOnly', function() { if(isReadOnlyApply($parent) || ctrlPropreties.isCtrlReadOnly == true){ $control.find('.controlData input').prop('disabled', true); $control.find('.inputinner').addClass('ctrlReadOnly'); } else { $control.find('.controlData input').prop('disabled', false); $control.find('.inputinner').removeClass('ctrlReadOnly'); } }); $control.trigger('checkAndSetReadOnly', $parent); // new { $control.off('clearData').on('clearData', function(event, setDefaultValue){ var $ctrl = $(this).find('.controlData input'); if(setDefaultValue){ $ctrl.val(''); }else{ $ctrl.val(''); } setCtrlPropretiesValue(ctrlPropreties, $ctrl.val()); executeControlChange(ctrlPropreties.classPath); $ctrl.trigger('blur'); }); $control.off('Control_Update').on('Control_Update', function(event){ event.stopPropagation(); if(fvDataNS.dontCallTrigger) return; return controlUpdate($parent, ctrlPropreties); }); $control.find('.controlData input') .keyup(function(event) { var selectionStart = this.selectionStart; var valSave = $(this).val().substring(0, selectionStart); $(this).val(cc_format($(this).val())); if(this.selectionStart != selectionStart){ var numberOnlyStart = selectionStart - (valSave.match(/-/g) || []).length; selectionStart = numberOnlyStart + Math.floor((numberOnlyStart-1)/4); if(valSave.slice(-1) == '-'){ selectionStart += 1; } this.selectionStart = selectionStart; this.selectionEnd = selectionStart; } setCtrlPropretiesValue(ctrlPropreties, getCreditNumber($(this).val())); fvDataNS.ignoreLostFocus = false; //$(this).change(); }) .attr("autocomplete", "off") .on("beforeinput keypress", function(event){ if(!isRunEvent(event)){ return; } return onlyNumberDigit(this,event); }) .off("drop").on("drop",function(e) { // disable drop function e.preventDefault(); }) .blur(function(event){ if(isNaN($(this).val()) && $(this).val().match(/^[+-]?[0.]+$/)){ $(this).val(''); setCtrlPropretiesValue(ctrlPropreties, ''); }else{ $(this).change(); } var ctrlValue = ctrlPropreties.val; $(this).val(formatCreditNumberDisplay(ctrlPropreties.val)); if(!creditNumberValidateError($parent, ctrlValue, $control.find('.controlInfMsg'))){ } executeSkipChange(ctrlPropreties); }) .focus(function(event){ $(this).val(cc_format(ctrlPropreties.val)); }); } // relevanceconds addToCtrlIdRefForRelevance($parent.isShowRelevanceCondition, $parent.relevanceconds.value, ctrlPropreties.classPath); if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } ctrlPropreties.relevancecondsExpression = relevancecondsToExpression($parent.id, $parent.isShowRelevanceCondition, $parent.relevanceconds); ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); ctrlPropreties.skipcondsExpression = skipcondsToExpression($parent.id, $parent.isShowSkipCondition, $parent.skipconds, ctrlType); } /*****************************************************************************************************************/ /*End********************************************inputNewPayment**************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************inputNumbering***************************************************/ /*****************************************************************************************************************/ var fvEditorsInputNumbering = function($parent, $control, ctrlType, ctrlPropreties){ if($parent && $parent.autoNumberType){ ctrlPropreties.autoNumberType = $parent.autoNumberType.value; } // defaultValue var defaultValue; if(ctrlPropreties.val == undefined){ if(isVersion(VERSION_AUTONUMBER_PHASE2)){ if($parent.autoNumberType.value == 'Received'){ defaultValue = ''; setCtrlPropretiesValue(ctrlPropreties, defaultValue, true); }else if($parent.autoNumberType.value == 'Collected'){ defaultValue = getValueOrEmpty($parent.prefix.value); defaultValue += getNumberYYMMDDhhmmssSS(); setCtrlPropretiesValue(ctrlPropreties, defaultValue, true); } }else{ defaultValue = getNumberYYMMDDhhmmssSS(); setCtrlPropretiesValue(ctrlPropreties, defaultValue, true); } }else{ defaultValue = ctrlPropreties.val; } /*var title = ''; if($parent.defaultValue.value != undefined && $parent.defaultValue.value != ''){ title = 'Default value : ' + $parent.defaultValue.value; }*/ $control.find('.currencyContain').removeClass('currencyContain'); var useCurencySymbol = ''; $control.find('.controlData input') .addClass('inpCtrlID_' + ctrlPropreties.id) //.attr('title', title) //.val(formatNumber(defaultValue, useCurencySymbol, $parent.kind.value)) //.val(formatNumber(defaultValue, null, CONST_CTRL_TYPE_INPUTNUMBERING)) .val(defaultValue) .off('setLookupValue').on('setLookupValue', function(event, value, isSearchUndValue){ if(!isControlHiddenByRelevance(ctrlPropreties)){ setLookupValue($(this), ctrlType, $parent, value, isSearchUndValue); } }) .off('setAutoStamp').on('setAutoStamp', function(event){ // CO-3355: new setting: OnDevice setAutonumTrigger($parent, $control, ctrlPropreties); }); //cleanDecNum($control.find('.controlData input')[0]); setCtrlPropretiesValue(ctrlPropreties, getRealNumberValue($control.find('.controlData input'), null), true); // label $control.find('.controlLabel').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.label.value.eng))); $control.off('checkAndSetRequired').on('checkAndSetRequired', function() { fvAppendRequired($parent, $control.find('.controlLabel')); }); $control.trigger('checkAndSetRequired'); // hint $control.find('.controlHint').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.hint.value.eng))); // hideInMobile $control.off('checkAndSetHide').on('checkAndSetHide', function() { execShowHideWebAppControl($control, $parent) }); $control.trigger('checkAndSetHide'); if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } // readOnly $control.off('checkAndSetReadOnly').on('checkAndSetReadOnly', function() { if(isReadOnlyApply($parent) || ctrlPropreties.isCtrlReadOnly == true){ $control.find('.controlData input').prop('disabled', true); $control.find('.inputinner').addClass('ctrlReadOnly'); } else { $control.find('.controlData input').prop('disabled', false); $control.find('.inputinner').removeClass('ctrlReadOnly'); } }); $control.trigger('checkAndSetReadOnly', $parent); // new { $control.off('clearData').on('clearData', function(event, setDefaultValue){ var $ctrl = $(this).find('.controlData input'); if(setDefaultValue){ $ctrl.val(getValueOrEmpty($parent.defaultValue.value)); //cleanDecNum(this); }else{ $ctrl.val(''); } setCtrlPropretiesValue(ctrlPropreties, $ctrl.val()); //$control.trigger('Control_Update'); //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); $ctrl.trigger('blur'); }); $control.off('Control_Update').on('Control_Update', function(event){ event.stopPropagation(); if(fvDataNS.dontCallTrigger) return; return controlUpdate($parent, ctrlPropreties); }); $control.find('.controlData input') .keyup(function(event) { setCtrlPropretiesValue(ctrlPropreties, $(this).val()); fvDataNS.ignoreLostFocus = false; //$(this).change(); }) /*.attr("autocomplete", "off") .on("beforeinput keypress", function(event){ if(!isRunEvent(event)){ return; } if(event.ctrlKey == true && (event.charCode == 118 || event.charCode == 99 || event.charCode == 120)){ return; } return onlyNumber(this); })*/ .off("drop").on("drop",function(e) { // disable drop function e.preventDefault(); }) .off('input propertychange').on('input propertychange', function(e) { /*hqkhanh fix 0025575: Autonumber - User cannot input characters onlyNumber_Propertychange($(this), ctrlPropreties, 'Integer', INTEGER_MAXLENGTH); */ }) .change(function(event) { if(!fvDataNS.ignoreLostFocus){ setCtrlPropretiesValue(ctrlPropreties, $(this).val()); //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); return; }else{ fvDataNS.ignoreLostFocus = false; } }) .blur(function(event){ /*hqkhanh fix 0025575: Autonumber - User cannot input characters if(isNaN($(this).val()) && $(this).val().match(/^[+-]?[0.]+$/)){ $(this).val(''); setCtrlPropretiesValue(ctrlPropreties, $(this).val()); }*/ setCtrlPropretiesValue(ctrlPropreties, $(this).val()); $(this).change(); var isError = false; var ctrlValue = ctrlPropreties.val; //$(this).val(formatNumber(ctrlValue, useCurencySymbol, $parent.kind.value)); //$(this).val(formatNumber(ctrlValue, null, CONST_CTRL_TYPE_INPUTNUMBERING)); $(this).val(ctrlValue); /*hqkhanh fix 0025575: Autonumber - User cannot input characters numberValidateError($parent, ctrlPropreties, $control.find('.controlInfMsg')); */ executeSkipChange(ctrlPropreties); }); /*hqkhanh fix 0025575: Autonumber - User cannot input characters onlyNumber($control.find('.controlData input')); */ } // Apply If .. Then .. Else in WebApps GUI (binding events) processBindingIfThenElseActionEvent($parent, ctrlPropreties); // Apply Skip If in WebApps GUI (binding events) processBindingSkipIfActionEvent($parent, ctrlPropreties); // CO-3355: new setting: OnDevice initAutonumTrigger($parent, $control, ctrlPropreties); } /*****************************************************************************************************************/ /*End********************************************inputNumbering***************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************inputTrends******************************************************/ /*****************************************************************************************************************/ var fvEditorsInputTrends = function($parent, $control, ctrlType, ctrlPropreties){ // defaultValue var defaultValue; if(ctrlPropreties.val == undefined){ //defaultValue = getValueOrEmpty($parent.defaultValue.value); defaultValue = ''; setCtrlPropretiesValue(ctrlPropreties, defaultValue, true); }else{ defaultValue = ctrlPropreties.val; } //var title = ''; $control.find('.currencyContain').removeClass('currencyContain'); var useCurencySymbol = ''; // useCurrentcySymbol if($parent.useCurrentcySymbol.value != undefined && $parent.useCurrentcySymbol.value == true){ if($parent.currency.value != undefined){ useCurencySymbol = $parent.currency.value; } } $control.find('#chart1').attr('id', 'chart_' + ctrlPropreties.id); //if($parent.disTrendsBtn && ($parent.disTrendsBtn.value == undefined || $parent.disTrendsBtn.value)){ if(!isTabletPreview){ $control.find('.controlTrendBtn .btnTrendTable').click(function(event, dontShowWarning){ var trendsFieldVal = getValueOrEmpty(ctrlPropreties.val); var isError = numberValidateError($parent, ctrlPropreties, $control.find('.controlInfMsg'), $control, dontShowWarning); if(jQuery.trim(trendsFieldVal) == '' || isError){ if(dontShowWarning){ if(ctrlPropreties.disTrendsBtn){ $control.find('.controlTrendBtn').removeClass(CONST_CSS_CLASS_HIDE_SESSION); $control.find('.controlTrendData').addClass(CONST_CSS_CLASS_HIDE_SESSION); }else{ $control.find('.controlInfo .controlTrendData .trend-table-target').addClass(CONST_CSS_CLASS_HIDE_SESSION); $control.find('.controlInfo .controlTrendData .jqplot-target').addClass(CONST_CSS_CLASS_HIDE_SESSION); } }else{ if(!isError){ alert(msg_warning_please_input_trend_value); } } return; } waitForDataLoading(true); var tBody = $control.find('.controlTrendData table tbody').empty(); var formId = fvDataNS.currentForm.idTmp; var trendsField = ctrlPropreties.name; trendsField += getLoopIndexFromPath(ctrlPropreties.parrentProperties); var trendingDateField = ''; var trendingDateFieldVal = ''; var keyField = ''; var keyFieldVal = ''; var numberOfPrior = 10; if($parent.numberOfPrior == undefined || isNaN($parent.numberOfPrior.value)){ numberOfPrior = 10; }else{ numberOfPrior = $parent.numberOfPrior.value; } if($parent.trendingDate != undefined){ if(fvDataNS.ctrlMap[$parent.trendingDate.value] != undefined){ trendingDateField = fvDataNS.ctrlMap[$parent.trendingDate.value]; var parrentProperties = fvDataNS.dataArray[ctrlPropreties.parrentProperties]; var controlsProperties = getCtrlPropertyInRoot(trendingDateField, parrentProperties); var ctrl = fvDataNS.ctrlArray[controlsProperties.classPath]; trendingDateFieldVal = ctrl.find('input').val(); } } if($parent.keyFieldFilter != undefined){ if(fvDataNS.ctrlMap[$parent.keyFieldFilter.value] != undefined){ keyField = fvDataNS.ctrlMap[$parent.keyFieldFilter.value]; var parrentProperties = fvDataNS.dataArray[ctrlPropreties.parrentProperties]; var controlsProperties = getCtrlPropertyInRoot(keyField, parrentProperties); if(controlsProperties.ctrlType == CONST_CTRL_TYPE_INPUTDATE || controlsProperties.ctrlType == CONST_CTRL_TYPE_INPUTCALCULATE){ var ctrl = fvDataNS.ctrlArray[controlsProperties.classPath]; keyFieldVal = ctrl.find('input').val(); }else{ keyFieldVal = controlsProperties.val; } } } var timezone = getTZMillis(authNS.Unified_TZ); $.ajax({ url: '/formview/TrendsServlet?id=' + formId + '&trendsField=' + trendsField + '&trendsFieldVal=' + trendsFieldVal + '&trendingDateField=' + trendingDateField + '&trendingDateFieldVal=' + trendingDateFieldVal + '&keyField=' + keyField + '&keyFieldVal=' + keyFieldVal + '&recCount=' + numberOfPrior + '&projectKey=' + fvDataNS.inputData.attrs.projectid + '&timezone=' + timezone, dataType: 'json', type: 'GET', data: '{}', cache: false, complete: function() { waitForDataLoading(false); }, success: function(response, status) { var row = 0; while(response[row] != undefined){ var tRow = $(''); tRow.addClass('row_' + row); tRow.find('.col_date').append(response[row][CONST_VALUE_DATE_LOWERCASE]); tRow.find('.col_prior').append(response[row]['prior']); tRow.find('.col_diff').append(response[row]['diff']); tRow.find('.col_diffPercen').append(response[row]['diffPercen'] + '%'); tBody.append(tRow); row ++; } if(row == 0){ if(dontShowWarning){ if(ctrlPropreties.disTrendsBtn){ $control.find('.controlTrendBtn').removeClass(CONST_CSS_CLASS_HIDE_SESSION); $control.find('.controlTrendData').addClass(CONST_CSS_CLASS_HIDE_SESSION); }else{ $control.find('.controlInfo .controlTrendData .trend-table-target').addClass(CONST_CSS_CLASS_HIDE_SESSION); $control.find('.controlInfo .controlTrendData .jqplot-target').addClass(CONST_CSS_CLASS_HIDE_SESSION); } }else{ alert(msg_warning_no_trend_data); } }else{ if(ctrlPropreties.disTrendsBtn){ $control.find('.controlTrendData .jqplot-target').addClass(CONST_CSS_CLASS_HIDE_SESSION); $control.find('.controlTrendData .trend-table-target').removeClass(CONST_CSS_CLASS_HIDE_SESSION); $control.find('.controlTrendData .btnCloseTableGraph').empty().append('Close Table'); $control.find('.controlTrendBtn').addClass(CONST_CSS_CLASS_HIDE_SESSION); $control.find('.controlTrendData').removeClass(CONST_CSS_CLASS_HIDE_SESSION); }else{ $control.find('.controlInfo .controlTrendData .trend-table-target').removeClass(CONST_CSS_CLASS_HIDE_SESSION); $control.find('.controlInfo .controlTrendData .jqplot-target').removeClass(CONST_CSS_CLASS_HIDE_SESSION); } } }, error: function(request, status, error) { waitForDataLoading(false); if(getStatus(request) == 401){ alert(msg_read_permission_required); }else{ alert(msg_error_try); } } }); }); $control.find('.controlTrendBtn .btnTrendGraph').click(function(event, dontShowWarning){ var trendsFieldVal = getValueOrEmpty(ctrlPropreties.val); var isError = numberValidateError($parent, ctrlPropreties, $control.find('.controlInfMsg'), $control, dontShowWarning); if(jQuery.trim(trendsFieldVal) == '' || isError){ if(dontShowWarning){ if(ctrlPropreties.disTrendsBtn){ $control.find('.controlTrendBtn').removeClass(CONST_CSS_CLASS_HIDE_SESSION); $control.find('.controlTrendData').addClass(CONST_CSS_CLASS_HIDE_SESSION); }else{ $control.find('.controlInfo .controlTrendData .trend-table-target').addClass(CONST_CSS_CLASS_HIDE_SESSION); $control.find('.controlInfo .controlTrendData .jqplot-target').addClass(CONST_CSS_CLASS_HIDE_SESSION); } }else{ if(!isError){ alert(msg_warning_please_input_trend_value); } } return; } waitForDataLoading(true); var formId = fvDataNS.currentForm.idTmp; var trendsField = ctrlPropreties.name; trendsField += getLoopIndexFromPath(ctrlPropreties.parrentProperties); var trendingDateField = ''; var trendingDateFieldVal = ''; var keyField = ''; var keyFieldVal = ''; var numberOfPrior = 10; if($parent.numberOfPrior == undefined || isNaN($parent.numberOfPrior.value)){ numberOfPrior = 10; }else{ numberOfPrior = $parent.numberOfPrior.value; } if($parent.trendingDate != undefined){ if(fvDataNS.ctrlMap[$parent.trendingDate.value] != undefined){ trendingDateField = fvDataNS.ctrlMap[$parent.trendingDate.value]; var parrentProperties = fvDataNS.dataArray[ctrlPropreties.parrentProperties]; var controlsProperties = getCtrlPropertyInRoot(trendingDateField, parrentProperties); trendingDateFieldVal = controlsProperties.val; } } if($parent.keyFieldFilter != undefined){ if(fvDataNS.ctrlMap[$parent.keyFieldFilter.value] != undefined){ keyField = fvDataNS.ctrlMap[$parent.keyFieldFilter.value]; var parrentProperties = fvDataNS.dataArray[ctrlPropreties.parrentProperties]; var controlsProperties = getCtrlPropertyInRoot(keyField, parrentProperties); keyFieldVal = controlsProperties.val; } } var timezone = getTZMillis(authNS.Unified_TZ); $.ajax({ url: '/formview/TrendsServlet?id=' + formId + '&trendsField=' + trendsField + '&trendsFieldVal=' + trendsFieldVal + '&trendingDateField=' + trendingDateField + '&trendingDateFieldVal=' + trendingDateFieldVal + '&keyField=' + keyField + '&keyFieldVal=' + keyFieldVal + '&recCount=' + numberOfPrior + '&projectKey=' + fvDataNS.inputData.attrs.projectid + '&timezone=' + timezone, dataType: 'json', type: 'GET', data: '{}', cache: false, complete: function() { waitForDataLoading(false); }, success: function(response, status) { var dataArray = []; var row = 0; while(response[row] != undefined){ row ++; } if(row == 0){ if(dontShowWarning){ if(ctrlPropreties.disTrendsBtn){ $control.find('.controlTrendBtn').removeClass(CONST_CSS_CLASS_HIDE_SESSION); $control.find('.controlTrendData').addClass(CONST_CSS_CLASS_HIDE_SESSION); }else{ $control.find('.controlInfo .controlTrendData .trend-table-target').addClass(CONST_CSS_CLASS_HIDE_SESSION); $control.find('.controlInfo .controlTrendData .jqplot-target').addClass(CONST_CSS_CLASS_HIDE_SESSION); } }else{ alert(msg_warning_no_trend_data); } return; }else{ if(ctrlPropreties.disTrendsBtn){ $control.find('.controlTrendData .trend-table-target').addClass(CONST_CSS_CLASS_HIDE_SESSION); $control.find('.controlTrendData .btnCloseTableGraph').empty().append('Close Graph'); $control.find('.controlTrendData .jqplot-target').removeClass(CONST_CSS_CLASS_HIDE_SESSION); $control.find('.controlTrendBtn').addClass(CONST_CSS_CLASS_HIDE_SESSION); $control.find('.controlTrendData').removeClass(CONST_CSS_CLASS_HIDE_SESSION); }else{ $control.find('.controlInfo .controlTrendData .trend-table-target').removeClass(CONST_CSS_CLASS_HIDE_SESSION); $control.find('.controlInfo .controlTrendData .jqplot-target').removeClass(CONST_CSS_CLASS_HIDE_SESSION); } } for(var i = row-1; i>=0; i--){ dataArray.push(response[i]['prior']); } if(isNaN(trendsFieldVal) || trendsFieldVal == ''){ trendsFieldVal = 0; }else{ trendsFieldVal = eval(trendsFieldVal); } dataArray.push(trendsFieldVal); $control.find('.controlTrendData .jqplot-target').empty().jqplot ([dataArray], { title: "", axesDefaults: { labelRenderer: $.jqplot.CanvasAxisLabelRenderer }, seriesDefaults: { rendererOptions: { smooth: false } }, axes: { xaxis: { tickOptions: { showMark: false, // whether or not to show the mark on the axis show: false, // whether to show the tick (mark and label) showLabel: false } } } }); }, error: function(request, status, error) { waitForDataLoading(false); if(getStatus(request) == 401){ alert(msg_read_permission_required); }else{ alert(msg_error_try); } } }); }); $control.find('.controlTrendData .btnCloseTableGraph').click(function(event){ $control.find('.controlTrendBtn').removeClass(CONST_CSS_CLASS_HIDE_SESSION); $control.find('.controlTrendData').addClass(CONST_CSS_CLASS_HIDE_SESSION); }); } /*}else{ // don't Display trends buttons option $control.find('.controlInfo .controlTrendBtn').remove(); $control.find('.controlInfo .controlTrendData').remove(); }*/ if($parent.disTrendsBtn && ($parent.disTrendsBtn.value == undefined || $parent.disTrendsBtn.value)){ ctrlPropreties.disTrendsBtn = true; }else{ ctrlPropreties.disTrendsBtn = false; // don't Display trends buttons option $control.find('.controlInfo .controlTrendBtn').addClass(CONST_CSS_CLASS_HIDE_SESSION); $control.find('.controlInfo .controlTrendBtn .btnTrendTable').trigger('click', true); $control.find('.controlInfo .controlTrendBtn .btnTrendGraph').trigger('click', true); $control.find('.controlInfo .controlTrendData').removeClass(CONST_CSS_CLASS_HIDE_SESSION); //$control.find('.controlInfo .controlTrendData .hideSession').removeClass(CONST_CSS_CLASS_HIDE_SESSION); //$control.find('.controlInfo .controlTrendData .jqplot-target').removeClass(CONST_CSS_CLASS_HIDE_SESSION); $control.find('.controlInfo .controlTrendData .btnCloseTableGraph').remove(); } $control.find('.controlData input') .addClass('inpCtrlID_' + ctrlPropreties.id) //.attr('title', title) .val(formatNumber(defaultValue, useCurencySymbol, $parent.kind.value)) .off('setLookupValue').on('setLookupValue', function(event, value, isSearchUndValue){ if(!isControlHiddenByRelevance(ctrlPropreties)){ setLookupValue($(this), ctrlType, $parent, value, isSearchUndValue); } }); cleanDecNum($control.find('.controlData input')[0]); setCtrlPropretiesValue(ctrlPropreties, getRealNumberValue($control.find('.controlData input'), useCurencySymbol), true); // label $control.find('.controlLabel').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.label.value.eng))); $control.off('checkAndSetRequired').on('checkAndSetRequired', function() { fvAppendRequired($parent, $control.find('.controlLabel')); }); $control.trigger('checkAndSetRequired'); // hint $control.find('.controlHint').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.hint.value.eng))); if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } // ctrlKind ctrlPropreties.kind = $parent.kind.value; // readOnly $control.off('checkAndSetReadOnly').on('checkAndSetReadOnly', function() { if(isReadOnlyApply($parent) || ctrlPropreties.isCtrlReadOnly == true){ $control.find('.controlData input').prop('disabled', true); $control.find('.inputinner').addClass('ctrlReadOnly'); } else { $control.find('.controlData input').prop('disabled', false); $control.find('.inputinner').removeClass('ctrlReadOnly'); } }); $control.trigger('checkAndSetReadOnly', $parent); // new { $control.off('clearData').on('clearData', function(event, setDefaultValue){ var $ctrl = $(this).find('.controlData input'); if(setDefaultValue){ //$ctrl.val(getValueOrEmpty($parent.defaultValue.value)); $ctrl.val(''); cleanDecNum(this); }else{ $ctrl.val(''); } setCtrlPropretiesValue(ctrlPropreties, $ctrl.val()); //$control.trigger('Control_Update'); //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); $ctrl.trigger('blur'); }); $control.off('Control_Update').on('Control_Update', function(event){ event.stopPropagation(); if(fvDataNS.dontCallTrigger) return; return controlUpdate($parent, ctrlPropreties); }); $control.find('.controlData input') .keyup(function(event) { pointNotAtFirst(this, event); cleanDecNum(this); setCtrlPropretiesValue(ctrlPropreties, $(this).val()); fvDataNS.ignoreLostFocus = false; //$(this).change(); }) .attr("autocomplete", "off") .on("beforeinput keypress", function(event){ if(!isRunEvent(event)){ return; } if(event.ctrlKey == true && (event.charCode == 118 || event.charCode == 99 || event.charCode == 120)){ return; } if($parent.kind.value == 'Decimal'){ if(!inputTextOnlyDecimalNumber(this, event, DECINAM_MAXLENGTH)) event.preventDefault(); }else{ return onlyIntegerNumber(this,event, INTEGER_MAXLENGTH); } }) .off("drop").on("drop",function(e) { // disable drop function e.preventDefault(); }) .off('input propertychange').on('input propertychange', function(e) { if($parent.kind.value == 'Decimal'){ onlyNumber_Propertychange($(this), ctrlPropreties, 'Decimal', DECINAM_MAXLENGTH); }else{ onlyNumber_Propertychange($(this), ctrlPropreties, 'Integer', INTEGER_MAXLENGTH); } }) .change(function(event) { if(!fvDataNS.ignoreLostFocus){ if(isNaN($(this).val()) && $(this).val().match(/^[+-]?[0.]+$/)){ $(this).val(''); } // Get actual value, not value inside Numeric Input Field // Fix bug 0019061: Integer - The message check range out disappear when user focus to another question // We have to plus empty string to convert ctrlPropreties.val into string value setCtrlPropretiesValue(ctrlPropreties, curencyToNumber($(this).val()) + ''); var isError = false; var ctrlValue = ctrlPropreties.val; //$(this).val(formatNumber(ctrlValue, useCurencySymbol, $parent.kind.value)); isError = numberValidateError($parent, ctrlPropreties, $control.find('.controlInfMsg'), $control); if(isError){ if($parent.disTrendsBtn && ($parent.disTrendsBtn.value == undefined || $parent.disTrendsBtn.value)){ $control.find('.controlTrendBtn').removeClass(CONST_CSS_CLASS_HIDE_SESSION); $control.find('.controlTrendData').addClass(CONST_CSS_CLASS_HIDE_SESSION); }else{ $control.find('.controlInfo .controlTrendData .trend-table-target').addClass(CONST_CSS_CLASS_HIDE_SESSION); $control.find('.controlInfo .controlTrendData .jqplot-target').addClass(CONST_CSS_CLASS_HIDE_SESSION); } return; } if($parent.disTrendsBtn && ($parent.disTrendsBtn.value == undefined || $parent.disTrendsBtn.value)){ if(!$control.find('.controlTrendData').hasClass(CONST_CSS_CLASS_HIDE_SESSION)){ if(!$control.find('.controlTrendData .trend-table-target').hasClass(CONST_CSS_CLASS_HIDE_SESSION)){ $control.find('.controlTrendBtn .btnTrendTable').trigger('click', true); }else if(!$control.find('.controlTrendData .jqplot-target').hasClass(CONST_CSS_CLASS_HIDE_SESSION)){ $control.find('.controlTrendBtn .btnTrendGraph').trigger('click', true); } } }else{ $control.find('.controlTrendBtn .btnTrendTable').trigger('click', true); $control.find('.controlTrendBtn .btnTrendGraph').trigger('click', true); //$control.find('.controlInfo .controlTrendData .hideSession').removeClass(CONST_CSS_CLASS_HIDE_SESSION); //$control.find('.controlInfo .controlTrendData .jqplot-target').removeClass(CONST_CSS_CLASS_HIDE_SESSION); } //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); return; }else{ fvDataNS.ignoreLostFocus = false; } }) .blur(function(event){ if(isNaN($(this).val()) && $(this).val().match(/^[+-]?[0.]+$/)){ $(this).val(''); setCtrlPropretiesValue(ctrlPropreties, $(this).val()); }else{ $(this).change(); } var ctrlValue = ctrlPropreties.val; $(this).val(formatNumber(ctrlValue, useCurencySymbol, $parent.kind.value)); numberValidateError($parent, ctrlPropreties, $control.find('.controlInfMsg'), $control); executeSkipChange(ctrlPropreties); }) .focus(function(event){ if($(this).val() != ctrlPropreties.val){ $(this).val(ctrlPropreties.val); this.selectionStart = this.selectionEnd = $(this).val().length; } }); } // relevanceconds addToCtrlIdRefForRelevance($parent.isShowRelevanceCondition, $parent.relevanceconds.value, ctrlPropreties.classPath); if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } ctrlPropreties.relevancecondsExpression = relevancecondsToExpression($parent.id, $parent.isShowRelevanceCondition, $parent.relevanceconds); ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); ctrlPropreties.skipcondsExpression = skipcondsToExpression($parent.id, $parent.isShowSkipCondition, $parent.skipconds, ctrlType); // Apply If .. Then .. Else in WebApps GUI (binding events) processBindingIfThenElseActionEvent($parent, ctrlPropreties); // Apply Skip If in WebApps GUI (binding events) processBindingSkipIfActionEvent($parent, ctrlPropreties); } /*****************************************************************************************************************/ /*End********************************************inputTrends******************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************inputCounter*****************************************************/ /*****************************************************************************************************************/ var fvEditorsInputCounter = function($parent, $control, ctrlType, ctrlPropreties){ // defaultValue var defaultValue; if(ctrlPropreties.val == undefined){ defaultValue = getValueOrEmpty($parent.defaultValue.value); if(defaultValue == '' && $parent.range && $parent.range.value && $parent.range.value.min != undefined) { defaultValue = getValueOrEmpty($parent.range.value.min); } setCtrlPropretiesValue(ctrlPropreties, defaultValue, true); fvEditorsSetDefaultValue(ctrlPropreties); }else{ defaultValue = ctrlPropreties.val; } /*var title = ''; if($parent.defaultValue.value != undefined && $parent.defaultValue.value != ''){ title = 'Default value : ' + $parent.defaultValue.value; }*/ var isNormalCounter = true; if(isVersion(VERSION_COUNTER_STAR_SLIDER)){ if($parent.counterFormat){ switch($parent.counterFormat.value){ case CONST_TYPE_STARS: isNormalCounter = false; $control.addClass(CONST_CLASS_ISSTAR); if($parent.fitImageToScreen && $parent.fitImageToScreen.value){ $control.find(CONST_JQUERY_CLASS_STAR_TYPE).addClass(CONST_CLASS_FIT_TO_SCREEN); } if($parent.range && $parent.range.value && $parent.range.value.stars == CONST_TEN){ $control.find(CONST_JQUERY_CLASS_STAR_TYPE).addClass(CONST_CLASS_10_STARS); $control.find(CONST_JQUERY_CLASS_STAR_TYPE).removeClass(CONST_CLASS_5_STARS); } function setDefaultStarsValue(value){ try { value = parseInt('' + value); } catch (e) { $control.find(CONST_DOT + CONST_CSS_CLASS_SELECTED).removeClass(CONST_CSS_CLASS_SELECTED); return; } for(var i=1; i<=10; i++){ if(i <= value){ $control.find(CONST_DOT + CONST_CLASS_STAR + CONST_HYPHEN + i).addClass(CONST_CSS_CLASS_SELECTED); }else{ $control.find(CONST_DOT + CONST_CLASS_STAR + CONST_HYPHEN + i).removeClass(CONST_CSS_CLASS_SELECTED); } } } setDefaultStarsValue(defaultValue); $control.find(CONST_DIV + CONST_DOT + CONST_CLASS_STAR).click(function(event){ var dataValue = $(this).attr(CONST_DATA); if(parseInt(dataValue) > CONST_I_FIVE && $control.find(CONST_DOT + CONST_CLASS_10_STARS).length == 0){ $control.find(CONST_DOT + CONST_CSS_CLASS_SELECTED).removeClass(CONST_CSS_CLASS_SELECTED); dataValue = ''; } setDefaultStarsValue(dataValue); setCtrlPropretiesValue(ctrlPropreties, dataValue); fvDataNS.ignoreLostFocus = false; $(this).change(); if(!$control.hasClass('ignore_focus')){ fvCtrlFocus($control, false); } }).change(function(event) { if(!fvDataNS.ignoreLostFocus){ setCtrlPropretiesValue(ctrlPropreties, $control.find(CONST_DOT + CONST_CSS_CLASS_SELECTED).length); if(ctrlPropreties.isValueChange){ myPostMessage($control, 'change'); } //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); return; }else{ fvDataNS.ignoreLostFocus = false; } }); break; case CONST_TYPE_SLIDER: isNormalCounter = false; function sliderChange(event, ui){ //var value = $control.find(CONST_SHARP + CONST_SLIDER_BAR).slider(CONST_VALUE); var value = ui.value; $control.find(CONST_DOT + CONST_SLIDER_VALUE).empty().append(value); setCtrlPropretiesValue(ctrlPropreties, value); fvDataNS.ignoreLostFocus = false; $(this).change(); if(!$control.hasClass('ignore_focus')){ fvCtrlFocus($control, false); } } $control.addClass(CONST_CLASS_ISSLIDER); var min = parseInt($parent.range.value.min); var max = parseInt($parent.range.value.max); if(!defaultValue){ defaultValue = min; } $control.find(CONST_DOT + CONST_SLIDER_VALUE).empty().append(defaultValue); setCtrlPropretiesValue(ctrlPropreties, defaultValue); $control.find(CONST_SHARP + CONST_SLIDER_BAR).slider({ orientation: "horizontal", range: "max", min: min, max: max, value: defaultValue, slide: sliderChange, change: sliderChange }).change(function(event) { if(!fvDataNS.ignoreLostFocus){ setCtrlPropretiesValue(ctrlPropreties, $(this).slider("value")); if(ctrlPropreties.isValueChange){ myPostMessage($control, 'change'); } //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); return; }else{ fvDataNS.ignoreLostFocus = false; } }); break; } } } $control.find('.controlData input') .addClass('inpCtrlID_' + ctrlPropreties.id) //.attr('title', title) .val(defaultValue) .off('setLookupValue').on('setLookupValue', function(event, value, isSearchUndValue){ if(!isControlHiddenByRelevance(ctrlPropreties)){ setLookupValue($(this), ctrlType, $parent, value, isSearchUndValue); } }); cleanDecNum($control.find('.controlData input')[0]); // label $control.find('.controlLabel').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.label.value.eng))); $control.off('checkAndSetRequired').on('checkAndSetRequired', function() { fvAppendRequired($parent, $control.find('.controlLabel')); }); $control.trigger('checkAndSetRequired'); // hint $control.find('.controlHint').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.hint.value.eng))); // hideInMobile $control.off('checkAndSetHide').on('checkAndSetHide', function() { execShowHideWebAppControl($control, $parent) }); $control.trigger('checkAndSetHide'); if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } // readOnly $control.off('checkAndSetReadOnly').on('checkAndSetReadOnly', function() { if(isReadOnlyApply($parent) || ctrlPropreties.isCtrlReadOnly == true){ $control.find('.controlData input').prop('disabled', true); //$control.find('.inputinner').addClass('ctrlReadOnly'); $control.find('.controlData').addClass('ctrlReadOnly'); $control.find('.controlData .btnUp, .inputCounterWrapButtonUpDown .btnUp') .off('click'); $control.find('.controlData .btnDown, .inputCounterWrapButtonUpDown .btnDown') .off('click'); }else{ $control.find('.controlData input').prop('disabled', false); $control.find('.controlData').removeClass('ctrlReadOnly'); // btnUp // Apply action with button up+Shading $control.find('.controlData .btnUp, .inputCounterWrapButtonUpDown .btnUp') .click(function(event){ fvDataNS.ignoreLostFocus = false; fvDataNS.dontJump = ctrlPropreties.classPath; var ctrlValue = parseInt($control.find('.controlData input').val(), 10); if(isNaN(ctrlValue)){ ctrlValue = 0; } var step = 1; if($parent.spinStep != undefined, 10){ step = parseInt($parent.spinStep.value, 10); } if(isNaN(step)){ step = 1; } ctrlValue += step; ctrlPropreties.newVal = ctrlValue; if(numberValidateRangeCannotExceedError($parent, ctrlPropreties , $control.find('.controlInfMsg'), $control, false)) { event.preventDefault(); return; } //$control.find('.controlInfMsg').empty(); $control.find('.controlData input').focus().val(ctrlValue).trigger('change') .trigger('blur'); // Simulate event lost focus(), fix bug 0018677: Counter - warning message works incorrectly when using up/down button to change value }); // btnDown $control.find('.controlData .btnDown, .inputCounterWrapButtonUpDown .btnDown') .click(function(event){ fvDataNS.ignoreLostFocus = false; fvDataNS.dontJump = ctrlPropreties.classPath; var ctrlValue = parseInt($control.find('.controlData input').val(), 10); if(isNaN(ctrlValue)){ ctrlValue = 0; } var step = 1; if($parent.spinStep != undefined, 10){ step = parseInt($parent.spinStep.value, 10); } if(isNaN(step)){ step = 1; } ctrlValue -= step; ctrlPropreties.newVal = ctrlValue; if(numberValidateRangeCannotExceedError($parent, ctrlPropreties , $control.find('.controlInfMsg'), $control, false)) { event.preventDefault(); return; } //$control.find('.controlInfMsg').empty(); $control.find('.controlData input').focus().val(ctrlValue).trigger('change') .trigger('blur'); // Simulate event lost focus(), 0018677: Counter - warning message works incorrectly when using up/down button to change value }); } }); $control.trigger('checkAndSetReadOnly', $parent); // new { $control.off('clearData').on('clearData', function(event, setDefaultValue){ var $ctrl = $(this).find('.controlData input'); var defaultValue = getValueOrEmpty($parent.defaultValue.value); if(setDefaultValue && defaultValue != ''){ if($control.find(CONST_DOT + CONST_CLASS_ISSTAR).length >0){ $control.find(CONST_DIV + CONST_CSS_CLASS_SELECTED).removeClass(CONST_CSS_CLASS_SELECTED); var ctrlTmp = $control.find(CONST_DIV + CONST_DOT + CONST_CLASS_STAR + CONST_HYPHEN + defaultValue); if(ctrlTmp.length > 0){ ctrlTmp.trigger('click'); }else{ $control.find(CONST_DOT + CONST_CSS_CLASS_SELECTED).removeClass(CONST_CSS_CLASS_SELECTED).change(); } }else if($control.find(CONST_DOT + CONST_CLASS_ISSLIDER).length >0){ $control.find(CONST_SHARP + CONST_SLIDER_BAR).slider( "value", setDefaultValue); setCtrlPropretiesValue(ctrlPropreties, $control.find(CONST_SHARP + CONST_SLIDER_BAR).slider( "value" )); }else{ $ctrl.val(getValueOrEmpty($parent.defaultValue.value)); setCtrlPropretiesValue(ctrlPropreties, $ctrl.val()); } }else{ if($control.find(CONST_DOT + CONST_CLASS_ISSTAR).length >0){ $control.find(CONST_DIV + CONST_CSS_CLASS_SELECTED).removeClass(CONST_CSS_CLASS_SELECTED); setCtrlPropretiesValue(ctrlPropreties, ''); }else if($control.find(CONST_DOT + CONST_CLASS_ISSLIDER).length >0){ var min = parseInt($parent.range.value.min); $control.find(CONST_SHARP + CONST_SLIDER_BAR).slider( "value", min); setCtrlPropretiesValue(ctrlPropreties, min); }else{ $ctrl.val(''); setCtrlPropretiesValue(ctrlPropreties, ''); } } //$control.trigger('Control_Update') //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); }); if(isNormalCounter){ $control.off('Control_Update').on('Control_Update', function(event){ event.stopPropagation(); if(fvDataNS.dontCallTrigger) return; return controlUpdate($parent, ctrlPropreties); }); $control.find('.controlData input') .keyup(function(event) { pointNotAtFirst(this, event); cleanDecNum(this); setCtrlPropretiesValue(ctrlPropreties, $(this).val()); fvDataNS.ignoreLostFocus = false; //$(this).change(); }) .attr("autocomplete", "off") .on("beforeinput keypress", function(event){ if(!isRunEvent(event)){ return; } if(event.ctrlKey == true && (event.charCode == 118 || event.charCode == 99 || event.charCode == 120)){ return; } return onlyIntegerNumber(this,event, INTEGER_MAXLENGTH); }) .off("drop").on("drop",function(e) { e.preventDefault(); }) .off('input propertychange').on('input propertychange', function(e) { onlyNumber_Propertychange($(this), ctrlPropreties, 'Integer', INTEGER_MAXLENGTH); }) .change(function(event) { if(!fvDataNS.ignoreLostFocus){ setCtrlPropretiesValue(ctrlPropreties, $(this).val()); if(ctrlPropreties.isValueChange){ myPostMessage($control, 'change'); } //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); return; }else{ fvDataNS.ignoreLostFocus = false; } }) .blur(function(event){ if(isNaN($(this).val()) && $(this).val().match(/^[+-]?[0.]+$/)){ $(this).val(''); setCtrlPropretiesValue(ctrlPropreties, $(this).val()); }else{ $(this).change(); } numberValidateError($parent, ctrlPropreties, $control.find('.controlInfMsg'), $control); executeSkipChange(ctrlPropreties); }); } } // relevanceconds addToCtrlIdRefForRelevance($parent.isShowRelevanceCondition, $parent.relevanceconds.value, ctrlPropreties.classPath); if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } ctrlPropreties.relevancecondsExpression = relevancecondsToExpression($parent.id, $parent.isShowRelevanceCondition, $parent.relevanceconds); ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); ctrlPropreties.skipcondsExpression = skipcondsToExpression($parent.id, $parent.isShowSkipCondition, $parent.skipconds, ctrlType); // Apply If .. Then .. Else in WebApps GUI (binding events) processBindingIfThenElseActionEvent($parent, ctrlPropreties); } /*****************************************************************************************************************/ /*End********************************************inputCounter*****************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************inputDate********************************************************/ /*****************************************************************************************************************/ var fvEditorsInputDate = function($parent, $control, ctrlType, ctrlPropreties){ // CO-1931 Verify Setting - Time Fields setVerifyTime(ctrlPropreties, $parent); // CO-896 Able to use the button type for Date/Time fields in Grid/Table for Print/Preview/Web if(isVersion(VERSION_SHOW_ICON_BUTTON_DATE_TIME)){ addClassShowIconForDate($parent, $control); } // dateDefaultField var defaultValue; if($parent.kind.value == undefined){ $parent.kind.value = CONST_VALUE_DATE; } var _allowEdit = true; if(ctrlPropreties.val == undefined){ if(isVersion(VERSION_SET_WEEK_ENDING_DATE) && $parent.kind.value != CONST_VALUE_TIME && $parent.isSetWeekEndingDate.value == true){ if($parent.weekEndingDateType && $parent.weekEndingDateType.value == CONST_VALUE_OTHER){ if($parent.weekEndingDateField && $parent.weekEndingDateField.value != ''){ var itemProperties = getPropertiesByID($parent.weekEndingDateField.value); if(itemProperties && itemProperties.val && itemProperties.val != ''){ defaultValue = getWeekEndingDate($parent.endDay.value, $parent.kind.value, itemProperties.val); }else{ //defaultValue = getValueOrEmpty($parent.defaultValue.value); //defaultValue = mmddyyyyToTFormat(defaultValue, $parent.kind.value); defaultValue = ''; } }else{ defaultValue = getWeekEndingDate($parent.endDay.value, $parent.kind.value); } }else{ defaultValue = getWeekEndingDate($parent.endDay.value, $parent.kind.value); } }else if(isVersion(VERSION_SET_MONTH_ENDING_DATE) && $parent.kind.value != CONST_VALUE_TIME && $parent.isSetMonthEndingDate.value == true){ if($parent.monthEndingDateType && $parent.monthEndingDateType.value == CONST_VALUE_OTHER){ if($parent.monthEndingDateField && $parent.monthEndingDateField.value != ''){ var itemProperties = getPropertiesByID($parent.monthEndingDateField.value); if(itemProperties && itemProperties.val && itemProperties.val != ''){ defaultValue = getMonthEndingDate($parent.kind.value, itemProperties.val); }else{ defaultValue = ''; } }else{ defaultValue = ''; } }else{ defaultValue = getMonthEndingDate($parent.kind.value); } }else{ defaultValue = getValueOrEmpty($parent.defaultValue.value); defaultValue = mmddyyyyToTFormat(defaultValue, $parent.kind.value, undefined, "mm/dd/yyyy"); } if(defaultValue != ''){ setCtrlPropretiesValue(ctrlPropreties, defaultValue, true, $parent, $control); if(getValueOrEmpty($parent.defaultValue.value) == CONST_TODAY){ ctrlPropreties.defaultValue = CONST_TODAY; }else{ fvEditorsSetDefaultValue(ctrlPropreties); } } }else{ defaultValue = ctrlPropreties.val; if(defaultValue != '' && !isCtrlAllowEdit(ctrlPropreties.ctrlType, $parent)){ _allowEdit = false; } } var isMilitaryTime = $parent.militaryTime?$parent.militaryTime.value:undefined; var type = ''; var addCtrlClass = ''; if($parent.kind.value != undefined && $parent.kind.value == CONST_VALUE_DATE){ type = CONST_VALUE_DATE; addCtrlClass = CONST_VALUE_DATE_LOWERCASE; $control.find('.controlData input').addClass('datePK'); if(defaultValue != ''){ var date = parseDateTFormat(defaultValue, CONST_VALUE_DATE); setCurrentTimeFV($control.find('.controlData .normalInputDate'), type, date, isMilitaryTime, $parent, ctrlPropreties); } $control.find('a.normalNowBtn').empty().append('Today'); }else if($parent.kind.value != undefined && $parent.kind.value == CONST_VALUE_TIME){ type = CONST_VALUE_TIME; if(isMilitaryTime){ addCtrlClass = CONST_VALUE_TIME_LOWERCASE; }else{ addCtrlClass = 'timeMilitary'; } $control.find('.controlData input').addClass('timePK'); if(defaultValue != ''){ var date = parseDateTFormat(defaultValue, CONST_VALUE_TIME); setCurrentTimeFV($control.find('.controlData .normalInputDate'), type, date, isMilitaryTime, $parent, ctrlPropreties); } }else{ type = CONST_VALUE_DATE_SPACE_TIME; if(isMilitaryTime){ addCtrlClass = 'date_time'; }else{ addCtrlClass = 'date_timeMilitary'; } $control.find('.controlData input').addClass('dateTimePK'); if(defaultValue != ''){ var date = parseDateTFormat(defaultValue, CONST_VALUE_DATE_TIME); setCurrentTimeFV($control.find('.controlData .normalInputDate'), type, date, isMilitaryTime, $parent, ctrlPropreties); } } $control.addClass(addCtrlClass); $control.find('.controlData input') .addClass('inpCtrlID_' + ctrlPropreties.id) .off('setLookupValue').on('setLookupValue', function(event, value, isSearchUndValue, isForRetrieve){ if(!isControlHiddenByRelevance(ctrlPropreties)){ setLookupValue($(this), ctrlType, $parent, value, isSearchUndValue, $control, undefined, isForRetrieve); // CO-1931 Verify Setting - Time Fields runVerifyTime(ctrlPropreties); } }) .off('setAutoStamp').on('setAutoStamp', function(event){ if(isWebAppDispatch()) return; setCurrentTimeFV($control.find('.controlData .normalInputDate'), type, undefined, isMilitaryTime, $parent, ctrlPropreties); //var ctrlValue = getValueOrEmpty(ctrlPropreties.val); dateValidateError($parent, ctrlPropreties, $control.find('.controlInfMsg'), $control); }) .off('setWeekEndingDate').on('setWeekEndingDate', function(event, relDate){ var weekEndingDate = getWeekEndingDate($parent.endDay.value, $parent.kind.value, relDate); if($parent.kind.value != undefined && $parent.kind.value == CONST_VALUE_DATE){ var date = parseDateTFormat(weekEndingDate, CONST_VALUE_DATE); setCurrentTimeFV($control.find('.controlData .normalInputDate'), type, date, isMilitaryTime, $parent, ctrlPropreties); }else if($parent.kind.value != undefined && $parent.kind.value == CONST_VALUE_TIME){ }else{ var date = parseDateTFormat(weekEndingDate, CONST_VALUE_DATE_TIME); setCurrentTimeFV($control.find('.controlData .normalInputDate'), type, date, isMilitaryTime, $parent, ctrlPropreties); } }) .off('setMonthEndingDate').on('setMonthEndingDate', function(event, relDate){ var monthEndingDate = getMonthEndingDate($parent.kind.value, relDate); if($parent.kind.value != undefined && $parent.kind.value == CONST_VALUE_DATE){ var date = parseDateTFormat(monthEndingDate, CONST_VALUE_DATE); setCurrentTimeFV($control.find('.controlData .normalInputDate'), type, date, isMilitaryTime, $parent, ctrlPropreties); }else if($parent.kind.value != undefined && $parent.kind.value == CONST_VALUE_TIME){ }else{ var date = parseDateTFormat(monthEndingDate, CONST_VALUE_DATE_TIME); setCurrentTimeFV($control.find('.controlData .normalInputDate'), type, date, isMilitaryTime, $parent, ctrlPropreties); } }); // label $control.find('.controlLabel').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.label.value.eng))); $control.off('checkAndSetRequired').on('checkAndSetRequired', function() { fvAppendRequired($parent, $control.find('.controlLabel')); }); $control.trigger('checkAndSetRequired'); if('normal' == ctrlPropreties.format){ $control.find('.controlLabel').addClass('normalLabel'); } else if('hide' == ctrlPropreties.format){ $control.find('.controlLabel').addClass(CONST_HIDEONMOBILEAPP); } if(ctrlPropreties.cssAttr != undefined && ctrlPropreties.cssAttr != ''){ $control.find('.controlData').attr('style', ctrlPropreties.cssAttr); } // hint $control.find('.controlHint').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.hint.value.eng))); // hideInMobile $control.off('checkAndSetHide').on('checkAndSetHide', function() { execShowHideWebAppControl($control, $parent) }); $control.trigger('checkAndSetHide'); // show now button execShowNowButton($control, $parent); if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } // readOnly $control.off('checkAndSetReadOnly').on('checkAndSetReadOnly', function() { if('dispatchUDate' != $parent.id.value // CO-3478 && (isReadOnlyApply($parent) || ctrlPropreties.isCtrlReadOnly == true || !_allowEdit)){ // readonly || date time not allow edit $control.find('.controlData input').prop('disabled',"disabled").addClass('fullSize'); $control.find('.controlData a').addClass('btnReadOnly'); $control.find('.controlData input').off('blur'); $control.find('.controlData .normalNowBtn').off('click'); }else{ $control.find('.controlData input').prop('disabled', false); $control.find('.controlData a').removeClass('btnReadOnly'); $control.find('.controlData input').blur(function(event){ //var ctrlValue = getValueOrEmpty(ctrlPropreties.val); dateValidateError($parent, ctrlPropreties, $control.find('.controlInfMsg'), $control); }); $control.find('.controlData .date-time-now-btn-session').click(function(event){ /*if('dispatchUDate' === ctrlPropreties.id && true == $('.inpCtrlID_dispatchUDate').prop('disabled')){ return; }*/ if($parent.btnType && $parent.btnType.value == CONST_TYPE_IMAGE && $parent.iconAction && $parent.iconAction.value == CONST_PICKER){ $control.find('.controlData .normalInputDate').focus(); }else{ setFocusCtrlMap(ctrlPropreties.classPath); fvDataNS.focusControl = this; var ctrlDate = $control.find('.controlData .normalInputDate'); ctrlPropreties.dataChangedByUser = true; var dtVal = setCurrentTimeFV(ctrlDate, type, undefined, isMilitaryTime, $parent, ctrlPropreties); /*if(dtVal == false){ dtVal = ctrlDate.val(); } if('dispatchUDate2' === ctrlPropreties.id && $('#chkPlusSchedule').prop('checked')){ $('.inpCtrlID_dispatchUDate').trigger('setLookupValue', [dtVal, false]); }*/ //var ctrlValue = getValueOrEmpty(ctrlPropreties.val); executeControlChange(ctrlPropreties.classPath); dateValidateError($parent, ctrlPropreties, $control.find('.controlInfMsg'), $control); executeSkipChange(ctrlPropreties); } }); } }); $control.trigger('checkAndSetReadOnly', $parent); $control.off('clearData').on('clearData', function(event, setDefaultValue){ if(setDefaultValue){ var defaultValueTmp = getValueOrEmpty($parent.defaultValue.value); if(defaultValueTmp !== ''){ defaultValueTmp = mmddyyyyToTFormat(defaultValueTmp, $parent.kind.value); if($parent.kind.value != undefined && $parent.kind.value == CONST_VALUE_DATE){ var date = parseDateTFormat(defaultValueTmp, CONST_VALUE_DATE); if (isNaN(date)) { $control.find('.controlData .normalInputDate').val(''); }else{ setCurrentTimeFV($control.find('.controlData .normalInputDate'), type, date, isMilitaryTime, $parent, ctrlPropreties); } }else if($parent.kind.value != undefined && $parent.kind.value == CONST_VALUE_TIME){ var date = parseDateTFormat(defaultValueTmp, CONST_VALUE_TIME); if (isNaN(date)) { $control.find('.controlData .normalInputDate').val(''); }else{ setCurrentTimeFV($control.find('.controlData .normalInputDate'), type, date, isMilitaryTime, $parent, ctrlPropreties); } }else{ var date = parseDateTFormat(defaultValueTmp, CONST_VALUE_DATE_TIME); if (isNaN(date)) { $control.find('.controlData .normalInputDate').val(''); }else{ setCurrentTimeFV($control.find('.controlData .normalInputDate'), type, date, isMilitaryTime, $parent, ctrlPropreties); } } }else{ $control.find('.controlData .normalInputDate').val(''); } if(defaultValue != ''){ setCtrlPropretiesValue(ctrlPropreties, mmddyyyyToTFormat($(this).val(), $parent.kind.value, undefined, DEFAULT_DATE_FORMAT), undefined, $parent, $control); }else{ setCtrlPropretiesValue(ctrlPropreties, undefined, undefined, $parent, $control); } // CO-1931 Verify Setting - Time Fields runVerifyTime(ctrlPropreties); //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); }else{ $control.find('.controlData .normalInputDate').val(''); setCtrlPropretiesValue(ctrlPropreties, undefined, undefined, $parent, $control); // CO-1931 Verify Setting - Time Fields runVerifyTime(ctrlPropreties); //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); } }); var showAndroid = true; if($parent.useCalendarView != undefined && $parent.useCalendarView.value){ // use calendar view showAndroid = false; } if(type == CONST_VALUE_DATE_SPACE_TIME){ var dateFormat; if(isMilitaryTime){ dateFormat = DEFAULT_DATE_TIME_FORMAT_24H; }else{ dateFormat = DEFAULT_DATE_TIME_FORMAT_12H; } var showSecond = true; if($parent.showSeconds && $parent.showSeconds.value == false){ dateFormat = dateFormat.replace(':ss', ''); showSecond = false; } var minuteInterval = '1'; if($parent.minuteInterval && $parent.minuteInterval.value){ minuteInterval = $parent.minuteInterval.value; } var minuteIntervalRounding = CONST_ROUNDING_UP; if(isVersion(VERSION_OPTION_MINUTE_INTERVAL_ROUNDING)){ if($parent.rounding && $parent.rounding.value){ minuteIntervalRounding = $parent.rounding.value; } } var limitUserToIntervalValue = false; if(isVersion(VERSION_LIMIT_TO_INTERVAL_VALUE)){ if($parent.limitUserToIntervalValue && $parent.limitUserToIntervalValue.value){ limitUserToIntervalValue = $parent.limitUserToIntervalValue.value; } }else{ limitUserToIntervalValue = true; } $control.find('.controlData .normalInputDate').datetimepicker( { showInObjectClass: '.fvWorkspaceScrollArea .fvWorkspace', dateFormat: dateFormat, showCalendar: true, showTime:true, showSecond: showSecond, isRTL: false, showButtonPanel:true, minuteInterval: minuteInterval, minuteIntervalRounding: minuteIntervalRounding, limitUserToIntervalValue: limitUserToIntervalValue, showAsAndorid: showAndroid, showAsAndorid24: isMilitaryTime, onSelect: function(dateText, inst) { //$(this).trigger('keyup'); setFocusCtrlMap(ctrlPropreties.classPath); fvDataNS.focusControl = this; setCtrlPropretiesValue(ctrlPropreties, mmddyyyyToTFormat(inst.selectedFullDate, $parent.kind.value, undefined, DEFAULT_DATE_FORMAT), undefined, $parent, $control); $(this).attr('data_fm', $(this).val()); $(this).attr('data_org', ctrlPropreties.val).attr('data_org_nfm', inst.selectedFullDate_mdy); fvDataNS.ignoreLostFocus = false; $(this).blur(); $(this).parents('.ctrl_selected').focus(); //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); executeSkipChange(ctrlPropreties); } }); }else if(type == CONST_VALUE_TIME){ var dateFormat; if(isMilitaryTime){ dateFormat = DEFAULT_TIME_FORMAT_24H; }else{ dateFormat = DEFAULT_TIME_FORMAT_12H; } var showSecond = true; if($parent.showSeconds && $parent.showSeconds.value == false){ dateFormat = dateFormat.replace(':ss', ''); showSecond = false; } var minuteInterval = '1'; if($parent.minuteInterval && $parent.minuteInterval.value){ minuteInterval = $parent.minuteInterval.value; } var minuteIntervalRounding = CONST_ROUNDING_UP; if(isVersion(VERSION_OPTION_MINUTE_INTERVAL_ROUNDING)){ if($parent.rounding && $parent.rounding.value){ minuteIntervalRounding = $parent.rounding.value; } } var limitUserToIntervalValue = false; if(isVersion(VERSION_LIMIT_TO_INTERVAL_VALUE)){ if($parent.limitUserToIntervalValue && $parent.limitUserToIntervalValue.value){ limitUserToIntervalValue = $parent.limitUserToIntervalValue.value; } }else{ limitUserToIntervalValue = true; } $control.find('.controlData .normalInputDate').datetimepicker( { showInObjectClass: '.fvWorkspaceScrollArea .fvWorkspace', dateFormat: dateFormat, showCalendar: false, showTime:true, showSecond: showSecond, isRTL: false, showButtonPanel:true, minuteInterval: minuteInterval, minuteIntervalRounding: minuteIntervalRounding, limitUserToIntervalValue: limitUserToIntervalValue, showAsAndorid: showAndroid, showAsAndorid24: isMilitaryTime, onSelect: function(dateText, inst) { setFocusCtrlMap(ctrlPropreties.classPath); fvDataNS.focusControl = this; //$(this).trigger('keyup'); setCtrlPropretiesValue(ctrlPropreties, mmddyyyyToTFormat(inst.selectedFullDate, $parent.kind.value, undefined, DEFAULT_DATE_FORMAT), undefined, $parent, $control); // CO-1931 Verify Setting - Time Fields runVerifyTime(ctrlPropreties); $(this).attr('data_fm', $(this).val()); $(this).attr('data_org', ctrlPropreties.val).attr('data_org_nfm', inst.selectedFullDate_mdy); fvDataNS.ignoreLostFocus = false; $(this).blur(); $(this).parents('.ctrl_selected').focus(); try { executeControlChange(ctrlPropreties.classPath); } catch (e) { } executeSkipChange(ctrlPropreties); } }); }else{ var _minDate = null; if('dispatchUDate' == ctrlPropreties.id){ _minDate = new Date().format(DEFAULT_DATE_FORMAT); //_minDate.setDate(_minDate.getDate()-1); } $control.find('.controlData .normalInputDate').datetimepicker({ showInObjectClass: '.fvWorkspaceScrollArea .fvWorkspace', dateFormat: DEFAULT_DATE_FORMAT, showCalendar: true, showTime:false, isRTL: false, showButtonPanel:true, minDate: _minDate, showAsAndorid: showAndroid, onSelect: function(dateText, inst) { setFocusCtrlMap(ctrlPropreties.classPath); fvDataNS.focusControl = this; //$(this).trigger('keyup'); var dateValue = mmddyyyyToTFormat(inst.selectedFullDate, $parent.kind.value, undefined, DEFAULT_DATE_FORMAT); setCtrlPropretiesValue(ctrlPropreties, dateValue, undefined, $parent, $control); $(this).attr('data_fm', $(this).val()); $(this).attr('data_org', ctrlPropreties.val).attr('data_org_nfm', inst.selectedFullDate_mdy); fvDataNS.ignoreLostFocus = false; $(this).blur(); $(this).parents('.ctrl_selected').focus(); /*if('dispatchUDate2' === ctrlPropreties.id && $('#chkPlusSchedule').prop('checked')){ $('.inpCtrlID_dispatchUDate').trigger('setLookupValue', [dateValue, false]); }*/ try { executeControlChange(ctrlPropreties.classPath); } catch (e) { } executeSkipChange(ctrlPropreties); } }); } $control.find('.controlData input').change(function(event){ //setCtrlPropretiesValue(ctrlPropreties, ctrlPropreties.val, undefined, $parent, $control); // change if($(this).val() != $(this).attr('data_fm')){ setCtrlPropretiesValue(ctrlPropreties, mmddyyyyToTFormat($(this).val(), $parent.kind.value, undefined, DEFAULT_DATE_FORMAT), undefined, $parent, $control); }else{ var data_org = $(this).attr('data_org'); if(data_org != undefined && ctrlPropreties.val != data_org){ setCtrlPropretiesValue(ctrlPropreties, mmddyyyyToTFormat(data_org, $parent.kind.value), undefined, $parent, $control); } } // CO-1931 Verify Setting - Time Fields runVerifyTime(ctrlPropreties); //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); executeSkipChange(ctrlPropreties); }); // ctrlKind ctrlPropreties.kind = $parent.kind.value; $control.off('Control_Update').on('Control_Update', function(event){ if(fvDataNS.dontCallTrigger) return; return controlUpdate($parent, ctrlPropreties); }); // relevanceconds addToCtrlIdRefForRelevance($parent.isShowRelevanceCondition, $parent.relevanceconds.value, ctrlPropreties.classPath); if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } // CO-1931 Verify Time Fields addVerifyTimeCtrlClass($control, ctrlPropreties); ctrlPropreties.relevancecondsExpression = relevancecondsToExpression($parent.id, $parent.isShowRelevanceCondition, $parent.relevanceconds); ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); ctrlPropreties.skipcondsExpression = skipcondsToExpression($parent.id, $parent.isShowSkipCondition, $parent.skipconds, ctrlType); // Apply If .. Then .. Else in WebApps GUI (binding events) processBindingIfThenElseActionEvent($parent, ctrlPropreties); // Apply Skip If in WebApps GUI (binding events) processBindingSkipIfActionEvent($parent, ctrlPropreties); // CO-4273: Week Ending Date - New Date Field Setting initWeekEndingDate($parent, $control, ctrlPropreties); // CO-6354: Date Field Month Ending Option initMonthEndingDate($parent, $control, ctrlPropreties); }; /*****************************************************************************************************************/ /*End********************************************inputDate********************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************inputSelectOne***************************************************/ /*****************************************************************************************************************/ var fvEditorsInputSelectOne = function($parent, $control, ctrlType, ctrlPropreties){ // defaultValue var defaultValue; if(ctrlPropreties.val == undefined){ defaultValue = getValueOrEmpty($parent.defaultValue.value); setCtrlPropretiesValue(ctrlPropreties, defaultValue, true); fvEditorsSetDefaultValue(ctrlPropreties); }else{ defaultValue = ctrlPropreties.val; if(ctrlPropreties.realType == CONST_CTRL_TYPE_INPUTAPPROVAL){ defaultValue = defaultValue.replace('rejected' , 'deny').replace('approved' , 'approve'); } } if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } // label $control.find('.controlLabel').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.label.value.eng))); //$control.find('.controlLabel').addClass('normalLabel'); $control.off('checkAndSetRequired').on('checkAndSetRequired', function() { fvAppendRequired($parent, $control.find('.controlLabel')); }); $control.trigger('checkAndSetRequired'); if('normal' == ctrlPropreties.format){ $control.find('.controlLabel').addClass('normalLabel'); } else if('hide' == ctrlPropreties.format){ $control.find('.controlLabel').addClass(CONST_HIDEONMOBILEAPP); } if(ctrlPropreties.cssAttr != undefined && ctrlPropreties.cssAttr != ''){ $control.find('.controlData').attr('style', ctrlPropreties.cssAttr); } // hint $control.find('.controlHint').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.hint.value.eng))); // options $optionsList = $control.find('.controlData').empty(); var showAsDropdown = false; var showAsOnOffSwitch = false; if(isVersion(VERSION_CHOOSE_ONE_SLIDER)) { if($parent.optionKind != undefined && $parent.optionKind.value == CONST_CHOOSE_ONE_SWITCH){ showAsOnOffSwitch = true; } } if(!showAsOnOffSwitch){ if($parent.showAsDropdown != undefined && $parent.showAsDropdown.value){ showAsDropdown = $parent.showAsDropdown.value; } if(isVersion(VERSION_DISPLAY_TYPE_FUNCTION)) { if ($parent.displayType && $parent.displayType.value){ if($parent.displayType.value == CONST_DROPDOWN){ showAsDropdown = true; }else{ showAsDropdown = false; } } } } var realValDisp = defaultValue; // CO-1168 if(showAsOnOffSwitch){ var ctrlId = 'on-off-switch_' + ctrlPropreties.id; var valTrue = CONST_SWITCH_1; var valFalse = CONST_SWITCH_0; switch($parent.switchOption.value){ case CONST_SWITCH_ON_OFF: valTrue = CONST_SWITCH_ON; valFalse = CONST_SWITCH_OFF; break; case CONST_SWITCH_YES_NO: valTrue = CONST_SWITCH_YES; valFalse = CONST_SWITCH_NO; break; case CONST_SWITCH_1_0: valTrue = CONST_SWITCH_1; valFalse = CONST_SWITCH_0; break; case CONST_SWITCH_CUSTOM: valTrue = $parent.switchCustomOn.value; valFalse = $parent.switchCustomOff.value; break; } $selectionList = $('#formview_templates .inputSelectOneOptionOnOffSwitch') .clone() .addClass('inpCtrlID_' + ctrlPropreties.id) .appendTo($optionsList) .off('setLookupValue').on('setLookupValue', function(event, value, isSearchUndValue){ if(!isControlHiddenByRelevance(ctrlPropreties)){ $control.addClass('ignore_focus_by_lu'); setLookupValue($(this), ctrlType, $parent, value, isSearchUndValue, $control, ctrlPropreties); } }); var inputCtrl = $optionsList.find('input').attr('id', ctrlId); if(defaultValue == valTrue){ inputCtrl.prop('checked',true); }else{ inputCtrl.prop('checked',false); } // readOnly $control.off('checkAndSetReadOnly').on('checkAndSetReadOnly', function() { if(isReadOnlyApply($parent) || ctrlPropreties.isCtrlReadOnly == true){ $control.find('.controlData input').prop('disabled', true); $control.find('.inputSelectOneOption').addClass('ctrlReadOnly'); } else { $control.find('.controlData input').prop('disabled', false); $control.find('.inputSelectOneOption').removeClass('ctrlReadOnly'); } }); $control.trigger('checkAndSetReadOnly', $parent); var activeSliderColor = getActiveSliderColor($parent); new DG.OnOffSwitch({ inputEl: $optionsList.find('#' + ctrlId), trackColorOn: activeSliderColor, trackColorOff: 'gray', height: 16, isReadOnly: isReadOnlyApply($parent), listener:function(name, checked){ var value = ''; if(checked){ value = valTrue; }else{ value = valFalse; } setCtrlPropretiesValue(ctrlPropreties, value); executeControlChange(ctrlPropreties.classPath); executeSkipChange(ctrlPropreties); if(!$control.hasClass('ignore_focus') && !$control.hasClass('ignore_focus_by_lu')){ fvCtrlFocus($control, false); }else{ $control.removeClass('ignore_focus_by_lu'); } } }); $control.off('clearData').on('clearData', function(event, setDefaultValue){ var $ctrl = $(this).find('select'); var defaultValueTmp = CONST_SWITCH_0; var valTrue = CONST_SWITCH_1; var valFalse = CONST_SWITCH_0; if(setDefaultValue){ defaultValueTmp = getValueOrEmpty($parent.defaultValue.value); }else{ switch($parent.switchOption.value){ case CONST_SWITCH_ON_OFF: valTrue = CONST_SWITCH_ON; valFalse = CONST_SWITCH_OFF; break; case CONST_SWITCH_YES_NO: valTrue = CONST_SWITCH_YES; valFalse = CONST_SWITCH_NO; break; case CONST_SWITCH_1_0: valTrue = CONST_SWITCH_1; valFalse = CONST_SWITCH_0; break; case CONST_SWITCH_CUSTOM: valTrue = $parent.switchCustomOn.value; valFalse = $parent.switchCustomOff.value; break; } defaultValueTmp = valFalse; } switch(defaultValueTmp){ case valTrue: if(!$control.find('input').is(':checked')){ ctrlPropreties.val = value; $control.find('input').prop('checked',true).change(); } break; case valFalse: if($control.find('input').is(':checked')){ ctrlPropreties.val = value; $control.find('input').prop('checked',false).change(); } break; } executeControlChange(ctrlPropreties.classPath); }); $control.off('Control_Update').on('Control_Update', function(event){ event.stopPropagation(); if(fvDataNS.dontCallTrigger) return; return controlUpdate($parent, ctrlPropreties); }); }else if(showAsDropdown){ $selectionList = $('#formview_templates .inputSelectOneOptionDropdown') .clone() .appendTo($optionsList); $selectionList = $selectionList.find('select'); $selectionList .addClass('inpCtrlID_' + ctrlPropreties.id) .appendTo($optionsList) .off('setLookupValue').on('setLookupValue', function(event, value, isSearchUndValue){ if(!isControlHiddenByRelevance(ctrlPropreties)){ setLookupValue($(this), ctrlType, $parent, value, isSearchUndValue, $control); } }) .blur(function(event) { var ctrlValue = ctrlPropreties.val; textValidateError($parent, ctrlValue, $control.find('.controlInfMsg') , ctrlPropreties, $control); }); if($parent.isAllowUncheck && $parent.isAllowUncheck.value){ $(''); if(response != undefined){ waDispatchUnits['PlusProjects'] = response.sort(); for ( var m = 0; m < waDispatchUnits['PlusProjects'].length; m++) { var info = waDispatchUnits['PlusProjects'][m].split('$'); var selected = ''; if(info[2] == curTmpProject){ selected = ' selected'; resetHtmlFlg = false; } $('.inpCtrlID_dispatchUPrj') .append(''); } } } catch(e){ } if(resetHtmlFlg){ // reset form structure $(".formView .fvWorkspace > *:not('.waDisTable, .waDisSendType, .sentToEmailBar, .sentToSMSBar, .waDisProjectForm, .waRootContainer')").remove(); // reset form list $('.inpCtrlID_dispatchUFrm').empty().append(''); } }, error: function(request, status, error) { jAlert(msg_error_try); } }); } } // trigger onChange with new mobile number for POD try{ $('.fvWorkspace .ctrlPOD').find('.controlData table') .trigger('changeTableDataSource' , [false, false, ctrlPropreties.val.split('@Deli@')[0]]); } catch(e){} } else{ webAppItem[2].val = ctrlPropreties.val; if(fvDataNS.currentForm.editRecordData != undefined && fvDataNS.currentForm.editRecordData['@Nickname'] != undefined){ fvDataNS.currentForm.editRecordData['@Nickname'].value = ctrlPropreties.val; } // update value for dispatched mobile number //if(ctrlPropreties.val != ''){ //$('.inpCtrlID_dispatchUID').trigger('setLookupValue', [ctrlPropreties.val, true]); $('.inpCtrlID_dispatchUID').val(ctrlPropreties.val); webAppItem[1].val = ctrlPropreties.val; // CO-3709 //} try{ var selectedMobileGroup = ''; _.each(waDispatchUnits.MUGroups, function(mobiles, groupName) { if(selectedMobileGroup == ''){ for ( var i = 0; i < mobiles.length; i++) { if (mobiles[i] === ctrlPropreties.val){ selectedMobileGroup = groupName; continue; } } } else{ if(selectedMobileGroup === '&Empty'){ selectedMobileGroup = 'Main'; } return true; } }); if(selectedMobileGroup != ''){ $('.inpCtrlID_dispatchMobileGroup').val(selectedMobileGroup.split('@')[0]); } } catch(e){} } } else if('dispatchMobileGroup' == ctrlPropreties.id){ var gKey = $(this).find('option:selected').attr('gKey'); if(gKey != undefined && gKey != ''){ gKey = '@' + gKey; } else if(gKey == undefined){ gKey = ''; } generateDispatchMobiles(ctrlPropreties.val+gKey, ''); } else if('dispatchUPrj' == ctrlPropreties.id){ waitForDataLoading(true); $.ajax({ url: '/formpreview?disPlus=prj&prjKey=' + ctrlPropreties.val, dataType: 'json', type: 'GET', cache: false, complete: function() { if(changeFlg != undefined && previewFormKey != undefined && previewFormKey != ''){ fvDataNS.isPlusLoading = true; // CO-4608 $('.inpCtrlID_dispatchUFrm').val(previewFormKey); var projectKeyTmp = $('.inpCtrlID_dispatchUPrj').val(); if(!projectKeyTmp) { projectKeyTmp = previewProjectKey; } fvOpenForm(previewFormKey, projectKeyTmp, undefined, false); } else{ fvDataNS.isPlusLoading = false; fvDataNS.isLoading = false; waitForDataLoading(false); } }, success: function(response, status) { // re-generate mobiles html if(response.MUNumbers != undefined){ waDispatchUnits['MUGroups'] = response.MUGroups; waDispatchUnits['MUNumbers'] = response.MUNumbers; waDispatchUnits['MUNames'] = response.MUNames; generateDispatchMobiles('', waDispatchUnits['PlusMobile']); } // re-generate forms html if(response.PlusForms != undefined){ if(changeFlg == undefined){ previewFormKey = ''; // reset data } $(".formView .fvWorkspace > *:not('.waDisTable, .waDisSendType, .sentToEmailBar, .sentToSMSBar, .waDisProjectForm, .waRootContainer')").remove(); $('.inpCtrlID_dispatchUFrm').empty() .append(''); var objPlusFrm = response.PlusForms; // waDispatchUnits['PlusForms'] objPlusFrm.sort(); for ( var m = 0; m < objPlusFrm.length; m++) { var info = objPlusFrm[m].split('$'); $('.inpCtrlID_dispatchUFrm') .append(''); } } }, error: function(request, status, error) { jAlert(msg_error_try); } }); } else if('dispatchUFrm' == ctrlPropreties.id){ if(ctrlPropreties.val == ''){ fvDataNS.isPlusLoading = false; // CO-4608 jAlert(msg_form_key_4_useform_empty); } else if($('.inpCtrlID_dispatchUPrj').val() == ''){ fvDataNS.isPlusLoading = false; jAlert(msg_project_key_4_useform_empty); } else if(changeFlg != undefined){ // load default fvDataNS.isPlusLoading = true; fvOpenForm(ctrlPropreties.val, $('.inpCtrlID_dispatchUPrj').val(), $('.inpCtrlID_dispatchUPrj').val(), false); // CO-3922 } else{ fvDataNS.isPlusLoading = true; fvOpenForm(ctrlPropreties.val, $('.inpCtrlID_dispatchUPrj').val(), undefined, false); } } else if('dispatchURepeat' == ctrlPropreties.id){ // show first blank option $('.inpCtrlID_dispatchURepeat option:first').css(CONST_CSS_KEY_DISPLAY, ''); if(CONST_PLUS_REPEAT_DAILY == ctrlPropreties.val || CONST_PLUS_REPEAT_QUARTERLY == ctrlPropreties.val || CONST_PLUS_REPEAT_ANNUALLY == ctrlPropreties.val){ var repeatLabel = 'Repeat Daily'; if(CONST_PLUS_REPEAT_QUARTERLY == ctrlPropreties.val){ repeatLabel = 'Repeat Quarterly'; } else if(CONST_PLUS_REPEAT_ANNUALLY == ctrlPropreties.val){ repeatLabel = 'Repeat Bi Annually'; } $('#intervalLabel').html('Interval Day(s)'); $('#rowWeekly').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); $('#rowMonthly1').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); $('#rowMonthly2').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); $('#rowYearly1').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); $('#rowYearly2').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); } else if(CONST_PLUS_REPEAT_WEEKLY == ctrlPropreties.val || CONST_PLUS_REPEAT_WEEKLY2 == ctrlPropreties.val){ $('#intervalLabel').html('Interval Week(s)'); $('#rowWeekly').css(CONST_CSS_KEY_DISPLAY, ''); $('#rowMonthly1').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); $('#rowMonthly2').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); $('#rowYearly1').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); $('#rowYearly2').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); } else if(CONST_PLUS_REPEAT_MONTHLY == ctrlPropreties.val || CONST_PLUS_REPEAT_MONTHLY2 == ctrlPropreties.val){ $('#repeatType').html('Repeat Monthly'); $('#intervalLabel').html('Interval Month(s)'); $('#rowWeekly').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); $('#rowMonthly1').css(CONST_CSS_KEY_DISPLAY, ''); $('#rowMonthly2').css(CONST_CSS_KEY_DISPLAY, ''); $('#rowYearly1').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); $('#rowYearly2').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); } else if(CONST_PLUS_REPEAT_YEARLY == ctrlPropreties.val){ $('#intervalLabel').html('Interval Year(s)'); $('#rowWeekly').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); $('#rowMonthly1').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); $('#rowMonthly2').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); $('#rowYearly1').css(CONST_CSS_KEY_DISPLAY, ''); $('#rowYearly2').css(CONST_CSS_KEY_DISPLAY, ''); } } } catch (e) { } try { executeControlChange(ctrlPropreties.classPath); executeSkipChange(ctrlPropreties); } catch (e) { } }); } }else{ ctrlPropreties.options = {}; _.each($parent.options.value, function(option, i) { if (option.isShowUnderlying !== undefined){ return true; } var optionItem = $('#formview_templates .inputSelectOneOption') .clone() .addClass('inpCtrlID_' + ctrlPropreties.id) .appendTo($optionsList) .off('setLookupValue').on('setLookupValue', function(event, value, isSearchUndValue){ if(!isControlHiddenByRelevance(ctrlPropreties)){ setLookupValue($(this), ctrlType, $parent, value, isSearchUndValue, $control); } }); var ctrlId = $control.find('.controlData').attr('id') + '_' + i; optionItem.find('input') .attr('id', ctrlId) .val(option.val) .addClass('radio_' + replaceNonAlphaNumericChar(option.val)); optionItem.find('label').attr('for', ctrlId).empty().append(createHtmlDisplayText($parent)); var image = valueOrEmpty(option.image); if($parent.isHideAnswer && true == $parent.isHideAnswer.value){ optionItem.find(cssDisplayTextString($parent)).append(' '); } else if(image != ''){ if(image.indexOf('/imageViewer?blobKey=') >= 0){ image += "&maxWidth=" + fvDataNS.ctrlWidth; } var imageLink = $(''); imageLink.attr('src', image).attr('alt', option.text.eng).css('background-color', '#' + option.iconColor); optionItem.find(cssDisplayTextString($parent)).append(imageLink).addClass('dispTextWithImage'); var isFilibCanvas = FILIB_ICON_IMAGE_CANVAS && image.indexOf('img/filib/') >= 0; var isFilibButtonCanvas = FILIBBUTTON_ICON_IMAGE_CANVAS && image.indexOf('img/filibbutton/') >= 0; if(isFilibCanvas || isFilibButtonCanvas) { var canvasWidth = 96; var canvasHeight = 96; var imageWidth = 187; var imageHeight = 187; if(isFilibButtonCanvas) { canvasWidth = 96; canvasHeight = 28; imageWidth = CONST_FILIB_BUTTON_IMAGE_WIDTH; imageHeight = CONST_FILIB_BUTTON_IMAGE_HEIGHT; } var canvasLink = $(''); canvasLink.attr('src', image).attr('alt', option.text.eng).css('background-color', '#ffffff').css('margin','10px 0px'); imageLink.css('display', 'none'); var imageObj = new Image(); imageObj.canvas = canvasLink[0]; imageObj.iconColor = option.iconColor; imageObj.imageWidth = CONST_FILIB_BUTTON_IMAGE_WIDTH; imageObj.imageHeight = CONST_FILIB_BUTTON_IMAGE_HEIGHT; imageObj.canvasWidth = canvasWidth; imageObj.canvasHeight = canvasHeight; imageObj.drawImageToCanvas = function(){ drawImageToCanvas(this.canvas, this, this.iconColor, this.canvasWidth, this.canvasHeight, this.imageWidth, this.imageHeight); } imageObj.onload = function(){ this.drawImageToCanvas(); } imageObj.src = image; optionItem.find(cssDisplayTextString($parent)).append(canvasLink).addClass('dispTextWithImage'); } if(!$control.hasClass('hasImage')){ $control.addClass('hasImage'); } if(option.showAnswerText){ var displayText = $('

'); displayText.append(option.text.eng); optionItem.find(cssDisplayTextString($parent)).append(displayText); } }else{ optionItem.find(cssDisplayTextString($parent)).append(option.text.eng); } ctrlPropreties.options[option.val] = option.text.eng; if('dispatchTo' === ctrlPropreties.id && 'Email' === option.val){ optionItem.addClass('email_sendTo'); } var parentObj = getParent(); if('dispatchTo' === ctrlPropreties.id && 'Link' === option.val && (isWADispatchPlus() || parentObj.dispatchFlg == true || parentObj.dispatchFlg == undefined) // CO-3902, CO-3908, CO-4892 ){ optionItem.addClass(CONST_CSS_CLASS_HIDE_SESSION); } if('dispatchTo' === ctrlPropreties.id && 'SMS' === option.val && (!authNS.currentUser.enableSMS || !authNS.currentUser.customerSMSIsEnable)) { //optionItem.addClass(CONST_CSS_CLASS_HIDE_SESSION); optionItem.attr("disabled", true); optionItem.attr("title", "Send to a mobile number. Please upgrade to use this control."); } if ((parentObj.dispatchFlg === true || parentObj.viewDataFillAndSend === true) && ('dispatchTo' === ctrlPropreties.id && 'SMS' === option.val)) { optionItem.addClass(CONST_CSS_CLASS_HIDE_SESSION); } if(defaultValue == option.val){ // CO-1168 realValDisp = option.text.eng; } }); $optionsList.find('input').attr('name', replaceNonAlphaNumericChar(ctrlPropreties.classPath, true)); //CO-6237: Choose One Default Value Clears in PDF //defaultValue = replaceNonAlphaNumericChar(defaultValue); //$optionsList.find('.radio_' + defaultValue).prop('checked', true); $optionsList.find('.radio_' + replaceNonAlphaNumericChar(defaultValue)).prop('checked', true); ctrlPropreties.formatedValue = realValDisp; // readOnly $control.off('checkAndSetReadOnly').on('checkAndSetReadOnly', function() { if(isReadOnlyApply($parent) || ctrlPropreties.isCtrlReadOnly == true){ $control.find('.controlData input').prop('disabled', true); $control.find('.inputSelectOneOption').addClass('ctrlReadOnly'); } else { $control.find('.controlData input').prop('disabled', false); $control.find('.inputSelectOneOption').removeClass('ctrlReadOnly'); } }); $control.trigger('checkAndSetReadOnly', $parent); // new { $control.off('clearData').on('clearData', function(event, setDefaultValue){ var $ctrl = $(this).find('input'); $ctrl.prop('checked', false); if(setDefaultValue){ var defaultValueTmp = getValueOrEmpty($parent.defaultValue.value); //CO-6237: Choose One Default Value Clears in PDF //defaultValueTmp = replaceNonAlphaNumericChar(defaultValueTmp); //$(this).find('.radio_' + defaultValueTmp).prop('checked', true); $(this).find('.radio_' + replaceNonAlphaNumericChar(defaultValueTmp)).prop('checked', true); setCtrlPropretiesValue(ctrlPropreties, defaultValueTmp); }else{ setCtrlPropretiesValue(ctrlPropreties, ''); } //$control.trigger('Control_Update') //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); }); $control.off('Control_Update').on('Control_Update', function(event){ event.stopPropagation(); if(fvDataNS.dontCallTrigger) return; return controlUpdate($parent, ctrlPropreties); }); $control.find('input').change(function(event) { if(event.cancelable != undefined){ setFocusCtrlMap(ctrlPropreties.classPath); fvDataNS.focusControl = this; } setCtrlPropretiesValue(ctrlPropreties, $control.find('input:radio:checked').val()); ctrlPropreties.formatedValue = $(this).next().text(); // CO-1168 fvDataNS.ignoreLostFocus = false; if(ctrlPropreties.isValueChange){ myPostMessage($control, 'change'); } //$control.trigger('Control_Update') //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); // Process validate required // Fix bug 0018711: Warning message didn't show when user click on caption text! requiredOnlyValidateError($parent, ctrlPropreties.val, $control.find('.controlInfMsg') , ctrlPropreties, $control); executeSkipChange(ctrlPropreties); }) if($parent.isAllowUncheck && $parent.isAllowUncheck.value){ $control.find('.check').mouseup(function(event){ var ctrl = $(this).find('input'); if(ctrl.is(':checked')){ setTimeout(function(event){ ctrl.prop('checked', false).trigger('clearData', false); }, 100); } }); } // Adding required checking // Fix bug 0018711: Warning message didn't show when user click on caption text! $control.off('processCheckRequired').on('processCheckRequired', function() { var ctrlValue = $control.find('input:radio:checked').val(); if (typeof ctrlValue === 'undefined') { ctrlValue = ''; } requiredOnlyValidateError($parent, ctrlValue, $control.find('.controlInfMsg') , ctrlPropreties, $control); }); } } try { // hideInMobile $control.off('checkAndSetHide').on('checkAndSetHide', function() { execShowHideWebAppControl($control, $parent) }); $control.trigger('checkAndSetHide'); // relevanceconds addToCtrlIdRefForRelevance($parent.isShowRelevanceCondition, $parent.relevanceconds.value, ctrlPropreties.classPath); if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } ctrlPropreties.relevancecondsExpression = relevancecondsToExpression($parent.id, $parent.isShowRelevanceCondition, $parent.relevanceconds); ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); ctrlPropreties.skipcondsExpression = skipcondsToExpression($parent.id, $parent.isShowSkipCondition, $parent.skipconds, ctrlType); } catch (e) { console.log('error : ' + e.message); } // Apply If .. Then .. Else in WebApps GUI processBindingIfThenElseActionEvent($parent, ctrlPropreties); // Apply Skip If in WebApps GUI (binding events) processBindingSkipIfActionEvent($parent, ctrlPropreties); } /*****************************************************************************************************************/ /*End********************************************inputSelectOne***************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************inputSelectMany**************************************************/ /*****************************************************************************************************************/ var fvEditorsInputSelectMany = function($parent, $control, ctrlType, ctrlPropreties){ // defaultValue var defaultValue; if(ctrlPropreties.val == undefined){ defaultValue = getValueOrEmpty($parent.defaultValue.value); setCtrlPropretiesValue(ctrlPropreties, defaultValue, true); fvEditorsSetDefaultValue(ctrlPropreties); }else{ defaultValue = ctrlPropreties.val; } if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } // label $control.find('.controlLabel').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.label.value.eng))); $control.off('checkAndSetRequired').on('checkAndSetRequired', function() { fvAppendRequired($parent, $control.find('.controlLabel')); }); $control.trigger('checkAndSetRequired'); // hint $control.find('.controlHint').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.hint.value.eng))); // options $optionsList = $control.find('.controlData').empty(); ctrlPropreties.options = {}; _.each($parent.options.value, function(option, i) { if (option.isShowUnderlying !== undefined){ return true; } var optionItem = $('#formview_templates .inputSelectManyOption') .clone() .addClass('inpCtrlID_' + ctrlPropreties.id) .appendTo($optionsList) .off('setLookupValue').on('setLookupValue', function(event, value, isSearchUndValue){ if(!isControlHiddenByRelevance(ctrlPropreties)){ setLookupValue($(this), ctrlType, $parent, value, isSearchUndValue, $control); } }); var ctrlId = $control.find('.controlData').attr('id') + '_' + i; optionItem.find('input') .attr('id', ctrlId) .val(option.val) .addClass('checkbox_' + option.val); optionItem.find('label').attr('for', ctrlId).empty().append(createHtmlDisplayText($parent)); var image = valueOrEmpty(option.image); if($parent.isHideAnswer && true == $parent.isHideAnswer.value){ optionItem.find(cssDisplayTextString($parent)).append(' '); } else if(image != ''){ if(image.indexOf('/imageViewer?blobKey=') >= 0){ image += "&maxWidth=" + fvDataNS.ctrlWidth; } var imageLink = $(''); imageLink.attr('src', image).attr('alt', option.text.eng).css('background-color', '#' + option.iconColor); optionItem.find(cssDisplayTextString($parent)).append(imageLink).addClass('dispTextWithImage'); var isFilibCanvas = FILIB_ICON_IMAGE_CANVAS && image.indexOf('img/filib/') >= 0; var isFilibButtonCanvas = FILIBBUTTON_ICON_IMAGE_CANVAS && image.indexOf('img/filibbutton/') >= 0; if(isFilibCanvas || isFilibButtonCanvas) { var canvasWidth = 96; var canvasHeight = 96; var imageWidth = 187; var imageHeight = 187; if(isFilibButtonCanvas) { canvasWidth = 96; canvasHeight = 28; imageWidth = CONST_FILIB_BUTTON_IMAGE_WIDTH; imageHeight = CONST_FILIB_BUTTON_IMAGE_HEIGHT; } var canvasLink = $(''); canvasLink.attr('src', image).attr('alt', option.text.eng).css('background-color', '#ffffff').css('margin','10px 0px'); imageLink.css('display', 'none'); var imageObj = new Image(); imageObj.canvas = canvasLink[0]; imageObj.iconColor = option.iconColor; imageObj.imageWidth = CONST_FILIB_BUTTON_IMAGE_WIDTH; imageObj.imageHeight = CONST_FILIB_BUTTON_IMAGE_HEIGHT; imageObj.canvasWidth = canvasWidth; imageObj.canvasHeight = canvasHeight; imageObj.drawImageToCanvas = function(){ drawImageToCanvas(this.canvas, this, this.iconColor, this.canvasWidth, this.canvasHeight, this.imageWidth, this.imageHeight); } imageObj.onload = function(){ this.drawImageToCanvas(); } imageObj.src = image; optionItem.find(cssDisplayTextString($parent)).append(canvasLink).addClass('dispTextWithImage'); } if(!$control.hasClass('hasImage')){ $control.addClass('hasImage'); } if(option.showAnswerText){ var displayText = $('

'); displayText.append(option.text.eng); optionItem.find(cssDisplayTextString($parent)).append(displayText); } }else{ optionItem.find(cssDisplayTextString($parent)).append(option.text.eng); } ctrlPropreties.options[option.val] = option.text.eng; }); $optionsList.find('input').attr('name', replaceNonAlphaNumericChar(ctrlPropreties.classPath, true)); var defaultValues = decodeBr('' + defaultValue).split("
"); for(var i =0; i' + itemValue); } } var ctrlValue = ctrlPropreties.val; requiredOnlyValidateError($parent, ctrlValue, $control.find('.controlInfMsg') , ctrlPropreties, $control); //$control.trigger('Control_Update') //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); }); } // hideInMobile $control.off('checkAndSetHide').on('checkAndSetHide', function() { execShowHideWebAppControl($control, $parent) }); $control.trigger('checkAndSetHide'); // relevanceconds addToCtrlIdRefForRelevance($parent.isShowRelevanceCondition, $parent.relevanceconds.value, ctrlPropreties.classPath); if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } ctrlPropreties.relevancecondsExpression = relevancecondsToExpression($parent.id, $parent.isShowRelevanceCondition, $parent.relevanceconds); ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); ctrlPropreties.skipcondsExpression = skipcondsToExpression($parent.id, $parent.isShowSkipCondition, $parent.skipconds, ctrlType); // Apply If .. Then .. Else in WebApps GUI (binding events) processBindingIfThenElseActionEvent($parent, ctrlPropreties); // Apply Skip If in WebApps GUI (binding events) processBindingSkipIfActionEvent($parent, ctrlPropreties); } /*****************************************************************************************************************/ /*End********************************************inputSelectMany**************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************inputScoreOne***************************************************/ /*****************************************************************************************************************/ var fvEditorsInputScoreOne = function($parent, $control, ctrlType, ctrlPropreties){ // defaultValue var defaultValue; if(ctrlPropreties.val == undefined){ defaultValue = getValueOrEmpty($parent.defaultValue.value); setCtrlPropretiesValue(ctrlPropreties, defaultValue, true); fvEditorsSetDefaultValue(ctrlPropreties); }else{ defaultValue = ctrlPropreties.val; } if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } // label $control.find('.controlLabel').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.label.value.eng))); $control.off('checkAndSetRequired').on('checkAndSetRequired', function() { fvAppendRequired($parent, $control.find('.controlLabel')); }); $control.trigger('checkAndSetRequired'); // hint $control.find('.controlHint').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.hint.value.eng))); // scoreCategory ctrlPropreties.scoreCategory = $parent.scoreCategory.value; if(fvDataNS.scoreData[$parent.scoreCategory.value] == undefined){ fvDataNS.scoreData[$parent.scoreCategory.value] = {}; } var scoreCategory = fvDataNS.scoreData[$parent.scoreCategory.value]; var maxOptionValue = undefined; // options $optionsList = $control.find('.controlData').empty(); var showAsDropdown = false; if($parent.showAsDropdown != undefined && $parent.showAsDropdown.value){ showAsDropdown = $parent.showAsDropdown.value; } if(isVersion(VERSION_DROPDOWN_SCORE_ONE)) { if ($parent.displayType && $parent.displayType.value){ if($parent.displayType.value == CONST_DROPDOWN){ showAsDropdown = true; }else{ showAsDropdown = false; } } } if(showAsDropdown){ $selectionList = $('#formview_templates .inputSelectOneOptionDropdown') .clone() .appendTo($optionsList); $selectionList = $selectionList.find('select'); $selectionList .addClass('inpCtrlID_' + ctrlPropreties.id) .appendTo($optionsList) .off('setLookupValue').on('setLookupValue', function(event, value, isSearchUndValue){ if(!isControlHiddenByRelevance(ctrlPropreties)){ setLookupValue($(this), ctrlType, $parent, value, isSearchUndValue, $control); } }) .blur(function(event) { var ctrlValue = ctrlPropreties.val; textValidateError($parent, ctrlValue, $control.find('.controlInfMsg') , ctrlPropreties, $control); }); if($parent.isAllowUncheck && $parent.isAllowUncheck.value){ $(''); if(response != undefined){ waDispatchUnits['PlusProjects'] = response.sort(); for ( var m = 0; m < waDispatchUnits['PlusProjects'].length; m++) { var info = waDispatchUnits['PlusProjects'][m].split('$'); var selected = ''; if(info[2] == curTmpProject){ selected = ' selected'; resetHtmlFlg = false; } $('.inpCtrlID_dispatchUPrj') .append(''); } } } catch(e){ } if(resetHtmlFlg){ // reset form structure $(".formView .fvWorkspace > *:not('.waDisTable, .waDisSendType, .sentToEmailBar, .sentToSMSBar, .waDisProjectForm, .waRootContainer')").remove(); // reset form list $('.inpCtrlID_dispatchUFrm').empty().append(''); } }, error: function(request, status, error) { jAlert(msg_error_try); } }); } } } else{ webAppItem[2].val = ctrlPropreties.val; if(fvDataNS.currentForm.editRecordData != undefined && fvDataNS.currentForm.editRecordData['@Nickname'] != undefined){ fvDataNS.currentForm.editRecordData['@Nickname'].value = ctrlPropreties.val; } // update value for dispatched mobile number //if(ctrlPropreties.val != ''){ $('.inpCtrlID_dispatchUID').trigger('setLookupValue', [ctrlPropreties.val, true]); //} } } else if('dispatchMobileGroup' == ctrlPropreties.id){ var gKey = $(this).find('option:selected').attr('gKey'); if(gKey != undefined && gKey != ''){ gKey = '@' + gKey; } else if(gKey == undefined){ gKey = ''; } generateDispatchMobiles(ctrlPropreties.val+gKey, ''); } else if('dispatchUPrj' == ctrlPropreties.id){ waitForDataLoading(true); $.ajax({ url: '/formpreview?disPlus=prj&prjKey=' + ctrlPropreties.val, dataType: 'json', type: 'GET', cache: false, complete: function() { if(changeFlg != undefined && previewFormKey != undefined && previewFormKey != ''){ fvDataNS.isPlusLoading = true; // CO-4608 $('.inpCtrlID_dispatchUFrm').val(previewFormKey); var projectKeyTmp = $('.inpCtrlID_dispatchUPrj').val(); if(!projectKeyTmp) { projectKeyTmp = previewProjectKey; } fvOpenForm(previewFormKey, projectKeyTmp, undefined, false); } else{ fvDataNS.isPlusLoading = false; fvDataNS.isLoading = false; waitForDataLoading(false); } }, success: function(response, status) { // re-generate mobiles html if(response.MUNumbers != undefined){ waDispatchUnits['MUGroups'] = response.MUGroups; waDispatchUnits['MUNumbers'] = response.MUNumbers; waDispatchUnits['MUNames'] = response.MUNames; generateDispatchMobiles('', waDispatchUnits['PlusMobile']); } // re-generate forms html if(response.PlusForms != undefined){ $(".formView .fvWorkspace > *:not('.waDisTable, .waDisSendType, .sentToEmailBar, .sentToSMSBar, .waDisProjectForm, .waRootContainer')").remove(); $('.inpCtrlID_dispatchUFrm').empty() .append(''); var objPlusFrm = response.PlusForms; // waDispatchUnits['PlusForms'] objPlusFrm.sort(); for ( var m = 0; m < objPlusFrm.length; m++) { var info = objPlusFrm[m].split('$'); $('.inpCtrlID_dispatchUFrm') .append(''); } } }, error: function(request, status, error) { jAlert(msg_error_try); } }); } else if('dispatchUFrm' == ctrlPropreties.id){ if(ctrlPropreties.val == ''){ fvDataNS.isPlusLoading = false; // CO-4608 jAlert(msg_form_key_4_useform_empty); } else if($('.inpCtrlID_dispatchUPrj').val() == ''){ fvDataNS.isPlusLoading = false; jAlert(msg_project_key_4_useform_empty); } else{ fvDataNS.isPlusLoading = true; fvOpenForm(ctrlPropreties.val, $('.inpCtrlID_dispatchUPrj').val(), undefined, false); } } else if('dispatchURepeat' == ctrlPropreties.id){ // show first blank option $('.inpCtrlID_dispatchURepeat option:first').css(CONST_CSS_KEY_DISPLAY, ''); if('daily' == ctrlPropreties.val){ //$('#repeatType').html('Repeat Daily'); $('#intervalLabel').html('Interval Day(s)'); $('#rowWeekly').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); $('#rowMonthly1').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); $('#rowMonthly2').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); $('#rowYearly1').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); $('#rowYearly2').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); $('#repeatDailyContainer').css(CONST_CSS_KEY_DISPLAY, ''); } else if('weekly' == ctrlPropreties.val){ //$('#repeatType').html('Repeat Weekly'); $('#intervalLabel').html('Interval Week(s)'); $('#rowWeekly').css(CONST_CSS_KEY_DISPLAY, ''); $('#rowMonthly1').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); $('#rowMonthly2').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); $('#rowYearly1').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); $('#rowYearly2').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); $('#repeatDailyContainer').css(CONST_CSS_KEY_DISPLAY, ''); } else if('monthly' == ctrlPropreties.val){ //$('#repeatType').html('Repeat Monthly'); $('#intervalLabel').html('Interval Month(s)'); $('#rowWeekly').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); $('#rowMonthly1').css(CONST_CSS_KEY_DISPLAY, ''); $('#rowMonthly2').css(CONST_CSS_KEY_DISPLAY, ''); $('#rowYearly1').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); $('#rowYearly2').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); $('#repeatDailyContainer').css(CONST_CSS_KEY_DISPLAY, ''); } else if('yearly' == ctrlPropreties.val){ //$('#repeatType').html('Repeat Yearly'); $('#intervalLabel').html('Interval Year(s)'); $('#rowWeekly').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); $('#rowMonthly1').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); $('#rowMonthly2').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); $('#rowYearly1').css(CONST_CSS_KEY_DISPLAY, ''); $('#rowYearly2').css(CONST_CSS_KEY_DISPLAY, ''); $('#repeatDailyContainer').css(CONST_CSS_KEY_DISPLAY, ''); } else{ $('#repeatDailyContainer').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); } // Edit case => trigger onChange => set default value /*if(changeFlg != undefined){ setPlusRepeatEditData(ctrlPropreties.val, fvDataNS.currentForm.editRecordData); }*/ } } catch (e) { } try { executeControlChange(ctrlPropreties.classPath); executeSkipChange(ctrlPropreties); } catch (e) { } }); } }else{ ctrlPropreties.options = {}; _.each($parent.options.value, function(option, i) { if (option.isShowUnderlying !== undefined){ return true; } var optionItem = $('#formview_templates .inputSelectOneOption') .clone() .addClass('inpCtrlID_' + ctrlPropreties.id) .appendTo($optionsList) .off('setLookupValue').on('setLookupValue', function(event, value, isSearchUndValue){ if(!isControlHiddenByRelevance(ctrlPropreties)){ setLookupValue($(this), ctrlType, $parent, value, isSearchUndValue, $control); } }); if(!isNaN(option.val)){ var tmp = parseFloat(option.val); if(maxOptionValue == undefined || maxOptionValue < tmp){ maxOptionValue = tmp; } } var ctrlId = $control.find('.controlData').attr('id') + '_' + i; optionItem.find('input') .attr('id', ctrlId) .val(option.val) .addClass('radio_' + replaceNonAlphaNumericChar(option.val)); optionItem.find('label').attr('for', ctrlId).empty().append(createHtmlDisplayText($parent)); var image = valueOrEmpty(option.image); if(image != ''){ if(image.indexOf('/imageViewer?blobKey=') >= 0){ image += "&maxWidth=" + fvDataNS.ctrlWidth; } var imageLink = $(''); imageLink.attr('src', image).attr('alt', option.text.eng).css('background-color', '#' + option.iconColor); optionItem.find(cssDisplayTextString($parent)).append(imageLink).addClass('dispTextWithImage'); var isFilibCanvas = FILIB_ICON_IMAGE_CANVAS && image.indexOf('img/filib/') >= 0; var isFilibButtonCanvas = FILIBBUTTON_ICON_IMAGE_CANVAS && image.indexOf('img/filibbutton/') >= 0; if(isFilibCanvas || isFilibButtonCanvas) { var canvasWidth = 96; var canvasHeight = 96; var imageWidth = 187; var imageHeight = 187; if(isFilibButtonCanvas) { canvasWidth = 96; canvasHeight = 28; imageWidth = CONST_FILIB_BUTTON_IMAGE_WIDTH; imageHeight = CONST_FILIB_BUTTON_IMAGE_HEIGHT; } var canvasLink = $(''); canvasLink.attr('src', image).attr('alt', option.text.eng).css('background-color', '#ffffff').css('margin','10px 0px'); imageLink.css('display', 'none'); var imageObj = new Image(); imageObj.canvas = canvasLink[0]; imageObj.iconColor = option.iconColor; imageObj.imageWidth = CONST_FILIB_BUTTON_IMAGE_WIDTH; imageObj.imageHeight = CONST_FILIB_BUTTON_IMAGE_HEIGHT; imageObj.canvasWidth = canvasWidth; imageObj.canvasHeight = canvasHeight; imageObj.drawImageToCanvas = function(){ drawImageToCanvas(this.canvas, this, this.iconColor, this.canvasWidth, this.canvasHeight, this.imageWidth, this.imageHeight); } imageObj.onload = function(){ this.drawImageToCanvas(); } imageObj.src = image; optionItem.find(cssDisplayTextString($parent)).append(canvasLink).addClass('dispTextWithImage'); } if(!$control.hasClass('hasImage')){ $control.addClass('hasImage'); } if(option.showAnswerText){ var displayText = $('

'); displayText.append(option.text.eng); optionItem.find(cssDisplayTextString($parent)).append(displayText); } }else{ optionItem.find(cssDisplayTextString($parent)).append(option.text.eng); } ctrlPropreties.options[option.val] = option.text.eng; }); if(maxOptionValue != undefined){ scoreCategory[$parent.name.value] = maxOptionValue; } $optionsList.find('input').attr('name', replaceNonAlphaNumericChar(ctrlPropreties.classPath, true)); $optionsList.find('.radio_' + replaceNonAlphaNumericChar(defaultValue)).prop('checked', true); // readOnly $control.off('checkAndSetReadOnly').on('checkAndSetReadOnly', function() { if(isReadOnlyApply($parent) || ctrlPropreties.isCtrlReadOnly == true){ $control.find('.controlData input').prop('disabled', true); $control.find('.inputSelectOneOption').addClass('ctrlReadOnly'); } else { $control.find('.controlData input').prop('disabled', false); $control.find('.inputSelectOneOption').removeClass('ctrlReadOnly'); } }); $control.trigger('checkAndSetReadOnly', $parent); // new { $control.off('clearData').on('clearData', function(event, setDefaultValue){ var $ctrl = $(this).find('input'); $ctrl.prop('checked', false); if(setDefaultValue){ var defaultValueTmp = getValueOrEmpty($parent.defaultValue.value); $(this).find('.radio_' + replaceNonAlphaNumericChar(defaultValueTmp)).prop('checked', true); setCtrlPropretiesValue(ctrlPropreties, defaultValueTmp); }else{ setCtrlPropretiesValue(ctrlPropreties, ''); } //$control.trigger('Control_Update') //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); }); $control.off('Control_Update').on('Control_Update', function(event){ event.stopPropagation(); if(fvDataNS.dontCallTrigger) return; return controlUpdate($parent, ctrlPropreties); }); $control.find('input').change(function(event) { if(event.cancelable != undefined){ setFocusCtrlMap(ctrlPropreties.classPath); fvDataNS.focusControl = this; } setCtrlPropretiesValue(ctrlPropreties, $control.find('input:radio:checked').val()); fvDataNS.ignoreLostFocus = false; if(ctrlPropreties.isValueChange){ myPostMessage($control, 'change'); } //$control.trigger('Control_Update') //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); // Process validate required // Fix bug 0018711: Warning message didn't show when user click on caption text! requiredOnlyValidateError($parent, ctrlPropreties.val, $control.find('.controlInfMsg') , ctrlPropreties, $control); executeSkipChange(ctrlPropreties); }); if($parent.isAllowUncheck && $parent.isAllowUncheck.value){ $control.find('.check').mouseup(function(event){ var ctrl = $(this).find('input'); if(ctrl.is(':checked')){ setTimeout(function(event){ ctrl.prop('checked', false).trigger('clearData', false); }, 100); } }); } // Adding required checking // Fix bug 0018711: Warning message didn't show when user click on caption text! $control.off('processCheckRequired').on('processCheckRequired', function() { var ctrlValue = $control.find('input:radio:checked').val(); if (typeof ctrlValue === 'undefined') { ctrlValue = ''; } requiredOnlyValidateError($parent, ctrlValue, $control.find('.controlInfMsg') , ctrlPropreties, $control); }); } } // relevanceconds addToCtrlIdRefForRelevance($parent.isShowRelevanceCondition, $parent.relevanceconds.value, ctrlPropreties.classPath); if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } ctrlPropreties.relevancecondsExpression = relevancecondsToExpression($parent.id, $parent.isShowRelevanceCondition, $parent.relevanceconds); ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); ctrlPropreties.skipcondsExpression = skipcondsToExpression($parent.id, $parent.isShowSkipCondition, $parent.skipconds, ctrlType); // Apply If .. Then .. Else in WebApps GUI (binding events) processBindingIfThenElseActionEvent($parent, ctrlPropreties); // Apply Skip If in WebApps GUI (binding events) processBindingSkipIfActionEvent($parent, ctrlPropreties); } /*****************************************************************************************************************/ /*End********************************************inputScoreOne***************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************inputLocation****************************************************/ /*****************************************************************************************************************/ var fvEditorsInputLocation = function($parent, $control, ctrlType, ctrlPropreties){ // CO-1912 Verify Setting - Location Fields setVerifyAddress(ctrlPropreties, $parent); //CO-4087: Add Get address option to GPS location setLocationStyle($parent, $control, ctrlType, ctrlPropreties); check4GetStaticImage($parent, $control, ctrlType, ctrlPropreties); // allow edit // CO-842 Location Pick from map button should hide when allow edit is unchecked if($parent.isAllowEdit && $parent.isAllowEdit.value == false){ $control.addClass('notAllowEdit'); } // defaultValue var defaultValue; if(ctrlPropreties.val == undefined){ defaultValue = getValueOrEmpty($parent.defaultValue.value); setCtrlPropretiesValue(ctrlPropreties, defaultValue, true); fvEditorsSetDefaultValue(ctrlPropreties); }else{ defaultValue = ctrlPropreties.val; if($parent.isAllowEdit && $parent.isAllowEdit.value == false){ if(fvDataNS.currentForm && fvDataNS.currentForm.editRecordData){ if($parent.readOnlyViewEdit){ $parent.readOnlyViewEdit.value = true; } if($parent.readOnlyDispatchEdit){ $parent.readOnlyDispatchEdit.value = true; } } } } /*var title = ''; if($parent.defaultValue.value != undefined && $parent.defaultValue.value != ''){ title = 'Default value : ' + $parent.defaultValue.value; }*/ $control.find('.controlData') .addClass('inpCtrlID_' + ctrlPropreties.id) //.attr('title', title) .off('setLookupValue').on('setLookupValue', function(event, value, isSearchUndValue){ if(!isControlHiddenByRelevance(ctrlPropreties)){ setLookupValue($(this), ctrlType, $parent, value, isSearchUndValue, $control); // CO-1912 Verify Setting - Location Fields runVerifyAddress(ctrlPropreties); } }); if($parent.showAsDecimal){ setGPS($parent, $control, defaultValue, $parent.showAsDecimal.value); }else{ setGPS($parent, $control, defaultValue); } if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } // label $control.find('.controlLabel').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.label.value.eng))); $control.off('checkAndSetRequired').on('checkAndSetRequired', function() { fvAppendRequired($parent, $control.find('.controlLabel')); }); $control.trigger('checkAndSetRequired'); // hint $control.find('.controlHint').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.hint.value.eng))); // hideInMobile $control.off('checkAndSetHide').on('checkAndSetHide', function() { execShowHideWebAppControl($control, $parent) }); $control.trigger('checkAndSetHide'); var isReadOnly = false; // readOnly $control.off('checkAndSetReadOnly').on('checkAndSetReadOnly', function() { if(isReadOnlyApply($parent) || ctrlPropreties.isCtrlReadOnly == true){ $control.find('.controlData input').prop('disabled', true); $control.find('.inputinner').addClass('ctrlReadOnly'); isReadOnly = true; var tmpHref = $control.find('.gpsPickFromMap a, .controlInfo4AdvancedStyle a, .controlInfo4AdvancedStyle img').attr('href'); $control.find('.gpsPickFromMap a, .controlInfo4AdvancedStyle a, .controlInfo4AdvancedStyle img').attr('href1',tmpHref).removeAttr('href').off(); $control.find('.gpsPickFromMap').addClass(CONST_CSS_CLASS_HIDE_SESSION); $control.addClass('noCaptureBtn'); } else { $control.find('.controlData input').prop('disabled', false); $control.find('.inputinner').removeClass('ctrlReadOnly'); isReadOnly = false; var tmpHref = $control.find('.gpsPickFromMap a, .controlInfo4AdvancedStyle a, .controlInfo4AdvancedStyle img').attr('href1'); $control.find('.gpsPickFromMap a, .controlInfo4AdvancedStyle a, .controlInfo4AdvancedStyle img').attr('href',tmpHref); initPickFromMap(); } }); $control.trigger('checkAndSetReadOnly', $parent); // new { $control.off('clearData').on('clearData', function(event, setDefaultValue){ var $ctrl = $(this).find('.controlData input'); if(setDefaultValue){ if($parent.showAsDecimal){ setGPS($parent, $control, getValueOrEmpty($parent.defaultValue.value), $parent.showAsDecimal.value); }else{ setGPS($parent, $control, getValueOrEmpty($parent.defaultValue.value)); } }else{ setGPS($parent, $control, ''); } setCtrlPropretiesValue(ctrlPropreties, getGPS($control)); // CO-1912 Verify Setting - Location Fields runVerifyAddress(ctrlPropreties); //$control.trigger('Control_Update') //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); }); $control.off('Control_Update').on('Control_Update', function(event){ event.stopPropagation(); if(fvDataNS.dontCallTrigger) return; return controlUpdate($parent, ctrlPropreties); }); $control.find('.controlData input') .keyup(function(event) { pointNotAtFirst(this, event); cleanDecNum(this); setCtrlPropretiesValue(ctrlPropreties, getGPS($control)); // CO-1912 Verify Setting - Location Fields runVerifyAddress(ctrlPropreties); fvDataNS.ignoreLostFocus = false; //$(this).change(); }) .attr("autocomplete", "off") .on("beforeinput keypress", function(event){ if(!isRunEvent(event)){ return; } if(event.ctrlKey == true && (event.charCode == 118 || event.charCode == 99 || event.charCode == 120)){ return; } if(!inputTextOnlyDecimalNumber(this, event, DECINAM_MAXLENGTH)) event.preventDefault(); }) .off("drop").on("drop",function(e) { e.preventDefault(); }) .off('input propertychange').on('input propertychange', function(e) { onlyNumber_Propertychange($(this), ctrlPropreties, 'Decimal', DECINAM_MAXLENGTH); }) .change(function(event) { if(!fvDataNS.ignoreLostFocus){ setCtrlPropretiesValue(ctrlPropreties, getGPS($control)); // CO-1912 Verify Setting - Location Fields runVerifyAddress(ctrlPropreties); //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); // PCA-206: Web App support for additional GPS info option // PCA-207: Form Preview support for additional GPS info option refreshInformationData4LocationWA($parent, $control, ctrlPropreties); var currentVal = ''; if (ctrlPropreties.val !== undefined && ctrlPropreties.val !== null) { currentVal = ctrlPropreties.val; } $(this).attr('valueWhenFocus', currentVal); return; }else{ fvDataNS.ignoreLostFocus = false; } }) // PCA-206: Web App support for additional GPS info option // PCA-207: Form Preview support for additional GPS info option .focus(function(event) { switch(ctrlPropreties.locationStype){ case CONST_TYPE_ADVANCED: return; } // Save the value when focus into GPS fields $(this).val(formatGpsToCoordinates($(this).val())); var currentVal = ''; if (ctrlPropreties.val !== undefined && ctrlPropreties.val !== null) { currentVal = ctrlPropreties.val; } $(this).attr('valueWhenFocus', currentVal); }) .blur(function(event) { $(this).change(); switch(ctrlPropreties.locationStype){ case CONST_TYPE_ADVANCED: return; } if(!($parent.showAsDecimal && $parent.showAsDecimal.value == true)){ if($(this).hasClass('inputLatitude')){ $(this).val(formatGpsToDegree($(this).val(), 'lat')); }else if($(this).hasClass('inputLongitude')){ $(this).val(formatGpsToDegree($(this).val(), 'lon')); } } var ctrlValue = getGPSForValidate($control); requiredOnlyValidateError($parent, ctrlValue, $control.find('.controlInfMsg') , ctrlPropreties, $control); // PCA-206: Web App support for additional GPS info option // PCA-207: Form Preview support for additional GPS info option refreshInformationData4LocationWA($parent, $control, ctrlPropreties); /*// CO-842 Location Pick from map button should hide when allow edit is unchecked if($control.hasClass('notAllowEdit') && $(this).val() != ''){ $(this).prop('disabled', true); //$control.find('.gpsPickFromMap').addClass(CONST_CSS_CLASS_HIDE_SESSION); $control.addClass('hasData'); }*/ // Check if we need refesh the GPS Image or not var currentVal = $(this).attr('valueWhenFocus'); if (ctrlPropreties.val !== currentVal) { // PCA-277 : Pick from map // Apply drawing EmbbedGPS Image for WebApps var latitude = ''; var longitude = ''; var arrGPS = []; if (ctrlPropreties.val !== undefined && ctrlPropreties.val !== null) { arrGPS = ctrlPropreties.val.split(' '); } if (arrGPS.length > 0) { latitude = arrGPS[0]; } if (arrGPS.length > 1) { longitude = arrGPS[1]; } applyDrawEmbbedGPSImage4WebApps($control, getGPSMapDisplay($parent), getGPSZoom($parent), latitude, longitude); } }); } function initPickFromMap() { if(isVersion(VERSION_5_0)){ if(isReadOnly){ //$control.find('.gpsPickFromMap a').attr("href", "#"); $control.find('.gpsPickFromMap a, .controlInfo4AdvancedStyle a, .controlInfo4AdvancedStyle img').removeAttr('href'); // fix bug 23404 }else{ var fbWidth = 800; var fbHeight = 480; if(isTabletPreview){ fbWidth = 400; fbHeight = 340; }else{ var screenWidth = $(window).width(); if(screenWidth - 100 < fbWidth){ var tmp = 60; fbWidth = screenWidth - 100; //fbHeight = Math.round(fbWidth*tmp/100); } } $control.find('.gpsPickFromMap a, .controlInfo4AdvancedStyle a, .controlInfo4AdvancedStyle img').fancybox({ 'width' : fbWidth, 'height' : fbHeight, 'modal' : true, 'autoScale' : false, 'transitionIn' : CONST_VALUE_NONE, 'transitionOut' : CONST_VALUE_NONE, 'type' : 'iframe', 'closeBtn' : false, onComplete : function() { $('#fancybox-wrap').addClass('pickGPSFromMapContainer'); // CO-2151 Fix problem with pick from map }, onStart : function(){ var arrGPS = ctrlPropreties.val.split(' '); if(arrGPS[1] == undefined){ arrGPS[1] = '0'; } this.href = '/html/latlon_select.html?inputLat=' + arrGPS[0] + '&inputLon=' + arrGPS[1]; $("body").css({'overflow-y':'hidden'}); $(".fvWorkspaceScrollArea").css({'overflow':'hidden'}); glbHashObject['flgHasClickButtonSelect'] = false; if(ctrlPropreties.hideButtonAfterClick){ $control.addClass(CONST_CLASS_HIDE_CONTROL); updateButtonHideAfterClick(ctrlPropreties.classPath); } }, onCleanup : function(){ if(glbHashObject['flgHasClickButtonSelect']){ // PCA-277 : Pick from map // $control.find('.controlData input.inputLatitude').val($('#fancybox-frame').contents().find('input.inputLat').val()); // $control.find('.controlData input.inputLongitude').val($('#fancybox-frame').contents().find('input.inputLon').val()); var latitudeVal = $('#fancybox-frame').contents().find('input.inputLat').val(); var longtitudeV = $('#fancybox-frame').contents().find('input.inputLon').val(); if(!($parent.showAsDecimal && $parent.showAsDecimal.value == true)){ $control.find('.controlData input.inputLatitude').val(formatGpsToDegree(latitudeVal, 'lat')); $control.find('.controlData input.inputLongitude').val(formatGpsToDegree(longtitudeV, 'lon')); }else{ $control.find('.controlData input.inputLatitude').val(latitudeVal); $control.find('.controlData input.inputLongitude').val(longtitudeV); } applyGetAddress($control, latitudeVal, longtitudeV); // PCA-277 : Pick from map // Apply drawing EmbbedGPS Image for WebApps (with waiting dialogs) applyDrawEmbbedGPSImage4WebApps($control, getGPSMapDisplay($parent), getGPSZoom($parent), latitudeVal, longtitudeV, true); /*// CO-842 Location Pick from map button should hide when allow edit is unchecked if($control.hasClass('notAllowEdit') && $control.find('.controlData input.inputLatitude').val() != ''){ $control.find('.controlData input.inputLatitude').prop('disabled', true); //$control.find('.gpsPickFromMap').addClass(CONST_CSS_CLASS_HIDE_SESSION); $control.addClass('hasData'); } if($control.hasClass('notAllowEdit') && $control.find('.controlData input.inputLongitude').val() != ''){ $control.find('.controlData input.inputLongitude').prop('disabled', true); //$control.find('.gpsPickFromMap').addClass(CONST_CSS_CLASS_HIDE_SESSION); $control.addClass('hasData'); }*/ $control.find('.controlData input.inputAltitude').val('0'); $control.find('.controlData input.inputAccuracy').val('0').trigger('change'); setCtrlPropretiesValue(ctrlPropreties, getGPS($control)); // CO-1912 Verify Setting - Location Fields runVerifyAddress(ctrlPropreties); // PCA-206: Web App support for additional GPS info option // PCA-207: Form Preview support for additional GPS info option refreshInformationData4LocationWA($parent, $control, ctrlPropreties); if(ctrlPropreties.hideButtonAfterClick){ setTimeout(function(){ $control.addClass(CONST_CLASS_HIDE_CONTROL); updateButtonHideAfterClick(ctrlPropreties.classPath); }, 100); } } }, onClosed : function(){ $("body").css({'overflow-y':'visible'}); $(".fvWorkspaceScrollArea").css({'overflow':'auto'}); //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); } }); } }else{ $control.find('.gpsPickFromMap').remove(); } } initPickFromMap(); // relevanceconds addToCtrlIdRefForRelevance($parent.isShowRelevanceCondition, $parent.relevanceconds.value, ctrlPropreties.classPath); if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } // verify address addVerifyAddressCtrlClass($control, ctrlPropreties); ctrlPropreties.relevancecondsExpression = relevancecondsToExpression($parent.id, $parent.isShowRelevanceCondition, $parent.relevanceconds); ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); ctrlPropreties.skipcondsExpression = skipcondsToExpression($parent.id, $parent.isShowSkipCondition, $parent.skipconds, ctrlType); // PCA-206: Web App support for additional GPS info option // PCA-207: Form Preview support for additional GPS info option refreshInformationData4LocationWA($parent, $control, ctrlPropreties); // Apply If .. Then .. Else in WebApps GUI (binding events) processBindingIfThenElseActionEvent($parent, ctrlPropreties); // Apply Skip If in WebApps GUI (binding events) processBindingSkipIfActionEvent($parent, ctrlPropreties); } /*****************************************************************************************************************/ /*End********************************************inputLocation****************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************inputBarcode*****************************************************/ /*****************************************************************************************************************/ var fvEditorsInputBarcode = function($parent, $control, ctrlType, ctrlPropreties){ // defaultValue var defaultValue; if(ctrlPropreties.val == undefined){ defaultValue = getValueOrEmpty($parent.defaultValue.value); setCtrlPropretiesValue(ctrlPropreties, defaultValue, true); fvEditorsSetDefaultValue(ctrlPropreties); }else{ defaultValue = ctrlPropreties.val; } /*var title = ''; if($parent.defaultValue.value != undefined && $parent.defaultValue.value != ''){ title = 'Default value : ' + $parent.defaultValue.value; }*/ $control.find('.controlData .btnScanSession').click(function(){ focusControl($control); }); ctrlPropreties.lastParseValue = defaultValue; $control.find('.controlData input') .addClass('inpCtrlID_' + ctrlPropreties.id) //.attr('title', title) .val(defaultValue) .off('setLookupValue').on('setLookupValue', function(event, value, isSearchUndValue){ if(!isControlHiddenByRelevance(ctrlPropreties)){ setLookupValue($(this), ctrlType, $parent, value, isSearchUndValue, $control); removeIconAndDisbleCtrlAfterEdit(ctrlPropreties.val, $parent, $control); var ctrlValue = $(this).val(); if(ctrlValue != ctrlPropreties.lastParseValue){ ctrlPropreties.lastParseValue = ctrlValue; parseBarcodeData($parent, ctrlValue, ctrlPropreties.parrentProperties); parseTextData($(this), $parent, ctrlValue, ctrlPropreties.parrentProperties); } appendBarcodeImage(ctrlPropreties, $parent, $control); } }); // hideInMobile $control.off('checkAndSetHide').on('checkAndSetHide', function() { execShowHideWebAppControl($control, $parent) }); $control.trigger('checkAndSetHide'); if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } if(ctrlPropreties.length && ctrlPropreties.length.max && ctrlPropreties.length.cannotExceedMaximum){ $control.find('.controlData input').attr('maxlength',ctrlPropreties.length.max); } // label $control.find('.controlLabel').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.label.value.eng))); $control.off('checkAndSetRequired').on('checkAndSetRequired', function() { fvAppendRequired($parent, $control.find('.controlLabel')); }); $control.trigger('checkAndSetRequired'); // hint $control.find('.controlHint').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.hint.value.eng))); //if(isTabletPreview){ $control.find('.inputinner').addClass('cls4PreviewOnly'); if($parent.btnType && $parent.btnType.value == 'Image'){ $control.addClass('show-icon'); } //} // readOnly $control.off('checkAndSetReadOnly').on('checkAndSetReadOnly', function() { if(isReadOnlyApply($parent) || ctrlPropreties.isCtrlReadOnly == true){ $control.find('.controlData input').prop('disabled', true); $control.find('.inputinner').addClass('ctrlReadOnly'); } else { $control.find('.controlData input').prop('disabled', false); $control.find('.inputinner').removeClass('ctrlReadOnly'); } }); $control.trigger('checkAndSetReadOnly', $parent); // new { $control.off('clearData').on('clearData', function(event, setDefaultValue){ var $ctrl = $(this).find('.controlData input'); if(setDefaultValue){ $ctrl.val(getValueOrEmpty($parent.defaultValue.value)); }else{ $ctrl.val(''); } setCtrlPropretiesValue(ctrlPropreties, $ctrl.val()); //$control.trigger('Control_Update') //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); var ctrlValue = ''; if(ctrlValue != ctrlPropreties.lastParseValue){ ctrlPropreties.lastParseValue = ctrlValue; parseBarcodeData($parent, ctrlValue, ctrlPropreties.parrentProperties); parseTextData($(this), $parent, ctrlValue, ctrlPropreties.parrentProperties); } }); $control.off('Control_Update').on('Control_Update', function(event){ event.stopPropagation(); if(fvDataNS.dontCallTrigger) return; return controlUpdate($parent, ctrlPropreties); }); appendBarcodeImage(ctrlPropreties, $parent, $control); $control.find('.controlData input') .keyup(function(event) { setCtrlPropretiesValue(ctrlPropreties, $(this).val()); fvDataNS.ignoreLostFocus = false; //$(this).change(); }) .attr("autocomplete", "off") .on("beforeinput keypress", function(event){ if(!isRunEvent(event)){ return; } if(event.ctrlKey == true && (event.charCode == 118 || event.charCode == 99 || event.charCode == 120)){ return; } /*if($parent.kind != undefined && $parent.kind.value == 'Number'){ //return onlyIntegerNumber(this,event, INTEGER_MAXLENGTH); return onlyNumber(this); }else{ return toNextCtrl(this,event, ctrlPropreties); }*/ var ctrlValue = ctrlPropreties.val; textValidateMaxLength($parent, ctrlValue, $control.find('.controlInfMsg'), event); return toNextCtrl(this,event, ctrlPropreties); }) .off("drop").on("drop",function(e) { if($parent.kind != undefined && $parent.kind.value == 'Number'){ e.preventDefault(); } }) .off('input propertychange').on('input propertychange', function(e) { if($parent.kind != undefined && $parent.kind.value == 'Number'){ onlyNumber_Propertychange($(this), ctrlPropreties, 'Integer', INTEGER_MAXLENGTH); } }) .change(function(event) { if(!fvDataNS.ignoreLostFocus){ setCtrlPropretiesValue(ctrlPropreties, $(this).val()); //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); return; }else{ fvDataNS.ignoreLostFocus = false; } }) .blur(function(event) { $(this).change(); var ctrlValue = ctrlPropreties.val; textValidateError($parent, ctrlValue, $control.find('.controlInfMsg') , ctrlPropreties, $control); removeIconAndDisbleCtrlAfterEdit(ctrlPropreties.val, $parent, $control); if(ctrlValue != ctrlPropreties.lastParseValue){ ctrlPropreties.lastParseValue = ctrlValue; parseBarcodeData($parent, ctrlValue, ctrlPropreties.parrentProperties); parseTextData($(this), $parent, ctrlValue, ctrlPropreties.parrentProperties); } appendBarcodeImage(ctrlPropreties, $parent, $control); }); if($parent.kind != undefined && $parent.kind.value == 'Number'){ onlyNumber($control.find('.controlData input')); } } // relevanceconds addToCtrlIdRefForRelevance($parent.isShowRelevanceCondition, $parent.relevanceconds.value, ctrlPropreties.classPath); if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } ctrlPropreties.relevancecondsExpression = relevancecondsToExpression($parent.id, $parent.isShowRelevanceCondition, $parent.relevanceconds); ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); ctrlPropreties.skipcondsExpression = skipcondsToExpression($parent.id, $parent.isShowSkipCondition, $parent.skipconds, ctrlType); // Apply If .. Then .. Else in WebApps GUI (binding events) processBindingIfThenElseActionEvent($parent, ctrlPropreties); // Apply Skip If in WebApps GUI (binding events) processBindingSkipIfActionEvent($parent, ctrlPropreties); removeIconAndDisbleCtrlAfterEdit(ctrlPropreties.val, $parent, $control); } /*****************************************************************************************************************/ /*End********************************************inputBarcode*****************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************inputNFC*********************************************************/ /*****************************************************************************************************************/ var fvEditorsInputNFC = function($parent, $control, ctrlType, ctrlPropreties){ // defaultValue var defaultValue; if(ctrlPropreties.val == undefined){ defaultValue = getValueOrEmpty($parent.defaultValue.value); setCtrlPropretiesValue(ctrlPropreties, defaultValue, true); fvEditorsSetDefaultValue(ctrlPropreties); }else{ defaultValue = ctrlPropreties.val; } /*var title = ''; if($parent.defaultValue.value != undefined && $parent.defaultValue.value != ''){ title = 'Default value : ' + $parent.defaultValue.value; }*/ $control.find('.controlData .btnScanSession').click(function(){ focusControl($control); }); ctrlPropreties.lastParseValue = defaultValue; $control.find('.controlData input') .addClass('inpCtrlID_' + ctrlPropreties.id) //.attr('title', title) .val(defaultValue) .off('setLookupValue').on('setLookupValue', function(event, value, isSearchUndValue){ if(!isControlHiddenByRelevance(ctrlPropreties)){ setLookupValue($(this), ctrlType, $parent, value, isSearchUndValue, $control); removeIconAndDisbleCtrlAfterEdit(ctrlPropreties.val, $parent, $control); var ctrlValue = $(this).val(); if(ctrlValue != ctrlPropreties.lastParseValue){ ctrlPropreties.lastParseValue = ctrlValue; parseNFCData($parent, ctrlValue); parseTextData($(this), $parent, ctrlValue, ctrlPropreties.parrentProperties); } } }); if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } if(ctrlPropreties.length && ctrlPropreties.length.max && ctrlPropreties.length.cannotExceedMaximum){ $control.find('.controlData input').attr('maxlength',ctrlPropreties.length.max); } // label $control.find('.controlLabel').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.label.value.eng))); $control.off('checkAndSetRequired').on('checkAndSetRequired', function() { fvAppendRequired($parent, $control.find('.controlLabel')); }); $control.trigger('checkAndSetRequired'); // hint $control.find('.controlHint').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.hint.value.eng))); //if(isTabletPreview){ $control.find('.inputinner').addClass('cls4PreviewOnly'); if($parent.btnType && $parent.btnType.value == 'Image'){ $control.addClass('show-icon'); } //} // readOnly $control.off('checkAndSetReadOnly').on('checkAndSetReadOnly', function() { if(isReadOnlyApply($parent) || ctrlPropreties.isCtrlReadOnly == true){ $control.find('.controlData input').prop('disabled', true); $control.find('.inputinner').addClass('ctrlReadOnly'); } else { $control.find('.controlData input').prop('disabled', false); $control.find('.inputinner').removeClass('ctrlReadOnly'); } }); $control.trigger('checkAndSetReadOnly', $parent); // new { $control.off('clearData').on('clearData', function(event, setDefaultValue){ var $ctrl = $(this).find('.controlData input'); if(setDefaultValue){ $ctrl.val(getValueOrEmpty($parent.defaultValue.value)); }else{ $ctrl.val(''); } setCtrlPropretiesValue(ctrlPropreties, $ctrl.val()); //$control.trigger('Control_Update') //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); var ctrlValue = ''; if(ctrlValue != ctrlPropreties.lastParseValue){ ctrlPropreties.lastParseValue = ctrlValue; parseNFCData($parent, ctrlValue); parseTextData($(this), $parent, ctrlValue, ctrlPropreties.parrentProperties); } }); $control.off('Control_Update').on('Control_Update', function(event){ event.stopPropagation(); if(fvDataNS.dontCallTrigger) return; return controlUpdate($parent, ctrlPropreties); }); $control.find('.controlData input') .keyup(function(event) { setCtrlPropretiesValue(ctrlPropreties, $(this).val()); fvDataNS.ignoreLostFocus = false; //$(this).change(); }) .attr("autocomplete", "off") .on("beforeinput keypress", function(event){ if(!isRunEvent(event)){ return; } var ctrlValue = ctrlPropreties.val; textValidateMaxLength($parent, ctrlValue, $control.find('.controlInfMsg'), event); return toNextCtrl(this,event, ctrlPropreties); }) .change(function(event) { if(!fvDataNS.ignoreLostFocus){ setCtrlPropretiesValue(ctrlPropreties, $(this).val()); //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); return; }else{ fvDataNS.ignoreLostFocus = false; } }) .blur(function(event) { $(this).change(); var ctrlValue = ctrlPropreties.val; textValidateError($parent, ctrlValue, $control.find('.controlInfMsg') , ctrlPropreties, $control); removeIconAndDisbleCtrlAfterEdit(ctrlPropreties.val, $parent, $control); if(ctrlValue != ctrlPropreties.lastParseValue){ ctrlPropreties.lastParseValue = ctrlValue; parseNFCData($parent, ctrlValue); parseTextData($(this), $parent, ctrlValue, ctrlPropreties.parrentProperties); } }); } // relevanceconds addToCtrlIdRefForRelevance($parent.isShowRelevanceCondition, $parent.relevanceconds.value, ctrlPropreties.classPath); if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } ctrlPropreties.relevancecondsExpression = relevancecondsToExpression($parent.id, $parent.isShowRelevanceCondition, $parent.relevanceconds); ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); ctrlPropreties.skipcondsExpression = skipcondsToExpression($parent.id, $parent.isShowSkipCondition, $parent.skipconds, ctrlType); // Apply If .. Then .. Else in WebApps GUI (binding events) processBindingIfThenElseActionEvent($parent, ctrlPropreties); // Apply Skip If in WebApps GUI (binding events) processBindingSkipIfActionEvent($parent, ctrlPropreties); removeIconAndDisbleCtrlAfterEdit(ctrlPropreties.val, $parent, $control); } /*****************************************************************************************************************/ /*End********************************************inputNFC*********************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************inputForward*****************************************************/ /*****************************************************************************************************************/ var fvEditorsInputForward = function($parent, $control, ctrlType, ctrlPropreties){ // defaultValue if(isVersion(VERSION_REPLY_TO_SENDER) && $parent.replyToSender && $parent.replyToSender.value){ var replayFlag = fvDataNS.dataArray["data __reply_flag"]; if(replayFlag.val != ''){ var replyTo = getSenderToReply(); ctrlPropreties.val = replyTo; } ctrlPropreties.replyToSender = true; } var defaultValue; if(ctrlPropreties.val == undefined){ defaultValue = getValueOrEmpty($parent.defaultValue.value); setCtrlPropretiesValue(ctrlPropreties, defaultValue, true); fvEditorsSetDefaultValue(ctrlPropreties); }else{ defaultValue = ctrlPropreties.val; } if($parent.isSecureForward && $parent.isSecureForward.value){ $control.find('.controlData input').addClass(CONST_CLASS_LOCK); $control.find('.controlData textarea').addClass(CONST_CLASS_LOCK_OPEN); } /*var title = ''; if($parent.defaultValue.value != undefined && $parent.defaultValue.value != ''){ title = 'Default value : ' + $parent.defaultValue.value; }*/ $control.find('.controlData input') .addClass('inpCtrlID_' + ctrlPropreties.id) //.attr('title', title) .val(defaultValue) .off('setLookupValue').on('setLookupValue', function(event, value, isSearchUndValue){ if(!isControlHiddenByRelevance(ctrlPropreties)){ setLookupValue($(this), ctrlType, $parent, value, isSearchUndValue, $control); } }); if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } if(ctrlPropreties.length && ctrlPropreties.length.max && ctrlPropreties.length.cannotExceedMaximum){ $control.find('.controlData input').attr('maxlength',ctrlPropreties.length.max); } // label $control.find('.controlLabel').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.label.value.eng))); $control.off('checkAndSetRequired').on('checkAndSetRequired', function() { fvAppendRequired($parent, $control.find('.controlLabel')); }); $control.trigger('checkAndSetRequired'); // hint $control.find('.controlHint').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.hint.value.eng))); // hideInMobile $control.off('checkAndSetHide').on('checkAndSetHide', function() { execShowHideWebAppControl($control, $parent) }); $control.trigger('checkAndSetHide'); if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } // readOnly $control.off('checkAndSetReadOnly').on('checkAndSetReadOnly', function() { if(isReadOnlyApply($parent) || ctrlPropreties.isCtrlReadOnly == true){ $control.find('.controlData input').prop('disabled', true); $control.find('.inputinner').addClass('ctrlReadOnly'); } else { if(isVersion(VERSION_REPLY_TO_SENDER) && $parent.replyToSender && $parent.replyToSender.value){ var replayFlag = fvDataNS.dataArray["data __reply_flag"]; if(replayFlag.val != ''){ $control.find('.controlData input').prop('disabled', true); $control.find('.inputinner').addClass('ctrlReadOnly'); }else{ $control.find('.controlData input').prop('disabled', false); $control.find('.inputinner').removeClass('ctrlReadOnly'); } }else{ $control.find('.controlData input').prop('disabled', false); $control.find('.inputinner').removeClass('ctrlReadOnly'); } } }); $control.trigger('checkAndSetReadOnly', $parent); // new { $control.off('clearData').on('clearData', function(event, setDefaultValue){ var $ctrl = $(this).find('.controlData input'); if(setDefaultValue){ $ctrl.val(getValueOrEmpty($parent.defaultValue.value)); }else{ $ctrl.val(''); } setCtrlPropretiesValue(ctrlPropreties, $ctrl.val()); //$control.trigger('Control_Update') //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); }); $control.off('Control_Update').on('Control_Update', function(event){ event.stopPropagation(); if(fvDataNS.dontCallTrigger) return; return controlUpdate($parent, ctrlPropreties); }); $control.find('.controlData input') .keyup(function(event) { setCtrlPropretiesValue(ctrlPropreties, $(this).val()); fvDataNS.ignoreLostFocus = false; //$(this).change(); }) .attr("autocomplete", "off") .on("beforeinput keypress", function(event){ if(!isRunEvent(event)){ return; } var ctrlValue = ctrlPropreties.val; textValidateMaxLength($parent, ctrlValue, $control.find('.controlInfMsg'), event); if (isVersion(VERSION_FW_TO_EMAIL)) { // CO-79 Allow to input an email address in Forward widgets in Webclient/Web forms }else{ if(event.ctrlKey == true && (event.charCode == 118 || event.charCode == 99 || event.charCode == 120)){ return; } return onlyNumberDigit(this, event); } }) .off("drop").on("drop",function(e) { if (isVersion(VERSION_FW_TO_EMAIL)) { // CO-79 Allow to input an email address in Forward widgets in Webclient/Web forms }else{ e.preventDefault(); } }) .change(function(event) { if(!fvDataNS.ignoreLostFocus){ setCtrlPropretiesValue(ctrlPropreties, $(this).val()); //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); return; }else{ fvDataNS.ignoreLostFocus = false; } }) .off('input propertychange').on('input propertychange', function(e) { if (isVersion(VERSION_FW_TO_EMAIL)) { // CO-79 Allow to input an email address in Forward widgets in Webclient/Web forms }else{ onlyNumber_Propertychange($(this), ctrlPropreties, 'NumberDigit', -1); } }) .blur(function(event) { $(this).change(); var ctrlValue = ctrlPropreties.val; textValidateError($parent, ctrlValue, $control.find('.controlInfMsg') , ctrlPropreties, $control); }); } // relevanceconds addToCtrlIdRefForRelevance($parent.isShowRelevanceCondition, $parent.relevanceconds.value, ctrlPropreties.classPath); if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } ctrlPropreties.relevancecondsExpression = relevancecondsToExpression($parent.id, $parent.isShowRelevanceCondition, $parent.relevanceconds); ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); ctrlPropreties.skipcondsExpression = skipcondsToExpression($parent.id, $parent.isShowSkipCondition, $parent.skipconds, ctrlType); // Apply If .. Then .. Else in WebApps GUI (binding events) processBindingIfThenElseActionEvent($parent, ctrlPropreties); // Apply Skip If in WebApps GUI (binding events) processBindingSkipIfActionEvent($parent, ctrlPropreties); } /*****************************************************************************************************************/ /*End********************************************inputForward*****************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************inputImage*******************************************************/ /*****************************************************************************************************************/ var fvEditorsInputImage = function($parent, $control, ctrlType, ctrlPropreties){ if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } if(isVersion(VERSION_ALLOW_EDIT_SKETCH_IMG)){ if($parent.isAllowSketch && $parent.isAllowSketch.value == false){ $control.addClass(CONST_CLASS_NOT_ALLOW_SKETCH); }else{ if(isVersion(VERSION_AUTO_START_SKETCH) && $parent.isAutoStartSketch && $parent.isAutoStartSketch.value){ $control.addClass(CONST_CLASS_AUTO_START_SKETCH); } } if($parent.isAllowEdit && $parent.isAllowEdit.value == false){ $control.addClass(CONST_CLASS_NOT_ALLOW_EDIT); if(ctrlPropreties.wasSketched == true){ $control.addClass(CONST_CLASS_WAS_SKETCHED); } } } // label $control.find('.controlLabel').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.label.value.eng))); $control.off('checkAndSetRequired').on('checkAndSetRequired', function() { fvAppendRequired($parent, $control.find('.controlLabel')); }); $control.trigger('checkAndSetRequired'); // hint $control.find('.controlHint').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.hint.value.eng))); // uploadDataLink if(ctrlPropreties.hintLink == undefined || ctrlPropreties.hintLink == ''){ $control.find('.controlInfo .imageContain img').addClass(CONST_CLASS_NO_IMAGE); $control.removeClass(CONST_CLASS_CTRL_HAS_IMAGE); $control.find('.controlInfo a.clearImgBtn').addClass(CONST_CLASS_HIDE_CONTROL); $control.find('.controlInfo a.imgActBtn4Image').addClass(CONST_CLASS_HIDE_CONTROL); }else{ $control.find('.controlInfo #img_uploadDataLink').attr('src', ctrlPropreties.hintLink); $control.find('.controlInfo #img_uploadDataLinkHref').attr('href', ctrlPropreties.hintLink); $control.find('.controlInfo .imageContain img').removeClass(CONST_CLASS_NO_IMAGE); $control.addClass(CONST_CLASS_CTRL_HAS_IMAGE); ctrlPropreties.wasSketched = true; $control.addClass(CONST_CLASS_WAS_SKETCHED); $control.find('.controlInfo a.clearImgBtn').removeClass(CONST_CLASS_HIDE_CONTROL); $control.find('.controlInfo #btn_contain a.imgActBtn').empty().text(CONST_VALUE_REPLACE).addClass(CONST_CLASS_REPLACE_BTN); $control.find('.controlInfo a.imgActBtn4Image').removeClass(CONST_CLASS_HIDE_CONTROL); // CO-4098: adjust image css adjustImageCss($control, ctrlPropreties); } // readOnly $control.off('checkAndSetReadOnly').on('checkAndSetReadOnly', function() { if(isReadOnlyApply($parent) || ctrlPropreties.isCtrlReadOnly == true){ $control.find('.controlInfo #btn_contain a').addClass('btnReadOnly'); // Fix bug 0018825: Read Only control is same as normal control! $control.addClass('btnReadOnly'); $control.find('.controlData #btn_contain a.imgActBtn').off(); $control.find('.controlData a.clearImgBtn').off(); $control.off('processCheckRequired'); }else{ $control.find('.controlInfo #btn_contain a').removeClass('btnReadOnly'); $control.removeClass('btnReadOnly'); $control.find('.controlData #btn_contain a.imgActBtn').click(function(){ initializingUploadImage($(this), ctrlType, ctrlPropreties, $control); }).trigger('click'); var fbWidth = 930; //var fbHeight = 510; var screenWidth = $(window).width(); var border = 10; var padding = 20; if(isTabletPreview){ fbWidth = 450; if(fbWidth > screenWidth - 10 - border - padding) { fbWidth = screenWidth - 10 - border - padding; } //fbHeight = '100%'; }else{ if(screenWidth - 100 < fbWidth){ var tmp = 54.83870968; fbWidth = screenWidth - 100; //fbHeight = Math.round(fbWidth*tmp/100); } } var fbHeight = '100%'; var wrapLeft = (screenWidth - fbWidth)/2 - border - padding; var isModal = true; if(wrapLeft < 0){ isModal = false; } if($parent.isShowAdvanceToolbar && $parent.isShowAdvanceToolbar.value == false){ $control.find('.controlData #btn_contain a.imgActBtn4Image').attr('href', '/html/sketch_na.html'); } $control.find('.controlData #btn_contain a.imgActBtn4Image').fancybox({ 'width' : fbWidth, 'height' : fbHeight, 'modal' : isModal, 'autoScale' : false, /*'overlayWidth' : '1024px',*/ 'transitionIn' : CONST_VALUE_NONE, 'transitionOut' : CONST_VALUE_NONE, 'wrapLeft' : wrapLeft, 'type' : 'iframe', onComplete : function() { $("#fancybox-wrap").css({'left': this.wrapLeft + 'px'}); fvDataNS.fancyboxParam = {}; fvDataNS.fancyboxParam.hintLink = ctrlPropreties.hintLink; if(ctrlPropreties.orgHintLink == undefined){ ctrlPropreties.orgHintLink = getValueOrEmpty(ctrlPropreties.hintLink); } fvDataNS.fancyboxParam.orgHintLink = ctrlPropreties.orgHintLink; fvDataNS.fancyboxParam.file = ctrlPropreties.val; if(ctrlPropreties.attrs && ctrlPropreties.attrs['blobKey']){ fvDataNS.fancyboxParam.blobKey = ctrlPropreties.attrs['blobKey']; } }, onStart : function(){ $("body").css({'overflow-y':'hidden'}); $(".fvWorkspaceScrollArea").css({'overflow':'hidden'}); // tdchien // Assign flag value for checking we have click [Done] on sketch glbHashObject['flgHasClickButtonDoneOfSignature'] = false; }, onCleanup : function(){ ctrlPropreties.hintLink = $('#fancybox-frame').contents().find('input.hintLink').val(); setCtrlPropretiesValue(ctrlPropreties,$('#fancybox-frame').contents().find('input.file').val()); fvDataNS.ignoreLostFocus = false; ctrlPropreties.attrs = { 'blobKey': $('#fancybox-frame').contents().find('input.blobKey').val() }; $control.find('.controlInfo #img_uploadDataLink').attr('src', ctrlPropreties.hintLink); $control.find('.controlInfo #img_uploadDataLinkHref').attr('href', ctrlPropreties.hintLink); if(ctrlPropreties.hintLink == undefined || ctrlPropreties.hintLink == ''){ $control.find('.controlInfo .imageContain img').addClass(CONST_CLASS_NO_IMAGE); $control.removeClass(CONST_CLASS_CTRL_HAS_IMAGE); // Fix bug : 0018709: Empty image is display when user clear the image! // Remove href hyperlink $control.find('.controlInfo #img_uploadDataLinkHref').removeAttr('href'); // Process showing blank image $control.find('.controlInfo #img_uploadDataLink').attr('src', '/images/signBlank.jpg'); }else{ $control.find('.controlInfo .imageContain img').removeClass(CONST_CLASS_NO_IMAGE); $control.addClass(CONST_CLASS_CTRL_HAS_IMAGE); } // Change label from [Sign] to [Edit] // (only affacted when we have click [Done] on Signature Drawing if (glbHashObject['flgHasClickButtonDoneOfSignature'] === true) { if(!isCorrectMediaName(ctrlPropreties.val)){ var fileType = '.jpg'; var fileName = createNewMediaName(ctrlPropreties.ctrlType, fileType); if(fileName == ''){ fileName = file; } setCtrlPropretiesValue(ctrlPropreties, fileName); } ctrlPropreties.specialChange = true; if($control.hasClass(CONST_CLASS_NOT_ALLOW_EDIT)){ ctrlPropreties.wasSketched = true; $control.addClass(CONST_CLASS_WAS_SKETCHED); } // Show clear button $control.find('.controlInfo a.clearImgBtn').removeClass(CONST_CLASS_HIDE_CONTROL); // Adding required checking // Fix bug 0018711: Warning message didn't show when user click on caption text! $control.trigger('processCheckRequired'); } }, onClosed : function(){ $("body").css({'overflow-y':'visible'}); $(".fvWorkspaceScrollArea").css({'overflow':'auto'}); //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); } }); $control.find('.controlData a.clearImgBtn').click(function(){ $control.trigger('clearData').trigger('processCheckRequired'); }); // Adding required checking // Fix bug 0018711: Warning message didn't show when user click on caption text! $control.off('processCheckRequired').on('processCheckRequired', function() { var ctrlValue = ctrlPropreties.val; if (typeof ctrlValue === 'undefined') { ctrlValue = ''; } requiredOnlyValidateError($parent, ctrlValue, $control.find('.controlInfMsg') , ctrlPropreties, $control); // Refresh layout in case of Shading // // PCA-293: Webapp/Preview - Apply new block formats for all widgets. if (isVersion(VERSION_SHADINGS_AND_BUTTON_TEXT_WEB_APP) && $(this).hasClass('VERSION_SHADINGS_AND_BUTTON_TEXT_WEB_APP')) { refreshLayout4MediaButtonShadingWA($(this)); } }); } }); $control.trigger('checkAndSetReadOnly', $parent); // Process button 'Clear Image' { $control.off('clearData').on('clearData', function(event, setDefaultValue){ setCtrlPropretiesValue(ctrlPropreties, ''); ctrlPropreties.attrs = { 'blobKey': '' }; ctrlPropreties.hintLink = ''; ctrlPropreties.orgHintLink = undefined; var uploadBtnText = CONST_VALUE_UPLOAD; // Process showing blank image $control.find('.controlInfo #img_uploadDataLink').attr('src', '/images/signBlank.jpg'); // Fix bug : 0018709: Empty image is display when user clear the image! //$control.find('.controlInfo #img_uploadDataLinkHref').attr('href', ''); $control.find('.controlInfo #img_uploadDataLinkHref').removeAttr('href'); $control.find('.controlInfo a.imgActBtn4Image').addClass(CONST_CLASS_HIDE_CONTROL); $control.find('.controlInfo a.clearImgBtn').addClass(CONST_CLASS_HIDE_CONTROL); $control.find('.controlInfo .imageContain img').addClass(CONST_CLASS_NO_IMAGE); $control.removeClass(CONST_CLASS_CTRL_HAS_IMAGE); $control.find('.controlInfo #btn_contain a.imgActBtn').empty().text(uploadBtnText).removeClass(CONST_CLASS_REPLACE_BTN); //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); }); } $control.off('setImage').on('setImage', function(event, blobKey, imgUrl, isCloneImage){ setImage4ImageWidget($control, ctrlPropreties, blobKey, imgUrl, isCloneImage); }); $control.off('setLookupValue').on('setLookupValue', function(event, value, isSearchUndValue){ if(!isControlHiddenByRelevance(ctrlPropreties)){ setLookupValue($(this), ctrlType, $parent, value, isSearchUndValue, $control, ctrlPropreties); } }); $control.off('Control_Update').on('Control_Update', function(event){ event.stopPropagation(); if(fvDataNS.dontCallTrigger) return; return controlUpdate($parent, ctrlPropreties); }); // Adjust for option Display > []Clear button adjustImage4ShowClearButton($control, $parent); // relevanceconds addToCtrlIdRefForRelevance($parent.isShowRelevanceCondition, $parent.relevanceconds.value, ctrlPropreties.classPath); if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } ctrlPropreties.relevancecondsExpression = relevancecondsToExpression($parent.id, $parent.isShowRelevanceCondition, $parent.relevanceconds); ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); ctrlPropreties.skipcondsExpression = skipcondsToExpression($parent.id, $parent.isShowSkipCondition, $parent.skipconds, ctrlType); } /*****************************************************************************************************************/ /*End********************************************inputImage*******************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************inputAudio*******************************************************/ /*****************************************************************************************************************/ var fvEditorsInputAudio = function($parent, $control, ctrlType, ctrlPropreties){ if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } // label $control.find('.controlLabel').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.label.value.eng))); $control.off('checkAndSetRequired').on('checkAndSetRequired', function() { fvAppendRequired($parent, $control.find('.controlLabel')); }); $control.trigger('checkAndSetRequired'); // hint $control.find('.controlHint').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.hint.value.eng))); // uploadDataLink //$control.find('.controlData #uploadDataLink').empty().append(getValueOrEmpty(ctrlPropreties.hintLink)); // uploadDataLink if(ctrlPropreties.hintLink == undefined || ctrlPropreties.hintLink == ''){ $control.find('.controlInfo #img_uploadDataLink').attr('src', URL_IMAGE_BLANK_PADDING); // Remove width auto $control.find('.controlInfo #img_uploadDataLink').removeClass('settingAutoWidth4Media'); $control.find('.controlInfo .imageContain img').addClass(CONST_CLASS_NO_IMAGE).removeClass('audioSampleImageView'); $control.removeClass(CONST_CLASS_CTRL_HAS_IMAGE); $control.find('.controlInfo a.clearImgBtn').addClass(CONST_CLASS_HIDE_CONTROL); }else{ // Put audio image $control.find('.controlInfo #img_uploadDataLink').attr('src', URL_IMAGE_4_CHOOSING_AUDIO); // Add width auto $control.find('.controlInfo #img_uploadDataLink').addClass('settingAutoWidth4Media'); // $control.find('.controlInfo #img_uploadDataLinkHref').attr('href', ctrlPropreties.hintLink); $control.find('.controlInfo .imageContain img').removeClass(CONST_CLASS_NO_IMAGE).addClass('audioSampleImageView'); $control.addClass(CONST_CLASS_CTRL_HAS_IMAGE); $control.find('.controlInfo a.clearImgBtn').removeClass(CONST_CLASS_HIDE_CONTROL); $control.find('.controlInfo #btn_contain a.imgActBtn').empty() .text(CONST_VALUE_REPLACE) .css('margin-left', '5px') .addClass(CONST_CLASS_REPLACE_BTN); // Add space left ; } var btnAudioPlayer = $control.find('.controlInfo .playMediaContentHyperlinkItem'); //$control.find('.controlInfo #img_uploadDataLink').attr('src', getValueOrEmpty(ctrlPropreties.hintLink)); if(ctrlPropreties.hintLink == undefined || ctrlPropreties.hintLink == ''){ // $control.find('.controlInfo .imageContain').addClass(CONST_CLASS_HIDE_CONTROL); // // Hide button 'Play Audio' btnAudioPlayer.addClass(CONST_CLASS_HIDE_CONTROL); }else{ // $control.find('.controlInfo #btn_contain a').empty().text('Replace); // $control.find('.controlInfo .imageContain').removeClass(CONST_CLASS_HIDE_CONTROL); // // Assign event for button 'Play Audio' writeToLogInfo('Hyperlink of audio file (Open) : ' + ctrlPropreties.hintLink); btnAudioPlayer.removeClass(CONST_CLASS_HIDE_CONTROL); assignVideoPlayerByFancybox(btnAudioPlayer, toCurLocationUrl(ctrlPropreties.hintLink), CONST_CTRL_TYPE_INPUTAUDIO); } // readOnly $control.off('checkAndSetReadOnly').on('checkAndSetReadOnly', function() { if(isReadOnlyApply($parent) || ctrlPropreties.isCtrlReadOnly == true){ //$control.find('.controlData input').prop('disabled', true); $control.find('.controlInfo #btn_contain a').addClass('btnReadOnly'); $control.find('.controlData #btn_contain a.imgActBtn').off(); $control.find('.controlData a.clearImgBtn').off(); $control.off('processCheckRequired'); }else{ $control.find('.controlInfo #btn_contain a').removeClass('btnReadOnly'); $control.find('.controlData #btn_contain a.imgActBtn').click(function(){ initializingUploadAudio($(this), ctrlPropreties, $control); }).trigger('click'); $control.find('.controlData a.clearImgBtn').click(function(){ $control.trigger('clearData').trigger('processCheckRequired'); }); // Adding required checking // Fix bug 0018711: Warning message didn't show when user click on caption text! $control.off('processCheckRequired').on('processCheckRequired', function() { var ctrlValue = ctrlPropreties.val; if (typeof ctrlValue === 'undefined') { ctrlValue = ''; } requiredOnlyValidateError($parent, ctrlValue, $control.find('.controlInfMsg') , ctrlPropreties, $control); // Refresh layout in case of Shading // PCA-293: Webapp/Preview - Apply new block formats for all widgets. if (isVersion(VERSION_SHADINGS_AND_BUTTON_TEXT_WEB_APP) && $(this).hasClass('VERSION_SHADINGS_AND_BUTTON_TEXT_WEB_APP')) { refreshLayout4MediaButtonShadingWA($(this)); } }); } }); $control.trigger('checkAndSetReadOnly', $parent); // new { $control.off('clearData').on('clearData', function(event, setDefaultValue){ setCtrlPropretiesValue(ctrlPropreties, ''); ctrlPropreties.hintLink = ''; // Setting blobKey = EMPTY for preventing error in server-side ctrlPropreties.attrs = { 'blobKey': '' }; // $control.find('.controlData #uploadDataLink').empty(); // $control.find('.controlInfo #btn_contain a').empty().text(CONST_VALUE_UPLOAD).removeClass(CONST_CLASS_REPLACE_BTN); // $control.find('.controlInfo .imageContain').addClass(CONST_CLASS_HIDE_CONTROL); // Process showing blank image $control.find('.controlInfo #img_uploadDataLink').attr('src', URL_IMAGE_BLANK_PADDING); // Remove width auto $control.find('.controlInfo #img_uploadDataLink').removeClass('settingAutoWidth4Media'); $control.find('.controlInfo #img_uploadDataLinkHref').removeAttr('href'); $control.find('.controlInfo a.clearImgBtn').addClass(CONST_CLASS_HIDE_CONTROL); $control.find('.controlInfo .imageContain img').addClass(CONST_CLASS_NO_IMAGE).removeClass('audioSampleImageView'); $control.removeClass(CONST_CLASS_CTRL_HAS_IMAGE); $control.find('.controlInfo #btn_contain a.imgActBtn').empty() .text(CONST_VALUE_UPLOAD) .css('margin-left', '0px') .removeClass(CONST_CLASS_REPLACE_BTN); // Do not add space left ; // Hide button 'Play Audio' var btnAudioPlayer = $control.find('.controlInfo .playMediaContentHyperlinkItem'); btnAudioPlayer.addClass(CONST_CLASS_HIDE_CONTROL); }); } // relevanceconds addToCtrlIdRefForRelevance($parent.isShowRelevanceCondition, $parent.relevanceconds.value, ctrlPropreties.classPath); if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } ctrlPropreties.relevancecondsExpression = relevancecondsToExpression($parent.id, $parent.isShowRelevanceCondition, $parent.relevanceconds); ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); ctrlPropreties.skipcondsExpression = skipcondsToExpression($parent.id, $parent.isShowSkipCondition, $parent.skipconds, ctrlType); } /*****************************************************************************************************************/ /*End********************************************inputAudio*******************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************inputVideo*******************************************************/ /*****************************************************************************************************************/ var fvEditorsInputVideo = function($parent, $control, ctrlType, ctrlPropreties){ if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } // label $control.find('.controlLabel').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.label.value.eng))); $control.off('checkAndSetRequired').on('checkAndSetRequired', function() { fvAppendRequired($parent, $control.find('.controlLabel')); }); $control.trigger('checkAndSetRequired'); // hint $control.find('.controlHint').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.hint.value.eng))); var btnVideoPlayer = $control.find('.controlInfo .playMediaContentHyperlinkItem'); // uploadDataLink //$control.find('.controlData #uploadDataLink').empty().append(getValueOrEmpty(ctrlPropreties.hintLink)); //$control.find('.controlInfo #img_uploadDataLink').attr('src', getValueOrEmpty(ctrlPropreties.hintLink)); if(ctrlPropreties.hintLink == undefined || ctrlPropreties.hintLink == ''){ $control.find('.controlInfo #img_uploadDataLink').attr('src', URL_IMAGE_BLANK_PADDING); // Remove width auto $control.find('.controlInfo #img_uploadDataLink').removeClass('settingAutoWidth4Media'); $control.find('.controlInfo .imageContain img').addClass(CONST_CLASS_NO_IMAGE).removeClass('videoSampleImageView'); $control.removeClass(CONST_CLASS_CTRL_HAS_IMAGE); $control.find('.controlInfo a.clearImgBtn').addClass(CONST_CLASS_HIDE_CONTROL); // Remove width auto $control.find('.controlInfo #img_uploadDataLink').removeClass('settingAutoWidth4Media'); }else{ // Put audio image $control.find('.controlInfo #img_uploadDataLink').attr('src', URL_IMAGE_4_CHOOSING_VIDEO); // Force width auto $control.find('.controlInfo #img_uploadDataLink').addClass('settingAutoWidth4Media'); // $control.find('.controlInfo #img_uploadDataLinkHref').attr('href', ctrlPropreties.hintLink); $control.find('.controlInfo .imageContain img').removeClass(CONST_CLASS_NO_IMAGE).addClass('videoSampleImageView'); $control.addClass(CONST_CLASS_CTRL_HAS_IMAGE); $control.find('.controlInfo a.clearImgBtn').removeClass(CONST_CLASS_HIDE_CONTROL); $control.find('.controlInfo #btn_contain a.imgActBtn').empty() .text(CONST_VALUE_REPLACE) .css('margin-left', '5px') .addClass(CONST_CLASS_REPLACE_BTN); // Add space left ; } if(ctrlPropreties.hintLink == undefined || ctrlPropreties.hintLink == ''){ // $control.find('.controlInfo .imageContain').addClass(CONST_CLASS_HIDE_CONTROL); // // // Hide button 'Play Video' btnVideoPlayer.addClass(CONST_CLASS_HIDE_CONTROL); }else{ // $control.find('.controlInfo #btn_contain a').empty().text(CONST_VALUE_REPLACE).addClass(CONST_CLASS_REPLACE_BTN); // $control.find('.controlInfo .imageContain').removeClass(CONST_CLASS_HIDE_CONTROL); // Assign event for button 'Play Video' writeToLogInfo('Hyperlink of video file (Open) : ' + ctrlPropreties.hintLink); btnVideoPlayer.removeClass(CONST_CLASS_HIDE_CONTROL); assignVideoPlayerByFancybox(btnVideoPlayer, toCurLocationUrl(ctrlPropreties.hintLink), CONST_CTRL_TYPE_INPUTVIDEO); } // readOnly $control.off('checkAndSetReadOnly').on('checkAndSetReadOnly', function() { if(isReadOnlyApply($parent) || ctrlPropreties.isCtrlReadOnly == true){ //$control.find('.controlData input').prop('disabled', true); $control.find('.controlInfo #btn_contain a').addClass('btnReadOnly'); $control.find('.controlData #btn_contain a.imgActBtn').off(); $control.find('.controlData a.clearImgBtn').off(); $control.off('processCheckRequired'); }else{ $control.find('.controlInfo #btn_contain a').removeClass('btnReadOnly'); $control.find('.controlData #btn_contain a.imgActBtn').click(function(){ initializingUploadVideo($(this), ctrlPropreties, $control); }).trigger('click'); $control.find('.controlData a.clearImgBtn').click(function(){ $control.trigger('clearData').trigger('processCheckRequired'); }); // Adding required checking // Fix bug 0018711: Warning message didn't show when user click on caption text! $control.off('processCheckRequired').on('processCheckRequired', function() { var ctrlValue = ctrlPropreties.val; if (typeof ctrlValue === 'undefined') { ctrlValue = ''; } requiredOnlyValidateError($parent, ctrlValue, $control.find('.controlInfMsg') , ctrlPropreties, $control); // Refresh layout in case of Shading // PCA-293: Webapp/Preview - Apply new block formats for all widgets. if (isVersion(VERSION_SHADINGS_AND_BUTTON_TEXT_WEB_APP) && $(this).hasClass('VERSION_SHADINGS_AND_BUTTON_TEXT_WEB_APP')) { refreshLayout4MediaButtonShadingWA($(this)); } }); } }); $control.trigger('checkAndSetReadOnly', $parent); // new { $control.off('clearData').on('clearData', function(event, setDefaultValue){ setCtrlPropretiesValue(ctrlPropreties, ''); // Setting blobKey = EMPTY for preventing error in server-side ctrlPropreties.attrs = { 'blobKey': '' }; ctrlPropreties.hintLink = ''; // $control.find('.controlData #uploadDataLink').empty(); // $control.find('.controlInfo #btn_contain a').empty().text(CONST_VALUE_UPLOAD).removeClass(CONST_CLASS_REPLACE_BTN); // $control.find('.controlInfo .imageContain').addClass(CONST_CLASS_HIDE_CONTROL); // Process showing blank image $control.find('.controlInfo #img_uploadDataLink').attr('src', URL_IMAGE_BLANK_PADDING); // Remove width auto $control.find('.controlInfo #img_uploadDataLink').removeClass('settingAutoWidth4Media'); $control.find('.controlInfo #img_uploadDataLinkHref').removeAttr('href'); $control.find('.controlInfo a.clearImgBtn').addClass(CONST_CLASS_HIDE_CONTROL); $control.find('.controlInfo .imageContain img').addClass(CONST_CLASS_NO_IMAGE).removeClass('videoSampleImageView'); $control.removeClass(CONST_CLASS_CTRL_HAS_IMAGE); $control.find('.controlInfo #btn_contain a.imgActBtn').empty() .text(CONST_VALUE_UPLOAD) .css('margin-left', '0px') .removeClass(CONST_CLASS_REPLACE_BTN); // Do not add space left ; // Hide button 'Play Video' var btnVideoPlayer = $control.find('.controlInfo .playMediaContentHyperlinkItem'); btnVideoPlayer.addClass(CONST_CLASS_HIDE_CONTROL); }); } // relevanceconds addToCtrlIdRefForRelevance($parent.isShowRelevanceCondition, $parent.relevanceconds.value, ctrlPropreties.classPath); if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } ctrlPropreties.relevancecondsExpression = relevancecondsToExpression($parent.id, $parent.isShowRelevanceCondition, $parent.relevanceconds); ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); ctrlPropreties.skipcondsExpression = skipcondsToExpression($parent.id, $parent.isShowSkipCondition, $parent.skipconds, ctrlType); } /*****************************************************************************************************************/ /*End********************************************inputVideo*******************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************inputSketch******************************************************/ /*****************************************************************************************************************/ var fvEditorsInputSketch = function($parent, $control, ctrlType, ctrlPropreties){ if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } // label $control.find('.controlLabel').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.label.value.eng))); $control.off('checkAndSetRequired').on('checkAndSetRequired', function() { fvAppendRequired($parent, $control.find('.controlLabel')); }); $control.trigger('checkAndSetRequired'); // hint $control.find('.controlHint').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.hint.value.eng))); var hintValue = getValueOrEmpty($parent.hint.value.eng); if(ctrlPropreties.hintLink != undefined && ctrlPropreties.hintLink == CONST_DONOT_SET_DEFAULT){ ctrlPropreties.hintLink = ''; }else if((ctrlPropreties.hintLink == undefined || ctrlPropreties.hintLink == '') && $parent.defaultImage && valueOrEmpty($parent.defaultImage.value) != ''){ var tmp = $parent.defaultImage.value; var pos = tmp.indexOf('/imageViewer?blobKey='); if(pos>0){ tmp = tmp.substring(pos); } ctrlPropreties.hintLink = tmp; } if($parent.defaultImage && valueOrEmpty($parent.defaultImage.value) != ''){ ctrlPropreties.defaultImage = $parent.defaultImage.value; } if(!ctrlPropreties.val || ctrlPropreties.val == ''){ if(ctrlPropreties.hintLink && ctrlPropreties.hintLink.indexOf('blobKey=') > 0){ var arr = ctrlPropreties.hintLink.split('blobKey='); var arrTmp = arr[1].split('&fileName='); if(arrTmp[1] == undefined){ var fileType = ".jpg"; var fileName = createNewMediaName(ctrlPropreties.ctrlType, fileType); if(fileName == ''){ fileName = 'signature.jpg'; } arrTmp[1] = fileName; } ctrlPropreties.val = arrTmp[1]; ctrlPropreties.attrs = { 'blobKey': arrTmp[0] } } } // uploadDataLink if(ctrlPropreties.hintLink == undefined || ctrlPropreties.hintLink == ''){ $control.find('.controlInfo .imageContain img').addClass(CONST_CLASS_NO_IMAGE); $control.removeClass(CONST_CLASS_CTRL_HAS_IMAGE); if(!isVersion(VERSION_UP_SKETCH_SIGN)){ $control.find('.controlInfo a.imgActBtn4Sketch').addClass(CONST_CLASS_HIDE_CONTROL); } $control.find('.controlInfo a.clearImgBtn').addClass(CONST_CLASS_HIDE_CONTROL); }else{ $control.find('.controlInfo #img_uploadDataLink').attr('src', ctrlPropreties.hintLink); $control.find('.controlInfo #img_uploadDataLinkHref').attr('href', ctrlPropreties.hintLink); $control.find('.controlInfo .imageContain img').removeClass(CONST_CLASS_NO_IMAGE); $control.addClass(CONST_CLASS_CTRL_HAS_IMAGE); if(isVersion(VERSION_SKETCH_BTN)){ $control.find('.controlInfo a.imgActBtn4Sketch').removeClass(CONST_CLASS_HIDE_CONTROL); } $control.find('.controlInfo a.clearImgBtn').removeClass(CONST_CLASS_HIDE_CONTROL); $control.find('.controlInfo #btn_contain a.imgActBtn').empty().text(CONST_VALUE_REPLACE).addClass(CONST_CLASS_REPLACE_BTN); } // readOnly $control.off('checkAndSetReadOnly').on('checkAndSetReadOnly', function() { if(isReadOnlyApply($parent) || ctrlPropreties.isCtrlReadOnly == true){ //$control.find('.controlData input').prop('disabled', true); $control.find('.controlInfo #btn_contain a').addClass('btnReadOnly'); // Fix bug 0018825: Read Only control is same as normal control! $control.addClass('btnReadOnly'); // fix bug 0023316 var tmpHref = $control.find('.controlData #btn_contain a.imgActBtn4Sketch').attr('href'); $control.find('.controlData #btn_contain a.imgActBtn4Sketch') .attr('href1',tmpHref).removeAttr('href'); //$control.find('.controlData #btn_contain a.imgActBtn4Sketch').removeAttr('href'); $control.find('.controlData #btn_contain a.imgActBtn4Sketch').off(); $control.find('.controlData #btn_contain a.imgActBtn').off(); $control.find('.controlData a.clearImgBtn').off(); $control.off('processCheckRequired'); }else{ var tmpHref = $control.find('.controlData #btn_contain a.imgActBtn4Sketch').attr('href1'); $control.find('.controlData #btn_contain a.imgActBtn4Sketch').attr('href',tmpHref); $control.find('.controlInfo #btn_contain a').removeClass('btnReadOnly'); $control.removeClass('btnReadOnly'); //$control.find('.controlData #btn_contain a.imgActBtn4Sketch').removeAttr('href'); $control.find('.controlData #btn_contain a.imgActBtn').click(function(){ initializingUploadImage($(this), ctrlType + '_Uploaded', ctrlPropreties, $control); }).trigger('click'); var fbWidth = 930; //var fbHeight = 510; var screenWidth = $(window).width(); var border = 10; var padding = 20; if(isTabletPreview){ fbWidth = 450; if(fbWidth > screenWidth - 10 - border - padding) { fbWidth = screenWidth - 10 - border - padding; } //fbHeight = '100%'; }else{ if(screenWidth - 100 < fbWidth){ var tmp = 54.83870968; fbWidth = screenWidth - 100; //fbHeight = Math.round(fbWidth*tmp/100); } } var fbHeight = '100%'; var wrapLeft = (screenWidth - fbWidth)/2 - border - padding; var isModal = true; if(wrapLeft < 0){ isModal = false; } if(isVersion(VERSION_ALLOW_REPLACE_CLEAR)){ if($parent.isAllowReplace&& $parent.isAllowReplace.value == false){ $control.addClass(CONST_CLASS_NOT_ALLOW_REPLACE); } if($parent.isAllowClear&& $parent.isAllowClear.value == false){ $control.addClass(CONST_CLASS_NOT_ALLOW_CLEAR); } } if($parent.isShowAdvanceToolbar && $parent.isShowAdvanceToolbar.value == false){ $control.find('.controlData #btn_contain a.imgActBtn4Sketch').attr('href', '/html/sketch_na.html'); } // Fix bug 0022149: Preview - Sketch button work when user click on it if (false === checkIfWeAreInPreviewScreenGUI()) { $control.find('.controlData #btn_contain a.imgActBtn4Sketch').fancybox({ 'width' : fbWidth, 'height' : fbHeight, 'modal' : isModal, 'autoScale' : false, /*'overlayWidth' : '1024px',*/ 'transitionIn' : CONST_VALUE_NONE, 'transitionOut' : CONST_VALUE_NONE, 'wrapLeft' : wrapLeft, 'type' : 'iframe', onComplete : function() { $("#fancybox-wrap").css({'left': this.wrapLeft + 'px'}); fvDataNS.fancyboxParam = {}; fvDataNS.fancyboxParam.hintLink = ctrlPropreties.hintLink; fvDataNS.fancyboxParam.type = ctrlPropreties.ctrlType + '_Sketched'; // CO-2573 /*if(ctrlPropreties.orgHintLink == undefined){ ctrlPropreties.orgHintLink = getValueOrEmpty(ctrlPropreties.hintLink); } fvDataNS.fancyboxParam.orgHintLink = ctrlPropreties.orgHintLink;*/ fvDataNS.fancyboxParam.orgHintLink = ctrlPropreties.defaultImage; fvDataNS.fancyboxParam.file = ctrlPropreties.val; if(ctrlPropreties.attrs && ctrlPropreties.attrs['blobKey']){ fvDataNS.fancyboxParam.blobKey = ctrlPropreties.attrs['blobKey']; } if($parent.isAllowClear&& $parent.isAllowClear.value == false){ fvDataNS.fancyboxParam.isAllowClear = false; }else{ fvDataNS.fancyboxParam.isAllowClear = true; } }, onStart : function(){ $("body").css({'overflow-y':'hidden'}); $(".fvWorkspaceScrollArea").css({'overflow':'hidden'}); // tdchien // Assign flag value for checking we have click [Done] on sketch glbHashObject['flgHasClickButtonDoneOfSignature'] = false; }, onCleanup : function(){ // Fix bug 0022129: [Suggestion] Should show "progress indicator" when click on "Done" after skectch line on Image waitForDataLoading(true); ctrlPropreties.hintLink = $('#fancybox-frame').contents().find('input.hintLink').val(); setCtrlPropretiesValue(ctrlPropreties, $('#fancybox-frame').contents().find('input.file').val()); fvDataNS.ignoreLostFocus = false; ctrlPropreties.attrs = { 'blobKey': $('#fancybox-frame').contents().find('input.blobKey').val() }; $control.find('.controlInfo #img_uploadDataLink').attr('src', ctrlPropreties.hintLink); $control.find('.controlInfo #img_uploadDataLinkHref').attr('href', ctrlPropreties.hintLink); if(ctrlPropreties.hintLink == undefined || ctrlPropreties.hintLink == ''){ $control.find('.controlInfo .imageContain img').addClass(CONST_CLASS_NO_IMAGE); //$control.find('.controlInfo .imageContain img').removeClass('signatureImageBorder'); $control.removeClass(CONST_CLASS_CTRL_HAS_IMAGE); // Fix bug : 0018709: Empty image is display when user clear the image! // Remove href hyperlink $control.find('.controlInfo #img_uploadDataLinkHref').removeAttr('href'); // Process showing blank image $control.find('.controlInfo #img_uploadDataLink').attr('src', '/images/signBlank.jpg'); }else{ $control.find('.controlInfo .imageContain img').removeClass(CONST_CLASS_NO_IMAGE); //$control.find('.controlInfo .imageContain img').addClass('signatureImageBorder'); $control.addClass(CONST_CLASS_CTRL_HAS_IMAGE); } // Change label from [Sign] to [Edit] // (only affacted when we have click [Done] on Signature Drawing if (glbHashObject['flgHasClickButtonDoneOfSignature'] === true) { if(!isCorrectMediaName(ctrlPropreties.val)){ var fileType = '.jpg'; var fileName = createNewMediaName(ctrlPropreties.ctrlType, fileType); if(fileName == ''){ fileName = file; } setCtrlPropretiesValue(ctrlPropreties, fileName); } ctrlPropreties.specialChange = true; // Show clear button $control.find('.controlInfo a.clearImgBtn').removeClass(CONST_CLASS_HIDE_CONTROL); // Adding required checking // Fix bug 0018711: Warning message didn't show when user click on caption text! $control.trigger('processCheckRequired'); } }, onClosed : function(){ $("body").css({'overflow-y':'visible'}); $(".fvWorkspaceScrollArea").css({'overflow':'auto'}); //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); // Fix bug 0022129: [Suggestion] Should show "progress indicator" when click on "Done" after skectch line on Image waitForDataLoading(false); } }); // Fix bug 0022149: Preview - Sketch button work when user click on it } // End if checking preview ( checkIfWeAreInPreviewScreenGUI() ) else { // Create no target for button [Sketch] when clicking $control.find('.controlData #btn_contain a.imgActBtn4Sketch').attr('href', '#notarget_destination'); } $control.find('.controlData a.clearImgBtn').click(function(){ $control.trigger('clearData').trigger('processCheckRequired'); }); // Adding required checking // Fix bug 0018711: Warning message didn't show when user click on caption text! $control.off('processCheckRequired').on('processCheckRequired', function() { var ctrlValue = ctrlPropreties.val; if (typeof ctrlValue === 'undefined') { ctrlValue = ''; } requiredOnlyValidateError($parent, ctrlValue, $control.find('.controlInfMsg') , ctrlPropreties, $control); // Refresh layout in case of Shading // PCA-293: Webapp/Preview - Apply new block formats for all widgets. if (isVersion(VERSION_SHADINGS_AND_BUTTON_TEXT_WEB_APP) && $(this).hasClass('VERSION_SHADINGS_AND_BUTTON_TEXT_WEB_APP')) { refreshLayout4MediaButtonShadingWA($(this)); } }); } }); $control.trigger('checkAndSetReadOnly', $parent); // Process button 'Clear Sketch' { $control.off('clearData').on('clearData', function(event, setDefaultValue){ setCtrlPropretiesValue(ctrlPropreties, ''); ctrlPropreties.specialChange = true; ctrlPropreties.attrs = { 'blobKey': '' }; ctrlPropreties.hintLink = ''; ctrlPropreties.orgHintLink = undefined; var uploadBtnText = CONST_VALUE_UPLOAD; // Process showing blank image $control.find('.controlInfo #img_uploadDataLink').attr('src', '/images/signBlank.jpg'); // Fix bug : 0018709: Empty image is display when user clear the image! //$control.find('.controlInfo #img_uploadDataLinkHref').attr('href', ''); $control.find('.controlInfo #img_uploadDataLinkHref').removeAttr('href'); if(!isVersion(VERSION_UP_SKETCH_SIGN)){ $control.find('.controlInfo a.imgActBtn4Sketch').addClass(CONST_CLASS_HIDE_CONTROL); } $control.find('.controlInfo a.clearImgBtn').addClass(CONST_CLASS_HIDE_CONTROL); $control.find('.controlInfo .imageContain img').addClass(CONST_CLASS_NO_IMAGE); $control.find('.controlInfo #btn_contain a.imgActBtn').empty().text(uploadBtnText).removeClass(CONST_CLASS_REPLACE_BTN); $control.removeClass(CONST_CLASS_CTRL_HAS_IMAGE); //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); }); } $control.off('Control_Update').on('Control_Update', function(event){ event.stopPropagation(); if(fvDataNS.dontCallTrigger) return; return controlUpdate($parent, ctrlPropreties); }); // relevanceconds addToCtrlIdRefForRelevance($parent.isShowRelevanceCondition, $parent.relevanceconds.value, ctrlPropreties.classPath); if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } ctrlPropreties.relevancecondsExpression = relevancecondsToExpression($parent.id, $parent.isShowRelevanceCondition, $parent.relevanceconds); ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); ctrlPropreties.skipcondsExpression = skipcondsToExpression($parent.id, $parent.isShowSkipCondition, $parent.skipconds, ctrlType); } /*****************************************************************************************************************/ /*End********************************************inputSketch******************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************inputSignature***************************************************/ /*****************************************************************************************************************/ var fvEditorsInputSignature = function($parent, $control, ctrlType, ctrlPropreties){ if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } // label $control.find('.controlLabel').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.label.value.eng))); $control.off('checkAndSetRequired').on('checkAndSetRequired', function() { fvAppendRequired($parent, $control.find('.controlLabel')); }); $control.trigger('checkAndSetRequired'); // hint $control.find('.controlHint').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.hint.value.eng))); // For same as MobileDevice : Always hide button [Clear Signature] $control.find('.controlInfo a.clearImgBtn').addClass(CONST_CLASS_HIDE_CONTROL); if(!isVersion(VERSION_UP_SKETCH_SIGN)){ $control.find('.VERSION_UP_SKETCH_SIGN').addClass(CONST_CLASS_HIDE_CONTROL); } if(isVersion(VERSION_BULK_SIGNATURE)){ if($parent.isBulkSignature && $parent.isBulkSignature.value){ ctrlPropreties.isBulkSignature = $parent.isBulkSignature.value; } if(ctrlPropreties.isBulkSignature){ $control.addClass('Bulk-Signature'); $control.off('Bulk-Signature').on('Bulk-Signature', function(event, hintLink, blobKey) { if(true){ // disable Bulk-Signature in view mode return; } $control.removeClass('Bulk-Signature'); ctrlPropreties.hintLink = hintLink; setCtrlPropretiesValue(ctrlPropreties, hintLink); fvDataNS.ignoreLostFocus = false; ctrlPropreties.attrs = { 'blobKey': blobKey }; $control.find('.controlInfo #img_uploadDataLink').attr('src', ctrlPropreties.hintLink); // Ignore href link $control.find('.controlInfo #img_uploadDataLinkHref').removeAttr('href'); //$control.find('.controlInfo #img_uploadDataLinkHref').attr('href', ctrlPropreties.hintLink); if(ctrlPropreties.hintLink == undefined || ctrlPropreties.hintLink == ''){ $control.find('.controlInfo .imageContain img').addClass(CONST_CLASS_NO_IMAGE); //$control.find('.controlInfo .imageContain img').removeClass('signatureImageBorder'); $control.removeClass(CONST_CLASS_CTRL_HAS_IMAGE); // Fix bug : 0018709: Empty image is display when user clear the image! // Remove href hyperlink $control.find('.controlInfo #img_uploadDataLinkHref').removeAttr('href'); // Process showing blank image $control.find('.controlInfo #img_uploadDataLink').attr('src', '/images/signBlank.jpg'); }else{ $control.find('.controlInfo .imageContain img').removeClass(CONST_CLASS_NO_IMAGE); //$control.find('.controlInfo .imageContain img').addClass('signatureImageBorder'); $control.addClass(CONST_CLASS_CTRL_HAS_IMAGE); } // Change label from [Sign] to [Edit] // (only affacted when we have click [Done] on Signature Drawing if (glbHashObject['flgHasClickButtonDoneOfSignature'] === true) { if(!isCorrectMediaName(ctrlPropreties.val)){ var fileType = '.jpg'; var fileName = createNewMediaName(ctrlPropreties.ctrlType, fileType); if(fileName == ''){ fileName = file; } setCtrlPropretiesValue(ctrlPropreties, fileName); } ctrlPropreties.specialChange = true; $control.find('.controlInfo .signButton4Signature').text('Edit'); // Show clear button $control.find('.controlInfo a.clearImgBtn').removeClass(CONST_CLASS_HIDE_CONTROL); // Adding required checking // Fix bug 0018711: Warning message didn't show when user click on caption text! $control.trigger('processCheckRequired'); // Adjust for option []Allow edit of Signature outside adjustSignatureOutside4AllowEdit($control, $parent); } }); } } // uploadDataLink if(ctrlPropreties.hintLink == undefined || ctrlPropreties.hintLink == ''){ // Process showing blank image $control.find('.controlInfo #img_uploadDataLink').attr('src', '/images/signBlank.jpg'); $control.find('.controlInfo #img_uploadDataLinkHref').removeAttr('href'); $control.find('.controlInfo .imageContain img').addClass(CONST_CLASS_NO_IMAGE); $control.removeClass(CONST_CLASS_CTRL_HAS_IMAGE); //$control.find('.controlInfo .imageContain img').removeClass('signatureImageBorder'); $control.find('.controlInfo #btn_contain a.signButton4Signature').empty().text('Sign'); // Hide clear button $control.find('.controlInfo a.clearImgBtn').addClass(CONST_CLASS_HIDE_CONTROL); }else{ $control.find('.controlInfo #img_uploadDataLink').attr('src', ctrlPropreties.hintLink); // Ignore href link $control.find('.controlInfo #img_uploadDataLinkHref').removeAttr('href'); //$control.find('.controlInfo #img_uploadDataLinkHref').attr('href', ctrlPropreties.hintLink); $control.find('.controlInfo .imageContain img').removeClass(CONST_CLASS_NO_IMAGE); $control.addClass(CONST_CLASS_CTRL_HAS_IMAGE); //$control.find('.controlInfo .imageContain img').addClass('signatureImageBorder'); // Show clear button $control.find('.controlInfo a.clearImgBtn').removeClass(CONST_CLASS_HIDE_CONTROL); $control.find('.controlInfo #btn_contain a.imgActBtn').empty().text(CONST_VALUE_REPLACE).addClass(CONST_CLASS_REPLACE_BTN); // Change label of button from [Sign] to [Edit] $control.find('.controlInfo #btn_contain a.signButton4Signature').empty().text('Edit'); } // readOnly $control.off('checkAndSetReadOnly').on('checkAndSetReadOnly', function() { if(isReadOnlyApply($parent) || ctrlPropreties.isCtrlReadOnly == true){ $control.find('.controlInfo #btn_contain a').addClass('btnReadOnly'); $control.find('.controlInfo #btn_contain a').removeAttr('href'); $control.find('.controlData #btn_contain a.signButton4Signature').off(); // Fix bug 0018825: Read Only control is same as normal control! $control.addClass('btnReadOnly'); $control.find('.controlData #btn_contain a.imgActBtn').off(); $control.find('.controlData a.clearImgBtn').off(); $control.off('processCheckRequired'); }else{ $control.find('.controlInfo #btn_contain a').removeClass('btnReadOnly'); $control.find('.controlInfo #btn_contain a').removeAttr('href'); // Fix bug 0018825: Read Only control is same as normal control! $control.removeClass('btnReadOnly'); $control.find('.controlData #btn_contain a.imgActBtn').click(function(){ initializingUploadImage($(this), ctrlType, ctrlPropreties, $control); }).trigger('click'); /* hqkhanh fix 1) Resize the height of the signature tool capture area to half its height. a. On my system it is 277px, please make this half 137.5 or half of what is captured. var fbWidth = 930; var fbHeight = 510; if(isTabletPreview){ fbWidth = 400; fbHeight = 340; }else{ var screenWidth = $(window).width(); if(screenWidth - 100 < fbWidth){ var tmp = 54.83870968; fbWidth = screenWidth - 100; //fbHeight = Math.round(fbWidth*tmp/100); } } */ var fbWidth = 930; var fbHeight = 199.5; var screenWidth = $(window).width(); if(screenWidth - 100 < fbWidth){ fbWidth = screenWidth - 100; } // Fix bug 0022149: Preview - Sketch button work when user click on it // 20/Jul/2016 :: Allow sign features in all Web form GUI //if (false === checkIfWeAreInPreviewScreenGUI()) { if (true) { var btnSign = $control.find('.controlData #btn_contain a.signButton4Signature'); var regOmageContain = $control.find('.controlData .imageContain'); // Use all control for fancy box regOmageContain.add(btnSign).fancybox({ //$control.find('.controlData #btn_contain a.signButton4Signature').fancybox({ 'width' : fbWidth, 'height' : fbHeight, 'modal' : true, 'autoScale' : false, /*'overlayWidth' : '1024px',*/ 'transitionIn' : CONST_VALUE_NONE, 'transitionOut' : CONST_VALUE_NONE, 'type' : 'iframe', onComplete : function() { fvDataNS.fancyboxParam = {}; fvDataNS.fancyboxParam.hintLink = ctrlPropreties.hintLink; if(ctrlPropreties.orgHintLink == undefined){ ctrlPropreties.orgHintLink = getValueOrEmpty(ctrlPropreties.hintLink); } fvDataNS.fancyboxParam.orgHintLink = ctrlPropreties.orgHintLink; fvDataNS.fancyboxParam.file = ctrlPropreties.val; if(ctrlPropreties.attrs && ctrlPropreties.attrs['blobKey']){ fvDataNS.fancyboxParam.blobKey = ctrlPropreties.attrs['blobKey']; } }, onStart : function(){ // Update the href link for current signature this.href = "/html/signature.html"; $("body").css({'overflow-y':'hidden'}); $(".fvWorkspaceScrollArea").css({'overflow':'hidden'}); // tdchien // Assign flag value for checking we have click [Done] on sketch glbHashObject['flgHasClickButtonDoneOfSignature'] = false; }, onCleanup : function(){ // Fix bug 0022129: [Suggestion] Should show "progress indicator" when click on "Done" after skectch line on Image waitForDataLoading(true); ctrlPropreties.hintLink = $('#fancybox-frame').contents().find('input.hintLink').val(); setCtrlPropretiesValue(ctrlPropreties, $('#fancybox-frame').contents().find('input.file').val()); fvDataNS.ignoreLostFocus = false; ctrlPropreties.attrs = { 'blobKey': $('#fancybox-frame').contents().find('input.blobKey').val() }; $control.find('.controlInfo #img_uploadDataLink').attr('src', ctrlPropreties.hintLink); // Ignore href link $control.find('.controlInfo #img_uploadDataLinkHref').removeAttr('href'); //$control.find('.controlInfo #img_uploadDataLinkHref').attr('href', ctrlPropreties.hintLink); if(ctrlPropreties.hintLink == undefined || ctrlPropreties.hintLink == ''){ $control.find('.controlInfo .imageContain img').addClass(CONST_CLASS_NO_IMAGE); //$control.find('.controlInfo .imageContain img').removeClass('signatureImageBorder'); $control.removeClass(CONST_CLASS_CTRL_HAS_IMAGE); // Fix bug : 0018709: Empty image is display when user clear the image! // Remove href hyperlink $control.find('.controlInfo #img_uploadDataLinkHref').removeAttr('href'); // Process showing blank image $control.find('.controlInfo #img_uploadDataLink').attr('src', '/images/signBlank.jpg'); }else{ $control.find('.controlInfo .imageContain img').removeClass(CONST_CLASS_NO_IMAGE); $control.addClass(CONST_CLASS_CTRL_HAS_IMAGE); //$control.find('.controlInfo .imageContain img').addClass('signatureImageBorder'); } // Change label from [Sign] to [Edit] // (only affacted when we have click [Done] on Signature Drawing if (glbHashObject['flgHasClickButtonDoneOfSignature'] === true) { if(!isCorrectMediaName(ctrlPropreties.val)){ var fileType = '.jpg'; var fileName = createNewMediaName(ctrlPropreties.ctrlType, fileType); if(fileName == ''){ fileName = file; } setCtrlPropretiesValue(ctrlPropreties, fileName); } ctrlPropreties.specialChange = true; $control.find('.controlInfo .signButton4Signature').text('Edit'); // Show clear button $control.find('.controlInfo a.clearImgBtn').removeClass(CONST_CLASS_HIDE_CONTROL); // Adding required checking // Fix bug 0018711: Warning message didn't show when user click on caption text! $control.trigger('processCheckRequired'); // Adjust for option []Allow edit of Signature outside adjustSignatureOutside4AllowEdit($control, $parent); } if(isVersion(VERSION_BULK_SIGNATURE)){ if(ctrlPropreties.isBulkSignature){ $control.removeClass('Bulk-Signature'); $('.Bulk-Signature').trigger('Bulk-Signature', [ctrlPropreties.hintLink, ctrlPropreties.attrs.blobKey]); } } }, onClosed : function(){ $("body").css({'overflow-y':'visible'}); $(".fvWorkspaceScrollArea").css({'overflow':'auto'}); //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); // Fix bug 0022129: [Suggestion] Should show "progress indicator" when click on "Done" after skectch line on Image waitForDataLoading(false); } }); // Fix bug 0022149: Preview - Sketch button work when user click on it } // End if checking preview ( checkIfWeAreInPreviewScreenGUI() ) else { // Create no target for button [Signature] when clicking //$control.find('.controlData #btn_contain a.signButton4Signature').attr('href', '#notarget_destination'); $control.find('.controlData #btn_contain a.signButton4Signature').removeAttr('href');//, '#notarget_destination'); } $control.find('.controlData a.clearImgBtn').click(function(){ $control.trigger('clearData').trigger('processCheckRequired'); }); // Adding required checking // Fix bug 0018711: Warning message didn't show when user click on caption text! $control.off('processCheckRequired').on('processCheckRequired', function() { var ctrlValue = ctrlPropreties.val; if (typeof ctrlValue === 'undefined') { ctrlValue = ''; } requiredOnlyValidateError($parent, ctrlValue, $control.find('.controlInfMsg') , ctrlPropreties, $control); // Refresh layout in case of Shading // PCA-293: Webapp/Preview - Apply new block formats for all widgets. if (isVersion(VERSION_SHADINGS_AND_BUTTON_TEXT_WEB_APP) && $(this).hasClass('VERSION_SHADINGS_AND_BUTTON_TEXT_WEB_APP')) { refreshLayout4MediaButtonShadingWA($(this)); } }); } }); $control.trigger('checkAndSetReadOnly', $parent); // Process button 'Clear Signature' { $control.off('clearData').on('clearData', function(event, setDefaultValue){ setCtrlPropretiesValue(ctrlPropreties, ''); ctrlPropreties.attrs = { 'blobKey': '' }; ctrlPropreties.hintLink = ''; ctrlPropreties.orgHintLink = undefined; var uploadBtnText = CONST_VALUE_UPLOAD; // Process showing blank image $control.find('.controlInfo #img_uploadDataLink').attr('src', '/images/signBlank.jpg'); // Fix bug : 0018709: Empty image is display when user clear the image! //$control.find('.controlInfo #img_uploadDataLinkHref').attr('href', ''); $control.find('.controlInfo #img_uploadDataLinkHref').removeAttr('href'); // Hide clear button $control.find('.controlInfo a.clearImgBtn').addClass(CONST_CLASS_HIDE_CONTROL); $control.find('.controlInfo .imageContain img').addClass(CONST_CLASS_NO_IMAGE); $control.removeClass(CONST_CLASS_CTRL_HAS_IMAGE); //$control.find('.controlInfo .imageContain img').removeClass('signatureImageBorder'); $control.find('.controlInfo #btn_contain a.signButton4Signature').empty().text('Sign'); $control.find('.controlInfo #btn_contain a.imgActBtn').empty().text(uploadBtnText).removeClass(CONST_CLASS_REPLACE_BTN); //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); }); } $control.off('Control_Update').on('Control_Update', function(event){ event.stopPropagation(); if(fvDataNS.dontCallTrigger) return; return controlUpdate($parent, ctrlPropreties); }); // Adjust for option []Allow edit of Signature outside adjustSignatureOutside4AllowEdit($control, $parent); // relevanceconds addToCtrlIdRefForRelevance($parent.isShowRelevanceCondition, $parent.relevanceconds.value, ctrlPropreties.classPath); if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } ctrlPropreties.relevancecondsExpression = relevancecondsToExpression($parent.id, $parent.isShowRelevanceCondition, $parent.relevanceconds); ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); ctrlPropreties.skipcondsExpression = skipcondsToExpression($parent.id, $parent.isShowSkipCondition, $parent.skipconds, ctrlType); } /*****************************************************************************************************************/ /*End********************************************inputSignature***************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************inputAction******************************************************/ /*****************************************************************************************************************/ var fvEditorsInputAction = function($parent, $control, ctrlType, ctrlPropreties){ if($parent.imgAction){ switch($parent.imgAction.value){ case CONST_CTRL_TYPE_INPUTNFC: case CONST_CTRL_TYPE_INPUTBARCODE: $control.addClass('nfc-barcode'); break; } } if(ctrlPropreties.isCtrlHidden || isWAHidden($parent) || processActionButton($parent,'Hide') || (ctrlPropreties.hideButtonAfterClick && authNS.currentUser.returnCtrlPath && $.inArray(ctrlPropreties.classPath, authNS.currentUser.returnCtrlPath) >= 0)){ // CO-4027: Open another form case $control.addClass(CONST_CLASS_HIDE_CONTROL); } if(!isTabletPreview){ // not support switch($parent.imgAction.value){ case CONST_ACTION_LANCH_PROGRAM: $control.addClass('notSupportControl'); return; case CONST_ACTION_SEND_STATUS: if(isWebClient || isFillAndSend || viewDataFillAndSend){ break; } $control.addClass('notSupportControl'); return; case 'Credit Card Payment': $control.addClass('notSupportControl'); return; case CONST_ACTION_FLINT_APP: $control.addClass('notSupportControl'); return; case CONST_ACTION_PROPAY: if(!isVersion(VERSION_SUPPORT_PROPAY_WEAPP)){ $control.addClass('notSupportControl'); return; } break; case CONST_ACTION_SQUARE: if(!isVersion(VERSION_SUPPORT_SQUARE_WEAPP)){ $control.addClass('notSupportControl'); return; } break; case CONST_ACTION_PRINT_MOBILE: $control.addClass('notSupportControl'); return; case CONST_ACTION_SHIPPING_CREATE_LABEL: break; case CONST_ACTION_SHIPPING_GET_RATE: break; } } ctrlPropreties.imgAction = $parent.imgAction.value; var hasImageIcon = false; // hintLink if($parent.hintLink.value == undefined || $parent.hintLink.value == ''){ $control.find('.controlInfo .controlImage').addClass(CONST_CLASS_HIDE_CONTROL); }else{ hasImageIcon = true; if($parent.imageSize && $parent.imageSize.value == 'ImageSize'){ if($parent.hintLink.value.indexOf('/imageViewer?blobKey=') >= 0){ $control.find('.controlInfo img#img_0').attr('src', $parent.hintLink.value); $control.find('.controlInfo img#img_0').off('orientationchange').on('orientationchange', function(){ $(this).attr('src', $parent.hintLink.value); }); }else{ $control.find('.controlInfo img#img_0').attr('src', $parent.hintLink.value); } }else{ if($parent.hintLink.value.indexOf('/imageViewer?blobKey=') >= 0){ $control.find('.controlInfo img#img_0').attr('src', $parent.hintLink.value + "&maxWidth=" + fvDataNS.ctrlWidth); $control.find('.controlInfo img#img_0').off('orientationchange').on('orientationchange', function(){ $(this).attr('src', $parent.hintLink.value + "&maxWidth=" + fvDataNS.ctrlWidth); }); }else{ var ctrlImg = $control.find('.controlInfo img#img_0'); var inconSize = 'small'; if(ctrlPropreties.buttonSize && 'small' != ctrlPropreties.buttonSize) { inconSize = ctrlPropreties.buttonSize; } if(ctrlPropreties.ifScreenSmallerThan && (getParent() && getParent().previewMode && getParent().previewMode.size && ctrlPropreties.applyScreenSize && parseFloat(getParent().previewMode.size) < parseFloat(ctrlPropreties.applyScreenSize))) { inconSize = ctrlPropreties.ifScreenSmallerSize; } // if(ctrlPropreties.buttonSize && 'small' != ctrlPropreties.buttonSize) { // if(!ctrlPropreties.ifScreenSmallerThan) { // inconSize = ctrlPropreties.buttonSize; // } else if(getParent() && getParent().previewMode && getParent().previewMode.size // && ctrlPropreties.applyScreenSize // && parseFloat(getParent().previewMode.size) < parseFloat(ctrlPropreties.applyScreenSize)) { // inconSize = ctrlPropreties.buttonSize;//iconSize = medium | large // } // } if((FILIB_ICON_IMAGE_CANVAS && $parent.hintLink.value.indexOf('/img/filib/') >= 0) || (FILIBBUTTON_ICON_IMAGE_CANVAS && $parent.hintLink.value.indexOf('/img/filibbutton/') >= 0)) { var ctrlCanvas = $control.find('.controlInfo canvas#canvas_0'); ctrlCanvas.css('max-width','100%'); var canvasWidth = CONST_FILIB_ICON_SMALL_WIDTH;//187 var canvasHeight = CONST_FILIB_ICON_SMALL_HEIGHT;//187 var imageWidth = CONST_FILIB_ICON_IMAGE_WIDTH;//187; var imageHeight = CONST_FILIB_ICON_IMAGE_HEIGHT;//187; if('medium' == inconSize) { canvasWidth = CONST_FILIB_ICON_MEDIUM_WIDTH; canvasHeight = CONST_FILIB_ICON_MEDIUM_HEIGHT; } else if('large' == inconSize) { canvasWidth = CONST_FILIB_ICON_LARGE_WIDTH; canvasHeight = CONST_FILIB_ICON_LARGE_HEIGHT; } if($parent.hintLink.value.indexOf('/img/filib/') >= 0){ ctrlCanvas[0].width = canvasWidth; ctrlCanvas[0].height = canvasHeight; } else if($parent.hintLink.value.indexOf('/img/filibbutton/') >= 0){ canvasWidth = CONST_FILIB_BUTTON_SMALL_WIDTH;//96; canvasHeight = CONST_FILIB_BUTTON_SMALL_HEIGHT;//28; if('medium' == inconSize) { canvasWidth = CONST_FILIB_BUTTON_MEDIUM_WIDTH;//144; canvasHeight = CONST_FILIB_BUTTON_MEDIUM_HEIGHT;//42; } else if('large' == inconSize) { canvasWidth = CONST_FILIB_BUTTON_LARGE_WIDTH;//168; canvasHeight = CONST_FILIB_BUTTON_LARGE_HEIGHT;//49; } imageWidth = CONST_FILIB_BUTTON_IMAGE_WIDTH; imageHeight = CONST_FILIB_BUTTON_IMAGE_HEIGHT; ctrlCanvas[0].width = canvasWidth; ctrlCanvas[0].height = canvasHeight; ctrlCanvas.css('margin','10px 0px'); } else { ctrlImg.attr('src', $parent.hintLink.value); ctrlImg.css('width', CONST_VALUE_INITIAL); } var indexImpFilib = $parent.hintLink.value.indexOf('/img/filib'); if(indexImpFilib >=0 ){ var imageObj = new Image(); imageObj.canvas = ctrlCanvas[0]; imageObj.iconColor = ctrlPropreties.iconColor; imageObj.canvasWidth = canvasWidth; imageObj.canvasHeight = canvasHeight; imageObj.imageWidth = imageWidth; imageObj.imageHeight = imageHeight; imageObj.onload = function() { drawImageToCanvas(this.canvas, this, this.iconColor , this.canvasWidth, this.canvasHeight, this.imageWidth, this.imageHeight); } imageObj.src = $parent.hintLink.value.substring(indexImpFilib, $parent.hintLink.value.length) .replace('/transparent/','/ffffff/'); ctrlCanvas.removeClass('hideSessionImp'); ctrlImg.css('display', 'none'); } } else { if(ctrlPropreties.iconColor != undefined){ if(('999899' == ctrlPropreties.iconColor || CONST_FILIB_WHITE_BACKGROUND_COLOR == ctrlPropreties.iconColor) && $parent.hintLink.value.indexOf('/ffffff/') >= 0) { //incase of white color icon, no fill background } else { ctrlImg.css('background-color', '#' + ctrlPropreties.iconColor); // CO-4050 } } ctrlImg.attr('src', $parent.hintLink.value); // delete for CO-4925: Action button image size different in pre if($parent.hintLink.value.indexOf('/img/filib/')>=0){ ctrlImg.css('width', CONST_FILIB_ICON_SMALL_WIDTH + 'px');//96px if('medium' == inconSize) { ctrlImg.css('width', CONST_FILIB_ICON_MEDIUM_WIDTH + 'px');//144px } else if('large' == inconSize) { ctrlImg.css('width', CONST_FILIB_ICON_LARGE_WIDTH + 'px');//168px } }else{ ctrlImg.css('width', CONST_VALUE_INITIAL).css('max-width', '100%'); } } } } } var btnDispatchUpload = ''; try{ // CO-3502 if(isApplyActionOpenFile($parent)){ btnDispatchUpload = $parent.ofRequired.value; var defaultValue; if(ctrlPropreties.val == undefined){ defaultValue = $parent.openFile.value; }else{ defaultValue = ctrlPropreties.val; } ctrlPropreties.val = defaultValue; $control.find('.controlData textarea').val(ctrlPropreties.val); var caption = ''; if($parent.ofDispatchCaptionText && $parent.ofDispatchCaptionText.value){ caption = $parent.ofDispatchCaptionText.value; } if(caption == undefined || caption === ''){ if('2' === $parent.ofSource.value){ caption = msg_source_web_url; } else{ caption = msg_source_upload; } } $control.find('.controlLabel').empty().append(caption); if('2' === $parent.ofSource.value){ $control.find('.controlData .controlButton').css('display','none'); $control.find('.controlData textarea') .prop('disabled', false) .blur(function(event) { ctrlPropreties.val = $(this).val(); }); } // label $control.off('checkAndSetRequired').on('checkAndSetRequired', function() { fvAppendRequired($parent, $control.find('.controlLabel')); }); $control.trigger('checkAndSetRequired'); } } catch(e){} // Hide label in case of empty value if('2' === btnDispatchUpload){ // do nothing } else if(isVersion(VERSION_ACTION_TYPE)){ if($parent.kind && $parent.kind.value == 'Image'){ if ($parent.imageText === undefined || !$parent.imageText.value || $parent.imageText.value === '') { $control.find('.controlLabel').hide(); }else{ // label $control.find('.controlLabel').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.imageText.value))); } hasImageIcon = false; }else{ $control.find('.controlLabel').hide(); if(hasImageIcon){ $control.addClass(CONST_CLS_SHOW_IMAGE_ICON); } $control.find('.controlInfo canvas#canvas_0').addClass('hideSessionImp'); $control.find('.controlInfo img#img_0').css('display', 'none'); } }else{ if ($parent.useImage && $parent.useImage.value){ if($parent.label.value.eng === undefined || $parent.label.value.eng === null || $parent.label.value.eng === '') { $control.find('.controlLabel').hide(); }else{ $control.find('.controlLabel').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.label.value.eng))); } }else{ $control.find('.controlLabel').hide(); } } if (!($parent.useImage && $parent.useImage.value)){ if(isVersion(VERSION_PAYMENT_TYPE) && ctrlPropreties.displayCCIcon){ $control.find('#displayCCIcon').removeClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } } // hint $control.find('.controlHint').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.hint.value.eng))); // Hide hint in case of empty value if ($parent.hint.value.eng === undefined || $parent.hint.value.eng === null || $parent.hint.value.eng === '') { $control.find('.controlHint').hide(); }else{ switch($parent.imgAction.value){ case CONST_ACTION_RETRIEVE: $control.find('.controlHint').hide(); break; } } // hideInMobile $control.off('checkAndSetHide').on('checkAndSetHide', function() { execShowHideWebAppControl($control, $parent) }); //$control.trigger('checkAndSetHide'); execShowHideWebAppControl($control, $parent) if($control.hasClass('hideOnMobileApp')){ //return; } if(hasImageIcon){ var imageIcon; var useCanvas = false; var btnIcon = $parent.hintLink.value; var btnIconColor = ctrlPropreties.iconColor; if(btnIconColor && !btnIconColor.startsWith('#')){ btnIconColor = '#' + btnIconColor; } if(btnIcon.indexOf('img/filib/transparent/') >= 0 || btnIcon.indexOf('/img/filib/') >= 0 || btnIcon.indexOf('/img/filibbutton/') >= 0){ imageIcon = $(''); $control.find('.controlData a').empty().append(imageIcon).append('

' + ($parent.actionBtnText.value || 'Enter button text') + '

'); var indexImpFilib = btnIcon.indexOf('/img/filib'); btnIcon = btnIcon.substring(indexImpFilib, $parent.hintLink.value.length); indexImpFilib = btnIcon.indexOf('/img/filibbutton/ffffff/'); if(indexImpFilib >=0){ var bgColor = btnIconColor; if(btnIconColor.toLowerCase() == '#ffffff'){ bgColor = '#000000'; }else{ bgColor = '#ffffff'; } useCanvas = setCanvasImage2(btnIcon, $control.find('.controlData a canvas')[0], bgColor, btnIconColor); }else{ useCanvas = setCanvasImage(btnIcon, $control.find('.controlData a canvas')[0], undefined, btnIconColor); } } if(!useCanvas){ imageIcon = $(''); if(btnIcon.indexOf('/')>=0){ imageIcon.prop('src', btnIcon); }else{ imageIcon.prop('src', 'url("/imageViewer?blobKey=' + btnIcon + '")'); } if(btnIconColor !== null){ if(btnIcon.indexOf('img/filib/ffffff/')>=0){ if(btnIconColor !== '#000000'){ imageIcon.css('background-color', btnIconColor); } }else if(btnIcon.indexOf('img/filib/transparent/')>=0){ imageIcon.css('background-color', btnIconColor); } } $control.find('.controlData a').empty().append(imageIcon).append('

' + ($parent.actionBtnText.value || 'Enter button text') + '

'); } }else{ // button text $control.find('.controlData a').empty().append('

' + ($parent.actionBtnText.value || 'Enter button text') + '

'); } if(isVersion(VERSION_ACTION_TYPE)){ if($parent.kind == undefined || $parent.kind.value == undefined){ if($parent.useImage.value){ $control.find('.controlData a').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); }else{ $control.find('.controlData img#img_0').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } }else{ if($parent.kind.value == 'Image'){ $control.find('.controlData a').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); }else{ $control.find('.controlData img#img_0').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } } }else{ if($parent.useImage.value){ $control.find('.controlData a').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); }else{ $control.find('.controlData img#img_0').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } } if(isVersion(VERSION_IMAGE_CAPTION_JUSTIFY)){ // imgJustify if('2' === btnDispatchUpload){ $control.find('.controlData textarea').blur(function(event) { var ctrlValue = ctrlPropreties.val; textValidateError($parent, ctrlValue, $control.find('.controlInfMsg'), ctrlPropreties, $control); }); } else if($parent.imgJustify.value == undefined || $parent.imgJustify.value == 'Center'){ $control.find('.controlHint').addClass('controlTextCenter'); $control.find('.controlData').addClass('controlTextCenter'); }else if($parent.imgJustify.value != undefined && $parent.imgJustify.value == 'Right'){ $control.find('.controlHint').addClass('controlTextRight'); $control.find('.controlData').addClass('controlTextRight'); }else{ $control.find('.controlHint').addClass('controlTextLeft'); $control.find('.controlData').addClass('controlTextLeft'); } if($parent.justificationCaption.value == undefined || $parent.justificationCaption.value == '1'){ $control.find('.controlLabel').addClass('controlTextCenter'); }else if($parent.justificationCaption.value != undefined && $parent.justificationCaption.value == '2'){ $control.find('.controlLabel').addClass('controlTextRight'); }else{ $control.find('.controlLabel').addClass('controlTextLeft'); } }else{ // imgJustify if('2' === btnDispatchUpload){ $control.find('.controlData textarea').blur(function(event) { var ctrlValue = ctrlPropreties.val; textValidateError($parent, ctrlValue, $control.find('.controlInfMsg'), ctrlPropreties, $control); }); } else if($parent.imgJustify.value == undefined || $parent.imgJustify.value == 'Center'){ $control.find('.controlLabel').addClass('controlTextCenter'); $control.find('.controlHint').addClass('controlTextCenter'); $control.find('.controlData').addClass('controlTextCenter'); //$control.find('.controlInfo .controlImage img').addClass('imgJustifyCenter'); }else if($parent.imgJustify.value != undefined && $parent.imgJustify.value == 'Right'){ $control.find('.controlLabel').addClass('controlTextRight'); $control.find('.controlHint').addClass('controlTextRight'); $control.find('.controlData').addClass('controlTextRight'); //$control.find('.controlInfo .controlImage img').addClass('imgJustifyRight'); }else{ $control.find('.controlLabel').addClass('controlTextLeft'); $control.find('.controlHint').addClass('controlTextLeft'); $control.find('.controlData').addClass('controlTextLeft'); //$control.find('.controlInfo .controlImage img').addClass('imgJustifyLeft'); } } if(CONST_ACTION_ATTACH_FORM == $parent.imgAction.value) { $control.addClass('shadingControlBackground'); $control.find('.actionValue').show(); var btnAction = $control.find('.actionBtn'); btnAction.css('width', '100%'); if (isReadOnlyApply($parent)) { btnAction.addClass('btnReadOnly'); } btnAction.find('.actionLabelText').empty().append(CONST_VALUE_ATTACH); var controlLabel2 = $control.find('.controlLabel2'); controlLabel2.empty().append(removeUnsupportHTML(getValueOrEmpty($parent.label.value.eng))); controlLabel2.show(); $control.off('checkAndSetRequired').on('checkAndSetRequired', function() { fvAppendRequired($parent, $control.find('.controlLabel2')); }); $control.trigger('checkAndSetRequired'); //$control.find('.buttonMediaGeneralRegion').css('display','flex'); var justificationHint = $parent.justificationHint.value; if(justificationHint == undefined || justificationHint == '1'){ $control.find('.controlHint').addClass('controlTextCenter'); }else if(justificationHint != undefined && justificationHint == '2'){ $control.find('.controlHint').addClass('controlTextRight'); }else{ $control.find('.controlHint').removeClass('controlTextCenter'); $control.find('.controlHint').addClass('controlTextLeft'); } $control.find('.imgActBtn').on('click', function(event){ $control.find('.actionBtn').trigger('click'); }); $control.find('.clearImgBtn').on('click', function(event){ ctrlPropreties.val = ''; $control.find('.actionValue').val(''); $control.find('.actionBtn').show(); //$control.find('.buttonMediaGeneralRegion').hide(); var buttonMediaGeneralRegion = $control.find('.buttonMediaGeneralRegion'); buttonMediaGeneralRegion.css('display',''); buttonMediaGeneralRegion.attr('style', buttonMediaGeneralRegion.attr('style') + 'display:none!important;'); }); $control.find('.imgActBtn').text(CONST_VALUE_REPLACE); $control.find('.clearImgBtn').text(CONS_RETRIVE_ACTION_CLEAR_TEXT); //set value for edit screen var defaultValue; if(ctrlPropreties.val == undefined){ defaultValue = $parent.openFile.value; }else{ defaultValue = ctrlPropreties.val; } ctrlPropreties.val = defaultValue; if(defaultValue.includes('$$')) { defaultValue = defaultValue.split('$$')[1]; } $control.find('.controlData .actionValue').val(defaultValue); var buttonMediaGeneralRegion = $control.find('.buttonMediaGeneralRegion'); if (defaultValue) { buttonMediaGeneralRegion.show(); btnAction.hide(); } else { buttonMediaGeneralRegion.hide(); btnAction.show(); } } switch($parent.imgAction.value){ case CONST_ACTION_PLAY_VIDEO: var videoLink = $parent.imgActionParam.value; /*if(videoLink != undefined){ videoLink = videoLink.replace('youtube.com/watch?v=', 'youtube.com/embed/'); }*/ videoLink = changeYoutobeLink(videoLink); // Adjust short URL into full URL // Fix bug 0019686: Action - Play video works incorrectly!! if (videoLink.indexOf('://') < 0) { videoLink = 'http://' + videoLink; } $control.find('.controlData .actionBtn').attr('href', videoLink); //$(this).colorbox({iframe:true, innerWidth:640, innerHeight:390}); $control.find('.controlData .actionBtn, .lblImageText').fancybox({ 'width' : '100%', 'height' : '100%', 'modal' : true, 'autoScale' : true, 'transitionIn' : CONST_VALUE_NONE, 'transitionOut' : CONST_VALUE_NONE, 'type' : 'iframe', onStart : function(){ $("body").css({'overflow-y':'hidden'}); $(".fvWorkspaceScrollArea").css({'overflow':'hidden'}); }, onClosed : function(){ $("body").css({'overflow-y':'visible'}); $(".fvWorkspaceScrollArea").css({'overflow':'auto'}); } }); break; case CONST_ACTION_LAUNCH_GOOGLE_MAP: // CO-4098: Route Summary processLaunchGoogleMap($parent, $control, ctrlType, ctrlPropreties); break; case CONST_ACTION_LAUNCH_GARMIN_DIRECTIONS: $control.find('.controlData .actionBtn, .lblImageText').fancybox({ 'width' : '100%', 'height' : '100%', 'modal' : true, 'autoScale' : true, 'transitionIn' : CONST_VALUE_NONE, 'transitionOut' : CONST_VALUE_NONE, 'type' : 'iframe', helpers: { overlay: { css: { 'background': 'rgba(204, 255, 238, 0.8)' } } }, beforeShow: function () { google.maps.event.trigger(map, "resize"); }, onStart : function(){ var link = getLaunchGoogleMapLink(ctrlPropreties, $parent); if(link == false){ return false; } this.href = link + '&output=embed'; $("body").css({'overflow-y':'hidden'}); $(".fvWorkspaceScrollArea").css({'overflow':'hidden'}); }, onClosed : function(){ $("body").css({'overflow-y':'visible'}); $(".fvWorkspaceScrollArea").css({'overflow':'auto'}); } }); break; case CONST_ACTION_JUMP_TO_QUES: case CONST_ACTION_JUMP_TO_PAGE: $control.addClass('ignore_focus'); break; case CONST_ACTION_PROPAY: $control.find('.controlData .actionBtn, .lblImageText').fancybox({ 'width' : '100%', 'height' : '100%', 'modal' : true, 'autoScale' : true, /* 'width' : 510, 'height' : 450, 'modal' : true, 'autoScale' : false, */ 'transitionIn' : CONST_VALUE_NONE, 'transitionOut' : CONST_VALUE_NONE, 'type' : 'iframe', helpers: { overlay: { css: { 'background': 'rgba(204, 255, 238, 0.8)' } } }, onComplete: function () { setTimeout(function(){ $('#fancybox-wrap').attr('style', 'width:95%;left:0px;padding:0 2.5%;display:block;top:40px'); }, 1000); $('#fancybox-bg-n.fancybox-bg').attr('style', 'top: -' + $('#fancybox-bg-n.fancybox-bg')[0].scrollHeight + 'px;'); $('#fancybox-content').css('min-height', '245px'); }, onStart : function(){ $('.fancybox-bg').each(function(){ if($(this).attr('id') != 'fancybox-bg-n') { $(this).remove(); } }); $("#fancybox-close").remove(); $("#fancybox-bg-n").css('top', '-42px').empty().append(''); $("#fancybox-bg-n").find('.close').click($.fancybox.close); $.fancybox.close var link = getProPayLink(ctrlPropreties, $parent); if(link == null){ return false; } this.href = link; $("body").css({'overflow-y':'hidden'}); $(".fvWorkspaceScrollArea").css({'overflow':'hidden'}); glbHashObject['flgHasSuccess'] = false; }, onCleanup : function(){ if(glbHashObject['flgHasSuccess']){ jAlert('Your credit card transaction was successful','Successful', function(){ jumpToNextCtrl($control); }); ctrlPropreties.val = 'charged'; var msg = ''; if(ctrlPropreties.isDisplayAmountCharged){ msg = msg_propay_success; } if(ctrlPropreties.addMessage && ctrlPropreties.addMessage.check){ msg += '
' + ctrlPropreties.addMessage.text + '
'; } if(msg != ''){ var formatValue = formatNumber(glbHashObject['flgHasSuccessAmount'], '$', undefined, 2); $control.find('.controlData a.actionBtn').replaceWith(msg.replace('$1', formatValue)); $control.find('#displayCCIcon').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); $control.find('#img_0').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); $control.find('.lblImageText').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); }else{ $control.addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } if(ctrlPropreties.amountCharged){ var desCtrlId = ctrlPropreties.amountCharged; var setValue = glbHashObject['flgHasSuccessAmount']; var desCtrls = fvDataNS.ctrlIdMap[desCtrlId]; if(desCtrls){ _.each(desCtrls, function(key, value){ var itemProperty = fvDataNS.dataArray[key]; var item = fvDataNS.ctrlArray[key]; if(item.find('textarea').length > 0){ item.find('textarea').trigger('setLookupValue', setValue); item.find('.controlData textarea').prop('disabled', true); item.find('.inputinner_textarea').addClass('ctrlReadOnly'); item.addClass('ctrlReadOnly'); }else{ item.find('input').trigger('setLookupValue', setValue); item.find('.controlData input').prop('disabled', true); item.find('.inputinner').addClass('ctrlReadOnly'); } }); } } } }, onClosed : function(){ $("body").css({'overflow-y':'visible'}); $(".fvWorkspaceScrollArea").css({'overflow':'auto'}); } }); break; case CONST_ACTION_SQUARE: $control.find('.controlData .actionBtn, .lblImageText').fancybox({ /*'width' : '100%', 'height' : '100%', 'modal' : true, 'autoScale' : true,*/ 'width' : '99%', 'height' : 460, 'modal' : true, 'autoScale' : false, 'transitionIn' : CONST_VALUE_NONE, 'transitionOut' : CONST_VALUE_NONE, 'type' : 'iframe', helpers: { overlay: { css: { 'background': 'rgba(204, 255, 238, 0.8)' } } }, onComplete: function () { /*setTimeout(function(){ $('#fancybox-wrap').attr('style', 'width:95%;left:0px;padding:0 2.5%;display:block;'); }, 1000);*/ $('#fancybox-bg-n.fancybox-bg').attr('style', 'top: -' + $('#fancybox-bg-n.fancybox-bg')[0].scrollHeight + 'px;'); $('#fancybox-content').css('min-height', '245px'); }, onStart : function(){ $('.fancybox-bg').each(function(){ if($(this).attr('id') != 'fancybox-bg-n') { $(this).remove(); } }); $("#fancybox-close").remove(); $("#fancybox-bg-n").css('top', '-42px').empty().append(''); $("#fancybox-bg-n").find('.close').click($.fancybox.close); $.fancybox.close var link = getSqPaymentFormLink(ctrlPropreties, $parent); if(link == null){ return false; } this.href = link; $("body").css({'overflow-y':'hidden'}); $(".fvWorkspaceScrollArea").css({'overflow':'hidden'}); glbHashObject['flgHasSuccess'] = false; }, onCleanup : function(){ if(glbHashObject['flgHasSuccess']){ jAlert('Your credit card transaction was successful','Successful', function(){ jumpToNextCtrl($control); }); ctrlPropreties.val = 'charged'; var msg = ''; if(ctrlPropreties.isDisplayAmountCharged){ msg = msg_propay_success; } if(ctrlPropreties.addMessage && ctrlPropreties.addMessage.check){ msg += '
' + ctrlPropreties.addMessage.text + '
'; } if(msg != ''){ var formatValue = formatNumber(glbHashObject['flgHasSuccessAmount'], '$', undefined, 2); $control.find('.controlData a.actionBtn').replaceWith(msg.replace('$1', formatValue)); $control.find('#displayCCIcon').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); $control.find('#img_0').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); $control.find('.lblImageText').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); }else{ $control.addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } if(ctrlPropreties.totalAmountPaid){ var desCtrlId = ctrlPropreties.totalAmountPaid; var setValue = glbHashObject['flgHasSuccessAmount']; var desCtrls = fvDataNS.ctrlIdMap[desCtrlId]; if(desCtrls){ _.each(desCtrls, function(key, value){ var itemProperty = fvDataNS.dataArray[key]; var item = fvDataNS.ctrlArray[key]; if(item.find('textarea').length > 0){ item.find('textarea').trigger('setLookupValue', setValue); item.find('.controlData textarea').prop('disabled', true); item.find('.inputinner_textarea').addClass('ctrlReadOnly'); item.addClass('ctrlReadOnly'); }else{ item.find('input').trigger('setLookupValue', setValue); item.find('.controlData input').prop('disabled', true); item.find('.inputinner').addClass('ctrlReadOnly'); } }); } } if(ctrlPropreties.transactionClientId){ var desCtrlId = ctrlPropreties.transactionClientId; var setValue = glbHashObject['flgHasSuccessTransactionId']; var desCtrls = fvDataNS.ctrlIdMap[desCtrlId]; if(desCtrls){ _.each(desCtrls, function(key, value){ var itemProperty = fvDataNS.dataArray[key]; var item = fvDataNS.ctrlArray[key]; if(item.find('textarea').length > 0){ item.find('textarea').trigger('setLookupValue', setValue); item.find('.controlData textarea').prop('disabled', true); item.find('.inputinner_textarea').addClass('ctrlReadOnly'); item.addClass('ctrlReadOnly'); }else{ item.find('input').trigger('setLookupValue', setValue); item.find('.controlData input').prop('disabled', true); item.find('.inputinner').addClass('ctrlReadOnly'); } }); } } } }, onClosed : function(){ $("body").css({'overflow-y':'visible'}); $(".fvWorkspaceScrollArea").css({'overflow':'auto'}); } }); break; case CONST_ACTION_OPEN_REVIEW: if(!isTabletPreview && !fvDataNS.isLoadedIncomplete){ fvDataNS.isLoadedIncomplete = true; updateFVDBInfoForIncomple(false, true); /*updateFVDBInfoForSent(false, false); updateFVDBInfoForComplete(false, false);*/ } break; case CONST_ACTION_ZEBRA_PRINT: zebraPrint($parent, $control, ctrlPropreties); break; case CONST_ACTION_SHIPPING_CREATE_LABEL: break; case CONST_ACTION_SHIPPING_GET_RATE: break; case CONST_ACTION_AUDIT: if(ctrlPropreties.val == undefined || ctrlPropreties.val == ''){ if(fvDataNS.auditDataInfo == undefined){ fvDataNS.auditDataInfo = {}; } fvDataNS.auditDataInfo[ctrlPropreties.classPath] = {}; } getEditRecordData4Audit(ctrlPropreties); break; case CONST_ACTION_GET_GEOTAB_DATA: if(authNS.currentUser == undefined || authNS.currentUser.CustomerKey == undefined){ storeData("geotab-userName-" + undefined, ""); storeData("geotab-sessionId-" + undefined, ""); storeData("geotab-database-" + undefined, ""); storeData("geotab-path-" + undefined, ""); } break; } // PCA-625 : Form Preview | Action Button - Addition, to add printing support for Web Client Only // (Just disable the Print action button in Preview.) var arrJQuerySelect = new Array(); arrJQuerySelect.push($control); arrJQuerySelect.push($control.find('.actionLabelText')); arrJQuerySelect.push($control.find('.controlLabel')); arrJQuerySelect.push($control.find('.actionBtn')); applyGrayFilter4ActionPrintWebClient($parent.imgAction.value, arrJQuerySelect); // try { // var isNeedDisabledBtnAction = false; // // Disable button inside Form > Preview // if ($parent.imgAction.value === CONST_ACTION_PRINT) { // // Trigger event print WebApps GUI (ignore Form Preview) // var url = window.location.toString(); // if (url.indexOf('fnId=preview_tablet') > 0 // && url.indexOf('/preview') > 0 // ) { // // Do nothing because we are in Form Preview // writeToLogInfoRequired('Process disable button inside Form Preview ...'); // isNeedDisabledBtnAction = true; // } // } // // if (isNeedDisabledBtnAction === true) { // var grayFilter = '-webkit-filter: grayscale(1) !important;'; // grayFilter += '-moz-filter: grayscale(1) !important;'; // grayFilter += '-ms-filter: grayscale(1) !important;'; // grayFilter += 'filter: grayscale(1) !important;'; // grayFilter += 'filter: gray !important;'; // /* Firefox 10+, Firefox on Android */ // grayFilter += 'filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale");'; // grayFilter += 'color: gray !important;'; // grayFilter += 'cursor: default !important;'; // grayFilter += '-webkit-filter: grayscale(100%); !important'; // // var arrJQuerySelect = new Array(); // arrJQuerySelect.push($control); // arrJQuerySelect.push($control.find('.actionLabelText')); // arrJQuerySelect.push($control.find('.controlLabel')); // arrJQuerySelect.push($control.find('.actionBtn')); // // for (var t = 0; t < arrJQuerySelect.length; t++) { // var objQuery = arrJQuerySelect[t]; // var objQueryCss = objQuery.attr('style'); // if (!objQueryCss || objQueryCss === null) { // objQueryCss = ''; // } // objQuery.attr('style', objQueryCss.toString() + ';' + grayFilter); // } // } // } catch (e) { // } // CO-3502 $control.find('.controlData .btnDispatchUpload').click(function(e){ initializingFVUploadFile($(this), ctrlPropreties, $control); }).trigger('click'); $control.find('.controlData .btnDispatchClear').click(function(e){ ctrlPropreties.val = ''; $control.find('.controlData textarea').css('height', '20px').val(''); }); ctrlPropreties.isRunning = false; $control.find('.controlData .actionBtn, .lblImageText') .on('reset_running_flag', function(){ if(ctrlPropreties.isRunning){ ctrlPropreties.isRunning = false; } }) .click(function(e, data){ fvDataNS.ignoreLostFocus = false; actionClickInfo = { 'screenHeight': screen.height, 'screenX': e.screenX, 'screenY': e.screenY, 'clientX': e.clientX, 'clientY': e.clientY, 'left': $(this).position().left, 'top': $(this).position().top, 'start': true } if(processActionButton($parent,'Message')){ actionClickInfo.start = false; relaseIsRunningFlag(ctrlPropreties); return; } if(ctrlPropreties && ctrlPropreties.isRunning){ actionClickInfo.start = false; relaseIsRunningFlag(ctrlPropreties); return; } myPostMessage($control, 'click'); var tmpStatus = ''; if(fvDataNS.currentForm.editRecordData != undefined && fvDataNS.currentForm.editRecordData['@Status'] != undefined && fvDataNS.currentForm.editRecordData['@Status'].value != undefined){ tmpStatus = fvDataNS.currentForm.editRecordData['@Status'].value; } if($parent.imgAction.value == CONST_ACTION_OPEN_FILE && $parent.ofRequired && $parent.ofRequired.value == '2'){ // do nothing } else if(CONST_ACTION_RETRIEVE == $parent.imgAction.value || CONST_ACTION_SET_DESTINATION_FIELDS == $parent.imgAction.value) { // do nothing, fix CO-4348: Web forms- Showing all fields when loading from (Mr.Khanh give and take) } else{ actionButtonClick(ctrlPropreties); } if(CONST_ACTION_SET_DESTINATION_FIELDS == $parent.imgAction.value) { //do nothing fix Co-4448 same as CO-4348 } else { autostampTrigger(ctrlPropreties, true); } destinationFillTrigger($parent, ctrlPropreties); switch($parent.imgAction.value){ case CONST_ACTION_JUMP_TO_QUES: //window.location.href = '#fvCtrlID_' + $parent.imgActionParamDesQues.value; jumpToCtrl(ctrlPropreties, $parent.imgActionParamDesQues.value, undefined, true); // Refresh layout of media buttons in shading mode (PCA-180) inside PageBreak reArrangeLayoutOfChooseOneWithShadingWALastAction(); break; case CONST_ACTION_JUMP_TO_PAGE: var parentPage = undefined; switch($parent.imgActionParamDesPage.value){ case 'first': var pages = $('.fvWorkspace .inputPageBreak'); var i = 0; while(i=0){ var page = $(pages[i]); if(page.hasClass('page-active')){ break; } if(!page.hasClass(CONST_CLASS_HIDE_CONTROL) && !page.hasClass(CONST_CSS_CLASS_HIDE_SESSION) && !page.hasClass(CONST_HIDEONMOBILEAPP)){ parentPage = page; } i--; } break; case 'last': var pages = $('.fvWorkspace .inputPageBreak'); var i = pages.length - 1; while(i>=0){ var page = $(pages[i]); if(!page.hasClass(CONST_CLASS_HIDE_CONTROL) && !page.hasClass(CONST_CSS_CLASS_HIDE_SESSION) && !page.hasClass(CONST_HIDEONMOBILEAPP)){ parentPage = page; break; } i--; } break; case 'top': parentPage = undefined; var visibleCtrls = $('.fvControl:visible'); if($(visibleCtrls[0]).hasClass('inputPageBreak')){ focusControl($(visibleCtrls[1]), true); }else{ focusControl($(visibleCtrls[0]), true); } break; case 'bottom': parentPage = undefined; var visibleCtrls = $('.fvControl:visible'); focusControl($(visibleCtrls[visibleCtrls.length - 1]), true); break; default: parentPage = $('#fvCtrlID_' + $parent.imgActionParamDesPage.value); } if(parentPage && !parentPage.hasClass(CONST_CLASS_HIDE_CONTROL) && !parentPage.hasClass(CONST_CSS_CLASS_HIDE_SESSION)){ /*var hideShowDetailBtn = parentPage.find('.hideShowDetailBtn'); if(hideShowDetailBtn.hasClass('showDetailBtn')){ hideShowDetailBtnClick(parentPage); }*/ hideShowDetailBtnClick(parentPage); //window.location.href = '#fvCtrlID_' + $parent.imgActionParamDesPage.value; //jumpToCtrl(ctrlPropreties, $parent.imgActionParamDesPage.value, undefined, true); // Refresh layout of media buttons in shading mode (PCA-180) inside PageBreak reArrangeLayoutOfChooseOneWithShadingWALastAction(); } break; case CONST_ACTION_PLAY_VIDEO: break; case CONST_ACTION_OPEN_WEB_PAGE: var isFromQuestion = false; if(isVersion(VERSION_OPEN_WEB_PAGE_NEW)){ if($parent.imgOpenWebPageQues && $parent.imgOpenWebPageQues.value !== '__Constant__'){ isFromQuestion = true; } } if(isVersion(VERSION_CONSISTENCE_DROPDOWN) && (!$parent.imgOpenWebPageParamType || $parent.imgOpenWebPageParamType.value != CONST_VALUE_OTHER)){ isFromQuestion = false; } var webPageLink = ''; if(isFromQuestion){ var linkField = fvDataNS.ctrlMap[$parent.imgOpenWebPageQues.value]; var parrentProperties = fvDataNS.dataArray[ctrlPropreties.parrentProperties]; var controlsProperties = getCtrlPropertyInRoot(linkField, parrentProperties); if(isHidenControl(controlsProperties)){ webPageLink = ''; }else{ webPageLink = controlsProperties.val; } }else{ webPageLink = $parent.imgActionParam.value; } // Fix bug 0019686: Action - Play video works incorrectly!! if (webPageLink.indexOf('://') < 0) { webPageLink = 'http://' + webPageLink; } window.open(webPageLink, '_blank'); break; case CONST_ACTION_LANCH_PROGRAM: // not support break; case CONST_ACTION_SEND_STATUS: sendDispatchCustomStatus($parent, ctrlPropreties); break; case CONST_ACTION_SAVE_AS_COMPLETE: if($parent.imgActionIncompleteStatus){ ctrlPropreties.imgActionIncompleteStatus = $parent.imgActionIncompleteStatus.value; } // CO-2868: edit_datestring and edit_userstring sometimes are not updated by View Data if(previewFormKey == '' || previewSubmit || isWebAppDataview()){ $('#fvmain_menu .fvSaveLink').trigger('click', undefined); } else{ $('#fvmain_menu .fvSaveLink').trigger('click', [undefined, false, false, undefined, undefined, true, ctrlPropreties.imgActionIncompleteStatus]); } break; case CONST_ACTION_SAVE_AND_SEND: if(!validateFillAndSendEmail()){ // CO-2220: Fill & Send actionClickInfo.start = false; relaseIsRunningFlag(ctrlPropreties); return; } ctrlPropreties.isRunning = true; var ignoreRequiredForward = false; if($parent.ignoreRequiredForward && $parent.ignoreRequiredForward.value){ ignoreRequiredForward = true; } if(isWebAppDataview()){ if(ignoreRequiredForward){ $('#fvmain_menu .fvSaveLink').trigger('click', [ctrlPropreties.classPath, false]); }else{ $('#fvmain_menu .fvSaveLink').trigger('click', [undefined, false]); } } else if(typeof webAppDispatch != 'undefined' && webAppDispatch){ if(tmpStatus == 'Sent'){ if(ignoreRequiredForward){ $('#fvmain_menu .fvSaveLink').trigger('click', ctrlPropreties.classPath); }else{ $('#fvmain_menu .fvSaveLink').trigger('click', undefined); } } else{ if(ignoreRequiredForward){ $('#fvmain_menu .fvSaveAndSend').trigger('click', [ctrlPropreties.classPath, false]); }else{ $('#fvmain_menu .fvSaveAndSend').trigger('click', [undefined, false]); } } } else if(previewFormKey == '' || previewSubmit){ if(ignoreRequiredForward){ $('#fvmain_menu .fvSaveLink').trigger('click', [ctrlPropreties.classPath, false]); }else{ $('#fvmain_menu .fvSaveLink').trigger('click', [undefined, false]); } } break; case CONST_ACTION_LAUNCH_GOOGLE_MAP: switch(ctrlPropreties.outputType){ case CONST_OUT_OMR: callOpenMapOfRoute($parent, ctrlPropreties); break; case CONST_OUT_RS: // CO-4098: Route Summary callRouteMapSummary($parent, ctrlPropreties); break; case CONST_OUT_OMR_N_RS: callOpenMapOfRoute($parent, ctrlPropreties); callRouteMapSummary($parent, ctrlPropreties); break; } break; case CONST_ACTION_LAUNCH_GARMIN_DIRECTIONS: break; case 'Credit Card Payment': // not support break; case CONST_ACTION_FLINT_APP: // not support break; case CONST_ACTION_SEND_AND_CONTINUE: if(!validateFillAndSendEmail()){ // CO-2220: Fill & Send actionClickInfo.start = false; relaseIsRunningFlag(ctrlPropreties); return; } ctrlPropreties.isRunning = true; var ignoreRequiredForward = false; if($parent.ignoreRequiredForward && $parent.ignoreRequiredForward.value){ ignoreRequiredForward = true; } if($parent.imgActionParam_isSendValues && $parent.imgActionParam_isSendValues.value === true){ if($parent.imgActionParam_sendValues && $parent.imgActionParam_sendValues.value && $parent.imgActionParam_sendValues.value.length>0){ var sendValues = []; _.each($parent.imgActionParam_sendValues.value, function(item){ var current_fieldId = item.text.current_field; var new_form_field_path = item.text.new_form_field; var itemProperties = getPropertiesByID(current_fieldId); var current_fieldValue = itemProperties.val; sendValues.push({ path: new_form_field_path, value: current_fieldValue }); }); var formInfo = {sendValues: sendValues, noResult: true}; actionOpenFormStack.push(formInfo); } } if(isWebAppDataview()){ if(ignoreRequiredForward){ $('#fvmain_menu .fvSaveLink').trigger('click', [ctrlPropreties.classPath, true]); }else{ $('#fvmain_menu .fvSaveLink').trigger('click', [undefined, true]); } } else if(typeof webAppDispatch != 'undefined' && webAppDispatch){ if(tmpStatus == 'Sent'){ if(ignoreRequiredForward){ $('#fvmain_menu .fvSaveLink').trigger('click', ctrlPropreties.classPath); }else{ $('#fvmain_menu .fvSaveLink').trigger('click', undefined); } } else{ if(ignoreRequiredForward){ $('#fvmain_menu .fvSaveAndSend').trigger('click', [ctrlPropreties.classPath, true]); }else{ $('#fvmain_menu .fvSaveAndSend').trigger('click', [undefined, true]); } } } else if(previewFormKey == '' || previewSubmit){ if(ignoreRequiredForward){ $('#fvmain_menu .fvSaveLink').trigger('click', [ctrlPropreties.classPath, true]); }else{ $('#fvmain_menu .fvSaveLink').trigger('click', [undefined, true]); } } break; case CONST_ACTION_SAVE_AND_LOAD_FORM: submitAndOpenSelectForm($parent, ctrlPropreties, actionClickInfo, tmpStatus, $(this)); // CO-4591 break; case CONST_ACTION_CLOSE_AND_OPEN_FORM: closeAndOpenSelectForm($parent, $control, ctrlType, ctrlPropreties, $(this)); // CO-4591 break; case CONST_ACTION_OPEN_FORM: if($parent.imgActionParam_OpenForm && getValueOrEmpty($parent.imgActionParam_OpenForm.value) != ''){ if(isTabletPreview){ fvOpenForm($parent.imgActionParam_OpenForm.value, undefined, undefined, false); }else{ ctrlPropreties.isRunning = true; var newProjectLoad = ''; if($parent.imgActionParam_OpenFormProject){ newProjectLoad = getValueOrEmpty($parent.imgActionParam_OpenFormProject.value); } var newFormLoad = getValueOrEmpty($parent.imgActionParam_OpenForm.value); var dontConfirmExit = undefined; var incompleteStatus = undefined; var isSaveAsIncomplete = ''; if($parent.imgActionParam_isSaveAsIncomplete){ isSaveAsIncomplete = getValueOrEmpty($parent.imgActionParam_isSaveAsIncomplete.value); } if(isSaveAsIncomplete !== false){ isSaveAsIncomplete = true; } var actionOpenFormData = {formId: newFormLoad, returnCtrlPath: ctrlPropreties.classPath, prjKey: '', isSaveAsIncomplete: isSaveAsIncomplete, previewProjectKey: fvDataNS.inputData.attrs.projectid, previewFormKey: fvDataNS.inputData.attrs.id}; if($parent.imgActionParam_isSendValues && $parent.imgActionParam_isSendValues.value === true){ if($parent.imgActionParam_sendValues && $parent.imgActionParam_sendValues.value && $parent.imgActionParam_sendValues.value.length>0){ var sendValues = []; _.each($parent.imgActionParam_sendValues.value, function(item){ var current_fieldId = item.text.current_field; var new_form_field_path = item.text.new_form_field; var itemProperties = getPropertiesByID(current_fieldId); var current_fieldValue = itemProperties.val; sendValues.push({ path: new_form_field_path, value: current_fieldValue }); }); actionOpenFormData.sendValues = sendValues; } } if($parent.imgActionParam_isReturnValues && $parent.imgActionParam_isReturnValues.value === true){ if($parent.imgActionParam_returnValues && $parent.imgActionParam_returnValues.value && $parent.imgActionParam_returnValues.value.length>0){ var returnValues = []; _.each($parent.imgActionParam_returnValues.value, function(item){ var current_fieldId = item.text.current_field; var new_form_field_path = item.text.new_form_field; returnValues.push({ current_fieldId: current_fieldId, new_form_field_path: new_form_field_path }); }); actionOpenFormData.returnValues = returnValues; } } var projectList = undefined; if(isWebClient){ projectList = getProjectListOfForm(newFormLoad); }else{ projectList = getProjectListOfFormViewData(newFormLoad); } if(projectList.length <= 0){ alert(msg_error_form_not_permit); }else if(projectList.length == 1){ if(projectList[0].key == newProjectLoad){ actionOpenFormData[CONST_PRJKEY] = projectList[0].key; $('#fvmain_menu .fvSaveContinueLink').trigger('click', [dontConfirmExit, incompleteStatus, actionOpenFormData]); }else{ alert(msg_error_form_not_permit); } }else{ if(newProjectLoad == ''){ showSelectProjectPopupForActionOpenForm(projectList, newFormLoad, $(this), actionOpenFormData); }else{ var hasProjectInList = false; for(var i=0; i 0){ waitForDataLoading(true); var arrRejected = [{ 'id': tmpRecordKey ,'prj': jobItem.attr(CONST_DATA_PRJ) ,'odk': jobItem.attr(CONST_DATA_FRM) }]; rejectDispatchJobItem(arrRejected); } } } catch(e){} if(retrieveReturnTab != undefined && retrieveReturnTab != '') { showTab(retrieveReturnTab); retrieveReturnTab = undefined; return false; } break; } break; case CONST_ACTION_SAVE_AND_EXIT: if($parent.imgActionIncompleteStatus){ ctrlPropreties.imgActionIncompleteStatus = $parent.imgActionIncompleteStatus.value; if(!isWebAppDispatch()){ $('#fvmain_menu .fvSaveContinueLink').trigger('click', [true, ctrlPropreties.imgActionIncompleteStatus]); }else{ $('#fvmain_menu .fvSaveLink ').trigger('click', [undefined, undefined, undefined, true]); } break; } ctrlPropreties.isRunning = true; if(!isWebAppDispatch()){ $('#fvmain_menu .fvSaveContinueLink').trigger('click', [true]); }else{ $('#fvmain_menu .fvSaveLink').trigger('click', [undefined, undefined, undefined, true]); } break; case CONST_ACTION_PRINT: actionPrint(); break; case CONST_ACTION_SAVE_FORM: if(!isWebAppDispatch()){ $('#fvmain_menu .fvSaveContinueLink').trigger('click', [false]); return; }else{ $('#fvmain_menu .fvSaveLink').trigger('click', [undefined, undefined, undefined, false]); } break; case CONST_ACTION_PROPAY: break; case CONST_ACTION_SQUARE: break; case CONST_ACTION_ONCLICK: var desCtrlId = $parent.imgActionParamDesQues.value; var setValue = $parent.imgActionParam.value; var desCtrls = fvDataNS.ctrlIdMap[desCtrlId];//$('.fvCtrlID_' + desCtrlId); if(desCtrls.length == 1){ $('.fvCtrlID_' + desCtrlId).find('textarea').trigger('setLookupValue', setValue); }else{ _.each(desCtrls, function(key, value){ var itemProperty = fvDataNS.dataArray[key]; if(isTheSameParent(ctrlPropreties.parrentProperties, itemProperty.parrentProperties)){ var item = fvDataNS.ctrlArray[key]; item.find('textarea').trigger('setLookupValue', setValue); } }); } break; case CONST_ACTION_INCOMPLETE_STATUS: if($parent.imgActionIncompleteStatus){ ctrlPropreties.imgActionIncompleteStatus = $parent.imgActionIncompleteStatus.value; } if(!isWebAppDispatch()){ $('#fvmain_menu .fvSaveContinueLink').trigger('click', [true, ctrlPropreties.imgActionIncompleteStatus]); }else{ $('#fvmain_menu .fvSaveLink').trigger('click', [undefined, undefined, undefined, true]); } break; case CONST_ACTION_RETRIEVE: if(!data || !data.isModify) { actionRetrieve(ctrlPropreties, $control); if('32' == ctrlPropreties.autoActionStampTriggerModify) { actionModify(ctrlPropreties, $control); } } else { actionModify(ctrlPropreties, $control); } actionButtonClick(ctrlPropreties); break; case CONST_ACTION_OPEN_FILE: if(ctrlPropreties.val != undefined && ctrlPropreties.val.indexOf('http') >= 0){ execOpenFile(ctrlPropreties.val, $parent.name.value); } else if($parent.openFile && $parent.openFile.value && $parent.openFile.value != ''){ execOpenFile($parent.openFile.value, $parent.name.value); } break; case CONST_ACTION_ZEBRA_PRINT: break; case CONST_ACTION_CLOSE_AND_RELOAD: var tmpFormKey = previewFormKey; var tmpProjectKey = previewProjectKey; if(!tmpFormKey) { tmpFormKey = getStoreData("fv_frm_key"); tmpProjectKey = getStoreData("fv_prj_key"); try { // 21029 if(webAppDispatch || webAppDataView || webAppDataViewAddNew){ tmpFormKey = fvDataNS.inputData.attrs.id; tmpProjectKey = fvDataNS.inputData.attrs.projectid; } } catch (e) { } } if(isTabletPreview){ // //fvOpenForm('', undefined); //// var ctrlAct = $('.menu_Preview'); //// showPreview(ctrlAct); //// /preview?id=tablet_preview&fnId=preview_tablet" + //// $.fancybox.update(); } else { fvOpenForm(tmpFormKey, tmpProjectKey, undefined, false); } break; case CONST_ACTION_SET_DESTINATION_FIELDS: actionButtonClick(ctrlPropreties); autostampTrigger(ctrlPropreties, true); break; case CONST_ACTION_SHIPPING_CREATE_LABEL: if(shippoApiKey == undefined || shippoApiKey == ''){ getShippoAccessToken(); } if(shippoApiKey == undefined || shippoApiKey == ''){ var link = getShippoCreateLabelLink(); window.open(link); } waitForDataLoading(true); shippoCreateLabelClick(ctrlPropreties, $control); break; case CONST_ACTION_SHIPPING_GET_RATE: if(shippoApiKey == undefined || shippoApiKey == ''){ getShippoAccessToken(); } if(shippoApiKey == undefined || shippoApiKey == ''){ var link = getShippoGetRateLink(); window.open(link); } waitForDataLoading(true); shippoGetRateClick(ctrlPropreties, $control); break; case CONST_ACTION_AUDIT: waitForDataLoading(true); auditClick(ctrlPropreties, $control, $parent); waitForDataLoading(false); break; case CONST_ACTION_CLOSE_AND_RETRIEVE: closeAndRetrieve($parent, ctrlPropreties); break; case CONST_ACTION_SEND_AND_RETRIEVE: saveSendAndRetrieve($parent, ctrlPropreties, tmpStatus); break; case CONST_ACTION_ATTACH_FORM: executeAttachForm($parent, ctrlPropreties); break; case CONST_ACTION_GET_GEOTAB_DATA: executeGetGeoTabData($parent, ctrlPropreties); break; default: } actionClickInfo.start = false; relaseIsRunningFlag(ctrlPropreties); // CO-4027: Hide button after click if(ctrlPropreties.hideButtonAfterClick){ $control.addClass(CONST_CLASS_HIDE_CONTROL); updateButtonHideAfterClick(ctrlPropreties.classPath); } }); // relevanceconds addToCtrlIdRefForRelevance($parent.isShowRelevanceCondition, $parent.relevanceconds.value, ctrlPropreties.classPath); if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } ctrlPropreties.relevancecondsExpression = relevancecondsToExpression($parent.id, $parent.isShowRelevanceCondition, $parent.relevanceconds); ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); // CO-3852: New Retrieve Setting - Auto Run initRetrieveAutorun($parent, $control, ctrlPropreties); } /*****************************************************************************************************************/ /*End********************************************inputAction******************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************inputPayment******************************************************/ /*****************************************************************************************************************/ var fvEditorsInputPayment = function($parent, $control, ctrlType, ctrlPropreties){ if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } if(!isTabletPreview){ // not support $control.addClass('notSupportControl'); return; } // hintLink if($parent.hintLink.value == undefined || $parent.hintLink.value == ''){ $control.find('.controlInfo .controlImage').addClass(CONST_CLASS_HIDE_CONTROL); }else{ if($parent.hintLink.value.indexOf('/imageViewer?blobKey=') >= 0){ $control.find('.controlInfo img').attr('src', $parent.hintLink.value + "&maxWidth=" + fvDataNS.ctrlWidth); $control.find('.controlInfo img').off('orientationchange').on('orientationchange', function(){ $(this).attr('src', $parent.hintLink.value + "&maxWidth=" + fvDataNS.ctrlWidth); }); }else{ $control.find('.controlInfo img').attr('src', $parent.hintLink.value); if(isTabletPreview && $parent.hintLink.value.indexOf('/img/filib/')>=0){ $control.find('.controlInfo img').css('width', '64px'); }else{ $control.find('.controlInfo img').css('width', CONST_VALUE_INITIAL); } } } // Hide label in case of empty value if(isVersion(VERSION_ACTION_TYPE)){ if($parent.kind && $parent.kind.value == 'Image'){ if ($parent.imageText === undefined || !$parent.imageText.value || $parent.imageText.value === '') { $control.find('.controlLabel').hide(); }else{ // label $control.find('.controlLabel').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.imageText.value))); } }else{ $control.find('.controlLabel').hide(); } }else{ if ($parent.useImage && $parent.useImage.value){ if($parent.label.value.eng === undefined || $parent.label.value.eng === null || $parent.label.value.eng === '') { $control.find('.controlLabel').hide(); }else{ $control.find('.controlLabel').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.label.value.eng))); } }else{ $control.find('.controlLabel').hide(); } } // hint $control.find('.controlHint').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.hint.value.eng))); // Hide hint in case of empty value if ($parent.hint.value.eng === undefined || $parent.hint.value.eng === null || $parent.hint.value.eng === '') { $control.find('.controlHint').hide(); } // button text $control.find('.controlData a').empty().append('

' + ($parent.actionBtnText.value || 'Enter button text') + '

'); if(isVersion(VERSION_ACTION_TYPE)){ if($parent.kind == undefined || $parent.kind.value == undefined){ if($parent.useImage.value){ $control.find('.controlData a').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); }else{ $control.find('.controlData img').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } }else{ if($parent.kind.value == 'Image'){ $control.find('.controlData a').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); }else{ $control.find('.controlData img').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } } }else{ if($parent.useImage.value){ $control.find('.controlData a').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); }else{ $control.find('.controlData img').addClass(CONST_CSS_CLASS_HIDE_SESSION_IMP); } } // imgJustify if($parent.imgJustify.value == undefined || $parent.imgJustify.value == 'Center'){ $control.find('.controlLabel').addClass('controlTextCenter'); $control.find('.controlHint').addClass('controlTextCenter'); $control.find('.controlData').addClass('controlTextCenter'); //$control.find('.controlInfo .controlImage img').addClass('imgJustifyCenter'); }else if($parent.imgJustify.value != undefined && $parent.imgJustify.value == 'Right'){ $control.find('.controlLabel').addClass('controlTextRight'); $control.find('.controlHint').addClass('controlTextRight'); $control.find('.controlData').addClass('controlTextRight'); //$control.find('.controlInfo .controlImage img').addClass('imgJustifyRight'); }else{ $control.find('.controlLabel').addClass('controlTextLeft'); $control.find('.controlHint').addClass('controlTextLeft'); $control.find('.controlData').addClass('controlTextLeft'); //$control.find('.controlInfo .controlImage img').addClass('imgJustifyLeft'); } // relevanceconds addToCtrlIdRefForRelevance($parent.isShowRelevanceCondition, $parent.relevanceconds.value, ctrlPropreties.classPath); if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } ctrlPropreties.relevancecondsExpression = relevancecondsToExpression($parent.id, $parent.isShowRelevanceCondition, $parent.relevanceconds); ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); } /*****************************************************************************************************************/ /*End********************************************inputPayment*****************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************inputSaveAndSend*************************************************/ /*****************************************************************************************************************/ var fvEditorsInputSaveAndSend = function($parent, $control, ctrlType, ctrlPropreties){ if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } // label $control.find('.controlLabel').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.label.value.eng))); // hint $control.find('.controlHint').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.hint.value.eng))); $control.find('.controlData .actionBtn, .lblImageText').click(function(){ if(ctrlPropreties && ctrlPropreties.isRunning){ return; } if(isWebAppDataview()){ ctrlPropreties.isRunning = true; $('#fvmain_menu .fvSaveLink').trigger('click', ctrlPropreties.classPath); } if(isWebAppDispatch()){ var tmpStatus = '';// Sent if(fvDataNS.currentForm.editRecordData != undefined && fvDataNS.currentForm.editRecordData['@Status'] != undefined && fvDataNS.currentForm.editRecordData['@Status'].value != undefined){ tmpStatus = fvDataNS.currentForm.editRecordData['@Status'].value; } ctrlPropreties.isRunning = true; if(tmpStatus == 'Sent'){ $('#fvmain_menu .fvSaveLink').trigger('click', ctrlPropreties.classPath); } else{ $('#fvmain_menu .fvSaveAndSend').trigger('click', ctrlPropreties.classPath); } } else if(previewFormKey == '' || previewSubmit){ ctrlPropreties.isRunning = true; $('#fvmain_menu .fvSaveLink').trigger('click', ctrlPropreties.classPath); } }); // align center $control.find('.controlLabel').addClass('controlTextCenter'); $control.find('.controlHint').addClass('controlTextCenter'); $control.find('.controlData').addClass('controlTextCenter'); // relevanceconds addToCtrlIdRefForRelevance($parent.isShowRelevanceCondition, $parent.relevanceconds.value, ctrlPropreties.classPath); if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } ctrlPropreties.relevancecondsExpression = relevancecondsToExpression($parent.id, $parent.isShowRelevanceCondition, $parent.relevanceconds); ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); } /*****************************************************************************************************************/ /*End********************************************inputSaveAndSend*************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************Group************************************************************/ /*****************************************************************************************************************/ var fvEditorsGroup = function($parent, $control, ctrlType, ctrlPropreties){ if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } if(isVersion(VERSION_REPEAT_ALLOW_DELETE)){ if($parent.isAllowDelete && $parent.isAllowDelete.value == false){ $control.addClass('notAllowDelete'); } } // label $control.find('.controlLabel').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.label.value.eng))); $control.off('checkAndSetRequired').on('checkAndSetRequired', function() { fvAppendRequired($parent, $control.find('.controlLabel')); }); $control.trigger('checkAndSetRequired'); // Variable repeats if($parent.isVariableRepeats && $parent.isVariableRepeats.value){ addToCtrlIdRefForRepeatCountChange($parent.repValSource.value, ctrlPropreties.classPath); } // relevanceconds addToCtrlIdRefForRelevance($parent.isShowRelevanceCondition, $parent.relevanceconds.value, ctrlPropreties.classPath); if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } ctrlPropreties.relevancecondsExpression = relevancecondsToExpression($parent.id, $parent.isShowRelevanceCondition, $parent.relevanceconds); ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); // Apply shading for WebApps in group if (isVersion(VERSION_SHADINGS_AND_BUTTON_TEXT_WEB_APP) && (glbBuildFormSettingsWA.isShadedheadings === true || glbBuildFormSettingsWA.isBorderAroundHeading === true) ) { //$control.find('.groupLoop').addClass('shadingControlBackground4Group'); // PCA-293: Webapp/Preview - Apply new block formats for all widgets. //$control.addClass('shadingControlBackground4Group'); $control.addClass('layoutControlCommonWA4Group'); } // With old form for using SHADING + BORDER, we will apply default shading/color if (glbBuildFormSettingsWA.isNewForm4UsingShading === false) { $control.addClass('oldFormOfUsingShadingAndBorder'); } $control.off('checkAndSetReadOnly').on('checkAndSetReadOnly', function() { if(isReadOnlyApply($parent) || ctrlPropreties.isCtrlReadOnly == true){ $($control).addClass('ctrlReadOnly'); } }); $control.trigger('checkAndSetReadOnly', $parent); } /*****************************************************************************************************************/ /*End********************************************Group************************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************inputEmailReport*************************************************/ /*****************************************************************************************************************/ var fvEditorsInputEmailReport = function($parent, $control, ctrlType, ctrlPropreties){ // defaultValue var defaultValue; var defaultValueMailContent; if(isVersion(VERSION_FAX_WIDGET) && $parent.isFaxWidget && $parent.isFaxWidget.value == true){ ctrlPropreties.isFaxWidget = true; $control.addClass('isFaxWidget'); $control.find('.controlData input').attr('placeholder', ''); $control.find('.controlData .notForFaxWidget').addClass(CONST_CSS_CLASS_HIDE_SESSION); ctrlPropreties.formatKind = undefined; ctrlPropreties.phoneFormatKind = undefined; if($parent.phoneNoFormat && $parent.phoneNoFormat.value){ ctrlPropreties.formatKind = CONST_FORMAT_KIND_PHONE; ctrlPropreties.phoneFormatKind = $parent.phoneFormatKind.value; } } if(ctrlPropreties.val == undefined){ defaultValue = getValueOrEmpty($parent.defaultValue.value); setCtrlPropretiesValue(ctrlPropreties, defaultValue, true); fvEditorsSetDefaultValue(ctrlPropreties); defaultValueMailContent = getValueOrEmpty($parent.defaultValue.mailcontent); setCtrlPropretiesValue(ctrlPropreties, ctrlPropreties.val + "$$" + defaultValueMailContent, true); }else{ var tmp = ('' + ctrlPropreties.val).split("$$"); if(tmp[1] == undefined){ tmp[1] = ''; } defaultValue = tmp[0]; defaultValueMailContent = tmp[1]; } if($parent.isSecureEmail && $parent.isSecureEmail.value){ $control.find('.controlData input').addClass(CONST_CLASS_LOCK); $control.find('.controlData textarea').addClass(CONST_CLASS_LOCK_OPEN); } $control.find('.controlData input') .addClass('inpCtrlID_' + ctrlPropreties.id) .val(defaultValue) .off('setLookupValue').on('setLookupValue', function(event, value, isSearchUndValue){ if(!isControlHiddenByRelevance(ctrlPropreties)){ setLookupValue($(this), ctrlType, $parent, value, isSearchUndValue, $control); } }); $control.find('.controlData textarea') .val(defaultValueMailContent); if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } // label $control.find('.controlLabel').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.label.value.eng))); $control.off('checkAndSetRequired').on('checkAndSetRequired', function() { fvAppendRequired($parent, $control.find('.controlLabel')); }); $control.trigger('checkAndSetRequired'); // hint $control.find('.controlHint').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.hint.value.eng))); // hideInMobile $control.off('checkAndSetHide').on('checkAndSetHide', function() { execShowHideWebAppControl($control, $parent) }); $control.trigger('checkAndSetHide'); // readOnly $control.off('checkAndSetReadOnly').on('checkAndSetReadOnly', function() { if(isReadOnlyApply($parent) || ctrlPropreties.isCtrlReadOnly == true){ $control.find('.controlData input').prop('disabled',"disabled").attr("placeholder", ""); $control.find('.controlData textarea').prop('disabled',"disabled").attr("placeholder", ""); $control.find('.inputinner').addClass('ctrlReadOnly'); $control.find('.textareainner1').addClass('ctrlReadOnly'); }else{ $control.find('.controlData input').prop('disabled', false); if(!ctrlPropreties.isFaxWidget){ $control.find('.controlData input').attr("placeholder", "Email report to..."); } $control.find('.controlData textarea').prop('disabled', false) .attr("placeholder", "Optional message..."); $control.find('.inputinner').removeClass('ctrlReadOnly'); $control.find('.textareainner1').removeClass('ctrlReadOnly'); } }); $control.trigger('checkAndSetReadOnly', $parent); // new { $control.off('clearData').on('clearData', function(event, setDefaultValue){ var $ctrl = $(this).find('.controlData input'); var $ctrlArea = $(this).find('.controlData textarea'); if(setDefaultValue){ $ctrl.val(getValueOrEmpty($parent.defaultValue.value)); $ctrlArea.val(getValueOrEmpty($parent.defaultValue.mailcontent)); }else{ $ctrl.val(''); $ctrlArea.val(''); } setCtrlPropretiesValue(ctrlPropreties, $ctrl.val() + "$$" + $ctrlArea.val()); //$control.trigger('Control_Update') //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); }); $control.off('Control_Update').on('Control_Update', function(event){ event.stopPropagation(); if(fvDataNS.dontCallTrigger) return; calculateDataChange($parent, ctrlPropreties); }); $control.find('.controlData input') .keyup(function(event) { if(!ctrlPropreties.isFaxWidget){ setCtrlPropretiesValue(ctrlPropreties, $(this).val() + "$$" + $control.find('.controlData textarea').val()); fvDataNS.ignoreLostFocus = false; }else{ var ignoreAutoFillFormat = false; if(isPressBackspace(event)) { ignoreAutoFillFormat = true; var isIgnoreBackspace = false; switch(ctrlPropreties.formatKind){ case CONST_FORMAT_KIND_PHONE: break; } if(isIgnoreBackspace){ var selectionStart = this.selectionStart; $(this).val(ctrlPropreties.formatedValue); this.selectionStart = this.selectionEnd = selectionStart+1; event.preventDefault(); return false; } } if($(this).val() == ctrlPropreties.formatedValue){ ignoreAutoFillFormat = true; } processTextKeyUp(this, ctrlPropreties, ctrlPropreties.formatKind, ctrlPropreties.phoneFormatKind, ignoreAutoFillFormat); ctrlPropreties.formatedValue = $(this).val(); fvDataNS.ignoreLostFocus = false; } }) .attr("autocomplete", "off") .on("beforeinput keypress", function(event){ if(!isRunEvent(event)){ return; } if(!ctrlPropreties.isFaxWidget){ ctrlPropreties.controlChange = true; return toNextCtrl(this,event, ctrlPropreties); }else{ var ctrlValue = ctrlPropreties.val; textValidateMaxLength($parent, ctrlValue, $control.find('.controlInfMsg'), event); switch(ctrlPropreties.formatKind){ case CONST_FORMAT_KIND_PHONE: if(!isValidLength(this, event, ctrlPropreties.formatKind, ctrlPropreties.phoneFormatKind)){ return false; }else{ return onlyNumberDigit(this,event); } break; default: return onlyNumberDigit(this,event); } } }) .change(function(event) { if(!fvDataNS.ignoreLostFocus){ if(!ctrlPropreties.isFaxWidget){ setCtrlPropretiesValue(ctrlPropreties, $(this).val() + "$$" + $control.find('.controlData textarea').val()); //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); return; }else{ setCtrlPropretiesValue(ctrlPropreties, $(this).val()); executeControlChange(ctrlPropreties.classPath); return; } }else{ if(!ctrlPropreties.isFaxWidget){ if(ctrlPropreties.val != ($(this).val() + "$$" + $control.find('.controlData textarea').val())){ setCtrlPropretiesValue(ctrlPropreties, $(this).val() + "$$" + $control.find('.controlData textarea').val()); //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); } fvDataNS.ignoreLostFocus = false; }else{ if(ctrlPropreties.val != $(this).val()){ setCtrlPropretiesValue(ctrlPropreties, $(this).val()); executeControlChange(ctrlPropreties.classPath); } fvDataNS.ignoreLostFocus = false; } } }) .blur(function(event) { var ctrlValue = $(this).val(); if(!ctrlPropreties.isFaxWidget){ emailReportValidateError($parent, ctrlValue, $control.find('.controlInfMsg') , ctrlPropreties, $control); } }); $control.find('.controlData textarea') .keyup(function(event) { setCtrlPropretiesValue(ctrlPropreties, $control.find('.controlData input').val() + "$$" + $(this).val()); fvDataNS.ignoreLostFocus = false; }) .attr("autocomplete", "off") .on("beforeinput keypress", function(event){ if(!isRunEvent(event)){ return; } ctrlPropreties.controlChange = true; }) .change(function(event) { setCtrlPropretiesValue(ctrlPropreties, $control.find('.controlData input').val() + "$$" + $(this).val()); }); } if(isVersion(VERSION_EMAIL_REPORT_NEW_DEFAULT) && $parent.defaultValue && $parent.defaultValue.selectedCtrl && $parent.defaultValue.selectedCtrl != ''){ addToCtrlIdRefForInputEmailReport($parent.defaultValue.selectedCtrl, ctrlPropreties.id, ctrlPropreties.classPath); $control.off('Calculate_Data_Change_New').on('Calculate_Data_Change_New', function(event, addToChangeList){ if(fvDataNS.currentForm && fvDataNS.currentForm.editRecordData){ if(fvDataNS.isdispatch == true){ if(ctrlPropreties.calculateExpression == undefined || (ctrlPropreties.calculateExpression['hasNickNameFunction'] != true && ctrlPropreties.calculateExpression['hasMobileIdFunction'] != true && ctrlPropreties.calculateExpression['hasMobileEmailFunction'] != true && ctrlPropreties.calculateExpression['hasWebUserEmailFunction'] != true)){ return; } }else{ return; } } if(ctrlPropreties.controlChange){ ctrlPropreties.controlChange = false; return; } /*if(ctrlPropreties.val != undefined && ctrlPropreties.val != ''){ return; }*/ var ctrlName = fvDataNS.ctrlMap[$parent.defaultValue.selectedCtrl]; var valObj = getControlInputValueNew(ctrlName, ctrlPropreties); var arr = ('' + valObj[CONST_VALUE]).split("$$"); $control.find('.controlData input').val(arr[0]); if(arr.length>1){ $control.find('.controlData textarea').val(arr[1]); }else{ arr[1] = $control.find('.controlData textarea').val(); } setCtrlPropretiesValue(ctrlPropreties, arr[0] + "$$" + arr[1]); if(addToChangeList){ if(fvDataNS.listCtrlChange == undefined){ resetListCtrlChange(); } if(fvDataNS.listCtrlValue == undefined){ resetListCtrlValue(); } if(ctrlPropreties.isValueChange){ setListCtrlDataChange(ctrlPropreties.classPath, true, ctrlPropreties.val); } } }).trigger('Calculate_Data_Change_New'); } /*var addCalculationCtrlClass = function($control, expressions, parentClass, ctrlId){ _.each(expressions.value, function(expression){ if(expression.group != undefined){ var expressionsTmp = {}; expressionsTmp.value = expression.group; addExpressionCtrlClass($control, expressionsTmp, parentClass, ctrlId); }else{ addToCtrlIdRefForInputCalculation(expression, ctrlId, parentClass); } }); } // expression addExpressionCtrlClass($control, $parent.expression, ctrlPropreties.classPath, ctrlPropreties.id);*/ // relevanceconds addToCtrlIdRefForRelevance($parent.isShowRelevanceCondition, $parent.relevanceconds.value, ctrlPropreties.classPath); if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } ctrlPropreties.relevancecondsExpression = relevancecondsToExpression($parent.id, $parent.isShowRelevanceCondition, $parent.relevanceconds); ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); // Apply If .. Then .. Else in WebApps GUI (binding events) processBindingIfThenElseActionEvent($parent, ctrlPropreties); // Remove spacing between email report and contents in case using Shadding & Button Text if (isVersion(VERSION_SHADINGS_AND_BUTTON_TEXT_WEB_APP)) { // if (glbBuildFormSettingsWA.isShadedheadings === true) { // $control.find('.controlInfMsg2').hide(); // } // Always hide the uneeded space // PCA-293: Webapp/Preview - Apply new block formats for all widgets. $control.find('.controlInfMsg2').hide(); // // PCA-178: Web App support for Shading and Spacing (custom options) // var customOptions = getCustomOptionsInObjectWA($parent, true); // // if (customOptions.apperance === LABEL_CONSTANTS_VALUE_OPTION_BUILD_FORM_APPEARANCE_CUSTOM) { // // Using shade headings by Custom Options // if (customOptions.isShadedHeadings === true) { // $control.find('.controlInfMsg2').hide(); // } // } else { // // Using shade headings by FormSettings // if (glbBuildFormSettingsWA.isShadedheadings === true) { // $control.find('.controlInfMsg2').hide(); // } // } } } /*****************************************************************************************************************/ /*End********************************************inputEmailReport*************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************inputCalculate***************************************************/ /*****************************************************************************************************************/ var fvEditorsInputCalculate = function($parent, $control, ctrlType, ctrlPropreties){ // defaultValue var defaultValue; if(ctrlPropreties.val == undefined){ defaultValue = ''; }else{ defaultValue = reformatCalculateValue($parent, ctrlPropreties.val); } if(isVersion(VERSION_CALCULATE_ROUND_DOWN)){ if($parent.round && $parent.round.value == 'Down'){ ctrlPropreties.roundDown = true; } } if(isVersion(VERSION_CALCULATION_KIND_STRING) && $parent.showAsTextMobile){ if($parent.showAsTextMobile.value){ $control.addClass('showAsTextMobile'); if($parent.mobileTextAlign){ switch($parent.mobileTextAlign.value){ case 'Center': $control.find('input').css('text-align', 'center'); break; case 'Right': $control.find('input').css('text-align', 'right'); break; default: } } } } $control.find('.currencyContain').removeClass('currencyContain'); var useCurencySymbol = ''; var usePercent = false; // useCurrentcySymbol if($parent.useCurrentcySymbol.value != undefined && $parent.useCurrentcySymbol.value == true){ if($parent.currency.value != undefined){ useCurencySymbol = $parent.currency.value; } }else if($parent.usePercent && $parent.usePercent.value == true){ usePercent = true; ctrlPropreties.usePercent = true; } formatNumberForDisplay($control.find('.controlData input'), $parent, defaultValue, ctrlPropreties.roundDown); $control.find('.controlData input') .addClass('inpCtrlID_' + ctrlPropreties.id) //.val(formatNumber(defaultValue, useCurencySymbol, CONST_CTRL_TYPE_INPUTCALCULATE, $parent.decPlace?$parent.decPlace.value:undefined, usePercent)) .off('setLookupValue').on('setLookupValue', function(event, value, isSearchUndValue){ if(!isControlHiddenByRelevance(ctrlPropreties)){ setLookupValue($(this), ctrlType, $parent, value, isSearchUndValue, $control); setCalculateDisplayText($control); } }); setCtrlPropretiesValue(ctrlPropreties, getRealNumberValue($control.find('.controlData input'), useCurencySymbol), true); // label $control.find('.controlLabel').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.label.value.eng))); $control.off('checkAndSetRequired').on('checkAndSetRequired', function() { fvAppendRequired($parent, $control.find('.controlLabel')); }); $control.trigger('checkAndSetRequired'); // hint $control.find('.controlHint').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.hint.value.eng))); $control.off('Control_Update').on('Control_Update', function(event){ event.stopPropagation(); if(fvDataNS.dontCallTrigger) return; if(isHidenControl(ctrlPropreties)){ return; } return controlUpdate($parent, ctrlPropreties); }); $control.find('.controlData input') .change(function(event) { $control.find('.controlData .displayText').empty().append($(this).val()); setCtrlPropretiesValue(ctrlPropreties, $(this).val()); //$control.trigger('Control_Update') //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); initLatLngFromAddress(ctrlPropreties); // CO-4372 setCalculateDisplayText($control); }); $control.off('clearData').on('clearData', function(event, setDefaultValue){ //$ctrl.trigger('change'); }); // hideInMobile $control.off('checkAndSetHide').on('checkAndSetHide', function() { execShowHideWebAppControl($control, $parent) }); $control.trigger('checkAndSetHide'); if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } var addExpressionCtrlClass = function($control, expressions, parentClass, ctrlId){ _.each(expressions.value, function(expression){ if(expression.group != undefined){ var expressionsTmp = {}; expressionsTmp.value = expression.group; addExpressionCtrlClass($control, expressionsTmp, parentClass, ctrlId); }else{ addToCtrlIdRefForInputCalculation(expression, ctrlId, parentClass); } }); } // expression addExpressionCtrlClass($control, $parent.expression, ctrlPropreties.classPath, ctrlPropreties.id); // relevanceconds addToCtrlIdRefForRelevance($parent.isShowRelevanceCondition, $parent.relevanceconds.value, ctrlPropreties.classPath); if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } ctrlPropreties.relevancecondsExpression = relevancecondsToExpression($parent.id, $parent.isShowRelevanceCondition, $parent.relevanceconds); ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); ctrlPropreties.skipcondsExpression = skipcondsToExpression($parent.id, $parent.isShowSkipCondition, $parent.skipconds, ctrlType); ctrlPropreties.calculateExpression = calculateObjToExpression($parent.id, $parent.expression, $parent.kind.value); addToRetrieveControlDataChange(ctrlPropreties, $parent); $control.off('Calculate_Data_Change').on('Calculate_Data_Change', function(event, ctrlTrigger, value){ if(fvDataNS.currentForm && fvDataNS.currentForm.editRecordData){ if(fvDataNS.isdispatch == true){ if(ctrlPropreties.calculateExpression == undefined || (ctrlPropreties.calculateExpression['hasNickNameFunction'] != true && ctrlPropreties.calculateExpression['hasMobileIdFunction'] != true && ctrlPropreties.calculateExpression['hasMobileEmailFunction'] != true && ctrlPropreties.calculateExpression['hasWebUserEmailFunction'] != true)){ return; } }else{ return; } } if(isHidenControl(ctrlPropreties)){ return; } if(ctrlPropreties.calculateExpression != undefined && ctrlPropreties.calculateExpression != ''){ var isShowHHMM = $parent.showAsHM?$parent.showAsHM.value:undefined; var isShowHHMMSS = $parent.showAsHMS?$parent.showAsHMS.value:undefined; var decPlace = $parent.decPlace?$parent.decPlace.value:undefined; if(usePercent){ if(decPlace){ decPlace = parseInt(decPlace) + 2; }else{ decPlace = 8; } } var calValue = calculateExpression(ctrlPropreties.calculateExpression, ctrlPropreties, fvDataNS.inputData, isShowHHMM, decPlace, isShowHHMMSS); if(calValue == undefined){ calValue = ''; } if(ctrlPropreties.kind == 'String'){ $control.find('.controlData input').val(calValue); }else{ formatNumberForDisplay($control.find('.controlData input'), $parent, calValue, ctrlPropreties.roundDown); //$control.find('.controlData input').val(formatNumber(calValue, useCurencySymbol, CONST_CTRL_TYPE_INPUTCALCULATE, decPlace, usePercent)); } var disValue = ''; if(ctrlPropreties.kind == 'String'){ disValue = calValue; }else{ disValue = $control.find('.controlData input').val(); if(useCurencySymbol != ''){ disValue = disValue.replace(useCurencySymbol, ''); } if($parent.negativeBrackets.value == true){ disValue = disValue.replace(/[()]/g, ''); } } if(isNaN(calValue)){ setCtrlPropretiesValue(ctrlPropreties, calValue); }else{ setCtrlPropretiesValue(ctrlPropreties, disValue); } //$control.trigger('Control_Update') //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); initLatLngFromAddress(ctrlPropreties); // CO-4372 } setCalculateDisplayText($control); }).trigger('Calculate_Data_Change'); $control.off('Calculate_Data_Change_New').on('Calculate_Data_Change_New', function(event, addToChangeList){ if(fvDataNS.currentForm && fvDataNS.currentForm.editRecordData){ if(fvDataNS.isdispatch == true){ if(ctrlPropreties.calculateExpression == undefined || (ctrlPropreties.calculateExpression['hasNickNameFunction'] != true && ctrlPropreties.calculateExpression['hasMobileIdFunction'] != true && ctrlPropreties.calculateExpression['hasMobileEmailFunction'] != true && ctrlPropreties.calculateExpression['hasWebUserEmailFunction'] != true)){ return; } }else{ return; } } if(isHidenControl(ctrlPropreties)){ return; } if(ctrlPropreties.calculateExpression != undefined && ctrlPropreties.calculateExpression != ''){ var isShowHHMM = $parent.showAsHM?$parent.showAsHM.value:undefined; var isShowHHMMSS = $parent.showAsHMS?$parent.showAsHMS.value:undefined; var decPlace = $parent.decPlace?$parent.decPlace.value:undefined; if(usePercent){ if(decPlace){ decPlace = parseInt(decPlace) + 2; }else{ decPlace = 8; } } var calValue = calculateExpression(ctrlPropreties.calculateExpression, ctrlPropreties, fvDataNS.inputData, isShowHHMM, decPlace, isShowHHMMSS); if(calValue == undefined){ calValue = ''; } if(ctrlPropreties.kind == 'String'){ $control.find('.controlData input').val(calValue); }else{ formatNumberForDisplay($control.find('.controlData input'), $parent, calValue, ctrlPropreties.roundDown); //$control.find('.controlData input').val(formatNumber(calValue, useCurencySymbol, CONST_CTRL_TYPE_INPUTCALCULATE, decPlace, usePercent)); } var disValue = ''; if(ctrlPropreties.kind == 'String'){ disValue = calValue; }else{ disValue = $control.find('.controlData input').val(); if(useCurencySymbol != ''){ disValue = disValue.replace(useCurencySymbol, ''); } if($parent.negativeBrackets.value == true){ disValue = disValue.replace(/[()]/g, ''); } } if(isNaN(calValue)){ if(isShowHHMM){ setCtrlPropretiesValue(ctrlPropreties, calValue); }else{ setCtrlPropretiesValue(ctrlPropreties, disValue); } }else{ setCtrlPropretiesValue(ctrlPropreties, disValue); } if(addToChangeList){ if(fvDataNS.listCtrlChange == undefined){ resetListCtrlChange(); } if(fvDataNS.listCtrlValue == undefined){ resetListCtrlValue(); } if(ctrlPropreties.isValueChange){ setListCtrlDataChange(ctrlPropreties.classPath, true, ctrlPropreties.val); } }else{ //$control.trigger('Control_Update') //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); } initLatLngFromAddress(ctrlPropreties); // CO-4372 } setCalculateDisplayText($control); }); } /*****************************************************************************************************************/ /*End********************************************inputCalculate***************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************ctrlTable********************************************************/ /*****************************************************************************************************************/ var fvEditorsCtrlTable = function($parent, $control, ctrlType, ctrlPropreties){ if(isVersion(VERSION_VERIFY_DUPLICATE) && $parent.isVerifyDuplicate && $parent.isVerifyDuplicate.value == true){ ctrlPropreties.isVerifyDuplicate = true; if($parent.isAllowDuplicate && $parent.isAllowDuplicate.value == true){ ctrlPropreties.isAllowDuplicate = true; } if($parent.duplicateColumnsGroup){ ctrlPropreties.duplicateColumnsGroup = $parent.duplicateColumnsGroup.value; }else{ ctrlPropreties.duplicateColumnsGroup = {}; } } if(!isTabletPreview){ $control.find('.deviceSearchSession').remove(); }else{ $control.addClass(CONST_CLS_IS_TAB_PREVIEW); $control.find('.startScanning').click(function(event){ var isScanningBtn = $(this).hasClass(CONST_CLS_SCANNING); if(isScanningBtn){ $(this).removeClass(CONST_CLS_SCANNING).empty().append(lbl_start_scanning); $($control.find('.controlData')[0]).addClass(CONST_CLS_SCANNED); $control.find('.controlData table').trigger("changeDataSource").trigger("changeTableDataSource"); }else{ $(this).addClass(CONST_CLS_SCANNING).empty().append(lbl_stop_scanning); $control.find('.bluetoothScanningItemCount').addClass(CONST_CLS_SCANNED); } }); } if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } // label var lblDsp = removeUnsupportHTML(getValueOrEmpty($parent.label.value.eng)); if('' == lblDsp && ctrlPropreties.podDataSource != undefined){ // Check for POD case lblDsp = lbl_pod_default_name; } $control.find('.controlLabel').empty().append(lblDsp); $control.off('checkAndSetRequired').on('checkAndSetRequired', function() { fvAppendRequired($parent, $control.find('.controlLabel')); }); $control.trigger('checkAndSetRequired'); if(lblDsp == ''){ $control.find('.controlInfo').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); $control.addClass('no-title'); } // relevanceconds addToCtrlIdRefForRelevance($parent.isShowRelevanceCondition, $parent.relevanceconds.value, ctrlPropreties.classPath); if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } //required rows ctrlPropreties.requiredRows = false; if($parent.requiredRows != undefined && $parent.requiredRows.value != undefined && $parent.requiredRows.value){ $control.addClass('required-rows'); ctrlPropreties.requiredRows = true; if(isVersion(VERSION_TABLE_REQUIRED_ROW_OPTION) && $parent.requiredOptionsGroup && !jQuery.isEmptyObject($parent.requiredOptionsGroup.value)){ ctrlPropreties.requiredOptionsGroup = $parent.requiredOptionsGroup.value; } //alert('use check list'); //addToCtrlIdRefForLookup($parent.lookupConditionFields, ctrlPropreties.classPath); } //automatic add row if(isVersion(VERSION_TABLE_AUTO_ADD_ROW)){ ctrlPropreties.autoAddNewRow = false; if($parent.autoAddNewRow != undefined && $parent.autoAddNewRow.value == true){ ctrlPropreties.autoAddNewRow = true; if($parent.loop != undefined && $parent.loop.value){ ctrlPropreties.defaultRows = $parent.loop.value; } $control.addClass('auto-add-new-row'); // CO-4565 var maxLoop = ''; if($parent.maxLoop != undefined && $parent.maxLoop.value != undefined && true == $parent.maxLoop.value.useMaxLoop){ maxLoop = $parent.maxLoop.value.val; } if(maxLoop == ''){ maxLoop = '0'; } ctrlPropreties.maxLoop = maxLoop; } } //use checklist if($parent.usechecklist != undefined && $parent.usechecklist.value != undefined && $parent.usechecklist.value){ //alert('use check list'); //addToCtrlIdRefForLookup($parent.lookupConditionFields, ctrlPropreties.classPath); }else{ // Variable repeats if($parent.isVariableNumberRow && $parent.isVariableNumberRow.value){ if($parent.rowValSource != undefined){ addToCtrlIdRefForTableCountChange($parent.rowValSource.value, ctrlPropreties.classPath); } } } //Equally Space Columns /*if($parent.equallySpaceColumns != undefined && $parent.equallySpaceColumns.value != undefined && $parent.equallySpaceColumns.value){ $control.find('.controlData').addClass("equallySpaceColumns"); }else{ $control.find('.controlData').addClass("noEquallySpaceColumns"); }*/ var isEquallySpaceColumns = false; if(!isVersion(VERSION_GRID_TYPE_FUNCTION)){ if($parent.equallySpaceColumns != undefined){ isEquallySpaceColumns = $parent.equallySpaceColumns.value; } }else{ if($parent.columnsSpaceType && $parent.columnsSpaceType.value == '0'){ isEquallySpaceColumns = true; } } if(isEquallySpaceColumns){ $control.find('.controlData').addClass("equallySpaceColumns"); }else{ $control.find('.controlData').addClass("noEquallySpaceColumns"); } //Fit to screen width if($parent.isUtilizingFullScr != undefined && $parent.isUtilizingFullScr.value){ $control.find('.controlData').addClass("fitToWidth"); } ctrlPropreties.relevancecondsExpression = relevancecondsToExpression($parent.id, $parent.isShowRelevanceCondition, $parent.relevanceconds); ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); if(isVersion(VERSION_CHECKLIST_CONDITION) && $parent.usechecklist != undefined && $parent.usechecklist.value != undefined && $parent.usechecklist.value){ ctrlPropreties.checklistCondsExpression = checklistCondsToExpression($parent.checklistconds, $parent.isShowAllWhenFilterQuesBlank); addToCtrlIdRefForChecklist($parent.checklistconds.value, ctrlPropreties.classPath); } // Fix bug 0015494: Can move 'Calendar' dialog when the mouse rolls // => We will hide Calendar when mouse scrolls on .ctrlOverFlowY $control.find('.ctrlOverFlowY').off('scroll').scroll(function() { processAutohideCalendarWhenScrollViewWA(); }); // With old form for using SHADING + BORDER, we will apply default shading/color if (glbBuildFormSettingsWA.isNewForm4UsingShading === false) { $control.addClass('oldFormOfUsingShadingAndBorder'); } // Apply []Remove border around answer if (isVersion(VERSION_REMOVE_ANSW_BORDER)) { $control.addClass('removeBorderAroundVersion'); } if(isVersion(VERSION_TABLE_TEXT_SIZE) && $parent.textSize != undefined){ var fontSize = 'font_' + $parent.textSize.value; $control.addClass(fontSize); } if(isVersion(VERSION_PORTAL_SHADING)){ if($parent.apperance && $parent.apperance.value == 'Custom'){ if($parent.shadedRow && $parent.shadedRow.value && $parent.shadedRow.value.isShadedRow){ $control.addClass('useShadedRowColumn'); } }else{ if(glbBuildFormSettingsWA && glbBuildFormSettingsWA.isShadedRow){ $control.addClass('useShadedRowColumn'); } } } } /*****************************************************************************************************************/ /*End********************************************ctrlTable********************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************ctrlScoreTable***************************************************/ /*****************************************************************************************************************/ var fvEditorsCtrlScoreTable = function($parent, $control, ctrlType, ctrlPropreties){ if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } // label var lblDsp = removeUnsupportHTML(getValueOrEmpty($parent.label.value.eng)); $control.find('.controlLabel').empty().append(lblDsp); $control.off('checkAndSetRequired').on('checkAndSetRequired', function() { fvAppendRequired($parent, $control.find('.controlLabel')); }); $control.trigger('checkAndSetRequired'); if(lblDsp == ''){ $control.find('.controlInfo').css(CONST_CSS_KEY_DISPLAY, CONST_VALUE_NONE); $control.addClass('no-title'); } // relevanceconds addToCtrlIdRefForRelevance($parent.isShowRelevanceCondition, $parent.relevanceconds.value, ctrlPropreties.classPath); if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } //Equally Space Columns /*if($parent.equallySpaceColumns != undefined && $parent.equallySpaceColumns.value != undefined && $parent.equallySpaceColumns.value){ $control.find('.controlData').addClass("equallySpaceColumns"); }else{ $control.find('.controlData').addClass("noEquallySpaceColumns"); }*/ var isEquallySpaceColumns = false; if(!isVersion(VERSION_GRID_TYPE_FUNCTION)){ if($parent.equallySpaceColumns != undefined){ isEquallySpaceColumns = $parent.equallySpaceColumns.value; } }else{ if($parent.columnsSpaceType && $parent.columnsSpaceType.value == '0'){ isEquallySpaceColumns = true; } } if(isEquallySpaceColumns){ $control.find('.controlData').addClass("equallySpaceColumns"); }else{ $control.find('.controlData').addClass("noEquallySpaceColumns"); } //Fit to screen width if($parent.isUtilizingFullScr != undefined && $parent.isUtilizingFullScr.value){ $control.find('.controlData').addClass("fitToWidth"); } // With old form for using SHADING + BORDER, we will apply default shading/color if (glbBuildFormSettingsWA.isNewForm4UsingShading === false) { $control.addClass('oldFormOfUsingShadingAndBorder'); } ctrlPropreties.relevancecondsExpression = relevancecondsToExpression($parent.id, $parent.isShowRelevanceCondition, $parent.relevanceconds); ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); } /*****************************************************************************************************************/ /*End********************************************ctrlScoreTable***************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************inputLookup******************************************************/ /*****************************************************************************************************************/ var fvEditorsInputLookup = function($parent, $control, ctrlType, ctrlPropreties){ processLookupProperty($parent, ctrlPropreties, $control); // defaultValue var defaultValue; if(ctrlPropreties.val == undefined){ defaultValue = getValueOrEmpty($parent.defaultValue.value); setCtrlPropretiesValue(ctrlPropreties, defaultValue, false); fvEditorsSetDefaultValue(ctrlPropreties); if(valueOrEmpty(ctrlPropreties.val) == ''){ $control.removeClass('hasData'); $control.find('.ico_lookup_erase').addClass(CONST_CSS_CLASS_HIDE_SESSION); if(isTabletPreview){ if(($parent.kbIconPortrait && $parent.kbIconPortrait.value) || ($parent.kbIconLanscape && $parent.kbIconLanscape.value)){ $control.find('.ico_lookup_keyboard').removeClass(CONST_CSS_CLASS_HIDE_SESSION); $control.addClass('hasKBIcon'); } } }else{ $control.addClass('hasData'); $control.find('.ico_lookup_erase').removeClass(CONST_CSS_CLASS_HIDE_SESSION); $control.find('.ico_lookup_keyboard').addClass(CONST_CSS_CLASS_HIDE_SESSION); $control.removeClass('hasKBIcon'); } }else{ defaultValue = ctrlPropreties.val; if(defaultValue == ''){ $control.removeClass('hasData'); $control.find('.ico_lookup_erase').addClass(CONST_CSS_CLASS_HIDE_SESSION); }else{ $control.addClass('hasData'); } } if($parent.sortType && $parent.sortType.value == 'desc'){ ctrlPropreties.sortType = 'desc'; }else{ ctrlPropreties.sortType = 'asc'; } if(isVersion(VERSION_CHOOSE_ONE_LU_FIELD)){ if($parent.isChooseOneField && $parent.isChooseOneField.value){ ctrlPropreties.isChooseOneField = true; } } $control.find('.controlData textarea') .addClass('inpCtrlID_' + ctrlPropreties.id) .val(defaultValue) .off('setLookupValue').on('setLookupValue', function(event, value, isSearchUndValue){ if(!isControlHiddenByRelevance(ctrlPropreties)){ setLookupValue($(this), ctrlType, $parent, value, isSearchUndValue, $control); } }); if(ctrlPropreties.length && ctrlPropreties.length.max && ctrlPropreties.length.cannotExceedMaximum){ $control.find('.controlData textarea').attr('maxlength',ctrlPropreties.length.max); } if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } // label $control.find('.controlLabel').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.label.value.eng))); $control.off('checkAndSetRequired').on('checkAndSetRequired', function() { fvAppendRequired($parent, $control.find('.controlLabel')); }); $control.trigger('checkAndSetRequired'); // hint $control.find('.controlHint').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.hint.value.eng))); // hideInMobile $control.off('checkAndSetHide').on('checkAndSetHide', function() { execShowHideWebAppControl($control, $parent) }); $control.trigger('checkAndSetHide'); //if(isTabletPreview){ $control.addClass('cls4PreviewOnly'); if($parent.dispMobile && $parent.dispMobile.value){ $control.addClass('show-barcode-icon'); } if($parent.dispNFCBtn && $parent.dispNFCBtn.value){ $control.addClass('show-nfc-icon'); } //} // readOnly $control.off('checkAndSetReadOnly').on('checkAndSetReadOnly', function() { if(isReadOnlyApply($parent) || ctrlPropreties.isCtrlReadOnly == true){ $control.find('.controlData textarea').prop('disabled', true); $control.find('.inputinner').addClass('ctrlReadOnly'); $control.find('.ico_lookup_erase').addClass('ctrlReadOnly'); $control.find('.ico_lookup_keyboard').addClass('ctrlReadOnly'); } else { $control.find('.controlData textarea').prop('disabled', false); $control.find('.inputinner').removeClass('ctrlReadOnly'); } }); $control.trigger('checkAndSetReadOnly', $parent); var luMaxRows = DEFAULT_LU_MAX_ROWS; try{ luMaxRows = parseInt($parent.maxRows.value); if(isNaN(luMaxRows)){ luMaxRows = DEFAULT_LU_MAX_ROWS; } }catch(e){ luMaxRows = DEFAULT_LU_MAX_ROWS; } var lkConditionalParam = []; // check isUseDispOnly var luTableKey = $parent.datasource.value; var lkFieldInd = parseInt($parent.lookupfield.value.replace('col', ''), 10) - 1; ctrlPropreties.lookupfield = $parent.lookupfield; //$control.off('checkAndSetRestrict').on('checkAndSetRestrict', function() { if(skipLKData($parent)){ $control.find('.ico_lookup').removeClass('ico_lookup'); $control.find('.ico_lookup_keyboard').remove(); if($parent.limitToList && $parent.limitToList.value == true){ $control.find('.ico_lookup_erase').removeClass('ico_lookup_erase'); $control.find('.controlData textarea').prop('disabled', true); $control.find('.inputinner').addClass('ctrlReadOnly'); } } else { if($parent.lookupConditionFields != undefined && $parent.lookupConditionFields.value != undefined && $parent.lookupConditionFields.value.length > 0){ var donotMakeLKConditionalParam = false; if(!fvDataNS.lkConditionalParamcache){ fvDataNS.lkConditionalParamcache = {}; }else if(fvDataNS.lkConditionalParamcache[$parent.id.value]){ lkConditionalParam = fvDataNS.lkConditionalParamcache[$parent.id.value]; donotMakeLKConditionalParam = true; } for(var i=0; i<$parent.lookupConditionFields.value.length; i++){ var item = $parent.lookupConditionFields.value[i]; if(!donotMakeLKConditionalParam){ var indexStr = ''; if(item.text.valCond == undefined){ var controlName = fvDataNS.ctrlMap[item.text.val]; if(controlName == undefined){ continue; } var parrentProperties = fvDataNS.dataArray[ctrlPropreties.parrentProperties]; var controlsProperties = getCtrlPropertyInRoot(controlName, parrentProperties); indexStr = controlsProperties.lookupfield.value.replace("col", ""); }else{ indexStr = item.text.valCond.replace("col", ""); } var index = parseInt(indexStr); index = index - 1; var condFieldName = "Column_" + index; var condCtrl = undefined; var condValue = ''; var condItem = undefined; var condOperator = CONST_VALUE_EQUAL; if(item.condOperator && item.condOperator.val){ condOperator = item.condOperator.val; } var condType = ' && '; if(item.condType && item.condType.val){ switch(item.condType.val){ case CONST_VALUE_OR_LOWERCASE: condType = ' || '; break; default: condType = ' && '; } } var condCompareType = CONST_STRING_LOWERCASE; if(item.condCompareType && item.condCompareType.val){ condCompareType = item.condCompareType.val; } switch(condOperator){ case CONST_VALUE_IS_EMPTY: case CONST_VALUE_NOT_IS_EMPTY: condItem = { condValue:condValue, condField:condFieldName, condOperator:condOperator, condType:condType, condCompareType: condCompareType } lkConditionalParam.push(condItem); continue; } if((!item.condAnswerType || item.condAnswerType.val == CONST_VALUE_OTHER) && (item.text.val && '0' != item.text.val)){ condCtrl = fvDataNS.ctrlMap[item.text.val]; if(condCtrl == undefined){ continue; } }else{ if(item.otherAnswerLUField){ condValue = item.otherAnswerLUField.val; }else{ condValue = ''; } } if(condCtrl != undefined){ condItem = { condCtrl:condCtrl, condField:condFieldName, condOperator:condOperator, condType:condType, condCompareType: condCompareType } }else{ condItem = { condValue:condValue, condField:condFieldName, condOperator:condOperator, condType:condType, condCompareType: condCompareType } } if(item.text.usingUnderlyValue != undefined){ condItem['usingUnderlyValue'] = item.text.usingUnderlyValue; } lkConditionalParam.push(condItem); } $control.find('.controlData textarea').addClass("lkCondCtrlID_" + item.text.val); } if(!donotMakeLKConditionalParam){ if(lkConditionalParam.length > 0){ lkConditionalParam[0]['&id'] = $parent.id.value; } fvDataNS.lkConditionalParamcache[$parent.id.value] = lkConditionalParam; } addToCtrlIdRefForLookup($parent.lookupConditionFields, ctrlPropreties.classPath); } loadLookupData(luTableKey, lkFieldInd, lkConditionalParam, $parent.name.value); } //}); //$control.trigger('checkAndSetRestrict'); $control.find('.ico_lookup_erase').click(function(){ clearLuCondition($control, $parent); $control.trigger('clearData', [undefined, true]); }); $control.off('clearData').on('clearData', function(event, setDefaultValue, isSetFocus){ var $ctrl = $(this).find('.controlData textarea'); $control.find('.ico_lookup_erase').addClass(CONST_CSS_CLASS_HIDE_SESSION); if(isTabletPreview){ if(($parent.kbIconPortrait && $parent.kbIconPortrait.value) || ($parent.kbIconLanscape && $parent.kbIconLanscape.value)){ $control.find('.ico_lookup_keyboard').removeClass(CONST_CSS_CLASS_HIDE_SESSION); $control.addClass('hasKBIcon'); } } if(setDefaultValue){ $ctrl.val(getValueOrEmpty($parent.defaultValue.value)); }else{ $ctrl.val(''); } setCtrlPropretiesValue(ctrlPropreties, $ctrl.val()); $control.removeClass('hasData'); $control.find('.controlData textarea').change(); if(isSetFocus){ setTimeout(function() { $control.find('.controlData textarea').trigger('click'); }, 250); } }); $control.off('Control_Update').on('Control_Update', function(event){ event.stopPropagation(); if(fvDataNS.dontCallTrigger) return; controlUpdate($parent, ctrlPropreties); }); $control.find('.controlData textarea') /*.focus(function(event){ if(isTabletPreview && !fvDataNS.hasShowLUTruncatWarning){ fvDataNS.hasShowLUTruncatWarning = true; alert(msg_lookup_limit_warning); } })*/ .keyup(function(event) { setCtrlPropretiesValue(ctrlPropreties, $(this).val()); if($(this).val() == ''){ $control.removeClass('hasData'); $control.find('.ico_lookup_erase').addClass(CONST_CSS_CLASS_HIDE_SESSION); if(isTabletPreview){ if(($parent.kbIconPortrait && $parent.kbIconPortrait.value) || ($parent.kbIconLanscape && $parent.kbIconLanscape.value)){ $control.find('.ico_lookup_keyboard').removeClass(CONST_CSS_CLASS_HIDE_SESSION); $control.addClass('hasKBIcon'); } } }else{ $control.addClass('hasData'); $control.find('.ico_lookup_erase').removeClass(CONST_CSS_CLASS_HIDE_SESSION); $control.find('.ico_lookup_keyboard').addClass(CONST_CSS_CLASS_HIDE_SESSION); $control.removeClass('hasKBIcon'); } var ctrlValue = ctrlPropreties.val; if(textValidateMaxLength($parent, ctrlValue, $control.find('.controlInfMsg'), event)) { return; } fvDataNS.ignoreLostFocus = false; /*if(!skipLKData($parent)){ $(this).change(); }*/ if(event.keyCode == 13){ var ctrlValue = ctrlPropreties.val; lookupValidateError(ctrlPropreties, $parent, ctrlValue , $control.find('.controlInfMsg'), $control); return toNextCtrl(this,event, ctrlPropreties); } }) .attr("autocomplete", "off") .on("beforeinput keypress", function(event){ if(!isRunEvent(event)){ return; } if(event.ctrlKey == true && (event.charCode == 118 || event.charCode == 99 || event.charCode == 120)){ return; } /*if($parent.kind != undefined && $parent.kind.value == 'Number'){ //return onlyIntegerNumber(this,event, INTEGER_MAXLENGTH); return onlyNumber(this); }else{ return toNextCtrl(this,event, ctrlPropreties); }*/ var ctrlValue = ctrlPropreties.val; if(textValidateMaxLength($parent, ctrlValue, $control.find('.controlInfMsg'), event)) { return; } return toNextCtrl(this,event, ctrlPropreties); }) //.on("cut copy paste",function(e) { .off("drop").on("drop",function(e) { // disable paste function if kind is number if($parent.kind != undefined && $parent.kind.value == 'Number'){ e.preventDefault(); } }) .on('textarea propertychange', function(e) { if($parent.kind != undefined && $parent.kind.value == 'Number'){ onlyNumber_Propertychange($(this), ctrlPropreties, 'Integer', INTEGER_MAXLENGTH); } }) .off('onchange') .result(function(event) { ctrlPropreties.autoAction = false; fvDataNS.dontCallBlur = true; fvDataNS.ignoreLostFocus = false; ctrlPropreties.dataChangedByUser = true; $(this).trigger('change'); }) .change(function(event, notFillEmpty) { if($control.find('.ac_results_lu_active li').hasClass('ac_over')){ return; } resizeTextarea(this, false); $(this).trigger('luDataChange', notFillEmpty); }) .on('luDataChange', function(event, notFillEmpty) { if(ctrlPropreties.isIgnoreResetData == true){ ctrlPropreties.isIgnoreResetData = false; return; } if(skipLKData($parent)){ setCtrlPropretiesValue(ctrlPropreties, $(this).val()); return; } if(event.cancelable !== undefined){ setCtrlPropretiesValue(ctrlPropreties, $(this).val()); if($(this).val() == ''){ $control.removeClass('hasData'); $control.find('.ico_lookup_erase').addClass(CONST_CSS_CLASS_HIDE_SESSION); if(isTabletPreview){ if(($parent.kbIconPortrait && $parent.kbIconPortrait.value) || ($parent.kbIconLanscape && $parent.kbIconLanscape.value)){ $control.find('.ico_lookup_keyboard').removeClass(CONST_CSS_CLASS_HIDE_SESSION); $control.addClass('hasKBIcon'); } } }else{ $control.addClass('hasData'); $control.find('.ico_lookup_erase').removeClass(CONST_CSS_CLASS_HIDE_SESSION); $control.find('.ico_lookup_keyboard').addClass(CONST_CSS_CLASS_HIDE_SESSION); $control.removeClass('hasKBIcon'); } if(jQuery.trim(ctrlPropreties.val) == '' && !ctrlPropreties.isCtrlHidden && ctrlPropreties.val != ''){ var ctrlPropreties_UseInEachFunction = ctrlPropreties; jQuery.each( $parent.destinationdataconds.value, function() { var ctrlId = this.text.val; var parentsGroupOfLu = ctrlPropreties_UseInEachFunction.classPath.split(' '); var parentGroupClassName = ''; for(var i=0; i/g,'
'); destinationValue = destinationValue.replace(/
/g,'\r\n'); var tmpEmail = destinationValue; // check isSearchUndValue var isSearchUndValue = false; if($parent.isSearchUndValue != undefined && $parent.isSearchUndValue.value == true){ isSearchUndValue = true; } destinationValue = getDestinationValue(destinationValue, isSearchUndValue); if(ctrlId.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ setUserVariableValue(ctrlId, destinationValue); }else{ if(maxRow > 1){ var ctrlTmp = $('.fvMainWrapper .fvCtrlID_' + ctrlId); var ctrlPropretiesTmp = $(ctrlTmp[ind]).data('odkControl-ctrlPropreties'); if(ctrlPropretiesTmp && ctrlPropretiesTmp.parentKind == 'table'){ table = ctrlPropretiesTmp.parentName; if(maxRows[table] == null){ maxRows[table] = 0; } if(maxRows[table]0){ var destinationCtrl = $('.fvMainWrapper ' + parentGroupClassName + ' tr.row_' + ind + ' .inpCtrlID_' + ctrlId); if(destinationCtrl.length == 0){ destinationNotFound = true; }else{ destinationCtrl.trigger('setLookupValue', [destinationValue, isSearchUndValue]); } }else{ var destinationCtrl = $('.fvMainWrapper ' + parentGroupClassName + ' .inpCtrlID_' + ctrlId); if(destinationCtrl.length == 0){ destinationNotFound = true; }else{ destinationCtrl.trigger('setLookupValue', [destinationValue, isSearchUndValue]); } } }else{ var destinationCtrl = $($('.fvMainWrapper ' + parentGroupClassName + ' .inpCtrlID_' + ctrlId)[ind]); if(destinationCtrl.length == 0){ destinationNotFound = true; }else{ destinationCtrl.trigger('setLookupValue', [destinationValue, isSearchUndValue]); } } } }else{ var ctrlTmp = $('.fvMainWrapper .fvCtrlID_' + ctrlId); if(ctrlTmp.hasClass(CONST_CTRL_TYPE_INPUTEMAILREPORT)){ var destinationCtrls = $('.fvMainWrapper ' + parentGroupClassName + ' .inpCtrlID_' + ctrlId); if(destinationCtrls.length == 0){ destinationNotFound = true; }else{ jQuery.each( destinationCtrls, function() { var destinationCtrl = $(this); destinationCtrl.trigger('setLookupValue', [tmpEmail, isSearchUndValue]); }); } }else{ var destinationCtrls = $('.fvMainWrapper ' + parentGroupClassName + ' .inpCtrlID_' + ctrlId); if(destinationCtrls.length == 0){ destinationNotFound = true; }else{ jQuery.each( destinationCtrls, function() { var destinationCtrl = $(this); destinationCtrl.trigger('setLookupValue', [destinationValue, isSearchUndValue]); }); } } } } } } }); if(destinationNotFound){ ctrlPropreties.destinationNotFound = true; } //GTodo if(ctrlPropreties.trackAsRelatedRecord) { ctrlPropreties.lookupRecordKeyVal = fetchingData['recordkey']; } var isOddRow = true; for(var i=0; i 0){ ctrlParent = $(this).parents('.fvPageDetail')[0]; }else{ ctrlParent = $('.fvWorkspaceScrollArea .fvWorkspace'); } // CO-2741 var firstMattching = validateLKFirstMatching($parent); var disableFlg = validateLKDisabled($parent, firstMattching, this.disabled); if(isReadOnlyApply($parent) || true == disableFlg){ $(this).prop('disabled', true); var ctrlParent = $(this).parent(); ctrlParent.addClass('ctrlReadOnly'); ctrlParent.parent().find('.ico_lookup_erase').addClass('ctrlReadOnly'); ctrlParent.parent().find('.ico_lookup_keyboard').addClass('ctrlReadOnly'); } else { $(this).prop('disabled', false); var ctrlParent = $(this).parent(); ctrlParent.removeClass('ctrlReadOnly'); ctrlParent.parent().find('.ico_lookup_erase').removeClass('ctrlReadOnly'); ctrlParent.parent().find('.ico_lookup_keyboard').removeClass('ctrlReadOnly'); } if(disableFlg){ $(this) .unbind(".autocomplete_lk") .autocomplete_lk(autoCompleteArray[$parent.name.value], { showInObject: ctrlParent, resultsClass: resultsClass, delay:10, minChars:0, matchContains: $parent.isSearchWildCard.value, onItemSelect:selectItem, onFindValue:findValue, autoFill:true, maxItemsToShow:5, showWhenFocus:1, max: luMaxRows, scrollHeight: 200 }) .flushCache(); }else{ $(this) .unbind(".autocomplete_lk") .autocomplete_lk(autoCompleteArray[$parent.name.value], { showInObject: ctrlParent, resultsClass: resultsClass, delay:10, minChars:0, matchContains: $parent.isSearchWildCard.value, onItemSelect:selectItem, onFindValue:findValue, autoFill:true, maxItemsToShow:5, showWhenFocus:1, max: luMaxRows, scrollHeight: 200 }) .flushCache() .simulate("keydown", { keyCode: $.simulate.VK_DOWN }); } if(!ctrlInHiddenPage(ctrlPropreties)){ fvDataNS.autocompleteBinded[ctrlPropreties.classPath] = true; } var validateLKData = true; var isLoadding = isEditLoading(); var notHasData = (autoCompleteArray[$parent.name.value].indexOf($(this).val()) < 0); if(((!isLoadding && isReset && notHasData && ctrlPropreties.val != '') || (!isLoadding && notHasData && firstMattching)) && !ctrlPropreties.isCtrlHidden){ if(notHasData && ctrlPropreties.isIgnoreResetData == true && $parent.limitToList && $parent.limitToList.value === false){ // CO-5378: Data lookup does not populate destination if(firstMattching != true && !fvDataNS.currentForm.retrieveControlDataChange){ //CO-5914: Lookup Conditions Limit to List Issue if(!isOpenNewForm()){ return; } } } ctrlPropreties.isIgnoreResetData = false; if(firstMattching == true){ validateLKData = false; setFirstMatching($(this), $parent, autoCompleteArray); }else{ if(isOpenNewForm() || isEvaluateEditRetrieveForward($parent)){ $(this).val('', false).change(); var ctrlPropreties_UseInEachFunction = ctrlPropreties; jQuery.each( $parent.destinationdataconds.value, function() { var ctrlId = this.text.val; var parentsGroupOfLu = ctrlPropreties_UseInEachFunction.classPath.split(' '); var parentGroupClassName = ''; for(var i=0; i 0){ while(ctrlPropreties.relevanceRetrieve.length > 0) { //relevanceRetrieve.splice(0, 1) = get item 0 and remove it from relevanceRetrieve var triggetCtrl = fvDataNS.ctrlArray[ctrlPropreties.relevanceRetrieve.splice(0, 1)[0]]; $(triggetCtrl.find('.controlData .actionBtn')[0]).trigger('click'); } } } catch(e){} }, 250); }) if($parent.kind != undefined && $parent.kind.value == 'Number'){ onlyNumber($control.find('.controlData textarea')); } $control.off('checkAndSetRestrict').on('checkAndSetRestrict', function() { if(skipLKData($parent)) { $(this).find('.controlData textarea').flushCache().off('autocomplete_lk').flushCache(); if($parent.limitToList && $parent.limitToList.value == true){ $control.find('.ico_lookup_erase').removeClass('ico_lookup_erase'); $control.find('.controlData textarea').prop('disabled', true); $control.find('.inputinner').addClass('ctrlReadOnly'); } } else { $(this).find('.controlData input, .controlData textarea').trigger('changeDataSource'); } }); // relevanceconds addToCtrlIdRefForRelevance($parent.isShowRelevanceCondition, $parent.relevanceconds.value, ctrlPropreties.classPath); if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } ctrlPropreties.relevancecondsExpression = relevancecondsToExpression($parent.id, $parent.isShowRelevanceCondition, $parent.relevanceconds); ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); ctrlPropreties.skipcondsExpression = skipcondsToExpression($parent.id, $parent.isShowSkipCondition, $parent.skipconds, ctrlType); // Apply If .. Then .. Else in WebApps GUI (binding events) processBindingIfThenElseActionEvent($parent, ctrlPropreties); // Apply Skip If in WebApps GUI (binding events) processBindingSkipIfActionEvent($parent, ctrlPropreties); } /*****************************************************************************************************************/ /*End********************************************inputLookup******************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************inputLFBluetooth*************************************************/ /*****************************************************************************************************************/ var fvEditorsInputLFBluetooth = function($parent, $control, ctrlType, ctrlPropreties){ fvEditorsInputLookup($parent, $control, ctrlType, ctrlPropreties); if(!isTabletPreview){ $control.find('.deviceSearchSession').remove(); }else{ $control.addClass(CONST_CLS_IS_TAB_PREVIEW); $control.find('.startScanning').click(function(event){ $(this).addClass(CONST_CLS_JUST_CLICK); var isScanningBtn = $(this).hasClass(CONST_CLS_SCANNING); if(isScanningBtn){ $(this).removeClass(CONST_CLS_SCANNING).empty().append(lbl_start_scanning); $control.find('.ctrlHref').addClass(CONST_CLS_SCANNED); }else{ $(this).addClass(CONST_CLS_SCANNING).empty().append(lbl_stop_scanning); $control.find('.bluetoothScanningItemCount').addClass(CONST_CLS_SCANNED); } }); } } /*****************************************************************************************************************/ /*End********************************************inputLFBluetooth*************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************inputFacingTable*************************************************/ /*****************************************************************************************************************/ var fvEditorsInputFacingTable = function($parent, $control, ctrlType, ctrlPropreties){ // defaultValue var defaultValue; if(ctrlPropreties.val == undefined){ defaultValue = getValueOrEmpty($parent.defaultValue.value); setCtrlPropretiesValue(ctrlPropreties, defaultValue, true); fvEditorsSetDefaultValue(ctrlPropreties); }else{ defaultValue = ctrlPropreties.val; } $control.find('.controlData input') .addClass('inpCtrlID_' + ctrlPropreties.id) .val(defaultValue) .off('setLookupValue').on('setLookupValue', function(event, value, isSearchUndValue){ if(!isControlHiddenByRelevance(ctrlPropreties)){ setLookupValue($(this), ctrlType, $parent, value, isSearchUndValue, $control); } }); if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } // label $control.find('.controlLabel').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.label.value.eng))); $control.off('checkAndSetRequired').on('checkAndSetRequired', function() { fvAppendRequired($parent, $control.find('.controlLabel')); }); $control.trigger('checkAndSetRequired'); // hint $control.find('.controlHint').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.hint.value.eng))); var luMaxRows = DEFAULT_LU_MAX_ROWS; try{ luMaxRows = parseInt($parent.maxRows.value); if(isNaN(luMaxRows)){ luMaxRows = DEFAULT_LU_MAX_ROWS; } }catch(e){ luMaxRows = DEFAULT_LU_MAX_ROWS; } var lkConditionalParam = []; // check isUseDispOnly if(skipLKData($parent)){ } else{ var luTableKey = $parent.datasource.value; var storeFieldInd = parseInt($parent.storeid.value.replace('col', ''), 10) - 1; var aisleFieldInd = parseInt($parent.aislecolumn.value.replace('col', ''), 10) - 1; var aisleValue = $parent.aislevalue.value; var condFieldName = "Column_" + aisleFieldInd; var condItem = { condField:condFieldName, condValue:aisleValue } lkConditionalParam.push(condItem); loadLookupData(luTableKey, storeFieldInd, lkConditionalParam, $parent.name.value); } $control.off('clearData').on('clearData', function(event, setDefaultValue){ var $ctrl = $(this).find('.controlData input'); $ctrl.val(''); setCtrlPropretiesValue(ctrlPropreties, ''); //$control.trigger('Control_Update') //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); }); $control.off('Control_Update').on('Control_Update', function(event){ event.stopPropagation(); if(fvDataNS.dontCallTrigger) return; skipRelevanceChange($parent, ctrlPropreties); calculateDataChange($parent, ctrlPropreties); /* fix bug 0026157: View data - Data in the first loop is lost after inputting value for second loop $('.fvMainWrapper .fvWorkspace .lkCondCtrlID_' + $parent.id.value).trigger("changeDataSource").trigger("changeTableDataSource"); */ triggerChangeDataSource($parent, ctrlPropreties); }); $control.find('.controlData input') .keyup(function(event) { setCtrlPropretiesValue(ctrlPropreties, $(this).val()); fvDataNS.ignoreLostFocus = false; //$(this).change(); }) .attr("autocomplete", "off") .on("beforeinput keypress", function(event){ if(!isRunEvent(event)){ return; } if(event.ctrlKey == true && (event.charCode == 118 || event.charCode == 99 || event.charCode == 120)){ return; } if($parent.kind != undefined && $parent.kind.value == 'Number'){ return onlyIntegerNumber(this,event, INTEGER_MAXLENGTH); }else{ return toNextCtrl(this,event, ctrlPropreties); } }) .blur(function(event){ $(this).change(); }) .off("drop").on("drop",function(e) { if($parent.kind != undefined && $parent.kind.value == 'Number'){ e.preventDefault(); } }) .off('input propertychange').on('input propertychange', function(e) { if($parent.kind != undefined && $parent.kind.value == 'Number'){ onlyNumber_Propertychange($(this), ctrlPropreties, 'Integer', INTEGER_MAXLENGTH); } }) .removeAttr('onchange') .result(function(event) { ctrlPropreties.autoAction = false; fvDataNS.ignoreLostFocus = false; ctrlPropreties.dataChangedByUser = true; $(this).trigger('change'); }) .change(function(event, notFillEmpty) { $control.find('.controlInfMsg').empty(); setCtrlPropretiesValue(ctrlPropreties, $(this).val()); if($parent.kind != undefined && $parent.kind.value == 'Number'){ if(!isOnlyNumber(ctrlPropreties.val)){ $(this).val(''); setCtrlPropretiesValue(ctrlPropreties, ''); //ctrlPropreties.oldVal = ''; showLookuNumberError(msg_fv_this_answer, $control.find('.controlInfMsg')); } } if(notFillEmpty && ctrlPropreties.val == ''){ return } if(!ctrlPropreties.isValueChange){ return; } $($(this).parents('.fvControl')[0]).trigger('Control_Update'); if($parent.isUseDispOnly != undefined && $parent.isUseDispOnly.value == true && !isWebAppDispatch()){ var isError = false; ctrlPropreties.limitToListError = false; // check limitToList autoCompleteArray[$parent.name.value] = getAutoCompleteArray(ctrlPropreties, $parent); if(autoCompleteArray[$parent.name.value] == undefined || jQuery.inArray(ctrlPropreties.val, autoCompleteArray[$parent.name.value]) < 0){ if($parent.limitToList && $parent.limitToList.value == true && ctrlPropreties.val !== ''){ ctrlPropreties.limitToListError = true; isError = true; } } if($parent.isUseCondLookup == undefined || $parent.isUseCondLookup.value != true){ if(!isError && jQuery.trim(ctrlPropreties.val) != ''){ var datasource = $parent.datasource.value; var lookupField = $parent.storeid.value; var lookupFieldValue = ctrlPropreties.val; indexStr = lookupField.replace("col", ""); index = parseInt(indexStr); index = index - 1; var lookupFieldName = "Column_" + index; var conditionalKey = luTableKey + '__' + $parent.id.value + '__' + index + getConditionalKey(lkConditionalParam, ctrlPropreties.classPath, ctrlPropreties.ignoreCondition); var fetchingData = undefined; if(fvDataNS.lkDataArrayMap != undefined && fvDataNS.lkDataArrayMap[conditionalKey] != undefined){ fetchingData = fvDataNS.lkDataArrayMap[conditionalKey][lookupFieldValue]; } if(fetchingData != undefined && JSON.stringify(fetchingData) != '{}'){ var isLoadding = isEditLoading(); if(!isLoadding && !isControlHidden(ctrlPropreties) && ctrlPropreties.val != ''){ var ctrlPropreties_UseInEachFunction = ctrlPropreties; var lookupField = 2; jQuery.each( $parent.destinationdataconds.value, function() { var ctrlId = this.text.val; index = lookupField; lookupField++; lookupFieldName = "Column_" + index; if(fetchingData[lookupFieldName] != undefined){ var parentsGroupOfLu = ctrlPropreties_UseInEachFunction.classPath.split(' '); var parentGroupClassName = ''; for(var i=0; i/g,'
'); destinationValue = destinationValue.replace(/
/g,'\r\n'); var tmpEmail = destinationValue; // check isSearchUndValue var isSearchUndValue = false; if($parent.isSearchUndValue != undefined && $parent.isSearchUndValue.value == true){ isSearchUndValue = true; } destinationValue = getDestinationValue(destinationValue, isSearchUndValue); if(ctrlId.startsWith(CONST_USER_VARIABLE_START_PARTENT)){ setUserVariableValue(ctrlId, destinationValue); }else{ var ctrlTmp = $('.fvMainWrapper .fvCtrlID_' + ctrlId); if(ctrlTmp.hasClass(CONST_CTRL_TYPE_INPUTEMAILREPORT)){ $('.fvMainWrapper ' + parentGroupClassName + ' .inpCtrlID_' + ctrlId).trigger('setLookupValue', [tmpEmail, isSearchUndValue]); }else{ if(ctrlTmp.hasClass(CONST_CTRL_TYPE_INPUTSELECTONE) || ctrlTmp.hasClass(CONST_CTRL_TYPE_INPUTSCOREONE)){ $('.fvMainWrapper ' + parentGroupClassName + ' .inpCtrlID_' + ctrlId).trigger('setLookupValue', [destinationValue, isSearchUndValue]); }else{ $('.fvMainWrapper ' + parentGroupClassName + ' .inpCtrlID_' + ctrlId).trigger('setLookupValue', [destinationValue, isSearchUndValue]); } } } } }); } }else{ var isLoadding = isEditLoading(); if(!isLoadding && !isControlHidden(ctrlPropreties) && ctrlPropreties.val != ''){ var ctrlPropreties_UseInEachFunction = ctrlPropreties; jQuery.each( $parent.destinationdataconds.value, function() { var ctrlId = this.text.val; var parentsGroupOfLu = ctrlPropreties_UseInEachFunction.classPath.split(' '); var parentGroupClassName = ''; for(var i=0; i 0){ ctrlParent = $(this).parents('.fvPageDetail')[0]; }else{ ctrlParent = $('.fvWorkspaceScrollArea .fvWorkspace'); } // CO-2741 var firstMattching = validateLKFirstMatching($parent); var disableFlg = validateLKDisabled($parent, firstMattching, this.disabled); if(true == disableFlg){ $(this).prop('disabled', true); var ctrlParent = $(this).parent(); ctrlParent.addClass('ctrlReadOnly'); ctrlParent.parent().find('.ico_lookup_erase').addClass('ctrlReadOnly'); ctrlParent.parent().find('.ico_lookup_keyboard').addClass('ctrlReadOnly'); } else { $(this).prop('disabled', false); var ctrlParent = $(this).parent(); ctrlParent.removeClass('ctrlReadOnly'); ctrlParent.parent().find('.ico_lookup_erase').removeClass('ctrlReadOnly'); ctrlParent.parent().find('.ico_lookup_keyboard').removeClass('ctrlReadOnly'); } if(disableFlg){ $(this) .unbind(".autocomplete_lk") .autocomplete_lk(autoCompleteArray[$parent.name.value], { showInObject: ctrlParent, resultsClass: resultsClass, delay:10, minChars:0, matchContains: $parent.isSearchWildCard.value, onItemSelect:selectItem, onFindValue:findValue, autoFill:true, maxItemsToShow:5, showWhenFocus:1, max: luMaxRows, scrollHeight: 200 }) .flushCache(); }else{ $(this) .unbind(".autocomplete_lk") .autocomplete_lk(autoCompleteArray[$parent.name.value], { showInObject: ctrlParent, resultsClass: resultsClass, delay:10, minChars:0, matchContains: $parent.isSearchWildCard.value, onItemSelect:selectItem, onFindValue:findValue, autoFill:true, maxItemsToShow:5, showWhenFocus:1, max: luMaxRows, scrollHeight: 200 }) .flushCache() .simulate("keydown", { keyCode: $.simulate.VK_DOWN }); } if(!ctrlInHiddenPage(ctrlPropreties)){ fvDataNS.autocompleteBinded[ctrlPropreties.classPath] = true; } var validateLKData = true; var isLoadding = isEditLoading(); var notHasData = (autoCompleteArray[$parent.name.value].indexOf($(this).val()) < 0); if(((!isLoadding && isReset && notHasData && ctrlPropreties.val != '') || (fvDataNS.isRetrieve && notHasData && ctrlPropreties.val != '') || (!isLoadding && notHasData && firstMattching)) && !ctrlPropreties.isCtrlHidden){ //$(this).val(''); if(firstMattching == true){ validateLKData = false; setFirstMatching($(this), $parent, autoCompleteArray); }else{ if(isOpenNewForm() || isEvaluateEditRetrieveForward($parent)){ $(this).val('', false).change(); var ctrlPropreties_UseInEachFunction = ctrlPropreties; jQuery.each( $parent.destinationdataconds.value, function() { var ctrlId = this.text.val; var parentsGroupOfLu = ctrlPropreties_UseInEachFunction.classPath.split(' '); var parentGroupClassName = ''; for(var i=0; i=0){ fileName = ctrlPropreties.val.substring(ctrlPropreties.val.lastIndexOf(CONST_DOUBLE_DOLLAR) + 2); }else{ fileName = ctrlPropreties.val; } $control.find('.controlInfo .displayURL').val(fileName); $control.addClass(CONST_CLASS_CTRL_HAS_ATTACH); } // readOnly $control.off('checkAndSetReadOnly').on('checkAndSetReadOnly', function() { if(isReadOnlyApply($parent) || ctrlPropreties.isCtrlReadOnly == true){ $control.find('.controlInfo #btn_contain a').addClass('btnReadOnly'); $control.addClass('btnReadOnly'); $control.find('.controlData #btn_contain a.attachBtn').off(); $control.find('.controlData #btn_contain a.openBtn').off(); }else{ $control.find('.controlInfo #btn_contain a').removeClass('btnReadOnly'); $control.removeClass('btnReadOnly'); $control.find('.controlData #btn_contain a.attachBtn').click(function(){ initializingUploadAttachment($(this), ctrlType + '_Uploaded', ctrlPropreties, $control); }).trigger('click'); $control.find('.controlData #btn_contain a.openBtn').click(function(){ if(ctrlPropreties.hintLink){ if(ctrlPropreties.hintLink.indexOf(CONST_URL_PARAM_FILENAME + '=')<0 && ctrlPropreties.val){ window.open(ctrlPropreties.hintLink + '&' + CONST_URL_PARAM_FILENAME + '=' + ctrlPropreties.val, '_blank'); }else{ window.open(ctrlPropreties.hintLink, '_blank'); } } }); if($parent.isAllowEdit && $parent.isAllowEdit.value == false){ $control.addClass(CONST_CLASS_NOT_ALLOW_EDIT); } } }); $control.trigger('checkAndSetReadOnly', $parent); { $control.off('clearData').on('clearData', function(event, setDefaultValue){ setCtrlPropretiesValue(ctrlPropreties, ''); ctrlPropreties.specialChange = true; ctrlPropreties.attrs = { 'blobKey': '' }; ctrlPropreties.hintLink = ''; ctrlPropreties.orgHintLink = undefined; var uploadBtnText = CONST_VALUE_UPLOAD; $control.find('.controlInfo .displayURL').val(''); $control.find('.controlInfo #btn_contain a.imgActBtn').empty().text(uploadBtnText).removeClass(CONST_CLASS_REPLACE_BTN); $control.removeClass(CONST_CLASS_CTRL_HAS_ATTACH); executeControlChange(ctrlPropreties.classPath); }); } $control.off('Control_Update').on('Control_Update', function(event){ if(fvDataNS.dontCallTrigger) return; return controlUpdate($parent, ctrlPropreties); }); $control.off('Attach_Data_Change').on('Attach_Data_Change', function(event){ adjustImageCss($control, ctrlPropreties); }); // relevanceconds addToCtrlIdRefForRelevance($parent.isShowRelevanceCondition, $parent.relevanceconds.value, ctrlPropreties.classPath); if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } ctrlPropreties.relevancecondsExpression = relevancecondsToExpression($parent.id, $parent.isShowRelevanceCondition, $parent.relevanceconds); ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); ctrlPropreties.skipcondsExpression = skipcondsToExpression($parent.id, $parent.isShowSkipCondition, $parent.skipconds, ctrlType); // Apply Skip If in WebApps GUI (binding events) processBindingSkipIfActionEvent($parent, ctrlPropreties); } /*****************************************************************************************************************/ /*End********************************************inputAttachment******************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start**************************************table inputText******************************************************/ /*****************************************************************************************************************/ var fvEditorsTableInputText = function($parent, $control, ctrlType, ctrlPropreties){ if(typeof $parent.id.value == 'string' && $parent.id.value.startsWith(REPEATABLE_SUMMARY_COL_ID.toString())){ return; } var formatKind = undefined; var phoneFormatKind = undefined; var customFormat = undefined; if($parent.socialSecurityFormat && $parent.socialSecurityFormat.value){ formatKind = CONST_FORMAT_KIND_SOCIAL; }else if($parent.phoneNoFormat && $parent.phoneNoFormat.value){ formatKind = CONST_FORMAT_KIND_PHONE; phoneFormatKind = $parent.phoneFormatKind.value; }else if($parent.isCustomFormat && $parent.isCustomFormat.value){ formatKind = CONST_FORMAT_KIND_CUSTOM; if($parent.txtCustomFormatVal){ customFormat = $parent.txtCustomFormatVal.value; }else{ customFormat = ''; } if($parent.customFormatTextChar){ ctrlPropreties.textChar = $parent.customFormatTextChar.value; }else{ ctrlPropreties.textChar = 'a'; } if($parent.customFormatNumChar){ ctrlPropreties.numChar = $parent.customFormatNumChar.value; }else{ ctrlPropreties.numChar = 'n'; } } ctrlPropreties.formatKind = formatKind; ctrlPropreties.customFormat = customFormat; ctrlPropreties.phoneFormatKind = phoneFormatKind; if(isVersion(VERSION_DUPLICAT_CHECK) && $parent.duplicateCheck && $parent.duplicateCheck.value){ ctrlPropreties.duplicateCheck = $parent.duplicateCheck.value; ctrlPropreties.duplicateCheckField = $parent.duplicateCheckField.value; } // upper case if($parent.uppercaseLock && $parent.uppercaseLock.value){ ctrlPropreties.uppercaseLock = $parent.uppercaseLock.value; $control.addClass('uppercase'); } // defaultValue var defaultValue; if(ctrlPropreties.val == undefined){ defaultValue = getValueOrEmpty($parent.defaultValue.value); setCtrlPropretiesValue(ctrlPropreties, defaultValue, true); fvEditorsSetDefaultValue(ctrlPropreties); if(fvDataNS.lkDataMap != undefined && fvDataNS.lkDataMap[ctrlPropreties.parentName] != undefined){ var col = fvDataNS.lkDataMap[ctrlPropreties.parentName][ctrlPropreties.id]; if( col != undefined){ if(fvDataNS.lkData[ctrlPropreties.parentName][ctrlPropreties.rowIndex]){ defaultValue = '' + getValueOrEmpty(fvDataNS.lkData[ctrlPropreties.parentName][ctrlPropreties.rowIndex][col]); }else{ defaultValue = ''; } defaultValue = defaultValue.replace(/<br>/g,'
'); defaultValue = defaultValue.replace(/
/g,'\r\n'); var tmpArr = ('' + defaultValue).split('$$'); if(tmpArr[0].indexOf('@') >= 0){ }else{ var isSearchUndValue = fvDataNS.lkDataMap[ctrlPropreties.parentName]['isSearchUndValue'] || false; defaultValue = getDestinationValue(defaultValue, isSearchUndValue); } defaultValue = valueDecode(defaultValue); setCtrlPropretiesValue(ctrlPropreties, defaultValue, true); } } }else{ defaultValue = ctrlPropreties.val; } if($parent.isCustomFormat && $parent.isCustomFormat.value && $parent.isShowCustomFormat && $parent.isShowCustomFormat.value){ $control.find('.controlData textarea').attr('placeholder', $parent.txtCustomFormatVal?$parent.txtCustomFormatVal.value:''); } $control.find('.controlData textarea') .addClass('inpCtrlID_' + ctrlPropreties.id) .val(formatTextDisplay(defaultValue, formatKind, phoneFormatKind, $parent)) .off('setLookupValue').on('setLookupValue', function(event, value, isSearchUndValue){ if(!isControlHiddenByRelevance(ctrlPropreties)){ setLookupValue($(this), ctrlType, $parent, value, isSearchUndValue, $control); ctrlPropreties.formatedValue = $(this).val(); if(value != ctrlPropreties.lastParseValue){ ctrlPropreties.lastParseValue = value; parseTextData($(this), $parent, ctrlPropreties.val, ctrlPropreties.parrentProperties); } ctrlPropreties.autoAction = false; $(this).change(); } }); $control.off('clearData').on('clearData', function(event, setDefaultValue){ var $ctrl = $(this).find('.controlData textarea'); var defaultValue; if(setDefaultValue){ defaultValue = getValueOrEmpty($parent.defaultValue.value); }else{ defaultValue = ''; } setLookupValue($ctrl, ctrlType, $parent, defaultValue, false, $control); $ctrl.change(); }); if(ctrlPropreties.length && ctrlPropreties.length.max && ctrlPropreties.length.cannotExceedMaximum) { $control.find('.controlData textarea').attr('maxlength',ctrlPropreties.length.max); } ctrlPropreties.formatedValue = $control.find('.controlData textarea').val(); // CO-3260 Field in view data adding values automatically fixFormatTextData($control.find('.controlData textarea'), ctrlPropreties, formatKind, phoneFormatKind); // hideInMobile $control.off('checkAndSetHide').on('checkAndSetHide', function() { execShowHideWebAppControl($control, $parent) }); $control.trigger('checkAndSetHide'); if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } // readOnly $control.off('checkAndSetReadOnly').on('checkAndSetReadOnly', function() { if(isReadOnlyApply($parent) || ctrlPropreties.isCtrlReadOnly == true){ $control.find('.controlData textarea').prop('disabled', true); $control.find('.inputinner').addClass('ctrlReadOnly'); } else { $control.find('.controlData textarea').prop('disabled', false); $control.find('.inputinner').removeClass('ctrlReadOnly'); } }); $control.trigger('checkAndSetReadOnly', $parent); if(isVersion(VERSION_NOFL)){ // Number of lines if($parent.numberOfLine != undefined){ var numberOfLine = parseInt($parent.numberOfLine.value, 10); if(numberOfLine > 1){ $control.find('textarea').css('height', 'inherit').attr('rows', $parent.numberOfLine.value); } } } // new if(!isEncryptedFormat($parent)){ var lockNumericKeyboard = false; var showSynbols = false; if($parent.lockNumericKeyboard && $parent.lockNumericKeyboard.value == true){ lockNumericKeyboard = true; if($parent.showSynbols && $parent.showSynbols.value == true){ showSynbols = true; } } $control.find('.controlData textarea') .keyup(function(event) { ctrlPropreties.autoAction = false; var ignoreAutoFillFormat = false; if(isPressBackspace(event)) { ignoreAutoFillFormat = true; var isIgnoreBackspace = false; switch(formatKind){ case CONST_FORMAT_KIND_SOCIAL: case CONST_FORMAT_KIND_PHONE: break; case CONST_FORMAT_KIND_CUSTOM: var textChar = undefined; var numChar = undefined; if(ctrlPropreties.textChar == undefined){ if($parent.customFormatTextChar){ textChar = $parent.customFormatTextChar.value; } if(textChar == undefined || textChar == ''){ textChar = 'a'; } ctrlPropreties.textChar = textChar; }else{ textChar = ctrlPropreties.textChar; } if(ctrlPropreties.numChar == undefined){ if($parent.customFormatNumChar){ numChar = $parent.customFormatNumChar.value; } if(numChar == undefined || numChar == ''){ numChar = 'n'; } ctrlPropreties.numChar = numChar; }else{ numChar = ctrlPropreties.numChar; } isIgnoreBackspace = !isCorrectFormat($(this).val(), customFormat, textChar, numChar); } if(isIgnoreBackspace){ var selectionStart = this.selectionStart; $(this).val(ctrlPropreties.formatedValue); this.selectionStart = this.selectionEnd = selectionStart+1; event.preventDefault(); return false; } } if($(this).val() == ctrlPropreties.formatedValue){ ignoreAutoFillFormat = true; } processTextKeyUp(this, ctrlPropreties, formatKind, phoneFormatKind, ignoreAutoFillFormat); if(isVersion(VERSION_UPPERCASE_LOCK) && ctrlPropreties.uppercaseLock){ var curPos = {selectionStart: this.selectionStart, selectionEnd: this.selectionEnd}; $(this).val($(this).val().toUpperCase()); this.selectionStart = curPos.selectionStart; this.selectionEnd = curPos.selectionEnd; } ctrlPropreties.formatedValue = $(this).val(); fvDataNS.ignoreLostFocus = false; ctrlPropreties.dataChangedByUser = true; //$(this).change(); }) .attr("autocomplete", "off") .on("beforeinput keypress", function(event){ if(!isRunEvent(event)){ return; } if(lockNumericKeyboard){ if(showSynbols){ if(!onlyNumberDigit(this, event)) event.preventDefault(); }else{ if(!onlyNumberDigitAndSymbols(this, event)) event.preventDefault(); } } var ctrlValue = ctrlPropreties.val; textValidateMaxLength($parent, ctrlValue, $control.find('.controlInfMsg'), event); switch(formatKind){ case CONST_FORMAT_KIND_SOCIAL: case CONST_FORMAT_KIND_PHONE: if(!isValidLength(this, event, formatKind, phoneFormatKind)){ return false; }else{ return onlyNumberDigit(this,event); } break; case CONST_FORMAT_KIND_CUSTOM: var textChar = undefined; var numChar = undefined; if(ctrlPropreties.textChar == undefined){ if($parent.customFormatTextChar){ textChar = $parent.customFormatTextChar.value; } if(textChar == undefined || textChar == ''){ textChar = 'a'; } ctrlPropreties.textChar = textChar; }else{ textChar = ctrlPropreties.textChar; } if(ctrlPropreties.numChar == undefined){ if($parent.customFormatNumChar){ numChar = $parent.customFormatNumChar.value; } if(numChar == undefined || numChar == ''){ numChar = 'n'; } ctrlPropreties.numChar = numChar; }else{ numChar = ctrlPropreties.numChar; } if(onlyNumberDigitCustomFormat(this, event, customFormat, textChar, numChar)){ return true; }else{ return onlyNumberDigitCustomFormatIgnoreSpecialChar(this, event, customFormat, textChar, numChar); } } }) .change(function(event) { if(!fvDataNS.ignoreLostFocus){ ctrlPropreties.formatedValue = $(this).val(); setTextValueWithoutFormat(ctrlPropreties, $(this).val(), formatKind); executeControlChange(ctrlPropreties.classPath); setTableRowNotEmptyClass($control, ctrlPropreties); return; }else{ fvDataNS.ignoreLostFocus = false; } }) .blur(function(event) { $(this).change(); verifyDuplicatesTableControl($(this), ctrlPropreties); var ctrlValue = ctrlPropreties.val; $(this).val(formatTextDisplay(ctrlValue, formatKind, phoneFormatKind)); ctrlPropreties.formatedValue = $(this).val(); textValidateError($parent, ctrlValue, $control.find('.controlInfMsg') , ctrlPropreties, $control); // CO-4054: New text setting - check duplicates start if(isVersion(VERSION_DUPLICAT_CHECK) && ctrlPropreties.duplicateCheck){ var duplicateCheckFieldId = ctrlPropreties.duplicateCheckField; if(duplicateCheckFieldId){ var ctrlNamesObj = fvDataNS.ctrlIdMap[duplicateCheckFieldId]; var ctrlNames = Object.keys(ctrlNamesObj); var duplicateError = false; var objTmp; ctrlNames.forEach(function(itemName){ if(duplicateError){ return false; } objTmp = fvDataNS.dataArray[itemName]; if(objTmp == undefined){ return true; } if(ctrlPropreties.val == objTmp.val){ duplicateError = true; return false; } }); if(duplicateError){ showDuplicateError(getControlLabel(objTmp), $control.find('.controlInfMsg'), undefined, objTmp.parentKind == 'table'); } } } //CO-4054: New text setting - check duplicates end executeSkipChange(ctrlPropreties); if(ctrlValue != ctrlPropreties.lastParseValue){ ctrlPropreties.lastParseValue = ctrlValue; parseTextData($(this), $parent, ctrlPropreties.val, ctrlPropreties.parrentProperties); } }).off("drop, paste").on("drop, paste",function(e) { // disable paste function if lockNumericKeyboard if(lockNumericKeyboard){ e.preventDefault(); } }); } $control.off('Control_Update').on('Control_Update', function(event){ event.stopPropagation(); if(fvDataNS.dontCallTrigger) return; return controlUpdate($parent, ctrlPropreties); }); if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); // Apply If .. Then .. Else in WebApps GUI (binding events) processBindingIfThenElseActionEvent($parent, ctrlPropreties); // Apply Skip If in WebApps GUI (binding events) processBindingSkipIfActionEvent($parent, ctrlPropreties); } /*****************************************************************************************************************/ /*End**************************************table inputText********************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start**************************************table inputNumeric***************************************************/ /*****************************************************************************************************************/ var fvEditorsTableInputNumeric = function($parent, $control, ctrlType, ctrlPropreties){ // defaultValue var defaultValue; if(ctrlPropreties.val == undefined){ defaultValue = getValueOrEmpty($parent.defaultValue.value); setCtrlPropretiesValue(ctrlPropreties, defaultValue, true); fvEditorsSetDefaultValue(ctrlPropreties); if(fvDataNS.lkDataMap != undefined && fvDataNS.lkDataMap[ctrlPropreties.parentName] != undefined){ var col = fvDataNS.lkDataMap[ctrlPropreties.parentName][ctrlPropreties.id]; if( col != undefined){ if(fvDataNS.lkData[ctrlPropreties.parentName][ctrlPropreties.rowIndex]){ defaultValue = '' + getValueOrEmpty(fvDataNS.lkData[ctrlPropreties.parentName][ctrlPropreties.rowIndex][col]); }else{ defaultValue = ''; } var isSearchUndValue = fvDataNS.lkDataMap[ctrlPropreties.parentName]['isSearchUndValue'] || false; defaultValue = getDestinationValue(defaultValue, isSearchUndValue); if(isNaN(defaultValue)){ defaultValue = ''; } if($parent.kind.value != 'Decimal'){ if(defaultValue.match(/[.]/) != undefined){ defaultValue = ''; } } setCtrlPropretiesValue(ctrlPropreties, defaultValue, true); } } }else{ defaultValue = ctrlPropreties.val; } /*var title = ''; if($parent.defaultValue.value != undefined && $parent.defaultValue.value != ''){ title = 'Default value : ' + $parent.defaultValue.value; }*/ $control.find('.currencyContain').removeClass('currencyContain'); var useCurencySymbol = ''; // useCurrentcySymbol if($parent.useCurrentcySymbol.value != undefined && $parent.useCurrentcySymbol.value == true){ if($parent.currency.value != undefined){ useCurencySymbol = $parent.currency.value; } } formatNumberForDisplay($control.find('.controlData input'), $parent, defaultValue, ctrlPropreties.roundDown); $control.find('.controlData input') .addClass('inpCtrlID_' + ctrlPropreties.id) //.attr('title', title) //.val(formatNumber(defaultValue, useCurencySymbol, $parent.kind.value)) .off('setLookupValue').on('setLookupValue', function(event, value, isSearchUndValue){ if(!isControlHiddenByRelevance(ctrlPropreties)){ setLookupValue($(this), ctrlType, $parent, value, isSearchUndValue, $control); ctrlPropreties.autoAction = false; $(this).change(); } }); $control.off('clearData').on('clearData', function(event, setDefaultValue){ var $ctrl = $(this).find('.controlData input'); var defaultValue; if(setDefaultValue){ defaultValue = getValueOrEmpty($parent.defaultValue.value); }else{ defaultValue = ''; } setLookupValue($ctrl, ctrlType, $parent, defaultValue, false, $control); $ctrl.change(); }); cleanDecNum($control.find('.controlData input')[0]); if(isEncryptedFormat($parent)){ formatEncryptedValue($parent, $control, defaultValue); } else{ var value = getRealNumberValue($control.find('.controlData input'), useCurencySymbol); if($parent.kind.value == 'Percent'){ value = getPercentValue(value); } setCtrlPropretiesValue(ctrlPropreties, value, true); } // hideInMobile $control.off('checkAndSetHide').on('checkAndSetHide', function() { execShowHideWebAppControl($control, $parent) }); $control.trigger('checkAndSetHide'); if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } // ctrlKind ctrlPropreties.kind = $parent.kind.value; // readOnly $control.off('checkAndSetReadOnly').on('checkAndSetReadOnly', function() { if(isReadOnlyApply($parent) || ctrlPropreties.isCtrlReadOnly == true){ $control.find('.controlData input').prop('disabled', true); $control.find('.inputinner').addClass('ctrlReadOnly'); } else { $control.find('.controlData input').prop('disabled', false); $control.find('.inputinner').removeClass('ctrlReadOnly'); } }); $control.trigger('checkAndSetReadOnly', $parent); // new if(!isEncryptedFormat($parent)){ $control.off('Control_Update').on('Control_Update', function(event){ event.stopPropagation(); if(fvDataNS.dontCallTrigger) return; calculateDataChange($parent, ctrlPropreties); /* fix bug 0026157: View data - Data in the first loop is lost after inputting value for second loop $('.fvMainWrapper .fvWorkspace .lkCondCtrlID_' + $parent.id.value).trigger("changeDataSource").trigger("changeTableDataSource"); */ triggerChangeDataSource($parent, ctrlPropreties); }); $control.find('.controlData input') .keyup(function(event) { ctrlPropreties.autoAction = false; fv = false; pointNotAtFirst(this, event); cleanDecNum(this); var value = $(this).val(); if($parent.kind.value == 'Percent'){ value = getPercentValue(value); } setCtrlPropretiesValue(ctrlPropreties, value); fvDataNS.ignoreLostFocus = false; ctrlPropreties.dataChangedByUser = true; //$(this).change(); }) .attr("autocomplete", "off") .on("beforeinput keypress", function(event){ if(!isRunEvent(event)){ return; } if(event.ctrlKey == true && (event.charCode == 118 || event.charCode == 99 || event.charCode == 120)){ return; } var value = $(this).val(); if($parent.kind.value == 'Percent'){ value = getPercentValue(value); } setCtrlPropretiesValue(ctrlPropreties, value); if($parent.kind.value == 'Decimal'){ if(!inputTextOnlyDecimalNumber(this, event, DECINAM_MAXLENGTH)) event.preventDefault(); }else if($parent.kind.value == 'Percent'){ if(!inputTextOnlyDecimalNumber(this, event, DECINAM_MAXLENGTH)) event.preventDefault(); }else{ return onlyIntegerNumber(this,event, INTEGER_MAXLENGTH); } }) .off("drop").on("drop",function(e) { e.preventDefault(); }) .off('input propertychange').on('input propertychange', function(e) { if($parent.kind.value == 'Decimal'){ onlyNumber_Propertychange($(this), ctrlPropreties, 'Decimal', DECINAM_MAXLENGTH); }else if($parent.kind.value == 'Percent'){ onlyNumber_Propertychange($(this), ctrlPropreties, 'Decimal', DECINAM_MAXLENGTH); }else{ onlyNumber_Propertychange($(this), ctrlPropreties, 'Integer', INTEGER_MAXLENGTH); } }) .change(function(event) { if(!fvDataNS.ignoreLostFocus){ // Get actual value, not value inside Numeric Input Field (Inside Table) // Fix bug 0019061: Integer - The message check range out disappear when user focus to another question // We have to plus empty string to convert ctrlPropreties.val into string value var isNegative = isNegativeNumber($(this)); var value = curencyToNumber($(this).val()); if($parent.kind.value == 'Percent'){ value = getPercentValue(value); } if(value > 0 && isNegative){ value = -value; } setCtrlPropretiesValue(ctrlPropreties, value + ''); //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); setTableRowNotEmptyClass($control, ctrlPropreties); return; }else{ fvDataNS.ignoreLostFocus = false; } }) .blur(function(event){ verifyDuplicatesTableControl($(this), ctrlPropreties); if(isNaN($(this).val()) && $(this).val().match(/^[+-]?[0.]+$/)){ $(this).val(''); setCtrlPropretiesValue(ctrlPropreties, $(this).val()); }else{ $(this).change(); } var ctrlValue = ctrlPropreties.val; formatNumberForDisplay($(this), $parent, ctrlValue, ctrlPropreties.roundDown); //$(this).val(formatNumber(ctrlValue, useCurencySymbol, $parent.kind.value)); numberValidateError($parent, ctrlPropreties, $control.find('.controlInfMsg'), $control); executeSkipChange(ctrlPropreties); }) .focus(function(event){ //$(this).val(curencyToNumber($(this).val())); $(this).removeClass('negativeFormat'); var ctrlValue = ctrlPropreties.val; if($parent.kind.value == 'Percent'){ ctrlValue = x100(parseFloat(ctrlValue)); if(isNaN(ctrlValue)){ ctrlValue = ''; } } if($(this).val() != ctrlValue){ $(this).val(ctrlValue); this.selectionStart = this.selectionEnd = $(this).val().length; } }); } if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); // Apply If .. Then .. Else in WebApps GUI (binding events) processBindingIfThenElseActionEvent($parent, ctrlPropreties); // Apply Skip If in WebApps GUI (binding events) processBindingSkipIfActionEvent($parent, ctrlPropreties); } /*****************************************************************************************************************/ /*End**************************************table inputNumeric*****************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start**************************************table inputTrends***************************************************/ /*****************************************************************************************************************/ var fvEditorsTableInputTrends = function($parent, $control, ctrlType, ctrlPropreties){ // defaultValue var defaultValue; if(ctrlPropreties.val == undefined){ defaultValue = getValueOrEmpty($parent.defaultValue.value); setCtrlPropretiesValue(ctrlPropreties, defaultValue, true); fvEditorsSetDefaultValue(ctrlPropreties); if(fvDataNS.lkDataMap != undefined && fvDataNS.lkDataMap[ctrlPropreties.parentName] != undefined){ var col = fvDataNS.lkDataMap[ctrlPropreties.parentName][ctrlPropreties.id]; if( col != undefined){ if(fvDataNS.lkData[ctrlPropreties.parentName][ctrlPropreties.rowIndex]){ defaultValue = '' + getValueOrEmpty(fvDataNS.lkData[ctrlPropreties.parentName][ctrlPropreties.rowIndex][col]); }else{ defaultValue = ''; } var isSearchUndValue = fvDataNS.lkDataMap[ctrlPropreties.parentName]['isSearchUndValue'] || false; defaultValue = getDestinationValue(defaultValue, isSearchUndValue); if(isNaN(defaultValue)){ defaultValue = ''; } if($parent.kind.value != 'Decimal'){ if(defaultValue.match(/[.]/) != undefined){ defaultValue = ''; } } setCtrlPropretiesValue(ctrlPropreties, defaultValue, true); } } }else{ defaultValue = ctrlPropreties.val; } /*var title = ''; if($parent.defaultValue.value != undefined && $parent.defaultValue.value != ''){ title = 'Default value : ' + $parent.defaultValue.value; }*/ $control.find('.currencyContain').removeClass('currencyContain'); var useCurencySymbol = ''; // useCurrentcySymbol if($parent.useCurrentcySymbol.value != undefined && $parent.useCurrentcySymbol.value == true){ if($parent.currency.value != undefined){ useCurencySymbol = $parent.currency.value; } } $control.find('.controlData input') .addClass('inpCtrlID_' + ctrlPropreties.id) //.attr('title', title) .val(formatNumber(defaultValue, useCurencySymbol, $parent.kind.value)) .off('setLookupValue').on('setLookupValue', function(event, value, isSearchUndValue){ if(!isControlHiddenByRelevance(ctrlPropreties)){ setLookupValue($(this), ctrlType, $parent, value, isSearchUndValue, $control); ctrlPropreties.autoAction = false; $(this).change(); } }); $control.off('clearData').on('clearData', function(event, setDefaultValue){ var $ctrl = $(this).find('.controlData input'); var defaultValue; if(setDefaultValue){ defaultValue = getValueOrEmpty($parent.defaultValue.value); }else{ defaultValue = ''; } setLookupValue($ctrl, ctrlType, $parent, defaultValue, false, $control); $ctrl.change(); }); cleanDecNum($control.find('.controlData input')[0]); setCtrlPropretiesValue(ctrlPropreties, getRealNumberValue($control.find('.controlData input'), useCurencySymbol), true); // hideInMobile $control.off('checkAndSetHide').on('checkAndSetHide', function() { execShowHideWebAppControl($control, $parent) }); $control.trigger('checkAndSetHide'); if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } // ctrlKind ctrlPropreties.kind = $parent.kind.value; // readOnly $control.off('checkAndSetReadOnly').on('checkAndSetReadOnly', function() { if(isReadOnlyApply($parent) || ctrlPropreties.isCtrlReadOnly == true){ $control.find('.controlData input').prop('disabled', true); $control.find('.inputinner').addClass('ctrlReadOnly'); } else { $control.find('.controlData input').prop('disabled', false); $control.find('.inputinner').removeClass('ctrlReadOnly'); } }); $control.trigger('checkAndSetReadOnly', $parent); // new { $control.off('Control_Update').on('Control_Update', function(event){ event.stopPropagation(); if(fvDataNS.dontCallTrigger) return; calculateDataChange($parent, ctrlPropreties); /* fix bug 0026157: View data - Data in the first loop is lost after inputting value for second loop $('.fvMainWrapper .fvWorkspace .lkCondCtrlID_' + $parent.id.value).trigger("changeDataSource").trigger("changeTableDataSource"); */ triggerChangeDataSource($parent, ctrlPropreties); }); $control.find('.controlData input') .keyup(function(event) { ctrlPropreties.autoAction = false; pointNotAtFirst(this, event); cleanDecNum(this); setCtrlPropretiesValue(ctrlPropreties, $(this).val()); fvDataNS.ignoreLostFocus = false; ctrlPropreties.dataChangedByUser = true; //$(this).change(); }) .attr("autocomplete", "off") .on("beforeinput keypress", function(event){ if(!isRunEvent(event)){ return; } if(event.ctrlKey == true && (event.charCode == 118 || event.charCode == 99 || event.charCode == 120)){ return; } setCtrlPropretiesValue(ctrlPropreties, $(this).val()); if($parent.kind.value == 'Decimal'){ if(!inputTextOnlyDecimalNumber(this, event, DECINAM_MAXLENGTH)) event.preventDefault(); }else{ return onlyIntegerNumber(this,event, INTEGER_MAXLENGTH); } }) .off("drop").on("drop",function(e) { e.preventDefault(); }) .off('input propertychange').on('input propertychange', function(e) { if($parent.kind.value == 'Decimal'){ onlyNumber_Propertychange($(this), ctrlPropreties, 'Decimal', DECINAM_MAXLENGTH); }else{ onlyNumber_Propertychange($(this), ctrlPropreties, 'Integer', INTEGER_MAXLENGTH); } }) .change(function(event) { if(!fvDataNS.ignoreLostFocus){ // Get actual value, not value inside Trends Input Field (Inside Table) // Fix bug 0019061: Integer - The message check range out disappear when user focus to another question // We have to plus empty string to convert ctrlPropreties.val into string value setCtrlPropretiesValue(ctrlPropreties, curencyToNumber($(this).val()) + ''); //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); setTableRowNotEmptyClass($control, ctrlPropreties); return; }else{ fvDataNS.ignoreLostFocus = false; } }) .blur(function(event){ $(this).change(); verifyDuplicatesTableControl($(this), ctrlPropreties); if(isNaN($(this).val()) && $(this).val().match(/^[+-]?[0.]+$/)){ $(this).val(''); setCtrlPropretiesValue(ctrlPropreties, $(this).val()); } var ctrlValue = ctrlPropreties.val; $(this).val(formatNumber(ctrlValue, useCurencySymbol, $parent.kind.value)); numberValidateError($parent, ctrlPropreties, $control.find('.controlInfMsg'), $control); executeSkipChange(ctrlPropreties); }) .focus(function(event){ if($(this).val() != ctrlPropreties.val){ $(this).val(ctrlPropreties.val); this.selectionStart = this.selectionEnd = $(this).val().length; } }); } if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); // Apply If .. Then .. Else in WebApps GUI (binding events) processBindingIfThenElseActionEvent($parent, ctrlPropreties); // Apply Skip If in WebApps GUI (binding events) processBindingSkipIfActionEvent($parent, ctrlPropreties); } /*****************************************************************************************************************/ /*End**************************************table inputTrends*****************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start**************************************table inputCounter***************************************************/ /*****************************************************************************************************************/ var fvEditorsTableInputCounter = function($parent, $control, ctrlType, ctrlPropreties){ // defaultValue var defaultValue; var defaultValue; if(ctrlPropreties.val == undefined){ defaultValue = getValueOrEmpty($parent.defaultValue.value); if(defaultValue == '' && $parent.range && $parent.range.value && $parent.range.value.min != undefined) { defaultValue = getValueOrEmpty($parent.range.value.min); } setCtrlPropretiesValue(ctrlPropreties, defaultValue, true); fvEditorsSetDefaultValue(ctrlPropreties); if(fvDataNS.lkDataMap != undefined && fvDataNS.lkDataMap[ctrlPropreties.parentName] != undefined){ var col = fvDataNS.lkDataMap[ctrlPropreties.parentName][ctrlPropreties.id]; if( col != undefined){ if(fvDataNS.lkData[ctrlPropreties.parentName][ctrlPropreties.rowIndex]){ defaultValue = '' + getValueOrEmpty(fvDataNS.lkData[ctrlPropreties.parentName][ctrlPropreties.rowIndex][col]); }else{ defaultValue = ''; } var isSearchUndValue = fvDataNS.lkDataMap[ctrlPropreties.parentName]['isSearchUndValue'] || false; defaultValue = getDestinationValue(defaultValue, isSearchUndValue); if(isNaN(defaultValue)){ defaultValue = ''; }else if(defaultValue.match(/[.]/) != undefined){ defaultValue = ''; } setCtrlPropretiesValue(ctrlPropreties, defaultValue, true); } } }else{ defaultValue = ctrlPropreties.val; } /*var title = ''; if($parent.defaultValue.value != undefined && $parent.defaultValue.value != ''){ title = 'Default value : ' + $parent.defaultValue.value; }*/ var isNormalCounter = true; if(isVersion(VERSION_COUNTER_STAR_SLIDER)){ if($parent.counterFormat){ switch($parent.counterFormat.value){ case CONST_TYPE_STARS: isNormalCounter = false; $control.find('.ctrlTableCell_inputCounter').addClass(CONST_CLASS_ISSTAR); if($parent.fitImageToScreen && $parent.fitImageToScreen.value){ $control.find(CONST_JQUERY_CLASS_STAR_TYPE).addClass(CONST_CLASS_FIT_TO_SCREEN); } if($parent.range && $parent.range.value && $parent.range.value.stars == CONST_TEN){ $control.find(CONST_JQUERY_CLASS_STAR_TYPE).addClass(CONST_CLASS_10_STARS); $control.find(CONST_JQUERY_CLASS_STAR_TYPE).removeClass(CONST_CLASS_5_STARS); } function setDefaultStarsValue(value){ try { value = parseInt('' + value); } catch (e) { $control.find(CONST_DOT + CONST_CSS_CLASS_SELECTED).removeClass(CONST_CSS_CLASS_SELECTED); return; } for(var i=1; i<=10; i++){ if(i <= value){ $control.find(CONST_DOT + CONST_CLASS_STAR + CONST_HYPHEN + i).addClass(CONST_CSS_CLASS_SELECTED); }else{ $control.find(CONST_DOT + CONST_CLASS_STAR + CONST_HYPHEN + i).removeClass(CONST_CSS_CLASS_SELECTED); } } } setDefaultStarsValue(defaultValue); $control.find(CONST_DIV + CONST_DOT + CONST_CLASS_STAR).click(function(event){ var dataValue = $(this).attr(CONST_DATA); if(parseInt(dataValue) > CONST_I_FIVE && $control.find(CONST_DOT + CONST_CLASS_10_STARS).length == 0){ $control.find(CONST_DOT + CONST_CSS_CLASS_SELECTED).removeClass(CONST_CSS_CLASS_SELECTED); dataValue = ''; } setDefaultStarsValue(dataValue); setCtrlPropretiesValue(ctrlPropreties, dataValue); fvDataNS.ignoreLostFocus = false; $(this).change(); }).change(function(event) { if(!fvDataNS.ignoreLostFocus){ setCtrlPropretiesValue(ctrlPropreties, $control.find(CONST_DOT + CONST_CSS_CLASS_SELECTED).length); if(ctrlPropreties.isValueChange){ myPostMessage($control, 'change'); } //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); ctrlPropreties.autoAction = false; executeControlChange(ctrlPropreties.classPath); setTableRowNotEmptyClass($control, ctrlPropreties); ctrlPropreties.dataChangedByUser = true; return; }else{ fvDataNS.ignoreLostFocus = false; } }); break; case CONST_TYPE_SLIDER: isNormalCounter = false; function sliderChange(event, ui){ //var value = $control.find(CONST_SHARP + CONST_SLIDER_BAR).slider(CONST_VALUE); var value = ui.value; $control.find(CONST_DOT + CONST_SLIDER_VALUE).empty().append(value); setCtrlPropretiesValue(ctrlPropreties, value); fvDataNS.ignoreLostFocus = false; $(this).change(); if(!$control.hasClass('ignore_focus')){ fvCtrlFocus($control, false); } } $control.find('.ctrlTableCell_inputCounter').addClass(CONST_CLASS_ISSLIDER); var min = parseInt($parent.range.value.min); var max = parseInt($parent.range.value.max); if(!defaultValue){ defaultValue = min; } $control.find(CONST_DOT + CONST_SLIDER_VALUE).empty().append(defaultValue); setCtrlPropretiesValue(ctrlPropreties, defaultValue); $control.find(CONST_SHARP + CONST_SLIDER_BAR).slider({ orientation: "horizontal", range: "max", min: min, max: max, value: defaultValue, slide: sliderChange, change: sliderChange }).change(function(event) { if(!fvDataNS.ignoreLostFocus){ setCtrlPropretiesValue(ctrlPropreties, $(this).slider("value")); if(ctrlPropreties.isValueChange){ myPostMessage($control, 'change'); } executeControlChange(ctrlPropreties.classPath); ctrlPropreties.autoAction = false; setTableRowNotEmptyClass($control, ctrlPropreties); ctrlPropreties.dataChangedByUser = true; return; }else{ fvDataNS.ignoreLostFocus = false; } }); break; } } } $control.find('.controlData input') .addClass('inpCtrlID_' + ctrlPropreties.id) //.attr('title', title) .val(defaultValue) .off('setLookupValue').on('setLookupValue', function(event, value, isSearchUndValue){ if(!isControlHiddenByRelevance(ctrlPropreties)){ setLookupValue($(this), ctrlType, $parent, value, isSearchUndValue, $control); ctrlPropreties.autoAction = false; $(this).change(); } }); cleanDecNum($control.find('.controlData input')[0]); // label $control.find('.controlLabel').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.label.value.eng))); $control.off('checkAndSetRequired').on('checkAndSetRequired', function() { fvAppendRequired($parent, $control.find('.controlLabel')); }); $control.trigger('checkAndSetRequired'); // hint $control.find('.controlHint').empty().append(removeUnsupportHTML(getValueOrEmpty($parent.hint.value.eng))); // hideInMobile $control.off('checkAndSetHide').on('checkAndSetHide', function() { execShowHideWebAppControl($control, $parent) }); $control.trigger('checkAndSetHide'); if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } // readOnly $control.off('checkAndSetReadOnly').on('checkAndSetReadOnly', function() { if(isReadOnlyApply($parent) || ctrlPropreties.isCtrlReadOnly == true){ $control.find('.controlData input').prop('disabled', true); //$control.find('.inputinner').addClass('ctrlReadOnly'); $control.find('.controlData').addClass('ctrlReadOnly'); $control.find('.controlData .btnUp').off('click'); $control.find('.controlData .btnDown').off('click'); if(isVersion(VERSION_COUNTER_STAR_SLIDER)){ $control.find(CONST_SHARP + CONST_SLIDER_BAR).off('slider'); $control.find(CONST_DIV + CONST_DOT + CONST_CLASS_STAR).off('click'); } }else if(isNormalCounter){ $control.find('.controlData input').prop('disabled', false); $control.find('.controlData').removeClass('ctrlReadOnly'); // btnUp $control.find('.controlData .btnUp') .click(function(event){ fvDataNS.ignoreLostFocus = false; fvDataNS.dontJump = ctrlPropreties.classPath; var ctrlValue = parseInt($control.find('.controlData input').val(), 10); if(isNaN(ctrlValue)){ ctrlValue = 0; } var step = 1; if($parent.spinStep != undefined, 10){ step = parseInt($parent.spinStep.value, 10); } if(isNaN(step)){ step = 1; } ctrlValue += step; ctrlPropreties.newVal = ctrlValue; if(numberValidateRangeCannotExceedError($parent, ctrlPropreties , $control.find('.controlInfMsg'), $control, false)) { event.preventDefault(); return; } //$control.find('.controlInfMsg').empty(); // We will use a special trick for fix issue : change event on IE11 $control.find('.controlData input').focus().val(ctrlValue) .trigger('change').trigger('blur'); // Simulate event lost focus(), fix bug 0018677: Counter - warning message works incorrectly when using up/down button to change value ctrlPropreties.dataChangedByUser = true; }); // btnDown $control.find('.controlData .btnDown') .click(function(event){ fvDataNS.ignoreLostFocus = false; fvDataNS.dontJump = ctrlPropreties.classPath; var ctrlValue = parseInt($control.find('.controlData input').val(), 10); if(isNaN(ctrlValue)){ ctrlValue = 0; } var step = 1; if($parent.spinStep != undefined, 10){ step = parseInt($parent.spinStep.value, 10); } if(isNaN(step)){ step = 1; } ctrlValue -= step; ctrlPropreties.newVal = ctrlValue; if(numberValidateRangeCannotExceedError($parent, ctrlPropreties , $control.find('.controlInfMsg'), $control, false)) { event.preventDefault(); return; } //$control.find('.controlInfMsg').empty(); // We will use a special trick for fix issue : change event on IE11 $control.find('.controlData input').focus().val(ctrlValue) .trigger('change').trigger('blur'); // Simulate event lost focus(), fix bug 0018677: Counter - warning message works incorrectly when using up/down button to change value ctrlPropreties.dataChangedByUser = true; }); } }); $control.trigger('checkAndSetReadOnly', $parent); $control.off('clearData').on('clearData', function(event, setDefaultValue){ var $ctrl = $(this).find('.controlData input'); var defaultValue = getValueOrEmpty($parent.defaultValue.value); if(setDefaultValue && defaultValue != ''){ if($control.find(CONST_DOT + CONST_CLASS_ISSTAR).length >0){ $control.find(CONST_DIV + CONST_CSS_CLASS_SELECTED).removeClass(CONST_CSS_CLASS_SELECTED); var ctrlTmp = $control.find(CONST_DIV + CONST_DOT + CONST_CLASS_STAR + CONST_HYPHEN + defaultValue); if(ctrlTmp.length > 0){ ctrlTmp.trigger('click'); }else{ $control.find(CONST_DOT + CONST_CSS_CLASS_SELECTED).removeClass(CONST_CSS_CLASS_SELECTED).change(); } }else if($control.find(CONST_DOT + CONST_CLASS_ISSLIDER).length >0){ $control.find(CONST_SHARP + CONST_SLIDER_BAR).slider( "value", setDefaultValue); setCtrlPropretiesValue(ctrlPropreties, $control.find(CONST_SHARP + CONST_SLIDER_BAR).slider( "value" )); }else{ $ctrl.val(getValueOrEmpty($parent.defaultValue.value)); setCtrlPropretiesValue(ctrlPropreties, $ctrl.val()); } }else{ if($control.find(CONST_DOT + CONST_CLASS_ISSTAR).length >0){ $control.find(CONST_DIV + CONST_CSS_CLASS_SELECTED).removeClass(CONST_CSS_CLASS_SELECTED); setCtrlPropretiesValue(ctrlPropreties, ''); }else if($control.find(CONST_DOT + CONST_CLASS_ISSLIDER).length >0){ var min = parseInt($parent.range.value.min); $control.find(CONST_SHARP + CONST_SLIDER_BAR).slider( "value", min); setCtrlPropretiesValue(ctrlPropreties, min); }else{ $ctrl.val(''); setCtrlPropretiesValue(ctrlPropreties, ''); } } //$control.trigger('Control_Update') //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); }); if(isNormalCounter){ $control.off('Control_Update').on('Control_Update', function(event){ event.stopPropagation(); if(fvDataNS.dontCallTrigger) return; calculateDataChange($parent, ctrlPropreties); /* fix bug 0026157: View data - Data in the first loop is lost after inputting value for second loop $('.fvMainWrapper .fvWorkspace .lkCondCtrlID_' + $parent.id.value).trigger("changeDataSource").trigger("changeTableDataSource"); */ triggerChangeDataSource($parent, ctrlPropreties); }); $control.find('.controlData input') .keyup(function(event) { ctrlPropreties.autoAction = false; pointNotAtFirst(this, event); cleanDecNum(this); setCtrlPropretiesValue(ctrlPropreties, $(this).val()); fvDataNS.ignoreLostFocus = false; ctrlPropreties.dataChangedByUser = true; //$(this).change(); }) .attr("autocomplete", "off") .on("beforeinput keypress", function(event){ if(!isRunEvent(event)){ return; } if(event.ctrlKey == true && (event.charCode == 118 || event.charCode == 99 || event.charCode == 120)){ return; } return onlyIntegerNumber(this,event, INTEGER_MAXLENGTH); }) .off("drop").on("drop",function(e) { e.preventDefault(); }) .off('input propertychange').on('input propertychange', function(e) { onlyNumber_Propertychange($(this), ctrlPropreties, 'Integer', INTEGER_MAXLENGTH); }) .change(function(event) { if(!fvDataNS.ignoreLostFocus){ setCtrlPropretiesValue(ctrlPropreties, $(this).val()); if(ctrlPropreties.isValueChange){ myPostMessage($control, 'change'); } //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); setTableRowNotEmptyClass($control, ctrlPropreties); return; }else{ fvDataNS.ignoreLostFocus = false; } }) .blur(function(event){ $(this).change(); verifyDuplicatesTableControl($(this), ctrlPropreties); if(isNaN($(this).val()) && $(this).val().match(/^[+-]?[0.]+$/)){ $(this).val(''); setCtrlPropretiesValue(ctrlPropreties, $(this).val()); } var ctrlValue = ctrlPropreties.val; numberValidateError($parent, ctrlPropreties, $control.find('.controlInfMsg'), $control); executeSkipChange(ctrlPropreties); }); } if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); // Apply If .. Then .. Else in WebApps GUI (binding events) processBindingIfThenElseActionEvent($parent, ctrlPropreties); // Apply Skip If in WebApps GUI (binding events) processBindingSkipIfActionEvent($parent, ctrlPropreties); } /*****************************************************************************************************************/ /*End****************************************table inputCounter***************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start**************************************table inputDate******************************************************/ /*****************************************************************************************************************/ var fvEditorsTableInputDate = function($parent, $control, ctrlType, ctrlPropreties){ // CO-1931 Verify Setting - Time Fields setVerifyTime(ctrlPropreties, $parent); // CO-896 Able to use the button type for Date/Time fields in Grid/Table for Print/Preview/Web if(isVersion(VERSION_SHOW_ICON_BUTTON_DATE_IN_GRID_TABLE)){ addClassShowIconForDate($parent, $control); } // Fix bug 0022174: Table - "Calendar" popup is closed immediately after it had just display $control.addClass(CONST_CTRL_TYPE_INPUTDATE); // dateDefaultField var defaultValue; var _allowEdit = true; if(ctrlPropreties.val == undefined){ if(isVersion(VERSION_SET_WEEK_ENDING_DATE) && $parent.kind.value != CONST_VALUE_TIME && $parent.isSetWeekEndingDate.value == true){ if($parent.weekEndingDateType && $parent.weekEndingDateType.value == CONST_VALUE_OTHER){ if($parent.weekEndingDateField && $parent.weekEndingDateField.value != ''){ var itemProperties = getPropertiesByID($parent.weekEndingDateField.value); if(itemProperties && itemProperties.val && itemProperties.val != ''){ defaultValue = getWeekEndingDate($parent.endDay.value, $parent.kind.value, itemProperties.val); }else{ //defaultValue = getValueOrEmpty($parent.defaultValue.value); //defaultValue = mmddyyyyToTFormat(defaultValue, $parent.kind.value); defaultValue = ''; } }else{ defaultValue = getWeekEndingDate($parent.endDay.value, $parent.kind.value); } }else{ defaultValue = getWeekEndingDate($parent.endDay.value, $parent.kind.value); } }else if(isVersion(VERSION_SET_MONTH_ENDING_DATE) && $parent.kind.value != CONST_VALUE_TIME && $parent.isSetMonthEndingDate.value == true){ if($parent.monthEndingDateType && $parent.monthEndingDateType.value == CONST_VALUE_OTHER){ if($parent.monthEndingDateField && $parent.monthEndingDateField.value != ''){ var itemProperties = getPropertiesByID($parent.monthEndingDateField.value); if(itemProperties && itemProperties.val && itemProperties.val != ''){ defaultValue = getMonthEndingDate($parent.kind.value, itemProperties.val); }else{ defaultValue = ''; } }else{ defaultValue = ''; } }else{ defaultValue = getMonthEndingDate($parent.kind.value); } }else{ defaultValue = getValueOrEmpty($parent.defaultValue.value); defaultValue = mmddyyyyToTFormat(defaultValue, $parent.kind.value, undefined, "mm/dd/yyyy"); } if(defaultValue != ''){ setCtrlPropretiesValue(ctrlPropreties, defaultValue, true, $parent, $control); if(getValueOrEmpty($parent.defaultValue.value) == CONST_TODAY){ ctrlPropreties.defaultValue = CONST_TODAY; }else{ fvEditorsSetDefaultValue(ctrlPropreties); } } if(fvDataNS.lkDataMap != undefined && fvDataNS.lkDataMap[ctrlPropreties.parentName] != undefined){ var col = fvDataNS.lkDataMap[ctrlPropreties.parentName][ctrlPropreties.id]; if( col != undefined){ if(fvDataNS.lkData[ctrlPropreties.parentName][ctrlPropreties.rowIndex]){ defaultValue = '' + getValueOrEmpty(fvDataNS.lkData[ctrlPropreties.parentName][ctrlPropreties.rowIndex][col]); }else{ defaultValue = ''; } var isSearchUndValue = fvDataNS.lkDataMap[ctrlPropreties.parentName]['isSearchUndValue'] || false; defaultValue = getDestinationValue(defaultValue, isSearchUndValue); defaultValue = mmddyyyyToTFormat(defaultValue, $parent.kind.value, undefined, "mm/dd/yyyy"); setCtrlPropretiesValue(ctrlPropreties, defaultValue, true, $parent, $control); } } }else{ defaultValue = ctrlPropreties.val; if(defaultValue != '' && !isCtrlAllowEdit(ctrlPropreties.ctrlType, $parent)){ _allowEdit = false; } } var isMilitaryTime = $parent.militaryTime?$parent.militaryTime.value:undefined; /*var title = ''; if($parent.defaultValue.value != undefined && $parent.defaultValue.value != ''){ title = 'Default value : ' + $parent.defaultValue.value; $control.find('.controlData .tblCellInputDate') .attr('title', title); }*/ var type = ''; if($parent.kind.value != undefined && $parent.kind.value == CONST_VALUE_DATE){ type = CONST_VALUE_DATE; $control.find('.controlData input').addClass('datePK'); $control.parents('.equallySpaceColumns').addClass('sp-date'); if(defaultValue != ''){ var date = parseDateTFormat(defaultValue, CONST_VALUE_DATE); setCurrentTimeFV($control.find('.controlData .tblCellInputDate'), type, date, isMilitaryTime, $parent, ctrlPropreties); } $control.find('a.tblCellNowBtn').empty().append('Today'); }else if($parent.kind.value != undefined && $parent.kind.value == CONST_VALUE_TIME){ type = CONST_VALUE_TIME; $control.find('.controlData input').addClass('timePK'); $control.parents('.equallySpaceColumns').addClass('sp-time'); if(defaultValue != ''){ var date = parseDateTFormat(defaultValue, CONST_VALUE_TIME); setCurrentTimeFV($control.find('.controlData .tblCellInputDate'), type, date, isMilitaryTime, $parent, ctrlPropreties); } }else{ type = CONST_VALUE_DATE_SPACE_TIME; $control.find('.controlData input').addClass('dateTimePK'); $control.parents('.equallySpaceColumns').addClass('sp-datetime'); if(defaultValue != ''){ var date = parseDateTFormat(defaultValue, CONST_VALUE_DATE_TIME); setCurrentTimeFV($control.find('.controlData .tblCellInputDate'), type, date, isMilitaryTime, $parent, ctrlPropreties); } } $control.find('.controlData input') .addClass('inpCtrlID_' + ctrlPropreties.id) .off('setLookupValue').on('setLookupValue', function(event, value, isSearchUndValue, isForRetrieve){ if(!isControlHiddenByRelevance(ctrlPropreties)){ setLookupValue($(this), 'tblCellInputDate', $parent, value, isSearchUndValue, $control, ctrlPropreties, isForRetrieve); // CO-1931 Verify Setting - Time Fields runVerifyTime(ctrlPropreties); ctrlPropreties.autoAction = false; $(this).change(); } }) .off('setAutoStamp').on('setAutoStamp', function(event){ if(isWebAppDispatch()) return; setCurrentTimeFV($control.find('.controlData .tblCellInputDate'), type, undefined, isMilitaryTime, $parent, ctrlPropreties); //var ctrlValue = getValueOrEmpty(ctrlPropreties.val); dateValidateError($parent, ctrlPropreties, $control.find('.controlInfMsg'), $control); // CO-1931 Verify Setting - Time Fields runVerifyTime(ctrlPropreties); }) .off('setWeekEndingDate').on('setWeekEndingDate', function(event, relDate){ var weekEndingDate = getWeekEndingDate($parent.endDay.value, $parent.kind.value, relDate); if($parent.kind.value != undefined && $parent.kind.value == CONST_VALUE_DATE){ var date = parseDateTFormat(weekEndingDate, CONST_VALUE_DATE); setCurrentTimeFV($control.find('.controlData .tblCellInputDate'), type, date, isMilitaryTime, $parent, ctrlPropreties); }else if($parent.kind.value != undefined && $parent.kind.value == CONST_VALUE_TIME){ }else{ var date = parseDateTFormat(weekEndingDate, CONST_VALUE_DATE_TIME); setCurrentTimeFV($control.find('.controlData .tblCellInputDate'), type, date, isMilitaryTime, $parent, ctrlPropreties); } }) .off('setMonthEndingDate').on('setMonthEndingDate', function(event, relDate){ var monthEndingDate = getMonthEndingDate($parent.kind.value, relDate); if($parent.kind.value != undefined && $parent.kind.value == CONST_VALUE_DATE){ var date = parseDateTFormat(monthEndingDate, CONST_VALUE_DATE); setCurrentTimeFV($control.find('.controlData .tblCellInputDate'), type, date, isMilitaryTime, $parent, ctrlPropreties); }else if($parent.kind.value != undefined && $parent.kind.value == CONST_VALUE_TIME){ }else{ var date = parseDateTFormat(monthEndingDate, CONST_VALUE_DATE_TIME); setCurrentTimeFV($control.find('.controlData .tblCellInputDate'), type, date, isMilitaryTime, $parent, ctrlPropreties); } }); $control.off('clearData').on('clearData', function(event, setDefaultValue){ var $ctrl = $(this).find('.controlData input'); var defaultValue; if(setDefaultValue){ defaultValue = getValueOrEmpty($parent.defaultValue.value); }else{ defaultValue = ''; } setLookupValue($ctrl, ctrlType, $parent, defaultValue, false, $control); $ctrl.change(); }); // hideInMobile $control.off('checkAndSetHide').on('checkAndSetHide', function() { execShowHideWebAppControl($control, $parent) }); $control.trigger('checkAndSetHide'); // show now button execShowNowButton($control, $parent); if(ctrlPropreties.isCtrlHidden || isWAHidden($parent)){ $control.addClass(CONST_CLASS_HIDE_CONTROL); } // ctrlKind ctrlPropreties.kind = $parent.kind.value; // readOnly $control.off('checkAndSetReadOnly').on('checkAndSetReadOnly', function() { if(isReadOnlyApply($parent) || ctrlPropreties.isCtrlReadOnly == true || !_allowEdit){ // readonly || date time not allow edit $control.find('.controlData input').prop('disabled',"disabled").addClass('fullSize'); $control.find('.controlData a').addClass('btnReadOnly'); $control.find('.controlData .tblCellInputDate').off('datetimepicker'); $control.find('.controlData .tblCellNowBtn').off('click'); }else{ var showAndroid = true; if($parent.useCalendarView != undefined && $parent.useCalendarView.value){ // use calendar view showAndroid = false; } $control.find('.controlData input').prop('disabled', false); $control.find('.controlData a').removeClass('btnReadOnly'); if(type == CONST_VALUE_DATE_SPACE_TIME){ var dateFormat; if(isMilitaryTime){ dateFormat = DEFAULT_DATE_TIME_FORMAT_24H; }else{ dateFormat = DEFAULT_DATE_TIME_FORMAT_12H; } var showSecond = true; if($parent.showSeconds && $parent.showSeconds.value == false){ dateFormat = dateFormat.replace(':ss', ''); showSecond = false; } var minuteInterval = '1'; if($parent.minuteInterval && $parent.minuteInterval.value){ minuteInterval = $parent.minuteInterval.value; } var minuteIntervalRounding = CONST_ROUNDING_UP; if(isVersion(VERSION_OPTION_MINUTE_INTERVAL_ROUNDING)){ if($parent.rounding && $parent.rounding.value){ minuteIntervalRounding = $parent.rounding.value; } } var limitUserToIntervalValue = false; if(isVersion(VERSION_LIMIT_TO_INTERVAL_VALUE)){ if($parent.limitUserToIntervalValue && $parent.limitUserToIntervalValue.value){ limitUserToIntervalValue = $parent.limitUserToIntervalValue.value; } }else{ limitUserToIntervalValue = true; } $control.find('.controlData .tblCellInputDate').datetimepicker( { showInObjectClass: '.fvWorkspaceScrollArea .fvWorkspace', dateFormat: dateFormat, showCalendar: true, showTime:true, showSecond: showSecond, isRTL: false, showButtonPanel:true, minuteInterval: minuteInterval, minuteIntervalRounding: minuteIntervalRounding, limitUserToIntervalValue: limitUserToIntervalValue, showAsAndorid: showAndroid, showAsAndorid24: isMilitaryTime, onSelect: function(dateText, inst) { ctrlPropreties.autoAction = false; setFocusCtrlMap(ctrlPropreties.classPath); fvDataNS.focusControl = this; //$(this).trigger('keyup'); setCtrlPropretiesValue(ctrlPropreties, mmddyyyyToTFormat(inst.selectedFullDate, $parent.kind.value, undefined, DEFAULT_DATE_FORMAT), undefined, $parent, $control); $(this).attr('data_fm', $(this).val()); $(this).attr('data_org', ctrlPropreties.val).attr('data_org_nfm', inst.selectedFullDate_mdy); fvDataNS.ignoreLostFocus = false; $(this).blur(); $(this).parents('.ctrl_selected').focus(); //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); executeSkipChange(ctrlPropreties); ctrlPropreties.dataChangedByUser = true; } }); }else if(type == CONST_VALUE_TIME){ var dateFormat; if(isMilitaryTime){ dateFormat = DEFAULT_TIME_FORMAT_24H; }else{ dateFormat = DEFAULT_TIME_FORMAT_12H; } var showSecond = true; if($parent.showSeconds && $parent.showSeconds.value == false){ dateFormat = dateFormat.replace(':ss', ''); showSecond = false; } var minuteInterval = '1'; if($parent.minuteInterval && $parent.minuteInterval.value){ minuteInterval = $parent.minuteInterval.value; } var minuteIntervalRounding = CONST_ROUNDING_UP; if(isVersion(VERSION_OPTION_MINUTE_INTERVAL_ROUNDING)){ if($parent.rounding && $parent.rounding.value){ minuteIntervalRounding = $parent.rounding.value; } } var limitUserToIntervalValue = false; if(isVersion(VERSION_LIMIT_TO_INTERVAL_VALUE)){ if($parent.limitUserToIntervalValue && $parent.limitUserToIntervalValue.value){ limitUserToIntervalValue = $parent.limitUserToIntervalValue.value; } }else{ limitUserToIntervalValue = true; } $control.find('.controlData .tblCellInputDate').datetimepicker( { showInObjectClass: '.fvWorkspaceScrollArea .fvWorkspace', dateFormat: dateFormat, showCalendar: false, showTime:true, showSecond: showSecond, isRTL: false, showButtonPanel:true, minuteInterval: minuteInterval, minuteIntervalRounding: minuteIntervalRounding, limitUserToIntervalValue: limitUserToIntervalValue, showAsAndorid: showAndroid, showAsAndorid24: isMilitaryTime, onSelect: function(dateText, inst) { ctrlPropreties.autoAction = false; setFocusCtrlMap(ctrlPropreties.classPath); fvDataNS.focusControl = this; //$(this).trigger('keyup'); setCtrlPropretiesValue(ctrlPropreties, mmddyyyyToTFormat(inst.selectedFullDate, $parent.kind.value, undefined, DEFAULT_DATE_FORMAT), undefined, $parent, $control); // CO-1931 Verify Setting - Time Fields runVerifyTime(ctrlPropreties); $(this).attr('data_fm', $(this).val()); $(this).attr('data_org', ctrlPropreties.val).attr('data_org_nfm', inst.selectedFullDate_mdy); fvDataNS.ignoreLostFocus = false; $(this).blur(); $(this).parents('.ctrl_selected').focus(); //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); executeSkipChange(ctrlPropreties); ctrlPropreties.dataChangedByUser = true; } }); }else{ $control.find('.controlData .tblCellInputDate').datetimepicker( { showInObjectClass: '.fvWorkspaceScrollArea .fvWorkspace', dateFormat: DEFAULT_DATE_FORMAT, showCalendar: true, showTime:false, isRTL: false, showButtonPanel:true, showAsAndorid: showAndroid, onSelect: function(dateText, inst) { ctrlPropreties.autoAction = false; setFocusCtrlMap(ctrlPropreties.classPath); fvDataNS.focusControl = this; //$(this).trigger('keyup'); setCtrlPropretiesValue(ctrlPropreties, mmddyyyyToTFormat(inst.selectedFullDate, $parent.kind.value, undefined, DEFAULT_DATE_FORMAT), undefined, $parent, $control); $(this).attr('data_fm', $(this).val()); $(this).attr('data_org', ctrlPropreties.val).attr('data_org_nfm', inst.selectedFullDate_mdy); fvDataNS.ignoreLostFocus = false; $(this).blur(); $(this).parents('.ctrl_selected').focus(); //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); executeSkipChange(ctrlPropreties); ctrlPropreties.dataChangedByUser = true; } }); } $control.find('.controlData .date-time-now-btn-session').click(function(event){ ctrlPropreties.autoAction = false; if($parent.btnType && $parent.btnType.value == CONST_TYPE_IMAGE && $parent.iconAction && $parent.iconAction.value == CONST_PICKER){ $control.find('.controlData .tblCellInputDate').focus(); }else{ setFocusCtrlMap(ctrlPropreties.classPath); fvDataNS.focusControl = this; ctrlPropreties.dataChangedByUser = true; setCurrentTimeFV($control.find('.controlData .tblCellInputDate'), type, undefined, isMilitaryTime, $parent, ctrlPropreties); //var ctrlValue = getValueOrEmpty(ctrlPropreties.val); executeControlChange(ctrlPropreties.classPath); dateValidateError($parent, ctrlPropreties, $control.find('.controlInfMsg'), $control); executeSkipChange(ctrlPropreties); ctrlPropreties.dataChangedByUser = true; } }); } }); $control.trigger('checkAndSetReadOnly', $parent); $control.off('Control_Update').on('Control_Update', function(event){ event.stopPropagation(); if(fvDataNS.dontCallTrigger) return; calculateDataChange($parent, ctrlPropreties); /* fix bug 0026157: View data - Data in the first loop is lost after inputting value for second loop $('.fvMainWrapper .fvWorkspace .lkCondCtrlID_' + $parent.id.value).trigger("changeDataSource").trigger("changeTableDataSource"); */ triggerChangeDataSource($parent, ctrlPropreties); }); $control.find('.controlData input').change(function(event, ignoreCheck){ if(!fvDataNS.ignoreLostFocus || ignoreCheck){ //setCtrlPropretiesValue(ctrlPropreties, ctrlPropreties.val, undefined, $parent, $control); // change if($(this).val() != $(this).attr('data_fm')){ setCtrlPropretiesValue(ctrlPropreties, mmddyyyyToTFormat($(this).val(), $parent.kind.value, undefined, DEFAULT_DATE_FORMAT), undefined, $parent, $control); }else{ var data_org = $(this).attr('data_org'); if(data_org != undefined && ctrlPropreties.val != data_org){ setCtrlPropretiesValue(ctrlPropreties, mmddyyyyToTFormat(data_org, $parent.kind.value), undefined, $parent, $control); } } // CO-1931 Verify Setting - Time Fields runVerifyTime(ctrlPropreties); //console.log('executeControlChange : ' + fvDataNS.dontCallTrigger); executeControlChange(ctrlPropreties.classPath); executeSkipChange(ctrlPropreties); setTableRowNotEmptyClass($control, ctrlPropreties); return; }else{ fvDataNS.ignoreLostFocus = false; } }).blur(function(event){ verifyDuplicatesTableControl($(this), ctrlPropreties); //var ctrlValue = getValueOrEmpty(ctrlPropreties.val); dateValidateError($parent, ctrlPropreties, $control.find('.controlInfMsg'), $control); executeSkipChange(ctrlPropreties); }); if($parent.readOnlyIfConditions != null){ addToCtrlIdRefForReadOnlyIf($parent.isShowReadOnlyIf, $parent.readOnlyIfConditions.value, ctrlPropreties.classPath);; } ctrlPropreties.readOnlyIfcondsExpression = readOnlyIfcondsToExpression($parent.id, $parent.isShowReadOnlyIf, $parent.readOnlyIfConditions); // CO-1931 Verify Time Fields addVerifyTimeCtrlClass($control, ctrlPropreties); // Apply If .. Then .. Else in WebApps GUI (binding events) processBindingIfThenElseActionEvent($parent, ctrlPropreties); // Apply Skip If in WebApps GUI (binding events) processBindingSkipIfActionEvent($parent, ctrlPropreties); // CO-4273: Week Ending Date - New Date Field Setting initWeekEndingDate($parent, $control, ctrlPropreties); // CO-6354: Date Field Month Ending Option initMonthEndingDate($parent, $control, ctrlPropreties); } /*****************************************************************************************************************/ /*End**************************************table inputDate********************************************************/ /*****************************************************************************************************************/ /*****************************************************************************************************************/ /*Start******************************************table inputSelectOne*********************************************/ /*****************************************************************************************************************/ function fvEditorsTableInputSelectOne($parent, $control, ctrlType, ctrlPropreties){ var defaultValue; var showAsDropdown = false; var showAsOnOffSwitch = false; if(isVersion(VERSION_CHOOSE_ONE_SLIDER)) { if($parent.optionKind != undefined && $parent.optionKind.value == CONST_CHOOSE_ONE_SWITCH){ showAsOnOffSwitch = true; var valTrue = CONST_SWITCH_1; var valFalse = CONST_SWITCH_0; switch($parent.switchOption.value){ case CONST_SWITCH_ON_OFF: valTrue = CONST_SWITCH_ON; valFalse = CONST_SWITCH_OFF; break; case CONST_SWITCH_YES_NO: valTrue = CONST_SWITCH_YES; valFalse = CONST_SWITCH_NO; break; case CONST_SWITCH_1_0: valTrue = CONST_SWITCH_1; valFalse = CONST_SWITCH_0; break; case CONST_SWITCH_CUSTOM: valTrue = $parent.switchCustomOn.value; valFalse = $parent.switchCustomOff.value; break; } $parent.options.value = []; $parent.options.value.push({ text: {eng: valTrue}, val: valTrue }); $parent.options.value.push({ text: {eng: valFalse}, val: valFalse }); } } if(!showAsOnOffSwitch){ if($parent.showAsDropdown != undefined && $parent.showAsDropdown.value){ showAsDropdown = $parent.showAsDropdown.value; } if(isVersion(VERSION_DISPLAY_TYPE_FUNCTION)) { if ($parent.displayType && $parent.displayType.value){ if($parent.displayType.value == CONST_DROPDOWN){ showAsDropdown = true; }else{ showAsDropdown = false; } } } } if(ctrlPropreties.val == undefined){ defaultValue = getValueOrEmpty($parent.defaultValue.value); setCtrlPropretiesValue(ctrlPropreties, defaultValue, true); fvEditorsSetDefaultValue(ctrlPropreties); if(fvDataNS.lkDataMap != undefined && fvDataNS.lkDataMap[ctrlPropreties.parentName] != undefined){ var col = fvDataNS.lkDataMap[ctrlPropreties.parentName][ctrlPropreties.id]; if( col != undefined){ if(fvDataNS.lkData[ctrlPropreties.parentName][ctrlPropreties.rowIndex]){ defaultValue = '' + getValueOrEmpty(fvDataNS.lkData[ctrlPropreties.parentName][ctrlPropreties.rowIndex][col]); }else{ defaultValue = ''; } var isSearchUndValue = fvDataNS.lkDataMap[ctrlPropreties.parentName]['isSearchUndValue'] || false; defaultValue = getDestinationValue(defaultValue, isSearchUndValue); // Check if fetching value is valid option - 26799 try { if(defaultValue != ''){ var isUnderly = false; _.each($parent.options.value, function(option, i) { if (option.isShowUnderlying !== undefined){ isUnderly = option.isShowUnderlying; return true; } }); var matched = false; _.each($parent.options.value, function(option, i) { if (isUnderly){ // fetch underly value if(option.val == defaultValue){ matched = true; return true; } } else{ // fetch answer value if(option.text.eng == defaultValue){ defaultValue = option.val; matched = true; return true; } } }); if(!matched){ defaultValue = ''; } } } catch (e) { } setCtrlPropretiesValue(ctrlPropreties, defaultValue, true); } } }else{ defaultValue = ctrlPropreties.val; } // options $optionsList = $control.find('.controlData').empty(); if(showAsOnOffSwitch){ var ctrlId = 'on-off-switch_' + ctrlPropreties.id; var valTrue = CONST_SWITCH_1; var valFalse = CONST_SWITCH_0; switch($parent.switchOption.value){ case CONST_SWITCH_ON_OFF: valTrue = CONST_SWITCH_ON; valFalse = CONST_SWITCH_OFF; break; case CONST_SWITCH_YES_NO: valTrue = CONST_SWITCH_YES; valFalse = CONST_SWITCH_NO; break; case CONST_SWITCH_1_0: valTrue = CONST_SWITCH_1; valFalse = CONST_SWITCH_0; break; case CONST_SWITCH_CUSTOM: valTrue = $parent.switchCustomOn.value; valFalse = $parent.switchCustomOff.value; break; } $selectionList = $('#formview_templates .inputSelectOneOptionOnOffSwitch') .clone() .addClass('inpCtrlID_' + ctrlPropreties.id) .appendTo($optionsList) .off('setLookupValue').on('setLookupValue', function(event, value, isSearchUndValue){ if(!isControlHiddenByRelevance(ctrlPropreties)){ $control.addClass('ignore_focus_by_lu'); setLookupValue($(this), ctrlType, $parent, value, isSearchUndValue, $control, ctrlPropreties); ctrlPropreties.autoAction = false; $(this).change(); } }); var inputCtrl = $optionsList.find('input').attr('id', ctrlId); if(defaultValue == valTrue){ inputCtrl.prop('checked',true); }else{ inputCtrl.prop('checked',false); } // readOnly $control.off('checkAndSetReadOnly').on('checkAndSetReadOnly', function() { if(isReadOnlyApply($parent) || ctrlPropreties.isCtrlReadOnly == true){ $control.find('.controlData input').prop('disabled', true); $control.find('.inputSelectOneOption').addClass('ctrlReadOnly'); } else { $control.find('.controlData input').prop('disabled', false); $control.find('.inputSelectOneOption').removeClass('ctrlReadOnly'); } }); $control.trigger('checkAndSetReadOnly', $parent); var activeSliderColor = getActiveSliderColor($parent); new DG.OnOffSwitch({ inputEl: $optionsList.find('#' + ctrlId), trackColorOn: activeSliderColor, trackColorOff: 'gray', height: 16, isReadOnly: isReadOnlyApply($parent), listener:function(name, checked){ var value = ''; if(checked){ value = valTrue; }else{ value = valFalse; } setCtrlPropretiesValue(ctrlPropreties, value); executeControlChange(ctrlPropreties.classPath); executeSkipChange(ctrlPropreties); if(!$control.hasClass('ignore_focus') && !$control.hasClass('ignore_focus_by_lu')){ fvCtrlFocus($control, false); }else{ $control.removeClass('ignore_focus_by_lu'); } ctrlPropreties.autoAction = false; setTableRowNotEmptyClass($control, ctrlPropreties); ctrlPropreties.dataChangedByUser = true; } }); $control.off('clearData').on('clearData', function(event, setDefaultValue){ var $ctrl = $(this).find('select'); var defaultValueTmp = CONST_SWITCH_0; var valTrue = CONST_SWITCH_1; var valFalse = CONST_SWITCH_0; if(setDefaultValue){ defaultValueTmp = getValueOrEmpty($parent.defaultValue.value); }else{ switch($parent.switchOption.value){ case CONST_SWITCH_ON_OFF: valTrue = CONST_SWITCH_ON; valFalse = CONST_SWITCH_OFF; break; case CONST_SWITCH_YES_NO: valTrue = CONST_SWITCH_YES; valFalse = CONST_SWITCH_NO; break; case CONST_SWITCH_1_0: valTrue = CONST_SWITCH_1; valFalse = CONST_SWITCH_0; break; case CONST_SWITCH_CUSTOM: valTrue = $parent.switchCustomOn.value; valFalse = $parent.switchCustomOff.value; break; } defaultValueTmp = valFalse; } switch(defaultValueTmp){ case valTrue: if(!$control.find('input').is(':checked')){ ctrlPropreties.val = value; $control.find('input').prop('checked',true).change(); } break; case valFalse: if($control.find('input').is(':checked')){ ctrlPropreties.val = value; $control.find('input').prop('checked',false).change(); } break; } executeControlChange(ctrlPropreties.classPath); }); $control.off('Control_Update').on('Control_Update', function(event){ event.stopPropagation(); if(fvDataNS.dontCallTrigger) return; return controlUpdate($parent, ctrlPropreties); }); }else if(showAsDropdown){ $selectionList = $('#formview_templates .inputSelectOneOptionDropdown') .clone() .appendTo($optionsList); $selectionList = $selectionList.find('select'); $selectionList .addClass('inpCtrlID_' + ctrlPropreties.id) .appendTo($optionsList) .off('setLookupValue').on('setLookupValue', function(event, value, isSearchUndValue){ if(!isControlHiddenByRelevance(ctrlPropreties)){ setLookupValue($(this), ctrlType, $parent, value, isSearchUndValue, $control); } }); if($parent.isAllowUncheck && $parent.isAllowUncheck.value){ $('