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 == 'profile_users_' || sField == 'profile_groups_') { $oField.select2('open'); } else { $oField[0].focus(); } return true; } return false; } // scSetFocusOnField function scEventControl_init(iSeqRow) { scEventControl_data["profile_id_" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["profile_name_" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["profile_users_" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["profile_groups_" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["profile_public_" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; } function scEventControl_active(iSeqRow) { if (scEventControl_data["profile_id_" + iSeqRow] && scEventControl_data["profile_id_" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["profile_id_" + iSeqRow] && scEventControl_data["profile_id_" + iSeqRow]["change"]) { return true; } if (scEventControl_data["profile_name_" + iSeqRow] && scEventControl_data["profile_name_" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["profile_name_" + iSeqRow] && scEventControl_data["profile_name_" + iSeqRow]["change"]) { return true; } if (scEventControl_data["profile_users_" + iSeqRow] && scEventControl_data["profile_users_" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["profile_users_" + iSeqRow] && scEventControl_data["profile_users_" + iSeqRow]["change"]) { return true; } if (scEventControl_data["profile_groups_" + iSeqRow] && scEventControl_data["profile_groups_" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["profile_groups_" + iSeqRow] && scEventControl_data["profile_groups_" + iSeqRow]["change"]) { return true; } if (scEventControl_data["profile_public_" + iSeqRow] && scEventControl_data["profile_public_" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["profile_public_" + iSeqRow] && scEventControl_data["profile_public_" + 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; if ("profile_users_" + iSeq == fieldName) { scEventControl_data[fieldName]["blur"] = false; } if ("profile_groups_" + 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_profile_id_' + iSeqRow).bind('blur', function() { sc_notif_form_notif_profiles_profile_id__onblur('#id_sc_field_profile_id_' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_notif_form_notif_profiles_profile_id__onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_notif_form_notif_profiles_profile_id__onfocus(this, iSeqRow, event) }); $('#id_sc_field_profile_name_' + iSeqRow).bind('blur', function() { sc_notif_form_notif_profiles_profile_name__onblur('#id_sc_field_profile_name_' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_notif_form_notif_profiles_profile_name__onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_notif_form_notif_profiles_profile_name__onfocus(this, iSeqRow, event) }); $('#id_sc_field_profile_users_' + iSeqRow).bind('select2:close', function() { sc_notif_form_notif_profiles_profile_users__onblur('#id_sc_field_profile_users_' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_notif_form_notif_profiles_profile_users__onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_notif_form_notif_profiles_profile_users__onfocus(this, iSeqRow, event) }); $('#id_sc_field_profile_groups_' + iSeqRow).bind('select2:close', function() { sc_notif_form_notif_profiles_profile_groups__onblur('#id_sc_field_profile_groups_' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_notif_form_notif_profiles_profile_groups__onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_notif_form_notif_profiles_profile_groups__onfocus(this, iSeqRow, event) }); $('#id_sc_field_profile_public_' + iSeqRow).bind('blur', function() { sc_notif_form_notif_profiles_profile_public__onblur('#id_sc_field_profile_public_' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_notif_form_notif_profiles_profile_public__onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_notif_form_notif_profiles_profile_public__onfocus(this, iSeqRow, event) }); $('#id_sc_field_profile_owner_' + iSeqRow).bind('change', function() { sc_notif_form_notif_profiles_profile_owner__onchange(this, iSeqRow, event) }); $('.sc-ui-checkbox-profile_public_' + iSeqRow).on('click', function() { scMarkFormAsChanged(); }); } // scJQEventsAdd Upload_Cancel = false; function sc_notif_form_notif_profiles_profile_id__onblur(oThis, iSeqRow, event) { do_ajax_notif_form_notif_profiles_validate_profile_id_(iSeqRow); scCssBlur(oThis, iSeqRow); } function sc_notif_form_notif_profiles_profile_id__onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); nm_check_insert(iSeqRow); } function sc_notif_form_notif_profiles_profile_id__onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis, iSeqRow); } function sc_notif_form_notif_profiles_profile_name__onblur(oThis, iSeqRow, event) { do_ajax_notif_form_notif_profiles_validate_profile_name_(iSeqRow); scCssBlur(oThis, iSeqRow); } function sc_notif_form_notif_profiles_profile_name__onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); nm_check_insert(iSeqRow); } function sc_notif_form_notif_profiles_profile_name__onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis, iSeqRow); } function sc_notif_form_notif_profiles_profile_users__onblur(oThis, iSeqRow, event) { do_ajax_notif_form_notif_profiles_validate_profile_users_(iSeqRow); scCssBlur(oThis, iSeqRow); } function sc_notif_form_notif_profiles_profile_users__onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); nm_check_insert(iSeqRow); } function sc_notif_form_notif_profiles_profile_users__onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis, iSeqRow); } function sc_notif_form_notif_profiles_profile_groups__onblur(oThis, iSeqRow, event) { do_ajax_notif_form_notif_profiles_validate_profile_groups_(iSeqRow); scCssBlur(oThis, iSeqRow); } function sc_notif_form_notif_profiles_profile_groups__onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); nm_check_insert(iSeqRow); } function sc_notif_form_notif_profiles_profile_groups__onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis, iSeqRow); } function sc_notif_form_notif_profiles_profile_public__onblur(oThis, iSeqRow, event) { do_ajax_notif_form_notif_profiles_validate_profile_public_(iSeqRow); scCssBlur(oThis, iSeqRow); } function sc_notif_form_notif_profiles_profile_public__onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); nm_check_insert(iSeqRow); } function sc_notif_form_notif_profiles_profile_public__onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis, iSeqRow); } function sc_notif_form_notif_profiles_profile_owner__onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function displayChange_block(block, status) { if ("0" == block) { displayChange_block_0(status); } } function displayChange_block_0(status) { displayChange_field("profile_id_", "", status); displayChange_field("profile_name_", "", status); displayChange_field("profile_users_", "", status); displayChange_field("profile_groups_", "", status); displayChange_field("profile_public_", "", status); } function displayChange_row(row, status) { displayChange_field_profile_id_(row, status); displayChange_field_profile_name_(row, status); displayChange_field_profile_users_(row, status); displayChange_field_profile_groups_(row, status); displayChange_field_profile_public_(row, status); } function displayChange_field(field, row, status) { if ("profile_id_" == field) { displayChange_field_profile_id_(row, status); } if ("profile_name_" == field) { displayChange_field_profile_name_(row, status); } if ("profile_users_" == field) { displayChange_field_profile_users_(row, status); } if ("profile_groups_" == field) { displayChange_field_profile_groups_(row, status); } if ("profile_public_" == field) { displayChange_field_profile_public_(row, status); } } function displayChange_field_profile_id_(row, status) { var fieldId; } function displayChange_field_profile_name_(row, status) { var fieldId; } function displayChange_field_profile_users_(row, status) { var fieldId; if ("on" == status) { Ctrl_Disabled = false; if ("all" == row) { var fieldList = $(".css_profile_users___obj"); for (var i = 0; i < fieldList.length; i++) { $($(fieldList[i]).attr("id")).select2("destroy"); } } else { if ($('#select2-id_sc_field_profile_users_' + row + '-container').hasClass('scFormInputDisabledMult')) { Ctrl_Disabled = true; } $("#id_sc_field_profile_users_" + row).select2("destroy"); } scJQSelect2Add(row, "profile_users_"); if (Ctrl_Disabled) { $('#select2-id_sc_field_profile_users_' + row + '-container').addClass('scFormInputDisabledMult') } } } function displayChange_field_profile_groups_(row, status) { var fieldId; if ("on" == status) { Ctrl_Disabled = false; if ("all" == row) { var fieldList = $(".css_profile_groups___obj"); for (var i = 0; i < fieldList.length; i++) { $($(fieldList[i]).attr("id")).select2("destroy"); } } else { if ($('#select2-id_sc_field_profile_groups_' + row + '-container').hasClass('scFormInputDisabledMult')) { Ctrl_Disabled = true; } $("#id_sc_field_profile_groups_" + row).select2("destroy"); } scJQSelect2Add(row, "profile_groups_"); if (Ctrl_Disabled) { $('#select2-id_sc_field_profile_groups_' + row + '-container').addClass('scFormInputDisabledMult') } } } function displayChange_field_profile_public_(row, status) { var fieldId; } function scRecreateSelect2() { displayChange_field_profile_users_("all", "on"); displayChange_field_profile_groups_("all", "on"); } function scResetPagesDisplay() { $(".sc-form-page").show(); } function scHidePage(pageNo) { $("#id_notif_form_notif_profiles_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(36); } } }