diff --git a/src/main/config/component/notify.xml b/src/main/config/component/notify.xml
index 2d8bb21..e448e1b 100644
--- a/src/main/config/component/notify.xml
+++ b/src/main/config/component/notify.xml
@@ -13,7 +13,7 @@
org.richfaces.component.UINotify
+ ]]>
org.richfaces.NotifyRenderer
@@ -31,7 +31,7 @@
org.ajax4jsf.tests.AbstractJspTestCase
-->
-
+
&ui_component_attributes;
&ajax_output_attributes;
@@ -50,8 +50,8 @@
""
-
-
+
+
styleClass
java.lang.String
diff --git a/src/main/config/component/notifyMessages.xml b/src/main/config/component/notifyMessages.xml
index 753d61d..be9ec0e 100644
--- a/src/main/config/component/notifyMessages.xml
+++ b/src/main/config/component/notifyMessages.xml
@@ -13,7 +13,7 @@
org.richfaces.component.UINotifyMessages
+ ]]>
org.richfaces.NotifyMessagesRenderer
@@ -31,7 +31,7 @@
org.ajax4jsf.tests.AbstractJspTestCase
-->
-
+
&ui_component_attributes;
&ajax_output_attributes;
diff --git a/src/main/config/component/notifyStack.xml b/src/main/config/component/notifyStack.xml
index 88c8ffa..f462ab0 100644
--- a/src/main/config/component/notifyStack.xml
+++ b/src/main/config/component/notifyStack.xml
@@ -1,5 +1,6 @@
-
+
org.richfaces.NotifyStack
@@ -8,7 +9,7 @@
org.richfaces.component.UINotifyStack
+ ]]>
org.richfaces.NotifyStackRenderer
@@ -26,7 +27,7 @@
org.ajax4jsf.tests.AbstractJspTestCase
-->
-
+
&ui_component_attributes;
diff --git a/src/main/java/org/richfaces/component/NotifyAttributes.java b/src/main/java/org/richfaces/component/NotifyAttributes.java
index e2e5c0b..f1dcc20 100644
--- a/src/main/java/org/richfaces/component/NotifyAttributes.java
+++ b/src/main/java/org/richfaces/component/NotifyAttributes.java
@@ -1,56 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
package org.richfaces.component;
+import org.richfaces.cdk.annotations.Attribute;
+
public interface NotifyAttributes {
- public abstract boolean isSticky();
+ @Attribute
+ boolean isSticky();
- public abstract void setSticky(boolean sticky);
+ void setSticky(boolean sticky);
- public abstract Integer getStayTime();
+ @Attribute
+ Integer getStayTime();
- public abstract void setStayTime(Integer time);
+ void setStayTime(Integer time);
- public abstract Integer getDelay();
+ @Attribute
+ Integer getDelay();
- public abstract void setDelay(Integer delay);
+ void setDelay(Integer delay);
- public abstract String getStyleClass();
+ @Attribute
+ String getStyleClass();
- public abstract void setStyleClass(String styleClass);
+ void setStyleClass(String styleClass);
- public abstract String getAppearAnimation();
+ @Attribute
+ String getAppearAnimation();
- public abstract void setAppearAnimation(String appearAnimation);
+ void setAppearAnimation(String appearAnimation);
- public abstract String getHideAnimation();
+ @Attribute
+ String getHideAnimation();
- public abstract void setHideAnimation(String hideAnimation);
+ void setHideAnimation(String hideAnimation);
- public abstract Integer getAnimationSpeed();
+ @Attribute
+ Integer getAnimationSpeed();
- public abstract void setAnimationSpeed(Integer animationSpeed);
+ void setAnimationSpeed(Integer animationSpeed);
- public abstract boolean isShowHistory();
+ @Attribute
+ boolean isShowHistory();
- public abstract void setShowHistory(boolean showHistory);
+ void setShowHistory(boolean showHistory);
- public abstract boolean isNonblocking();
+ @Attribute
+ boolean isNonblocking();
- public abstract void setNonblocking(boolean nonblocking);
+ void setNonblocking(boolean nonblocking);
- public abstract boolean isShowShadow();
+ @Attribute
+ boolean isShowShadow();
- public abstract void setShowShadow(boolean showShadow);
+ void setShowShadow(boolean showShadow);
- public abstract boolean isShowCloseButton();
+ @Attribute(defaultValue = "true")
+ boolean isShowCloseButton();
- public abstract void setShowCloseButton(boolean showCloseButton);
+ void setShowCloseButton(boolean showCloseButton);
- public abstract Double getNonblockingOpacity();
+ @Attribute
+ Double getNonblockingOpacity();
- public abstract void setNonblockingOpacity(Double nonblockingOpacity);
+ void setNonblockingOpacity(Double nonblockingOpacity);
- public abstract String getStack();
+ @Attribute
+ String getStack();
- public abstract void setStack(String stack);
+ void setStack(String stack);
}
diff --git a/src/main/java/org/richfaces/component/UINotify.java b/src/main/java/org/richfaces/component/UINotify.java
index 3779dbc..906d859 100644
--- a/src/main/java/org/richfaces/component/UINotify.java
+++ b/src/main/java/org/richfaces/component/UINotify.java
@@ -7,6 +7,8 @@ public abstract class UINotify extends UIComponentBase implements NotifyAttribut
public static final String COMPONENT_TYPE = "org.richfaces.Notify";
public static final String COMPONENT_FAMILY = "org.richfaces.Notify";
+ public static final double DEFAULT_NONBLOCKING_OPACITY = .2;
+
public abstract String getTitle();
public abstract void setTitle(String title);
diff --git a/src/main/java/org/richfaces/component/UINotifyMessages.java b/src/main/java/org/richfaces/component/UINotifyMessages.java
index 8e3d448..50a052f 100644
--- a/src/main/java/org/richfaces/component/UINotifyMessages.java
+++ b/src/main/java/org/richfaces/component/UINotifyMessages.java
@@ -1,8 +1,9 @@
package org.richfaces.component;
-import javax.faces.component.UIMessages;
import org.ajax4jsf.component.AjaxOutput;
+import javax.faces.component.UIMessages;
+
public abstract class UINotifyMessages extends UIMessages implements AjaxOutput, NotifyAttributes {
public static final String COMPONENT_TYPE = "org.richfaces.NotifyMessages";
diff --git a/src/main/java/org/richfaces/renderkit/html/NotifyMessagesRenderer.java b/src/main/java/org/richfaces/renderkit/html/NotifyMessagesRenderer.java
index 9e3f50e..f9eb13b 100644
--- a/src/main/java/org/richfaces/renderkit/html/NotifyMessagesRenderer.java
+++ b/src/main/java/org/richfaces/renderkit/html/NotifyMessagesRenderer.java
@@ -1,14 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
package org.richfaces.renderkit.html;
+import org.ajax4jsf.renderkit.RendererUtils;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.richfaces.component.UINotify;
+import org.richfaces.component.UINotifyMessages;
+
+import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
import java.io.IOException;
import java.util.Iterator;
-import javax.faces.application.FacesMessage;
-import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
-import org.richfaces.component.UINotify;
-import org.richfaces.component.UINotifyMessages;
public class NotifyMessagesRenderer extends NotifyRenderer {
@@ -17,7 +41,7 @@ public class NotifyMessagesRenderer extends NotifyRenderer {
UINotifyMessages messagesComponent = (UINotifyMessages) component;
ResponseWriter writer = context.getResponseWriter();
writer.startElement(HTML.DIV_ELEM, null);
- writer.writeAttribute(HTML.id_ATTRIBUTE, getUtils().clientId(context, component), "type");
+ writer.writeAttribute(HTML.id_ATTRIBUTE, RendererUtils.getInstance().clientId(context, component), "type");
Integer delay = messagesComponent.getDelay();
if (delay == null) {
delay = 0;
@@ -27,10 +51,12 @@ public class NotifyMessagesRenderer extends NotifyRenderer {
interval = 0;
}
- Iterator messages = messagesComponent.isGlobalOnly() ? context.getMessages(null) : context.getMessages();
+ Iterator messages = messagesComponent.isGlobalOnly()
+ ? context.getMessages(null) : context.getMessages();
while (messages.hasNext()) {
FacesMessage msg = messages.next();
- UINotify notify = (UINotify) context.getApplication().createComponent(UINotify.COMPONENT_TYPE);
+ UINotify notify = (UINotify) context.getApplication()
+ .createComponent(UINotify.COMPONENT_TYPE);
notify.setAnimationSpeed(messagesComponent.getAnimationSpeed());
notify.setAppearAnimation(messagesComponent.getAppearAnimation());
notify.setDelay(delay);
@@ -50,7 +76,7 @@ public class NotifyMessagesRenderer extends NotifyRenderer {
notify.setText(msg.getDetail());
}
String styleClass = messagesComponent.getStyleClass();
- if(styleClass == null) {
+ if (styleClass == null) {
styleClass = "";
}
if (FacesMessage.SEVERITY_INFO.equals(msg.getSeverity())) {
diff --git a/src/main/java/org/richfaces/renderkit/html/NotifyRenderer.java b/src/main/java/org/richfaces/renderkit/html/NotifyRenderer.java
index 262ee39..27da309 100644
--- a/src/main/java/org/richfaces/renderkit/html/NotifyRenderer.java
+++ b/src/main/java/org/richfaces/renderkit/html/NotifyRenderer.java
@@ -1,10 +1,27 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
package org.richfaces.renderkit.html;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import java.io.IOException;
-import java.util.*;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
@@ -12,24 +29,37 @@ import org.ajax4jsf.resource.InternetResource;
import org.richfaces.component.UINotify;
import org.richfaces.component.UINotifyStack;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
public class NotifyRenderer extends HeaderResourcesRendererBase {
- private static final Map defaults = new HashMap();
+ private static final Map DEFAULTS;
- {
- defaults.put("pnotify_addclass", "");
- defaults.put("pnotify_nonblock", false);
- defaults.put("pnotify_nonblock_opacity", .2);
- defaults.put("pnotify_history", true);
- defaults.put("pnotify_animate_speed", "slow");
- defaults.put("pnotify_opacity", 1);
- defaults.put("pnotify_shadow", false);
- defaults.put("pnotify_closer", true);
- defaults.put("pnotify_hide", true);
- defaults.put("pnotify_delay", 8000);
+ static {
+ Map defaults = new HashMap();
+ defaults.put("styleClass", "");
+ defaults.put("nonblocking", false);
+ defaults.put("nonblockingOpacity", UINotify.DEFAULT_NONBLOCKING_OPACITY);
+ defaults.put("showHistory", true);
+ defaults.put("animationSpeed", "slow");
+ defaults.put("opacity", 1);
+ defaults.put("showShadow", false);
+ defaults.put("showCloseButton", true);
+ defaults.put("appearAnimation", "fade");
+ defaults.put("hideAnimation", "fade");
+ defaults.put("sticky", false);
+ defaults.put("stayTime", 8000);
defaults.put("delay", 0);
-
+ DEFAULTS = Collections.unmodifiableMap(defaults);
}
+
private final InternetResource[] scripts = {
getResource("/org/richfaces/renderkit/html/scripts/jquery-1.4.2.js"),
getResource("/org/richfaces/renderkit/html/scripts/jquery.pnotify.js"),
@@ -60,29 +90,29 @@ public class NotifyRenderer extends HeaderResourcesRendererBase {
* Include only attributes that are actually set.
*/
Map options = new HashMap();
- addOptionIfSetAndNotDefault("pnotify_title", notify.getTitle(), options);
- addOptionIfSetAndNotDefault("pnotify_text", notify.getText(), options);
- addOptionIfSetAndNotDefault("pnotify_hide", !notify.isSticky(), options);
- addOptionIfSetAndNotDefault("pnotify_delay", notify.getStayTime(), options);
+ addOptionIfSetAndNotDefault("title", notify.getTitle(), options);
+ addOptionIfSetAndNotDefault("text", notify.getText(), options);
+ addOptionIfSetAndNotDefault("sticky", notify.isSticky(), options);
+ addOptionIfSetAndNotDefault("stayTime", notify.getStayTime(), options);
Map animationOptions = new HashMap();
- addOptionIfSetAndNotDefault("effect_in", notify.getAppearAnimation(), animationOptions);
- addOptionIfSetAndNotDefault("effect_out", notify.getHideAnimation(), animationOptions);
- addOptionIfSetAndNotDefault("pnotify_animation", animationOptions, options);
- addOptionIfSetAndNotDefault("pnotify_animate_speed", notify.getAnimationSpeed(), options);
- addOptionIfSetAndNotDefault("pnotify_nonblock", notify.isNonblocking(), options);
- addOptionIfSetAndNotDefault("pnotify_nonblock_opacity", notify.getNonblockingOpacity(), options);
- addOptionIfSetAndNotDefault("pnotify_history", notify.isShowHistory(), options);
- addOptionIfSetAndNotDefault("pnotify_shadow", notify.isShowShadow(), options);
- addOptionIfSetAndNotDefault("pnotify_closer", notify.isShowCloseButton(), options);
+ addOptionIfSetAndNotDefault("appearAnimation", notify.getAppearAnimation(), animationOptions);
+ addOptionIfSetAndNotDefault("hideAnimation", notify.getHideAnimation(), animationOptions);
+ addOptionIfSetAndNotDefault("animation", animationOptions, options);
+ addOptionIfSetAndNotDefault("animationSpeed", notify.getAnimationSpeed(), options);
+ addOptionIfSetAndNotDefault("nonblocking", notify.isNonblocking(), options);
+ addOptionIfSetAndNotDefault("nonblockingOpacity", notify.getNonblockingOpacity(), options);
+ addOptionIfSetAndNotDefault("showHistory", notify.isShowHistory(), options);
+ addOptionIfSetAndNotDefault("showShadow", notify.isShowShadow(), options);
+ addOptionIfSetAndNotDefault("showCloseButton", notify.isShowCloseButton(), options);
UINotifyStack stack = getStackComponent(context, notify);
if (stack != null) {
- addOptionIfSetAndNotDefault("pnotify_stack", getUtils().clientId(context, stack), options);
+ addOptionIfSetAndNotDefault("stack", getUtils().clientId(context, stack), options);
}
String styleClass = notify.getStyleClass();
if (styleClass == null) {
styleClass = "";
}
- addOptionIfSetAndNotDefault("pnotify_addclass", getStackStyleClass(context, notify) + " " + styleClass, options);
+ addOptionIfSetAndNotDefault("styleClass", getStackStyleClass(context, notify) + " " + styleClass, options);
addOptionIfSetAndNotDefault("delay", notify.getDelay(), options);
return options;
}
@@ -93,7 +123,10 @@ public class NotifyRenderer extends HeaderResourcesRendererBase {
}
protected void addOptionIfSetAndNotDefault(String optionName, Object value, Map options) {
- if (value != null && value != "" && !value.equals(defaults.get(optionName))) {
+ if (value != null && !"".equals(value)
+ && !value.equals(DEFAULTS.get(optionName))
+ && !(value instanceof Collection && ((Collection) value).size() == 0)
+ && !(value instanceof Map && ((Map) value).size() == 0)) {
options.put(optionName, value);
}
}
diff --git a/src/main/java/org/richfaces/renderkit/html/NotifyStackRenderer.java b/src/main/java/org/richfaces/renderkit/html/NotifyStackRenderer.java
index 4745810..68dc053 100644
--- a/src/main/java/org/richfaces/renderkit/html/NotifyStackRenderer.java
+++ b/src/main/java/org/richfaces/renderkit/html/NotifyStackRenderer.java
@@ -1,5 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
package org.richfaces.renderkit.html;
+import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
+import org.ajax4jsf.renderkit.RendererUtils;
+import org.ajax4jsf.resource.InternetResource;
+import org.richfaces.component.UINotifyStack;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
@@ -7,11 +34,6 @@ import javax.faces.context.ResponseWriter;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
-import org.ajax4jsf.javascript.JSFunction;
-import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
-import org.ajax4jsf.resource.InternetResource;
-import org.richfaces.component.UINotifyStack;
public class NotifyStackRenderer extends HeaderResourcesRendererBase {
@@ -25,12 +47,15 @@ public class NotifyStackRenderer extends HeaderResourcesRendererBase {
return;
}
ResponseWriter writer = context.getResponseWriter();
- writer.startElement(HTML.SCRIPT_ELEM, null);
- writer.writeText(new JSFunction("RichFaces.NotifyStack.register", getUtils().clientId(context, component), getOptions(context, (UINotifyStack) component)), null);
- writer.endElement(HTML.SCRIPT_ELEM);
+ writer.startElement(RendererUtils.HTML.SCRIPT_ELEM, null);
+ writer.writeText(new JSFunction("RichFaces.NotifyStack.register",
+ RendererUtils.getInstance().clientId(context, component),
+ getOptions((UINotifyStack) component)
+ ), null);
+ writer.endElement(RendererUtils.HTML.SCRIPT_ELEM);
}
- protected Map getOptions(FacesContext context, UINotifyStack stack) throws IOException {
+ protected Map getOptions(UINotifyStack stack) throws IOException {
/**
* Include only attributes that are actually set.
*/
@@ -42,7 +67,7 @@ public class NotifyStackRenderer extends HeaderResourcesRendererBase {
}
protected void addOptionIfSet(String optionName, Object value, Map options) {
- if (value != null && value != "") {
+ if (value != null && !"".equals(value)) {
options.put(optionName, value);
}
}
diff --git a/src/main/resources/org/richfaces/renderkit/html/scripts/richfaces.notify.js b/src/main/resources/org/richfaces/renderkit/html/scripts/richfaces.notify.js
index b4e73eb..04e3d0c 100644
--- a/src/main/resources/org/richfaces/renderkit/html/scripts/richfaces.notify.js
+++ b/src/main/resources/org/richfaces/renderkit/html/scripts/richfaces.notify.js
@@ -1,11 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright , Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
window.RichFaces = window.RichFaces || {};
-RichFaces.NotifyStack = (function(){
+RichFaces.NotifyStack = (function() {
var stacks = {};
return {
- register: function(id,stack) {
+ register: function(id, stack) {
var existingStack = stacks[id];
- if(existingStack != null) {
- stack = jQuery.extend(existingStack,stack);
+ if (existingStack != null) {
+ stack = jQuery.extend(existingStack, stack);
delete stack.addpos1;
delete stack.addpos2;
delete stack.animation;
@@ -14,13 +36,14 @@ RichFaces.NotifyStack = (function(){
delete stack.nextpos1;
delete stack.nextpos2;
}
+ stack.id = id;
stacks[id] = stack;
},
getStack: function(id) {
var stack = stacks[id];
- if(stack == null) {
- stack = {};
- stacks[id] = stack;
+ if (stack == null) {
+ stack = jQuery.extend({}, jQuery.pnotify.defaults.pnotify_stack);
+ this.register(id, stack);
}
return stack;
}
@@ -28,16 +51,124 @@ RichFaces.NotifyStack = (function(){
})();
RichFaces.Notify = function(options) {
- if(options!=null && typeof options.pnotify_stack == "string") {
- options.pnotify_stack = RichFaces.NotifyStack.getStack(options.pnotify_stack);
+ /**
+ * Copies attributes from one objects to other object, but
+ * can change the name of target attributes.
+ */
+ function extend(target, source, translation) {
+ for (var attr in source) {
+ var targetAttr = translation[attr] != null ? translation[attr] : attr;
+ target[targetAttr] = source[attr];
+ if (attr != 'stack' && target[targetAttr] instanceof Object) {
+ target[targetAttr] = extend({}, target[targetAttr], translation);
+ }
+ }
+ return target;
+ }
+
+ options = jQuery.extend({stack:'default'}, options);
+ if (options != null && typeof options.stack == "string") {
+ options.stack = RichFaces.NotifyStack.getStack(options.stack);
+ }
+ var delegateOptions = extend({}, options, {
+ 'title':'pnotify_title' ,
+ 'text': 'pnotify_text',
+ 'styleClass': 'pnotify_addclass',
+ 'nonblocking': 'pnotify_nonblock',
+ 'nonblockingOpacity': 'pnotify_nonblock_opacity',
+ 'showHistory': 'pnotify_history',
+ 'animation': 'pnotify_animation',
+ 'appearAnimation': 'effect_in',
+ 'hideAnimation': 'effect_out',
+ 'animationSpeed': 'pnotify_animate_speed',
+ 'opacity': 'pnotify_opacity',
+ 'showShadow': 'pnotify_shadow',
+ 'showCloseButton': 'pnotify_closer',
+ 'sticky': 'pnotify_hide',
+ 'stayTime': 'pnotify_delay',
+ 'stack': 'pnotify_stack'
+ });
+ if (options.sticky !== null) {
+ delegateOptions.pnotify_hide = !options.sticky;
}
jQuery(document).ready(function() {
- if(options.delay) {
- setTimeout(function(){
- jQuery.pnotify(options);
- },options.delay);
+ if (options.delay) {
+ setTimeout(function() {
+ jQuery.pnotify(delegateOptions);
+ }, options.delay);
} else {
- jQuery.pnotify(options);
+ jQuery.pnotify(delegateOptions);
+ }
+ });
+};
+
+//TODO remove this fix when it gets in to jquery.js
+(function() {
+ var safariCompatMode;
+ var getCompatMode = function() {
+ var compatMode = document.compatMode;
+ if (!compatMode && jQuery.browser.safari) {
+ if (!safariCompatMode) {
+ //detect compatMode as described in http://code.google.com/p/doctype/wiki/ArticleCompatMode
+ var width = jQuery(document.createElement("div")).attr('style', 'position:absolute;width:0;height:0;width:1')
+ .css('width');
+ safariCompatMode = compatMode = (width == '1px' ? 'BackCompat' : 'CSS1Compat');
+ } else {
+ compatMode = safariCompatMode;
+ }
}
+
+ return compatMode;
+ };
+
+
+ // Create innerHeight, innerWidth, outerHeight and outerWidth methods
+ jQuery.each([ "Height", "Width" ], function(i, name) {
+
+ var tl = i ? "Left" : "Top", // top or left
+ br = i ? "Right" : "Bottom", // bottom or right
+ lower = name.toLowerCase();
+
+ // innerHeight and innerWidth
+ jQuery.fn["inner" + name] = function() {
+ return this[0] ?
+ jQuery.css(this[0], lower, false, "padding") :
+ null;
+ };
+
+ // outerHeight and outerWidth
+ jQuery.fn["outer" + name] = function(margin) {
+ return this[0] ?
+ jQuery.css(this[0], lower, false, margin ? "margin" : "border") :
+ null;
+ };
+
+ var type = name.toLowerCase();
+
+ jQuery.fn[ type ] = function(size) {
+ // Get window width or height
+ return this[0] == window ?
+ // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
+ getCompatMode() == "CSS1Compat" && document.documentElement[ "client" + name ] ||
+ document.body[ "client" + name ] :
+
+ // Get document width or height
+ this[0] == document ?
+ // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
+ Math.max(
+ document.documentElement["client" + name],
+ document.body["scroll" + name], document.documentElement["scroll" + name],
+ document.body["offset" + name], document.documentElement["offset" + name]
+ ) :
+
+ // Get or set width or height on the element
+ size === undefined ?
+ // Get width or height on the element
+ (this.length ? jQuery.css(this[0], type) : null) :
+
+ // Set the width or height on the element (default to pixels if value is unitless)
+ this.css(type, typeof size === "string" ? size : size + "px");
+ };
+
});
-}
+}());
\ No newline at end of file
diff --git a/src/main/templates/notify.jspx b/src/main/templates/notify.jspx
index b98f34d..45fe3d2 100644
--- a/src/main/templates/notify.jspx
+++ b/src/main/templates/notify.jspx
@@ -1,38 +1,39 @@
-
+
/org/richfaces/renderkit/html/scripts/jquery-1.4.2.js,
- /org/richfaces/renderkit/html/scripts/jquery.pnotify.js
+ /org/richfaces/renderkit/html/scripts/jquery.pnotify.js
/org/richfaces/renderkit/html/css/jquery.pnotify.xcss
+