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) { $oField[0].focus(); return true; } return false; } // scSetFocusOnField function scEventControl_init(iSeqRow) { scEventControl_data["setting_key_" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["setting_value_" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["description_" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["setting_id_" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; } function scEventControl_active(iSeqRow) { if (scEventControl_data["setting_key_" + iSeqRow] && scEventControl_data["setting_key_" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["setting_key_" + iSeqRow] && scEventControl_data["setting_key_" + iSeqRow]["change"]) { return true; } if (scEventControl_data["setting_value_" + iSeqRow] && scEventControl_data["setting_value_" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["setting_value_" + iSeqRow] && scEventControl_data["setting_value_" + iSeqRow]["change"]) { return true; } if (scEventControl_data["description_" + iSeqRow] && scEventControl_data["description_" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["description_" + iSeqRow] && scEventControl_data["description_" + iSeqRow]["change"]) { return true; } if (scEventControl_data["setting_id_" + iSeqRow] && scEventControl_data["setting_id_" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["setting_id_" + iSeqRow] && scEventControl_data["setting_id_" + iSeqRow]["change"]) { return true; } return false; } // scEventControl_active function scEventControl_active_all() { for (var i = 1; i < iAjaxNewLine; i++) { if (scEventControl_active(i)) { 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; 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_setting_id_' + iSeqRow).bind('blur', function() { sc_form_app_settings_setting_id__onblur('#id_sc_field_setting_id_' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_app_settings_setting_id__onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_app_settings_setting_id__onfocus(this, iSeqRow, event) }); $('#id_sc_field_setting_key_' + iSeqRow).bind('blur', function() { sc_form_app_settings_setting_key__onblur('#id_sc_field_setting_key_' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_app_settings_setting_key__onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_app_settings_setting_key__onfocus(this, iSeqRow, event) }); $('#id_sc_field_setting_value_' + iSeqRow).bind('blur', function() { sc_form_app_settings_setting_value__onblur('#id_sc_field_setting_value_' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_app_settings_setting_value__onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_app_settings_setting_value__onfocus(this, iSeqRow, event) }); $('#id_sc_field_description_' + iSeqRow).bind('blur', function() { sc_form_app_settings_description__onblur('#id_sc_field_description_' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_app_settings_description__onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_app_settings_description__onfocus(this, iSeqRow, event) }); $('#id_sc_field_updated_at_' + iSeqRow).bind('change', function() { sc_form_app_settings_updated_at__onchange(this, iSeqRow, event) }); $('#id_sc_field_updated_at__hora' + iSeqRow).bind('change', function() { sc_form_app_settings_updated_at__hora_onchange(this, iSeqRow, event) }); $('#id_sc_field_updated_by_' + iSeqRow).bind('change', function() { sc_form_app_settings_updated_by__onchange(this, iSeqRow, event) }); } // scJQEventsAdd Upload_Cancel = false; function sc_form_app_settings_setting_id__onblur(oThis, iSeqRow, event) { do_ajax_form_app_settings_validate_setting_id_(iSeqRow); scCssBlur(oThis, iSeqRow); } function sc_form_app_settings_setting_id__onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); nm_check_insert(iSeqRow); } function sc_form_app_settings_setting_id__onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis, iSeqRow); } function sc_form_app_settings_setting_key__onblur(oThis, iSeqRow, event) { do_ajax_form_app_settings_validate_setting_key_(iSeqRow); scCssBlur(oThis, iSeqRow); } function sc_form_app_settings_setting_key__onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); nm_check_insert(iSeqRow); } function sc_form_app_settings_setting_key__onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis, iSeqRow); } function sc_form_app_settings_setting_value__onblur(oThis, iSeqRow, event) { do_ajax_form_app_settings_validate_setting_value_(iSeqRow); scCssBlur(oThis, iSeqRow); } function sc_form_app_settings_setting_value__onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); nm_check_insert(iSeqRow); } function sc_form_app_settings_setting_value__onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis, iSeqRow); } function sc_form_app_settings_description__onblur(oThis, iSeqRow, event) { do_ajax_form_app_settings_validate_description_(iSeqRow); scCssBlur(oThis, iSeqRow); } function sc_form_app_settings_description__onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); nm_check_insert(iSeqRow); } function sc_form_app_settings_description__onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis, iSeqRow); } function sc_form_app_settings_updated_at__onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_app_settings_updated_at__hora_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_app_settings_updated_by__onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function displayChange_block(block, status) { if ("0" == block) { displayChange_block_0(status); } } function displayChange_block_0(status) { displayChange_field("setting_key_", "", status); displayChange_field("setting_value_", "", status); displayChange_field("description_", "", status); } function displayChange_row(row, status) { displayChange_field_setting_key_(row, status); displayChange_field_setting_value_(row, status); displayChange_field_description_(row, status); displayChange_field_setting_id_(row, status); } function displayChange_field(field, row, status) { if ("setting_key_" == field) { displayChange_field_setting_key_(row, status); } if ("setting_value_" == field) { displayChange_field_setting_value_(row, status); } if ("description_" == field) { displayChange_field_description_(row, status); } if ("setting_id_" == field) { displayChange_field_setting_id_(row, status); } } function displayChange_field_setting_key_(row, status) { var fieldId; } function displayChange_field_setting_value_(row, status) { var fieldId; } function displayChange_field_description_(row, status) { var fieldId; } function displayChange_field_setting_id_(row, status) { var fieldId; } function scRecreateSelect2() { } function scResetPagesDisplay() { $(".sc-form-page").show(); } function scHidePage(pageNo) { $("#id_form_app_settings_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(28); } } }