Content deleted Content added
1.6 |
2.7 |
||
(9 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){
mw.hook("wikipage.content").remove(facet);
FASC.$content=$area;
if(FASC.locked){
FASC.$exclude=false;
}else{
FASC.$exclude=FASC.$content.find("form");}
FASC.furnish();}
function facility(){
OO=window.OO;
if(FASC.large){
FASC.$content=false;
FASC.$exclude=false;
FASC.furnish();
}else{
Line 25 ⟶ 29:
if(typeof FASC.cfg.$portlet==="object"){
FASC.cfg.$portlet.hide();}
mw.loader.using(["
function fire(){
var signature="ext.gadget."+FANCY
if(mw.loader.getState(signature)!=="ready"){
rls={};
rls[signature]="ready";
mw.loader.state(rls);
if(typeof mw.libs[FANCY]!=="object"||!mw.libs[FANCY]){
mw.libs[FANCY]={};}
mw.libs[FANCY].type=FANCY;
FANCY=mw.libs[FANCY];
FANCY.vsn=Version;
FANCY.doc="w:en:User:PerfektesChaos/js/"+FANCY.type;
FANCY.doc="[["+FANCY.doc+"]]";
FANCY.fetch=EXPORT.fetch;
FANCY.fire=EXPORT.fire;
env=mw.config.get(["wgAction","wgPageContentModel"]);
FASC.cfg.live=false;
if(env.wgPageContentModel==="wikitext"){
FASC.locked=(env.wgAction==="view");
FASC.sign=FANCY.type;
mw.loader.using(["user","mediawiki.util"],FASC.fire);}}}
function freshed(){
FASC.cfg.live=true;
FASC.cfg.$portlet.show();}
var dup,r,s;
if(FASC.cfg.live){
Line 57 ⟶ 70:
return r;
};
var r=FASC.cfg.live;
if(r){
fiat();}
return r;
};
FASC.cfg.escape=function(anchor){
return mw.html.escape(anchor);
};
FASC.cfg.fair=function(anchor,allow){
var r
if(allow){
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){
}
return r;
};
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 87 ⟶ 111:
FASC.cfg.fire=function(){
var launch,lock,portlet;
FASC.$body=$("body");
if(typeof FANCY.large==="boolean"){
FASC.large=FANCY.large;}
Line 113 ⟶ 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;
};
FASC.$factory=function(
var
if(!
badge={};
badge.$i=FASC.$facet((about.mode===1),(about.mode===2));
badge.$i.addClass(FASC.show);
if(about.mode===1){
badge.$i.addClass(FASC.siblings);}
badge.$s=$("<span>");
badge.$s.css({"font-size":"25%"}).text(" ");
badge.$r.append(badge.$s);
FASC.badges[about.mode]=badge;}
$r=badge.
$
$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.$span=$r;
return $r;
};
Line 158 ⟶ 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 176 ⟶ 205:
if(all[s]){
if(FASC.$content){
if(typeof FASC.reApos!=="object"){
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];}}}
return r;
};
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=$("<span>"),r;
$p.css({"left":(-0.5*about.$span.innerWidth()-1)+"px",
"position":"relative",
"top":"3px"});
about.$span.append($p);
options.$floatableContainer=$p;
$p=$("<span>");
if(show){
show=(action?"#":"")+FASC.cfg.escape(show);
}else{
show="#";}
if(about.mode===2){
$p.css({"background-color":"#FFFF00",
"color":"#FF0000",
"font-weight":"bold",
"margin":"0.2em",
"padding":"0.4em"}).text(show);
}else{
if(show){
if(action){
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);
$p=$("#"+sign);
options.width=$p.outerWidth()+margin;
$p.detach().css({"visibility":"visible"});
options.$content=$p;
r=new OO.ui.PopupWidget(options);
r.$floatable.attr({"role":"tooltip"}).css({"opacity":illusive,
"padding":"2px",
"text-align":"center"});
FASC.$body.append(r.$floatable);
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,$span:false};
FASC.bubbles.push(bubble);
$a.attr({"title":null});
$a.before(FASC.$factory(bubble));
};
FASC.filter=function(anchor){
var r=true,i,s;
if(FASC.
for(i=0;i<FASC.
if(anchor.substr(1,
r=false;
break;}}}
Line 205 ⟶ 291:
};
FASC.fire=function(){
FASC.badges=[false,false,false];
if(typeof FASC.large!=="boolean"){
FASC.large=false;}
if(typeof FASC.unStart
FASC.
FASC.reFine=false;
FASC.scope=FASC.sign+"-inner";
Line 235 ⟶ 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);}
};
FASC.flip=function(activity,about,apply,activate){
var live=about.live,popup=about.popups[apply];
if(typeof activity==="object"&&activity){
if(typeof activity.preventDefault==="function"){
activity.preventDefault();}
if(typeof activity.stopPropagation==="function"){
activity.stopPropagation();}}
if(!popup){
popup=FASC.fiat(about,apply);
about.popups[apply]=popup;
if(apply&&!about.popups[0]){
about.popups[0]=FASC.fiat(about,0);}}
if(apply){
about.popups[0].toggle(false);
live=!live;
about.live=live;
popup.toggle(live);
}else if(live){
popup.toggle(false);
}else{
popup.toggle(activate);}
};
FASC.furnish=function(){
var total={},$total=$("[id]"),dup,i,lapsus,s,$e,$inner
FASC.bubbles=[];
FASC.dup={};
FASC.total=[];
Line 269 ⟶ 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 287 ⟶ 382:
$e=dup[i];
if($e){
total[s]=false;}
if(!lapsus){
Line 299 ⟶ 393:
if(s!=="#"){
$e.addClass(FASC.scope);
if(typeof total[s]!=="object"&&FASC.filter(s)){
$e.before(FASC.$failure(s));
if(!FASC.want){
Line 314 ⟶ 408:
FASC.total.push(s);
if(FASC.learn){
FASC.file(FASC.cfg.fair(s),false,total[s]);}}}
};
fire();
|