Content deleted Content added
1.9 |
2.7 |
||
(6 intermediate revisions by the same user not shown) | |||
Line 1:
/// Gadget/fragmentAnchors/r.js
///
/// Fingerprint:#0#
/// Documentation:[[w:en:User:PerfektesChaos/js/fragmentAnchors]]
/// @license:CC-by-sa/4.0 GPLv3
///<nowiki>
(function(mw,$){
"use strict";
var Version=
},EXPORT={},OO;
function facet($area){
Line 29 ⟶ 31:
mw.loader.using(["oojs","oojs-ui-core","oojs-ui-widgets"],facility);}
function fire(){
var signature="ext.gadget."+FANCY,env,rls;
if(mw.loader.getState(signature)!=="ready"){
rls={};
mw.loader.state(signature,"ready");▼
rls[signature]="ready";
if(typeof mw.libs[FANCY]!=="object"||!mw.libs[FANCY]){
mw.libs[FANCY]={};}
Line 75 ⟶ 79:
return mw.html.escape(anchor);
};
FASC.cfg.fair=function(anchor,allow){
var r
if(allow){
if(typeof FASC.wikiAnchor!=="object"){▼
r=anchor;
}else{
r=anchor.replace(/_/g," ");}
▲if(typeof FASC.cfg.wikiAnchor!=="object"){
s="[0-9A-Fa-f]";
s="\\.("+s+s+")";
FASC.cfg.wikiAnchor=new RegExp(s,"g");}
try{
s=r.replace(FASC.cfg.wikiAnchor,"%$1");
r=decodeURIComponent(s);
}catch(e){
}
};
FASC.cfg.familiar=function(anchor,$at){
var s=FASC.cfg.fair(anchor,true),r,$e;
if(s!==anchor&&$at.is("span")){
$e=$at.next();
r=($e.is("span")&&"#"+$e.attr("id")===s);
if(!r){
$e=$at.prev();
r=($e.is("span")&&"#"+$e.attr("id")===s);}}
return r;
};
Line 120 ⟶ 138:
var m=(alert||augment?1:0),n=(alert?20:12),s=FASC["source"+m],$r=$("<img />");
$r.attr({alt:"id?",src:"https://upload.wikimedia.org/wikipedia/commons/thumb/"+s+"/"+n+"px-"+s.substr(5)+".png"});
$r.css({"height":n,
"width":n}); if(alert){
$r.css({"background-color":"#FFFF00",
"border":"#FF0000 2px solid", "padding":"1px"});}
return $r;
Line 135 ⟶ 155:
badge.$i.addClass(FASC.siblings);}
badge.$s=$("<span>");
badge.$s.css({"font-size":"25%"}).text(" ");
badge.$r=$("<span>");
badge.$r.append(badge.$s);
Line 142 ⟶ 161:
$r=badge.$r.clone();
$i=badge.$i.clone();
$r.append($i).append(badge.$s.clone());
$i.hover(function(activity){
FASC.flip(activity,about,0,true);
return false; },function(activity){ FASC.flip(activity,about,0,false
return false;
});
$i.click(function(activity){
FASC.flip(activity,about,1
return false;
about.$img=$i;▼
});
return $r;
};
Line 160 ⟶ 184:
$s=$("<span>");
$s.addClass(FASC.single);
$s.css({"background-color":"#FFFF00",
"border":"#FF0000 2px solid", "color":"#FF0000",
"font-size":"120%", "font-weight":"bold",
"padding-left":"0.2em", "padding-right":"0.2em"});
$s.attr({title:anchor});
Line 178 ⟶ 205:
if(all[s]){
if(FASC.$content){
if(typeof FASC.reApos!=="object"){
seek="[id='"+s.substr(1)+"']";▼
FASC.reApos=new RegExp("'","g");}
▲seek="[id='"+s.substr(1).replace(FASC.reApos,"\\'")+"']";
try{
$e=FASC.$content.find(seek);
$e=false;}
if($e&&$e.length&&!(FASC.$exclude&&FASC.$exclude.find(seek).length)){
r[s]=$e;
}else{
r[s]=all[s];}}}
Line 188 ⟶ 219:
};
FASC.fiat=function(about,action){
var illusive=0.75,margin=10,options={align:"center",anchor:true,horizontalPosition:"center",padded:false,verticalPosition:"below"},show=about.sign,sign=FASC.sign+(action?"-t":"-i")+about.id
$p.css({"left":(-0.5*about.$span.innerWidth()-1)+"px",
"position":"relative",
"top":"3px"});
options.$floatableContainer=$p;
$p=$("<span>");
if(show){
show=(action?"#":"")+FASC.cfg.escape(show);
Line 194 ⟶ 231:
show="#";}
if(about.mode===2){
$p.css({"background-color":"#FFFF00",
"color":"#FF0000", "font-weight":"bold",
"margin":"0.2em", "padding":"0.4em"}).text(show);
}else{
Line 202 ⟶ 241:
show=FASC.cfg.fancy(show);
illusive=0.95;}
$p.css({"color":"#000000",
"font-weight":"normal"}).text(show); }else{
$p.css({"margin":"0.2em",
"width":"2em"}).text(" ");}} $p.attr({"id":sign}).addClass(FASC.sign+"-text")
.css({"font-family":"sans-serif",
"font-size":"medium", "font-style":"normal",
"font-variant":"normal", "visibility":"hidden"});
FASC.$body.append($p);
Line 216 ⟶ 257:
$p.detach().css({"visibility":"visible"});
options.$content=$p;
r=new OO.ui.PopupWidget(options);
"padding":"2px",
▲$e.attr({"role":"tooltip"}).css({"opacity":illusive,
FASC.$body.append(r.$floatable);
▲FASC.$body.append($e);
return r;
};
FASC.file=function(anchor,alert,$a){
var sign=anchor.substr(1),lapse=(!FASC.fine(sign)),mode=(alert?1:(lapse?2:0)),id=FASC.bubbles.length,bubble={id:id,mode:mode,popups:[false,false],sign:sign,live:false,$a:$a,$
FASC.bubbles.push(bubble);
$a.attr({"title":null});
Line 278 ⟶ 316:
$li.text("−"+FASC.want[s]+"× "+s);
$ul.append($li);}
$box.css({"border":"#FF0000 2px solid",
"color":"#FF0000", "margin-bottom":"1em",
"margin-top":"1em", "padding":"0.5em"});
$box.attr({"id":FASC.sign+"-errors"});
$box.addClass(FASC.show+" error "+FASC.sign+"-errors");
$box.append($ul);
$before.before($box);}
Line 307 ⟶ 347:
}else{
popup.toggle(activate);}
▲return false;
};
FASC.furnish=function(){
Line 320 ⟶ 359:
s="#"+$e.attr("id");
if(FASC.filter(s)){
if(FASC.cfg.familiar(s,$e)){
s=false;}
}else{
s=false;}
if(s){
if(typeof total[s]==="object"){
if(typeof FASC.dup[s]!=="object"){
Line 349 ⟶ 393:
if(s!=="#"){
$e.addClass(FASC.scope);
if(typeof total[s]!=="object"&&FASC.filter(s)){
$e.before(FASC.$failure(s));
if(!FASC.want){
|