MediaWiki:Common.js: Unterschied zwischen den Versionen
Aus OHO - search engine for sustainable open hardware projects
(4 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
/* Das folgende JavaScript wird für alle Benutzer geladen. */ | /* Das folgende JavaScript wird für alle Benutzer geladen. */ | ||
jQuery(document).ready(function($) { | jQuery(document).ready(function($) { | ||
document.getElementsByClassName("wait_screen_box")[0].style.display = 'none'; | |||
mw.loader.using('jquery.ui.autocomplete', function() { | mw.loader.using('jquery.ui.autocomplete', function() { | ||
(function (mw, $) { | (function (mw, $) { | ||
Zeile 6: | Zeile 8: | ||
$('.searchInputProjectKWAC').autocomplete( { | $('.searchInputProjectKWAC').autocomplete( { | ||
source: function(request, response) { | source: function(request, response) { | ||
var api = new mw.Api(); | mw.loader.using('mw.Api').then(function () { | ||
var api = new mw.Api(); | |||
api.get({action:'pfautocomplete', limit:10, substr:request.term, property:'Keywords'}).done( | |||
function (data) { | |||
var dataf = []; | |||
dataf = processListAC(request.term, data, dataf); | |||
dataf = dataf.sort().slice(0, 10); | |||
response(dataf); | |||
}); | |||
}); | }); | ||
} | } | ||
Zeile 31: | Zeile 35: | ||
$(".project_gallery_scroll_box .button_left").click(function(){ | $(".project_gallery_scroll_box .button_left").click(function(){ | ||
var binn = $(this).parent().find(".gallery_inner"); | var binn = $(this).parent().find(".gallery_inner"); | ||
if (binn. | if (binn.position().left < 0) { | ||
var imgW = binn.find(".imgbox").first().outerWidth(); | var imgW = binn.find(".imgbox").first().outerWidth(); | ||
binn.animate({left:"+="+imgW}); | binn.animate({left:"+="+imgW}); | ||
Zeile 38: | Zeile 42: | ||
$(".project_gallery_scroll_box .button_right").click(function(){ | $(".project_gallery_scroll_box .button_right").click(function(){ | ||
var binn = $(this).parent().find(".gallery_inner"); | var binn = $(this).parent().find(".gallery_inner"); | ||
if (binn. | if (binn.position().left + binn.width() > binn.parent().width()) { | ||
var imgW = binn.find(".imgbox").first().outerWidth(); | var imgW = binn.find(".imgbox").first().outerWidth(); | ||
binn.animate({left:"-="+imgW}); | binn.animate({left:"-="+imgW}); | ||
Zeile 67: | Zeile 71: | ||
$(".materialRow .showComment").click(function(){ | $(".materialRow .showComment").click(function(){ | ||
$(this).parent().toggleClass("openComments"); | $(this).parent().toggleClass("openComments"); | ||
$(this).parent().parent().next(). | $(this).parent().parent().next().toggleClass("openCommentsRow"); | ||
}); | }); | ||
$(".showGralComment").click(function(){ | $(".showGralComment").click(function(){ | ||
Zeile 86: | Zeile 90: | ||
$(".project_material_table .materialCommandsBox").addClass("openComments"); | $(".project_material_table .materialCommandsBox").addClass("openComments"); | ||
$(".project_material_table .commentRow").not(".notFoundComment").show(500); | $(".project_material_table .commentRow").not(".notFoundComment").show(500); | ||
$(this).html(' | $(this).html('Hide All Comments'); | ||
}else{ | }else{ | ||
$(".project_material_table .materialCommandsBox").removeClass("openComments"); | $(".project_material_table .materialCommandsBox").removeClass("openComments"); | ||
$(".project_material_table .commentRow").not(".notFoundComment").hide(500); | $(".project_material_table .commentRow").not(".notFoundComment").hide(500); | ||
$(this).html(' | $(this).html('Show All Comments'); | ||
} | } | ||
}); | }); | ||
Zeile 116: | Zeile 120: | ||
$(".newtablinks a, .newtablink").attr("target", "_blank"); | $(".newtablinks a, .newtablink").attr("target", "_blank"); | ||
window.isfirst = true; window.prevc = false; | |||
$('ul.dropdown-menu li a').each(function(){ | |||
if($(this).text().substr(0,1) == '_'){ | |||
if (window.isfirst!==false) {$(this).parent().addClass('firstchild')} | |||
$(this).text($(this).text().substr(1)).parent().addClass('menuchild lastchild'); | |||
if (window.prevc!==false) {window.prevc.parent().removeClass('lastchild');} | |||
window.isfirst = false; | |||
window.prevc = $(this); | |||
}else{ | |||
window.isfirst = true; | |||
window.prevc = false; | |||
} | |||
}) | |||
$(".home_resume_text.home_hidden_text .home_more_results_link a").click(function(e){ | |||
e.preventDefault(); | |||
$(this).parent().parent().removeClass('home_hidden_text'); | |||
$(this).parent().hide(); | |||
}); |
Aktuelle Version vom 22. Februar 2022, 02:34 Uhr
/* Das folgende JavaScript wird für alle Benutzer geladen. */ jQuery(document).ready(function($) { document.getElementsByClassName("wait_screen_box")[0].style.display = 'none'; mw.loader.using('jquery.ui.autocomplete', function() { (function (mw, $) { $(function () { $('.searchInputProjectKWAC').autocomplete( { source: function(request, response) { mw.loader.using('mw.Api').then(function () { var api = new mw.Api(); api.get({action:'pfautocomplete', limit:10, substr:request.term, property:'Keywords'}).done( function (data) { var dataf = []; dataf = processListAC(request.term, data, dataf); dataf = dataf.sort().slice(0, 10); response(dataf); }); }); } }); }); }(mediaWiki, jQuery)); }); $(".project_gallery_scroll_box").append('<div class="button_left"></div>'); $(".project_gallery_scroll_box").append('<div class="button_right"></div>'); $(".project_gallery_scroll_box a.image, .project_gallery_scroll_box img").unwrap('pre'); $(".project_gallery_scroll_box > a.image, .project_gallery_scroll_box > img").wrap('<div class="imgbox"></div>'); $(".project_gallery_scroll_box .imgbox").wrapAll('<div class="gallery_inner"></div>'); $('.project_gallery_scroll_box img').each(function(){ var imgClass = (this.width >= this.height) ? 'imgwfill' : 'imghfill'; $(this).addClass(imgClass); }); $(".project_gallery_scroll_box .button_left").click(function(){ var binn = $(this).parent().find(".gallery_inner"); if (binn.position().left < 0) { var imgW = binn.find(".imgbox").first().outerWidth(); binn.animate({left:"+="+imgW}); } }); $(".project_gallery_scroll_box .button_right").click(function(){ var binn = $(this).parent().find(".gallery_inner"); if (binn.position().left + binn.width() > binn.parent().width()) { var imgW = binn.find(".imgbox").first().outerWidth(); binn.animate({left:"-="+imgW}); } }); $(".project_gallery_scroll_box").removeClass('waitbox'); }); function processListAC(search, data, dataf) { for(var dlist in data) { for(var drow in data[dlist]) { var listW = data[dlist][drow].title.split(","); for(var w in listW) { wt = listW[w].trim(); if (wt.length>0) { wt = wt.charAt(0).toUpperCase() + wt.substr(1).toLowerCase(); if (wt.toLowerCase().indexOf(search.toLowerCase())===0 && $.inArray(wt, dataf)===-1) { dataf[dataf.length] = wt; } } } } } return dataf; } /* Das folgende JavaScript wird für alle Benutzer geladen. */ $(".materialRow .showComment").click(function(){ $(this).parent().toggleClass("openComments"); $(this).parent().parent().next().toggleClass("openCommentsRow"); }); $(".showGralComment").click(function(){ $(".generalCommentsBox").toggle(500); var grhtml = $(".showGralComment").html(); if (grhtml.indexOf('+') > -1) { grhtml = grhtml.replace('+', '-'); }else{ grhtml = grhtml.replace('-', '+'); } $(".showGralComment").html(grhtml); }); $(".project_material_table .showAllComments").click(function(e){ e.preventDefault(); var txt = $(this).html(); if (txt=='Show All Comments') { $(".project_material_table .materialCommandsBox").addClass("openComments"); $(".project_material_table .commentRow").not(".notFoundComment").show(500); $(this).html('Hide All Comments'); }else{ $(".project_material_table .materialCommandsBox").removeClass("openComments"); $(".project_material_table .commentRow").not(".notFoundComment").hide(500); $(this).html('Show All Comments'); } }); $(".searchMatCol").keyup(function(e){ findRowsByCol($(".searchMatCol")); }); if (window.initJSFuncts!==undefined) { for(ijsf=0; ijsf<window.initJSFuncts.length; ijsf++) { try {window.initJSFuncts[ijsf]();}catch(e){console.log(e);} } } function getUrlParameter(sParam) { var sPageURL = window.location.search.substring(1); var sURLVariables = sPageURL.split('&'); for (i = 0; i < sURLVariables.length; i++) { sParameterName = sURLVariables[i].split('='); if (sParameterName[0] === sParam) { return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]); } } } $(".newtablinks a, .newtablink").attr("target", "_blank"); window.isfirst = true; window.prevc = false; $('ul.dropdown-menu li a').each(function(){ if($(this).text().substr(0,1) == '_'){ if (window.isfirst!==false) {$(this).parent().addClass('firstchild')} $(this).text($(this).text().substr(1)).parent().addClass('menuchild lastchild'); if (window.prevc!==false) {window.prevc.parent().removeClass('lastchild');} window.isfirst = false; window.prevc = $(this); }else{ window.isfirst = true; window.prevc = false; } }) $(".home_resume_text.home_hidden_text .home_more_results_link a").click(function(e){ e.preventDefault(); $(this).parent().parent().removeClass('home_hidden_text'); $(this).parent().hide(); });