function scJQGeneralAdd() { scLoadScInput('input:text.sc-js-input'); scLoadScInput('input:password.sc-js-input'); scLoadScInput('input:checkbox.sc-js-input'); scLoadScInput('input:radio.sc-js-input'); scLoadScInput('select.sc-js-input'); scLoadScInput('textarea.sc-js-input'); } // scJQGeneralAdd function scFocusField(sField) { var $oField = $('#id_sc_field_' + sField); if (0 == $oField.length) { $oField = $('input[name=' + sField + ']'); } if (0 == $oField.length && document.F1.elements[sField]) { $oField = $(document.F1.elements[sField]); } if ($("#id_ac_" + sField).length > 0) { if ($oField.hasClass("select2-hidden-accessible")) { if (false == scSetFocusOnField($oField, sField)) { setTimeout(function() { scSetFocusOnField($oField, sField); }, 500); } } else { if (false == scSetFocusOnField($oField, sField)) { if (false == scSetFocusOnField($("#id_ac_" + sField, sField))) { setTimeout(function() { scSetFocusOnField($("#id_ac_" + sField, sField)); }, 500); } } else { setTimeout(function() { scSetFocusOnField($oField, sField); }, 500); } } } else { setTimeout(function() { scSetFocusOnField($oField, sField); }, 500); } } // scFocusField function scSetFocusOnField($oField, sField) { if ($oField.length > 0 && $oField[0].offsetHeight > 0 && $oField[0].offsetWidth > 0 && !$oField[0].disabled) { if (sField == 'client_id' || sField == 'ctype_id') { $oField.select2('open'); } else { $oField[0].focus(); } return true; } return false; } // scSetFocusOnField function scEventControl_init(iSeqRow) { scEventControl_data["enabled" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["status" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["client_id" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["scheduled_date" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["ctype_id" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["meeting_link" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["notes" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["outcome" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["follow_up_date" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; } function scEventControl_active(iSeqRow) { if (scEventControl_data["enabled" + iSeqRow] && scEventControl_data["enabled" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["enabled" + iSeqRow] && scEventControl_data["enabled" + iSeqRow]["change"]) { return true; } if (scEventControl_data["status" + iSeqRow] && scEventControl_data["status" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["status" + iSeqRow] && scEventControl_data["status" + iSeqRow]["change"]) { return true; } if (scEventControl_data["client_id" + iSeqRow] && scEventControl_data["client_id" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["client_id" + iSeqRow] && scEventControl_data["client_id" + iSeqRow]["change"]) { return true; } if (scEventControl_data["scheduled_date" + iSeqRow] && scEventControl_data["scheduled_date" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["scheduled_date" + iSeqRow] && scEventControl_data["scheduled_date" + iSeqRow]["change"]) { return true; } if (scEventControl_data["ctype_id" + iSeqRow] && scEventControl_data["ctype_id" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["ctype_id" + iSeqRow] && scEventControl_data["ctype_id" + iSeqRow]["change"]) { return true; } if (scEventControl_data["meeting_link" + iSeqRow] && scEventControl_data["meeting_link" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["meeting_link" + iSeqRow] && scEventControl_data["meeting_link" + iSeqRow]["change"]) { return true; } if (scEventControl_data["notes" + iSeqRow] && scEventControl_data["notes" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["notes" + iSeqRow] && scEventControl_data["notes" + iSeqRow]["change"]) { return true; } if (scEventControl_data["outcome" + iSeqRow] && scEventControl_data["outcome" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["outcome" + iSeqRow] && scEventControl_data["outcome" + iSeqRow]["change"]) { return true; } if (scEventControl_data["follow_up_date" + iSeqRow] && scEventControl_data["follow_up_date" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["follow_up_date" + iSeqRow] && scEventControl_data["follow_up_date" + iSeqRow]["change"]) { return true; } return false; } // scEventControl_active function scEventControl_onFocus(oField, iSeq) { var fieldId, fieldName; fieldId = $(oField).attr("id"); fieldName = fieldId.substr(12); scEventControl_data[fieldName]["blur"] = true; if ("client_id" + iSeq == fieldName) { scEventControl_data[fieldName]["blur"] = false; } if ("ctype_id" + iSeq == fieldName) { scEventControl_data[fieldName]["blur"] = false; } scEventControl_data[fieldName]["change"] = false; } // scEventControl_onFocus function scEventControl_onBlur(sFieldName) { scEventControl_data[sFieldName]["blur"] = false; if (scEventControl_data[sFieldName]["change"]) { if (scEventControl_data[sFieldName]["original"] == $("#id_sc_field_" + sFieldName).val() || scEventControl_data[sFieldName]["calculated"] == $("#id_sc_field_" + sFieldName).val()) { scEventControl_data[sFieldName]["change"] = false; } } } // scEventControl_onBlur function scEventControl_onChange(sFieldName) { scEventControl_data[sFieldName]["change"] = false; } // scEventControl_onChange function scEventControl_onAutocomp(sFieldName) { scEventControl_data[sFieldName]["autocomp"] = false; } // scEventControl_onChange var scEventControl_data = {}; function scJQEventsAdd(iSeqRow) { $('#id_sc_field_client_id' + iSeqRow).bind('select2:close', function() { sc_form_consultations_client_id_onblur('#id_sc_field_client_id' + iSeqRow, iSeqRow, event) }) .bind('focus', function() { sc_form_consultations_client_id_onfocus(this, iSeqRow, event) }); $('#id_sc_field_ctype_id' + iSeqRow).bind('select2:close', function() { sc_form_consultations_ctype_id_onblur('#id_sc_field_ctype_id' + iSeqRow, iSeqRow, event) }) .bind('focus', function() { sc_form_consultations_ctype_id_onfocus(this, iSeqRow, event) }); $('#id_sc_field_scheduled_date' + iSeqRow).bind('blur', function() { setTimeout(function() {sc_form_consultations_scheduled_date_onblur('#id_sc_field_scheduled_date' + iSeqRow, iSeqRow, event);}, 300) }) .bind('focus', function() { sc_form_consultations_scheduled_date_onfocus(this, iSeqRow, event) }); $('#id_sc_field_scheduled_date_hora' + iSeqRow).bind('blur', function() { setTimeout(function() {sc_form_consultations_scheduled_date_onblur('#id_sc_field_scheduled_date' + iSeqRow, iSeqRow, event);}, 300) }) .bind('focus', function() { sc_form_consultations_scheduled_date_onfocus(this, iSeqRow, event) }); $('#id_sc_field_status' + iSeqRow).bind('blur', function() { sc_form_consultations_status_onblur('#id_sc_field_status' + iSeqRow, iSeqRow, event) }) .bind('click', function() { sc_form_consultations_status_onclick(this, iSeqRow, event) }) .bind('focus', function() { sc_form_consultations_status_onfocus(this, iSeqRow, event) }); $('#id_sc_field_meeting_link' + iSeqRow).bind('blur', function() { sc_form_consultations_meeting_link_onblur('#id_sc_field_meeting_link' + iSeqRow, iSeqRow, event) }) .bind('focus', function() { sc_form_consultations_meeting_link_onfocus(this, iSeqRow, event) }); $('#id_sc_field_notes' + iSeqRow).bind('blur', function() { sc_form_consultations_notes_onblur('#id_sc_field_notes' + iSeqRow, iSeqRow, event) }) .bind('focus', function() { sc_form_consultations_notes_onfocus(this, iSeqRow, event) }); $('#id_sc_field_outcome' + iSeqRow).bind('blur', function() { sc_form_consultations_outcome_onblur('#id_sc_field_outcome' + iSeqRow, iSeqRow, event) }) .bind('focus', function() { sc_form_consultations_outcome_onfocus(this, iSeqRow, event) }); $('#id_sc_field_follow_up_date' + iSeqRow).bind('blur', function() { sc_form_consultations_follow_up_date_onblur('#id_sc_field_follow_up_date' + iSeqRow, iSeqRow, event) }) .bind('focus', function() { sc_form_consultations_follow_up_date_onfocus(this, iSeqRow, event) }); $('#id_sc_field_enabled' + iSeqRow).bind('blur', function() { sc_form_consultations_enabled_onblur('#id_sc_field_enabled' + iSeqRow, iSeqRow, event) }) .bind('focus', function() { sc_form_consultations_enabled_onfocus(this, iSeqRow, event) }); $('.sc-ui-checkbox-enabled' + iSeqRow).on('click', function() { scMarkFormAsChanged(); }); $('.sc-ui-radio-status' + iSeqRow).on('click', function() { scMarkFormAsChanged(); }); } // scJQEventsAdd Upload_Cancel = false; function sc_form_consultations_client_id_onblur(oThis, iSeqRow, event) { do_ajax_form_consultations_mob_validate_client_id(); scCssBlur(oThis); } function sc_form_consultations_client_id_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_consultations_ctype_id_onblur(oThis, iSeqRow, event) { do_ajax_form_consultations_mob_validate_ctype_id(); scCssBlur(oThis); } function sc_form_consultations_ctype_id_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_consultations_scheduled_date_onblur(oThis, iSeqRow, event) { do_ajax_form_consultations_mob_validate_scheduled_date(); scCssBlur(oThis); } function sc_form_consultations_scheduled_date_onblur(oThis, iSeqRow, event) { do_ajax_form_consultations_mob_validate_scheduled_date(); scCssBlur(oThis); } function sc_form_consultations_scheduled_date_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_consultations_scheduled_date_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_consultations_status_onblur(oThis, iSeqRow, event) { do_ajax_form_consultations_mob_validate_status(); scCssBlur(oThis); } function sc_form_consultations_status_onclick(oThis, iSeqRow, event) { do_ajax_form_consultations_mob_event_status_onclick(); } function sc_form_consultations_status_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_consultations_meeting_link_onblur(oThis, iSeqRow, event) { do_ajax_form_consultations_mob_validate_meeting_link(); scCssBlur(oThis); } function sc_form_consultations_meeting_link_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_consultations_notes_onblur(oThis, iSeqRow, event) { do_ajax_form_consultations_mob_validate_notes(); scCssBlur(oThis); } function sc_form_consultations_notes_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_consultations_outcome_onblur(oThis, iSeqRow, event) { do_ajax_form_consultations_mob_validate_outcome(); scCssBlur(oThis); } function sc_form_consultations_outcome_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_consultations_follow_up_date_onblur(oThis, iSeqRow, event) { do_ajax_form_consultations_mob_validate_follow_up_date(); scCssBlur(oThis); } function sc_form_consultations_follow_up_date_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_consultations_enabled_onblur(oThis, iSeqRow, event) { do_ajax_form_consultations_mob_validate_enabled(); scCssBlur(oThis); } function sc_form_consultations_enabled_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function displayChange_block(block, status) { if ("0" == block) { displayChange_block_0(status); } if ("1" == block) { displayChange_block_1(status); } } function displayChange_block_0(status) { displayChange_field("enabled", "", status); displayChange_field("status", "", status); displayChange_field("client_id", "", status); displayChange_field("scheduled_date", "", status); displayChange_field("ctype_id", "", status); displayChange_field("meeting_link", "", status); } function displayChange_block_1(status) { displayChange_field("notes", "", status); displayChange_field("outcome", "", status); displayChange_field("follow_up_date", "", status); } function displayChange_row(row, status) { displayChange_field_enabled(row, status); displayChange_field_status(row, status); displayChange_field_client_id(row, status); displayChange_field_scheduled_date(row, status); displayChange_field_ctype_id(row, status); displayChange_field_meeting_link(row, status); displayChange_field_notes(row, status); displayChange_field_outcome(row, status); displayChange_field_follow_up_date(row, status); } function displayChange_field(field, row, status) { if ("enabled" == field) { displayChange_field_enabled(row, status); } if ("status" == field) { displayChange_field_status(row, status); } if ("client_id" == field) { displayChange_field_client_id(row, status); } if ("scheduled_date" == field) { displayChange_field_scheduled_date(row, status); } if ("ctype_id" == field) { displayChange_field_ctype_id(row, status); } if ("meeting_link" == field) { displayChange_field_meeting_link(row, status); } if ("notes" == field) { displayChange_field_notes(row, status); } if ("outcome" == field) { displayChange_field_outcome(row, status); } if ("follow_up_date" == field) { displayChange_field_follow_up_date(row, status); } } function displayChange_field_enabled(row, status) { var fieldId; } function displayChange_field_status(row, status) { var fieldId; } function displayChange_field_client_id(row, status) { var fieldId; if ("on" == status) { Ctrl_Disabled = false; if ("all" == row) { var fieldList = $(".css_client_id__obj"); for (var i = 0; i < fieldList.length; i++) { $($(fieldList[i]).attr("id")).select2("destroy"); } } else { if ($('#select2-id_sc_field_client_id' + row + '-container').hasClass('scFormInputDisabled')) { Ctrl_Disabled = true; } $("#id_sc_field_client_id" + row).select2("destroy"); } scJQSelect2Add(row, "client_id"); if (Ctrl_Disabled) { $('#select2-id_sc_field_client_id' + row + '-container').addClass('scFormInputDisabled') } } } function displayChange_field_scheduled_date(row, status) { var fieldId; } function displayChange_field_ctype_id(row, status) { var fieldId; if ("on" == status) { Ctrl_Disabled = false; if ("all" == row) { var fieldList = $(".css_ctype_id__obj"); for (var i = 0; i < fieldList.length; i++) { $($(fieldList[i]).attr("id")).select2("destroy"); } } else { if ($('#select2-id_sc_field_ctype_id' + row + '-container').hasClass('scFormInputDisabled')) { Ctrl_Disabled = true; } $("#id_sc_field_ctype_id" + row).select2("destroy"); } scJQSelect2Add(row, "ctype_id"); if (Ctrl_Disabled) { $('#select2-id_sc_field_ctype_id' + row + '-container').addClass('scFormInputDisabled') } } } function displayChange_field_meeting_link(row, status) { var fieldId; } function displayChange_field_notes(row, status) { var fieldId; } function displayChange_field_outcome(row, status) { var fieldId; } function displayChange_field_follow_up_date(row, status) { var fieldId; } function scRecreateSelect2() { displayChange_field_client_id("all", "on"); displayChange_field_ctype_id("all", "on"); } function scResetPagesDisplay() { $(".sc-form-page").show(); } function scHidePage(pageNo) { $("#id_form_consultations_mob_form" + pageNo).hide(); } function scCheckNoPageSelected() { if (!$(".sc-form-page").filter(".scTabActive").filter(":visible").length) { var inactiveTabs = $(".sc-form-page").filter(".scTabInactive").filter(":visible"); if (inactiveTabs.length) { var tabNo = $(inactiveTabs[0]).attr("id").substr(33); } } } var sc_jq_calendar_value = {}; function scJQCalendarAdd(iSeqRow) { $("#id_sc_field_scheduled_date" + iSeqRow).datepicker('destroy'); $("#id_sc_field_scheduled_date" + iSeqRow).datepicker({ beforeShow: function(input, inst) { var $oField = $(this), aParts = $oField.val().split(" "), sTime = ""; sc_jq_calendar_value["#id_sc_field_scheduled_date" + iSeqRow] = $oField.val(); if (2 == aParts.length) { sTime = " " + aParts[1]; } if ('' == sTime || ' ' == sTime) { sTime = '