Difference between revisions of "MediaWiki:Common.js"
From OHO - search engine for sustainable open hardware projects
| (9 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 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, $) { | ||
| Line 6: | Line 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); | |||
}); | |||
}); | }); | ||
} | } | ||
| Line 67: | Line 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(){ | ||
| Line 85: | Line 89: | ||
if (txt=='Show All Comments') { | if (txt=='Show All Comments') { | ||
$(".project_material_table .materialCommandsBox").addClass("openComments"); | $(".project_material_table .materialCommandsBox").addClass("openComments"); | ||
$(".project_material_table .commentRow").not(".notFoundComment"). | $(".project_material_table .commentRow").not(".notFoundComment").addClass("openCommentsRow"); | ||
$(this).html('Hide All Comments'); | $(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"). | $(".project_material_table .commentRow").not(".notFoundComment").removeClass("openCommentsRow"); | ||
$(this).html('Show All Comments'); | $(this).html('Show All Comments'); | ||
} | } | ||
| Line 134: | Line 138: | ||
$(".home_resume_text.home_hidden_text .home_more_results_link a").click(function(e){ | $(".home_resume_text.home_hidden_text .home_more_results_link a").click(function(e){ | ||
e.preventDefault(); | e.preventDefault(); | ||
$(this).parent().removeClass('home_hidden_text'); | $(this).parent().parent().removeClass('home_hidden_text'); | ||
$(this).parent().hide(); | |||
}); | }); | ||
Latest revision as of 05:35, 31 March 2022
/* 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").addClass("openCommentsRow");
$(this).html('Hide All Comments');
}else{
$(".project_material_table .materialCommandsBox").removeClass("openComments");
$(".project_material_table .commentRow").not(".notFoundComment").removeClass("openCommentsRow");
$(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();
});
