').attr('id', 'messageContainer').hide()
.append($('
').text(header))
.append($('
').css({display: 'table-cell', overflow: 'auto'}).html(DOMPurify.sanitize(sessionMessage.message)))
.appendTo('body');
var messageWidth = $(window).width();
if (messageWidth > 600) {
messageWidth = 600;
} else {
messageWidth -= 50;
}
$('#messageContainer').dialog({
open: sessionMessageOpen,
draggable: true,
resizable: false,
height: 'auto',
minWidth: messageWidth,
maxWidth: 800,
maxHeight: 600,
title: title,
buttons: sessionMessageButtons
});
sessionMessage = null;
}
}
function sessionMessageCountdown(time) {
var sessionMessageTimeLeft = (time / 1000);
$('#btnSessionMessageOk').empty().append($('').addClass('ui-button-text').text(sessionMessageOk + ' (' + sessionMessageTimeLeft + ')'));
sessionMessageTimer = setInterval(function () {
sessionMessageTimeLeft--;
$('#btnSessionMessageOk').empty().append($('').addClass('ui-button-text').text(sessionMessageOk + ' (' + sessionMessageTimeLeft + ')'));
if (sessionMessageTimeLeft <= 0) {
clearInterval(sessionMessageTimer);
$('#messageContainer').dialog('close');
$('#messageContainer').remove();
}
}, 1000);
}
function markFilterTDs(child, filterNum) {
trNum = 0;
$('#' + child).find('tr').each(function () {
tdNum = 0;
$(this).find('td').each(function () {
$(this).attr('id', 'fn' + filterNum + 'tr' + trNum + 'td' + tdNum);
tdNum++;
});
trNum++;
});
}
function finalizeAuthProfileData(options, data) {
if (hScroll) {
$('#main, .cactiConsoleContentArea').css({ 'overflow-x': 'auto' });
$('#overflow').removeClass('ti-arrows-diagonal').addClass('ti-arrows-diagonal-minimize-2');
resetTables();
} else {
$('#main, .cactiConsoleContentArea').css({ 'overflow-x': 'hidden' });
$('#overflow').removeClass('ti-arrows-diagonal-minimize-2').addClass('ti-arrows-diagonal');
tuneTables();
}
}
function makeFiltersResponsive() {
var storage = Storages.sessionStorage;
var filterNum = 0;
if ($('div.cactiTableButton').closest('.cactiTable').not('#dqdebug').find('.filterTable').length) {
$('div.cactiTableButton').closest('.cactiTable').not('#dqdebug').each(function () {
if ($(this).find('.filterTable').length) {
filterHeader = $(this).closest('.cactiTable');
id = filterHeader.attr('id');
child = id + '_child';
filterContents = $('#' + child);
if (pageHasHidableColumnsAndProfile()) {
if (filterHeader.find('.cactiSwitchConstraints').length == 0) {
if (hScroll) {
$('#main, .cactiConsoleContentArea').css({ 'overflow-x': 'auto' });
filterHeader.find('div.cactiTableButton').append('');
} else {
$('#main, .cactiConsoleContentArea').css({ 'overflow-x': 'hidden' });
filterHeader.find('div.cactiTableButton').append('');
}
$('.cactiSwitchConstraints').rebind('click', function (event) {
event.preventDefault();
event.stopPropagation();
hScroll = !hScroll;
postUrl({
url: urlPath + 'auth_profile.php?tab=general&action=update_data',
handle: false,
noState: true,
funcEnd: 'finalizeAuthProfileData'
}, {
__csrf_magic: csrfMagicToken,
name: 'enable_hscroll',
value: hScroll ? 'on' : ''
});
});
}
}
if (filterContents.find('#export').length) {
title = $('#export').attr('title');
filterHeader.find('div.cactiTableButton').append($('').attr('title', title));
$('.cactiFilterExport').rebind('click', function (event) {
event.stopPropagation();
$('#export').trigger('click');
}).tooltip();
}
if (filterContents.find('#import').length) {
title = $('#import').attr('title');
filterHeader.find('div.cactiTableButton').append($('').attr('title', title));
$('.cactiFilterImport').rebind('click', function (event) {
event.stopPropagation();
$('#import').trigger('click');
}).tooltip();
}
if (filterContents.find('#clear').length) {
if (filterHeader.find('.cactiFilterClear').length == 0) {
filterHeader.find('div.cactiTableButton').append('');
}
$('.cactiFilterClear').rebind('click', function(event) {
event.stopPropagation();
$('#clear').trigger('click');
}).tooltip();
}
toggleFilterAndIcon(id, child, true);
if (storage.isSet('filterVisibility')) {
state = storage.get('filterVisibility');
} else {
state = 'visible';
}
if (state == 'hidden') {
if (filterHeader.find('.cactiFilterState').length == 0) {
filterHeader.find('div.cactiTableButton').append('');
} else {
filterHeader.find('div.cactiTableButton').find('.cactiFilterState').removeClass('fa-angle-double-up').addClass('fa-angle-double-down');
}
} else {
if (filterHeader.find('.cactiFilterState').length == 0) {
filterHeader.find('div.cactiTableButton').append('');
} else {
filterHeader.find('div.cactiTableButton').find('.cactiFilterState').removeClass('fa-angle-double-down').addClass('fa-angle-double-up');
}
}
filterHeader.find('.cactiFilterState').rebind('click', function() {
id = $(this).closest('.cactiTable').attr('id');
child = id + '_child';
toggleFilterAndIcon(id, child, false);
});
if (typeof showHideFilter != 'undefined') {
$('.cactiFilterState').attr('title', showHideFilter).tooltip();
}
filterNum++;
}
});
} else if ($('#dqdebug').length) {
$('#dqdebug').find('div.cactiTableButton').each(function () {
if ($(this).find('a').length) {
anchors = $('div.cactiTableButton').find('a');
anchors.each(function () {
$(this).attr('title', $(this).text());
});
anchors.not('.cactiTableCopy').addClass('ti ti-trash');
anchors.filter('.cactiTableCopy').addClass('ti ti-copy');
anchors.tooltip().text('');
}
});
}
if ($('#form_graph_view').length) {
$('#form_graph_view').filter('input, select').not('#date1, #date2').on('click', function () {
closeDateFilters();
});
}
}
function toggleFilterAndIcon(id, child, initial) {
var storage = Storages.sessionStorage;
if (storage.isSet('filterVisibility')) {
state = storage.get('filterVisibility');
} else {
state = 'visible';
}
if (initial) {
if (state == 'hidden') {
$('#' + child).hide();
$('#' + id).find('.cactiFilterClear, .cactiFilterImport, .cactiFilterExport').show();
}
} else if ($('#' + child).is(':visible')) {
$('#' + child).hide();
$('#' + id).find('.cactiFilterClear, .cactiFilterImport, .cactiFilterExport').show();
$('.cactiFilterState').find('i').removeClass('ti-chevrons-up').addClass('ti-chevrons-down');
storage.set('filterVisibility', 'hidden');
} else {
$('#' + child).show();
$('#' + id).find('.cactiFilterClear, .cactiFilterImport, .cactiFilterExport').hide();
$('.cactiFilterState').find('i').removeClass('ti-chevrons-down').addClass('ti-chevrons-up');
storage.set('filterVisibility', 'visible');
}
$(window).trigger('resize');
}
function setGraphTabs() {
page = window.location.href;
if (page.indexOf('graph_view.php') >= 0) {
$('.lefttab').removeClass('selected');
$('#tab-graphs').addClass('selected');
if (page.indexOf('action=tree') > 0) {
$('#preview, #listview, #treeview').removeClass('selected').prop('aria-selected', false);
$('#treeview').addClass('selected').prop('aria-selected', true);
} else if (page.indexOf('action=list') > 0) {
$('#preview, #listview, #treeview').removeClass('selected').prop('aria-selected', false);
$('#listview').addClass('selected').prop('aria-selected', true);
} else if (page.indexOf('action=preview') > 0) {
$('#preview, #listview, #treeview').removeClass('selected').prop('aria-selected', false);
$('#preview').addClass('selected').prop('aria-selected', true);
}
}
}
function setupResponsiveMenuAndTabs() {
$('.maintabs a.lefttab, .dropdownMenu a, .menuoptions a, #gtabs a.righttab').not('[href^="http"], [href^="https"], [href^="#"], [target="_blank"]').rebind('click', function (event) {
if (!shouldCaptureClick(event)) {
return;
}
page = basename($(this).attr('href'));
if (page == 'logout.php' || page == 'auth_changepassword.php') {
return;
} else if (page == 'index.php' && $(this).attr('href').indexOf('login') > -1) {
return;
} else {
event.preventDefault();
}
if ((pageName != 'auth_profile.php') && (userMenuNavigationExists(page) || page == 'graph_view.php') && ($(this).hasClass('selected') || (pageName == page && pageName != 'graph_view.php') && pageName != 'link.php')) {
handleUserMenu(true);
} else {
var id = $(this).attr('id');
var href = $(this).attr('href');
loadTopTab(href, id, false);
}
});
$(window).on('orientationchange, fullscreenchange', function () {
responsiveUI('force');
});
}
function responsiveUI(event) {
var tree = false;
if (event != 'force') {
if (new Date() - resizeTime < resizeDelta) {
var myEvent = event;
setTimeout(function () {
responsiveUI(myEvent);
}, resizeDelta);
return false;
} else {
resizeTimeout = false;
}
}
if ($('.cactiTreeNavigationArea').length > 0) {
tree = true;
} else {
tree = false;
}
handleUserMenu(false);
var mainWidth = getMainWidth();
/* change textbox and textarea widths */
$('input[type="text"], textarea').each(function () {
var offset;
if ($(this).attr('type') == 'text') {
offset = 20;
} else {
offset = 5;
}
if (mainWidth != 100) {
if ($(this).width() > mainWidth) {
$(this).css('max-width', (mainWidth - offset) + 'px');
} else {
$(this).css('max-width', '');
}
if ($(this).width() > mainWidth) {
$(this).css('max-width', (mainWidth - offset) + 'px');
}
if ($(this).parents('.formColumnRight').is(":visible") && $(this).width() > $(this).parents('.formColumnRight').prop('clientWidth')) {
$(this).css('max-width', ($(this).parents('.formColumnRight').prop('clientWidth')) + 'px');
} else {
$(this).css('max-width', '');
}
}
});
$('table.filterTable').each(function () {
tuneFilter($(this), mainWidth);
});
tuneTables();
}
function getMainWidth() {
var mainWidth;
// Subtract 15px for the scroll bar
if ($('#navigation').length && $('#navigation').is(':visible')) {
mainWidth = $('body').outerWidth() - $('#navigation').width() - 15;
} else {
mainWidth = $('body').outerWidth() - 15;
}
return mainWidth;
}
function getCactiHelp(cactiPage) {
var url = urlPath + 'help.php?page=' + cactiPage;
$.getJSON(url, function (data) {
if (data.status == 'Success') {
window.open(data.location, '_blank');
}
});
}
function responsiveResizeGraphs(initialize) {
var graphRow, drillDown;
var mainWidth = getMainWidth() - 30;
var myColumns = $('#columns').val();
if ($('.tableRowGraph:first').length) {
graphRow = $('.tableRowGraph:first').width();
} else {
graphRow = 0;
}
if ($('.graphDrillDown:first').length) {
drillDown = $('.graphDrillDown:first').outerWidth() + 15;
} else {
drillDown = 0;
}
if (myColumns == null) {
myColumns = 1;
}
if (mainWidth < graphRow) {
graphRow = mainWidth - drillDown;
} else if (graphRow == 0) {
graphRow = mainWidth;
}
// Dont resize if nothing changed
if (initialize === undefined && (previousMainWidth == null || (previousMainWidth == mainWidth && previousColumns == myColumns))) {
previousMainWidth = mainWidth;
return true;
}
var myWidth = Number.parseInt((graphRow - (drillDown * myColumns)) / myColumns);
$('.graphimage').each(function () {
var graph_id = $(this).attr('graph_id');
if (!(graph_id > 0)) {
graph_id = $(this).attr('id').replace('wrapper_', '');
graph_id = $(this).attr('id').replace('graph_', '');
}
$(this).attr('rra_id');
var type = $(this).attr('graph_type');
var original_cwidth = $('#wrapper_' + graph_id).attr('graph_width');
$('#wrapper_' + graph_id).attr('graph_height');
/* original image attributes */
var image_width = $(this).attr('image_width');
var image_height = $(this).attr('image_height');
var canvas_top = $(this).attr('canvas_top');
var canvas_left = $(this).attr('canvas_left');
var canvas_width = $(this).attr('canvas_width');
var canvas_height = $(this).attr('canvas_height');
var remove_whcss = false;
var ratio = myWidth / image_width;
/* optimize display and set correct ratio if image is full size */
if (image_width * original_cwidth / canvas_width < myWidth) {
remove_whcss = true;
ratio = original_cwidth / canvas_width;
}
// Dont change the size if the differential is small
if (ratio > .97 && ratio < 1.03) {
ratio = 1;
}
var new_image_width = Number.parseInt(image_width * ratio)
var new_image_height = Number.parseInt(image_height * ratio)
var new_canvas_width = Number.parseInt(canvas_width * ratio);
var new_canvas_height = Number.parseInt(canvas_height * ratio);
var new_canvas_graph_top = Number.parseInt(canvas_top * ratio);
var new_canvas_graph_left = Number.parseInt(canvas_left * ratio);
$(this).attr('graph_width', new_canvas_width);
$(this).attr('graph_height', new_canvas_height);
$(this).attr('graph_top', new_canvas_graph_top);
$(this).attr('graph_left', new_canvas_graph_left);
if (!remove_whcss || type == 'svg+xml') {
$(this).css('width', new_image_width);
$(this).css('height', new_image_height);
} else {
$(this).css('width', '');
$(this).css('height', '');
$(this).removeAttr('width');
$(this).removeAttr('height');
}
});
previousMainWidth = mainWidth;
previousColumns = myColumns;
if ($('.cactiTreeNavigationArea').length) {
resizeTreePanel();
}
}
function resizeTreePanel() {
var navWidth;
var docHeight = $(window).outerHeight();
navWidth = $('.cactiTreeNavigationArea').width();
var searchHeight = $('.cactiTreeSearch').outerHeight();
var pageHeadHeight = $('.cactiPageHead').outerHeight();
var breadCrHeight = $('.breadCrumbBar').outerHeight();
var pageBottomHeight = $('.cactiPageBottom').outerHeight();
//console.log('----------------------');
var jsTreeHeight = Math.max.apply(Math, $('#jstree').children(':visible').map(function () {
return $(this).outerHeight();
}).get());
var treeAreaHeight = docHeight - pageHeadHeight - breadCrHeight - searchHeight - pageBottomHeight;
//console.log('docHeight:' + docHeight);
//console.log('searchHeight:' + searchHeight);
//console.log('pageHeadHeight:' + pageHeadHeight);
//console.log('pageBottomHeight:' + pageBottomHeight);
//console.log('breadCrHeight:' + breadCrHeight);
//console.log('jsTreeHeight:' + jsTreeHeight);
//console.log('treeAreaHeight:' + treeAreaHeight);
$('#jstree').height(jsTreeHeight + 30);
$('.cactiTreeNavigationArea').height(treeAreaHeight + searchHeight);
var treeLeft = $('#jstree').offset().left;
var visWidth = Math.max.apply(Math, $('#jstree').find('.jstree-anchor:visible').map(function () {
return this.getBoundingClientRect().right - treeLeft;
}).get());
if (visWidth < 0) {
$('.cactiTreeNavigationArea').css('width', 0);
$('.cactiGraphContentArea').css('margin-left', 0);
$('.cactiTreeNavigationArea').css('overflow-x', '');
} else if (visWidth < minTreeWidth) {
$('.cactiTreeNavigationArea').css('width', minTreeWidth);
$('.cactiGraphContentArea').css('margin-left', minTreeWidth + 5);
$('.cactiTreeNavigationArea').css('overflow-x', '');
} else if (visWidth > maxTreeWidth) {
$('.cactiTreeNavigationArea').css('width', maxTreeWidth);
$('.cactiGraphContentArea').css('margin-left', maxTreeWidth + 5);
$('.cactiTreeNavigationArea').css('overflow-x', 'auto');
} else if (visWidth > navWidth) {
$('.cactiTreeNavigationArea').css('width', visWidth);
$('.cactiGraphContentArea').css('margin-left', visWidth + 5);
$('.cactiTreeNavigationArea').css('overflow-x', 'auto');
} else {
$('.cactiTreeNavigationArea').css('width', visWidth);
$('.cactiGraphContentArea').css('margin-left', visWidth + 5);
$('.cactiTreeNavigationArea').css('overflow-x', '');
}
navWidth = $('#navigation').width();
$('#searcher').css('width', getTreeSearchWidth(navWidth));
}
function getTreeSearchWidth(navWidth) {
return Math.max(navWidth - 70, 40);
}
function countHiddenCols(object) {
var hidden = 0;
$(object).find('th').each(function () {
if ($(this).css('display') == 'none') {
hidden++;
}
});
return hidden;
}
function tuneTables() {
var mainWidth = getMainWidth();
$('.cactiTable').each(function () {
$(this).find('th:first-child').each(function () {
var object = $(this).closest('.cactiTable');
tuneTable(object, mainWidth);
});
});
}
function pageHasHidableColumnsAndProfile() {
if (typeof userSettings != 'undefined' && userSettings && $(document).find('th').length) {
return true;
}
return false;
}
function resetTables() {
$('.cactiTable').each(function () {
$(this).find('th:first-child').each(function () {
var object = $(this).closest('.cactiTable');
resetTable(object);
});
});
}
function resetTable(object) {
var id = $(object).attr('id');
var column = 1;
$(object).find('th').each(function () {
$('#' + id + ' th:nth-child(' + column + ')').show();
$('#' + id + ' td:nth-child(' + column + ')').show();
column++;
});
}
function tuneTable(object, width) {
var rows = $(object).find('tr').length;
var width = width;
var tableWidth = $(object).width();
var totalCols = $(object).find('th').length;
var columnsHidden = countHiddenCols(object);
var visibleColumns = totalCols - columnsHidden;
$(object).attr('id');
if (rows > 101) return false;
// Enable horizontal scroll bar
if (hScroll) {
$('#main, .cactiConsoleContentArea').css({ 'overflow-x': 'visible' });
return false;
} else {
$('#main, .cactiConsoleContentArea').css({ 'overflow-x': 'hidden' });
}
// We have to both show and hide columns that fit.
// So, always find the size of the page columns.
var calculatedColumns = [];
var calculatedWidth = 0;
var allSeenWidth = 0;
var calculatedPadding = 15;
var tableChanged = false;
var stopExpand = false;
var debug = false;
var tableHeaders = $(object).find('th');
$(tableHeaders).each(function () {
if ($(this).index() == tableHeaders.length) {
calculatedColumns.addClass('noHide');
}
});
// Traverse the table and look for columns to hide from left to right
$($(object).find('th').get()).each(function () {
var isLastCheckBox = $(this).hasClass('tableSubHeaderCheckbox') && $(this).index() == tableHeaders.length - 1;
var columnWidth = $.textMetrics(this).width;
// Get the width of columns that can not be hidden
if ($(this).hasClass('noHide') || isLastCheckBox) {
calculatedColumns.push($(this).index());
calculatedWidth += columnWidth + calculatedPadding;
}
if ($(this).is(':visible')) {
allSeenWidth += columnWidth + calculatedPadding;
}
});
if (debug) {
console.log(
'allSeenWidth:' + Math.round(allSeenWidth, 1) +
', calulatedWidth:' + Math.round(calculatedWidth, 1) +
', tableWidth:' + Math.round(tableWidth, 1) +
', width:' + Math.round(width, 1)
);
}
if (width < tableWidth) {
$($(object).find('th').get()).each(function () {
// Now traverse the available columns for hiding
// and See which need to be hidden
if (!calculatedColumns.includes($(this).index())) {
var columnWidth = $.textMetrics(this).width + calculatedPadding;
$(this).find('div.sortinfo').attr('sort-column');
if (debug) {
console.log(
'ColIndex:' + $(this).index() +
', ColWidth:' + Math.round(columnWidth, 1) +
', TotalWidth:' + Math.round(calculatedWidth, 1) +
', PageWidth:' + Math.round(width, 1)
);
}
if (width < calculatedWidth) {
$(this).hide();
tableChanged = true;
} else {
calculatedColumns.push($(this).index());
calculatedWidth += columnWidth + calculatedPadding;
}
}
});
if (tableChanged) {
$($(object).find('td').each(function () {
if (!calculatedColumns.includes($(this).index())) {
$(this).hide();
}
}));
}
}
tableChanged = false;
if (allSeenWidth < width) {
// Since we can show hidden columns now, let's go
// in reverse until we run out of space
$($(object).find('th').get()).each(function () {
if (!calculatedColumns.includes($(this).index())) {
if ($(this).is(':hidden') && stopExpand == false) {
var columnWidth = $.textMetrics(this).width + calculatedPadding;
$(this).find('div.sortinfo').attr('sort-column');
if (allSeenWidth + columnWidth < tableWidth) {
$(this).show();
var newTableWidth = $(object).width();
if (debug) {
console.log(
'Reverse ColIndex:' + $(this).index() +
', columnWidth:' + Math.round(columnWidth, 1) +
', allSeenWidth:' + Math.round(allSeenWidth, 1) +
', width:' + Math.round(width, 1) +
', newTableWidth:' + Math.round(newTableWidth, 1)
);
}
if (newTableWidth > width) {
$(this).hide();
stopExpand = true;
} else {
calculatedColumns.push($(this).index());
tableChanged = true;
}
}
}
}
});
if (tableChanged) {
$($(object).find('td').each(function () {
if (calculatedColumns.includes($(this).index())) {
$(this).show();
}
}));
}
}
}
function tuneFilter(object, width) {
var timespan, clearWidth;
if ($(object).find('#timespan').length && $(object).find('#timespan').is(':visible')) {
timespan = true;
var timeShiftWidth = $(object).find('.shiftArrow').closest('td').width();
var dateWidth = $(object).find('#date1').closest('td').width() + $(object).find('#date1').closest('td').prev('td').width();
clearWidth = $('#tsclear').width();
var refreshWidth = $('#tsrefresh').width();
} else {
timespan = false;
clearWidth = $(object).find('#clear').width();
var saveWidth = $(object).find('#save').width();
var exportWidth = $(object).find('#export').width();
var importWidth = $(object).find('#import').width();
}
var minTds = 2;
var visTds = $(object).find('td:visible').length;
if ($(object).find('input[type="button"]').length) {
minTds++;
}
if ($(object).width() > width) {
if (!timespan) {
$($(object).find('td').get().reverse()).each(function () {
if ($(this).find('input[type="button"]').length == 0) {
if ($(this).is(':visible')) {
$(this).hide();
visTds--;
if ($(this).closest('td').prev().find('input, select').length == 0) {
$(this).closest('td').prev().hide();
visTds--;
}
}
if ($(object).width() < width) {
return false;
}
if (visTds <= minTds) {
return false;
}
}
});
if ($(object).width() > width) {
if (saveWidth > 0) {
$('#save').hide();
}
}
if ($(object).width() > width) {
if (exportWidth > 0) {
$('#export').hide();
}
}
if ($(object).width() > width) {
if (importWidth > 0) {
$('#import').hide();
}
}
if ($(object).width() > width) {
if (clearWidth > 0) {
$('#clear').hide();
}
}
} else {
$('#date1').closest('td').hide().prev('td').hide();
$('#date2').closest('td').hide().prev('td').hide();
if ($(object).width() > width) {
$('.shiftArrow').closest('td').hide();
}
if ($(object).width() > width) {
$('#tsclear').hide();
}
if ($(object).width() > width) {
$('#tsrefresh').hide();
}
}
} else {
if (!timespan) {
if ($(object).width() + clearWidth < width) {
$('#clear').show();
}
if ($(object).width() + importWidth < width) {
$('#import').show();
}
if ($(object).width() + exportWidth < width) {
$('#export').show();
}
if ($(object).width() + saveWidth < width) {
$('#save').show();
}
if ($(object).width() < width) {
$(object).find('td').each(function () {
if ($(this).find('input[type="button"]').length == 0) {
if (!$(this).is(':visible')) {
showWidth = $(this).width();
if ($(this).next('td').find('input, select').length > 0) {
showWidth += $(this).next('td').width();
}
if ($(object).width() + showWidth < width) {
$(this).show();
if ($(this).next('td').find('input, select').length > 0) {
$(this).next('td').show();
}
} else {
return false;
}
}
}
});
}
} else {
if ($(object).width() + refreshWidth < width) {
$('#tsrefresh').show();
}
if ($(object).width() + clearWidth < width) {
$('#tsclear').show();
}
if ($(object).width() + timeShiftWidth < width) {
$('.shiftArrow').closest('td').show();
}
if ($(object).width() + (2 * dateWidth) < width) {
$('#date1').closest('td').show().prev('td').show();
$('#date2').closest('td').show().prev('td').show();
}
}
}
}
function handleUserMenu(toggle) {
var storage = Storages.sessionStorage;
$(window).width();
/* set the navigation id is not set */
if (currentNavId == 'undefined' || currentNavId == null) {
currentNavId = 'menu:' + $('.lefttab.selected').attr('id');
}
/* check if the tab is selected */
var checkNav = currentNavId.replace('menu:', '');
if (!$('#'+checkNav).hasClass('selected')) {
$('#'+checkNav).addClass('selected');
}
if (toggle) {
if (currentNavState == 'visible') {
currentNavState = 'hidden';
} else {
currentNavState = 'visible';
}
} else if (currentNavState == null) {
currentNavState = 'visible';
}
storage.set(currentNavId, currentNavState);
if ($('#navigation').length) {
if (currentNavState == 'hidden') {
menuHide(true);
} else if (currentNavState == 'visible') {
menuShow();
}
}
}
function menuHide(store) {
var myClass = '';
var curMargin = Number.parseInt($('#navigation_right').css('margin-left'));
if ($('.cactiTreeNavigationArea').length) {
myClass = '.cactiTreeNavigationArea';
if (curMargin > 0) {
marginLeftTree = curMargin;
$('.cactiTreeNavigationArea').css('width', curMargin);
}
} else if ($('.cactiConsoleNavigationArea').length) {
myClass = '.cactiConsoleNavigationArea';
if (curMargin > 0) {
marginLeftConsole = curMargin;
}
}
$('#navigation_right').animate({ 'margin-left': '0px' }, 20);
if (myClass != '') {
$(myClass).hide('slide', { direction: 'left' }, 20, function () {
responsiveResizeGraphs();
});
}
$('#navigation').hide();
if (myClass == '.cactiTreeNavigationArea' || pageName == 'graph_view.php') {
responsiveResizeGraphs();
}
}
function menuShow() {
var myClass = '';
if (!userMenuNavigationExists(pageName)) {
if (pageName != 'graph_view.php' && pageName != 'about.php') {
$('#navigation').hide();
return;
}
} else if ($('#menu').length > 0) {
marginLeftConsole = $('#navigation').width();
}
if ($('.cactiTreeNavigationArea').length) {
myClass = '.cactiTreeNavigationArea';
if (marginLeftTree == null) {
marginLeftTree = minTreeWidth;
}
var treeWidth = $('.cactiTreeNavigationArea').width();
if (marginLeftTree > treeWidth) {
$('#navigation_right').animate({ 'margin-left': marginLeftTree }, 20);
$('.cactiTreeNavigationArea').css('width', marginLeftTree);
}
} else if ($('.cactiConsoleNavigationArea').length) {
myClass = '.cactiConsoleNavigationArea';
if (marginLeftConsole > 0) {
$('#navigation_right').animate({ 'margin-left': marginLeftConsole }, 20);
}
$('#navigation').show();
}
if (myClass != '') {
$(myClass).show('slide', { direction: 'left' }, 20, function () {
responsiveResizeGraphs();
});
}
$('#navigation').show();
}
function loadTopTab(href, id, force) {
var storage = Storages.sessionStorage;
/* used for debugging */
//getStackTrace(); // new Error().stack;
var url = href;// + (href.indexOf('?') > 0 ? '&' : '?') + 'headercontent=true';
/* close all toasts */
$.toast().reset('all');
/**
* set the last visible lefttabs have a menu state,
* right tabs do not and are always visible.
*/
if (id !== undefined && id.startsWith('tab-')) {
currentNavId = 'menu:'+id;
currentNavState = storage.get(currentNavId);
if (currentNavState == null) {
currentNavState = 'visible';
}
} else {
currentNavState = 'visible';
}
return loadUrl({
url: url,
tabId: id,
force: force,
loadType: 'toptab',
funcStart: 'loadTopTabStart',
funcEnd: 'loadTopTabEnd',
elementId: 'cactiContent'
});
}
function loadTopTabStart(options) {
$('.submenuoptions').slideUp(120);
$('.menuoptions').slideUp(120);
if (options.url.indexOf('graph_view.php') >= 0) {
$('.cactiGraphHeaderBackground').show();
$('.cactiConsolePageHeadBackdrop').hide();
} else if (userMenuNavigationExists(options.url)) {
$('.cactiGraphHeaderBackground').hide();
$('.cactiConsolePageHeadBackdrop').show();
}
}
function loadTopTabEnd(options) {
if (options.pageName != '') {
if ($('#menu').find("a[href^='" + escapeString(options.url) + "']").length > 0) {
$('#menu').find('.pic').removeClass('selected');
$('#menu').find("a[href^='" + escapeString(options.url) + "']").addClass('selected');
} else if ($('#menu').find("a[href*='/" + pageName + "']").length > 0) {
$('#menu').find('.pic').removeClass('selected');
$('#menu').find("a[href*='/" + pageName + "']").addClass('selected');
}
}
if (options.tabId) {
var tabElementId = '#' + options.tabId;
var tabElement = $(tabElementId);
if (tabElement.hasClass('lefttab')) {
$('.lefttab').removeClass('selected');
$('.submenuoptions').find('.selected').removeClass('selected');
tabElement.addClass('selected');
var hideTabId = tabElementId.substring(0, tabElementId.length - 9);
if (hideTabId && hideTabId != '#') {
$(hideTabId).addClass('selected');
}
} else if (tabElement.parents('.submenuoptions').length > 0) {
tabElement.parents('.submenuoptions').find('.selected').removeClass('selected');
tabElement.addClass('selected');
}
}
handleUserMenu();
}
function userMenuNavigationExists(url) {
if (url == 'index.php' || basename(url) == 'index.php') {
return true;
} else {
var myFound = false;
$('#navigation').find('a').each(function () {
var checkUrl = basename($(this).attr('href'));
if (checkUrl == url || checkUrl == basename(url)) {
myFound = true;
return true;
}
});
return myFound;
}
}
function loadPageUsingPost(href, postData, returnLocation) {
var stack = ''; //getStackTrace(); // new Error().stack;
console.error("Function loadPageUsingPost is now deprecated, use postUrl instead\n" + stack);
return postUrl({
url: href,
tabId: returnLocation,
type: 'loadPageUsingPost',
}, postData);
}
function setNavigationScroll() {
var object = '';
$('.cactiConsoleNavigationArea, .cactiTreeNavigationArea').rebind('mousemove', function (pos) {
object = '';
if ($('.cactiConsoleNavigationArea').length) {
object = '.cactiConsoleNavigationArea';
} else if ($('.cactiTreeNavigationArea').length) {
object = '.cactiTreeNavigationArea';
}
if (object != '') {
var mpos = $(object).position();
var width = $(object).outerWidth();
var height = $(object).outerHeight();
if (pos.pageX < mpos.left ||
pos.pageY < mpos.top ||
pos.pageX > mpos.left + width - 1 ||
pos.pageY > mpos.top + height - 1) {
if (isHover) {
clearTimeout(hoverTimer);
hoverTimer = setTimeout(function () {
$(object).css('overflow-y', 'hidden');
}, 500);
}
isHover = false;
} else {
if (!isHover) {
clearTimeout(hoverTimer);
hoverTimer = setTimeout(function () {
$(object).css('overflow-y', 'auto');
}, 500);
}
isHover = true;
}
}
});
$('.cactiConsoleNavigationArea, .cactiTreeNavigationArea').rebind('mouseleave', function (pos) {
if ($('.cactiConsoleNavigationArea').length) {
object = '.cactiConsoleNavigationArea';
} else if ($('.cactiTreeNavigationArea').length) {
object = '.cactiTreeNavigationArea';
}
isHover = false;
clearTimeout(hoverTimer);
hoverTimer = setTimeout(function () {
$(object).css('overflow-y', 'hidden');
}, 500);
});
}
function loadPageNoHeader(href, scroll, force) {
var stack = ''; //getStackTrace(); // new Error().stack;
console.error("Function loadPageNoHeader is now deprecated, use loadUrl instead\n" + stack);
return loadUrl({
url: href,
scroll: scroll,
force: force,
loadType: 'noheader'
});
}
function cactiPreparePostRequest(href, postData) {
var target = new URL(href, window.location.href);
if (target.origin !== window.location.origin) {
throw new Error('Refusing to send a CSRF token to a different origin');
}
if (typeof postData === 'string') {
postData = postData.replace(/(^|&)__csrf_magic=[^&]*/g, '').replace(/&{2,}/g, '&').replace(/^&|&$/g, '');
postData = '__csrf_magic=' + encodeURIComponent(csrfMagicToken) + (postData === '' ? '' : '&' + postData);
} else {
postData = $.extend({__csrf_magic: csrfMagicToken}, postData || {});
postData.__csrf_magic = csrfMagicToken;
}
return {
url: target.pathname + target.search,
data: postData
};
}
function cactiPreparePostRequestFromUrl(href) {
var target = new URL(href, window.location.href);
if (target.origin !== window.location.origin) {
throw new Error('Refusing to send a CSRF token to a different origin');
}
var fields = [];
target.searchParams.forEach(function (value, name) {
if (name !== '__csrf_magic') {
fields.push({name: name, value: value});
}
});
return cactiPreparePostRequest(target.pathname, $.param(fields));
}
function submitPageUsingPost(href) {
var request = cactiPreparePostRequestFromUrl(href);
var form = $('
';
var messageWidth = $(window).width();
if (messageWidth > 400) {
messageWidth = 400;
} else {
messageWidth -= 50;
}
$('#httperror').remove();
$('body').append(returnStr);
$('#httperror').dialog({
resizable: false,
height: 'auto',
width: messageWidth,
title: errorReasonTitle,
buttons: {
Ok: function () {
$(this).dialog('close');
}
}
});
}
}
if (url !== undefined) {
if (data.status >= 500) {
// Let the HTTP Error stick log an error
$.get(urlPath + 'help.php?page=' + encodeURIComponent(url) + '&error=' + data.status);
} else if (data.status >= 400) {
// Let the HTTP Error stick
} else if (data.statusText != 'abort') {
$.ajaxQ.abortAll();
document.location = url;
}
}
}
function ajaxAnchors() {
basename(location.pathname);
$(document).rebind('click.cactiPostAction', 'a.cactiPostAction', function (event) {
if (!shouldCaptureClick(event)) {
return;
}
event.preventDefault();
event.stopImmediatePropagation();
var href = $(this).data('url') || $(this).attr('href');
if (href != null && href != '#') {
submitPageUsingPost(href);
}
return false;
});
$('a.pic, a.linkOverDark, a.linkEditMain, a.console, a.hyperLink, a.tab').not('[href^="http"], [href^="https"], [href^="#"], [href^="mailto"], [target="_blank"]').not('.cactiPostAction').rebind('click', function (event) {
if (!shouldCaptureClick(event)) {
return;
}
event.preventDefault();
event.stopPropagation();
if ($(window).width() < 640) {
menuHide(false);
}
/* determine the page name */
var href = $(this).attr('href');
if (href == '#') {
return false;
}
/* update menu selection */
if ($(this).hasClass('pic')) {
$(this).addClass('selected');
}
/* update menu selection */
if ($(this).hasClass('lefttab')) {
$('.lefttab').removeClass('selected');
$(this).addClass('selected');
}
/* update menu selection */
if ($(this).hasClass('righttab')) {
$('.righttab').removeClass('selected');
$(this).addClass('selected');
}
if (href != null) {
pageName = basename(href);
}
loadUrl({
url: href,
loadType: 'loadPage'
});
return false;
});
}
function checkFormStatus(href, type, scroll_or_id) {
var changed = false;
if ($('.cactiFormStart').not('#chk').length) {
$('.cactiFormStart').not('#chk').each(function () {
var formID = $(this).attr('id');
var submitData = $(this).serializeForm();
if (typeof formArray != 'undefined' && formArray[formID] !== undefined) {
var formData = formArray[formID];
$.each(submitData, function (index, value) {
if (formData[index] !== undefined) {
if (formData[index] != value) {
if (index == 'settings_sendmail_path' || index == 'rrd_archive' || index == '__csrf_magicSubmit' || index == '__csrf_magic' || index == 'settings_smtp_password' || index == 'settings_smtp_password_confirm') {
// Ignore this entry
} else if (index.indexOf('[]') > 0) {
// Ignore this entry
} else {
console.log('Index:-' + index + '-:Submit:' + value + ', Orig:' + formData[index]);
changed = true;
}
}
}
});
}
});
if (changed) {
warningMessage(href, type, scroll_or_id);
return false;
} else {
return true;
}
} else {
return true;
}
}
function setupCollapsible() {
var storage = Storages.sessionStorage;
$('.collapsible').each(function (data) {
var state;
var id = $(this).attr('id') + '_cs';
if (storage.isSet(id)) {
state = storage.get(id);
} else {
state = 'show';
}
if (state == 'hide') {
$(this).addClass('collapsed');
$(this).nextUntil('div.spacer', 'div.formRow').hide();
$(this).find('i').removeClass('ti-chevrons-up').addClass('ti-chevrons-down');
storage.set(id, 'hide');
}
});
$('.collapsible').rebind('click', function (data) {
var id = $(this).attr('id') + '_cs';
if ($(this).find('i').hasClass('ti-chevrons-up')) {
$(this).addClass('collapsed');
$(this).nextUntil('div.spacer', 'div.formRow').slideUp('slow');
$(this).find('i').removeClass('ti-chevrons-up').addClass('ti-chevrons-down');
storage.set(id, 'hide');
} else {
$(this).removeClass('collapsed');
$(this).nextUntil('div.spacer', 'div.formRow').slideDown('slow');
$(this).nextUntil('div.spacer', 'div.formRow').each(function(data) {
$(this).find('input, select').trigger('change');
});
$(this).find('i').removeClass('ti-chevrons-down').addClass('ti-chevrons-up');
storage.set(id, 'show');
}
});
}
function openUserMenu() {
$('.user').removeClass('usermenuup').addClass('usermenudown');
$('.menuoptions').slideDown(120, 'easeInOutCubic');
}
function closeUserMenu() {
$('.user').removeClass('usermenudown').addClass('usermenuup');
$('.menuoptions').slideUp(120, 'easeInOutCubic');
}
function handleConsole(pageName) {
if (pageName == null || pageName.length == 0) {
pageName = basename($(location).attr('pathname'));
}
// Modify the console pic
$('#menu_main_console').find('.menu_parent').attr('href', 'index.php').addClass('console selected');
$('#menu_main_console_div').remove();
if (pageName != 'index.php') {
$('#menu_main_console').find('.menu_parent').removeClass('selected');
}
}
function setupUserMenu() {
handleConsole();
$('.menuoptions').on('mouseenter', function () {
clearTimeout(userMenuTimer);
}).on('mouseleave', function () {
if ($('.menuoptions').is(':visible')) {
userMenuTimer = setTimeout(function () { closeUserMenu(); }, 1000);
}
});
$('.user').on('mouseenter', function (data) {
clearTimeout(userMenuTimer);
userMenuOpenTimer = setTimeout(function () { openUserMenu(); }, 400);
openUserMenu();
}).on('mouseleave', function (data) {
if ($('.menuoptions').is(':visible')) {
userMenuTimer = setTimeout(function () { closeUserMenu(); }, 1000);
} else {
clearTimeout(userMenuOpenTimer);
}
});
}
function setupSpecialKeys() {
if (!isMobile.any()) {
$('#filter, #rfilter').trigger('focus');
} else {
$('#filter, #rfilter').prop('size', '15');
}
// Clicking the search glyph applies the filter: submit its form, or on the modern bar (no form) trigger Enter.
$(document).rebind('click.cactiSearchIcon', 'i.ti.ti-search.filter', function () {
var input = $(this).prev('input').get(0);
if (!input) {
return;
}
if (input.form) {
if (typeof input.form.requestSubmit === 'function') {
input.form.requestSubmit();
} else {
$(input.form).trigger('submit');
}
} else {
$(input).trigger($.Event('keydown', { keyCode: 13, which: 13, key: 'Enter' }));
}
});
}
/**
* setupSortable - This function will set all actions for sortable columns
* every time a page is regenerated
*/
function setupSortable() {
$('th.sortable').on('click', function (e) {
document.getSelection().removeAllRanges();
var $target = $(e.target);
var sortAdd = '';
if (!$target.is('.ui-resizable-handle')) {
var page = $(this).find('.sortinfo').attr('sort-page');
var column = $(this).find('.sortinfo').attr('sort-column');
var direction = $(this).find('.sortinfo').attr('sort-direction');
var returnto = $(this).find('.sortinfo').attr('sort-return');
if (shiftPressed) {
sortAdd = '&add=true';
} else {
sortAdd = '&add=reset';
}
url = page + (page.indexOf('?') > 0 ? '&' : '?') +
'sort_column=' + column +
'&sort_direction=' + direction +
sortAdd;
loadUrl({
url: url,
elementId: returnto
});
}
});
}
function shouldCaptureClick(event) {
var evt = event ? event : window.event;
return !(evt.shiftKey || evt.altKey || evt.ctrlKey || evt.metaKey);
}
function setupBreadcrumbs() {
$('#breadcrumbs > li > a').on('click', function (event) {
if (!shouldCaptureClick(event))
return
event.preventDefault();
event.stopPropagation();
var href = $(this).attr('href');
if (href != '#') {
href = href.replace('action=tree_content', 'action=tree');
$(this).prop('href', href);
document.location = href;
}
});
}
/**
* saveTableWidths - This function will initialize table widths on page
* load. It includes the 'initial' boolean to initialize the page
*/
function saveTableWidths(initial) {
// We will save columns widths persistently
var storage = Storages.localStorage;
// Initialize table width on the page
$('table.cactiTable').each(function (data) {
var sizes, items;
var table = $(this);
// Persist widths under the action-independent data-colsizing key when it
// is present, so a table keeps its column widths across reloads that
// change the request action/report/tab (e.g. a filter refresh). Fall back
// to the DOM id for any table without the attribute.
var key = table.attr('data-colsizing');
if (key === undefined || key === '') {
key = table.attr('id');
}
if (storage.isSet(key)) {
sizes = storage.get(key);
} else {
sizes = new Array();
}
items = sizes ? sizes : new Array();
var width = $(document).width();
// if the table width changes, reset the columns
if (key !== undefined && sizes == undefined) {
storage.remove(key);
sizes = new Array();
items = new Array();
} else if (key !== undefined && initial) {
if (items.length > 0) {
if (items[0] + 18 < width) {
storage.remove(key);
sizes = new Array();
items = new Array();
}
}
}
var i = 1;
items[0] = width;
sizes[0] = width;
if (key !== undefined) {
if (initial && items.length > 1) {
table.find('th.ui-resizable').each(function (data) {
if (items[i] == 0) {
items[i] = $(this).width();
sizes[i] = items[i];
}
if (items[i] != 0) {
$(this).css('width', items[i]);
$(this).attr('resizeWidth', items[i]);
}
i++;
});
} else {
table.find('th.ui-resizable').each(function (data) {
sizes[i] = $(this).width();
if (sizes[i] != 0) {
$(this).css('width', items[i]);
$(this).attr('resizeWidth', sizes[i]);
}
i++;
});
if (i > 1) {
storage.set(key, sizes);
}
}
}
});
}
/** applyTableSizing - This function sets all table headers to be resizable using
* the jQueryUI function resizable. It also calls the saveTableWidths function
* to store the widths in localStorage every time a column is resized. */
function applyTableSizing() {
var originalSize = 0;
var colWidth = 0;
$('.tableHeader').not('.tableFixed').find('th').resizable({
handles: 'e',
start: function (event, ui) {
colWidth = $(this).width();
originalSize = ui.size.width;
if (originalSize == 0) {
originalSize = $(this).width();
}
$(ui.originalElement).siblings().each(function (data) {
$(this).attr('resizeWidth', $(this).width());
});
},
resize: function (event, ui) {
var resizeDelta = ui.size.width - originalSize;
var newColWidth = colWidth + resizeDelta;
var nextWidth = $(ui.element).next().attr('resizeWidth');
$(ui.element).next().css('width', nextWidth - resizeDelta);
$(ui.element).prevUntil('tr').each(function (data) {
$(this).css('width', $(this).attr('resizeWidth'));
});
$(this).css('height', 'auto');
},
stop: function (event, ui) {
saveTableWidths(false);
}
});
$('.tableHeader').not('.tableFixed').each(function () {
$(this).find('th').filter(function () {
return $(this).css('display') != 'none';
}).last().resizable('destroy');
});
saveTableWidths(true);
}
function correctUrlParameters(url) {
if (url.indexOf('action=tree_content') < 0 && url.indexOf('action=tree') >= 0) {
url = url.replace('action=tree', 'action=tree_content');
}
return url;
}
/** setupPageTimeout - This function will setup the page timeout based upon
* the plugin developers $refresh requirements. It also sets up a location
* to redirect the user to upon timeout. This is generally done for automatically
* logging out the user, but can be used for simply refreshing the page as in the
* case of the Graphs page. */
function setupPageTimeout() {
if (typeof myRefresh != 'undefined') {
clearTimeout(myRefresh);
}
if (typeof refreshMSeconds != 'undefined') {
myRefresh = setTimeout(function () {
if (refreshIsLogout) {
document.location = urlPath + 'logout.php?action=timeout';
} else {
if (previousPage != '') {
refreshPage = previousPage;
}
/* fix coner case with tree refresh */
if (refreshFunction == '') {
refreshPage = correctUrlParameters(refreshPage);
loadUrl({ url: refreshPage });
} else {
var funct = refreshFunction.replace('()', '');
window[funct]();
setupPageTimeout();
}
}
}, refreshMSeconds);
}
}
function pulsateStart(element) {
pulsating = true;
pulsate(element);
}
function pulsate(element) {
if (pulsating) {
$(element || this).delay(100).fadeOut(800).delay(100).fadeIn(800, pulsate);
}
}
function pulsateStop(element) {
pulsating = false;
}
function setTitleAndHref() {
myHref = $(location).attr('href');
myTitle = $(document).attr('title');
}
function clearAllTimeouts() {
if (typeof installTimer != 'undefined') {
return true;
}
var id = window.setTimeout(function () { }, 0);
while (id--) {
window.clearTimeout(id); // will do nothing if no timeout with id is present
}
}
function setZoneInfo() {
var dt = new Date();
var tz = -dt.getTimezoneOffset();
var CactiDateTime = 'CactiDateTime=' + dt.toString() + '; Max-Age: -1; path=' + urlPath + '; SameSite=Strict;';
var CactiTimeZone = 'CactiTimeZone=' + tz.toString() + '; Max-Age: -1; path=' + urlPath + '; SameSite=Strict;';
if (window.location.protocol == 'https:') {
CactiDateTime += ' Secure;';
CactiTimeZone += ' Secure;';
}
document.cookie = CactiDateTime;
document.cookie = CactiTimeZone;
}
$(function (){
cactiReady();
});
function cactiReady() {
statePushed = false;
popFired = false;
var tapped = false;
/**
* Unbind key elements to debounce actions
*/
$('input, select, textarea, a').off();
// Use traditional popstate handler
window.onpopstate = function (event) {
handlePopState(event);
}
// Don't allow selection when shift is pressed
$(document).on('mousedown', function (event) {
if (event.shiftKey) {
event.preventDefault();
}
});
$('#filter, #rfilter').on('keydown', function (event) {
if (event.keyCode == 8 && $(this).val() == '') {
handlePopState();
}
});
setZoneInfo();
setTitleAndHref();
setupUserMenu();
applySkin();
initGraphDrilldown();
setupEllipsis();
handleUserMenu();
$('#navigation_right').show();
if (isMobile.any() != null) {
$(window).on('touchstart', function (event) {
if (!tapped) {
tapped = setTimeout(function () { tapped = null; }, 300);
} else {
clearTimeout(tapped);
tapped = null;
if (screenfull.isEnabled) {
screenfull.request();
}
}
});
$(window).on('load', function (event) {
setTimeout(function () { window.scrollTo(0, 1); }, 0);
});
}
}
/* only perform the recalculation of elements at the final end of the windows resize event */
var waitForFinalEvent = (function () {
var timers = {};
return function (callback, ms, uniqueId) {
if (!uniqueId) {
uniqueId = "Don't call this twice without a uniqueId";
}
if (timers[uniqueId]) {
clearTimeout(timers[uniqueId]);
}
timers[uniqueId] = setTimeout(callback, ms);
};
})();
function setSelectMenus() {
$.widget('ui.selectmenu', $.ui.selectmenu, {
_renderMenu: function(ul, items) {
let that = this;
let attr = this.element[0].attributes;
$.each( items, function( index, item ) {
that._renderItemData( ul, item );
});
if (attr['data-defaultLabel'] !== undefined) {
if(this.menuWrap.find('input').length === 0) {
this.menuWrap.prepend('');
}
this._on(false, this.menuWrap.find('input'), {
'keydown': function (event) {
var preventDefault = true;
switch ( event.keyCode ) {
case $.ui.keyCode.TAB:
case $.ui.keyCode.ESCAPE:
this.close(event);
break;
case $.ui.keyCode.ENTER:
case $.ui.keyCode.UP:
case $.ui.keyCode.DOWN:
case $.ui.keyCode.HOME:
case $.ui.keyCode.PAGE_UP:
case $.ui.keyCode.END:
case $.ui.keyCode.PAGE_DOWN:
case $.ui.keyCode.SPACE:
this.menu.trigger(event);
break;
default:
preventDefault = false;
break;
}
if ( preventDefault ) {
event.preventDefault();
}
},
'input': function (event) {
let search_string = that.menuWrap.find('input').val().toUpperCase();
$(ul).find('li').each(function (index, item) {
if ($(this).text().toUpperCase().indexOf(search_string) > -1) {
$(this).addClass('ui-menu-item').prop('hidden', false);
} else {
$(this).removeClass('ui-menu-item').prop('hidden', true);
}
})
}
})
}
},
_renderButtonItem: function(item) {
let attr = this.element[0].attributes;
let showDefaultLabel = select2Setup["displayDefaultLabel"];
if (attr['data-defaultLabel'] !== undefined) {
let defaultLabel = attr['data-defaultLabel'].value;
let filterActive = '';
let defaultIndex = 0;
let defaultValue = this.element.find("option").eq(0).val();
if (attr['data-defaultValue'] !== undefined) {
let defaultValue = attr['data-defaultValue'].value;
}
filterActive = (defaultValue !== item.value) ? 'true' : 'false';
/* fallback to index value -- maybe superfluous */
if (filterActive === '') {
filterActive = (defaultIndex !== item.index) ? 'true' : 'false';
}
let buttonItem = $('