jquery -> toast 효과

1758 단어 jquery

 
/**
 *   android   Toast  ,                         
 * @param config
 * @return
 */
var Toast = function(config){
	this.context = config.context==null?$('body'):config.context;//   
	this.message = config.message;//    
	this.time = config.time==null?3000:config.time;//    
	this.left = config.left;//        
	this.top = config.top;//        
	this.init();
}
var msgEntity;
Toast.prototype = {
	//           
	init : function(){
		$("#toastMessage").remove();
		//     
		var msgDIV = new Array();
		msgDIV.push('<div id="toastMessage" style="border-radius:18px;-moz-opacity:0.6;opacity:0.6;">');
		msgDIV.push('<span>'+this.message+'</span>');
		msgDIV.push('</div>');
		msgEntity = $(msgDIV.join('')).appendTo(this.context);
		//      
		var left = this.left == null ? this.context.width()/2-msgEntity.find('span').width()/2 : this.left;
		var top = this.top == null ? '20px' : this.top;
		msgEntity.css({position:'absolute',bottom:top,'z-index':'99',left:left,'background-color':'black',color:'white','font-size':'15px',padding:'10px',margin:'10px'});
		msgEntity.hide();
	},
	//    
	show :function(){
		msgEntity.fadeIn(this.time/2);
		msgEntity.fadeOut(this.time/2);
	}
		
}
	new Toast({context:$('body'),message:'Toast    '}).show();  

 
 
 
 
 
 
 
 
 
 

좋은 웹페이지 즐겨찾기