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["description_" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["hours_" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["price_" + 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["description_" + iSeqRow] && scEventControl_data["description_" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["description_" + iSeqRow] && scEventControl_data["description_" + iSeqRow]["change"]) { return true; } if (scEventControl_data["hours_" + iSeqRow] && scEventControl_data["hours_" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["hours_" + iSeqRow] && scEventControl_data["hours_" + iSeqRow]["change"]) { return true; } if (scEventControl_data["price_" + iSeqRow] && scEventControl_data["price_" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["price_" + iSeqRow] && scEventControl_data["price_" + 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_package_id_' + iSeqRow).bind('change', function() { sc_form_development_packages_package_id__onchange(this, iSeqRow, event) }); $('#id_sc_field_name_' + iSeqRow).bind('blur', function() { setTimeout(function() {sc_form_development_packages_name__onblur('#id_sc_field_name_' + iSeqRow, iSeqRow, event);}, 300) }) .bind('change', function() { sc_form_development_packages_name__onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_development_packages_name__onfocus(this, iSeqRow, event) }); $('#id_sc_field_hours_' + iSeqRow).bind('blur', function() { setTimeout(function() {sc_form_development_packages_hours__onblur('#id_sc_field_hours_' + iSeqRow, iSeqRow, event);}, 300) }) .bind('change', function() { sc_form_development_packages_hours__onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_development_packages_hours__onfocus(this, iSeqRow, event) }); $('#id_sc_field_price_' + iSeqRow).bind('blur', function() { sc_form_development_packages_price__onblur('#id_sc_field_price_' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_development_packages_price__onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_development_packages_price__onfocus(this, iSeqRow, event) }); $('#id_sc_field_description_' + iSeqRow).bind('blur', function() { sc_form_development_packages_description__onblur('#id_sc_field_description_' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_development_packages_description__onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_development_packages_description__onfocus(this, iSeqRow, event) }); $('#id_sc_field_enabled_' + iSeqRow).bind('blur', function() { sc_form_development_packages_enabled__onblur('#id_sc_field_enabled_' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_development_packages_enabled__onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_development_packages_enabled__onfocus(this, iSeqRow, event) }); $('.sc-ui-checkbox-enabled_' + iSeqRow).on('click', function() { scMarkFormAsChanged(); }); } // scJQEventsAdd Upload_Cancel = false; function sc_form_development_packages_package_id__onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_development_packages_name__onblur(oThis, iSeqRow, event) { do_ajax_form_development_packages_validate_name_(iSeqRow); scCssBlur(oThis, iSeqRow); } function sc_form_development_packages_name__onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); nm_check_insert(iSeqRow); } function sc_form_development_packages_name__onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis, iSeqRow); } function sc_form_development_packages_hours__onblur(oThis, iSeqRow, event) { do_ajax_form_development_packages_validate_hours_(iSeqRow); scCssBlur(oThis, iSeqRow); } function sc_form_development_packages_hours__onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); nm_check_insert(iSeqRow); } function sc_form_development_packages_hours__onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis, iSeqRow); } function sc_form_development_packages_price__onblur(oThis, iSeqRow, event) { do_ajax_form_development_packages_validate_price_(iSeqRow); scCssBlur(oThis, iSeqRow); } function sc_form_development_packages_price__onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); nm_check_insert(iSeqRow); } function sc_form_development_packages_price__onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis, iSeqRow); } function sc_form_development_packages_description__onblur(oThis, iSeqRow, event) { do_ajax_form_development_packages_validate_description_(iSeqRow); scCssBlur(oThis, iSeqRow); } function sc_form_development_packages_description__onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); nm_check_insert(iSeqRow); } function sc_form_development_packages_description__onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis, iSeqRow); } function sc_form_development_packages_enabled__onblur(oThis, iSeqRow, event) { do_ajax_form_development_packages_validate_enabled_(iSeqRow); scCssBlur(oThis, iSeqRow); } function sc_form_development_packages_enabled__onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); nm_check_insert(iSeqRow); } function sc_form_development_packages_enabled__onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis, iSeqRow); } 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("description_", "", status); displayChange_field("hours_", "", status); displayChange_field("price_", "", status); } function displayChange_row(row, status) { displayChange_field_enabled_(row, status); displayChange_field_name_(row, status); displayChange_field_description_(row, status); displayChange_field_hours_(row, status); displayChange_field_price_(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 ("description_" == field) { displayChange_field_description_(row, status); } if ("hours_" == field) { displayChange_field_hours_(row, status); } if ("price_" == field) { displayChange_field_price_(row, status); } } function displayChange_field_enabled_(row, status) { var fieldId; } function displayChange_field_name_(row, status) { var fieldId; } function displayChange_field_description_(row, status) { var fieldId; } function displayChange_field_hours_(row, status) { var fieldId; } function displayChange_field_price_(row, status) { var fieldId; } function scRecreateSelect2() { } function scResetPagesDisplay() { $(".sc-form-page").show(); } function scHidePage(pageNo) { $("#id_form_development_packages_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); } } }