- Welcome to the Kancolle Wiki!
- If you have any questions regarding site content, account registration, etc., please visit the KanColle Wiki Discord
MediaWiki:DetailToggle.js
Revision as of 08:45, 20 February 2016 by com>Ckwng (Compatibility with tabview)
Note: After saving, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
(function(mw, $) {
"use strict";
$(document).ready(function() {
if (typeof(Storage) === "undefined") {
return;
}
var ToggleStorage = function(property, property_default) {
if (!localStorage[property]) {
localStorage[property] = property_default;
}
return {
toggle: function() {
localStorage[property] = localStorage[property] === "show" ? "hide" : "show";
},
on: function() {
return localStorage[property] === "show";
}
};
}
function update(toggle_element, toggle) {
var property = toggle_element.data("target") || "default",
property_default = toggle_element.data("default") || "show",
target = "toggle-target-" + property,
target_class = "." + target,
toggleStorage = ToggleStorage(target, property_default);
if (toggle) {
toggleStorage.toggle();
}
if (toggleStorage.on()) {
$(".toggle-show").show();
$(".toggle-hide").hide();
$(target_class).show();
} else {
$(".toggle-show").hide();
$(".toggle-hide").show();
$(target_class).hide();
}
}
function updateContent() {
$(".toggle").each(function() {
var toggle_element = $(this);
toggle_element.show();
update(toggle_element);
toggle_element.off("click");
toggle_element.click(function() {
update(toggle_element, true);
});
});
}
updateContent();
mw.hook("wikipage.content").add(updateContent);
});
}(mediaWiki, jQuery));