| 1 |
/* global jQuery, PoweredCache */ |
| 2 |
/* eslint-disable */ |
| 3 |
|
| 4 |
(function ($) { |
| 5 |
// Use strict mode |
| 6 |
|
| 7 |
// Define global PoweredCache object if it does not exist |
| 8 |
if (typeof window.PoweredCache !== 'object') { |
| 9 |
window.PoweredCache = {}; |
| 10 |
} |
| 11 |
|
| 12 |
PoweredCache.pageToggles = function (page) { |
| 13 |
const body = $('body'); |
| 14 |
if (!body.hasClass('toplevel_page_powered-cache')) { |
| 15 |
return; |
| 16 |
} |
| 17 |
|
| 18 |
function showSettings(element) { |
| 19 |
const settings = $(`#${element.attr('aria-controls')}`); |
| 20 |
|
| 21 |
element.on('change', function () { |
| 22 |
if (element.is(':checked')) { |
| 23 |
settings.show(); |
| 24 |
} else { |
| 25 |
settings.hide(); |
| 26 |
} |
| 27 |
}); |
| 28 |
} |
| 29 |
|
| 30 |
function init() { |
| 31 |
const toggles = $('.sui-toggle input[type="checkbox"]'); |
| 32 |
|
| 33 |
toggles.each(function () { |
| 34 |
const toggle = $(this); |
| 35 |
|
| 36 |
if (undefined !== toggle.attr('aria-controls')) { |
| 37 |
showSettings(toggle); |
| 38 |
} |
| 39 |
}); |
| 40 |
} |
| 41 |
|
| 42 |
init(); |
| 43 |
|
| 44 |
return this; |
| 45 |
}; |
| 46 |
|
| 47 |
$('body').ready(function () { |
| 48 |
PoweredCache.pageToggles('toggles'); |
| 49 |
}); |
| 50 |
})(jQuery); |
| 51 |
|
| 52 |
/* eslint-enable */ |
| 53 |
|