Source
xxxxxxxxxx
* When triggering keydown event on [space] button, event is called for both, the actual element as well as calendar
// JavaScript Document
/*
** Zabbix
** Copyright (C) 2001-2022 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
*/
var CLNDR = null,
calendar = function (timeobject, trigger_elmnt, date_time_format) {
if (!this.checkOuterObj(timeobject)) {
throw 'Calendar: constructor expects second parameter to be input form field DOM node.';
}
this.id = jQuery(trigger_elmnt).attr('id');
this.trigger_elmnt = trigger_elmnt;
this.date_time_format = date_time_format;
this.sdt = new CDate();
};
function toggleCalendar(trigger_elmnt, time_input, date_time_format) {
if (CLNDR && jQuery(trigger_elmnt).is(CLNDR.trigger_elmnt) && CLNDR.is_visible) {
CLNDR.clndrhide();
}
else {
CLNDR && CLNDR.clndrhide();
CLNDR = new calendar(time_input, trigger_elmnt, date_time_format);
CLNDR.clndrshow();
}
}
calendar.prototype = {
id: null, // Calendar ID. Should be unique on page.
sdt: null, // Date object of a selected date.
month: 0, // Represents currently opened month number.
year: 2008, // Represents currently opened year.
day: 1, // Represents currently opened day.
clndr_calendar: null, // html obj of calendar
clndr_month_div: null, // html obj
clndr_year_div: null, // html obj
clndr_days: null, // html obj
clndr_month: null, // html obj
clndr_year: null, // html obj
clndr_year_wrap: null, // html obj
clndr_month_wrap: null, // html obj
clndr_monthup: null, // html bttn obj
clndr_monthdown: null, // html bttn obj
clndr_yearup: null, // html bttn obj
clndr_yeardown: null, // html bttn obj
timeobject: null, // Input field with selected time. Source and destination of selected date.
is_visible: false, // State of calendar visibility.
has_user_time: false, // Confirms, if time was selected from input field.
hl_month: null, // highlighted month number
hl_year: null, // highlighted year number
hl_day: null, // highlighted days number
active_section: null, // Active calendar section. See 'sections' array. Default value set in method clndrshow.
monthname: new Array(t('S_JANUARY'), t('S_FEBRUARY'), t('S_MARCH'), t('S_APRIL'), t('S_MAY'), t('S_JUNE'),
t('S_JULY'), t('S_AUGUST'), t('S_SEPTEMBER'), t('S_OCTOBER'), t('S_NOVEMBER'), t('S_DECEMBER')
),
dayname: new Array(t('S_SUNDAY'), t('S_MONDAY'), t('S_TUESDAY'), t('S_WEDNESDAY'), t('S_THURSDAY'), t('S_FRIDAY'),
t('S_SATURDAY')
),
sections: new Array('.calendar-year', '.calendar-month', '.calendar-date'),
date_time_format: PHP_ZBX_FULL_DATE_TIME,
trigger_elmnt: null, // Calendar visibility trigger element.
ondateselected: function() {
this.setDateToOuterObj();
this.clndrhide();
},
clndrhide: function() {
if (this.is_visible) {
this.calendardelete();
this.is_visible = false;
jQuery(window).off('resize', this.calendarPositionHandler);