v50 Steam/Premium information for editors
- v50 information can now be added to pages in the main namespace. v0.47 information can still be found in the DF2014 namespace. See here for more details on the new versioning policy.
- Use this page to report any issues related to the migration.
This notice may be cached—the current version can be found here.
Difference between revisions of "User:Lethosor/main.js"
Jump to navigation
Jump to search
m (update - color, modal click to exit) |
m (add opts v0.0.0.0.0.0.1) |
||
Line 3: | Line 3: | ||
LE=(function(){ | LE=(function(){ | ||
_le = {}; | _le = {}; | ||
+ | _le.OPTS={} | ||
+ | function update_opts(){ | ||
+ | if(!'LE_USER_OPTS' in window)window.LE_USER_OPTS={} | ||
+ | _le.OPTS=$.extend({ | ||
+ | menu:{ | ||
+ | show_overlay:true | ||
+ | } | ||
+ | },window.LE_USER_OPTS); | ||
+ | } | ||
+ | update_opts(); | ||
+ | O=function(){return _le.OPTS}; | ||
T={ | T={ | ||
func:function(o){return !!(o&&o.call);}, | func:function(o){return !!(o&&o.call);}, | ||
Line 24: | Line 35: | ||
return A; | return A; | ||
} | } | ||
+ | A('update_opts',update_opts); | ||
function init(){ | function init(){ | ||
if(window.console&&window.console.log) console.log("Loaded LethosorMenu"); | if(window.console&&window.console.log) console.log("Loaded LethosorMenu"); | ||
Line 52: | Line 64: | ||
MS.show=function(evt){ | MS.show=function(evt){ | ||
T.PD(evt); | T.PD(evt); | ||
− | MS.$O.fadeIn(500); | + | if(O().menu.show_overlay) MS.$O.stop().fadeIn(500); |
− | MS.$.fadeIn(350); | + | MS.$.stop().fadeIn(350); |
MS.active=true | MS.active=true | ||
}; | }; | ||
MS.hide=function(evt){ | MS.hide=function(evt){ | ||
T.PD(evt); | T.PD(evt); | ||
− | MS.$O.fadeOut(400); | + | MS.$O.stop().fadeOut(400); |
− | MS.$.fadeOut(250); | + | MS.$.stop().fadeOut(250); |
MS.active=false | MS.active=false | ||
}; | }; |
Revision as of 23:53, 28 February 2013
;jQuery(function($){
LE=(function(){
_le = {};
_le.OPTS={}
function update_opts(){
if(!'LE_USER_OPTS' in window)window.LE_USER_OPTS={}
_le.OPTS=$.extend({
menu:{
show_overlay:true
}
},window.LE_USER_OPTS);
}
update_opts();
O=function(){return _le.OPTS};
T={
func:function(o){return !!(o&&o.call);},
PD:function(e){//preventDefault
if(!e||!e.preventDefault)return;
o=e.preventDefault;if(e&&!!(o&&o.call)) e.preventDefault();
},
log:function(s){
if(console&&console.log&&console.log.call)console.log(s);
},
}
function A(a,b){
if(!b){
if (typeof a != 'object') return;
for(i in a){
if(i in {}) continue;
_le[i] = a[i]
}
}
else _le[a]=b;
return A;
}
A('update_opts',update_opts);
function init(){
if(window.console&&window.console.log) console.log("Loaded LethosorMenu");
link = $("<a>").attr({href:'#le-menu-show'}).text("LethosorMenu").attr({title:'Shift-Alt-L'});
menuitem = $("<li>").append(link);
$("div#p-personal ul").append(menuitem);
//link.bind('click', function(e){
// e.preventDefault();
// mscr().show();
//});
}
mscr = (function(){
MS={active:false,};
MS.$=$("<div>").css({position:'absolute', 'z-index':100, top:'10%', left:'10%', width:'80%', height:'80%',
'background-color':'white', padding:'1.5em', margin:'-1.5em'}).hide().appendTo('body');
//upper 'o' not #0
MS.$O=$("<div>").css({position:'absolute', 'z-index':99, top:0, left:0, width:'100%', height:'100%',
'background-color':'rgba(100,100,100,0.5)'}).hide().appendTo('body')
.attr({href:'#le-menu-hide'});
MS.header=$("<h3>").css({'text-align':'center'}).html('<span style="color:#093">L</span><span style="color:#084">e</span>'+
'<span style="color:#075">t</span><span style="color:#066">h</span><span style="color:#057">o</span>'+
'<span style="color:#048">s</span><span style="color:#039">o</span><span style="color:#02a">r</span><span style="color:#c40">Menu</span>')
.appendTo(MS.$);
MS.close=$("<a>").attr({href:'#le-menu-hide'}).text('Close').css({'text-align':'right','float':'right','color':'red'})
.attr({title:'Esc'}).prependTo(MS.$);
MS.show=function(evt){
T.PD(evt);
if(O().menu.show_overlay) MS.$O.stop().fadeIn(500);
MS.$.stop().fadeIn(350);
MS.active=true
};
MS.hide=function(evt){
T.PD(evt);
MS.$O.stop().fadeOut(400);
MS.$.stop().fadeOut(250);
MS.active=false
};
$(document).delegate('[href=#le-menu-show]','click',MS.show);
$(document).delegate('[href=#le-menu-hide]','click',MS.hide);
return function(){return MS;};
})();
A('menuScreen',mscr);
keyf=function(e){
if(e.metaKey||e.ctrlKey)return;
M=mscr();
if(e.altKey&&e.shiftKey&&e.keyCode==76){//S-A-l
if(!M.active)M.show();return;
}
if(!M.active)return;
T.PD(e);
if(e.keyCode==27){//esc
M.hide();
}
};
$(document).bind('keydown', keyf);
init();return _le;
})();
});