From 1e9015c86f152d3ce52b37c8e0420bbcf71e0425 Mon Sep 17 00:00:00 2001 From: Erlimar Silva Campos Date: Mon, 11 Nov 2013 19:30:39 -0200 Subject: [PATCH 1/4] Update messi.js controlling the resizing and scrolling the screen to adjust the message in the user's field of view. --- messi.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/messi.js b/messi.js index 60a7285..d3bab52 100644 --- a/messi.js +++ b/messi.js @@ -94,7 +94,7 @@ function Messi(data, options) { if(_this.options.show) _this.show(); // controlamos el redimensionamiento de la pantalla - jQuery(window).bind('resize', function(){ _this.resize(); }); + jQuery(window).bind('resize scroll', function(){ _this.resize(); }); // configuramos el cierre automático if(_this.options.autoclose != null) { @@ -199,7 +199,7 @@ Messi.prototype = { unload: function() { if (this.visible) this.hide(); - jQuery(window).unbind('resize', function () { this.resize(); }); + jQuery(window).unbind('resize scroll', function () { this.resize(); }); this.messi.remove(); }, From 73f4aa93af078a7b945b4fdd027f8c4777e88359 Mon Sep 17 00:00:00 2001 From: Erlimar Silva Campos Date: Mon, 11 Nov 2013 19:32:21 -0200 Subject: [PATCH 2/4] Update messi.min.js controlling the resizing and scrolling the screen to adjust the message in the user's field of view. --- messi.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/messi.min.js b/messi.min.js index ae5693d..5b93096 100644 --- a/messi.min.js +++ b/messi.min.js @@ -8,4 +8,4 @@ * Licensed under the MIT license: * http://www.opensource.org/licenses/MIT */ -function Messi(e,t){var n=this;n.options=jQuery.extend({},Messi.prototype.options,t||{});n.messi=jQuery(n.template);n.setContent(e);if(n.options.title==null){jQuery(".messi-titlebox",n.messi).remove()}else{jQuery(".messi-title",n.messi).append(n.options.title);if(n.options.buttons.length===0&&!n.options.autoclose){if(n.options.closeButton){var r=jQuery('');r.bind("click",function(){n.hide()});jQuery(".messi-titlebox",this.messi).prepend(r)}}if(n.options.titleClass!=null)jQuery(".messi-titlebox",this.messi).addClass(n.options.titleClass)}if(n.options.width!=null)jQuery(".messi-box",n.messi).css("width",n.options.width);if(n.options.buttons.length>0){for(var i=0;i").data("value",n.options.buttons[i].val);o.bind("click",function(){var e=jQuery.data(this,"value");var t=n.options.callback!=null?function(){n.options.callback(e)}:null;n.hide(t)});jQuery(".messi-actions",this.messi).append(o)}}else{jQuery(".messi-footbox",this.messi).remove()}if(n.options.buttons.length===0&&n.options.title==null&&!n.options.autoclose){if(n.options.closeButton){var r=jQuery('');r.bind("click",function(){n.hide()});jQuery(".messi-content",this.messi).prepend(r)}}n.modal=n.options.modal?jQuery('
').css({opacity:n.options.modalOpacity,width:jQuery(document).width(),height:jQuery(document).height(),"z-index":n.options.zIndex+jQuery(".messi").length}).appendTo(document.body):null;if(n.options.show)n.show();jQuery(window).bind("resize",function(){n.resize()});if(n.options.autoclose!=null){setTimeout(function(e){e.hide()},n.options.autoclose,this)}return n}Messi.prototype={options:{autoclose:null,buttons:[],callback:null,center:true,closeButton:true,height:"auto",title:null,titleClass:null,modal:false,modalOpacity:.2,padding:"10px",show:true,unload:true,viewport:{top:"0px",left:"0px"},width:"500px",zIndex:99999},template:'
',content:"
",visible:false,setContent:function(e){jQuery(".messi-content",this.messi).css({padding:this.options.padding,height:this.options.height}).empty().append(e)},viewport:function(){return{top:(jQuery(window).height()-this.messi.height())/2+jQuery(window).scrollTop()+"px",left:(jQuery(window).width()-this.messi.width())/2+jQuery(window).scrollLeft()+"px"}},show:function(){if(this.visible)return;if(this.options.modal&&this.modal!=null)this.modal.show();this.messi.appendTo(document.body);if(this.options.center)this.options.viewport=this.viewport(jQuery(".messi-box",this.messi));this.messi.css({top:this.options.viewport.top,left:this.options.viewport.left,"z-index":this.options.zIndex+jQuery(".messi").length}).show().animate({opacity:1},300);this.visible=true},hide:function(e){if(!this.visible)return;var t=this;this.messi.animate({opacity:0},300,function(){if(t.options.modal&&t.modal!=null)t.modal.remove();t.messi.css({display:"none"}).remove();t.visible=false;if(e)e.call();if(t.options.unload)t.unload()});return this},resize:function(){if(this.options.modal){jQuery(".messi-modal").css({width:jQuery(document).width(),height:jQuery(document).height()})}if(this.options.center){this.options.viewport=this.viewport(jQuery(".messi-box",this.messi));this.messi.css({top:this.options.viewport.top,left:this.options.viewport.left})}},toggle:function(){this[this.visible?"hide":"show"]();return this},unload:function(){if(this.visible)this.hide();jQuery(window).unbind("resize",function(){this.resize()});this.messi.remove()}};jQuery.extend(Messi,{alert:function(e,t,n){var r=[{id:"ok",label:"OK",val:"OK"}];n=jQuery.extend({closeButton:false,buttons:r,callback:function(){}},n||{},{show:true,unload:true,callback:t});return new Messi(e,n)},ask:function(e,t,n){var r=[{id:"yes",label:"Yes",val:"Y","class":"btn-success"},{id:"no",label:"No",val:"N","class":"btn-danger"}];n=jQuery.extend({closeButton:false,modal:true,buttons:r,callback:function(){}},n||{},{show:true,unload:true,callback:t});return new Messi(e,n)},img:function(e,t){var n=new Image;jQuery(n).load(function(){var e={width:jQuery(window).width()-50,height:jQuery(window).height()-50};var r=this.width>e.width||this.height>e.height?Math.min(e.width/this.width,e.height/this.height):1;jQuery(n).css({width:this.width*r,height:this.height*r});t=jQuery.extend(t||{},{show:true,unload:true,closeButton:true,width:this.width*r,height:this.height*r,padding:0});new Messi(n,t)}).error(function(){console.log("Error loading "+e)}).attr("src",e)},load:function(e,t){t=jQuery.extend(t||{},{show:true,unload:true,params:{}});var n={url:e,data:t.params,dataType:"html",cache:false,error:function(e,t,n){console.log(e.responseText)},success:function(e){new Messi(e,t)}};jQuery.ajax(n)}}); \ No newline at end of file +function Messi(e,t){var n=this;n.options=jQuery.extend({},Messi.prototype.options,t||{});n.messi=jQuery(n.template);n.setContent(e);if(n.options.title==null){jQuery(".messi-titlebox",n.messi).remove()}else{jQuery(".messi-title",n.messi).append(n.options.title);if(n.options.buttons.length===0&&!n.options.autoclose){if(n.options.closeButton){var r=jQuery('');r.bind("click",function(){n.hide()});jQuery(".messi-titlebox",this.messi).prepend(r)}}if(n.options.titleClass!=null)jQuery(".messi-titlebox",this.messi).addClass(n.options.titleClass)}if(n.options.width!=null)jQuery(".messi-box",n.messi).css("width",n.options.width);if(n.options.buttons.length>0){for(var i=0;i").data("value",n.options.buttons[i].val);o.bind("click",function(){var e=jQuery.data(this,"value");var t=n.options.callback!=null?function(){n.options.callback(e)}:null;n.hide(t)});jQuery(".messi-actions",this.messi).append(o)}}else{jQuery(".messi-footbox",this.messi).remove()}if(n.options.buttons.length===0&&n.options.title==null&&!n.options.autoclose){if(n.options.closeButton){var r=jQuery('');r.bind("click",function(){n.hide()});jQuery(".messi-content",this.messi).prepend(r)}}n.modal=n.options.modal?jQuery('
').css({opacity:n.options.modalOpacity,width:jQuery(document).width(),height:jQuery(document).height(),"z-index":n.options.zIndex+jQuery(".messi").length}).appendTo(document.body):null;if(n.options.show)n.show();jQuery(window).bind("resize scroll",function(){n.resize()});if(n.options.autoclose!=null){setTimeout(function(e){e.hide()},n.options.autoclose,this)}return n}Messi.prototype={options:{autoclose:null,buttons:[],callback:null,center:true,closeButton:true,height:"auto",title:null,titleClass:null,modal:false,modalOpacity:.2,padding:"10px",show:true,unload:true,viewport:{top:"0px",left:"0px"},width:"500px",zIndex:99999},template:'
',content:"
",visible:false,setContent:function(e){jQuery(".messi-content",this.messi).css({padding:this.options.padding,height:this.options.height}).empty().append(e)},viewport:function(){return{top:(jQuery(window).height()-this.messi.height())/2+jQuery(window).scrollTop()+"px",left:(jQuery(window).width()-this.messi.width())/2+jQuery(window).scrollLeft()+"px"}},show:function(){if(this.visible)return;if(this.options.modal&&this.modal!=null)this.modal.show();this.messi.appendTo(document.body);if(this.options.center)this.options.viewport=this.viewport(jQuery(".messi-box",this.messi));this.messi.css({top:this.options.viewport.top,left:this.options.viewport.left,"z-index":this.options.zIndex+jQuery(".messi").length}).show().animate({opacity:1},300);this.visible=true},hide:function(e){if(!this.visible)return;var t=this;this.messi.animate({opacity:0},300,function(){if(t.options.modal&&t.modal!=null)t.modal.remove();t.messi.css({display:"none"}).remove();t.visible=false;if(e)e.call();if(t.options.unload)t.unload()});return this},resize:function(){if(this.options.modal){jQuery(".messi-modal").css({width:jQuery(document).width(),height:jQuery(document).height()})}if(this.options.center){this.options.viewport=this.viewport(jQuery(".messi-box",this.messi));this.messi.css({top:this.options.viewport.top,left:this.options.viewport.left})}},toggle:function(){this[this.visible?"hide":"show"]();return this},unload:function(){if(this.visible)this.hide();jQuery(window).unbind("resize scroll",function(){this.resize()});this.messi.remove()}};jQuery.extend(Messi,{alert:function(e,t,n){var r=[{id:"ok",label:"OK",val:"OK"}];n=jQuery.extend({closeButton:false,buttons:r,callback:function(){}},n||{},{show:true,unload:true,callback:t});return new Messi(e,n)},ask:function(e,t,n){var r=[{id:"yes",label:"Yes",val:"Y","class":"btn-success"},{id:"no",label:"No",val:"N","class":"btn-danger"}];n=jQuery.extend({closeButton:false,modal:true,buttons:r,callback:function(){}},n||{},{show:true,unload:true,callback:t});return new Messi(e,n)},img:function(e,t){var n=new Image;jQuery(n).load(function(){var e={width:jQuery(window).width()-50,height:jQuery(window).height()-50};var r=this.width>e.width||this.height>e.height?Math.min(e.width/this.width,e.height/this.height):1;jQuery(n).css({width:this.width*r,height:this.height*r});t=jQuery.extend(t||{},{show:true,unload:true,closeButton:true,width:this.width*r,height:this.height*r,padding:0});new Messi(n,t)}).error(function(){console.log("Error loading "+e)}).attr("src",e)},load:function(e,t){t=jQuery.extend(t||{},{show:true,unload:true,params:{}});var n={url:e,data:t.params,dataType:"html",cache:false,error:function(e,t,n){console.log(e.responseText)},success:function(e){new Messi(e,t)}};jQuery.ajax(n)}}); From 62b4f38353604acdea4064f737be80ca7771fd66 Mon Sep 17 00:00:00 2001 From: Erlimar Silva Campos Date: Fri, 22 Nov 2013 16:57:32 -0200 Subject: [PATCH 3/4] Update messi.js Call callback on autoclose event. --- messi.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/messi.js b/messi.js index d3bab52..cfbbb05 100644 --- a/messi.js +++ b/messi.js @@ -99,7 +99,9 @@ function Messi(data, options) { // configuramos el cierre automático if(_this.options.autoclose != null) { setTimeout(function(_this) { - _this.hide(); + var value = jQuery.data(this, 'value'); + var after = (_this.options.callback != null) ? function () { _this.options.callback(value); } : null; + _this.hide(after); }, _this.options.autoclose, this); }; From 5fab9f12a310e7a3d68a4a785bb3224a647f0f5d Mon Sep 17 00:00:00 2001 From: Erlimar Silva Campos Date: Fri, 22 Nov 2013 17:00:30 -0200 Subject: [PATCH 4/4] Update messi.min.js Call callback on autoclose event. --- messi.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/messi.min.js b/messi.min.js index 5b93096..875c2f4 100644 --- a/messi.min.js +++ b/messi.min.js @@ -8,4 +8,4 @@ * Licensed under the MIT license: * http://www.opensource.org/licenses/MIT */ -function Messi(e,t){var n=this;n.options=jQuery.extend({},Messi.prototype.options,t||{});n.messi=jQuery(n.template);n.setContent(e);if(n.options.title==null){jQuery(".messi-titlebox",n.messi).remove()}else{jQuery(".messi-title",n.messi).append(n.options.title);if(n.options.buttons.length===0&&!n.options.autoclose){if(n.options.closeButton){var r=jQuery('');r.bind("click",function(){n.hide()});jQuery(".messi-titlebox",this.messi).prepend(r)}}if(n.options.titleClass!=null)jQuery(".messi-titlebox",this.messi).addClass(n.options.titleClass)}if(n.options.width!=null)jQuery(".messi-box",n.messi).css("width",n.options.width);if(n.options.buttons.length>0){for(var i=0;i").data("value",n.options.buttons[i].val);o.bind("click",function(){var e=jQuery.data(this,"value");var t=n.options.callback!=null?function(){n.options.callback(e)}:null;n.hide(t)});jQuery(".messi-actions",this.messi).append(o)}}else{jQuery(".messi-footbox",this.messi).remove()}if(n.options.buttons.length===0&&n.options.title==null&&!n.options.autoclose){if(n.options.closeButton){var r=jQuery('');r.bind("click",function(){n.hide()});jQuery(".messi-content",this.messi).prepend(r)}}n.modal=n.options.modal?jQuery('
').css({opacity:n.options.modalOpacity,width:jQuery(document).width(),height:jQuery(document).height(),"z-index":n.options.zIndex+jQuery(".messi").length}).appendTo(document.body):null;if(n.options.show)n.show();jQuery(window).bind("resize scroll",function(){n.resize()});if(n.options.autoclose!=null){setTimeout(function(e){e.hide()},n.options.autoclose,this)}return n}Messi.prototype={options:{autoclose:null,buttons:[],callback:null,center:true,closeButton:true,height:"auto",title:null,titleClass:null,modal:false,modalOpacity:.2,padding:"10px",show:true,unload:true,viewport:{top:"0px",left:"0px"},width:"500px",zIndex:99999},template:'
',content:"
",visible:false,setContent:function(e){jQuery(".messi-content",this.messi).css({padding:this.options.padding,height:this.options.height}).empty().append(e)},viewport:function(){return{top:(jQuery(window).height()-this.messi.height())/2+jQuery(window).scrollTop()+"px",left:(jQuery(window).width()-this.messi.width())/2+jQuery(window).scrollLeft()+"px"}},show:function(){if(this.visible)return;if(this.options.modal&&this.modal!=null)this.modal.show();this.messi.appendTo(document.body);if(this.options.center)this.options.viewport=this.viewport(jQuery(".messi-box",this.messi));this.messi.css({top:this.options.viewport.top,left:this.options.viewport.left,"z-index":this.options.zIndex+jQuery(".messi").length}).show().animate({opacity:1},300);this.visible=true},hide:function(e){if(!this.visible)return;var t=this;this.messi.animate({opacity:0},300,function(){if(t.options.modal&&t.modal!=null)t.modal.remove();t.messi.css({display:"none"}).remove();t.visible=false;if(e)e.call();if(t.options.unload)t.unload()});return this},resize:function(){if(this.options.modal){jQuery(".messi-modal").css({width:jQuery(document).width(),height:jQuery(document).height()})}if(this.options.center){this.options.viewport=this.viewport(jQuery(".messi-box",this.messi));this.messi.css({top:this.options.viewport.top,left:this.options.viewport.left})}},toggle:function(){this[this.visible?"hide":"show"]();return this},unload:function(){if(this.visible)this.hide();jQuery(window).unbind("resize scroll",function(){this.resize()});this.messi.remove()}};jQuery.extend(Messi,{alert:function(e,t,n){var r=[{id:"ok",label:"OK",val:"OK"}];n=jQuery.extend({closeButton:false,buttons:r,callback:function(){}},n||{},{show:true,unload:true,callback:t});return new Messi(e,n)},ask:function(e,t,n){var r=[{id:"yes",label:"Yes",val:"Y","class":"btn-success"},{id:"no",label:"No",val:"N","class":"btn-danger"}];n=jQuery.extend({closeButton:false,modal:true,buttons:r,callback:function(){}},n||{},{show:true,unload:true,callback:t});return new Messi(e,n)},img:function(e,t){var n=new Image;jQuery(n).load(function(){var e={width:jQuery(window).width()-50,height:jQuery(window).height()-50};var r=this.width>e.width||this.height>e.height?Math.min(e.width/this.width,e.height/this.height):1;jQuery(n).css({width:this.width*r,height:this.height*r});t=jQuery.extend(t||{},{show:true,unload:true,closeButton:true,width:this.width*r,height:this.height*r,padding:0});new Messi(n,t)}).error(function(){console.log("Error loading "+e)}).attr("src",e)},load:function(e,t){t=jQuery.extend(t||{},{show:true,unload:true,params:{}});var n={url:e,data:t.params,dataType:"html",cache:false,error:function(e,t,n){console.log(e.responseText)},success:function(e){new Messi(e,t)}};jQuery.ajax(n)}}); +function Messi(e,t){var n=this;n.options=jQuery.extend({},Messi.prototype.options,t||{});n.messi=jQuery(n.template);n.setContent(e);if(n.options.title==null){jQuery(".messi-titlebox",n.messi).remove()}else{jQuery(".messi-title",n.messi).append(n.options.title);if(n.options.buttons.length===0&&!n.options.autoclose){if(n.options.closeButton){var r=jQuery('');r.bind("click",function(){n.hide()});jQuery(".messi-titlebox",this.messi).prepend(r)}}if(n.options.titleClass!=null)jQuery(".messi-titlebox",this.messi).addClass(n.options.titleClass)}if(n.options.width!=null)jQuery(".messi-box",n.messi).css("width",n.options.width);if(n.options.buttons.length>0){for(var i=0;i").data("value",n.options.buttons[i].val);o.bind("click",function(){var e=jQuery.data(this,"value");var t=n.options.callback!=null?function(){n.options.callback(e)}:null;n.hide(t)});jQuery(".messi-actions",this.messi).append(o)}}else{jQuery(".messi-footbox",this.messi).remove()}if(n.options.buttons.length===0&&n.options.title==null&&!n.options.autoclose){if(n.options.closeButton){var r=jQuery('');r.bind("click",function(){n.hide()});jQuery(".messi-content",this.messi).prepend(r)}}n.modal=n.options.modal?jQuery('
').css({opacity:n.options.modalOpacity,width:jQuery(document).width(),height:jQuery(document).height(),"z-index":n.options.zIndex+jQuery(".messi").length}).appendTo(document.body):null;if(n.options.show)n.show();jQuery(window).bind("resize scroll",function(){n.resize()});if(n.options.autoclose!=null){setTimeout(function(e){var v=jQuery.data(this,'value');var a=(e.options.callback!=null)?function(){e.options.callback(v);}:null;e.hide(a);},n.options.autoclose,this)}return n}Messi.prototype={options:{autoclose:null,buttons:[],callback:null,center:true,closeButton:true,height:"auto",title:null,titleClass:null,modal:false,modalOpacity:.2,padding:"10px",show:true,unload:true,viewport:{top:"0px",left:"0px"},width:"500px",zIndex:99999},template:'
',content:"
",visible:false,setContent:function(e){jQuery(".messi-content",this.messi).css({padding:this.options.padding,height:this.options.height}).empty().append(e)},viewport:function(){return{top:(jQuery(window).height()-this.messi.height())/2+jQuery(window).scrollTop()+"px",left:(jQuery(window).width()-this.messi.width())/2+jQuery(window).scrollLeft()+"px"}},show:function(){if(this.visible)return;if(this.options.modal&&this.modal!=null)this.modal.show();this.messi.appendTo(document.body);if(this.options.center)this.options.viewport=this.viewport(jQuery(".messi-box",this.messi));this.messi.css({top:this.options.viewport.top,left:this.options.viewport.left,"z-index":this.options.zIndex+jQuery(".messi").length}).show().animate({opacity:1},300);this.visible=true},hide:function(e){if(!this.visible)return;var t=this;this.messi.animate({opacity:0},300,function(){if(t.options.modal&&t.modal!=null)t.modal.remove();t.messi.css({display:"none"}).remove();t.visible=false;if(e)e.call();if(t.options.unload)t.unload()});return this},resize:function(){if(this.options.modal){jQuery(".messi-modal").css({width:jQuery(document).width(),height:jQuery(document).height()})}if(this.options.center){this.options.viewport=this.viewport(jQuery(".messi-box",this.messi));this.messi.css({top:this.options.viewport.top,left:this.options.viewport.left})}},toggle:function(){this[this.visible?"hide":"show"]();return this},unload:function(){if(this.visible)this.hide();jQuery(window).unbind("resize scroll",function(){this.resize()});this.messi.remove()}};jQuery.extend(Messi,{alert:function(e,t,n){var r=[{id:"ok",label:"OK",val:"OK"}];n=jQuery.extend({closeButton:false,buttons:r,callback:function(){}},n||{},{show:true,unload:true,callback:t});return new Messi(e,n)},ask:function(e,t,n){var r=[{id:"yes",label:"Yes",val:"Y","class":"btn-success"},{id:"no",label:"No",val:"N","class":"btn-danger"}];n=jQuery.extend({closeButton:false,modal:true,buttons:r,callback:function(){}},n||{},{show:true,unload:true,callback:t});return new Messi(e,n)},img:function(e,t){var n=new Image;jQuery(n).load(function(){var e={width:jQuery(window).width()-50,height:jQuery(window).height()-50};var r=this.width>e.width||this.height>e.height?Math.min(e.width/this.width,e.height/this.height):1;jQuery(n).css({width:this.width*r,height:this.height*r});t=jQuery.extend(t||{},{show:true,unload:true,closeButton:true,width:this.width*r,height:this.height*r,padding:0});new Messi(n,t)}).error(function(){console.log("Error loading "+e)}).attr("src",e)},load:function(e,t){t=jQuery.extend(t||{},{show:true,unload:true,params:{}});var n={url:e,data:t.params,dataType:"html",cache:false,error:function(e,t,n){console.log(e.responseText)},success:function(e){new Messi(e,t)}};jQuery.ajax(n)}});