MediaWiki:Common.js: Unterschied zwischen den Versionen

Aus WIKI LAUER-FISCHER GmbH
Wechseln zu: Navigation, Suche
 
(23 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
var arrow_expanded = "url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gQ3JlYXRlZCB3aXRoIElua3NjYXBlIChodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy8pIC0tPgoKPHN2ZwogICB4bWxuczpkYz0iaHR0cDovL3B1cmwub3JnL2RjL2VsZW1lbnRzLzEuMS8iCiAgIHhtbG5zOmNjPSJodHRwOi8vY3JlYXRpdmVjb21tb25zLm9yZy9ucyMiCiAgIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyIKICAgeG1sbnM6c3ZnPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIgogICB4bWxuczpzb2RpcG9kaT0iaHR0cDovL3NvZGlwb2RpLnNvdXJjZWZvcmdlLm5ldC9EVEQvc29kaXBvZGktMC5kdGQiCiAgIHhtbG5zOmlua3NjYXBlPSJodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy9uYW1lc3BhY2VzL2lua3NjYXBlIgogICB3aWR0aD0iMTYiCiAgIGhlaWdodD0iMTYiCiAgIGlkPSJzdmcyIgogICB2ZXJzaW9uPSIxLjEiCiAgIGlua3NjYXBlOnZlcnNpb249IjAuNDguNSByMTAwNDAiCiAgIHNvZGlwb2RpOmRvY25hbWU9ImFycm93LWV4cGFuZGVkLnN2ZyI+CiAgPGRlZnMKICAgICBpZD0iZGVmczQiIC8+CiAgPHNvZGlwb2RpOm5hbWVkdmlldwogICAgIGlkPSJiYXNlIgogICAgIHBhZ2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AgICAgIDwvY2M6V29yaz4KICAgIDwvcmRmOlJERj4KICA8L21ldGFkYXRhPgogIDxnCiAgICAgaW5rc2NhcGU6bGFiZWw9IkxheWVyIDEiCiAgICAgaW5rc2NhcGU6Z3JvdXBtb2RlPSJsYXllciIKICAgICBpZD0ibGF5ZXIxIj4KICAgIDxwYXRoCiAgICAgICBkPSJtIDYuMDAxLDIuOTk4IDUuMDAxLDUgLTUuMDAxLDUgeiIKICAgICAgIGlkPSJwYXRoMjk5NyIKICAgICAgIGlua3NjYXBlOmNvbm5lY3Rvci1jdXJ2YXR1cmU9IjAiCiAgICAgICBzdHlsZT0iZmlsbDojNzk3OTc5IiAvPgogIDwvZz4KPC9zdmc+)";
 
  
// Delete WINAPO SQL from Addon-Produkte and insert a new link after Addon-Produkte.
 
// 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 () {
     var sql_margin_top = jQuery("#n-WINAPO-SQL a").css("margin-top");
+
     "use strict"
     var sql_margin_bottom = "calc(" + jQuery("#p-AddOn-Produkte").css("margin-bottom") + " + " + jQuery("#p-AddOn-Produkte div").css("padding-bottom") + ")";
+
     // Register slideToggle() on each category.
     var sql_font_size = jQuery("#n-WINAPO-SQL a").css("font-size");
+
     var makeOnClick = generateMakeOnClick();
    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 > h3").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).attr("aria-pressed", expanded ? "true" : "false");
+
        jQuery(this).attr({ "role": "button", "type": "button" });
    var css = expanded ? arrow_expanded : arrow_collapsed;
 
    jQuery(this).parent().css({ "background-image": css, "background-repeat": "no-repeat" });
 
  
    if (expanded) {
+
         var expanded = m.defaultExpanded
         jQuery(this).addClass("expanded");
 
    }
 
    else {
 
        jQuery(this).addClass("collapsed");
 
        jQuery(this).parent().children("div").hide();
 
    }
 
  
    jQuery(this).click(function () {
+
         var cookie = getCookie(cookieName + k.toString());
         jQuery(this).parent().children("div.pBody:first-of-type").slideToggle('fast');
 
  
         var newExpanded = jQuery(this).attr("aria-pressed") !== "true";
+
         if (cookie === null) {
        var newArrow = newExpanded ? arrow_expanded : arrow_collapsed;
+
             setStateCookie(k, expanded);
        setStateCookie(n, newExpanded);
 
        jQuery(this).parent().css("background-image", newArrow);
 
        jQuery(this).attr("aria-pressed", newExpanded ? "true" : "false");
 
 
 
        if (newExpanded) {
 
             jQuery(this).removeClass("collapsed").addClass("expanded");
 
 
         }
 
         }
 
         else {
 
         else {
             jQuery(this).removeClass("expanded").addClass("collapsed");
+
             expanded = cookie === "1";
 
         }
 
         }
    })
 
  
    function getCookie(key) {
+
        jQuery(this).children("h3").attr("aria-pressed", expanded ? "true" : "false");
        "use strict";
+
         jQuery(this).children("h3").addClass(expanded ? "nav-expanded" : "nav-collapsed");
         var cookieQuery = document.cookie.match('(?:^|;)\\s*' + key + '\\s*=\\s*([^;]+)');
 
  
         return cookieQuery === null ? null : cookieQuery.pop();
+
         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');
 +
        })
 
     }
 
     }
  
     // Writes the  state of the k-th section into a cookie.
+
     makeOnClick.defaultExpanded = true
     function setStateCookie(k, expanded) {
+
 
        "use strict";
+
     return makeOnClick
        var now = new Date();
+
}
        now.setFullYear(now.getFullYear() + 3);
+
function getCookie(key) {
 +
    "use strict";
 +
    var cookieQuery = document.cookie.match('(?:^|;)\\s*' + key + '\\s*=\\s*([^;]+)');
  
        var expirationDate = now.toUTCString();
+
    return cookieQuery === null ? null : cookieQuery.pop();
 +
}
  
        var cookie = "showSection" + k.toString() + "=" + (expanded ? "1" : "0") + "; Expires=" + expirationDate + "; path=/";
+
// 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);
  
        document.cookie = cookie;
+
    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;
}