MediaWiki:Common.js: Unterschied zwischen den Versionen
Olthir (Diskussion | Beiträge) |
|||
Zeile 27: | Zeile 27: | ||
req.send(); | req.send(); | ||
})(); | })(); | ||
+ | |||
+ | /** TEST **/ | ||
+ | $(".hp-tab").scroll(function() { | ||
+ | var maxScrollLeft = $(this).get(0).scrollWidth - $(this).get(0).clientWidth; | ||
+ | var leftPos = $(this).scrollLeft(); | ||
+ | if (leftPos > (maxScrollLeft - ((maxScrollLeft / 100) * 10))) { | ||
+ | $(this).removeClass("hp-arrow-both-mask"); | ||
+ | $(this).removeClass("hp-arrow-next-mask"); | ||
+ | $(this).addClass("hp-arrow-prev-mask"); | ||
+ | $(this).parent().closest(".hp-tab-wrapper").children(".hp-arrow-right").css('visibility', 'hidden'); | ||
+ | $(this).parent().closest(".hp-tab-wrapper").children(".hp-arrow-left").css('visibility', 'visible'); | ||
+ | } else if (leftPos < ((maxScrollLeft / 100) * 10)) { | ||
+ | $(this).removeClass("hp-arrow-both-mask"); | ||
+ | $(this).removeClass("hp-arrow-prev-mask"); | ||
+ | $(this).addClass("hp-arrow-next-mask"); | ||
+ | $(this).parent().closest(".hp-tab-wrapper").children(".hp-arrow-right").css('visibility', 'visible'); | ||
+ | $(this).parent().closest(".hp-tab-wrapper").children(".hp-arrow-left").css('visibility', 'hidden'); | ||
+ | } else { | ||
+ | $(this).addClass("hp-arrow-both-mask"); | ||
+ | $(this).parent().closest(".hp-tab-wrapper").children(".hp-arrow-right").css('visibility', 'visible'); | ||
+ | $(this).parent().closest(".hp-tab-wrapper").children(".hp-arrow-left").css('visibility', 'visible'); | ||
+ | } | ||
+ | }); | ||
+ | |||
+ | var onLoadURLCheck = ""; | ||
+ | if ($(location).attr('hash').length > 0) { | ||
+ | onLoadURLCheck = "#" + replaceExpr($(location).attr('hash').substring(1)); | ||
+ | } | ||
+ | var doesExist; | ||
+ | |||
+ | if ($(".hp-tabber").length && $(onLoadURLCheck).length > 0 && $(onLoadURLCheck).parents('.hp-tabber').length === 1) { | ||
+ | doesExist = true; | ||
+ | } else { | ||
+ | doesExist = false; | ||
+ | } | ||
+ | if (doesExist) { | ||
+ | var selectedTabber = $(onLoadURLCheck).parent('.hp-tabber'); | ||
+ | var selectedTab = $(onLoadURLCheck).parent('.hp-tabber').children('.hp-tab-wrapper').children('.hp-tab'); | ||
+ | selectedTabber.children(".hp-active-tab").removeClass("hp-active-tab"); | ||
+ | selectedTab.children(".hp-active-tab").removeClass("hp-active-tab"); | ||
+ | selectedTabber.children(onLoadURLCheck).addClass('hp-active-tab'); | ||
+ | selectedTab.children('.hp-tablinks').each(function(index) { | ||
+ | if (replaceExpr($(this).text()) + "_" === onLoadURLCheck.substring(1)) { | ||
+ | $(this).addClass('hp-active-tab'); | ||
+ | |||
+ | var allMaxScrollLeft = $(this).parent().get(0).scrollWidth - $(this).parent().get(0).clientWidth; | ||
+ | if (allMaxScrollLeft > 0) { | ||
+ | var tableftoffset = $(this).offset().left - $(this).parent().offset().left + $(this).parent().scrollLeft(); | ||
+ | $(this).parent().scrollLeft(tableftoffset); | ||
+ | } | ||
+ | } | ||
+ | }); | ||
+ | // $("html").animate({ scrollTop: $(onLoadURLCheck).offset().top - 140 }, 400 ); | ||
+ | } | ||
+ | |||
+ | function replaceExpr(myid) { | ||
+ | return myid.replace(/([;&,\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g, '\\$1'); | ||
+ | } | ||
+ | |||
+ | $(".hp-tablinks").click(function() { | ||
+ | $(this).parent().closest('.hp-tabber').children(".hp-active-tab").removeClass("hp-active-tab"); | ||
+ | $(this).parent().closest('.hp-tab').children(".hp-active-tab").removeClass("hp-active-tab"); | ||
+ | //$('#' + replaceExpr($(this).text()) + "_").addClass('hp-active-tab'); | ||
+ | $(this).parent().closest('.hp-tabber').children('.hp-tabcontent').eq($(this).index()).addClass('hp-active-tab'); | ||
+ | $(this).addClass('hp-active-tab'); | ||
+ | history.pushState('', '', '#' + $(this).text() + "_"); | ||
+ | }); | ||
+ | |||
+ | $(".hp-arrow-left").click(function() { | ||
+ | var parentTab1 = $(this).parent().closest(".hp-tab-wrapper").children(".hp-tab"); | ||
+ | var maxScrollLeft = parentTab1.get(0).scrollWidth - parentTab1.get(0).clientWidth; | ||
+ | var leftPos = parentTab1.scrollLeft(); | ||
+ | |||
+ | parentTab1.animate({ | ||
+ | scrollLeft: leftPos - 150 | ||
+ | }, 200, function() {}); | ||
+ | }); | ||
+ | |||
+ | $(".hp-arrow-right").click(function() { | ||
+ | var parentTab2 = $(this).parent().closest(".hp-tab-wrapper").children(".hp-tab"); | ||
+ | var maxScrollLeft = parentTab2.get(0).scrollWidth - parentTab2.get(0).clientWidth; | ||
+ | var leftPos = parentTab2.scrollLeft(); | ||
+ | |||
+ | parentTab2.animate({ | ||
+ | scrollLeft: leftPos + 150 | ||
+ | }, 200, function() {}); | ||
+ | }); |
Version vom 20. Januar 2023, 22:27 Uhr
/** Test if an element has a certain class **************************************
*
* Description: Uses regular expressions and caching for better performance.
* Maintainers: [[User:Mike Dillon]], [[User:R. Koot]], [[User:SG]]
*/
var hasClass = ( function() {
var reCache = {};
return function( element, className ) {
return ( reCache[className] ? reCache[className] : ( reCache[className] = new RegExp( "(?:\\s|^)" + className + "(?:\\s|$)" ) ) ).test( element.className );
};
})();
(function () {
var req = new XMLHttpRequest();
req.addEventListener('load', function (ev) {
if (this.status >= 200 && this.status < 300) {
var data = JSON.parse(this.responseText);
if (data.hasOwnProperty('version')) {
var gdpr = document.createElement("script");
gdpr.src = "https://s3-static.geo.gfsrv.net/cookiebanner/" + data.version + "/cookie.min.js";
document.head.appendChild(gdpr);
}
}
});
req.open('GET', "https://s3-static.geo.gfsrv.net/cookiebanner/version.json");
req.send();
})();
/** TEST **/
$(".hp-tab").scroll(function() {
var maxScrollLeft = $(this).get(0).scrollWidth - $(this).get(0).clientWidth;
var leftPos = $(this).scrollLeft();
if (leftPos > (maxScrollLeft - ((maxScrollLeft / 100) * 10))) {
$(this).removeClass("hp-arrow-both-mask");
$(this).removeClass("hp-arrow-next-mask");
$(this).addClass("hp-arrow-prev-mask");
$(this).parent().closest(".hp-tab-wrapper").children(".hp-arrow-right").css('visibility', 'hidden');
$(this).parent().closest(".hp-tab-wrapper").children(".hp-arrow-left").css('visibility', 'visible');
} else if (leftPos < ((maxScrollLeft / 100) * 10)) {
$(this).removeClass("hp-arrow-both-mask");
$(this).removeClass("hp-arrow-prev-mask");
$(this).addClass("hp-arrow-next-mask");
$(this).parent().closest(".hp-tab-wrapper").children(".hp-arrow-right").css('visibility', 'visible');
$(this).parent().closest(".hp-tab-wrapper").children(".hp-arrow-left").css('visibility', 'hidden');
} else {
$(this).addClass("hp-arrow-both-mask");
$(this).parent().closest(".hp-tab-wrapper").children(".hp-arrow-right").css('visibility', 'visible');
$(this).parent().closest(".hp-tab-wrapper").children(".hp-arrow-left").css('visibility', 'visible');
}
});
var onLoadURLCheck = "";
if ($(location).attr('hash').length > 0) {
onLoadURLCheck = "#" + replaceExpr($(location).attr('hash').substring(1));
}
var doesExist;
if ($(".hp-tabber").length && $(onLoadURLCheck).length > 0 && $(onLoadURLCheck).parents('.hp-tabber').length === 1) {
doesExist = true;
} else {
doesExist = false;
}
if (doesExist) {
var selectedTabber = $(onLoadURLCheck).parent('.hp-tabber');
var selectedTab = $(onLoadURLCheck).parent('.hp-tabber').children('.hp-tab-wrapper').children('.hp-tab');
selectedTabber.children(".hp-active-tab").removeClass("hp-active-tab");
selectedTab.children(".hp-active-tab").removeClass("hp-active-tab");
selectedTabber.children(onLoadURLCheck).addClass('hp-active-tab');
selectedTab.children('.hp-tablinks').each(function(index) {
if (replaceExpr($(this).text()) + "_" === onLoadURLCheck.substring(1)) {
$(this).addClass('hp-active-tab');
var allMaxScrollLeft = $(this).parent().get(0).scrollWidth - $(this).parent().get(0).clientWidth;
if (allMaxScrollLeft > 0) {
var tableftoffset = $(this).offset().left - $(this).parent().offset().left + $(this).parent().scrollLeft();
$(this).parent().scrollLeft(tableftoffset);
}
}
});
// $("html").animate({ scrollTop: $(onLoadURLCheck).offset().top - 140 }, 400 );
}
function replaceExpr(myid) {
return myid.replace(/([;&,\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g, '\\$1');
}
$(".hp-tablinks").click(function() {
$(this).parent().closest('.hp-tabber').children(".hp-active-tab").removeClass("hp-active-tab");
$(this).parent().closest('.hp-tab').children(".hp-active-tab").removeClass("hp-active-tab");
//$('#' + replaceExpr($(this).text()) + "_").addClass('hp-active-tab');
$(this).parent().closest('.hp-tabber').children('.hp-tabcontent').eq($(this).index()).addClass('hp-active-tab');
$(this).addClass('hp-active-tab');
history.pushState('', '', '#' + $(this).text() + "_");
});
$(".hp-arrow-left").click(function() {
var parentTab1 = $(this).parent().closest(".hp-tab-wrapper").children(".hp-tab");
var maxScrollLeft = parentTab1.get(0).scrollWidth - parentTab1.get(0).clientWidth;
var leftPos = parentTab1.scrollLeft();
parentTab1.animate({
scrollLeft: leftPos - 150
}, 200, function() {});
});
$(".hp-arrow-right").click(function() {
var parentTab2 = $(this).parent().closest(".hp-tab-wrapper").children(".hp-tab");
var maxScrollLeft = parentTab2.get(0).scrollWidth - parentTab2.get(0).clientWidth;
var leftPos = parentTab2.scrollLeft();
parentTab2.animate({
scrollLeft: leftPos + 150
}, 200, function() {});
});