`
chenfeng_lian
  • 浏览: 9431 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Jquery 简单插件 弹出框

 
阅读更多
/**
 * @author: chenfeng_lian
 * after included jQuery
 */
;var PAF = window.PAF || {}; 
PAF.plugins = PAF.plugins||{};

(function($){
	PAF.plugins.ErrorMsg = function(options){
		this.opts = $.extend(true, PAF.plugins.ErrorMsg.defaults, options);
		this.mask = null;
		this.$el = null;
		this.el = null;

		this.init();
	};
	PAF.plugins.ErrorMsg.prototype = {
		init : function() {
			var Confirm = this;
			var opts = this.opts;
			var sHtml = '<div class="errorLayout">'+this.opts.sHtml+'</div>';
			$('body').append(sHtml);

			Confirm.$el = $('.errorLayout');
			Confirm.setMask();
			$('#close, #confirm').on('click', {
					scope : Confirm
				}, Confirm.fnConfirmIng);
		},
		fn : function() { },
		fnConfirmIng : function(e) {
			var Confirm = e.data.scope;
			Confirm.opts.callbacks.fnConfirmIng
				&& Confirm.opts.callbacks.fnConfirmIng();
			Confirm.mask.remove();
			Confirm.destroy();
			return false;
		},
		destroy : function() { this.$el.remove(); },
		setMask : function() {
			var Confirm = this;
			this.mask = $('<div class="mask"></div>').appendTo(
					Confirm.opts.parent).css({
						height : $(document).height(),
						width : $(Confirm.opts.parent).width()
			});
		}
	};

	PAF.plugins.ErrorMsg.defaults = {
		'parent' : 'body',
		'sHtml': '',
		callbacks: {
			fnConfirmIng: function(){window.console && console.log('fnConfirmIng');}
		}
	};
	return PAF.plugins.ErrorMsg ;
}(jQuery));

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics