You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2014/10/19 13:40:40 UTC
[63/78] [abbrv] git commit: ISIS-537 Use
https://github.com/mouse0270/bootstrap-growl instead of
https://github.com/stanlemon/jGrowl
ISIS-537 Use https://github.com/mouse0270/bootstrap-growl instead of https://github.com/stanlemon/jGrowl
https://trello.com/c/6X5FTzZY/44-toast-pop-ups-need-to-be-larger-more-visible-and-doesn-t-seem-to-follow-the-theme
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/80bc388a
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/80bc388a
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/80bc388a
Branch: refs/heads/master
Commit: 80bc388a8dd4a3949b31158cdcc18f70acc63a47
Parents: 2533cef
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Fri Oct 17 10:45:58 2014 +0300
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Fri Oct 17 10:45:58 2014 +0300
----------------------------------------------------------------------
component/viewer/wicket/pom.xml | 2 +
.../wicket/ui/errors/JGrowlBehaviour.java | 14 +-
.../viewer/wicket/ui/errors/JGrowlUtil.java | 19 +-
.../wicket/ui/errors/js/bootstrap-growl.js | 312 ++++++++++++++++
.../wicket/ui/errors/js/bootstrap-growl.min.js | 2 +
.../viewer/wicket/ui/pages/PageAbstract.html | 3 -
.../viewer/wicket/ui/pages/PageAbstract.java | 18 +-
.../viewer/wicket/ui/pages/jquery.jgrowl.css | 253 -------------
.../viewer/wicket/ui/pages/jquery.jgrowl.js | 352 -------------------
9 files changed, 343 insertions(+), 632 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/80bc388a/component/viewer/wicket/pom.xml
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/pom.xml b/component/viewer/wicket/pom.xml
index e76802d..b711983 100644
--- a/component/viewer/wicket/pom.xml
+++ b/component/viewer/wicket/pom.xml
@@ -103,6 +103,8 @@
<exclude>**/moment.min.js</exclude>
<exclude>**/bootstrap-datetimepicker.js</exclude>
<exclude>**/bootstrap-datetimepicker.min.js</exclude>
+ <exclude>**/bootstrap-growl.js</exclude>
+ <exclude>**/bootstrap-growl.min.js</exclude>
</excludes>
</configuration>
<executions>
http://git-wip-us.apache.org/repos/asf/isis/blob/80bc388a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/errors/JGrowlBehaviour.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/errors/JGrowlBehaviour.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/errors/JGrowlBehaviour.java
index a869d17..90084e6 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/errors/JGrowlBehaviour.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/errors/JGrowlBehaviour.java
@@ -24,7 +24,9 @@ import org.apache.wicket.Component;
import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.head.IHeaderResponse;
+import org.apache.wicket.markup.head.JavaScriptHeaderItem;
import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
+import org.apache.wicket.request.resource.JavaScriptResourceReference;
import org.apache.isis.applib.RecoverableException;
import org.apache.isis.core.commons.authentication.MessageBroker;
@@ -58,14 +60,22 @@ public class JGrowlBehaviour extends AbstractDefaultAjaxBehavior {
@Override
public void renderHead(Component component, IHeaderResponse response) {
super.renderHead(component, response);
+
+ renderFeedbackMessages(response);
+ }
+
+ public void renderFeedbackMessages(IHeaderResponse response) {
+ response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(JGrowlBehaviour.class, "js/bootstrap-growl.js")));
+
String feedbackMsg = JGrowlUtil.asJGrowlCalls(getMessageBroker());
if(!Strings.isNullOrEmpty(feedbackMsg)) {
response.render(OnDomReadyHeaderItem.forScript(feedbackMsg));
}
}
-
+
+
protected MessageBroker getMessageBroker() {
return IsisContext.getMessageBroker();
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/80bc388a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/errors/JGrowlUtil.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/errors/JGrowlUtil.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/errors/JGrowlUtil.java
index 293cfc2..b571926 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/errors/JGrowlUtil.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/errors/JGrowlUtil.java
@@ -29,28 +29,31 @@ public class JGrowlUtil {
final StringBuilder buf = new StringBuilder();
for (String info : messageBroker.getMessages()) {
- addJGrowlCall(info, "INFO", false, buf);
+ addJGrowlCall(info, "info", false, buf);
}
for (String warning : messageBroker.getWarnings()) {
- addJGrowlCall(warning, "WARNING", true, buf);
+ addJGrowlCall(warning, "warning", true, buf);
}
final String error = messageBroker.getApplicationError();
if(error!=null) {
- addJGrowlCall(error, "ERROR", true, buf);
+ addJGrowlCall(error, "danger", true, buf);
}
return buf.toString();
}
private static void addJGrowlCall(final String origMsg, final String cssClassSuffix, boolean sticky, final StringBuilder buf) {
final CharSequence escapedMsg = escape(origMsg);
- buf.append("$.jGrowl(\"").append(escapedMsg).append('\"');
+ buf.append("$.growl(\"")
+ .append(escapedMsg)
+ .append("   ") // add some space so that the dismiss icon (x) doesn't overlap with the text
+ .append('"');
buf.append(", {");
- buf.append("theme: \"jgrowl-").append(cssClassSuffix).append("\"");
+ buf.append("type: \"").append(cssClassSuffix).append('"');
if (sticky) {
- buf.append(", sticky: true");
+ buf.append(", delay: 0");
}
- buf.append("}");
+ buf.append('}');
buf.append(");\n");
}
@@ -62,6 +65,4 @@ public class JGrowlUtil {
.replace(""", "'")
.replace("'", "'");
}
-
-
}
http://git-wip-us.apache.org/repos/asf/isis/blob/80bc388a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/errors/js/bootstrap-growl.js
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/errors/js/bootstrap-growl.js b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/errors/js/bootstrap-growl.js
new file mode 100644
index 0000000..ec3012e
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/errors/js/bootstrap-growl.js
@@ -0,0 +1,312 @@
+/*
+* Project: Bootstrap Growl - v2.0.0
+* Description: Turns standard Bootstrap alerts into "Growl-like" notifications.
+* Author: Mouse0270 aka Robert McIntosh
+* License: MIT License
+* Website: https://github.com/mouse0270/bootstrap-growl
+*/
+;(function ( $, window, document, undefined ) {
+ // Create the defaults once
+ var pluginName = "growl",
+ dataKey = "plugin_" + pluginName,
+ defaults = {
+ element: 'body',
+ type: "info",
+ allow_dismiss: true,
+ placement: {
+ from: "top",
+ align: "right"
+ },
+ offset: 20,
+ spacing: 10,
+ z_index: 1031,
+ delay: 5000,
+ timer: 1000,
+ url_target: '_blank',
+ mouse_over: false,
+ animate: {
+ enter: 'animated fadeInDown',
+ exit: 'animated fadeOutUp'
+ },
+ onShow: null,
+ onShown: null,
+ onHide: null,
+ onHidden: null,
+ icon_type: 'class',
+ template: '<div data-growl="container" class="alert" role="alert"><button type="button" class="close" data-growl="dismiss"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button><span data-growl="icon"></span><span data-growl="title"></span><span data-growl="message"></span><a href="#" data-growl="url"></a></div>'
+ };
+
+ // The actual plugin constructor
+ var setDefaults = function(element, options) {
+ defaults = $.extend(true, {}, defaults, options);
+ },
+ closeAll = function(options) {
+ if (!options) {
+ $('[data-growl="container"]').find('[data-growl="dismiss"]').trigger('click');
+ }else{
+ $('[data-growl="container"][data-growl-position="'+options+'"]').find('[data-growl="dismiss"]').trigger('click');
+ }
+ },
+ Plugin = function (element, content, options) {
+ var content = {
+ content: {
+ message: typeof content == 'object' ? content.message : content,
+ title: content.title ? content.title : null,
+ icon: content.icon ? content.icon : null,
+ url: content.url ? content.url : null
+ }
+ };
+
+ options = $.extend(true, {}, content, options);
+ this.settings = $.extend(true, {}, defaults, options);
+ plugin = this;
+ init(options, this.settings, plugin);
+ this.$template = $template;
+ },
+ init = function (options, settings, plugin) {
+
+ var base = {
+ settings: settings,
+ $element: $(settings.element),
+ template: settings.template
+ };
+
+ if (typeof settings.offset == 'number') {
+ settings.offset = {
+ x: settings.offset,
+ y: settings.offset
+ };
+ }
+
+ $template = buildGrowl(base);
+ addContent($template, base.settings);
+ placement($template, base.settings);
+ bindControls($template, base.settings,plugin);
+ },
+ buildGrowl = function(base) {
+
+ var $template = $(base.settings.template);
+
+ $template.addClass('alert-' + base.settings.type);
+ $template.attr('data-growl-position', base.settings.placement.from + '-' + base.settings.placement.align);
+
+ $template.find('[data-growl="dismiss"]').css('display', 'none');
+ if (base.settings.allow_dismiss) {
+ $template.find('[data-growl="dismiss"]').css('display', 'inline-block');
+ }
+
+ return $template;
+ },
+ addContent = function($template, settings) {
+
+ $template.find('[data-growl="dismiss"]').css({
+ 'position': 'absolute',
+ 'top': '5px',
+ 'right': '10px',
+ 'z-index': ((settings.z_index-1) >= 1 ? (settings.z_index-1) : 1)
+ });
+
+ if (settings.content.icon) {
+ if (settings.icon_type.toLowerCase() == 'class') {
+ $template.find('[data-growl="icon"]').addClass(settings.content.icon);
+ }else{
+ if ($template.find('[data-growl="icon"]').is('img')) {
+ $template.find('[data-growl="icon"]').attr('src', settings.content.icon);
+ }else{
+ $template.find('[data-growl="icon"]').append('<img src="'+settings.content.icon+'" />');
+ }
+ }
+ }
+
+ if (settings.content.title) {
+ $template.find('[data-growl="title"]').html(settings.content.title);
+ }
+
+ if (settings.content.message) {
+ $template.find('[data-growl="message"]').html(settings.content.message);
+ }
+
+ if (settings.content.url) {
+ $template.find('[data-growl="url"]').attr('href', settings.content.url).attr('target', settings.url_target);
+ $template.find('[data-growl="url"]').css({
+ 'position': 'absolute',
+ 'top': '0px',
+ 'left': '0px',
+ 'width': '100%',
+ 'height': '100%',
+ 'z-index': ((settings.z_index-2) >= 1 ? (settings.z_index-2) : 1)
+ });
+ }
+ },
+ placement = function($template, settings) {
+ var offsetAmt = settings.offset.y,
+ gCSS = {
+ 'position': (settings.element === 'body' ? 'fixed' : 'absolute'),
+ 'margin': 0,
+ 'z-index': settings.z_index,
+ 'display': 'inline-block'
+ },
+ hasAnimation = false;
+
+ $('[data-growl-position="' + settings.placement.from + '-' + settings.placement.align + '"]').each(function() {
+ return offsetAmt = Math.max(offsetAmt, parseInt($(this).css(settings.placement.from)) + $(this).outerHeight() + settings.spacing);
+ });
+
+ gCSS[settings.placement.from] = offsetAmt + "px";
+ $template.css(gCSS);
+
+ if (settings.onShow) {
+ settings.onShow(event);
+ }
+
+ $(settings.element).append($template);
+
+ switch (settings.placement.align) {
+ case 'center':
+ $template.css({
+ 'left': '50%',
+ 'marginLeft': -($template.outerWidth() / 2) + 'px'
+ });
+ break;
+ case 'left':
+ $template.css('left', settings.offset.x + 'px');
+ break;
+ case 'right':
+ $template.css('right', settings.offset.x + 'px');
+ break;
+ }
+ $template.addClass('growl-animated');
+
+ $template.one('webkitAnimationStart oanimationstart MSAnimationStart animationstart', function(event) {
+ hasAnimation = true;
+ });
+
+ $template.one('webkitAnimationEnd oanimationend MSAnimationEnd animationend', function(event) {
+ if (settings.onShown) {
+ settings.onShown(event);
+ }
+ });
+
+ setTimeout(function() {
+ if (!hasAnimation) {
+ if (settings.onShown) {
+ settings.onShown(event);
+ }
+ }
+ }, 600);
+ },
+ bindControls = function($template, settings, plugin) {
+ $template.addClass(settings.animate.enter);
+
+ $template.find('[data-growl="dismiss"]').on('click', function() {
+ plugin.close();
+ });
+
+ $template.on('mouseover', function(e) {
+ $template.addClass('hovering');
+ }).on('mouseout', function() {
+ $template.removeClass('hovering');
+ });
+
+ if (settings.delay >= 1) {
+ $template.data('growl-delay', settings.delay);
+ var timer = setInterval(function() {
+
+ var delay = parseInt($template.data('growl-delay')) - settings.timer;
+ if ((!$template.hasClass('hovering') && settings.mouse_over == 'pause') || settings.mouse_over != 'pause') {
+ $template.data('growl-delay', delay);
+ }
+
+ if (delay <= 0) {
+ clearInterval(timer);
+ plugin.close();
+ }
+ }, settings.timer);
+ }
+ };
+
+ // Avoid Plugin.prototype conflicts
+ Plugin.prototype = {
+ update: function(command, update) {
+ switch (command) {
+ case 'icon':
+ if (this.settings.icon_type.toLowerCase() == 'class') {
+ this.$template.find('[data-growl="icon"]').removeClass(this.settings.content.icon);
+ this.$template.find('[data-growl="icon"]').addClass(update);
+ }else{
+ if (this.$template.find('[data-growl="icon"]').is('img')) {
+ this.$template.find('[data-growl="icon"]')
+ }else{
+ this.$template.find('[data-growl="icon"]').find('img').attr().attr('src', update);
+ }
+ }
+ break;
+ case 'url':
+ this.$template.find('[data-growl="url"]').attr('href', update);
+ break;
+ case 'type':
+ this.$template.removeClass('alert-' + this.settings.type);
+ this.$template.addClass('alert-' + update);
+ break;
+ default:
+ this.$template.find('[data-growl="' + command +'"]').html(update);
+ }
+
+ return this;
+ },
+ close: function() {
+ var base = this.$template,
+ settings = this.settings,
+ posX = base.css(settings.placement.from),
+ hasAnimation = false;
+
+ if (settings.onHide) {
+ settings.onHide(event);
+ }
+
+ base.addClass(this.settings.animate.exit);
+
+ base.nextAll('[data-growl-position="' + this.settings.placement.from + '-' + this.settings.placement.align + '"]').each(function() {
+ $(this).css(settings.placement.from, posX);
+ posX = (parseInt(posX)+(settings.spacing)) + $(this).outerHeight();
+ });
+
+ base.one('webkitAnimationStart oanimationstart MSAnimationStart animationstart', function(event) {
+ hasAnimation = true;
+ });
+
+ base.one('webkitAnimationEnd oanimationend MSAnimationEnd animationend', function(event) {
+ $(this).remove();
+ if (settings.onHidden) {
+ settings.onHidden(event);
+ }
+ });
+
+ setTimeout(function() {
+ if (!hasAnimation) {
+ base.remove();
+ if (settings.onHidden) {
+ settings.onHidden(event);
+ }
+ }
+ }, 100);
+
+ return this;
+ }
+ };
+
+ // A really lightweight plugin wrapper around the constructor,
+ // preventing against multiple instantiations
+ $.growl = function ( content, options ) {
+ if (content == false && options.command == "closeAll") {
+ closeAll(options.position);
+ return false;
+ }else if (content == false) {
+ setDefaults(this, options);
+ return false;
+ }
+ var plugin = new Plugin( this, content, options );
+ return plugin;
+ };
+
+})( jQuery, window, document );
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/80bc388a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/errors/js/bootstrap-growl.min.js
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/errors/js/bootstrap-growl.min.js b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/errors/js/bootstrap-growl.min.js
new file mode 100644
index 0000000..ad059cc
--- /dev/null
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/errors/js/bootstrap-growl.min.js
@@ -0,0 +1,2 @@
+/* Project: Bootstrap Growl - v2.0.0 | Author: Mouse0270 aka Robert McIntosh | License: MIT License | Website: https://github.com/mouse0270/bootstrap-growl */
+(function(e,t,n,r){var i="growl",s="plugin_"+i,o={element:"body",type:"info",allow_dismiss:true,placement:{from:"top",align:"right"},offset:20,spacing:10,z_index:1031,delay:5e3,timer:1e3,url_target:"_blank",mouse_over:false,animate:{enter:"animated fadeInDown",exit:"animated fadeOutUp"},onShow:null,onShown:null,onHide:null,onHidden:null,icon_type:"class",template:'<div data-growl="container" class="alert" role="alert"><button type="button" class="close" data-growl="dismiss"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button><span data-growl="icon"></span><span data-growl="title"></span><span data-growl="message"></span><a href="#" data-growl="url"></a></div>'};var u=function(t,n){o=e.extend(true,{},o,n)},a=function(t){if(!t){e('[data-growl="container"]').find('[data-growl="dismiss"]').trigger("click")}else{e('[data-growl="container"][data-growl-position="'+t+'"]').find('[data-growl="dismiss"]').trigger("click")}},f=function(t,n,r){var n={content:{messa
ge:typeof n=="object"?n.message:n,title:n.title?n.title:null,icon:n.icon?n.icon:null,url:n.url?n.url:null}};r=e.extend(true,{},n,r);this.settings=e.extend(true,{},o,r);plugin=this;l(r,this.settings,plugin);this.$template=$template},l=function(t,n,r){var i={settings:n,$element:e(n.element),template:n.template};if(typeof n.offset=="number"){n.offset={x:n.offset,y:n.offset}}$template=c(i);h($template,i.settings);p($template,i.settings);d($template,i.settings,r)},c=function(t){var n=e(t.settings.template);n.addClass("alert-"+t.settings.type);n.attr("data-growl-position",t.settings.placement.from+"-"+t.settings.placement.align);n.find('[data-growl="dismiss"]').css("display","none");if(t.settings.allow_dismiss){n.find('[data-growl="dismiss"]').css("display","inline-block")}return n},h=function(e,t){e.find('[data-growl="dismiss"]').css({position:"absolute",top:"5px",right:"10px","z-index":t.z_index-1>=1?t.z_index-1:1});if(t.content.icon){if(t.icon_type.toLowerCase()=="class"){e.find('[data
-growl="icon"]').addClass(t.content.icon)}else{if(e.find('[data-growl="icon"]').is("img")){e.find('[data-growl="icon"]').attr("src",t.content.icon)}else{e.find('[data-growl="icon"]').append('<img src="'+t.content.icon+'" />')}}}if(t.content.title){e.find('[data-growl="title"]').html(t.content.title)}if(t.content.message){e.find('[data-growl="message"]').html(t.content.message)}if(t.content.url){e.find('[data-growl="url"]').attr("href",t.content.url).attr("target",t.url_target);e.find('[data-growl="url"]').css({position:"absolute",top:"0px",left:"0px",width:"100%",height:"100%","z-index":t.z_index-2>=1?t.z_index-2:1})}},p=function(t,n){var r=n.offset.y,i={position:n.element==="body"?"fixed":"absolute",margin:0,"z-index":n.z_index,display:"inline-block"},s=false;e('[data-growl-position="'+n.placement.from+"-"+n.placement.align+'"]').each(function(){return r=Math.max(r,parseInt(e(this).css(n.placement.from))+e(this).outerHeight()+n.spacing)});i[n.placement.from]=r+"px";t.css(i);if(n.on
Show){n.onShow(event)}e(n.element).append(t);switch(n.placement.align){case"center":t.css({left:"50%",marginLeft:-(t.outerWidth()/2)+"px"});break;case"left":t.css("left",n.offset.x+"px");break;case"right":t.css("right",n.offset.x+"px");break}t.addClass("growl-animated");t.one("webkitAnimationStart oanimationstart MSAnimationStart animationstart",function(e){s=true});t.one("webkitAnimationEnd oanimationend MSAnimationEnd animationend",function(e){if(n.onShown){n.onShown(e)}});setTimeout(function(){if(!s){if(n.onShown){n.onShown(event)}}},600)},d=function(e,t,n){e.addClass(t.animate.enter);e.find('[data-growl="dismiss"]').on("click",function(){n.close()});e.on("mouseover",function(t){e.addClass("hovering")}).on("mouseout",function(){e.removeClass("hovering")});if(t.delay>=1){e.data("growl-delay",t.delay);var r=setInterval(function(){var i=parseInt(e.data("growl-delay"))-t.timer;if(!e.hasClass("hovering")&&t.mouse_over=="pause"||t.mouse_over!="pause"){e.data("growl-delay",i)}if(i<=0){c
learInterval(r);n.close()}},t.timer)}};f.prototype={update:function(e,t){switch(e){case"icon":if(this.settings.icon_type.toLowerCase()=="class"){this.$template.find('[data-growl="icon"]').removeClass(this.settings.content.icon);this.$template.find('[data-growl="icon"]').addClass(t)}else{if(this.$template.find('[data-growl="icon"]').is("img")){this.$template.find('[data-growl="icon"]')}else{this.$template.find('[data-growl="icon"]').find("img").attr().attr("src",t)}}break;case"url":this.$template.find('[data-growl="url"]').attr("href",t);break;case"type":this.$template.removeClass("alert-"+this.settings.type);this.$template.addClass("alert-"+t);break;default:this.$template.find('[data-growl="'+e+'"]').html(t)}return this},close:function(){var t=this.$template,n=this.settings,r=t.css(n.placement.from),i=false;if(n.onHide){n.onHide(event)}t.addClass(this.settings.animate.exit);t.nextAll('[data-growl-position="'+this.settings.placement.from+"-"+this.settings.placement.align+'"]').each(f
unction(){e(this).css(n.placement.from,r);r=parseInt(r)+n.spacing+e(this).outerHeight()});t.one("webkitAnimationStart oanimationstart MSAnimationStart animationstart",function(e){i=true});t.one("webkitAnimationEnd oanimationend MSAnimationEnd animationend",function(t){e(this).remove();if(n.onHidden){n.onHidden(t)}});setTimeout(function(){if(!i){t.remove();if(n.onHidden){n.onHidden(event)}}},100);return this}};e.growl=function(e,t){if(e==false&&t.command=="closeAll"){a(t.position);return false}else if(e==false){u(this,t);return false}var n=new f(this,e,t);return n}})(jQuery,window,document)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/80bc388a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.html
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.html b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.html
index 33195c4..0f5bc83 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.html
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.html
@@ -28,9 +28,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
<title wicket:id="pageTitle"></title>
<wicket:header-items/>
- <wicket:link>
- <link href="jquery.jgrowl.css" rel="stylesheet" type="text/css"/>
- </wicket:link>
</head>
<body>
<div id="container" class="page container-fluid">
http://git-wip-us.apache.org/repos/asf/isis/blob/80bc388a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.java
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.java b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.java
index 05cfc64..93a352d 100644
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.java
+++ b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/PageAbstract.java
@@ -31,7 +31,6 @@ import de.agilecoders.wicket.extensions.markup.html.bootstrap.icon.FontAwesomeCs
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import com.google.common.base.Strings;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import org.apache.wicket.MarkupContainer;
@@ -44,7 +43,6 @@ import org.apache.wicket.markup.head.CssReferenceHeaderItem;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
import org.apache.wicket.markup.head.JavaScriptReferenceHeaderItem;
-import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
import org.apache.wicket.markup.head.PriorityHeaderItem;
import org.apache.wicket.markup.head.filter.HeaderResponseContainer;
import org.apache.wicket.markup.html.WebMarkupContainer;
@@ -84,7 +82,7 @@ import org.apache.isis.viewer.wicket.ui.components.actionprompt.ActionPromptModa
import org.apache.isis.viewer.wicket.ui.components.widgets.breadcrumbs.BreadcrumbPanel;
import org.apache.isis.viewer.wicket.ui.components.widgets.themepicker.ThemePicker;
import org.apache.isis.viewer.wicket.ui.errors.ExceptionModel;
-import org.apache.isis.viewer.wicket.ui.errors.JGrowlUtil;
+import org.apache.isis.viewer.wicket.ui.errors.JGrowlBehaviour;
import org.apache.isis.viewer.wicket.ui.overlays.Overlays;
import org.apache.isis.viewer.wicket.ui.pages.about.AboutPage;
import org.apache.isis.viewer.wicket.ui.panels.PanelUtil;
@@ -99,7 +97,6 @@ public abstract class PageAbstract extends WebPage implements ActionPromptProvid
private static final long serialVersionUID = 1L;
- private static final JavaScriptResourceReference JQUERY_JGROWL_JS = new JavaScriptResourceReference(PageAbstract.class, "jquery.jgrowl.js");
private static final String REGULAR_CASE_KEY = "isis.viewer.wicket.regularCase";
/**
@@ -264,17 +261,12 @@ public abstract class PageAbstract extends WebPage implements ActionPromptProvid
response.render(CssHeaderItem.forReference(FontAwesomeCssReference.instance()));
response.render(CssHeaderItem.forReference(new CssResourceReference(PageAbstract.class, "bootstrap-overrides.css")));
- response.render(JavaScriptReferenceHeaderItem.forReference(JQUERY_JGROWL_JS));
response.render(JavaScriptReferenceHeaderItem.forReference(JQUERY_LIVEQUERY_JS));
response.render(JavaScriptReferenceHeaderItem.forReference(JQUERY_ISIS_WICKET_VIEWER_JS));
-
- final String feedbackMsg = JGrowlUtil.asJGrowlCalls(getMessageBroker());
- if (!Strings.isNullOrEmpty(feedbackMsg)) {
- final OnDomReadyHeaderItem forScript = OnDomReadyHeaderItem.forScript(feedbackMsg);
- response.render(forScript);
- }
-
-
+
+ JGrowlBehaviour jGrowlBehaviour = new JGrowlBehaviour();
+ jGrowlBehaviour.renderFeedbackMessages(response);
+
// overlays
if(getConfiguration().getBoolean(REGULAR_CASE_KEY, false)) {
response.render(CssReferenceHeaderItem.forReference(PanelUtil.cssResourceReferenceFor(Overlays.class, "regular-case")));
http://git-wip-us.apache.org/repos/asf/isis/blob/80bc388a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/jquery.jgrowl.css
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/jquery.jgrowl.css b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/jquery.jgrowl.css
deleted file mode 100644
index b603356..0000000
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/jquery.jgrowl.css
+++ /dev/null
@@ -1,253 +0,0 @@
-/**
- * jGrowl 1.2.10
- *
- * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
- * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
- *
- * Written by Stan Lemon <st...@gmail.com>
- * Last updated: 2013.02.14
- *
- * jGrowl is a jQuery plugin implementing unobtrusive userland notifications. These
- * notifications function similarly to the Growl Framework available for
- * Mac OS X (http://growl.info).
- *
- * To Do:
- * - Move library settings to containers and allow them to be changed per container
- *
- * Changes in 1.2.10
- * - Fix beforeClose to be called in click event
- *
- * Changes in 1.2.9
- * - Fixed BC break in jQuery 2.0 beta
- *
- * Changes in 1.2.8
- * - Fixes for jQuery 1.9 and the MSIE6 check, note that with jQuery 2.0 support
- * jGrowl intends to drop support for IE6 altogether
- *
- * Changes in 1.2.6
- * - Fixed js error when a notification is opening and closing at the same time
- *
- * Changes in 1.2.5
- * - Changed wrapper jGrowl's options usage to "o" instead of $.jGrowl.defaults
- * - Added themeState option to control 'highlight' or 'error' for jQuery UI
- * - Ammended some CSS to provide default positioning for nested usage.
- * - Changed some CSS to be prefixed with jGrowl- to prevent namespacing issues
- * - Added two new options - openDuration and closeDuration to allow
- * better control of notification open and close speeds, respectively
- * Patch contributed by Jesse Vincet.
- * - Added afterOpen callback. Patch contributed by Russel Branca.
- *
- * Changes in 1.2.4
- * - Fixed IE bug with the close-all button
- * - Fixed IE bug with the filter CSS attribute (special thanks to gotwic)
- * - Update IE opacity CSS
- * - Changed font sizes to use "em", and only set the base style
- *
- * Changes in 1.2.3
- * - The callbacks no longer use the container as context, instead they use the actual notification
- * - The callbacks now receive the container as a parameter after the options parameter
- * - beforeOpen and beforeClose now check the return value, if it's false - the notification does
- * not continue. The open callback will also halt execution if it returns false.
- * - Fixed bug where containers would get confused
- * - Expanded the pause functionality to pause an entire container.
- *
- * Changes in 1.2.2
- * - Notification can now be theme rolled for jQuery UI, special thanks to Jeff Chan!
- *
- * Changes in 1.2.1
- * - Fixed instance where the interval would fire the close method multiple times.
- * - Added CSS to hide from print media
- * - Fixed issue with closer button when div { position: relative } is set
- * - Fixed leaking issue with multiple containers. Special thanks to Matthew Hanlon!
- *
- * Changes in 1.2.0
- * - Added message pooling to limit the number of messages appearing at a given time.
- * - Closing a notification is now bound to the notification object and triggered by the close button.
- *
- * Changes in 1.1.2
- * - Added iPhone styled example
- * - Fixed possible IE7 bug when determining if the ie6 class shoudl be applied.
- * - Added template for the close button, so that it's content could be customized.
- *
- * Changes in 1.1.1
- * - Fixed CSS styling bug for ie6 caused by a mispelling
- * - Changes height restriction on default notifications to min-height
- * - Added skinned examples using a variety of images
- * - Added the ability to customize the content of the [close all] box
- * - Added jTweet, an example of using jGrowl + Twitter
- *
- * Changes in 1.1.0
- * - Multiple container and instances.
- * - Standard $.jGrowl() now wraps $.fn.jGrowl() by first establishing a generic jGrowl container.
- * - Instance methods of a jGrowl container can be called by $.fn.jGrowl(methodName)
- * - Added glue preferenced, which allows notifications to be inserted before or after nodes in the container
- * - Added new log callback which is called before anything is done for the notification
- * - Corner's attribute are now applied on an individual notification basis.
- *
- * Changes in 1.0.4
- * - Various CSS fixes so that jGrowl renders correctly in IE6.
- *
- * Changes in 1.0.3
- * - Fixed bug with options persisting across notifications
- * - Fixed theme application bug
- * - Simplified some selectors and manipulations.
- * - Added beforeOpen and beforeClose callbacks
- * - Reorganized some lines of code to be more readable
- * - Removed unnecessary this.defaults context
- * - If corners plugin is present, it's now customizable.
- * - Customizable open animation.
- * - Customizable close animation.
- * - Customizable animation easing.
- * - Added customizable positioning (top-left, top-right, bottom-left, bottom-right, center)
- *
- * Changes in 1.0.2
- * - All CSS styling is now external.
- * - Added a theme parameter which specifies a secondary class for styling, such
- * that notifications can be customized in appearance on a per message basis.
- * - Notification life span is now customizable on a per message basis.
- * - Added the ability to disable the global closer, enabled by default.
- * - Added callbacks for when a notification is opened or closed.
- * - Added callback for the global closer.
- * - Customizable animation speed.
- * - jGrowl now set itself up and tears itself down.
- *
- * Changes in 1.0.1:
- * - Removed dependency on metadata plugin in favor of .data()
- * - Namespaced all events
- */
-
-div.jGrowl {
- z-index: 9999;
- color: #fff;
- font-size: 12px;
-}
-
-/** Special IE6 Style Positioning **/
-div.ie6 {
- position: absolute;
-}
-
-div.ie6.top-right {
- right: auto;
- bottom: auto;
- left: expression( ( 0 - jGrowl.offsetWidth + ( document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth ) + ( ignoreMe2 = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ) ) + 'px' );
- top: expression( ( 0 + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) ) + 'px' );
-}
-
-div.ie6.top-left {
- left: expression( ( 0 + ( ignoreMe2 = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ) ) + 'px' );
- top: expression( ( 0 + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) ) + 'px' );
-}
-
-div.ie6.bottom-right {
- left: expression( ( 0 - jGrowl.offsetWidth + ( document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth ) + ( ignoreMe2 = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ) ) + 'px' );
- top: expression( ( 0 - jGrowl.offsetHeight + ( document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) ) + 'px' );
-}
-
-div.ie6.bottom-left {
- left: expression( ( 0 + ( ignoreMe2 = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ) ) + 'px' );
- top: expression( ( 0 - jGrowl.offsetHeight + ( document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) ) + 'px' );
-}
-
-div.ie6.center {
- left: expression( ( 0 + ( ignoreMe2 = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ) ) + 'px' );
- top: expression( ( 0 + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) ) + 'px' );
- width: 100%;
-}
-
-/** Normal Style Positions **/
-div.jGrowl {
- position: absolute;
-}
-
-body > div.jGrowl {
- position: fixed;
-}
-
-div.jGrowl.top-left {
- left: 0px;
- top: 0px;
-}
-
-div.jGrowl.top-right {
- right: 0px;
- top: 0px;
-}
-
-div.jGrowl.bottom-left {
- left: 0px;
- bottom: 0px;
-}
-
-div.jGrowl.bottom-right {
- right: 0px;
- bottom: 0px;
-}
-
-div.jGrowl.center {
- top: 0px;
- width: 50%;
- left: 25%;
-}
-
-/** Cross Browser Styling **/
-div.center div.jGrowl-notification, div.center div.jGrowl-closer {
- margin-left: auto;
- margin-right: auto;
-}
-
-div.jGrowl div.jGrowl-notification, div.jGrowl div.jGrowl-closer {
- background-color: #000;
- opacity: .85;
- -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=85)";
- filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=85);
- zoom: 1;
- width: 235px;
- padding: 10px;
- margin-top: 5px;
- margin-bottom: 5px;
- font-family: Tahoma, Arial, Helvetica, sans-serif;
- font-size: 1em;
- text-align: left;
- display: none;
- -moz-border-radius: 5px;
- -webkit-border-radius: 5px;
-}
-
-div.jGrowl div.jGrowl-notification {
- min-height: 40px;
-}
-
-div.jGrowl div.jGrowl-notification,
-div.jGrowl div.jGrowl-closer {
- margin: 10px;
-}
-
-div.jGrowl div.jGrowl-notification div.jGrowl-header {
- font-weight: bold;
- font-size: .85em;
-}
-
-div.jGrowl div.jGrowl-notification div.jGrowl-close {
- z-index: 99;
- float: right;
- font-weight: bold;
- font-size: 1em;
- cursor: pointer;
-}
-
-div.jGrowl div.jGrowl-closer {
- padding-top: 4px;
- padding-bottom: 4px;
- cursor: pointer;
- font-size: .9em;
- font-weight: bold;
- text-align: center;
-}
-
-/** Hide jGrowl when printing **/
-@media print {
- div.jGrowl {
- display: none;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/80bc388a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/jquery.jgrowl.js
----------------------------------------------------------------------
diff --git a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/jquery.jgrowl.js b/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/jquery.jgrowl.js
deleted file mode 100644
index cd15d4a..0000000
--- a/component/viewer/wicket/ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/jquery.jgrowl.js
+++ /dev/null
@@ -1,352 +0,0 @@
-/**
- * jGrowl 1.2.10
- *
- * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
- * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
- *
- * Written by Stan Lemon <st...@gmail.com>
- * Last updated: 2013.02.14
- *
- * jGrowl is a jQuery plugin implementing unobtrusive userland notifications. These
- * notifications function similarly to the Growl Framework available for
- * Mac OS X (http://growl.info).
- *
- * To Do:
- * - Move library settings to containers and allow them to be changed per container
- *
- * Changes in 1.2.10
- * - Fix beforeClose to be called in click event
- *
- * Changes in 1.2.9
- * - Fixed BC break in jQuery 2.0 beta
- *
- * Changes in 1.2.8
- * - Fixes for jQuery 1.9 and the MSIE6 check, note that with jQuery 2.0 support
- * jGrowl intends to drop support for IE6 altogether
- *
- * Changes in 1.2.6
- * - Fixed js error when a notification is opening and closing at the same time
- *
- * Changes in 1.2.5
- * - Changed wrapper jGrowl's options usage to "o" instead of $.jGrowl.defaults
- * - Added themeState option to control 'highlight' or 'error' for jQuery UI
- * - Ammended some CSS to provide default positioning for nested usage.
- * - Changed some CSS to be prefixed with jGrowl- to prevent namespacing issues
- * - Added two new options - openDuration and closeDuration to allow
- * better control of notification open and close speeds, respectively
- * Patch contributed by Jesse Vincet.
- * - Added afterOpen callback. Patch contributed by Russel Branca.
- *
- * Changes in 1.2.4
- * - Fixed IE bug with the close-all button
- * - Fixed IE bug with the filter CSS attribute (special thanks to gotwic)
- * - Update IE opacity CSS
- * - Changed font sizes to use "em", and only set the base style
- *
- * Changes in 1.2.3
- * - The callbacks no longer use the container as context, instead they use the actual notification
- * - The callbacks now receive the container as a parameter after the options parameter
- * - beforeOpen and beforeClose now check the return value, if it's false - the notification does
- * not continue. The open callback will also halt execution if it returns false.
- * - Fixed bug where containers would get confused
- * - Expanded the pause functionality to pause an entire container.
- *
- * Changes in 1.2.2
- * - Notification can now be theme rolled for jQuery UI, special thanks to Jeff Chan!
- *
- * Changes in 1.2.1
- * - Fixed instance where the interval would fire the close method multiple times.
- * - Added CSS to hide from print media
- * - Fixed issue with closer button when div { position: relative } is set
- * - Fixed leaking issue with multiple containers. Special thanks to Matthew Hanlon!
- *
- * Changes in 1.2.0
- * - Added message pooling to limit the number of messages appearing at a given time.
- * - Closing a notification is now bound to the notification object and triggered by the close button.
- *
- * Changes in 1.1.2
- * - Added iPhone styled example
- * - Fixed possible IE7 bug when determining if the ie6 class shoudl be applied.
- * - Added template for the close button, so that it's content could be customized.
- *
- * Changes in 1.1.1
- * - Fixed CSS styling bug for ie6 caused by a mispelling
- * - Changes height restriction on default notifications to min-height
- * - Added skinned examples using a variety of images
- * - Added the ability to customize the content of the [close all] box
- * - Added jTweet, an example of using jGrowl + Twitter
- *
- * Changes in 1.1.0
- * - Multiple container and instances.
- * - Standard $.jGrowl() now wraps $.fn.jGrowl() by first establishing a generic jGrowl container.
- * - Instance methods of a jGrowl container can be called by $.fn.jGrowl(methodName)
- * - Added glue preferenced, which allows notifications to be inserted before or after nodes in the container
- * - Added new log callback which is called before anything is done for the notification
- * - Corner's attribute are now applied on an individual notification basis.
- *
- * Changes in 1.0.4
- * - Various CSS fixes so that jGrowl renders correctly in IE6.
- *
- * Changes in 1.0.3
- * - Fixed bug with options persisting across notifications
- * - Fixed theme application bug
- * - Simplified some selectors and manipulations.
- * - Added beforeOpen and beforeClose callbacks
- * - Reorganized some lines of code to be more readable
- * - Removed unnecessary this.defaults context
- * - If corners plugin is present, it's now customizable.
- * - Customizable open animation.
- * - Customizable close animation.
- * - Customizable animation easing.
- * - Added customizable positioning (top-left, top-right, bottom-left, bottom-right, center)
- *
- * Changes in 1.0.2
- * - All CSS styling is now external.
- * - Added a theme parameter which specifies a secondary class for styling, such
- * that notifications can be customized in appearance on a per message basis.
- * - Notification life span is now customizable on a per message basis.
- * - Added the ability to disable the global closer, enabled by default.
- * - Added callbacks for when a notification is opened or closed.
- * - Added callback for the global closer.
- * - Customizable animation speed.
- * - jGrowl now set itself up and tears itself down.
- *
- * Changes in 1.0.1:
- * - Removed dependency on metadata plugin in favor of .data()
- * - Namespaced all events
- */
-(function($) {
- /** Compatibility holdover for 1.9 to check IE6 **/
- var $ie6 = (function(){
- return false === $.support.boxModel && $.support.objectAll && $support.leadingWhitespace;
- })();
-
- /** jGrowl Wrapper - Establish a base jGrowl Container for compatibility with older releases. **/
- $.jGrowl = function( m , o ) {
- // To maintain compatibility with older version that only supported one instance we'll create the base container.
- if ( $('#jGrowl').size() == 0 )
- $('<div id="jGrowl"></div>').addClass( (o && o.position) ? o.position : $.jGrowl.defaults.position ).appendTo('body');
-
- // Create a notification on the container.
- $('#jGrowl').jGrowl(m,o);
- };
-
-
- /** Raise jGrowl Notification on a jGrowl Container **/
- $.fn.jGrowl = function( m , o ) {
- if ( $.isFunction(this.each) ) {
- var args = arguments;
-
- return this.each(function() {
- var self = this;
-
- /** Create a jGrowl Instance on the Container if it does not exist **/
- if ( $(this).data('jGrowl.instance') == undefined ) {
- $(this).data('jGrowl.instance', $.extend( new $.fn.jGrowl(), { notifications: [], element: null, interval: null } ));
- $(this).data('jGrowl.instance').startup( this );
- }
-
- /** Optionally call jGrowl instance methods, or just raise a normal notification **/
- if ( $.isFunction($(this).data('jGrowl.instance')[m]) ) {
- $(this).data('jGrowl.instance')[m].apply( $(this).data('jGrowl.instance') , $.makeArray(args).slice(1) );
- } else {
- $(this).data('jGrowl.instance').create( m , o );
- }
- });
- };
- };
-
- $.extend( $.fn.jGrowl.prototype , {
-
- /** Default JGrowl Settings **/
- defaults: {
- pool: 0,
- header: '',
- group: '',
- sticky: false,
- position: 'top-right',
- glue: 'after',
- theme: 'default',
- themeState: 'highlight',
- corners: '10px',
- check: 250,
- life: 3000,
- closeDuration: 'normal',
- openDuration: 'normal',
- easing: 'swing',
- closer: true,
- closeTemplate: '×',
- closerTemplate: '<div>[ close all ]</div>',
- log: function(e,m,o) {},
- beforeOpen: function(e,m,o) {},
- afterOpen: function(e,m,o) {},
- open: function(e,m,o) {},
- beforeClose: function(e,m,o) {},
- close: function(e,m,o) {},
- animateOpen: {
- opacity: 'show'
- },
- animateClose: {
- opacity: 'hide'
- }
- },
-
- notifications: [],
-
- /** jGrowl Container Node **/
- element: null,
-
- /** Interval Function **/
- interval: null,
-
- /** Create a Notification **/
- create: function( message , o ) {
- var o = $.extend({}, this.defaults, o);
-
- /* To keep backward compatibility with 1.24 and earlier, honor 'speed' if the user has set it */
- if (typeof o.speed !== 'undefined') {
- o.openDuration = o.speed;
- o.closeDuration = o.speed;
- }
-
- this.notifications.push({ message: message , options: o });
-
- o.log.apply( this.element , [this.element,message,o] );
- },
-
- render: function( notification ) {
- var self = this;
- var message = notification.message;
- var o = notification.options;
-
- // Support for jQuery theme-states, if this is not used it displays a widget header
- o.themeState = (o.themeState == '') ? '' : 'ui-state-' + o.themeState;
-
- var notification = $('<div/>')
- .addClass('jGrowl-notification ' + o.themeState + ' ui-corner-all' + ((o.group != undefined && o.group != '') ? ' ' + o.group : ''))
- .append($('<div/>').addClass('jGrowl-close').html(o.closeTemplate))
- .append($('<div/>').addClass('jGrowl-header').html(o.header))
- .append($('<div/>').addClass('jGrowl-message').html(message))
- .data("jGrowl", o).addClass(o.theme).children('div.jGrowl-close').bind("click.jGrowl", function() {
- $(this).parent().trigger('jGrowl.beforeClose');
- })
- .parent();
-
-
- /** Notification Actions **/
- $(notification).bind("mouseover.jGrowl", function() {
- $('div.jGrowl-notification', self.element).data("jGrowl.pause", true);
- }).bind("mouseout.jGrowl", function() {
- $('div.jGrowl-notification', self.element).data("jGrowl.pause", false);
- }).bind('jGrowl.beforeOpen', function() {
- if ( o.beforeOpen.apply( notification , [notification,message,o,self.element] ) != false ) {
- $(this).trigger('jGrowl.open');
- }
- }).bind('jGrowl.open', function() {
- if ( o.open.apply( notification , [notification,message,o,self.element] ) != false ) {
- if ( o.glue == 'after' ) {
- $('div.jGrowl-notification:last', self.element).after(notification);
- } else {
- $('div.jGrowl-notification:first', self.element).before(notification);
- }
-
- $(this).animate(o.animateOpen, o.openDuration, o.easing, function() {
- // Fixes some anti-aliasing issues with IE filters.
- if ($.support.opacity === false)
- this.style.removeAttribute('filter');
-
- if ( $(this).data("jGrowl") != null ) // Happens when a notification is closing before it's open.
- $(this).data("jGrowl").created = new Date();
-
- $(this).trigger('jGrowl.afterOpen');
- });
- }
- }).bind('jGrowl.afterOpen', function() {
- o.afterOpen.apply( notification , [notification,message,o,self.element] );
- }).bind('jGrowl.beforeClose', function() {
- if ( o.beforeClose.apply( notification , [notification,message,o,self.element] ) != false )
- $(this).trigger('jGrowl.close');
- }).bind('jGrowl.close', function() {
- // Pause the notification, lest during the course of animation another close event gets called.
- $(this).data('jGrowl.pause', true);
- $(this).animate(o.animateClose, o.closeDuration, o.easing, function() {
- if ( $.isFunction(o.close) ) {
- if ( o.close.apply( notification , [notification,message,o,self.element] ) !== false )
- $(this).remove();
- } else {
- $(this).remove();
- }
- });
- }).trigger('jGrowl.beforeOpen');
-
- /** Optional Corners Plugin **/
- if ( o.corners != '' && $.fn.corner != undefined ) $(notification).corner( o.corners );
-
- /** Add a Global Closer if more than one notification exists **/
- if ( $('div.jGrowl-notification:parent', self.element).size() > 1 &&
- $('div.jGrowl-closer', self.element).size() == 0 && this.defaults.closer != false ) {
- $(this.defaults.closerTemplate).addClass('jGrowl-closer ' + this.defaults.themeState + ' ui-corner-all').addClass(this.defaults.theme)
- .appendTo(self.element).animate(this.defaults.animateOpen, this.defaults.speed, this.defaults.easing)
- .bind("click.jGrowl", function() {
- $(this).siblings().trigger("jGrowl.beforeClose");
-
- if ( $.isFunction( self.defaults.closer ) ) {
- self.defaults.closer.apply( $(this).parent()[0] , [$(this).parent()[0]] );
- }
- });
- };
- },
-
- /** Update the jGrowl Container, removing old jGrowl notifications **/
- update: function() {
- $(this.element).find('div.jGrowl-notification:parent').each( function() {
- if ( $(this).data("jGrowl") != undefined && $(this).data("jGrowl").created != undefined &&
- ($(this).data("jGrowl").created.getTime() + parseInt($(this).data("jGrowl").life)) < (new Date()).getTime() &&
- $(this).data("jGrowl").sticky != true &&
- ($(this).data("jGrowl.pause") == undefined || $(this).data("jGrowl.pause") != true) ) {
-
- // Pause the notification, lest during the course of animation another close event gets called.
- $(this).trigger('jGrowl.beforeClose');
- }
- });
-
- if ( this.notifications.length > 0 &&
- (this.defaults.pool == 0 || $(this.element).find('div.jGrowl-notification:parent').size() < this.defaults.pool) )
- this.render( this.notifications.shift() );
-
- if ( $(this.element).find('div.jGrowl-notification:parent').size() < 2 ) {
- $(this.element).find('div.jGrowl-closer').animate(this.defaults.animateClose, this.defaults.speed, this.defaults.easing, function() {
- $(this).remove();
- });
- }
- },
-
- /** Setup the jGrowl Notification Container **/
- startup: function(e) {
- this.element = $(e).addClass('jGrowl').append('<div class="jGrowl-notification"></div>');
- this.interval = setInterval( function() {
- $(e).data('jGrowl.instance').update();
- }, parseInt(this.defaults.check));
-
- if ($ie6) {
- $(this.element).addClass('ie6');
- }
- },
-
- /** Shutdown jGrowl, removing it and clearing the interval **/
- shutdown: function() {
- $(this.element).removeClass('jGrowl').find('div.jGrowl-notification').remove();
- clearInterval( this.interval );
- },
-
- close: function() {
- $(this.element).find('div.jGrowl-notification').each(function(){
- $(this).trigger('jGrowl.beforeClose');
- });
- }
- });
-
- /** Reference the Defaults Object for compatibility with older versions of jGrowl **/
- $.jGrowl.defaults = $.fn.jGrowl.prototype.defaults;
-
-})(jQuery);