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 == 'project_id') { $oField.select2('open'); } else { $oField[0].focus(); } return true; } return false; } // scSetFocusOnField function scEventControl_init(iSeqRow) { scEventControl_data["status" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["project_id" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["title" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["description" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["priority" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["enabled" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["duration" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["due_date" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["hours_estimated" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; scEventControl_data["hours_spent" + iSeqRow] = {"blur": false, "change": false, "autocomp": false, "original": "", "calculated": ""}; } function scEventControl_active(iSeqRow) { 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["project_id" + iSeqRow] && scEventControl_data["project_id" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["project_id" + iSeqRow] && scEventControl_data["project_id" + 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["description" + iSeqRow] && scEventControl_data["description" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["description" + iSeqRow] && scEventControl_data["description" + iSeqRow]["change"]) { return true; } if (scEventControl_data["priority" + iSeqRow] && scEventControl_data["priority" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["priority" + iSeqRow] && scEventControl_data["priority" + iSeqRow]["change"]) { return true; } 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["duration" + iSeqRow] && scEventControl_data["duration" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["duration" + iSeqRow] && scEventControl_data["duration" + iSeqRow]["change"]) { return true; } if (scEventControl_data["due_date" + iSeqRow] && scEventControl_data["due_date" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["due_date" + iSeqRow] && scEventControl_data["due_date" + iSeqRow]["change"]) { return true; } if (scEventControl_data["hours_estimated" + iSeqRow] && scEventControl_data["hours_estimated" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["hours_estimated" + iSeqRow] && scEventControl_data["hours_estimated" + iSeqRow]["change"]) { return true; } if (scEventControl_data["hours_spent" + iSeqRow] && scEventControl_data["hours_spent" + iSeqRow]["blur"]) { return true; } if (scEventControl_data["hours_spent" + iSeqRow] && scEventControl_data["hours_spent" + 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 ("project_id" + 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_task_id' + iSeqRow).bind('change', function() { sc_form_tasks_task_id_onchange(this, iSeqRow, event) }); $('#id_sc_field_project_id' + iSeqRow).bind('select2:close', function() { sc_form_tasks_project_id_onblur('#id_sc_field_project_id' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_tasks_project_id_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_tasks_project_id_onfocus(this, iSeqRow, event) }); $('#id_sc_field_title' + iSeqRow).bind('blur', function() { sc_form_tasks_title_onblur('#id_sc_field_title' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_tasks_title_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_tasks_title_onfocus(this, iSeqRow, event) }); $('#id_sc_field_description' + iSeqRow).bind('blur', function() { sc_form_tasks_description_onblur('#id_sc_field_description' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_tasks_description_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_tasks_description_onfocus(this, iSeqRow, event) }); $('#id_sc_field_assigned_to' + iSeqRow).bind('change', function() { sc_form_tasks_assigned_to_onchange(this, iSeqRow, event) }); $('#id_sc_field_status' + iSeqRow).bind('blur', function() { sc_form_tasks_status_onblur('#id_sc_field_status' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_tasks_status_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_tasks_status_onfocus(this, iSeqRow, event) }); $('#id_sc_field_priority' + iSeqRow).bind('blur', function() { sc_form_tasks_priority_onblur('#id_sc_field_priority' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_tasks_priority_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_tasks_priority_onfocus(this, iSeqRow, event) }); $('#id_sc_field_due_date' + iSeqRow).bind('blur', function() { sc_form_tasks_due_date_onblur('#id_sc_field_due_date' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_tasks_due_date_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_tasks_due_date_onfocus(this, iSeqRow, event) }); $('#id_sc_field_hours_estimated' + iSeqRow).bind('blur', function() { sc_form_tasks_hours_estimated_onblur('#id_sc_field_hours_estimated' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_tasks_hours_estimated_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_tasks_hours_estimated_onfocus(this, iSeqRow, event) }); $('#id_sc_field_hours_spent' + iSeqRow).bind('blur', function() { sc_form_tasks_hours_spent_onblur('#id_sc_field_hours_spent' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_tasks_hours_spent_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_tasks_hours_spent_onfocus(this, iSeqRow, event) }); $('#id_sc_field_enabled' + iSeqRow).bind('blur', function() { sc_form_tasks_enabled_onblur('#id_sc_field_enabled' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_tasks_enabled_onchange(this, iSeqRow, event) }) .bind('focus', function() { sc_form_tasks_enabled_onfocus(this, iSeqRow, event) }); $('#id_sc_field_created_at' + iSeqRow).bind('change', function() { sc_form_tasks_created_at_onchange(this, iSeqRow, event) }); $('#id_sc_field_created_at_hora' + iSeqRow).bind('change', function() { sc_form_tasks_created_at_hora_onchange(this, iSeqRow, event) }); $('#id_sc_field_usr_login' + iSeqRow).bind('change', function() { sc_form_tasks_usr_login_onchange(this, iSeqRow, event) }); $('#id_sc_field_duration' + iSeqRow).bind('blur', function() { sc_form_tasks_duration_onblur('#id_sc_field_duration' + iSeqRow, iSeqRow, event) }) .bind('change', function() { sc_form_tasks_duration_onchange(this, iSeqRow, event) }) .bind('click', function() { sc_form_tasks_duration_onclick(this, iSeqRow, event) }) .bind('focus', function() { sc_form_tasks_duration_onfocus(this, iSeqRow, event) }); $('.sc-ui-radio-status' + iSeqRow).on('click', function() { scMarkFormAsChanged(); }); $('.sc-ui-radio-priority' + iSeqRow).on('click', function() { scMarkFormAsChanged(); }); $('.sc-ui-checkbox-enabled' + iSeqRow).on('click', function() { scMarkFormAsChanged(); }); $('.sc-ui-radio-duration' + iSeqRow).on('click', function() { scMarkFormAsChanged(); }); } // scJQEventsAdd Upload_Cancel = false; function sc_form_tasks_task_id_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_tasks_project_id_onblur(oThis, iSeqRow, event) { do_ajax_form_tasks_validate_project_id(); scCssBlur(oThis); } function sc_form_tasks_project_id_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_tasks_project_id_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_tasks_title_onblur(oThis, iSeqRow, event) { do_ajax_form_tasks_validate_title(); scCssBlur(oThis); } function sc_form_tasks_title_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_tasks_title_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_tasks_description_onblur(oThis, iSeqRow, event) { do_ajax_form_tasks_validate_description(); scCssBlur(oThis); } function sc_form_tasks_description_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_tasks_description_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_tasks_assigned_to_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_tasks_status_onblur(oThis, iSeqRow, event) { do_ajax_form_tasks_validate_status(); scCssBlur(oThis); } function sc_form_tasks_status_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_tasks_status_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_tasks_priority_onblur(oThis, iSeqRow, event) { do_ajax_form_tasks_validate_priority(); scCssBlur(oThis); } function sc_form_tasks_priority_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_tasks_priority_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_tasks_due_date_onblur(oThis, iSeqRow, event) { do_ajax_form_tasks_validate_due_date(); scCssBlur(oThis); } function sc_form_tasks_due_date_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_tasks_due_date_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_tasks_hours_estimated_onblur(oThis, iSeqRow, event) { do_ajax_form_tasks_validate_hours_estimated(); scCssBlur(oThis); } function sc_form_tasks_hours_estimated_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_tasks_hours_estimated_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_tasks_hours_spent_onblur(oThis, iSeqRow, event) { do_ajax_form_tasks_validate_hours_spent(); scCssBlur(oThis); } function sc_form_tasks_hours_spent_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_tasks_hours_spent_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_tasks_enabled_onblur(oThis, iSeqRow, event) { do_ajax_form_tasks_validate_enabled(); scCssBlur(oThis); } function sc_form_tasks_enabled_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_tasks_enabled_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function sc_form_tasks_created_at_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_tasks_created_at_hora_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_tasks_usr_login_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_tasks_duration_onblur(oThis, iSeqRow, event) { do_ajax_form_tasks_validate_duration(); scCssBlur(oThis); } function sc_form_tasks_duration_onchange(oThis, iSeqRow, event) { scMarkFormAsChanged(); } function sc_form_tasks_duration_onclick(oThis, iSeqRow, event) { do_ajax_form_tasks_event_duration_onclick(); } function sc_form_tasks_duration_onfocus(oThis, iSeqRow, event) { scEventControl_onFocus(oThis, iSeqRow); scCssFocus(oThis); } function displayChange_block(block, status) { if ("0" == block) { displayChange_block_0(status); } if ("1" == block) { displayChange_block_1(status); } } function displayChange_block_0(status) { displayChange_field("status", "", status); displayChange_field("project_id", "", status); displayChange_field("title", "", status); displayChange_field("description", "", status); } function displayChange_block_1(status) { displayChange_field("priority", "", status); displayChange_field("enabled", "", status); displayChange_field("duration", "", status); displayChange_field("due_date", "", status); displayChange_field("hours_estimated", "", status); displayChange_field("hours_spent", "", status); } function displayChange_row(row, status) { displayChange_field_status(row, status); displayChange_field_project_id(row, status); displayChange_field_title(row, status); displayChange_field_description(row, status); displayChange_field_priority(row, status); displayChange_field_enabled(row, status); displayChange_field_duration(row, status); displayChange_field_due_date(row, status); displayChange_field_hours_estimated(row, status); displayChange_field_hours_spent(row, status); } function displayChange_field(field, row, status) { if ("status" == field) { displayChange_field_status(row, status); } if ("project_id" == field) { displayChange_field_project_id(row, status); } if ("title" == field) { displayChange_field_title(row, status); } if ("description" == field) { displayChange_field_description(row, status); } if ("priority" == field) { displayChange_field_priority(row, status); } if ("enabled" == field) { displayChange_field_enabled(row, status); } if ("duration" == field) { displayChange_field_duration(row, status); } if ("due_date" == field) { displayChange_field_due_date(row, status); } if ("hours_estimated" == field) { displayChange_field_hours_estimated(row, status); } if ("hours_spent" == field) { displayChange_field_hours_spent(row, status); } } function displayChange_field_status(row, status) { var fieldId; } function displayChange_field_project_id(row, status) { var fieldId; if ("on" == status) { Ctrl_Disabled = false; if ("all" == row) { var fieldList = $(".css_project_id__obj"); for (var i = 0; i < fieldList.length; i++) { $($(fieldList[i]).attr("id")).select2("destroy"); } } else { if ($('#select2-id_sc_field_project_id' + row + '-container').hasClass('scFormInputDisabled')) { Ctrl_Disabled = true; } $("#id_sc_field_project_id" + row).select2("destroy"); } scJQSelect2Add(row, "project_id"); if (Ctrl_Disabled) { $('#select2-id_sc_field_project_id' + row + '-container').addClass('scFormInputDisabled') } } } function displayChange_field_title(row, status) { var fieldId; } function displayChange_field_description(row, status) { var fieldId; } function displayChange_field_priority(row, status) { var fieldId; } function displayChange_field_enabled(row, status) { var fieldId; } function displayChange_field_duration(row, status) { var fieldId; } function displayChange_field_due_date(row, status) { var fieldId; } function displayChange_field_hours_estimated(row, status) { var fieldId; } function displayChange_field_hours_spent(row, status) { var fieldId; } function scRecreateSelect2() { displayChange_field_project_id("all", "on"); } function scResetPagesDisplay() { $(".sc-form-page").show(); } function scHidePage(pageNo) { $("#id_form_tasks_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(21); } } } var sc_jq_calendar_value = {}; function scJQCalendarAdd(iSeqRow) { $("#id_sc_field_due_date" + iSeqRow).datepicker('destroy'); $("#id_sc_field_due_date" + iSeqRow).datepicker({ beforeShow: function(input, inst) { var $oField = $(this), aParts = $oField.val().split(" "), sTime = ""; sc_jq_calendar_value["#id_sc_field_due_date" + iSeqRow] = $oField.val(); }, onClose: function(dateText, inst) { do_ajax_form_tasks_validate_due_date(iSeqRow); }, showWeek: true, numberOfMonths: 1, changeMonth: true, changeYear: true, yearRange: 'c-5:c+5', dayNames: ["