2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/templates/munstrap/static/js/munstrap.js

31 lines
869 B
JavaScript
Raw Normal View History

2016-12-07 05:46:27 +01:00
/*
* Sanitize all tab links
*/
$( "ul#tabs>li>a" ).each(function( index ) {
2016-12-07 05:59:38 +01:00
var eid = $( this ).attr('href').replace(/[^#\w]/gi,'_');
2016-12-07 05:46:27 +01:00
$( this ).attr('href', eid);
});
/*
* Sanitize all tab ids
*/
$( "div#munin_nodeview_tab>div" ).each(function( index ) {
2016-12-07 05:59:38 +01:00
var eid = $( this ).attr('id').replace(/[^\w]/gi,'_');
2016-12-07 05:46:27 +01:00
$( this ).attr('id', eid);
});
/*
* Update the URL with selected tab and active selected tab on page refresh
*/
$(document).ready(function() {
if(location.hash) {
$('a[href="' + location.hash + '"]').tab('show');
}
$(document.body).on("click", "a[data-toggle=tab]", function(event) {
location.hash = this.getAttribute("href");
});
});
$(window).on('popstate', function() {
var anchor = location.hash || $("a[data-toggle=tab]").first().attr("href");
2016-12-07 05:59:38 +01:00
$('a[href="' + anchor + '"]').tab('show');
2016-12-07 05:46:27 +01:00
});