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 (fix })
m (update)
Line 2: Line 2:
 
LE=(function(){
 
LE=(function(){
 
_le = {};
 
_le = {};
 +
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){
 
function A(a,b){
 
if(!b){
 
if(!b){
Line 20: Line 30:
 
link.bind('click', function(e){
 
link.bind('click', function(e){
 
e.preventDefault();
 
e.preventDefault();
 +
mscr().show();
 
});
 
});
 
}
 
}
init();
 
 
 
return _le;
+
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');
 +
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'); //upper 'o' not #0
 +
MS.header=$("<h3>").css({'text-align':'center'}).text("LethosorMenu").appendTo(MS.$);
 +
MS.close=$("<a>").attr({href:'#'}).text('Close').css({'text-align':'right','float':'right','color':'red'})
 +
.prependTo(MS.$);
 +
 +
MS.show=function(evt){
 +
T.PD(evt);
 +
MS.$O.fadeIn(500);
 +
MS.$.fadeIn(350);
 +
MS.active=true
 +
};
 +
MS.hide=function(evt){
 +
T.PD(evt);
 +
MS.$O.fadeOut(400);
 +
MS.$.fadeOut(250);
 +
MS.active=false
 +
};
 +
MS.close.bind('click',MS.hide);
 +
 +
return function(){return MS;};
 +
})();
 +
A('menuScreen',mscr);
 +
 +
keyf=function(e){
 +
if(e.metaKey||e.ctrlKey)return;
 +
M=mscr();
 +
if(!M.active)return;
 +
T.PD(e);
 +
if(e.keyCode==27){//esc
 +
M.hide();
 +
}
 +
};
 +
$(document).bind('keydown', keyf);
 +
 +
init();return _le;
 
})();
 
})();
 
});
 
});

Revision as of 21:58, 28 February 2013

;jQuery(function($){
LE=(function(){
	_le = {};
	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;
	}
	function init(){
		if(window.console&&window.console.log) console.log("Loaded LethosorMenu");
		link = $("<a>").attr({href:'#'}).text("LethosorMenu");
		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');
		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'); //upper 'o' not #0
		MS.header=$("<h3>").css({'text-align':'center'}).text("LethosorMenu").appendTo(MS.$);
		MS.close=$("<a>").attr({href:'#'}).text('Close').css({'text-align':'right','float':'right','color':'red'})
			.prependTo(MS.$);
		
		MS.show=function(evt){
			T.PD(evt);
			MS.$O.fadeIn(500);
			MS.$.fadeIn(350);
			MS.active=true
		};
		MS.hide=function(evt){
			T.PD(evt);
			MS.$O.fadeOut(400);
			MS.$.fadeOut(250);
			MS.active=false
		};
		MS.close.bind('click',MS.hide);
		
		return function(){return MS;};
	})();
	A('menuScreen',mscr);
	
	keyf=function(e){
		if(e.metaKey||e.ctrlKey)return;
		M=mscr();
		if(!M.active)return;
		T.PD(e);
		if(e.keyCode==27){//esc
			M.hide();
		}
	};
	$(document).bind('keydown', keyf);
	
	init();return _le;
})();
});