mirror of
https://github.com/Cacti/cacti.git
synced 2026-11-08 21:16:17 +09:00
226 lines
8.6 KiB
JavaScript
226 lines
8.6 KiB
JavaScript
/*
|
|
+-------------------------------------------------------------------------+
|
|
| Copyright (C) 2004-2023 The Cacti Group |
|
|
| |
|
|
| 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. |
|
|
+-------------------------------------------------------------------------+
|
|
| Cacti: The Complete RRDTool-based Graphing Solution |
|
|
+-------------------------------------------------------------------------+
|
|
| This code is designed, written, and maintained by the Cacti Group. See |
|
|
| about.php and/or the AUTHORS file for specific developer information. |
|
|
+-------------------------------------------------------------------------+
|
|
| http://www.cacti.net/ |
|
|
+-------------------------------------------------------------------------+
|
|
*/
|
|
|
|
function themeReady() {
|
|
if ($('#cactiPageBottom').length == 0) {
|
|
$('<div id="cactiPageBottom" class="cactiPageBottom"></a></div>').insertAfter('#cactiContent');
|
|
}
|
|
|
|
// Setup the navigation menu
|
|
setMenuVisibility();
|
|
|
|
// Add nice search filter to filters
|
|
if ($('input[id="filter"]').length > 0) {
|
|
$('input[id="filter"]').after("<i class='fa fa-search filter'/>").attr('autocomplete', 'off').attr('placeholder', searchFilter).parent('td').css('white-space', 'nowrap');
|
|
}
|
|
|
|
if ($('input[id="filterd"]').length > 0) {
|
|
$('input[id="filterd"]').after("<i class='fa fa-search filter'/>").attr('autocomplete', 'off').attr('placeholder', searchFilter).parent('td').css('white-space', 'nowrap');
|
|
}
|
|
|
|
if ($('input[id="rfilter"]').length > 0) {
|
|
$('input[id="rfilter"]').after("<i class='fa fa-search filter'/>").attr('autocomplete', 'off').attr('placeholder', searchRFilter).parent('td').css('white-space', 'nowrap');
|
|
}
|
|
|
|
$('input#filter, input#rfilter').addClass('ui-state-default ui-corner-all');
|
|
|
|
$('input[type="text"], input[type="password"], input[type="checkbox"], textarea').not('image').addClass('ui-state-default ui-corner-all');
|
|
|
|
/* Start clean up */
|
|
|
|
//login page
|
|
$('.cactiLoginLogo').html("<i class='fa fa-paw'/>").css('font-size: 20px');
|
|
|
|
/* clean up the navigation menu */
|
|
$('.cactiConsoleNavigationArea').find('#menu').appendTo($('.cactiConsoleNavigationArea').find('#navigation'));
|
|
$('.cactiConsoleNavigationArea').find('#navigation > table').remove();
|
|
|
|
$('.maintabs nav ul li a.lefttab').each( function() {
|
|
id = $(this).attr('id');
|
|
|
|
if (id == 'tab-graphs' && $(this).parent().hasClass('maintabs-has-submenu') == 0 ) {
|
|
$(this).parent().addClass('maintabs-has-submenu');
|
|
$('<div class="dropdownMenu">'
|
|
+'<ul id="submenu-tab-graphs" class="submenuoptions" style="display:none;">'
|
|
+'<li><a href="'+urlPath+'graph_view.php?action=tree">'+treeView+'</a></li>'
|
|
+'<li><a href="'+urlPath+'graph_view.php?action=list">'+listView+'</a></li>'
|
|
+'<li><a href="'+urlPath+'graph_view.php?action=preview">'+previewView+'</a></li>'
|
|
+'</ul>'
|
|
+'</div>').appendTo('body');
|
|
}
|
|
});
|
|
|
|
/* user menu on the right ... */
|
|
if ($('.usertabs').length == 0) {
|
|
$('#userDocumentation').remove();
|
|
$('#userCommunity').remove();
|
|
$('.menuHr').remove();
|
|
$('<div class="maintabs usertabs">'
|
|
+'<nav><ul>'
|
|
+'<li><a id="menu-user-help" class="usertabs-submenu" href="#"><i class="fa fa-question"></i></a></li>'
|
|
+'<li class="action-icon-user"><a class="pic" href="#"><i class="fa fa-user"></i></a></li>'
|
|
+'</ul></nav>'
|
|
+'</div>').insertAfter('.maintabs');
|
|
|
|
$('<div class="dropdownMenu">'
|
|
+'<ul id="submenu-user-help" class="submenuoptions right" style="display:none;">'
|
|
+'<li><a href="https://www.cacti.net" target="_blank"><span>'+cactiHome+'</span></a></li>'
|
|
+'<li><a href="https://github.com/cacti" target="_blank"><span>'+cactiProjectPage+'</span></a></li>'
|
|
+'<li><hr class="menu"></li>'
|
|
+'<li><a href="https://forums.cacti.net/" target="_blank"><span>'+cactiCommunityForum+'</span></a></li>'
|
|
+'<li><a href="https://github.com/Cacti/documentation/blob/develop/README.md" target="_blank"><span>'+cactiDocumentation+'</span></a></li>'
|
|
+'<li><hr class="menu"></li>'
|
|
+'<li><a href="https://github.com/Cacti/cacti/issues/new" target="_blank"><span>'+reportABug+'</span></a></li>'
|
|
+'<li><a href="'+urlPath+'about.php"><span>'+aboutCacti+'</span></a></li>'
|
|
+'</ul>'
|
|
+'</div>').appendTo('body');
|
|
}
|
|
|
|
ajaxAnchors();
|
|
|
|
/* User Menu */
|
|
$('.menuoptions').parent().appendTo('body');
|
|
|
|
$(window).trigger('resize');
|
|
|
|
$('.action-icon-user').unbind().click(function(event) {
|
|
event.preventDefault();
|
|
|
|
if ($('.menuoptions').is(':visible') === false) {
|
|
$('.submenuoptions').slideUp(120);
|
|
$('.menuoptions').slideDown(120);
|
|
} else {
|
|
$('.menuoptions').slideUp(120);
|
|
}
|
|
|
|
return false;
|
|
});
|
|
|
|
/* Highlight sortable table columns */
|
|
$('.tableHeader th').has('i.fa-sort').removeClass('tableHeaderColumnHover tableHeaderColumnSelected');
|
|
$('.tableHeader th').has('i.fa-sort-up').addClass('tableHeaderColumnSelected');
|
|
$('.tableHeader th').has('i.fa-sort-down').addClass('tableHeaderColumnSelected');
|
|
$('.tableHeader th').has('i.fa-sort').hover(
|
|
function() {
|
|
$(this).addClass('tableHeaderColumnHover');
|
|
}, function() {
|
|
$(this).removeClass('tableHeaderColumnHover');
|
|
}
|
|
);
|
|
|
|
$('input#filter, input#rfilter').addClass('ui-state-default ui-corner-all');
|
|
|
|
$('input[type="text"], input[type="password"], input[type="checkbox"], textarea').not('image').addClass('ui-state-default ui-corner-all');
|
|
|
|
$('select.colordropdown').dropcolor();
|
|
|
|
$('select').not('.colordropdown, #user_language').each(function() {
|
|
if ($(this).prop('multiple') != true) {
|
|
$(this).each(function() {
|
|
id = $(this).attr('id');
|
|
|
|
$(this).selectmenu({
|
|
change: function(event, ui) {
|
|
$(this).val(ui.item.value).change();
|
|
},
|
|
position: {
|
|
my: "left top",
|
|
at: "left bottom",
|
|
collision: "flip"
|
|
},
|
|
width: 'auto'
|
|
});
|
|
|
|
$('#'+id+'-menu').css('max-height', '250px');
|
|
});
|
|
} else {
|
|
$(this).addClass('ui-state-default ui-corner-all');
|
|
}
|
|
});
|
|
|
|
renderLanguages();
|
|
|
|
/* End clean up */
|
|
|
|
/* Notification Handler */
|
|
if ($('#message').length) {
|
|
// alert($('#message_container').html());
|
|
}
|
|
|
|
/* Replace icons */
|
|
$('.fa-arrow-down').addClass('fa-chevron-down').removeClass('fa-arrow-down');
|
|
$('.fa-arrow-up').addClass('fa-chevron-up').removeClass('fa-arrow-up');
|
|
$('.fa-remove').addClass('fa-trash-o').removeClass('fa-remove');
|
|
|
|
setNavigationScroll();
|
|
}
|
|
|
|
function setMenuVisibility() {
|
|
storage=Storages.localStorage;
|
|
|
|
// Initialize the navigation settings
|
|
$('#navigation').hide();
|
|
$('li.menuitem').each(function() {
|
|
active = storage.get($(this).attr('id'));
|
|
if (active != null && active == 'active') {
|
|
$(this).find('ul').attr('aria-hidden', 'false').attr('aria-expanded', 'true').show();
|
|
$(this).next('a').show();
|
|
} else {
|
|
$(this).find('ul').attr('aria-hidden', 'true').attr('aria-expanded', 'false').hide();
|
|
$(this).next('a').hide();
|
|
}
|
|
});
|
|
|
|
$('#navigation').show();
|
|
|
|
// Functon to give life to the Navigation pane
|
|
$('#nav li:has(ul) a.active').unbind().click(function(event) {
|
|
event.preventDefault();
|
|
|
|
id = $(this).closest('.menuitem').attr('id');
|
|
|
|
if ($(this).next().is(':visible')){
|
|
$(this).next('ul').attr('aria-hidden', 'true').attr('aria-expanded', 'false');
|
|
$(this).next().slideUp( { duration: 200, easing: 'swing' } );
|
|
storage.set($(this).closest('.menuitem').attr('id'), 'collapsed');
|
|
} else {
|
|
$(this).next('ul').attr('aria-hidden', 'false').attr('aria-expanded', 'true');
|
|
$(this).next().slideToggle( { duration: 200, easing: 'swing' } );
|
|
if ($(this).next().is(':visible')) {
|
|
storage.set($(this).closest('.menuitem').attr('id'), 'active');
|
|
} else {
|
|
storage.set($(this).closest('.menuitem').attr('id'), 'collapsed');
|
|
}
|
|
}
|
|
|
|
$('li.menuitem').not('#'+id).each(function() {
|
|
text = $(this).attr('id');
|
|
id = $(this).attr('id');
|
|
|
|
$(this).find('ul').attr('aria-hidden', 'true').attr('aria-expanded', 'false');
|
|
$(this).find('ul').slideUp( { duration: 200, easing: 'swing' } );
|
|
storage.set($(this).attr('id'), 'collapsed');
|
|
});
|
|
});
|
|
}
|