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"

From Dwarf Fortress Wiki
Jump to navigation Jump to search
m (link test)
m (fix link)
Line 46: Line 46:
 
//});
 
//});
 
}
 
}
 +
function user_lethosor(e){
 +
T.PD(e);h=window.location.href;
 +
window.location.href=h.slice(0,h.lastIndexOf('/'))+"/User:Lethosor";
 +
}
 +
$(document).delegate('[href=#le-lethosor]','click',user_lethosor);
 
 
 
mscr = (function(){
 
mscr = (function(){
Line 55: Line 60:
 
'background-color':'rgba(100,100,100,0.5)'}).hide().appendTo('body')
 
'background-color':'rgba(100,100,100,0.5)'}).hide().appendTo('body')
 
.attr({href:'#le-menu-hide'});  
 
.attr({href:'#le-menu-hide'});  
MS.header=$("<h3>").css({'text-align':'center'}).html('<a href="User:Lethosor" target="_blank"><span style="color:#093">L</span><span style="color:#084">e</span>'+
+
MS.header=$("<h3>").css({'text-align':'center'}).html('<a href="#le-lethosor" target="_blank"><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:#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></a><span style="color:#c40">Menu</span>')
 
'<span style="color:#048">s</span><span style="color:#039">o</span><span style="color:#02a">r</span></a><span style="color:#c40">Menu</span>')

Revision as of 02:31, 1 March 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();
		//});
	}
	function user_lethosor(e){
		T.PD(e);h=window.location.href;
		window.location.href=h.slice(0,h.lastIndexOf('/'))+"/User:Lethosor";
	}
	$(document).delegate('[href=#le-lethosor]','click',user_lethosor);
	
	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('<a href="#le-lethosor" target="_blank"><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></a><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);
			$('body').css({overflow:'hidden'});
			MS.active=true;
		};
		MS.hide=function(evt){
			T.PD(evt);
			MS.$O.stop().fadeOut(400);
			MS.$.stop().fadeOut(250);
			$('body').css({overflow:'auto'});
			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;
})();
});