MediaWiki: Common.js
Aus Semantic CorA
Version vom 31. Januar 2018, 09:46 Uhr von Lia Veja (Diskussion | Beiträge)
Hinweis: Leere nach dem Speichern den Browser-Cache, um die Änderungen sehen zu können.
- Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
- Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
- Internet Explorer: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
- Opera: Gehe zu Menü → Einstellungen (Opera → Einstellungen auf dem Mac) und dann auf Datenschutz & Sicherheit → Browserdaten löschen → Gespeicherte Bilder und Dateien.
/* Das folgende JavaScript wird für alle Benutzer geladen. */
/* Any JavaScript here will be loaded for all users on every page load. */
// <source lang="javascript">
// This JavaScript will be loaded for all users on every page load.
// Except for additions at the end, imported from en.wikipedia.org and modified (parts removed).
// for authors see http://en.wikipedia.org/w/index.php?title=MediaWiki:Common.js&action=history
/* Scripts specific to Internet Explorer */
if (navigator.appName == "Microsoft Internet Explorer") {
/** Internet Explorer bug fix **************************************************
* Description: Fixes IE horizontal scrollbar bug
* Maintainers: [[User:Tom-]]?
*/
var oldWidth;
var docEl = document.documentElement;
function fixIEScroll() {
if (!oldWidth || docEl.clientWidth > oldWidth)
doFixIEScroll();
else
setTimeout(doFixIEScroll, 1);
oldWidth = docEl.clientWidth;
}
function doFixIEScroll() {
docEl.style.overflowX = (docEl.scrollWidth - docEl.clientWidth < 4) ? "hidden" : "";
}
document.attachEvent("onreadystatechange", fixIEScroll);
document.attachEvent("onresize", fixIEScroll);
// In print IE (7?) does not like line-height
appendCSS( '@media print { sup, sub, p, .documentDescription { line-height: normal; }}');
//Import scripts specific to Internet Explorer 6
// THIS IS A PNG transparency FIX, here commented out:
// if (navigator.appVersion.substr(22, 1) == "6") {
// importScript("MediaWiki:Common.js/IE60Fixes.js");
// }
} // END "Microsoft Internet Explorer"
/**
* ImageAnnotator
* Globally enabled per
* http://commons.wikimedia.org/?title=Commons:Village_pump&oldid=26818359#New_interface_feature
* Maintainer: [[User:Lupo]]
*/
// Not on Special pages, and only if viewing the page
//if (wgNamespaceNumber != -1 && jQuery.inArray(mw.config.get('wgAction'), ['view', 'purge']) != -1 ) {
// if (typeof ImageAnnotator_disable == 'undefined' || !ImageAnnotator_disable) {
// Don't even import it if it's disabled.
// importScript('MediaWiki:Gadget-ImageAnnotator.js');
// }
//}
if (wgNamespaceNumber != -1) importScript ('MediaWiki:Gadget-ImageAnnotator.js');
/** Table sorting fixes
* Description: Disables code in table sorting routine to set classes on even/odd rows
*/
ts_alternate_row_colors = false;
/**
* sort event-tables according to column 3.
*/
function presort() {
var table = document.getElementById("event-table");
if (table != null && table != 'undefined') {
var sortLink = table.rows[0].cells[2].lastChild;
ts_resortTable(sortLink);
}
}
/*
* Description: Get resource string (text, image URLs) for a given language, based on a string-key
* If no resource is defined in a given language for a resource key, the resource for "en" will be returned, if this is missing as well an error message.
* resourceKey: key for the resource (string)
*/
$j.resource = function (resourceKey) {
var lang = wgContentLanguage.split("-")[0]; // language: "pt-BR", "de-formal", etc.
return ($j.jI18n[lang] && $j.jI18n[lang][resourceKey] ?
$j.jI18n[lang][resourceKey] :
($j.jI18n.en[resourceKey]) ? $j.jI18n.en[resourceKey] : "MISSING RESOURCE");
};
/**
* Semantic Forms quit formtable class on edit
*/
function initHideFirstTemplate(){
var jTrHiddenFormTexts = $j(
// select only input type text from formtable
".lemmata-body"
);
jTrHiddenFormTexts
.parents('table:eq(0)')
.css({'display': 'none'});
}
//moveable TOCs
//importScript('MediaWiki:MoveTOC.js');
// collapsible parts: div and tr → Template:Hidden
// may be fused later with toggleCollapse
// main difference: initCollapsebox() uses a switcher defined by the Wikitemplate
// and is not using a javascript resource title
function initCollapsebox() {
/* is nested in: div.collapsebox
└ div.switcher
└ div.collapsecontent */
jQuery("div.collapsebox div.switcher").live('click',
function() {
jQuery(this).nextAll("div.collapsecontent:first").slideToggle(250);
/* $(this).toggle() does not work in live as toggle is a bind()
therefore toggle must be bound to a different DOM element */
jQuery(this).find(".show, .hide").toggle();
});
/* is in a table: tr.collapsebox
└ div.switcher
tr.collapsecontent */
jQuery("tr.collapsebox div.switcher").live('click',
function() {
jQuery(this).closest("tr.collapsebox").nextAll("tr.collapsecontent:first").toggle();
jQuery(this).find(".show, .hide").toggle();
});
}// END initCollapsebox()
///////////////////////////////////
// confirm deletion using SMW forms
// does not work in IE 6
//////////////////////////////////
function initConfirmDeleteSubform() {
$j.extend(true, $j.jI18n, {
en: {
message : "'Delete this sub form irreversibly?'"
},
de: {
message : "'Dieses Teilformular unwiderruflich löschen?'"
}
});
// default buttons: <input type="button" ... class="remove"/>
$j("input.remove").attr("onClick", function() {// case sensitive not: onclick
//typeof this.onclick → function
var currentClickHandlerString = this.getAttributeNode('onclick').value;
// add a confirm
return "var removethis = confirm("+$j.resource('message')+"); if(removethis) {return " + currentClickHandlerString + "};";
});
/* added delete buttons by the SMW-form: <input type="button" />
add onclick handling */
$j("input.addAnother").click(function () {
// just new generated div#div_gen_1
$j("div")
.filter(function() { return this.id.match(/div_gen_\d+/); })
.find(":button")
.attr("onClick",function() {// case sensitive not: onclick
// add a confirm
return "var removethis = confirm("+$j.resource('message')+"); if(removethis) {$j('#' + String($j(this).parent().attr('id'))).remove();} else {return false;};";
});
});
}// end initConfirmDeleteSubform()
/*
///////////////////////////////////
// indicate hidden inputs created
// from template:Hidden
//////////////////////////////////
structure of template:Hidden:
div.collapsebox
├ div.switcher (float)
├ div.collapsetitle
└ div.collapsecontent
tr.collapsebox
└ th/td
├ div.switcher (float)
└ div.collapsetitle
tr.collapsecontent
*/
function initMarkHiddenInputs(){
var jDivHiddenFormTexts = $j(
// select only input type text + textarea with values
"div.collapsecontent.indicateHiddenInputs * :text[value!=]"
+", div.collapsecontent.indicateHiddenInputs * textarea[value!=]"
);
var jTrHiddenFormTexts = $j(
// select only input type text + textarea with values
"tr.collapsecontent.indicateHiddenInputs *:not(.collapsecontent) :text[value!=]"
+", tr.collapsecontent.indicateHiddenInputs *:not(.collapsecontent) textarea[value!=]"
);
// <div>
jDivHiddenFormTexts
.parents(".collapsebox")
.css({'border-left':'2px solid #ce5c00'});
//indicate the fields itself
jDivHiddenFormTexts
.css({'background-color':'#fcdeb1'}); //pale orange
// <tr>
//indicate the fields itself
jTrHiddenFormTexts
.css({'background-color':'#fcdeb1'}); //pale orange
//indicate current level
jTrHiddenFormTexts
.closest(".collapsebox")
.css({'border-left':'2px solid #ce5c00'});
// to ?upermost level
jTrHiddenFormTexts
.parents(".collapsecontent")
.prev(".collapsebox")
.css({'border-left':'2px solid #ce5c00'});
}// END initMarkHiddenInputs()
//$(window).bind('load', function()
$(window).load(function() {
// I changed rearranger image(by Adrian)
jQuery('img.rearrangerImage').attr('src','http://smw-cora.org/upload/Rearranger.png');
// I changed dull-blue-circle.png (from blue to orange) (by Adrian)
jQuery('img.timeline-copyright').attr('src','http://smw-cora.org/upload/Copyright-vertical.png');
jQuery('div.timeline-band-layer-inner > div > img').attr('src','http://smw-cora.org/upload/Dull-blue-circle.png');
//I changed the slim bottom lines (in fact it is border color left) from blue to orange (by Adrian)
jQuery('div.timeline-band-layer-inner > div').each(function(){
if(jQuery(this).css('border-left-color') == 'rgb(88, 160, 220)') {
jQuery(this).css('border-left-color','rgb(247,102,0)');
}
});
// I changed icon for resize image (by Adrian)
// jQuery('#buttondecreaseimagesize').attr('src','http://smw-cora.org/upload/Minus_size.png');
// jQuery('#buttonincreaseimagesize').attr('src','http://smw-cora.org/upload/Plus_size.png');
// Eliminated <---Resize---> (by Adrian)
// $("#SIAresizeDiv").contents().filter(function(){
// return (this.nodeType == 3);
// }).remove();
});
addOnloadHook(presort);
jQuery(document).ready(function() {
var $j = jQuery.noConflict;
// try to add the toolbar on uploading
var aa= jQuery('<a/>')
.attr("href", "http://smw-cora.org/index.php/Main_Page").attr("id","poweredbyCora");
jQuery("#footer-poweredbyico").append(aa);
var img = jQuery('<img />').attr({ 'id': 'poc', 'src': 'http://smw-cora.org/upload/SC_Credit.png', 'alt':'Powered by CorA Project' }).appendTo(jQuery('#poweredbyCora'));
/*jQuery('.smwtimeline').find('img').each(function () {
var curSrc = jQuery(this).attr('src');
var class = jQuery(this).attr('class');
alert("yes");
if ( class === '' ) {
jQuery(this).attr('src', 'http://smw-cora.org/upload/dull-blue-circle.png');
}
if ( class === 'timeline-copyright' ) {
jQuery(this).attr('src', 'http://example.com/brown.gif');
}
});
jQuery('.smwtimeline').on('DOMNodeInserted ', 'img', function(){
alert("insert");
jQuery(this).html('<b>yaay!</b>');
});*/
//Adrian - BEGIN - setting min-height of div.content - for push down #footer
jQuery('#content').css('min-height', Math.max(jQuery('#content').height(), jQuery('#mw-panel').height()));
//Adrian - END - setting height of div.content
// edit tools update
// upload new icons for tools
if(wgAction == "edit"){
jQuery('#mw-editbutton-bold').attr('src','http://smw-cora.org/upload/Button_bold.png');
jQuery('#mw-editbutton-italic').attr('src','http://smw-cora.org/upload/Button_italic.png');
jQuery('#mw-editbutton-link').attr('src','http://smw-cora.org/upload/Button_link.png');
jQuery('#mw-editbutton-extlink').attr('src','http://smw-cora.org/upload/Button_extlink.png');
jQuery('#mw-editbutton-headline').attr('src','http://smw-cora.org/upload/Button_headline.png');
jQuery('#mw-editbutton-image').attr('src','http://smw-cora.org/upload/Button_image.png');
jQuery('#mw-editbutton-media').attr('src','http://smw-cora.org/upload/Button_media.png');
jQuery('#mw-editbutton-nowiki').attr('src','http://smw-cora.org/upload/Button_nowiki.png');
jQuery('#mw-editbutton-signature').attr('src','http://smw-cora.org/upload/Button_sig.png');
jQuery('#mw-editbutton-hr').attr('src','http://smw-cora.org/upload/Button_hr.png');
}
if(wgPageName == "Special:Upload" && wgUserName){
$j("textarea#wpUploadDescription").before('<div id="toolbar"></div>');
}
// initmovingTOC(); // TOC CSS position fixed or static → MediaWiki:Gadget-moveTOC.js
initCollapsebox();//collapsable parts
// page specific
if(wgAction == "formedit" || wgPageName == "Special:FormEdit"){
initConfirmDeleteSubform();
initMarkHiddenInputs();
initHideFirstTemplate();
}
if(wgCanonicalSpecialPageName === "Browse"){
// alert("browse");
jQuery(".smwb-propvalue td").each(function(){
var data = [];
var kids = jQuery(this).children(".smwb-value");
if(kids.length>1){
for(var i=0; i<kids.length; i++){
data.push(kids[i].outerHTML);
}
// alert('xx '+data);
var stories = jQuery('.story-body');
kids.detach();
jQuery(this).empty();
var x=data.join("<br/>");
jQuery(x).appendTo(this);
}
});
}
/* if(wgPageName == "Special:OfflineImportLexicon"){
importScript('MediaWiki:OIL_Constants.js');
importScript('MediaWiki:jquery.ezpz_tooltip.min.js');
importScript('MediaWiki:OfflineImportLexicon.js');
importScript('MediaWiki:OfflineImportLexiconSecond.js');
}*/
if (wgNamespaceNumber != -1 && jQuery.inArray(mw.config.get('wgAction'), ['view']) != -1 ){
// importScript('MediaWiki:AQE-Constants.js');
// importScript('MediaWiki:Jquery.tools.min.js');
// importScript('MediaWiki:AnalysisQueryEditor.js');
// importScript('MediaWiki:AnalysisQueryEditorSecond.js');
}
});
//importScript('MediaWiki:Multilingual description.js');
// </source>