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["enabled" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["name" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["type" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["subject" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["body" + 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["name" + iSeqRow] && scEventControl_data["name" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["name" + iSeqRow] && scEventControl_data["name" + iSeqRow]["change"]) { return true; } if (scEventControl_data["type" + iSeqRow] && scEventControl_data["type" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["type" + iSeqRow] && scEventControl_data["type" + iSeqRow]["change"]) { return true; } if (scEventControl_data["subject" + iSeqRow] && scEventControl_data["subject" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["subject" + iSeqRow] && scEventControl_data["subject" + iSeqRow]["change"]) { return true; } if (scEventControl_data["body" + iSeqRow] && scEventControl_data["body" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["body" + iSeqRow] && scEventControl_data["body" + 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; 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_template_id' + iSeqRow).bind('change', function() { sc_form_message_templates_template_id_onchange(this, iSeqRow, event) }); $('#id_sc_field_name' + iSeqRow).bind('blur', function() { sc_form_message_templates_name_onblur('#id_sc_field_name' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_message_templates_name_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_message_templates_name_onfocus(this, iSeqRow, event) }); $('#id_sc_field_subject' + iSeqRow).bind('blur', function() { sc_form_message_templates_subject_onblur('#id_sc_field_subject' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_message_templates_subject_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_message_templates_subject_onfocus(this, iSeqRow, event) }); $('#id_sc_field_body' + iSeqRow).bind('blur', function() { sc_form_message_templates_body_onblur('#id_sc_field_body' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_message_templates_body_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_message_templates_body_onfocus(this, iSeqRow, event) }); $('#id_sc_field_type' + iSeqRow).bind('blur', function() { sc_form_message_templates_type_onblur('#id_sc_field_type' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_message_templates_type_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_message_templates_type_onfocus(this, iSeqRow, event) }); $('#id_sc_field_enabled' + iSeqRow).bind('blur', function() { sc_form_message_templates_enabled_onblur('#id_sc_field_enabled' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_message_templates_enabled_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_message_templates_enabled_onfocus(this, iSeqRow, event) }); $('.sc-ui-checkbox-enabled' + iSeqRow).on('click', function() { scMarkFormAsChanged(); }); } // scJQEventsAdd Upload_Cancel = false; function sc_form_message_templates_template_id_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_message_templates_name_onblur(oThis, iSeqRow, event) { do_ajax_form_message_templates_validate_name(); scCssBlur(oThis); } function sc_form_message_templates_name_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_message_templates_name_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_message_templates_subject_onblur(oThis, iSeqRow, event) { do_ajax_form_message_templates_validate_subject(); scCssBlur(oThis); } function sc_form_message_templates_subject_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_message_templates_subject_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_message_templates_body_onblur(oThis, iSeqRow, event) { do_ajax_form_message_templates_validate_body(); scCssBlur(oThis); } function sc_form_message_templates_body_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_message_templates_body_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_message_templates_type_onblur(oThis, iSeqRow, event) { do_ajax_form_message_templates_validate_type(); scCssBlur(oThis); } function sc_form_message_templates_type_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_message_templates_type_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_message_templates_enabled_onblur(oThis, iSeqRow, event) { do_ajax_form_message_templates_validate_enabled(); scCssBlur(oThis); } function sc_form_message_templates_enabled_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_message_templates_enabled_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function displayChange_block(block, status) { if ("0" == block) { displayChange_block_0(status); } } function displayChange_block_0(status) { displayChange_field("enabled", "", status); displayChange_field("name", "", status); displayChange_field("type", "", status); displayChange_field("subject", "", status); displayChange_field("body", "", status); } function displayChange_row(row, status) { displayChange_field_enabled(row, status); displayChange_field_name(row, status); displayChange_field_type(row, status); displayChange_field_subject(row, status); displayChange_field_body(row, status); } function displayChange_field(field, row, status) { if ("enabled" == field) { displayChange_field_enabled(row, status); } if ("name" == field) { displayChange_field_name(row, status); } if ("type" == field) { displayChange_field_type(row, status); } if ("subject" == field) { displayChange_field_subject(row, status); } if ("body" == field) { displayChange_field_body(row, status); } } function displayChange_field_enabled(row, status) { var fieldId; } function displayChange_field_name(row, status) { var fieldId; } function displayChange_field_type(row, status) { var fieldId; } function displayChange_field_subject(row, status) { var fieldId; } function displayChange_field_body(row, status) { var fieldId; if ("on" == status) { if ("all" == row) { var fieldList = $(".css_body__obj"); for (var i = 0; i < fieldList.length; i++) { fieldId = $(fieldList[i]).attr("id").substr(12); scAjaxExecFieldEditorHtml('mceRemoveControl', false, fieldId); scAjaxExecFieldEditorHtml('mceAddControl', false, fieldId); } } else { scAjaxExecFieldEditorHtml('mceRemoveControl', false, "body"); scAjaxExecFieldEditorHtml('mceAddControl', false, "body"); } } } function scRecreateSelect2() { } function scResetPagesDisplay() { $(".sc-form-page").show(); } function scHidePage(pageNo) { $("#id_form_message_templates_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 scJQHtmlEditorData = (function() { var data = {}; function scJQHtmlEditorData(a, b) { if (a) { if (typeof(a) === typeof({})) { for (var d in a) { if (a.hasOwnProperty(d)) { data[d] = a[d]; } } } else if ((typeof(a) === typeof('')) || (typeof(a) === typeof(1))) { if (b) { data[a] = b; } else { if (typeof(a) === typeof('')) { var v = data; a = a.split('.'); a.forEach(function (r) { v = v[r]; }); return v; } return data[a]; } } } return data; } return scJQHtmlEditorData; }()); function scJQHtmlEditorAdd(iSeqRow) {