User:PerfektesChaos/js/fragmentAnchors/r.js: Difference between revisions

Content deleted Content added
1.8
1.9
Line 1:
/// Gadget/fragmentAnchors/r.js
/// 2016-0409-2401 PerfektesChaos@de.wikipedia
/// Fingerprint:#0#256A6881C6F672FB#
///<nowiki>
(function(mw,$){
"use strict";
var Version=1.89,FANCY="fragmentAnchors",FASC={cfg:{},siblings:"error-repeated-id",source0:"6/62/Anchor_pictogram.svg",source1:"d/d6/Anchor_pictogram_red.svg",unStart:["Anker:","wpTextbox"],vsn:Version
},EXPORT={},OO;
};
if(typeof mw.libs[FANCY]!=="object"||!mw.libs[FANCY]){
mw.libs[FANCY]={};}
mw.libs[FANCY].type=FANCY;
FANCY=mw.libs[FANCY];
function facet($area){
mw.hook("wikipage.content").remove(facet);
Line 20 ⟶ 16:
FASC.furnish();}
function facility(){
OO=window.OO;
if(FASC.large){
FASC.$content=false;
Line 30 ⟶ 27:
if(typeof FASC.cfg.$portlet==="object"){
FASC.cfg.$portlet.hide();}
mw.loader.using(["jquery.tipsyoojs","oojs-ui-core","oojs-ui-widgets"],facility);}
function fire(){
var signature="ext.gadget."+FANCY.type,env;
FANCY.doc="[[w:en:User:PerfektesChaos/js/"+FANCY.type+"]]";
if(mw.loader.getState(signature)!=="ready"){
mw.loader.state(signature,"ready");
if(typeof mw.libs[FANCY]!=="object"||!mw.libs[FANCY]){
env=mw.config.get(["wgAction","wgPageContentModel"]);
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;
FASC.cfg.live=false;
mw.loader.using(["user","mediawiki.util"],FASC.fire);}}}
function freshed(){
FASC.cfg.live=true;
FASC.cfg.$portlet.show();}
FANCYEXPORT.fetch=function(){
var dup,r,s;
if(FASC.cfg.live){
Line 62 ⟶ 66:
return r;
};
FANCYEXPORT.fire=function(){
var r=FASC.cfg.live;
if(r){
fiat();}
return r;
};
FASC.cfg.element=function(attend,attributes,anchor){
return mw.html.element(attend,attributes,anchor);
};
FASC.cfg.escape=function(anchor){
Line 92 ⟶ 93:
FASC.cfg.fire=function(){
var launch,lock,portlet;
FASC.$body=$("body");
if(typeof FANCY.large==="boolean"){
FASC.large=FANCY.large;}
Line 124 ⟶ 126:
return $r;
};
FASC.$factory=function(anchor,alertabout){
var sign=anchor.substr(1),lapse=(!FASC.fine(sign)),mode=(alert?1:(lapse?2:0)),$rbadge=FASC.badges[about.mode],show,$i,$sr;
if(!$rbadge){
badge={};
$i=FASC.$facet(alert,lapse);
badge.$i=FASC.$facet((about.mode===1),(about.mode===2));
$i.addClass(FASC.show);
badge.$i.addClass(FASC.show);
if(alert){
if(about.mode===1){
$i.addClass(FASC.siblings);}
badge.$i.addClass(FASC.siblings);}
$i.attr({rel:"tipsy"});
badge.$s=$("<span>");
badge.$s.css({"font-size":"25%"});
badge.$s.text(" ");
badge.$r=$("<aspan>");
badge.$r.attrappend({href:"#"}badge.$s);
FASC.badges[about.mode]=badge;}
$r.append($s);
$r=badge.$r.clone();
$i=badge.$i.clone();
$r.append($i);
$r.append(badge.$s.clone());
$i.hover(function(activity){
FASC.badges[mode]=$r;}
FASC.flip(activity,about,0,true);},function(activity){
$r=$r.clone();
FASC.flip(activity,about,0,false);});
$i=$r.children();
$i.click(function(activity){
if(lapse){
FASC.flip(activity,about,1);});
show=FASC.cfg.element("span",{style:"background-color:#FFFF00;color:#FF0000;font-weight:bold;margin:0.2em;padding:0.4em;"},sign);
about.$img=$i;
}else{
if(sign){
show=FASC.cfg.escape(sign);
}else{
show=FASC.cfg.element("span",{style:"margin:0.2em;width:2em;"},"  ");}}
$i.attr({"data-id":sign,"title":show});
$i.tipsy({gravity:"s",html:true,opacity:0.8});
$r.click(FASC.flip);
return $r;
};
Line 189 ⟶ 186:
r[s]=all[s];}}}
return r;
};
FASC.fiat=function(about,action){
var illusive=0.75,margin=10,options={align:"center",anchor:true,padded:false},show=about.sign,sign=FASC.sign+(action?"-t":"-i")+about.id,$i=about.$img,$p=$("<span>"),offset,r,$e;
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;
offset=$i.offset();
offset.top+=$i.innerHeight()+margin;
r=new OO.ui.PopupWidget(options);
$e=r.$element;
$e.attr({"role":"tooltip"}).css({"opacity":illusive,
"padding":"2px","text-align":"center"})
.offset(offset);
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,$img:false};
FASC.bubbles.push(bubble);
$a.attr({"title":null});
$a.before(FASC.$factory(bubble));
};
FASC.filter=function(anchor){
Line 239 ⟶ 281:
"margin-bottom":"1em","margin-top":"1em",
"padding":"0.5em"});
$box.attr({"id":FASC.sign+"-errors"});
$box.addClass(FASC.show+" error");
$box.append($ul);
$before.before($box);}
};
FASC.flip=function(activity,about,apply,activate){
var live=about.live,popup=about.popups[apply];
var $that=$(this),sel=$that.attr("original-title"),$img;
if(typeof activity==="object"&&activity){
if(sel){
if(typeof activity.preventDefault==="function"){
$that.attr({"rel":null,"original-title":null});
activity.preventDefault();}
sel="hide";
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);}
$img=$that.children().eq(1);
$img.trigger($.Event("mouseleave"));
sel=$img.attr("data-id");
sel=FASC.cfg.fancy("#"+sel);
$that.attr({"rel":"tipsy","title":sel});
$that.tipsy({gravity:"n",opacity:0.9,trigger:"manual"});
sel="show";}
$that.tipsy(sel);
return false;
};
FASC.furnish=function(){
var total={},$total=$("[id]"),dup,i,lapsus,s,$e,$inner,$m;
FASC.bubbles=[];
FASC.dup={};
FASC.total=[];
Line 288 ⟶ 338:
$e=dup[i];
if($e){
$m=FASC.$factoryfile(s,true,$e);}}
$e.before($m);}}
total[s]=false;}
if(!lapsus){
Line 315 ⟶ 364:
FASC.total.push(s);
if(FASC.learn){
FASC.file(FASC.cfg.fair(s),false,total[s]);}}}
$e=total[s];
$m=FASC.$factory(FASC.cfg.fair(s),false);
$e.before($m);}}}
};
fire();