root / templates / munstrap / static / js / munstrap.js @ 8589c6df
Historique | Voir | Annoter | Télécharger (1,17 ko)
| 1 |
/*
|
|---|---|
| 2 |
* Sanitize all tab links
|
| 3 |
*/
|
| 4 |
$("ul#tabs>li>a").each(function (index) { |
| 5 |
var eid = $(this).attr('href').replace(/[^#\w]/gi, '_'); |
| 6 |
$(this).attr('href', eid); |
| 7 |
}); |
| 8 |
|
| 9 |
/*
|
| 10 |
* Sanitize all tab ids
|
| 11 |
*/
|
| 12 |
$("div#munin_nodeview_tab>div").each(function (index) { |
| 13 |
var eid = $(this).attr('id').replace(/[^\w]/gi, '_'); |
| 14 |
$(this).attr('id', eid); |
| 15 |
}); |
| 16 |
|
| 17 |
/*
|
| 18 |
* Update the URL with selected tab and active selected tab on page refresh
|
| 19 |
*/
|
| 20 |
(function () {
|
| 21 |
'use strict';
|
| 22 |
|
| 23 |
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { |
| 24 |
var id = $(this).parents('[role="tablist"]').attr('id'); |
| 25 |
var key = 'lastTag'; |
| 26 |
if (id) {
|
| 27 |
key += ':' + id;
|
| 28 |
} |
| 29 |
|
| 30 |
localStorage.setItem(key, $(e.target).attr('href')); |
| 31 |
location.hash = $(e.target).attr('href'); |
| 32 |
}); |
| 33 |
|
| 34 |
$('[role="tablist"]').each(function (idx, elem) { |
| 35 |
var id = $(elem).attr('id'); |
| 36 |
var key = 'lastTag'; |
| 37 |
if (id) {
|
| 38 |
key += ':' + id;
|
| 39 |
} |
| 40 |
|
| 41 |
var lastTab = localStorage.getItem(key);
|
| 42 |
if (!lastTab) {
|
| 43 |
lastTab = location.hash; |
| 44 |
} |
| 45 |
if (lastTab) {
|
| 46 |
$('[href="' + lastTab + '"]').tab('show'); |
| 47 |
} |
| 48 |
}); |
| 49 |
})(); |
