Ouvrir le menu principal

Modifications

MediaWiki:Common.js

6 244 octets supprimés, 28 mars 2015 à 22:05
aucun résumé de modification
jQuery(document).ready(function($)
{
mw.loader.load('//ffxiv.wiki.jeuxonline.info/w/index.php?title=Mediawiki:CompositeListField.js&action=raw'); mw.loader.load('//ffxiv.wiki.jeuxonline.info/w/index.php?title=Mediawiki:EorzeaClock.js&action=raw'); // twitter $("#ca-form_edit span atweets").texthtml($('<a>', {class:"twitter-timeline", href:"Modifierhttps://twitter.com/JOL_FFXIV"}).attr('data-widget-id', '358938402130890752')); mw.loader.load('//platform.twitter.com/widgets.js');
// modifie le texte de l'onglet "Modifier avec formulaire" $("#tweetsca-form_edit span a").htmltext($('<a>', {class:"twitter-timelineModifier", href:"https:); //twittercréé des liens qui ouvre un nouvel onglet $(".com/JOL_FFXIVnewTabLink a"}).attr('data-widget-idtarget', '358938402130890752')); mw.loader.load('//platform.twitter.com/widgets.js_blank');
// créé un lien vers une catégorie d'images $("a.newTabLink sfUploadable").attr('href', $("a.sfUploadable").attr('targethref') + '&wpUploadDescription=[[Catégorie:', +$("#imageCat").text()+'_blank]]');
/*---------------*/ /* Vertical Tabs */ /*---------------*/ mw.loader.using( ['jquery.ui.tabs'], function () { $("a.sfUploadable#tabs, #tabs1, #tabs2, #tabs3, #tabs4, #tabs5, #tabs6, #tabs7, #tabs8, #tabs9").attrtabs('href', ); $("a#vtabs" ).sfUploadable"tabs().attraddClass('href'"ui-tabs-vertical ui-helper-clearfix" ) + '&wpUploadDescription=[[Catégorie:'+; $("#imageCatvtabs li").textremoveClass("ui-corner-top" )+']]'.addClass( "ui-corner-left" ); });
mw.loader.load(' /*--------------------*/ /* Boîtes déroulantes */ffxiv.wiki.jeuxonline.info /w*--------------------*/index $( ".php?title=Mediawiki:CompositeListFieldtoggle-content" ).js&action=raw'hide(); mw $( ".loadertoggle" ).click( function(e) { if( $(this).hasClass("active") ) { $(this).loadremoveClass("active"); } else { $('//ffxivthis).wikiaddClass("active"); } $(this).jeuxonlinenext(".info/w/indextoggle-content").php?title=Mediawiki:EorzeaClockslideToggle(); e.js&action=raw'preventDefault(); });
/*-----------------------------*/ /* Vertical Tabs Switch HQ-NQ sur les objets */ /*-----------------------------*/ mw.loader.using var $swap = $( ['jquery.ui.tabs<div>']), function $save = $('<div>') { , $infobox = $( "#tabs, #tabs1, #tabs2, #tabs3, #tabs4, #tabs5, #tabs6, #tabs7, #tabs8, #tabs9div.infobox" ).tabs(); var $switchlink = $( "#vtabsbodyContent div.hqswitch a" ); $switchlink.tabsremoveAttr('title'); var url = $switchlink.addClassattr( "ui-tabs-vertical ui-helper-clearfix" 'href'); $swap.load( "#vtabs li" url+' .objet'); $save.removeClasshtml( "ui-corner-top" )$infobox.addClassclone( "ui-corner-left" ); });
/*--------------------*/ function replace(e) /* Boîtes déroulantes */ { /*--------------------*/ $(".infobox:first").replaceWith($swap.find(".objet")); $swap.html($save.find( ".toggle-contentobjet" ).hideclone()); $save.html($( ".toggleinfobox:first" ).clickclone( function(e) {); if( $(this"#bodyContent div.hqswitch").hasClass("activehq") ) { $(this"#bodyContent div.hqswitch").removeClass("activehq"); } else { $(this"#bodyContent div.hqswitch").addClass("activehq"); } $(this).next(".toggle-content").slideToggle(); e.preventDefault(); });
/*-----------------------------*/ /* Switch HQ-NQ sur les objets */ /*-----------------------------*/ var $swap = $('<div>'), $save = $('<div>'), $infobox = $("div.infobox"); var $switchlink = $("#bodyContent div.hqswitch a"); $switchlink.removeAttrtoggle('title'); var url = $switchlink.attr('href'); $swap.load(url+' .objet'); $save.html($infobox.clone()replace, replace);
function replace(e) { /*----------*/ $(".infobox:first").replaceWith($swap.find(".objet")); /* Tooltips */ $swap.html($save.find(".objet").clone()); /*----------*/ $save.html($(".infobox:first").clone()); if ( $("#bodyContent div.hqswitch").hasClassappend("hq") ) { $("#bodyContent <div id='tooltip' style='position:fixed; z-index:150;'></div.hqswitch").removeClass("hq>"); var tooltipCache = {} else {; var $tooltip = $("#bodyContent div.hqswitch").addClass("hqtooltip"); } e.preventDefault(); }
function tooltipPosition(e) { var ttHeight = $tooltip.innerHeight() + 15, ttWidth = $tooltip.innerWidth(), wHeight = $switchlink(window).toggleheight(replace), replacewWidth = $(window).width();
var newTop = e.clientY + ((e.clientY > (wHeight/*2)) ? -ttHeight : 15); newTop = Math.max(0, Math.min(wHeight ---------*/ttHeight, newTop)); var newLeft; /* Tooltips */ if((e.clientX + ttWidth +15) < wWidth) /*----------*/ { $ newLeft = e.clientX + (("#bodyContent")e.appendclientX > ("<div id='tooltip' style='position:fixed; zwWidth/2)) ? -index(ttWidth + 15) :150;'></div>"15); var tooltipCache = } else {}; var $tooltip newLeft = $("#tooltip"wWidth -ttWidth)/2; }
function tooltipPosition(e) { var ttHeight = $tooltip.innerHeightcss() {"top":newTop + 15"px", ttWidth = $tooltip.innerWidth("left":newLeft + "px"}),; wHeight = $(window).height(), wWidth = $(window).width(); }
$('#bodyContent span.tooltip').each( function() { var newTop $link = e.clientY + $((ethis).clientY > children(wHeight/2)) ? -ttHeight : 15'a'); newTop var url = Math.max(0, Math$link.minattr(wHeight - ttHeight, newTop)'href');
if((e.clientX + ttWidth +15) < wWidth) { var newLeft = e.clientX + ((e.clientX > (wWidth/2)) ? -(ttWidth + 15) : 15); } else { var newLeft = (wWidth -ttWidth)/2; } $tooltiplink.cssremoveAttr({"top":newTop + "px", "left":newLeft + "px"}'title'); }
$link.hover(function(e) { if('#bodyContent spantooltipCache[url]) { $tooltip.html(tooltipCache[url]); } else { $tooltip.load(url + ').each( popup', function() { var $link tooltipCache[url] = $tooltip.html(this).children; tooltipPosition('a'e); }); var url = } $linktooltip.attrcss('hrefdisplay','block'); }, function() { $link("#tooltip").removeAttrcss('titledisplay','none').empty(); }).mousemove(tooltipPosition); });
$link.hover(function(e) {
if(tooltipCache[url]) {
$tooltip.html(tooltipCache[url]);
} else {
$tooltip.load(url + ' .popup', function() {
tooltipCache[url] = $tooltip.html();
tooltipPosition(e);
});
}
$tooltip.css('display','block');
}, function() {
$("#tooltip").css('display','none').empty();
}).mousemove(tooltipPosition);
});
 
/*----------------------------------------------------------*/
/* Formulaire objet : remplissage automatique de 2-3 champs */
/*----------------------------------------------------------*/
$("input[name='Objet[niveau]']").on('focusout', function()
{
var itemLvl = $("input[name='Objet[itemLevel]']");
if(!itemLvl.val())
itemLvl.val($(this).val());
});
 
$("form#sfForm").on('focusout', "select[name*='Objet/Recette'][name*='[classe]']:eq(1)", function()
{
var repairArtisan = $("select[name='Objet[artisan]']");
if(!repairArtisan.val())
repairArtisan.val($(this).val());
});
 
/*
Hightlight sur image map (http://he.wikipedia.org/wiki/%D7%9E%D7%93%D7%99%D7%94_%D7%95%D7%99%D7%A7%D7%99:Imagemap-Highlight.js)
*/
 
var myClassName = 'imageMapHighlighterArtefacts',
hilightDivMarker = '.imageMapHighlighter';
function drawMarker(context, areas)
{
function drawPoly(coords)
{
context.moveTo(coords.shift(), coords.shift());
while (coords.length)
context.lineTo(coords.shift(), coords.shift());
}
 
for(var i in areas)
{
var coords = areas[i].coords.split(',');
context.beginPath();
switch (areas[i].shape)
{
case 'rect':
drawPoly([coords[0], coords[1], coords[0], coords[3], coords[2], coords[3], coords[2], coords[1]]);
break;
case 'circle':
context.arc(coords[0],coords[1],coords[2],0,Math.PI*2);
break;
case 'poly':
drawPoly(coords);
break;
}
context.closePath();
context.stroke();
context.fill();
}
}
 
function drawPosition(context, xPos, yPos, rate)
{
var size = 50 * rate;
var x = xPos * size;
var y = yPos * size;
context.beginPath();
context.moveTo(x, y);
context.lineTo(x+size, y);
context.lineTo(x+size, y+size);
context.lineTo(x, y+size);
context.lineTo(x, y);
context.closePath();
context.stroke();
context.fill();
};
function mouseAction(e)
{
var $this = $(this),
context = $this.data('context'),
activate = e.type == 'mouseover';
$this.toggleClass('liHighlighting', activate);
context.clearRect(0, 0, context.canvas.width, context.canvas.height);
if (activate)
drawMarker(context, $this.data('areas'));
}
 
function mouseActionPosition(e)
{
var $this = $(this),
context = $this.data('context'),
activate = e.type == 'mouseover';
context.clearRect(0, 0, context.canvas.width, context.canvas.height);
if (activate)
{
drawPosition(context, $this.data('xPos'), $this.data('yPos'), $this.data('rate'));
}
}
 
function pageOfHref(href, cssClass)
{
var page = href.replace(document.location.protocol + "/wiki/", '').replace(/.*\/\//, '').replace(/_/g, ' ');
page = page.replace(/#(.*)/, function(toReplace){return toReplace.replace(/\.([\dA-F]{2})/g, '%$1');});
page = decodeURIComponent(page);
if (cssClass.indexOf('new') + 1)
page += ' (Page inexistante)';
return page;
}
if($(hilightDivMarker).length && $('<canvas>')[0].getContext)
{
$(hilightDivMarker).each(function(index)
{
var mainDiv = $(this);
if(mainDiv.hasClass('noLink'))
{
$("map area", mainDiv).removeAttr('href');
}
var img = $('img', this), map = img.siblings('map:first');
/* if (!('area', map).length)
return;*/
var w = img.width(), h = img.height();
var dims = {position: 'absolute', width: w + 'px', height: h + 'px', border: 0, top:0, left:0};
var jcanvas = $('<canvas>', {'class': myClassName})
.css(dims)
.attr({width: w, height: h});
var bgimg = $('<img>', {'class': myClassName, src: img.attr('src')})
.css(dims);
var context = $.extend(jcanvas[0].getContext("2d"), {fillStyle: 'rgba(255,255,255,0.5)', strokeStyle: 'rgba(0,0,0,0)', lineJoin: 'round', lineWidth: 0});
 
var div = $('<div>').css({position: 'relative', width: w + 'px', height: h + 'px'});
img.before(div);
div.append(bgimg)
.append(jcanvas)
.append(img);
img.fadeTo(1, 0);
var ol = $('<ul>', {'class': myClassName}).css({clear: 'both', display: 'inline-block', width: w});
div.after(ol);
var lis = {};
$('area', map).each(function()
{
var $this = $(this), text = this.title;
var li = lis[text];
if (!li)
{
li = $('<li>');
if(mainDiv.hasClass('noLink'))
{
li.text(text);
}
else
{
li.addClass(myClassName);
var href = this.href, cssClass = this['class'] || '';
li.append($('<a>', {href: href, title: pageOfHref(href, cssClass), text: text, 'class': cssClass}))
}
li.bind('mouseover mouseout', mouseAction)
.data('areas', [])
.data('context', context);
lis[text] = li;
ol.append(li);
}
li.data('areas').push(this);
$(this).bind('mouseover mouseout', function(e) {li.trigger(e);})
$(".smwtable tr").has("td.Localisation:contains("+text.split(' (')[0]+")").bind('mouseover mouseout', function(e) {li.trigger(e);})
});
 
var mapData = $(".mapData", mainDiv).text().split(":");
if(mapData)
{
mapData[2] = w / mapData[2];
$(".smwtable tr:not(:has(td.Localisation)):has(td.Position)").each(function()
{
var pos = $("td.Position", this).text();
var xPos = (pos.substr(0, pos.indexOf(':')) - mapData[0]);
var yPos = (pos.substring(pos.indexOf(':')+1) - mapData[1]);
if(index == 0)
{
$(this).bind('mouseover mouseout', mouseActionPosition).data('context', context).data('xPos', xPos).data('yPos', yPos).data('rate', mapData[2]);
}
});
if(mw.config.get('wgCategories')[0] === 'ALEA')
{
var aleaPic = $('#mw-content-text img')[0];
var size = 50 * mapData[2];
var aleaX = (mapData[3]-mapData[0]) * size;
var aleaY = (mapData[4]-mapData[1]) * size;
context.drawImage(aleaPic, aleaX, aleaY);
}
}
});
}
});