MediaWiki:Common.js: Unterschied zwischen den Versionen

Aus WIKI LAUER-FISCHER GmbH
Wechseln zu: Navigation, Suche
 
(15 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
// Delete WINAPO SQL from Addon-Produkte and insert a new link after Addon-Produkte.
+
var cookieName = "sectionVisible"
// That way WINAPO SQL looks like big link and is not affected by slideToggle() on Addon-Produkte.
+
 
 
jQuery(document).ready(function () {
 
jQuery(document).ready(function () {
     if (jQuery("#n-WINAPO-SQL").length > 0) {
+
     "use strict"
        var sql_margin_top = jQuery("#n-WINAPO-SQL a").css("margin-top");
+
    // Register slideToggle() on each category.
        var sql_margin_bottom = "calc(" + jQuery("#p-AddOn-Produkte").css("margin-bottom") + " + " + jQuery("#p-AddOn-Produkte div").css("padding-bottom") + ")";
+
    var makeOnClick = generateMakeOnClick();
        var sql_font_size = jQuery("#n-WINAPO-SQL a").css("font-size");
 
        var sql_padding_left = jQuery("#p-search > h3").css("padding-left");
 
        var sql_line_height = jQuery("#n-WINAPO-SQL a").css("line-height");
 
        var sql_height = jQuery("#n-WINAPO-SQL a").css("height");
 
  
 
        jQuery("#n-WINAPO-SQL").detach();
 
        jQuery("#p-AddOn-Produkte").css({ "margin-bottom": "0px" });
 
        jQuery("#p-AddOn-Produkte div").css({ "padding-bottom": "0px" });
 
        jQuery("#p-AddOn-Produkte").after("<a href=\"/Kategorie:WINAPO_SQL\" class=\"portlet generated-sidebar\"><h3>WINAPO SQL</h3></a>");
 
        jQuery("#p-AddOn-Produkte + a > h3").css({ "margin-bottom": "0px", "margin-top": "0px", "padding-left": sql_padding_left, "padding-top": "0px", "padding-bottom": "0px", "font-size": sql_font_size, "line-height": sql_line_height, "height": sql_height });
 
        jQuery("#p-AddOn-Produkte + a").css({ "display": "block", "margin-bottom": sql_margin_bottom, "margin-top": sql_margin_top, "padding-top": "0px", "padding-bottom": "0px" });
 
    }
 
 
    // Register slideToggle() on each category.
 
 
     jQuery("div.generated-sidebar.portlet").each(makeOnClick);
 
     jQuery("div.generated-sidebar.portlet").each(makeOnClick);
 +
    makeOnClick.defaultExpanded = false;
 +
    jQuery("#p-tb").each(makeOnClick);
 
});
 
});
  
 
// Registers the slideToggle() function on this and sets up the cookie
 
// Registers the slideToggle() function on this and sets up the cookie
function makeOnClick(n) {
+
function generateMakeOnClick() {
 
     "use strict";
 
     "use strict";
  
     jQuery(this).attr({ "role": "button", "type": "button" });
+
     var n = 0;
 +
    var makeOnClick = function m() {
 +
        if (jQuery(this).children("h3").is(":hidden")) {
 +
            return;
 +
        }
  
    var cookie = getCookie("showSection" + n);
+
        var k = n
    var expanded;
 
  
    if (cookie === null) {
+
         n++
         expanded = true;
 
        setStateCookie(n, expanded);
 
    }
 
    else {
 
        expanded = cookie === "1";
 
    }
 
  
    jQuery(this).children("h3").attr("aria-pressed", expanded ? "true" : "false");
+
        jQuery(this).attr({ "role": "button", "type": "button" });
    jQuery(this).addClass(expanded ? "nav-expanded" : "nav-collapsed");
 
  
    if (expanded == false) {
+
        var expanded = m.defaultExpanded
        jQuery(this).children("div").hide();
 
    }
 
  
    jQuery(this).children("h3").click(function () {
+
         var cookie = getCookie(cookieName + k.toString());
         var newExpanded = jQuery(this).attr("aria-pressed") !== "true";
 
        setStateCookie(n, newExpanded);
 
  
         if (newExpanded) {
+
         if (cookie === null) {
             jQuery(this).parent().removeClass("nav-collapsed");
+
             setStateCookie(k, expanded);
            jQuery(this).parent().addClass("nav-expanded");
 
 
         }
 
         }
 
         else {
 
         else {
             jQuery(this).parent().removeClass("nav-expanded");
+
             expanded = cookie === "1";
            jQuery(this).parent().addClass("nav-collapsed");
 
 
         }
 
         }
  
         jQuery(this).parent().hide();
+
         jQuery(this).children("h3").attr("aria-pressed", expanded ? "true" : "false");
         setTimeout(function (e) {
+
         jQuery(this).children("h3").addClass(expanded ? "nav-expanded" : "nav-collapsed");
            e.show(0);
 
        }, 0, jQuery(this).parent());
 
  
         jQuery(this).attr("aria-pressed", newExpanded ? "true" : "false");
+
         if (expanded == false) {
 +
            jQuery(this).children("div").hide();
 +
        }
  
         jQuery(this).parent().children("div.pBody:first-of-type").slideToggle('fast');
+
         jQuery(this).children("h3").click(function () {
    })
+
            var newExpanded = jQuery(this).attr("aria-pressed") !== "true";
 +
            setStateCookie(k, newExpanded);
  
    function getCookie(key) {
+
            if (newExpanded) {
        "use strict";
+
                jQuery(this).removeClass("nav-collapsed");
        var cookieQuery = document.cookie.match('(?:^|;)\\s*' + key + '\\s*=\\s*([^;]+)');
+
                jQuery(this).addClass("nav-expanded");
 +
            }
 +
            else {
 +
                jQuery(this).removeClass("nav-expanded");
 +
                jQuery(this).addClass("nav-collapsed");
 +
            }
  
        return cookieQuery === null ? null : cookieQuery.pop();
+
            jQuery(this).attr("aria-pressed", newExpanded ? "true" : "false");
 +
 
 +
            jQuery(this).parent().children("div.pBody:first-of-type").slideToggle('fast');
 +
        })
 
     }
 
     }
  
     // Writes the  state of the k-th section into a cookie.
+
     makeOnClick.defaultExpanded = true
    function setStateCookie(k, expanded) {
 
        "use strict";
 
        var now = new Date();
 
        now.setFullYear(now.getFullYear() + 3);
 
  
        var expirationDate = now.toUTCString();
+
    return makeOnClick
 +
}
 +
function getCookie(key) {
 +
    "use strict";
 +
    var cookieQuery = document.cookie.match('(?:^|;)\\s*' + key + '\\s*=\\s*([^;]+)');
  
        var cookie = "showSection" + k.toString() + "=" + (expanded ? "1" : "0") + "; Expires=" + expirationDate + "; path=/";
+
    return cookieQuery === null ? null : cookieQuery.pop();
 +
}
  
        document.cookie = cookie;
+
// Writes the  state of the k-th section into a cookie.
    }
+
function setStateCookie(k, expanded) {
 +
    "use strict";
 +
    var now = new Date();
 +
    now.setFullYear(now.getFullYear() + 3);
 +
 
 +
    var expirationDate = now.toUTCString();
 +
 
 +
    var cookie = cookieName + k.toString() + "=" + (expanded ? "1" : "0") + "; Expires=" + expirationDate + "; path=/";
 +
 
 +
    document.cookie = cookie;
 
}
 
}

Aktuelle Version vom 13. April 2018, 14:59 Uhr

var cookieName = "sectionVisible"

jQuery(document).ready(function () {
    "use strict"
    // Register slideToggle() on each category.
    var makeOnClick = generateMakeOnClick();

    jQuery("div.generated-sidebar.portlet").each(makeOnClick);
    makeOnClick.defaultExpanded = false;
    jQuery("#p-tb").each(makeOnClick);
});

// Registers the slideToggle() function on this and sets up the cookie
function generateMakeOnClick() {
    "use strict";

    var n = 0;
    var makeOnClick = function m() {
        if (jQuery(this).children("h3").is(":hidden")) {
            return;
        }

        var k = n

        n++

        jQuery(this).attr({ "role": "button", "type": "button" });

        var expanded = m.defaultExpanded

        var cookie = getCookie(cookieName + k.toString());

        if (cookie === null) {
            setStateCookie(k, expanded);
        }
        else {
            expanded = cookie === "1";
        }

        jQuery(this).children("h3").attr("aria-pressed", expanded ? "true" : "false");
        jQuery(this).children("h3").addClass(expanded ? "nav-expanded" : "nav-collapsed");

        if (expanded == false) {
            jQuery(this).children("div").hide();
        }

        jQuery(this).children("h3").click(function () {
            var newExpanded = jQuery(this).attr("aria-pressed") !== "true";
            setStateCookie(k, newExpanded);

            if (newExpanded) {
                jQuery(this).removeClass("nav-collapsed");
                jQuery(this).addClass("nav-expanded");
            }
            else {
                jQuery(this).removeClass("nav-expanded");
                jQuery(this).addClass("nav-collapsed");
            }

            jQuery(this).attr("aria-pressed", newExpanded ? "true" : "false");

            jQuery(this).parent().children("div.pBody:first-of-type").slideToggle('fast');
        })
    }

    makeOnClick.defaultExpanded = true

    return makeOnClick
}
function getCookie(key) {
    "use strict";
    var cookieQuery = document.cookie.match('(?:^|;)\\s*' + key + '\\s*=\\s*([^;]+)');

    return cookieQuery === null ? null : cookieQuery.pop();
}

// Writes the  state of the k-th section into a cookie.
function setStateCookie(k, expanded) {
    "use strict";
    var now = new Date();
    now.setFullYear(now.getFullYear() + 3);

    var expirationDate = now.toUTCString();

    var cookie = cookieName + k.toString() + "=" + (expanded ? "1" : "0") + "; Expires=" + expirationDate + "; path=/";

    document.cookie = cookie;
}