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["company" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["country" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["email" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["first_name" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["job_title" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["last_name" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["mobile" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["notes" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["phone" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["source" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; } function scEventControl_active(iSeqRow) { if (scEventControl_data["company" + iSeqRow] && scEventControl_data["company" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["company" + iSeqRow] && scEventControl_data["company" + iSeqRow]["change"]) { return true; } if (scEventControl_data["country" + iSeqRow] && scEventControl_data["country" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["country" + iSeqRow] && scEventControl_data["country" + iSeqRow]["change"]) { return true; } if (scEventControl_data["email" + iSeqRow] && scEventControl_data["email" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["email" + iSeqRow] && scEventControl_data["email" + iSeqRow]["change"]) { return true; } if (scEventControl_data["first_name" + iSeqRow] && scEventControl_data["first_name" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["first_name" + iSeqRow] && scEventControl_data["first_name" + iSeqRow]["change"]) { return true; } if (scEventControl_data["job_title" + iSeqRow] && scEventControl_data["job_title" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["job_title" + iSeqRow] && scEventControl_data["job_title" + iSeqRow]["change"]) { return true; } if (scEventControl_data["last_name" + iSeqRow] && scEventControl_data["last_name" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["last_name" + iSeqRow] && scEventControl_data["last_name" + iSeqRow]["change"]) { return true; } if (scEventControl_data["mobile" + iSeqRow] && scEventControl_data["mobile" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["mobile" + iSeqRow] && scEventControl_data["mobile" + 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["phone" + iSeqRow] && scEventControl_data["phone" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["phone" + iSeqRow] && scEventControl_data["phone" + iSeqRow]["change"]) { return true; } if (scEventControl_data["source" + iSeqRow] && scEventControl_data["source" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["source" + iSeqRow] && scEventControl_data["source" + 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_company' + iSeqRow).bind('blur', function() { sc_contact_company_onblur('#id_sc_field_company' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_contact_company_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_contact_company_onfocus(this, iSeqRow, event) }); $('#id_sc_field_country' + iSeqRow).bind('blur', function() { sc_contact_country_onblur('#id_sc_field_country' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_contact_country_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_contact_country_onfocus(this, iSeqRow, event) }); $('#id_sc_field_email' + iSeqRow).bind('blur', function() { sc_contact_email_onblur('#id_sc_field_email' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_contact_email_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_contact_email_onfocus(this, iSeqRow, event) }); $('#id_sc_field_first_name' + iSeqRow).bind('blur', function() { sc_contact_first_name_onblur('#id_sc_field_first_name' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_contact_first_name_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_contact_first_name_onfocus(this, iSeqRow, event) }); $('#id_sc_field_job_title' + iSeqRow).bind('blur', function() { sc_contact_job_title_onblur('#id_sc_field_job_title' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_contact_job_title_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_contact_job_title_onfocus(this, iSeqRow, event) }); $('#id_sc_field_last_name' + iSeqRow).bind('blur', function() { sc_contact_last_name_onblur('#id_sc_field_last_name' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_contact_last_name_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_contact_last_name_onfocus(this, iSeqRow, event) }); $('#id_sc_field_mobile' + iSeqRow).bind('blur', function() { sc_contact_mobile_onblur('#id_sc_field_mobile' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_contact_mobile_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_contact_mobile_onfocus(this, iSeqRow, event) }); $('#id_sc_field_notes' + iSeqRow).bind('blur', function() { sc_contact_notes_onblur('#id_sc_field_notes' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_contact_notes_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_contact_notes_onfocus(this, iSeqRow, event) }); $('#id_sc_field_phone' + iSeqRow).bind('blur', function() { sc_contact_phone_onblur('#id_sc_field_phone' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_contact_phone_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_contact_phone_onfocus(this, iSeqRow, event) }); $('#id_sc_field_source' + iSeqRow).bind('blur', function() { sc_contact_source_onblur('#id_sc_field_source' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_contact_source_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_contact_source_onfocus(this, iSeqRow, event) }); } // scJQEventsAdd Upload_Cancel = false; function sc_contact_company_onblur(oThis, iSeqRow, event) { do_ajax_contact_validate_company(); scCssBlur(oThis); } function sc_contact_company_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_contact_company_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_contact_country_onblur(oThis, iSeqRow, event) { do_ajax_contact_validate_country(); scCssBlur(oThis); } function sc_contact_country_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_contact_country_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_contact_email_onblur(oThis, iSeqRow, event) { do_ajax_contact_validate_email(); scCssBlur(oThis); } function sc_contact_email_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_contact_email_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_contact_first_name_onblur(oThis, iSeqRow, event) { do_ajax_contact_validate_first_name(); scCssBlur(oThis); } function sc_contact_first_name_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_contact_first_name_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_contact_job_title_onblur(oThis, iSeqRow, event) { do_ajax_contact_validate_job_title(); scCssBlur(oThis); } function sc_contact_job_title_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_contact_job_title_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_contact_last_name_onblur(oThis, iSeqRow, event) { do_ajax_contact_validate_last_name(); scCssBlur(oThis); } function sc_contact_last_name_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_contact_last_name_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_contact_mobile_onblur(oThis, iSeqRow, event) { do_ajax_contact_validate_mobile(); scCssBlur(oThis); } function sc_contact_mobile_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_contact_mobile_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_contact_notes_onblur(oThis, iSeqRow, event) { do_ajax_contact_validate_notes(); scCssBlur(oThis); } function sc_contact_notes_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_contact_notes_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_contact_phone_onblur(oThis, iSeqRow, event) { do_ajax_contact_validate_phone(); scCssBlur(oThis); } function sc_contact_phone_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_contact_phone_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_contact_source_onblur(oThis, iSeqRow, event) { do_ajax_contact_validate_source(); scCssBlur(oThis); } function sc_contact_source_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_contact_source_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("company", "", status); displayChange_field("country", "", status); displayChange_field("email", "", status); displayChange_field("first_name", "", status); displayChange_field("job_title", "", status); displayChange_field("last_name", "", status); displayChange_field("mobile", "", status); displayChange_field("notes", "", status); displayChange_field("phone", "", status); displayChange_field("source", "", status); } function displayChange_row(row, status) { displayChange_field_company(row, status); displayChange_field_country(row, status); displayChange_field_email(row, status); displayChange_field_first_name(row, status); displayChange_field_job_title(row, status); displayChange_field_last_name(row, status); displayChange_field_mobile(row, status); displayChange_field_notes(row, status); displayChange_field_phone(row, status); displayChange_field_source(row, status); } function displayChange_field(field, row, status) { if ("company" == field) { displayChange_field_company(row, status); } if ("country" == field) { displayChange_field_country(row, status); } if ("email" == field) { displayChange_field_email(row, status); } if ("first_name" == field) { displayChange_field_first_name(row, status); } if ("job_title" == field) { displayChange_field_job_title(row, status); } if ("last_name" == field) { displayChange_field_last_name(row, status); } if ("mobile" == field) { displayChange_field_mobile(row, status); } if ("notes" == field) { displayChange_field_notes(row, status); } if ("phone" == field) { displayChange_field_phone(row, status); } if ("source" == field) { displayChange_field_source(row, status); } } function displayChange_field_company(row, status) { var fieldId; } function displayChange_field_country(row, status) { var fieldId; } function displayChange_field_email(row, status) { var fieldId; } function displayChange_field_first_name(row, status) { var fieldId; } function displayChange_field_job_title(row, status) { var fieldId; } function displayChange_field_last_name(row, status) { var fieldId; } function displayChange_field_mobile(row, status) { var fieldId; } function displayChange_field_notes(row, status) { var fieldId; } function displayChange_field_phone(row, status) { var fieldId; } function displayChange_field_source(row, status) { var fieldId; } function scRecreateSelect2() { } function scResetPagesDisplay() { $(".sc-form-page").show(); } function scHidePage(pageNo) { $("#id_contact_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(18); } } } function scJQUploadAdd(iSeqRow) { } // scJQUploadAdd var api_cache_requests = []; function ajax_check_file(img_name, field ,t, p, p_cache, iSeqRow, hasRun, img_before){ setTimeout(function(){ if(img_name == '') return; iSeqRow= iSeqRow !== undefined && iSeqRow !== null ? iSeqRow : ''; var hasVar = p.indexOf('_@NM@_') > -1 || p_cache.indexOf('_@NM@_') > -1 ? true : false; p = p.split('_@NM@_'); $.each(p, function(i,v){ try{ p[i] = $('[name='+v+iSeqRow+']').val(); } catch(err){ p[i] = v; } }); p = p.join(''); p_cache = p_cache.split('_@NM@_'); $.each(p_cache, function(i,v){ try{ p_cache[i] = $('[name='+v+iSeqRow+']').val(); } catch(err){ p_cache[i] = v; } }); p_cache = p_cache.join(''); img_before = img_before !== undefined ? img_before : $(t).attr('src'); var str_key_cache = '