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 ($oField.length > 0) { switch ($oField[0].name) { case 'published_at': case 'views': case 'status': case 'title': case 'category_id': case 'meta_description': case 'slug': case 'featured_image': sc_exib_ocult_pag('form_blog_posts_form0'); break; case 'excerpt': case 'content': sc_exib_ocult_pag('form_blog_posts_form1'); break; } } 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 == 'category_id') { $oField.select2('open'); } else { $oField[0].focus(); } return true; } return false; } // scSetFocusOnField function scEventControl_init(iSeqRow) { scEventControl_data["published_at" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["views" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["status" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["title" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["category_id" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["meta_description" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["slug" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["featured_image" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["excerpt" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["content" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; } function scEventControl_active(iSeqRow) { if (scEventControl_data["published_at" + iSeqRow] && scEventControl_data["published_at" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["published_at" + iSeqRow] && scEventControl_data["published_at" + iSeqRow]["change"]) { return true; } if (scEventControl_data["views" + iSeqRow] && scEventControl_data["views" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["views" + iSeqRow] && scEventControl_data["views" + iSeqRow]["change"]) { return true; } if (scEventControl_data["status" + iSeqRow] && scEventControl_data["status" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["status" + iSeqRow] && scEventControl_data["status" + iSeqRow]["change"]) { return true; } if (scEventControl_data["title" + iSeqRow] && scEventControl_data["title" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["title" + iSeqRow] && scEventControl_data["title" + iSeqRow]["change"]) { return true; } if (scEventControl_data["category_id" + iSeqRow] && scEventControl_data["category_id" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["category_id" + iSeqRow] && scEventControl_data["category_id" + iSeqRow]["change"]) { return true; } if (scEventControl_data["meta_description" + iSeqRow] && scEventControl_data["meta_description" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["meta_description" + iSeqRow] && scEventControl_data["meta_description" + iSeqRow]["change"]) { return true; } if (scEventControl_data["slug" + iSeqRow] && scEventControl_data["slug" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["slug" + iSeqRow] && scEventControl_data["slug" + iSeqRow]["change"]) { return true; } if (scEventControl_data["excerpt" + iSeqRow] && scEventControl_data["excerpt" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["excerpt" + iSeqRow] && scEventControl_data["excerpt" + iSeqRow]["change"]) { return true; } if (scEventControl_data["content" + iSeqRow] && scEventControl_data["content" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["content" + iSeqRow] && scEventControl_data["content" + 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; if ("category_id" + iSeq == fieldName) { scEventControl_data[fieldName]["blur"] = false; } if ("title" + iSeq == fieldName) { scEventControl_data[fieldName]["change"] = true; scEventControl_data[fieldName]["original"] = $(oField).val(); scEventControl_data[fieldName]["calculated"] = $(oField).val(); return; } 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_id' + iSeqRow).bind('change', function() { sc_form_blog_posts_id_onchange(this, iSeqRow, event) }); $('#id_sc_field_title' + iSeqRow).bind('blur', function() { sc_form_blog_posts_title_onblur('#id_sc_field_title' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_blog_posts_title_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_blog_posts_title_onfocus(this, iSeqRow, event) }); $('#id_sc_field_slug' + iSeqRow).bind('blur', function() { sc_form_blog_posts_slug_onblur('#id_sc_field_slug' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_blog_posts_slug_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_blog_posts_slug_onfocus(this, iSeqRow, event) }); $('#id_sc_field_meta_description' + iSeqRow).bind('blur', function() { sc_form_blog_posts_meta_description_onblur('#id_sc_field_meta_description' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_blog_posts_meta_description_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_blog_posts_meta_description_onfocus(this, iSeqRow, event) }); $('#id_sc_field_content' + iSeqRow).bind('blur', function() { sc_form_blog_posts_content_onblur('#id_sc_field_content' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_blog_posts_content_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_blog_posts_content_onfocus(this, iSeqRow, event) }); $('#id_sc_field_excerpt' + iSeqRow).bind('blur', function() { sc_form_blog_posts_excerpt_onblur('#id_sc_field_excerpt' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_blog_posts_excerpt_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_blog_posts_excerpt_onfocus(this, iSeqRow, event) }); $('#id_sc_field_featured_image' + iSeqRow).bind('blur', function() { sc_form_blog_posts_featured_image_onblur('#id_sc_field_featured_image' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_blog_posts_featured_image_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_blog_posts_featured_image_onfocus(this, iSeqRow, event) }); $('#id_sc_field_category_id' + iSeqRow).bind('select2:close', function() { sc_form_blog_posts_category_id_onblur('#id_sc_field_category_id' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_blog_posts_category_id_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_blog_posts_category_id_onfocus(this, iSeqRow, event) }); $('#id_sc_field_status' + iSeqRow).bind('blur', function() { sc_form_blog_posts_status_onblur('#id_sc_field_status' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_blog_posts_status_onchange(this, iSeqRow, event) }) .bind('click', function() { sc_form_blog_posts_status_onclick(this, iSeqRow, event) }) .bind('focus', function() { sc_form_blog_posts_status_onfocus(this, iSeqRow, event) }); $('#id_sc_field_published_at' + iSeqRow).bind('blur', function() { sc_form_blog_posts_published_at_onblur('#id_sc_field_published_at' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_blog_posts_published_at_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_blog_posts_published_at_onfocus(this, iSeqRow, event) }); $('#id_sc_field_published_at_hora' + iSeqRow).bind('blur', function() { sc_form_blog_posts_published_at_hora_onblur('#id_sc_field_published_at' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_blog_posts_published_at_hora_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_blog_posts_published_at_hora_onfocus(this, iSeqRow, event) }); $('#id_sc_field_created_at' + iSeqRow).bind('change', function() { sc_form_blog_posts_created_at_onchange(this, iSeqRow, event) }); $('#id_sc_field_created_at_hora' + iSeqRow).bind('change', function() { sc_form_blog_posts_created_at_hora_onchange(this, iSeqRow, event) }); $('#id_sc_field_updated_at' + iSeqRow).bind('change', function() { sc_form_blog_posts_updated_at_onchange(this, iSeqRow, event) }); $('#id_sc_field_updated_at_hora' + iSeqRow).bind('change', function() { sc_form_blog_posts_updated_at_hora_onchange(this, iSeqRow, event) }); $('#id_sc_field_views' + iSeqRow).bind('blur', function() { sc_form_blog_posts_views_onblur('#id_sc_field_views' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_blog_posts_views_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_blog_posts_views_onfocus(this, iSeqRow, event) }); $('.sc-ui-radio-status' + iSeqRow).on('click', function() { scMarkFormAsChanged(); }); } // scJQEventsAdd Upload_Cancel = false; function sc_form_blog_posts_id_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_blog_posts_title_onblur(oThis, iSeqRow, event) { do_ajax_form_blog_posts_validate_title(); scCssBlur(oThis); } function sc_form_blog_posts_title_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); do_ajax_form_blog_posts_event_title_onchange(); } function sc_form_blog_posts_title_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_blog_posts_slug_onblur(oThis, iSeqRow, event) { do_ajax_form_blog_posts_validate_slug(); scCssBlur(oThis); } function sc_form_blog_posts_slug_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_blog_posts_slug_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_blog_posts_meta_description_onblur(oThis, iSeqRow, event) { do_ajax_form_blog_posts_validate_meta_description(); scCssBlur(oThis); } function sc_form_blog_posts_meta_description_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_blog_posts_meta_description_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_blog_posts_content_onblur(oThis, iSeqRow, event) { do_ajax_form_blog_posts_validate_content(); scCssBlur(oThis); } function sc_form_blog_posts_content_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_blog_posts_content_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_blog_posts_excerpt_onblur(oThis, iSeqRow, event) { do_ajax_form_blog_posts_validate_excerpt(); scCssBlur(oThis); } function sc_form_blog_posts_excerpt_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_blog_posts_excerpt_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_blog_posts_featured_image_onblur(oThis, iSeqRow, event) { scCssBlur(oThis); } function sc_form_blog_posts_featured_image_onchange(oThis, iSeqRow, event) { File_Event = event.target; File_Arr = File_Event.files; if (File_Arr.length > 0) { File_Name = File_Arr[0].name; if (File_Name.indexOf('*') != -1) { scJs_alert (File_Name + '