package("components"); /** * Construye caja de dialogo * * @classDescription Construye una caja de dialogo general * @namespace components * @extends Listener * @author Pablo Viojo * @version 1 */ svweb.components.DialogBox = Listener.extend({ status:"closed", _message:"", initialize:function(options){ if (options){ this.options = jQuery.extend ( { id:(new Date()).getTime(), content:"", closeOnOk:true, closeBtn:null, buttons:null, offset:{ x:0, y:0 } }, options ); this._message = this.options.msg } this.body = jQuery("#"+this._getCntId()); if (this.body.length==0){ jQuery("body").append('
' + '' + ''); this.body = jQuery("#"+this._getCntId()); if (this.options.content){ var msgBody = jQuery(".msg_body",this.body).append(jQuery(this.options.content)); if (this.options.closeBtn){ jQuery(this.options.closeBtn,msgBody).click(this._evtClose.closure(this)); } var html = '" msgBody.append(html); jQuery("#msg_but_cont a.btn_cancel", this.body).click(this.cancel.closure(this)); jQuery("#msg_but_cont a.btn_ok", this.body).click(this.ok.closure(this)); jQuery("#msg_but_cont a.btn_accept", this.body).click(this.accept.closure(this)); } } }, cancel:function(){ this.fire("cancel"); this.close(); }, ok:function(){ this.fire("ok"); if (this.options.closeOnOk){ this.close(); } }, accept:function(){ this.fire("accept"); this.close(); }, _evtClose:function(e){ this.close(); }, _getCntId:function(){ return "dialogBox_"+this.options.id; }, show:function(){ this.open(); }, open:function(){ var h = Math.max($(document).height(),$(window).height()); var w = Math.max($(document).width(),$(window).width()); jQuery("#overlay").css({height:h,width:w,opacity:0}); jQuery("#overlay").fadeTo("normal",0.5).show(); if ($.browser.msie){ this.body.css({opacity:0}).show(); } this.center(); this.body.fadeIn("normal"); this.status = "opened"; this.fire("open",null); }, center:function(){ var pos = getCenter("#"+this._getCntId()); this.body.css({top:pos.top+this.options.offset.y,left:pos.left+this.options.offset.x}); }, hide:function(){ this.close(); }, close:function(){ if (this.status == "opened"){ this.status = "closed"; jQuery("#overlay").fadeOut("normal"); jQuery("#"+this._getCntId()).fadeOut("normal"); } this.fire("close",null); }, /* * Información adicional al combo, se envia con los eventos */ setData:function(data){ this._data = data; }, getData:function(){ return this._data; }, setMessage:function(message){ this._message = message; jQuery("#msgBox .msg_body p").html(this._message); } });