");
$alert.attr("class", "bootstrap-growl alert");
@@ -13,7 +13,7 @@
$alert.addClass("alert-" + options.type);
}
if (options.allow_dismiss) {
- $alert.append("
");
}
$alert.append(message);
if (options.top_offset) {
@@ -57,6 +57,20 @@
return $(this).alert("close");
});
}
+ if (options.autoshrink) {
+ $(options.ele).on("click", ".bootstrap-growl.alert>.close", function(e) {
+ var $this, height;
+ $this = $(this).closest(".alert");
+ height = $this.outerHeight() + options.stackup_spacing;
+ $this.nextAll().css(options.offset.from, function(i, val) {
+ val = parseInt(val, 10);
+ return (val - height) + "px";
+ });
+ $this.alert("close");
+ e.preventDefault();
+ return e.stopPropagation();
+ });
+ }
return $alert;
};
@@ -71,7 +85,8 @@
width: 250,
delay: 4000,
allow_dismiss: true,
- stackup_spacing: 10
+ stackup_spacing: 10,
+ autoshrink: true
};
}).call(this);
diff --git a/jquery.bootstrap-growl.min.js b/jquery.bootstrap-growl.min.js
index 09045f6..45c27ef 100644
--- a/jquery.bootstrap-growl.min.js
+++ b/jquery.bootstrap-growl.min.js
@@ -1 +1 @@
-(function(){var t;t=jQuery,t.bootstrapGrowl=function(e,s){var a,o,l;switch(s=t.extend({},t.bootstrapGrowl.default_options,s),a=t("
"),a.attr("class","bootstrap-growl alert"),s.type&&a.addClass("alert-"+s.type),s.allow_dismiss&&a.append('
×'),a.append(e),s.top_offset&&(s.offset={from:"top",amount:s.top_offset}),l=s.offset.amount,t(".bootstrap-growl").each(function(){return l=Math.max(l,parseInt(t(this).css(s.offset.from))+t(this).outerHeight()+s.stackup_spacing)}),o={position:"body"===s.ele?"fixed":"absolute",margin:0,"z-index":"9999",display:"none"},o[s.offset.from]=l+"px",a.css(o),"auto"!==s.width&&a.css("width",s.width+"px"),t(s.ele).append(a),s.align){case"center":a.css({left:"50%","margin-left":"-"+a.outerWidth()/2+"px"});break;case"left":a.css("left","20px");break;default:a.css("right","20px")}return a.fadeIn(),s.delay>0&&a.delay(s.delay).fadeOut(function(){return t(this).alert("close")}),a},t.bootstrapGrowl.default_options={ele:"body",type:"info",offset:{from:"top",amount:20},align:"right",width:250,delay:4e3,allow_dismiss:!0,stackup_spacing:10}}).call(this);
+(function(){var t;t=jQuery,t.bootstrapGrowl=function(e,s){var o,a,r;switch(s=t.extend({},t.bootstrapGrowl.default_options,s),o=t("
"),o.attr("class","bootstrap-growl alert"),s.type&&o.addClass("alert-"+s.type),s.allow_dismiss&&o.append('
×'),o.append(e),s.top_offset&&(s.offset={from:"top",amount:s.top_offset}),r=s.offset.amount,t(".bootstrap-growl").each(function(){return r=Math.max(r,parseInt(t(this).css(s.offset.from))+t(this).outerHeight()+s.stackup_spacing)}),a={position:"body"===s.ele?"fixed":"absolute",margin:0,"z-index":"9999",display:"none"},a[s.offset.from]=r+"px",o.css(a),"auto"!==s.width&&o.css("width",s.width+"px"),t(s.ele).append(o),s.align){case"center":o.css({left:"50%","margin-left":"-"+o.outerWidth()/2+"px"});break;case"left":o.css("left","20px");break;default:o.css("right","20px")}return o.fadeIn(),s.delay>0&&o.delay(s.delay).fadeOut(function(){return t(this).alert("close")}),s.autoshrink&&t(s.ele).on("click",".bootstrap-growl.alert>.close",function(e){var o,a;return o=t(this).closest(".alert"),a=o.outerHeight()+s.stackup_spacing,o.nextAll().css(s.offset.from,function(t,e){return e=parseInt(e,10),e-a+"px"}),o.alert("close"),e.preventDefault(),e.stopPropagation()}),o},t.bootstrapGrowl.default_options={ele:"body",type:"info",offset:{from:"top",amount:20},align:"right",width:250,delay:4e3,allow_dismiss:!0,stackup_spacing:10,autoshrink:!0}}).call(this);
\ No newline at end of file