//***** aic prototype controls by Piter Gavrinev 19.04.2024. v7.5
//need moment.js
function div(className, id) {
if (typeof id !== "undefined") {
return $("
");
} else {
return $("");
}
}
/**
* Переключатель
* @param {string} Title
*/
var AIC_Switch = function (Title, isChecked) {
var checked = false;
if (typeof isChecked !== "undefined") {
checked = (isChecked.toString()?.toLowerCase?.() === 'true');
};
this.IsDisable = false;
var control_obj = this;
this._delegateClickFunction = null;
this._rootEl = div("filter filter-switch");
this._rootEl.attr("data-filter", "switch");
this._rootEl.uniqueId();
let input = $("");
input.uniqueId();
let label = $("");
let span = $("
" + Title + "
");
label.append(span);
this._rootEl.append(input);
this._rootEl.append(label);
input.prop('checked', checked);
input.click(function () {
if ($.isFunction(control_obj._delegateClickFunction)) {
control_obj._delegateClickFunction($(this).is(":checked"));
};
});
}
AIC_Switch.prototype.val = function () {
return this._rootEl.children("input").is(":checked");
};
AIC_Switch.prototype.Disable = function (IsDisable) {
this.IsDisable = IsDisable;
if (IsDisable) {
this._rootEl.children("input").attr("disabled", "disabled");
} else {
this._rootEl.children("input").removeAttr("disabled");
}
}
AIC_Switch.prototype.click = function (callbackFunction) {
this._delegateClickFunction = callbackFunction;
};
AIC_Switch.prototype.AppendTo = function (object) {
object.append(this._rootEl);
this._rootEl.trigger('new-html');
};
AIC_Switch.prototype.valueOf = function () {
return this._rootEl;
};
/**
* Группа чекбоксов
* @param {string} Title
* @param {string} PlaceHolderName
* @param {string} SelectButtonName
*/
var AIC_CheckBoxes = function (Title, PlaceHolderName, SelectButtonName) {
this.IsDisable = false;
this.IsLoadingState = false;
this._rootEl = div("filter");
this._rootEl.attr("data-filter", "checkboxes");
this._rootEl.uniqueId();
var control_obj = this;
this._delegateClickFunction = null;
if (typeof PlaceHolderName !== "undefined") {
this._rootEl.append($("
" + PlaceHolderName + "
"));
}
if (typeof SelectButtonName == "undefined") {
SelectButtonName = "Применить";
}
const button = $("");
this._rootEl.append(button);
let filter_content = div("filter_content");
filter_content.attr("data-filter-content", "");
let filter_content_top = div("filter_content_top");
let filter_content_close = div("filter_content_close");
filter_content_close.attr("data-filter-close", "");
filter_content_top.append(filter_content_close);
filter_content.append(filter_content_top);
this._rootEl.append(filter_content);
this._content = div("filter-checkboxes");
filter_content.append(this._content);
let filter_checkboxes_bottom = div("filter-checkboxes_bottom");
const ApplayButton = $("");
filter_checkboxes_bottom.append(ApplayButton);
filter_content.append(filter_checkboxes_bottom);
ApplayButton.click(function () {
if ($.isFunction(control_obj._delegateClickFunction)) {
var RetArray = control_obj.val();
control_obj._delegateClickFunction(RetArray);
}
});
}
AIC_CheckBoxes.prototype.val = function () {
var RetArray = [];
var inputs = this._content.find("input");
inputs.each(function () {
const isChecked = $(this).is(":checked");
const dataId = $(this).data("id");
RetArray.push({ id: dataId, IsChecked: isChecked });
});
return RetArray;
};
AIC_CheckBoxes.prototype.Disable = function (IsDisable) {
this.IsDisable = IsDisable;
if (IsDisable) {
this._rootEl.children("button").attr("disabled", "disabled");
} else {
this._rootEl.children("button").removeAttr("disabled");
}
}
AIC_CheckBoxes.prototype.SetLoadding = function (IsLoadingState) {
this.IsLoadingState = IsLoadingState;
if (IsLoadingState) {
this._rootEl.children("button").addClass("_loading");
} else {
this._rootEl.children("button").removeClass("_loading");
}
}
AIC_CheckBoxes.prototype.click = function (callbackFunction) {
this._delegateClickFunction = callbackFunction;
};
AIC_CheckBoxes.prototype.Clear = function () {
this._content.empty();
};
AIC_CheckBoxes.prototype.SetCheckBox = function (Id, IsChecked) {
var ret = false;
var inputs = this._content.find("input");
if (inputs.length > 0) {
inputs.each(function () {
const dataId = $(this).data("id");
if (dataId == Id) {
$(this).prop("checked", IsChecked);
ret = true;
}
});
}
return ret;
}
/**
* @param {string} Id
* @param {string} Name
* @param {boolean} IsChecked
*/
AIC_CheckBoxes.prototype.AddCheckbox = function (Id, Name, IsChecked) {
if (typeof IsChecked == "undefined") {
IsChecked = false;
}
var item = div("filter-checkboxes_item");
var input = $("");
input.data("id", Id);
input.prop("checked", IsChecked);
input.uniqueId();
var lbl = $("");
item.append(input);
item.append(lbl);
this._content.append(item);
};
AIC_CheckBoxes.prototype.AppendTo = function (object) {
object.append(this._rootEl);
this._rootEl.trigger('new-html');
};
AIC_CheckBoxes.prototype.valueOf = function () {
return this._rootEl;
};
/**
* поле поиска
* @param {boolean} _isEng
* @param {string} PlaceHolderName
*/
var AIC_SearchTextField = function (_isEng, PlaceHolderName) {
const pls = (typeof PlaceHolderName !== "undefined" ? PlaceHolderName : "Поиск по разделу");
var control_obj = this;
this._rootEL = div("search");
const sf = div("search_field");
const sf_input = $("");
sf.append(sf_input);
this._rootEL.append(sf);
const sb = div("search_btn");
const sb_btn = $("");
sf_input.on('keydown', function (e) {
if (e.keyCode == 13) {
e.preventDefault();
if ($.isFunction(control_obj._delegateClickFunction)) {
control_obj._delegateClickFunction(sf_input.val());
};
}
});
this._rootEL.clickFunction =
sb_btn.click(function (event) {
event.preventDefault();
if ($.isFunction(control_obj._delegateClickFunction)) {
control_obj._delegateClickFunction(sf_input.val());
};
});
sb.append(sb_btn);
this._rootEL.append(sb);
}
AIC_SearchTextField.prototype.val = function () {
return this._rootEL.find("input").val();
};
AIC_SearchTextField.prototype.click = function (callbackFunction) {
this._delegateClickFunction = callbackFunction;
};
AIC_SearchTextField.prototype.AppendTo = function (object) {
object.append(this._rootEL);
this._rootEL.trigger('new-html');
};
AIC_SearchTextField.prototype.valueOf = function () {
return this._rootEL;
};
/**
* Пагинатор
* @param {number} totalPages
* @param {boolean} isEng
*/
var AIC_Pager = function (totalPages, isEng) {
this._isEng = isEng || false;
this._currentObject = null;
this._totalPages = totalPages;
this._rootEl = div("col-md-18 offset-md-4 pagination");
this.SetCurrentPage(0);
};
AIC_Pager.prototype.click = function (callbackFunction) {
this._delegateClickFunction = callbackFunction;
};
/**
* Устанавливает выидимость страницы по номеру
* @param {any} currentPage
*/
AIC_Pager.prototype.SetCurrentPage = function (currentPage) {
var control_obj = this;
var windowSize = 5;
var startpage = Math.floor((currentPage) / windowSize);
this._rootEl.empty();
var starti = (startpage * windowSize);
var prevObj = $("" + (this._isEng ? "First" :
"В начало") + "");
if (currentPage >= windowSize) {
prevObj.attr("href", "#");
prevObj.click(function (event) {
event.preventDefault();
if ($.isFunction(control_obj._delegateClickFunction)) {
control_obj._delegateClickFunction(starti - 1);
};
});
}
this._rootEl.append(prevObj);
for (var i = starti; (i < starti + windowSize) && i <= this._totalPages; i++) {
var pageObj = $("" + (i + 1) + "");
if (i !== currentPage) pageObj.attr("href", "#");
pageObj.click(function (event) {
event.preventDefault();
var num = $(this).data("num");
if ($.isFunction(control_obj._delegateClickFunction)) {
control_obj._delegateClickFunction(num);
};
});
this._rootEl.append(pageObj);
}
var endObj = $("= (this._totalPages - windowSize) ? " _disabled" : "") + " \">" + (this._isEng ? "next" : "дальше") + "");
endObj.click(function (event) {
event.preventDefault();
if ($.isFunction(control_obj._delegateClickFunction)) {
control_obj._delegateClickFunction(starti + windowSize);
};
});
this._rootEl.append(endObj);
if (this._currentObject !== null) {
this._currentObject.trigger('new-html');
}
};
AIC_Pager.prototype.AppendTo = function (object) {
object.append(this._rootEl);
this._currentObject = object;
};
AIC_Pager.prototype.valueOf = function () {
return this._rootEl;
};
/**
* Список с подуровнями типа древо
* @param {boolean} isEng
* @param {string} Title
* @param {string} AnyThematicName
*/
var AIC_LevelControl = function (isEng, Title, AnyThematicName) {
this.IsDisable = false;
this.IsLoadingState = false;
this._value = null;
this._title = null;
let lt = this._isEng ? "Show all" : "Любая тематика";
if (typeof AnyThematicName !== "undefined") lt = AnyThematicName;
this._defaultThematicName = AnyThematicName;
this._isEng = isEng || false;
this._rootEl = $("");
this._rootEl.uniqueId();
if (typeof Title !== "undefined") this._rootEl.append($("
" + Title + "
"));
this._rootEl.append($(""));
var control_container = $("");
control_container.append($("
" +
"" +
"
"));
var _control = $("");
_control.append($("
" +
"
" +
"
" + (this._isEng ? "Data not found" : "Ничего не найдено") + "
"));
control_container.append(_control);
this._levels = $("");
_control.append(this._levels);
this._rootEl.append(control_container);
if (typeof AnyThematicName !== "undefined") {
this.AddLevel(-1, 0, lt);
}
};
AIC_LevelControl.prototype.Disable = function (IsDisable) {
this.IsDisable = IsDisable;
if (IsDisable) {
this._rootEl.children("button").attr("disabled", "disabled");
} else {
this._rootEl.children("button").removeAttr("disabled");
}
}
AIC_LevelControl.prototype.SetLoadding = function (IsLoadingState) {
this.IsLoadingState = IsLoadingState;
if (IsLoadingState) {
this._rootEl.children("button").addClass("_loading");
} else {
this._rootEl.children("button").removeClass("_loading");
}
}
AIC_LevelControl.prototype.Clear = function () {
this._value = null;
this._title = null;
this._rootEl.children("button").off('click');
this._levels.empty();
if (typeof this._defaultThematicName !== "undefined") {
this._rootEl.children("button").text(this._defaultThematicName);
this._rootEl.children("button").attr("title", this._defaultThematicName);
this.AddLevel(-1, 0, this._defaultThematicName);
}
//this.ReInit();
};
AIC_LevelControl.prototype.ReInit = function () {
this._rootEl.trigger('new-html');
};
AIC_LevelControl.prototype.AppendTo = function (object) {
object.append(this._rootEl);
this._rootEl.trigger('new-html');
};
// register callback
AIC_LevelControl.prototype.click = function (callbackFunction) {
this._delegateClickFunction = callbackFunction;
};
/**
* Добавление уровня
* @param {string} Id
* @param {string} parentId
* @param {string} Title
* @param {boolean} NotClikable
*/
AIC_LevelControl.prototype.AddLevel = function (Id, parentId, Title, NotClikable) {
var rootId = this._rootEl.attr("id");
var section = $("");
if (NotClikable) {
var label_control = $("");
section.append(label_control);
} else {
var input_control = $("");
var label_control = $("");
input_control.data("Id", Id);
input_control.data("Title", Title);
var control_obj = this;
input_control.click(function () {
if ($.isFunction(control_obj._delegateClickFunction)) {
control_obj._value = $(this).data("Id");
control_obj._title = $(this).data("Title");
control_obj._delegateClickFunction(control_obj._value, control_obj._title);
}
});
section.append(input_control);
section.append(label_control);
}
var ParentElement = this._levels.find("[id='filter_" + rootId + "_" + parentId + "']");
if (ParentElement.length > 0) {
var childLevel = ParentElement.parent().next();
if (childLevel.attr("class") !== "level") {
childLevel = $("");
childLevel.append(section);
childLevel.insertAfter(ParentElement.parent());
} else {
childLevel.append(section);
}
} else {
this._levels.append(section);
}
};
//*************************************
/**
* Выбор периода между двумя годами
* @param {number} minYear
* @param {number} maxYear
* @param {boolean} isEng
* @param {string} Title
*/
var AIC_YearToYearCalendarControl = function (minYear, maxYear, isEng, Title, YearFrom, YearTo) {
var control_obj = this;
this.IsLoadingState = false;
this.minYearVal = minYear;
this.maxYearVal = maxYear;
this.fromYear = YearFrom;
this.toYear = YearTo;
this._isEng = isEng || false;
this.IsDisable = false;
this.ClickEvent = function () {
if ($.isFunction(control_obj._delegateClickFunction)) {
control_obj.fromYear = fromValueControl.val();
control_obj.toYear = toValueControl.val();
control_obj._delegateClickFunction(fromValueControl.val(), toValueControl.val());
}
}
this._rootEl = $("");
var datepiker = $("");
if (typeof Title !== "undefined") {
datepiker.append($("
" + Title + "
"));
}
var fromValueControl = $("");
var toValueControl = $("");
if (typeof YearFrom !== "undefined") {
fromValueControl.val(YearFrom);
};
if (typeof YearTo !== "undefined") {
toValueControl.val(YearTo);
}
datepiker.append(fromValueControl);
datepiker.append(toValueControl);
datepiker.append($(""));
var modal = $(" ");
modal.append($("
"));
modal.append($("
-
"));
modal.append($("
" +
" " +
" " +
"
"));
var footer = $("");
var button = $("");
button.click(this.ClickEvent);
footer.append(button);
modal.append(footer);
datepiker.append(modal);
this._rootEl.append(datepiker);
};
AIC_YearToYearCalendarControl.prototype.Disable = function (IsDisable) {
this.IsDisable = IsDisable;
if (IsDisable) {
this._rootEl.find("button, input").attr("disabled", "disabled");
} else {
this._rootEl.find("button, input").removeAttr("disabled");
}
};
AIC_YearToYearCalendarControl.prototype.SetLoadding = function (IsLoadingState) {
this.IsLoadingState = IsLoadingState;
if (IsLoadingState) {
this._rootEl.children("button").addClass("_loading");
} else {
this._rootEl.children("button").removeClass("_loading");
}
}
AIC_YearToYearCalendarControl.prototype.click = function (callbackFunction) {
this._delegateClickFunction = callbackFunction;
};
AIC_YearToYearCalendarControl.prototype.AppendTo = function (object) {
object.append(this._rootEl);
this._rootEl.trigger('new-html');
var button = this._rootEl.find("button.datepicker-filter_apply-btn");
button.click(this.ClickEvent);
};
AIC_YearToYearCalendarControl.prototype.Remove = function () {
this._rootEl.Remove();
};
AIC_YearToYearCalendarControl.prototype.SetYears = function (YearFrom, YearTo) {
this._rootEl.find(".datepicker-filter_input-from").val(YearFrom);
this._rootEl.find(".datepicker-filter_input-to").val(YearTo);
this.fromYear = YearFrom;
this.toYear = YearTo;
};
AIC_YearToYearCalendarControl.prototype.SetMxMinYears = function (YearFrom, YearTo) {
this._rootEl.children(".datepicker-filter").attr("data-min-date", YearFrom);
this._rootEl.children(".datepicker-filter").data("min-date", YearFrom);
this._rootEl.children(".datepicker-filter").attr("data-max-date", YearTo);
this._rootEl.children(".datepicker-filter").data("max-date", YearTo);
this.minYearVal = YearFrom;
this.maxYearVal = YearTo;
}
AIC_YearToYearCalendarControl.prototype.ReInit = function () {
this._rootEl.children(".datepicker-filter").removeClass("_changed");
this._rootEl.find(".datepicker-filter_datepicker-from").empty();
this._rootEl.find(".datepicker-filter_datepicker-to").empty();
this._rootEl.trigger('new-html');
var button = this._rootEl.find("button.datepicker-filter_apply-btn");
button.click(this.ClickEvent);
};
/**
* выбор из списка
* var someTheme = IsEng ? "Any theme" : "Любая тема";
* @param {string} someTheme
* @param {string} Title
* @param {boolean} WithSearch
* @param {boolean} IsEng
*/
var AIC_ListControl = function (someTheme, Title, WithSearch, IsEng) {
this._value = null;
this._title = null;
this.IsDisable = false;
this._isEng = IsEng || false;
this._WithSearch = WithSearch || false;
var control_obj = this;
this._delegateClickFunction = null;
this._rootEl = $("");
this._rootEl.uniqueId();
var rootId = this._rootEl.attr("id");
if (typeof Title !== "undefined") {
this._rootEl.append($("
" + Title + "
"));
}
this._rootEl.append($(""));
var filter_content = $("");
filter_content.append($("
"));
this.selector = div("filter-select_options");
var all_option_el = $("");
var ch_radio_all = $("");
all_option_el.append(ch_radio_all);
ch_radio_all.click(function () {
if ($.isFunction(control_obj._delegateClickFunction)) {
control_obj._value = null;
control_obj._title = null;
control_obj._delegateClickFunction(-1);
}
});
all_option_el.append($(""));
this.selector.append(all_option_el);
// загружаем все темы
var filter_select = div("filter-select");
if (this._WithSearch) {
filter_select = div("filter-select filter-select-with-search");
var fss = div("filter-select_search");
fss.append($(""));
filter_select.append(fss);
var fsse = div("filter-select_search_empty");
fsse.text(this._isEng ? "Data not found" : "Ничего не найдено");
filter_select.append(fsse);
}
filter_select.append(this.selector);
filter_content.append(filter_select);
this._rootEl.append(filter_content);
};
AIC_ListControl.prototype.AppendTo = function (object) {
object.append(this._rootEl);
this._rootEl.trigger('new-html');
};
AIC_ListControl.prototype.click = function (callbackFunction) {
this._delegateClickFunction = callbackFunction;
};
AIC_ListControl.prototype.Clear = function () {
this.selector.empty();
};
AIC_ListControl.prototype.ReInit = function () {
this._rootEl.trigger('new-html');
};
AIC_ListControl.prototype.Disable = function (IsDisable) {
this.IsDisable = IsDisable;
if (IsDisable) {
this._rootEl.find("button, input").attr("disabled", "disabled");
} else {
this._rootEl.find("button, input").removeAttr("disabled");
}
};
AIC_ListControl.prototype.AddOption = function (Id, Title, isSelected) {
var control_obj = this;
var rootId = this._rootEl.attr("id");
var option_el = $("");
var ch_radio = $("");
ch_radio.click(function (noClick) {
var CurrentThemaID = $(this).val();
var title = $(this).parent().children("label").text();
if (noClick === true) return;
if ($.isFunction(control_obj._delegateClickFunction)) {
control_obj._value = CurrentThemaID;
control_obj._title = title;
control_obj._delegateClickFunction(CurrentThemaID, title);
}
});
option_el.append(ch_radio);
option_el.append($(""));
this.selector.append(option_el);
if (isSelected === true) {
ch_radio.click();
}
};
/**
* Выбор диапазона между двумя датами календарями
* @param {boolean} IsEng
*/
var AIC_TwoDateControl = function (IsEng) {
this._from_date_val = null;
this._to_date_val = null;
this.IsDisable = false;
this.IsLoadingState = false;
this._isEng = IsEng || false;
var control_obj = this;
this._delegateClickFunction = null;
this._rootEl = $("");
var root_control = $("
");
this.control_from = $("");
this.control_to = $("");
this.control_from.uniqueId();
this.control_from.attr("name", "datepicker-from-" + this.control_from[0].id);
this.control_to.uniqueId();
this.control_to.attr("name", "datepicker-to-" + this.control_to[0].id);
var vontrol_button = $("");
root_control.append(this.control_from);
root_control.append(this.control_to);
root_control.append(vontrol_button);
var filter_modal = div("datepicker-filter_modal");
var fhead = div("datepicker-filter_head");
fhead.append(div("datepicker-filter_close"));
filter_modal.append(fhead);
var ftabs = div("datepicker-filter_tabs");
ftabs.append($(" - "));
filter_modal.append(ftabs);
var fbody = div("datepicker-filter_body");
fbody.append(div("datepicker-filter_datepicker-from datepicker-custom"));
fbody.append(div("datepicker-filter_datepicker-to datepicker-custom"));
filter_modal.append(fbody);
var footer = $("");
var resetButton = $("");
resetButton.uniqueId();
var applyButton = $(" ");
applyButton.uniqueId();
this._rootEl.applyClickFunction = function () {
from_date_val = moment(control_obj.control_from.val(), "DD.MM.YYYY").format("YYYY-MM-DD");
to_date_val = moment(control_obj.control_to.val(), "DD.MM.YYYY").format("YYYY-MM-DD");
if ($.isFunction(control_obj._delegateClickFunction)) {
control_obj._from_date_val = from_date_val;
control_obj._to_date_val = to_date_val;
control_obj._delegateClickFunction(from_date_val, to_date_val);
}
};
applyButton.click(this._rootEl.applyClickFunction);
this._rootEl.resetClickFunction = function () {
if ($.isFunction(control_obj._delegateClickFunction)) {
control_obj._from_date_val = null;
control_obj._to_date_val = null;
control_obj._delegateClickFunction(null, null);
}
};
resetButton.click(this._rootEl.resetClickFunction);
footer.append(resetButton);
footer.append(applyButton);
filter_modal.append(footer);
root_control.append(filter_modal);
this.UpdateDatapicker = function (controlId, SETdateFrom, SETdateTo, currentDate) {
$(controlId).data('datepickerElement').datepicker("option", "maxDate", moment(SETdateTo).toDate());
$(controlId).data('datepickerElement').datepicker("option", "minDate", moment(SETdateFrom).toDate());
$(controlId).data('datepickerElement').datepicker("option", "setDate", moment(currentDate).toDate());
};
this._rootEl.append(root_control);
};
AIC_TwoDateControl.prototype.Disable = function (IsDisable) {
this.IsDisable = IsDisable;
if (IsDisable) {
this._rootEl.find("button.datepicker-filter_button").attr("disabled", "disabled");
} else {
this._rootEl.find("button.datepicker-filter_button").removeAttr("disabled");
}
};
AIC_TwoDateControl.prototype.SetLoadding = function (IsLoadingState) {
this.IsLoadingState = IsLoadingState;
if (IsLoadingState) {
this._rootEl.children("button.datepicker-filter_button").addClass("_loading");
} else {
this._rootEl.children("button.datepicker-filter_button").removeClass("_loading");
}
}
/**
*
* @param {string} minDate дата начала
* @param {string} maxDate дата конца периода
* @param {string} currentDate устанавливает выбранную дату в календаре
*/
AIC_TwoDateControl.prototype.SetDatesRange = function (minDate, maxDate, currentDate) {
var cd = currentDate || maxDate;
this.UpdateDatapicker(this.control_from, minDate, maxDate, cd, this._isEng);
this.UpdateDatapicker(this.control_to, minDate, maxDate, cd, this._isEng);
};
AIC_TwoDateControl.prototype.AppendTo = function (object) {
object.append(this._rootEl);
this._rootEl.trigger('new-html');
this._rootEl.find("button.datepicker-filter_apply-btn").click(this._rootEl.applyClickFunction);
this._rootEl.find("button.datepicker-filter_clear-btn").click(this._rootEl.resetClickFunction);
};
AIC_TwoDateControl.prototype.click = function (callbackFunction) {
this._delegateClickFunction = callbackFunction;
};
AIC_TwoDateControl.prototype.valueOf = function () {
return this._rootEl;
};
//------------- AIC dates choise control EXT ------
/**
* Выбор диапазона между двумя датами календарями (с возможностью выбора за все время)
* @param {any} IsEng
* @param {any} Title
*/
var AIC_TwoDateControlEXT = function (IsEng, Title) {
this._from_date_val = null;
this._to_date_val = null;
this.IsDisable = false;
this._isEng = IsEng || false;
var control_obj = this;
this._delegateSubcontrolClickFunction = null;
this._rootEl = $('');
var filter_el = $('');
if (typeof Title !== "undefined") {
filter_el.append($("
" + Title + "
"));
}
filter_el.append($(''));
var subc = $('');
subc.append($('
'));
var filter_select = $('');
var fo = $('');
var reset_button = $('');
reset_button.uniqueId();
reset_button.attr("name", 'nm_' + reset_button.attr('id'));
fo.append(reset_button);
fo.append($(' '));
filter_select.append(fo);
var filter_select_option = div("filter-select_option");
var inp = $('');
inp.uniqueId();
inp.attr("name", 'nm_' + reset_button.attr('id'));
var lbl = $('');
filter_select_option.append(lbl);
filter_select_option.append(inp);
filter_select.append(filter_select_option);
subc.append(filter_select);
filter_el.append(subc);
this._rootEl.append(filter_el);
this.DatesControl = new AIC_TwoDateControl(IsEng);
this._rootEl.DatesControlClickFunction = function (fdate, tdate) {
if ($.isFunction(control_obj._delegateSubcontrolClickFunction)) {
control_obj._from_date_val = fdate;
control_obj._to_date_val = tdate;
control_obj._delegateSubcontrolClickFunction(fdate, tdate);
}
};
this.DatesControl.click(this._rootEl.DatesControlClickFunction);
this._rootEl.append(this.DatesControl._rootEl);
}
AIC_TwoDateControlEXT.prototype.click = function (callbackFunction) {
this._delegateSubcontrolClickFunction = callbackFunction;
};
AIC_TwoDateControlEXT.prototype.AppendTo = function (object) {
object.append(this._rootEl);
this._rootEl.trigger('new-html');
this.DatesControl._rootEl.find("button.datepicker-filter_apply-btn").click(this.DatesControl._rootEl.applyClickFunction);
this.DatesControl._rootEl.find("button.datepicker-filter_clear-btn").click(this.DatesControl._rootEl.resetClickFunction);
this.DatesControl.click(this._rootEl.DatesControlClickFunction);
};
AIC_TwoDateControlEXT.prototype.valueOf = function () {
return this._rootEl;
};
AIC_TwoDateControlEXT.prototype.SetDatesRange = function (minDate, maxDate, currentDate) {
this.DatesControl.SetDatesRange(minDate, maxDate, currentDate);
};
//************************ AIC Two Quartal choise control ***************************
//
/**
* Выбор диапазона между двумя кварталами
* @param {string} minQDate
* @param {string} maxQDate
* @param {boolean} IsEng
* @param {string} Title
*/
var AIC_TwoQuartalDateControl = function (minQDate, maxQDate, IsEng, Title) {
this._from_date_val = null;
this._to_date_val = null;
this._isEng = IsEng || false;
var control_obj = this;
this._delegateClickFunction = null;
this._rootEl = div("filter");
this.filter_el = $('');
this.filter_el.data("min-date", moment(minQDate).format('MM.YYYY'));
this.filter_el.data("max-date", moment(maxQDate).format('MM.YYYY'));
if (typeof Title !== "undefined") {
this.filter_el.append($("
" + Title + "
"));
}
this.control_from = $('');
this.filter_el.append(this.control_from);
this.control_to = $('');
this.filter_el.append(this.control_to);
this.filter_el.append($(''));
var filter_modal = div("datepicker-filter_modal");
filter_modal.append(div("datepicker-filter_head").append(div("datepicker-filter_close")));
var tabs = div("datepicker-filter_tabs");
tabs.append($(" - "));
filter_modal.append(tabs);
var body = div("datepicker-filter_body");
body.append(div("datepicker-filter_datepicker-from quarterpicker-custom"));
body.append(div("datepicker-filter_datepicker-to quarterpicker-custom"));
filter_modal.append(body);
var footer = div("datepicker-filter_footer _right");
var resetButton = $("");
var applyButton = $(" ");
this._rootEl.applyClickFunction = function () {
from_date_val = moment(control_obj.control_from.val(), "MM.YYYY").format("YYYY-MM-DD");
to_date_val = moment(control_obj.control_to.val(), "MM.YYYY").format("YYYY-MM-DD");
if ($.isFunction(control_obj._delegateClickFunction)) {
control_obj._from_date_val = from_date_val;
control_obj._to_date_val = to_date_val;
control_obj._delegateClickFunction(from_date_val, to_date_val);
}
}
applyButton.click(this._rootEl.applyClickFunction);
this._rootEl.resetClickFunction = function () {
if ($.isFunction(control_obj._delegateClickFunction)) {
control_obj._from_date_val = null;
control_obj._to_date_val = null;
control_obj._delegateClickFunction(null, null);
}
};
resetButton.click(this._rootEl.resetClickFunction);
footer.append(resetButton);
footer.append(applyButton);
filter_modal.append(footer);
this.filter_el.append(filter_modal);
this._rootEl.append(this.filter_el);
}
AIC_TwoQuartalDateControl.prototype.SetDatesRange = function (minDate, maxDate) {
this.control_from.val(moment(minDate).format("MM.YYYY"));
this.control_to.val(moment(maxDate).format("MM.YYYY"));
};
AIC_TwoQuartalDateControl.prototype.AppendTo = function (object) {
object.append(this._rootEl);
this._rootEl.trigger('new-html');
this._rootEl.find("button.datepicker-filter_apply-btn").click(this._rootEl.applyClickFunction);
this._rootEl.find("button.datepicker-filter_clear-btn").click(this._rootEl.resetClickFunction);
};
AIC_TwoQuartalDateControl.prototype.click = function (callbackFunction) {
this._delegateClickFunction = callbackFunction;
};
AIC_TwoQuartalDateControl.prototype.valueOf = function () {
return this._rootEl;
};