Showing
20 changed files
with
1668 additions
and
0 deletions
src/main/config/component/notify.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<!DOCTYPE components PUBLIC "-//AJAX4JSF//CDK Generator config/EN" | ||
3 | + "http://labs.jboss.com/jbossrichfaces/component-config.dtd" | ||
4 | + [ | ||
5 | + <!ENTITY notifyAttributes SYSTEM "notifyAttributes.ent"> | ||
6 | + ] | ||
7 | + > | ||
8 | +<components> | ||
9 | + <component> | ||
10 | + <name>org.richfaces.Notify</name> | ||
11 | + <family>org.richfaces.Notify</family> | ||
12 | + <classname>org.richfaces.component.html.HtmlNotify</classname> | ||
13 | + <superclass>org.richfaces.component.UINotify</superclass> | ||
14 | + <description> | ||
15 | + <![CDATA[ | ||
16 | + ]]> | ||
17 | + </description> | ||
18 | + <renderer generate="false" override="true"> | ||
19 | + <name>org.richfaces.NotifyRenderer</name> | ||
20 | + <classname>org.richfaces.renderkit.html.NotifyRenderer</classname> | ||
21 | + </renderer> | ||
22 | + <tag> | ||
23 | + <name>notify</name> | ||
24 | + <classname>org.richfaces.taglib.NotifyTag</classname> | ||
25 | + <superclass> | ||
26 | + org.ajax4jsf.webapp.taglib.HtmlComponentTagBase | ||
27 | + </superclass> | ||
28 | + <!-- | ||
29 | + <test> | ||
30 | + <classname>org.richfaces.taglib.HtmlNotifyTagTest</classname> | ||
31 | + <superclassname>org.ajax4jsf.tests.AbstractJspTestCase</superclassname> | ||
32 | + </test> | ||
33 | + --> | ||
34 | + | ||
35 | + </tag> | ||
36 | + &ui_component_attributes; | ||
37 | + &ajax_output_attributes; | ||
38 | + ¬ifyAttributes; | ||
39 | + <property> | ||
40 | + <name>title</name> | ||
41 | + <classname>java.lang.String</classname> | ||
42 | + <description> | ||
43 | + </description> | ||
44 | + <defaultvalue>""</defaultvalue> | ||
45 | + </property> | ||
46 | + <property> | ||
47 | + <name>text</name> | ||
48 | + <classname>java.lang.String</classname> | ||
49 | + <description> | ||
50 | + </description> | ||
51 | + <defaultvalue>""</defaultvalue> | ||
52 | + </property> | ||
53 | + | ||
54 | + | ||
55 | + <property> | ||
56 | + <name>styleClass</name> | ||
57 | + <classname>java.lang.String</classname> | ||
58 | + <description></description> | ||
59 | + </property> | ||
60 | + </component> | ||
61 | +</components> |
1 | + <property> | ||
2 | + <name>stack</name> | ||
3 | + <classname>java.lang.String</classname> | ||
4 | + <description> | ||
5 | + Id of stack component in which this message will be displayed. | ||
6 | + </description> | ||
7 | + <defaultvalue>null</defaultvalue> | ||
8 | + </property> | ||
9 | + <property> | ||
10 | + <name>sticky</name> | ||
11 | + <classname>boolean</classname> | ||
12 | + <description> | ||
13 | + if you want it to fade out on its own or just sit there | ||
14 | + </description> | ||
15 | + <defaultvalue>false</defaultvalue> | ||
16 | + </property> | ||
17 | + <property> | ||
18 | + <name>stayTime</name> | ||
19 | + <classname>java.lang.Integer</classname> | ||
20 | + <description> | ||
21 | + the time you want it to be alive for before fading out (milliseconds) | ||
22 | + </description> | ||
23 | + <defaultvalue>8000</defaultvalue> | ||
24 | + </property> | ||
25 | + <property> | ||
26 | + <name>delay</name> | ||
27 | + <classname>java.lang.Integer</classname> | ||
28 | + <description> | ||
29 | + Miliseconds before component should be shown for the first time. | ||
30 | + </description> | ||
31 | + <defaultvalue>0</defaultvalue> | ||
32 | + </property> | ||
33 | + <property> | ||
34 | + <name>appearAnimation</name> | ||
35 | + <classname>java.lang.String</classname> | ||
36 | + <description> | ||
37 | + The animation to use when displaying and hiding the notice. | ||
38 | + "none", "show", "fade", and "slide" are built in to jQuery. | ||
39 | + Others require jQuery UI. | ||
40 | + </description> | ||
41 | + <defaultvalue>"fade"</defaultvalue> | ||
42 | + </property> | ||
43 | + <property> | ||
44 | + <name>hideAnimation</name> | ||
45 | + <classname>java.lang.String</classname> | ||
46 | + <description> | ||
47 | + The animation to use when displaying and hiding the notice. | ||
48 | + "none", "show", "fade", and "slide" are built in to jQuery. | ||
49 | + Others require jQuery UI. | ||
50 | + </description> | ||
51 | + <defaultvalue>"fade"</defaultvalue> | ||
52 | + </property> | ||
53 | + <property> | ||
54 | + <name>animationSpeed</name> | ||
55 | + <classname>java.lang.Integer</classname> | ||
56 | + <description> | ||
57 | + animation speed (milliseconds) | ||
58 | + </description> | ||
59 | + <defaultvalue>null</defaultvalue> | ||
60 | + </property> | ||
61 | + <property> | ||
62 | + <name>showHistory</name> | ||
63 | + <classname>boolean</classname> | ||
64 | + <description> | ||
65 | + Display a pull down menu to redisplay previous notices, | ||
66 | + and place the notice in the history. | ||
67 | + </description> | ||
68 | + <defaultvalue>true</defaultvalue> | ||
69 | + </property> | ||
70 | + <property> | ||
71 | + <name>nonblocking</name> | ||
72 | + <classname>boolean</classname> | ||
73 | + <description> | ||
74 | + Non-blocking notice lets the user click elements underneath it. | ||
75 | + </description> | ||
76 | + <defaultvalue>false</defaultvalue> | ||
77 | + </property> | ||
78 | + <property> | ||
79 | + <name>showShadow</name> | ||
80 | + <classname>boolean</classname> | ||
81 | + <description> | ||
82 | + Display a drop shadow. | ||
83 | + </description> | ||
84 | + <defaultvalue>false</defaultvalue> | ||
85 | + </property> | ||
86 | + <property> | ||
87 | + <name>showCloseButton</name> | ||
88 | + <classname>boolean</classname> | ||
89 | + <description> | ||
90 | + Provide a button for the user to manually close the notice. | ||
91 | + </description> | ||
92 | + <defaultvalue>true</defaultvalue> | ||
93 | + </property> | ||
94 | + <property> | ||
95 | + <name>nonblockingOpacity</name> | ||
96 | + <classname>java.lang.Double</classname> | ||
97 | + <description> | ||
98 | + The opacity of the notice (if it's non-blocking) when the mouse is over it. | ||
99 | + </description> | ||
100 | + <defaultvalue>.2</defaultvalue> | ||
101 | + </property> | ||
102 | + <property> | ||
103 | + <name>styleClass</name> | ||
104 | + <classname>java.lang.String</classname> | ||
105 | + <description></description> | ||
106 | + </property> |
src/main/config/component/notifyMessages.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<!DOCTYPE components PUBLIC "-//AJAX4JSF//CDK Generator config/EN" | ||
3 | + "http://labs.jboss.com/jbossrichfaces/component-config.dtd" | ||
4 | + [ | ||
5 | + <!ENTITY notifyAttributes SYSTEM "notifyAttributes.ent"> | ||
6 | + ] | ||
7 | + > | ||
8 | +<components> | ||
9 | + <component> | ||
10 | + <name>org.richfaces.NotifyMessages</name> | ||
11 | + <family>org.richfaces.NotifyMessages</family> | ||
12 | + <classname>org.richfaces.component.html.HtmlNotifyMessages</classname> | ||
13 | + <superclass>org.richfaces.component.UINotifyMessages</superclass> | ||
14 | + <description> | ||
15 | + <![CDATA[ | ||
16 | + ]]> | ||
17 | + </description> | ||
18 | + <renderer generate="false" override="true"> | ||
19 | + <name>org.richfaces.NotifyMessagesRenderer</name> | ||
20 | + <classname>org.richfaces.renderkit.html.NotifyMessagesRenderer</classname> | ||
21 | + </renderer> | ||
22 | + <tag> | ||
23 | + <name>notifyMessages</name> | ||
24 | + <classname>org.richfaces.taglib.NotifyMessagesTag</classname> | ||
25 | + <superclass> | ||
26 | + org.ajax4jsf.webapp.taglib.HtmlComponentTagBase | ||
27 | + </superclass> | ||
28 | + <!-- | ||
29 | + <test> | ||
30 | + <classname>org.richfaces.taglib.HtmlNotifyMessagesTagTest</classname> | ||
31 | + <superclassname>org.ajax4jsf.tests.AbstractJspTestCase</superclassname> | ||
32 | + </test> | ||
33 | + --> | ||
34 | + | ||
35 | + </tag> | ||
36 | + &ui_component_attributes; | ||
37 | + &ajax_output_attributes; | ||
38 | + ¬ifyAttributes; | ||
39 | + <property> | ||
40 | + <name>globalOnly</name> | ||
41 | + <classname>boolean</classname> | ||
42 | + <description></description> | ||
43 | + </property> | ||
44 | + <property> | ||
45 | + <name>showDetail</name> | ||
46 | + <classname>boolean</classname> | ||
47 | + <description></description> | ||
48 | + </property> | ||
49 | + <property> | ||
50 | + <name>showSummary</name> | ||
51 | + <classname>boolean</classname> | ||
52 | + <description></description> | ||
53 | + </property> | ||
54 | + </component> | ||
55 | +</components> |
src/main/config/component/notifyStack.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<!DOCTYPE components PUBLIC "-//AJAX4JSF//CDK Generator config/EN" "http://labs.jboss.com/jbossrichfaces/component-config.dtd" > | ||
3 | +<components> | ||
4 | + <component> | ||
5 | + <name>org.richfaces.NotifyStack</name> | ||
6 | + <family>org.richfaces.NotifyStack</family> | ||
7 | + <classname>org.richfaces.component.html.HtmlNotifyStack</classname> | ||
8 | + <superclass>org.richfaces.component.UINotifyStack</superclass> | ||
9 | + <description> | ||
10 | + <![CDATA[ | ||
11 | + ]]> | ||
12 | + </description> | ||
13 | + <renderer generate="false" override="false"> | ||
14 | + <name>org.richfaces.NotifyStackRenderer</name> | ||
15 | + <classname>org.richfaces.renderkit.html.NotifyStackRenderer</classname> | ||
16 | + </renderer> | ||
17 | + <tag> | ||
18 | + <name>notifyStack</name> | ||
19 | + <classname>org.richfaces.taglib.NotifyStackTag</classname> | ||
20 | + <superclass> | ||
21 | + org.ajax4jsf.webapp.taglib.HtmlComponentTagBase | ||
22 | + </superclass> | ||
23 | + <!-- | ||
24 | + <test> | ||
25 | + <classname>org.richfaces.taglib.HtmlNotifyStackTagTest</classname> | ||
26 | + <superclassname>org.ajax4jsf.tests.AbstractJspTestCase</superclassname> | ||
27 | + </test> | ||
28 | + --> | ||
29 | + | ||
30 | + </tag> | ||
31 | + &ui_component_attributes; | ||
32 | + <property> | ||
33 | + <name>verticalStackingDirection</name> | ||
34 | + <classname>java.lang.String</classname> | ||
35 | + <description></description> | ||
36 | + </property> | ||
37 | + <property> | ||
38 | + <name>horizontalStackingDirection</name> | ||
39 | + <classname>java.lang.String</classname> | ||
40 | + <description> | ||
41 | + </description> | ||
42 | + </property> | ||
43 | + <property> | ||
44 | + <name>push</name> | ||
45 | + <classname>java.lang.String</classname> | ||
46 | + <description> | ||
47 | + Stack end from which message should be pushed. | ||
48 | + Acceptable values: "up","down" | ||
49 | + </description> | ||
50 | + </property> | ||
51 | + | ||
52 | + <property> | ||
53 | + <name>styleClass</name> | ||
54 | + <classname>java.lang.String</classname> | ||
55 | + <description></description> | ||
56 | + </property> | ||
57 | + </component> | ||
58 | +</components> |
1 | +package org.richfaces.component; | ||
2 | + | ||
3 | +public interface NotifyAttributes { | ||
4 | + | ||
5 | + public abstract boolean isSticky(); | ||
6 | + | ||
7 | + public abstract void setSticky(boolean sticky); | ||
8 | + | ||
9 | + public abstract Integer getStayTime(); | ||
10 | + | ||
11 | + public abstract void setStayTime(Integer time); | ||
12 | + | ||
13 | + public abstract Integer getDelay(); | ||
14 | + | ||
15 | + public abstract void setDelay(Integer delay); | ||
16 | + | ||
17 | + public abstract String getStyleClass(); | ||
18 | + | ||
19 | + public abstract void setStyleClass(String styleClass); | ||
20 | + | ||
21 | + public abstract String getAppearAnimation(); | ||
22 | + | ||
23 | + public abstract void setAppearAnimation(String appearAnimation); | ||
24 | + | ||
25 | + public abstract String getHideAnimation(); | ||
26 | + | ||
27 | + public abstract void setHideAnimation(String hideAnimation); | ||
28 | + | ||
29 | + public abstract Integer getAnimationSpeed(); | ||
30 | + | ||
31 | + public abstract void setAnimationSpeed(Integer animationSpeed); | ||
32 | + | ||
33 | + public abstract boolean isShowHistory(); | ||
34 | + | ||
35 | + public abstract void setShowHistory(boolean showHistory); | ||
36 | + | ||
37 | + public abstract boolean isNonblocking(); | ||
38 | + | ||
39 | + public abstract void setNonblocking(boolean nonblocking); | ||
40 | + | ||
41 | + public abstract boolean isShowShadow(); | ||
42 | + | ||
43 | + public abstract void setShowShadow(boolean showShadow); | ||
44 | + | ||
45 | + public abstract boolean isShowCloseButton(); | ||
46 | + | ||
47 | + public abstract void setShowCloseButton(boolean showCloseButton); | ||
48 | + | ||
49 | + public abstract Double getNonblockingOpacity(); | ||
50 | + | ||
51 | + public abstract void setNonblockingOpacity(Double nonblockingOpacity); | ||
52 | + | ||
53 | + public abstract String getStack(); | ||
54 | + | ||
55 | + public abstract void setStack(String stack); | ||
56 | +} |
1 | +package org.richfaces.component; | ||
2 | + | ||
3 | +import javax.faces.component.UIComponentBase; | ||
4 | + | ||
5 | +public abstract class UINotify extends UIComponentBase implements NotifyAttributes { | ||
6 | + | ||
7 | + public static final String COMPONENT_TYPE = "org.richfaces.Notify"; | ||
8 | + public static final String COMPONENT_FAMILY = "org.richfaces.Notify"; | ||
9 | + | ||
10 | + public abstract String getTitle(); | ||
11 | + | ||
12 | + public abstract void setTitle(String title); | ||
13 | + | ||
14 | + public abstract String getText(); | ||
15 | + | ||
16 | + public abstract void setText(String text); | ||
17 | +} |
1 | +package org.richfaces.component; | ||
2 | + | ||
3 | +import javax.faces.component.UIMessages; | ||
4 | +import org.ajax4jsf.component.AjaxOutput; | ||
5 | + | ||
6 | +public abstract class UINotifyMessages extends UIMessages implements AjaxOutput, NotifyAttributes { | ||
7 | + | ||
8 | + public static final String COMPONENT_TYPE = "org.richfaces.NotifyMessages"; | ||
9 | + public static final String COMPONENT_FAMILY = "org.richfaces.Notify"; | ||
10 | + | ||
11 | + public abstract Integer getInterval(); | ||
12 | + | ||
13 | + public abstract void setInterval(Integer interval); | ||
14 | + | ||
15 | +} |
1 | +package org.richfaces.component; | ||
2 | + | ||
3 | +import javax.faces.component.UIComponentBase; | ||
4 | + | ||
5 | +public abstract class UINotifyStack extends UIComponentBase { | ||
6 | + | ||
7 | + public static final String COMPONENT_TYPE = "org.richfaces.NotifyStack"; | ||
8 | + public static final String COMPONENT_FAMILY = "org.richfaces.Notify"; | ||
9 | + | ||
10 | + public abstract String getStyleClass(); | ||
11 | + | ||
12 | + public abstract void setStyleClass(String styleClass); | ||
13 | + | ||
14 | + public abstract String getStackDir1(); | ||
15 | + | ||
16 | + public abstract void setStackDir1(String stackDir1); | ||
17 | + | ||
18 | + public abstract String getStackDir2(); | ||
19 | + | ||
20 | + public abstract void setStackDir2(String stackDir2); | ||
21 | + | ||
22 | + public abstract String getPush(); | ||
23 | + | ||
24 | + public abstract void setPush(String stackPush); | ||
25 | +} |
1 | +package org.richfaces.renderkit.html; | ||
2 | + | ||
3 | +import javax.faces.component.UIComponent; | ||
4 | +import javax.faces.context.FacesContext; | ||
5 | +import java.io.IOException; | ||
6 | +import java.util.Iterator; | ||
7 | +import javax.faces.application.FacesMessage; | ||
8 | +import javax.faces.context.ResponseWriter; | ||
9 | +import org.ajax4jsf.renderkit.RendererUtils.HTML; | ||
10 | +import org.richfaces.component.UINotify; | ||
11 | +import org.richfaces.component.UINotifyMessages; | ||
12 | + | ||
13 | +public class NotifyMessagesRenderer extends NotifyRenderer { | ||
14 | + | ||
15 | + @Override | ||
16 | + public void encodeEnd(FacesContext context, UIComponent component) throws IOException { | ||
17 | + UINotifyMessages messagesComponent = (UINotifyMessages) component; | ||
18 | + ResponseWriter writer = context.getResponseWriter(); | ||
19 | + writer.startElement(HTML.DIV_ELEM, null); | ||
20 | + writer.writeAttribute(HTML.id_ATTRIBUTE, getUtils().clientId(context, component), "type"); | ||
21 | + Integer delay = messagesComponent.getDelay(); | ||
22 | + if (delay == null) { | ||
23 | + delay = 0; | ||
24 | + } | ||
25 | + Integer interval = messagesComponent.getInterval(); | ||
26 | + if (interval == null) { | ||
27 | + interval = 0; | ||
28 | + } | ||
29 | + | ||
30 | + Iterator<FacesMessage> messages = messagesComponent.isGlobalOnly() ? context.getMessages(null) : context.getMessages(); | ||
31 | + while (messages.hasNext()) { | ||
32 | + FacesMessage msg = messages.next(); | ||
33 | + UINotify notify = (UINotify) context.getApplication().createComponent(UINotify.COMPONENT_TYPE); | ||
34 | + notify.setAnimationSpeed(messagesComponent.getAnimationSpeed()); | ||
35 | + notify.setAppearAnimation(messagesComponent.getAppearAnimation()); | ||
36 | + notify.setDelay(delay); | ||
37 | + notify.setHideAnimation(messagesComponent.getHideAnimation()); | ||
38 | + notify.setNonblocking(messagesComponent.isNonblocking()); | ||
39 | + notify.setNonblockingOpacity(messagesComponent.getNonblockingOpacity()); | ||
40 | + notify.setShowCloseButton(messagesComponent.isShowCloseButton()); | ||
41 | + notify.setShowHistory(messagesComponent.isShowHistory()); | ||
42 | + notify.setShowShadow(messagesComponent.isShowShadow()); | ||
43 | + notify.setStack(messagesComponent.getStack()); | ||
44 | + notify.setStayTime(messagesComponent.getStayTime()); | ||
45 | + notify.setSticky(messagesComponent.isSticky()); | ||
46 | + if (messagesComponent.isShowSummary()) { | ||
47 | + notify.setTitle(msg.getSummary()); | ||
48 | + } | ||
49 | + if (messagesComponent.isShowDetail()) { | ||
50 | + notify.setText(msg.getDetail()); | ||
51 | + } | ||
52 | + String styleClass = messagesComponent.getStyleClass(); | ||
53 | + if(styleClass == null) { | ||
54 | + styleClass = ""; | ||
55 | + } | ||
56 | + if (FacesMessage.SEVERITY_INFO.equals(msg.getSeverity())) { | ||
57 | + styleClass += " rf-ny-info"; | ||
58 | + } else if (FacesMessage.SEVERITY_WARN.equals(msg.getSeverity())) { | ||
59 | + styleClass += " rf-ny-warn"; | ||
60 | + } else if (FacesMessage.SEVERITY_ERROR.equals(msg.getSeverity())) { | ||
61 | + styleClass += " rf-ny-error"; | ||
62 | + } else if (FacesMessage.SEVERITY_FATAL.equals(msg.getSeverity())) { | ||
63 | + styleClass += " rf-ny-fatal"; | ||
64 | + } | ||
65 | + styleClass = styleClass.trim(); | ||
66 | + notify.setStyleClass(styleClass); | ||
67 | + notify.encodeAll(context); | ||
68 | + delay += interval; | ||
69 | + } | ||
70 | + writer.endElement(HTML.DIV_ELEM); | ||
71 | + } | ||
72 | + | ||
73 | + @Override | ||
74 | + protected Class getComponentClass() { | ||
75 | + return UINotifyMessages.class; | ||
76 | + } | ||
77 | +} |
1 | +package org.richfaces.renderkit.html; | ||
2 | + | ||
3 | +import javax.faces.component.UIComponent; | ||
4 | +import javax.faces.context.FacesContext; | ||
5 | +import javax.faces.context.ResponseWriter; | ||
6 | +import java.io.IOException; | ||
7 | +import java.util.*; | ||
8 | +import org.ajax4jsf.javascript.JSFunction; | ||
9 | +import org.ajax4jsf.renderkit.HeaderResourcesRendererBase; | ||
10 | +import org.ajax4jsf.renderkit.RendererUtils.HTML; | ||
11 | +import org.ajax4jsf.resource.InternetResource; | ||
12 | +import org.richfaces.component.UINotify; | ||
13 | +import org.richfaces.component.UINotifyStack; | ||
14 | + | ||
15 | +public class NotifyRenderer extends HeaderResourcesRendererBase { | ||
16 | + | ||
17 | + private static final Map<String, Object> defaults = new HashMap<String, Object>(); | ||
18 | + | ||
19 | + { | ||
20 | + defaults.put("pnotify_addclass", ""); | ||
21 | + defaults.put("pnotify_nonblock", false); | ||
22 | + defaults.put("pnotify_nonblock_opacity", .2); | ||
23 | + defaults.put("pnotify_history", true); | ||
24 | + defaults.put("pnotify_animate_speed", "slow"); | ||
25 | + defaults.put("pnotify_opacity", 1); | ||
26 | + defaults.put("pnotify_shadow", false); | ||
27 | + defaults.put("pnotify_closer", true); | ||
28 | + defaults.put("pnotify_hide", true); | ||
29 | + defaults.put("pnotify_delay", 8000); | ||
30 | + defaults.put("delay", 0); | ||
31 | + | ||
32 | + } | ||
33 | + private final InternetResource[] scripts = { | ||
34 | + getResource("/org/richfaces/renderkit/html/scripts/jquery-1.4.2.js"), | ||
35 | + getResource("/org/richfaces/renderkit/html/scripts/jquery.pnotify.js"), | ||
36 | + getResource("/org/richfaces/renderkit/html/scripts/richfaces.notify.js") | ||
37 | + }; | ||
38 | + private final InternetResource[] styles = { | ||
39 | + getResource("/org/richfaces/renderkit/html/css/jquery.pnotify.xcss") | ||
40 | + }; | ||
41 | + | ||
42 | + @Override | ||
43 | + public void encodeEnd(FacesContext context, UIComponent component) throws IOException { | ||
44 | + if (!(component instanceof UINotify)) { | ||
45 | + return; | ||
46 | + } | ||
47 | + ResponseWriter writer = context.getResponseWriter(); | ||
48 | + writer.startElement(HTML.DIV_ELEM, null); | ||
49 | + writer.writeAttribute(HTML.id_ATTRIBUTE, getUtils().clientId(context, component), "type"); | ||
50 | + writer.startElement(HTML.SCRIPT_ELEM, null); | ||
51 | + writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", "type"); | ||
52 | + writer.writeText(new JSFunction("RichFaces.Notify", getOptions(context, (UINotify) component)), null); | ||
53 | + writer.writeText(";", null); | ||
54 | + writer.endElement(HTML.SCRIPT_ELEM); | ||
55 | + writer.endElement(HTML.DIV_ELEM); | ||
56 | + } | ||
57 | + | ||
58 | + protected Map<String, Object> getOptions(FacesContext context, UINotify notify) throws IOException { | ||
59 | + /** | ||
60 | + * Include only attributes that are actually set. | ||
61 | + */ | ||
62 | + Map<String, Object> options = new HashMap<String, Object>(); | ||
63 | + addOptionIfSetAndNotDefault("pnotify_title", notify.getTitle(), options); | ||
64 | + addOptionIfSetAndNotDefault("pnotify_text", notify.getText(), options); | ||
65 | + addOptionIfSetAndNotDefault("pnotify_hide", !notify.isSticky(), options); | ||
66 | + addOptionIfSetAndNotDefault("pnotify_delay", notify.getStayTime(), options); | ||
67 | + Map<String, Object> animationOptions = new HashMap<String, Object>(); | ||
68 | + addOptionIfSetAndNotDefault("effect_in", notify.getAppearAnimation(), animationOptions); | ||
69 | + addOptionIfSetAndNotDefault("effect_out", notify.getHideAnimation(), animationOptions); | ||
70 | + addOptionIfSetAndNotDefault("pnotify_animation", animationOptions, options); | ||
71 | + addOptionIfSetAndNotDefault("pnotify_animate_speed", notify.getAnimationSpeed(), options); | ||
72 | + addOptionIfSetAndNotDefault("pnotify_nonblock", notify.isNonblocking(), options); | ||
73 | + addOptionIfSetAndNotDefault("pnotify_nonblock_opacity", notify.getNonblockingOpacity(), options); | ||
74 | + addOptionIfSetAndNotDefault("pnotify_history", notify.isShowHistory(), options); | ||
75 | + addOptionIfSetAndNotDefault("pnotify_shadow", notify.isShowShadow(), options); | ||
76 | + addOptionIfSetAndNotDefault("pnotify_closer", notify.isShowCloseButton(), options); | ||
77 | + UINotifyStack stack = getStackComponent(context, notify); | ||
78 | + if (stack != null) { | ||
79 | + addOptionIfSetAndNotDefault("pnotify_stack", getUtils().clientId(context, stack), options); | ||
80 | + } | ||
81 | + String styleClass = notify.getStyleClass(); | ||
82 | + if (styleClass == null) { | ||
83 | + styleClass = ""; | ||
84 | + } | ||
85 | + addOptionIfSetAndNotDefault("pnotify_addclass", getStackStyleClass(context, notify) + " " + styleClass, options); | ||
86 | + addOptionIfSetAndNotDefault("delay", notify.getDelay(), options); | ||
87 | + return options; | ||
88 | + } | ||
89 | + | ||
90 | + protected String getStackStyleClass(FacesContext context, UINotify notify) { | ||
91 | + UINotifyStack stack = getStackComponent(context, notify); | ||
92 | + return stack == null ? "" : stack.getStyleClass(); | ||
93 | + } | ||
94 | + | ||
95 | + protected void addOptionIfSetAndNotDefault(String optionName, Object value, Map<String, Object> options) { | ||
96 | + if (value != null && value != "" && !value.equals(defaults.get(optionName))) { | ||
97 | + options.put(optionName, value); | ||
98 | + } | ||
99 | + } | ||
100 | + | ||
101 | + protected Class getComponentClass() { | ||
102 | + return UINotify.class; | ||
103 | + } | ||
104 | + | ||
105 | + @Override | ||
106 | + protected InternetResource[] getScripts() { | ||
107 | + return scripts; | ||
108 | + } | ||
109 | + | ||
110 | + @Override | ||
111 | + protected InternetResource[] getStyles() { | ||
112 | + return styles; | ||
113 | + } | ||
114 | + | ||
115 | + protected UINotifyStack getStackComponent(FacesContext context, UINotify notify) { | ||
116 | + String stackId = notify.getStack(); | ||
117 | + if (stackId == null) { | ||
118 | + UIComponent parent = notify.getParent(); | ||
119 | + while (parent != null && !(parent instanceof UINotifyStack)) { | ||
120 | + parent = parent.getParent(); | ||
121 | + } | ||
122 | + return (UINotifyStack) parent; | ||
123 | + } else { | ||
124 | + UIComponent componentFor = getUtils().findComponentFor(context.getViewRoot(), stackId); | ||
125 | + if (componentFor instanceof UINotifyStack) { | ||
126 | + return (UINotifyStack) componentFor; | ||
127 | + } else { | ||
128 | + return null; | ||
129 | + } | ||
130 | + } | ||
131 | + } | ||
132 | +} |
1 | +package org.richfaces.renderkit.html; | ||
2 | + | ||
3 | + | ||
4 | +import javax.faces.component.UIComponent; | ||
5 | +import javax.faces.context.FacesContext; | ||
6 | +import javax.faces.context.ResponseWriter; | ||
7 | +import java.io.IOException; | ||
8 | +import java.util.HashMap; | ||
9 | +import java.util.Map; | ||
10 | +import org.ajax4jsf.javascript.JSFunction; | ||
11 | +import org.ajax4jsf.renderkit.HeaderResourcesRendererBase; | ||
12 | +import org.ajax4jsf.renderkit.RendererUtils.HTML; | ||
13 | +import org.ajax4jsf.resource.InternetResource; | ||
14 | +import org.richfaces.component.UINotifyStack; | ||
15 | + | ||
16 | +public class NotifyStackRenderer extends HeaderResourcesRendererBase { | ||
17 | + | ||
18 | + private final InternetResource[] scripts = { | ||
19 | + getResource("/org/richfaces/renderkit/html/scripts/richfaces.notify.js") | ||
20 | + }; | ||
21 | + | ||
22 | + @Override | ||
23 | + public void encodeEnd(FacesContext context, UIComponent component) throws IOException { | ||
24 | + if (!(component instanceof UINotifyStack)) { | ||
25 | + return; | ||
26 | + } | ||
27 | + ResponseWriter writer = context.getResponseWriter(); | ||
28 | + writer.startElement(HTML.SCRIPT_ELEM, null); | ||
29 | + writer.writeText(new JSFunction("RichFaces.NotifyStack.register", getUtils().clientId(context, component), getOptions(context, (UINotifyStack) component)), null); | ||
30 | + writer.endElement(HTML.SCRIPT_ELEM); | ||
31 | + } | ||
32 | + | ||
33 | + protected Map<String, Object> getOptions(FacesContext context, UINotifyStack stack) throws IOException { | ||
34 | + /** | ||
35 | + * Include only attributes that are actually set. | ||
36 | + */ | ||
37 | + Map<String, Object> options = new HashMap<String, Object>(); | ||
38 | + addOptionIfSet("dir1", stack.getStackDir1(), options); | ||
39 | + addOptionIfSet("dir2", stack.getStackDir2(), options); | ||
40 | + addOptionIfSet("push", stack.getPush(), options); | ||
41 | + return options; | ||
42 | + } | ||
43 | + | ||
44 | + protected void addOptionIfSet(String optionName, Object value, Map<String, Object> options) { | ||
45 | + if (value != null && value != "") { | ||
46 | + options.put(optionName, value); | ||
47 | + } | ||
48 | + } | ||
49 | + | ||
50 | + @Override | ||
51 | + protected InternetResource[] getScripts() { | ||
52 | + return scripts; | ||
53 | + } | ||
54 | + | ||
55 | + @Override | ||
56 | + protected Class<? extends UIComponent> getComponentClass() { | ||
57 | + return UINotifyStack.class; | ||
58 | + } | ||
59 | +} |
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<f:template xmlns:f='http:/jsf.exadel.com/template' | ||
3 | +xmlns:u='http:/jsf.exadel.com/template/util' | ||
4 | +xmlns="http://www.w3.org/1999/xhtml" > | ||
5 | + | ||
6 | + <f:verbatim> | ||
7 | +/* Notice----------------------------------*/ | ||
8 | +.rf-ny { | ||
9 | + top: 18px; | ||
10 | + right: 18px; | ||
11 | + position: absolute; | ||
12 | + height: auto; | ||
13 | + /* Ensure that the notices are on top of everything else. */ | ||
14 | + z-index: 9999; | ||
15 | +} | ||
16 | + </f:verbatim> | ||
17 | + <u:selector name=".rf-ny-info"> | ||
18 | + <u:style name="color" skin="generalTextColor"/> | ||
19 | + </u:selector> | ||
20 | + <f:verbatim> | ||
21 | +.rf-ny-warn { | ||
22 | + color:orange; | ||
23 | +} | ||
24 | +.rf-ny-error { | ||
25 | + color:red; | ||
26 | +} | ||
27 | +.rf-ny-fatal { | ||
28 | + color:red; | ||
29 | + font-weight:bold; | ||
30 | +} | ||
31 | +/* This hides position: fixed from IE6, which doesn't understand it. */ | ||
32 | +html > body .rf-ny { | ||
33 | + position: fixed; | ||
34 | +} | ||
35 | + </f:verbatim> | ||
36 | + <u:selector name=".rf-ny .rf-ny-sh"> | ||
37 | + <u:style name="margin" value="0"/> | ||
38 | + <u:style name="padding" value="8px"/> | ||
39 | + <u:style name="background-color" skin="headerBackgroundColor"/> | ||
40 | + <u:style name="color" skin="headerTextColor"/> | ||
41 | + <u:style name="opcity" value=".3"/> | ||
42 | + <u:style name="-moz-border-radius" value="8px"/> | ||
43 | + <u:style name="-webkit-border-radius" value="8px"/> | ||
44 | + <u:style name="border-radius" value="8px"/> | ||
45 | + <u:style name="position" value="absolute"/> | ||
46 | + <u:style name="z-index" value="-1"/> | ||
47 | + <u:style name="top" value=".1em"/> | ||
48 | + <u:style name="left" value=".1em"/> | ||
49 | + <u:style name="bottom" value="-.2em"/> | ||
50 | + <u:style name="right" value="-.2em"/> | ||
51 | + </u:selector> | ||
52 | + <u:selector name=".rf-ny-co"> | ||
53 | + <u:style name="height" value="100%"/> | ||
54 | + <u:style name="padding" value=".8em"/> | ||
55 | + <u:style name="border-width" value="1px"/> | ||
56 | + <u:style name="border-style" value="solid"/> | ||
57 | + <u:style name="border-color" value="panelBorderColor"/> | ||
58 | + <u:style name="background-color" skin="generalBackgroundColor"/> | ||
59 | + <u:style name="color" skin="panelTextColor"/> | ||
60 | + <u:style name="-moz-border-radius" value="4px"/> | ||
61 | + <u:style name="-webkit-border-radius" value="4px"/> | ||
62 | + <u:style name="border-radius" value="4px"/> | ||
63 | + </u:selector> | ||
64 | + <f:verbatim> | ||
65 | +.rf-ny-co-hover { | ||
66 | + background:red; | ||
67 | +} | ||
68 | +.rf-ny-cl { | ||
69 | + float: right; | ||
70 | + margin-left: .2em; | ||
71 | +} | ||
72 | + </f:verbatim> | ||
73 | + <u:selector name=".rf-ny-cl-ic"> | ||
74 | + <u:style name="display" value="block"/> | ||
75 | + <u:style name="width" value="11px"/> | ||
76 | + <u:style name="height" value="11px"/> | ||
77 | + <u:style name="background-image"> | ||
78 | + <f:resource f:key="org.richfaces.renderkit.html.images.CancelControlIcon"/> | ||
79 | + </u:style> | ||
80 | + </u:selector> | ||
81 | + <f:verbatim> | ||
82 | +.rf-ny-ti { | ||
83 | + display: block; | ||
84 | + font-size: 1.2em; | ||
85 | + font-weight: bold; | ||
86 | + margin-bottom: .4em; | ||
87 | +} | ||
88 | +.rf-ny-te { | ||
89 | + display: block; | ||
90 | +} | ||
91 | +.rf-ny-ic { | ||
92 | + display: none; | ||
93 | + float: left; | ||
94 | + margin-right: .2em; | ||
95 | + width:32px; | ||
96 | + height:32px; | ||
97 | +} | ||
98 | +/* History Pulldown----------------------------------*/ | ||
99 | + </f:verbatim> | ||
100 | + <u:selector name=".rf-ny-hc"> | ||
101 | + <u:style name="background-color" skin="headerBackgroundColor"/> | ||
102 | + <u:style name="border-color" skin="headerBackgroundColor"/> | ||
103 | + <u:style name="font-size" skin="headerSizeFont"/> | ||
104 | + <u:style name="color" skin="headerTextColor"/> | ||
105 | + <u:style name="font-family" skin="headerFamilyFont"/> | ||
106 | + <u:style name="background-image"> | ||
107 | + <f:resource f:key="org.richfaces.renderkit.html.GradientA"/> | ||
108 | + </u:style> | ||
109 | + <u:style name="font-weight" value="normal"/> | ||
110 | + <u:style name="color" skin="panelTextColor"/> | ||
111 | + <u:style name="-moz-border-radius-bottomleft" value="4px"/> | ||
112 | + <u:style name="-webkit-border-bottom-left-radius" value="4px"/> | ||
113 | + <u:style name="border-bottom-left-radius" value="4px"/> | ||
114 | + <u:style name="-moz-border-radius-bottomright" value="4px"/> | ||
115 | + <u:style name="-webkit-border-bottom-right-radius" value="4px"/> | ||
116 | + <u:style name="border-bottom-right-radius" value="4px"/> | ||
117 | + <u:style name="position" value="absolute"/> | ||
118 | + <u:style name="top" value="0"/> | ||
119 | + <u:style name="right" value="18px"/> | ||
120 | + <u:style name="width" value="70px"/> | ||
121 | + <u:style name="z-index" value="10000"/> | ||
122 | + </u:selector> | ||
123 | + <f:verbatim> | ||
124 | +.rf-ny-hc .rf-ny-hh { | ||
125 | + padding: 2px; | ||
126 | +} | ||
127 | +.rf-ny-hc button { | ||
128 | + cursor: pointer; | ||
129 | + display: block; | ||
130 | + width: 100%; | ||
131 | +} | ||
132 | +.rc-ny-ha { | ||
133 | + -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; | ||
134 | +} | ||
135 | + </f:verbatim> | ||
136 | + <u:selector name=".rf-ny-hc .rf-ny-hp"> | ||
137 | + <u:style name="display" value="block"/> | ||
138 | + <u:style name="margin" value="0 auto"/> | ||
139 | + <u:style name="width" value="16px"/> | ||
140 | + <u:style name="height" value="16px"/> | ||
141 | + <u:style name="background-color" skin="panelTextColor"/> | ||
142 | + <u:style name="background-image"> | ||
143 | + <f:resource f:key="org.richfaces.renderkit.html.images.TriangleIconDown"/> | ||
144 | + </u:style> | ||
145 | + </u:selector> | ||
146 | + <u:selector name=".rc-ny-hl"> | ||
147 | + <u:style name="border-color" skin="panelBorderColor"/> | ||
148 | + <u:style name="background-color" skin="generalBackgroundColor"/> | ||
149 | + <u:style name="font-weight" value="normal"/> | ||
150 | + <u:style name="color" skin="panelTextColor"/> | ||
151 | + <u:style name="-moz-border-radius" value="4px"/> | ||
152 | + <u:style name="-webkit-border-radius" value="4px"/> | ||
153 | + <u:style name="border-radius" value="4px"/> | ||
154 | + </u:selector> | ||
155 | + <u:selector name=".rf-ny-info .rf-ny-ic"> | ||
156 | + <u:style name="display" value="block"/> | ||
157 | + <u:style name="background-image"> | ||
158 | + <f:resource f:key="/org/richfaces/renderkit/html/images/info.png"/> | ||
159 | + </u:style> | ||
160 | + </u:selector> | ||
161 | + <u:selector name=".rf-ny-warn .rf-ny-ic"> | ||
162 | + <u:style name="display" value="block"/> | ||
163 | + <u:style name="background-image"> | ||
164 | + <f:resource f:key="/org/richfaces/renderkit/html/images/warn.png"/> | ||
165 | + </u:style> | ||
166 | + </u:selector> | ||
167 | + <u:selector name=".rf-ny-error .rf-ny-ic"> | ||
168 | + <u:style name="display" value="block"/> | ||
169 | + <u:style name="background-image"> | ||
170 | + <f:resource f:key="/org/richfaces/renderkit/html/images/error.png"/> | ||
171 | + </u:style> | ||
172 | + </u:selector> | ||
173 | + <u:selector name=".rf-ny-fatal .rf-ny-ic"> | ||
174 | + <u:style name="display" value="block"/> | ||
175 | + <u:style name="background-image"> | ||
176 | + <f:resource f:key="/org/richfaces/renderkit/html/images/fatal.png"/> | ||
177 | + </u:style> | ||
178 | + </u:selector> | ||
179 | +</f:template> |
1.97 KB
2.41 KB
4.49 KB
1.38 KB
This diff could not be displayed because it is too large.
1 | +/* | ||
2 | + * jQuery Pines Notify (pnotify) Plugin 1.0.0 | ||
3 | + * | ||
4 | + * Copyright (c) 2009 Hunter Perrin | ||
5 | + * | ||
6 | + * Licensed (along with all of Pines) under the GNU Affero GPL: | ||
7 | + * http://www.gnu.org/licenses/agpl.html | ||
8 | + */ | ||
9 | + | ||
10 | +(function($) { | ||
11 | + var history_handle_top, timer; | ||
12 | + var body; | ||
13 | + var jwindow; | ||
14 | + $.extend({ | ||
15 | + pnotify_remove_all: function () { | ||
16 | + var body_data = body.data("pnotify"); | ||
17 | + /* POA: Added null-check */ | ||
18 | + if (body_data && body_data.length) { | ||
19 | + $.each(body_data, function(){ | ||
20 | + if (this.pnotify_remove) | ||
21 | + this.pnotify_remove(); | ||
22 | + }); | ||
23 | + } | ||
24 | + }, | ||
25 | + pnotify_position_all: function () { | ||
26 | + if (timer) | ||
27 | + clearTimeout(timer); | ||
28 | + timer = null; | ||
29 | + var body_data = body.data("pnotify"); | ||
30 | + if (!body_data || !body_data.length) | ||
31 | + return; | ||
32 | + $.each(body_data, function(){ | ||
33 | + var s = this.opts.pnotify_stack; | ||
34 | + if (!s) return; | ||
35 | + if (!s.nextpos1) | ||
36 | + s.nextpos1 = s.firstpos1; | ||
37 | + if (!s.nextpos2) | ||
38 | + s.nextpos2 = s.firstpos2; | ||
39 | + if (!s.addpos2) | ||
40 | + s.addpos2 = 0; | ||
41 | + if (this.css("display") != "none") { | ||
42 | + var curpos1, curpos2; | ||
43 | + var animate = {}; | ||
44 | + // Calculate the current pos1 value. | ||
45 | + var csspos1; | ||
46 | + switch (s.dir1) { | ||
47 | + case "down": | ||
48 | + csspos1 = "top"; | ||
49 | + break; | ||
50 | + case "up": | ||
51 | + csspos1 = "bottom"; | ||
52 | + break; | ||
53 | + case "left": | ||
54 | + csspos1 = "right"; | ||
55 | + break; | ||
56 | + case "right": | ||
57 | + csspos1 = "left"; | ||
58 | + break; | ||
59 | + } | ||
60 | + curpos1 = parseInt(this.css(csspos1)); | ||
61 | + if (isNaN(curpos1)) | ||
62 | + curpos1 = 0; | ||
63 | + // Remember the first pos1, so the first visible notice goes there. | ||
64 | + if (typeof s.firstpos1 == "undefined") { | ||
65 | + s.firstpos1 = curpos1; | ||
66 | + s.nextpos1 = s.firstpos1; | ||
67 | + } | ||
68 | + // Calculate the current pos2 value. | ||
69 | + var csspos2; | ||
70 | + switch (s.dir2) { | ||
71 | + case "down": | ||
72 | + csspos2 = "top"; | ||
73 | + break; | ||
74 | + case "up": | ||
75 | + csspos2 = "bottom"; | ||
76 | + break; | ||
77 | + case "left": | ||
78 | + csspos2 = "right"; | ||
79 | + break; | ||
80 | + case "right": | ||
81 | + csspos2 = "left"; | ||
82 | + break; | ||
83 | + } | ||
84 | + curpos2 = parseInt(this.css(csspos2)); | ||
85 | + if (isNaN(curpos2)) | ||
86 | + curpos2 = 0; | ||
87 | + // Remember the first pos2, so the first visible notice goes there. | ||
88 | + if (typeof s.firstpos2 == "undefined") { | ||
89 | + s.firstpos2 = curpos2; | ||
90 | + s.nextpos2 = s.firstpos2; | ||
91 | + } | ||
92 | + // Check that it's not beyond the viewport edge. | ||
93 | + if ((s.dir1 == "down" && s.nextpos1 + this.height() > jwindow.height()) || | ||
94 | + (s.dir1 == "up" && s.nextpos1 + this.height() > jwindow.height()) || | ||
95 | + (s.dir1 == "left" && s.nextpos1 + this.width() > jwindow.width()) || | ||
96 | + (s.dir1 == "right" && s.nextpos1 + this.width() > jwindow.width()) ) { | ||
97 | + // If it is, it needs to go back to the first pos1, and over on pos2. | ||
98 | + s.nextpos1 = s.firstpos1; | ||
99 | + s.nextpos2 += s.addpos2 + 10; | ||
100 | + s.addpos2 = 0; | ||
101 | + } | ||
102 | + // Animate if we're moving on dir2. | ||
103 | + if (s.animation && s.nextpos2 < curpos2) { | ||
104 | + switch (s.dir2) { | ||
105 | + case "down": | ||
106 | + animate.top = s.nextpos2+"px"; | ||
107 | + break; | ||
108 | + case "up": | ||
109 | + animate.bottom = s.nextpos2+"px"; | ||
110 | + break; | ||
111 | + case "left": | ||
112 | + animate.right = s.nextpos2+"px"; | ||
113 | + break; | ||
114 | + case "right": | ||
115 | + animate.left = s.nextpos2+"px"; | ||
116 | + break; | ||
117 | + } | ||
118 | + } else | ||
119 | + this.css(csspos2, s.nextpos2+"px"); | ||
120 | + // Keep track of the widest/tallest notice in the column/row, so we can push the next column/row. | ||
121 | + switch (s.dir2) { | ||
122 | + case "down": | ||
123 | + case "up": | ||
124 | + if (this.outerHeight(true) > s.addpos2) | ||
125 | + s.addpos2 = this.height(); | ||
126 | + break; | ||
127 | + case "left": | ||
128 | + case "right": | ||
129 | + if (this.outerWidth(true) > s.addpos2) | ||
130 | + s.addpos2 = this.width(); | ||
131 | + break; | ||
132 | + } | ||
133 | + // Move the notice on dir1. | ||
134 | + if (s.nextpos1) { | ||
135 | + // Animate if we're moving toward the first pos. | ||
136 | + if (s.animation && (curpos1 > s.nextpos1 || animate.top || animate.bottom || animate.right || animate.left)) { | ||
137 | + switch (s.dir1) { | ||
138 | + case "down": | ||
139 | + animate.top = s.nextpos1+"px"; | ||
140 | + break; | ||
141 | + case "up": | ||
142 | + animate.bottom = s.nextpos1+"px"; | ||
143 | + break; | ||
144 | + case "left": | ||
145 | + animate.right = s.nextpos1+"px"; | ||
146 | + break; | ||
147 | + case "right": | ||
148 | + animate.left = s.nextpos1+"px"; | ||
149 | + break; | ||
150 | + } | ||
151 | + } else | ||
152 | + this.css(csspos1, s.nextpos1+"px"); | ||
153 | + } | ||
154 | + if (animate.top || animate.bottom || animate.right || animate.left) | ||
155 | + this.animate(animate, {duration: 500, queue: false}); | ||
156 | + // Calculate the next dir1 position. | ||
157 | + switch (s.dir1) { | ||
158 | + case "down": | ||
159 | + case "up": | ||
160 | + s.nextpos1 += this.height() + 10; | ||
161 | + break; | ||
162 | + case "left": | ||
163 | + case "right": | ||
164 | + s.nextpos1 += this.width() + 10; | ||
165 | + break; | ||
166 | + } | ||
167 | + } | ||
168 | + }); | ||
169 | + // Reset the next position data. | ||
170 | + $.each(body_data, function(){ | ||
171 | + var s = this.opts.pnotify_stack; | ||
172 | + if (!s) return; | ||
173 | + s.nextpos1 = s.firstpos1; | ||
174 | + s.nextpos2 = s.firstpos2; | ||
175 | + s.addpos2 = 0; | ||
176 | + s.animation = true; | ||
177 | + }); | ||
178 | + }, | ||
179 | + pnotify: function(options) { | ||
180 | + if (!body) | ||
181 | + body = $("body"); | ||
182 | + if (!jwindow) | ||
183 | + jwindow = $(window); | ||
184 | + | ||
185 | + var animating; | ||
186 | + | ||
187 | + // Build main options. | ||
188 | + var opts; | ||
189 | + if (typeof options != "object") { | ||
190 | + opts = $.extend({}, $.pnotify.defaults); | ||
191 | + opts.pnotify_text = options; | ||
192 | + } else { | ||
193 | + opts = $.extend({}, $.pnotify.defaults, options); | ||
194 | + } | ||
195 | + | ||
196 | + if (opts.pnotify_before_init) { | ||
197 | + if (opts.pnotify_before_init(opts) === false) | ||
198 | + return null; | ||
199 | + } | ||
200 | + | ||
201 | + // This keeps track of the last element the mouse was over, so | ||
202 | + // mouseleave, mouseenter, etc can be called. | ||
203 | + var nonblock_last_elem; | ||
204 | + // This is used to pass events through the notice if it is non-blocking. | ||
205 | + var nonblock_pass = function(e, e_name){ | ||
206 | + pnotify.css("display", "none"); | ||
207 | + var element_below = document.elementFromPoint(e.clientX, e.clientY); | ||
208 | + pnotify.css("display", "block"); | ||
209 | + var jelement_below = $(element_below); | ||
210 | + var cursor_style = jelement_below.css("cursor"); | ||
211 | + pnotify.css("cursor", cursor_style != "auto" ? cursor_style : "default"); | ||
212 | + // If the element changed, call mouseenter, mouseleave, etc. | ||
213 | + if (!nonblock_last_elem || nonblock_last_elem.get(0) != element_below) { | ||
214 | + if (nonblock_last_elem) { | ||
215 | + dom_event.call(nonblock_last_elem.get(0), "mouseleave", e.originalEvent); | ||
216 | + dom_event.call(nonblock_last_elem.get(0), "mouseout", e.originalEvent); | ||
217 | + } | ||
218 | + dom_event.call(element_below, "mouseenter", e.originalEvent); | ||
219 | + dom_event.call(element_below, "mouseover", e.originalEvent); | ||
220 | + } | ||
221 | + dom_event.call(element_below, e_name, e.originalEvent); | ||
222 | + // Remember the latest element the mouse was over. | ||
223 | + nonblock_last_elem = jelement_below; | ||
224 | + }; | ||
225 | + | ||
226 | + // Create our widget. | ||
227 | + // Stop animation, reset the removal timer, and show the close | ||
228 | + // button when the user mouses over. | ||
229 | + var pnotify = $("<div />", { | ||
230 | + "class": "rf-ny "+opts.pnotify_addclass, | ||
231 | + "css": {"display": "none"}, | ||
232 | + "mouseenter": function(e){ | ||
233 | + if (opts.pnotify_nonblock) e.stopPropagation(); | ||
234 | + if (opts.pnotify_mouse_reset && animating == "out") { | ||
235 | + // If it's animating out, animate back in really quick. | ||
236 | + pnotify.stop(true); | ||
237 | + pnotify.css("height", "auto").animate({"width": opts.pnotify_width, "opacity": opts.pnotify_nonblock ? opts.pnotify_nonblock_opacity : opts.pnotify_opacity}, "fast"); | ||
238 | + } else if (opts.pnotify_nonblock && animating != "out") { | ||
239 | + // If it's non-blocking, animate to the other opacity. | ||
240 | + pnotify.animate({"opacity": opts.pnotify_nonblock_opacity}, "fast"); | ||
241 | + } | ||
242 | + if (opts.pnotify_hide && opts.pnotify_mouse_reset) pnotify.pnotify_cancel_remove(); | ||
243 | + if (opts.pnotify_closer && !opts.pnotify_nonblock) pnotify.closer.show(); | ||
244 | + }, | ||
245 | + "mouseleave": function(e){ | ||
246 | + if (opts.pnotify_nonblock) e.stopPropagation(); | ||
247 | + nonblock_last_elem = null; | ||
248 | + pnotify.css("cursor", "auto"); | ||
249 | + if (opts.pnotify_nonblock && animating != "out") | ||
250 | + pnotify.animate({"opacity": opts.pnotify_opacity}, "fast"); | ||
251 | + if (opts.pnotify_hide && opts.pnotify_mouse_reset) pnotify.pnotify_queue_remove(); | ||
252 | + pnotify.closer.hide(); | ||
253 | + $.pnotify_position_all(); | ||
254 | + }, | ||
255 | + "mouseover": function(e){ | ||
256 | + if (opts.pnotify_nonblock) e.stopPropagation(); | ||
257 | + }, | ||
258 | + "mouseout": function(e){ | ||
259 | + if (opts.pnotify_nonblock) e.stopPropagation(); | ||
260 | + }, | ||
261 | + "mousemove": function(e){ | ||
262 | + if (opts.pnotify_nonblock) { | ||
263 | + e.stopPropagation(); | ||
264 | + nonblock_pass(e, "onmousemove"); | ||
265 | + } | ||
266 | + }, | ||
267 | + "mousedown": function(e){ | ||
268 | + if (opts.pnotify_nonblock) { | ||
269 | + e.stopPropagation(); | ||
270 | + e.preventDefault(); | ||
271 | + nonblock_pass(e, "onmousedown"); | ||
272 | + } | ||
273 | + }, | ||
274 | + "mouseup": function(e){ | ||
275 | + if (opts.pnotify_nonblock) { | ||
276 | + e.stopPropagation(); | ||
277 | + e.preventDefault(); | ||
278 | + nonblock_pass(e, "onmouseup"); | ||
279 | + } | ||
280 | + }, | ||
281 | + "click": function(e){ | ||
282 | + if (opts.pnotify_nonblock) { | ||
283 | + e.stopPropagation(); | ||
284 | + nonblock_pass(e, "onclick"); | ||
285 | + } | ||
286 | + }, | ||
287 | + "dblclick": function(e){ | ||
288 | + if (opts.pnotify_nonblock) { | ||
289 | + e.stopPropagation(); | ||
290 | + nonblock_pass(e, "ondblclick"); | ||
291 | + } | ||
292 | + } | ||
293 | + }); | ||
294 | + pnotify.opts = opts; | ||
295 | + // Create a drop shadow. | ||
296 | + if (opts.pnotify_shadow && !$.browser.msie) | ||
297 | + pnotify.shadow_container = $("<div />", {"class": "rf-ny-sh"}).prependTo(pnotify); | ||
298 | + // Create a container for the notice contents. | ||
299 | + pnotify.container = $("<div />", {"class": "rf-ny-co"}) | ||
300 | + .appendTo(pnotify); | ||
301 | + | ||
302 | + pnotify.pnotify_version = "1.0.0"; | ||
303 | + | ||
304 | + // This function is for updating the notice. | ||
305 | + pnotify.pnotify = function(options) { | ||
306 | + // Update the notice. | ||
307 | + var old_opts = opts; | ||
308 | + if (typeof options == "string") | ||
309 | + opts.pnotify_text = options; | ||
310 | + else | ||
311 | + opts = $.extend({}, opts, options); | ||
312 | + pnotify.opts = opts; | ||
313 | + // Update the shadow. | ||
314 | + if (opts.pnotify_shadow != old_opts.pnotify_shadow) { | ||
315 | + if (opts.pnotify_shadow && !$.browser.msie) | ||
316 | + pnotify.shadow_container = $("<div />", {"class": "rf-ny-sh"}).prependTo(pnotify); | ||
317 | + else | ||
318 | + pnotify.children(".rf-ny-sh").remove(); | ||
319 | + } | ||
320 | + // Update the additional classes. | ||
321 | + if (opts.pnotify_addclass === false) | ||
322 | + pnotify.removeClass(old_opts.pnotify_addclass); | ||
323 | + else if (opts.pnotify_addclass !== old_opts.pnotify_addclass) | ||
324 | + pnotify.removeClass(old_opts.pnotify_addclass).addClass(opts.pnotify_addclass); | ||
325 | + // Update the title. | ||
326 | + if (opts.pnotify_title === false) | ||
327 | + pnotify.title_container.hide("fast"); | ||
328 | + else if (opts.pnotify_title !== old_opts.pnotify_title) | ||
329 | + pnotify.title_container.html(opts.pnotify_title).show(200); | ||
330 | + // Update the text. | ||
331 | + if (opts.pnotify_text === false) { | ||
332 | + pnotify.text_container.hide("fast"); | ||
333 | + } else if (opts.pnotify_text !== old_opts.pnotify_text) { | ||
334 | + if (opts.pnotify_insert_brs) | ||
335 | + opts.pnotify_text = opts.pnotify_text.replace(/\n/g, "<br />"); | ||
336 | + pnotify.text_container.html(opts.pnotify_text).show(200); | ||
337 | + } | ||
338 | + pnotify.pnotify_history = opts.pnotify_history; | ||
339 | + // Change the notice type. | ||
340 | + if (opts.pnotify_type != old_opts.pnotify_type) | ||
341 | + pnotify.container.toggleClass("rf-ny-co rf-ny-co-hover"); | ||
342 | + if ((opts.pnotify_notice_icon != old_opts.pnotify_notice_icon && opts.pnotify_type == "notice") || | ||
343 | + (opts.pnotify_error_icon != old_opts.pnotify_error_icon && opts.pnotify_type == "error") || | ||
344 | + (opts.pnotify_type != old_opts.pnotify_type)) { | ||
345 | + // Remove any old icon. | ||
346 | + pnotify.container.find("div.rf-ny-ic").remove(); | ||
347 | +// if ((opts.pnotify_error_icon && opts.pnotify_type == "error") || (opts.pnotify_notice_icon)) { | ||
348 | + // Build the new icon. | ||
349 | + $("<div />", {"class": "rf-ny-ic"}) | ||
350 | + .append($("<span />", {"class": opts.pnotify_type == "error" ? opts.pnotify_error_icon : opts.pnotify_notice_icon})) | ||
351 | + .prependTo(pnotify.container); | ||
352 | +// } | ||
353 | + } | ||
354 | + // Update the width. | ||
355 | + if (opts.pnotify_width !== old_opts.pnotify_width) | ||
356 | + pnotify.animate({width: opts.pnotify_width}); | ||
357 | + // Update the minimum height. | ||
358 | + if (opts.pnotify_min_height !== old_opts.pnotify_min_height) | ||
359 | + pnotify.container.animate({minHeight: opts.pnotify_min_height}); | ||
360 | + // Update the opacity. | ||
361 | + if (opts.pnotify_opacity !== old_opts.pnotify_opacity) | ||
362 | + pnotify.fadeTo(opts.pnotify_animate_speed, opts.pnotify_opacity); | ||
363 | + if (!opts.pnotify_hide) | ||
364 | + pnotify.pnotify_cancel_remove(); | ||
365 | + else if (!old_opts.pnotify_hide) | ||
366 | + pnotify.pnotify_queue_remove(); | ||
367 | + pnotify.pnotify_queue_position(); | ||
368 | + return pnotify; | ||
369 | + }; | ||
370 | + | ||
371 | + // Queue the position function so it doesn't run repeatedly and use | ||
372 | + // up resources. | ||
373 | + pnotify.pnotify_queue_position = function() { | ||
374 | + if (timer) | ||
375 | + clearTimeout(timer); | ||
376 | + timer = setTimeout($.pnotify_position_all, 10); | ||
377 | + }; | ||
378 | + | ||
379 | + // Display the notice. | ||
380 | + pnotify.pnotify_display = function() { | ||
381 | + // If the notice is not in the DOM, append it. | ||
382 | + if (!pnotify.parent().length) | ||
383 | + pnotify.appendTo(body); | ||
384 | + // Run callback. | ||
385 | + if (opts.pnotify_before_open) { | ||
386 | + if (opts.pnotify_before_open(pnotify) === false) | ||
387 | + return; | ||
388 | + } | ||
389 | + pnotify.pnotify_queue_position(); | ||
390 | + // First show it, then set its opacity, then hide it. | ||
391 | + if (opts.pnotify_animation == "fade" || opts.pnotify_animation.effect_in == "fade") { | ||
392 | + // If it's fading in, it should start at 0. | ||
393 | + pnotify.show().fadeTo(0, 0).hide(); | ||
394 | + } else { | ||
395 | + // Or else it should be set to the opacity. | ||
396 | + if (opts.pnotify_opacity != 1) | ||
397 | + pnotify.show().fadeTo(0, opts.pnotify_opacity).hide(); | ||
398 | + } | ||
399 | + pnotify.animate_in(function(){ | ||
400 | + if (opts.pnotify_after_open) | ||
401 | + opts.pnotify_after_open(pnotify); | ||
402 | + | ||
403 | + pnotify.pnotify_queue_position(); | ||
404 | + | ||
405 | + // Now set it to hide. | ||
406 | + if (opts.pnotify_hide) | ||
407 | + pnotify.pnotify_queue_remove(); | ||
408 | + }); | ||
409 | + }; | ||
410 | + | ||
411 | + // Remove the notice. | ||
412 | + pnotify.pnotify_remove = function() { | ||
413 | + if (pnotify.timer) { | ||
414 | + window.clearTimeout(pnotify.timer); | ||
415 | + pnotify.timer = null; | ||
416 | + } | ||
417 | + // Run callback. | ||
418 | + if (opts.pnotify_before_close) { | ||
419 | + if (opts.pnotify_before_close(pnotify) === false) | ||
420 | + return; | ||
421 | + } | ||
422 | + pnotify.animate_out(function(){ | ||
423 | + if (opts.pnotify_after_close) { | ||
424 | + if (opts.pnotify_after_close(pnotify) === false) | ||
425 | + return; | ||
426 | + } | ||
427 | + pnotify.pnotify_queue_position(); | ||
428 | + // If we're supposed to remove the notice from the DOM, do it. | ||
429 | + if (opts.pnotify_remove) | ||
430 | + pnotify.detach(); | ||
431 | + }); | ||
432 | + }; | ||
433 | + | ||
434 | + // Animate the notice in. | ||
435 | + pnotify.animate_in = function(callback){ | ||
436 | + // Declare that the notice is animating in. (Or has completed animating in.) | ||
437 | + animating = "in"; | ||
438 | + var animation; | ||
439 | + if (typeof opts.pnotify_animation.effect_in != "undefined") | ||
440 | + animation = opts.pnotify_animation.effect_in; | ||
441 | + else | ||
442 | + animation = opts.pnotify_animation; | ||
443 | + if (animation == "none") { | ||
444 | + pnotify.show(); | ||
445 | + callback(); | ||
446 | + } else if (animation == "show") | ||
447 | + pnotify.show(opts.pnotify_animate_speed, callback); | ||
448 | + else if (animation == "fade") | ||
449 | + pnotify.show().fadeTo(opts.pnotify_animate_speed, opts.pnotify_opacity, callback); | ||
450 | + else if (animation == "slide") | ||
451 | + pnotify.slideDown(opts.pnotify_animate_speed, callback); | ||
452 | + else if (typeof animation == "function") | ||
453 | + animation("in", callback, pnotify); | ||
454 | + else if (pnotify.effect) | ||
455 | + pnotify.effect(animation, {}, opts.pnotify_animate_speed, callback); | ||
456 | + }; | ||
457 | + | ||
458 | + // Animate the notice out. | ||
459 | + pnotify.animate_out = function(callback){ | ||
460 | + // Declare that the notice is animating out. (Or has completed animating out.) | ||
461 | + animating = "out"; | ||
462 | + var animation; | ||
463 | + if (typeof opts.pnotify_animation.effect_out != "undefined") | ||
464 | + animation = opts.pnotify_animation.effect_out; | ||
465 | + else | ||
466 | + animation = opts.pnotify_animation; | ||
467 | + if (animation == "none") { | ||
468 | + pnotify.hide(); | ||
469 | + callback(); | ||
470 | + } else if (animation == "show") | ||
471 | + pnotify.hide(opts.pnotify_animate_speed, callback); | ||
472 | + else if (animation == "fade") | ||
473 | + pnotify.fadeOut(opts.pnotify_animate_speed, callback); | ||
474 | + else if (animation == "slide") | ||
475 | + pnotify.slideUp(opts.pnotify_animate_speed, callback); | ||
476 | + else if (typeof animation == "function") | ||
477 | + animation("out", callback, pnotify); | ||
478 | + else if (pnotify.effect) | ||
479 | + pnotify.effect(animation, {}, opts.pnotify_animate_speed, callback); | ||
480 | + }; | ||
481 | + | ||
482 | + // Cancel any pending removal timer. | ||
483 | + pnotify.pnotify_cancel_remove = function() { | ||
484 | + if (pnotify.timer) | ||
485 | + window.clearTimeout(pnotify.timer); | ||
486 | + }; | ||
487 | + | ||
488 | + // Queue a removal timer. | ||
489 | + pnotify.pnotify_queue_remove = function() { | ||
490 | + // Cancel any current removal timer. | ||
491 | + pnotify.pnotify_cancel_remove(); | ||
492 | + pnotify.timer = window.setTimeout(function(){ | ||
493 | + pnotify.pnotify_remove(); | ||
494 | + }, (isNaN(opts.pnotify_delay) ? 0 : opts.pnotify_delay)); | ||
495 | + }; | ||
496 | + | ||
497 | + // Provide a button to close the notice. | ||
498 | + pnotify.closer = $("<div />", { | ||
499 | + "class": "rf-ny-cl", | ||
500 | + "css": {"cursor": "pointer", "display": "none"}, | ||
501 | + "click": function(){ | ||
502 | + pnotify.pnotify_remove(); | ||
503 | + pnotify.closer.hide(); | ||
504 | + } | ||
505 | + }) | ||
506 | + .append($("<span />", {"class": "rf-ny-cl-ic"})) | ||
507 | + .appendTo(pnotify.container); | ||
508 | + | ||
509 | + // Add the appropriate icon. | ||
510 | +// if ((opts.pnotify_error_icon && opts.pnotify_type == "error") || (opts.pnotify_notice_icon)) { | ||
511 | + $("<div />", {"class": "rf-ny-ic"}) | ||
512 | + .append($("<span />", {"class": opts.pnotify_type == "error" ? opts.pnotify_error_icon : opts.pnotify_notice_icon})) | ||
513 | + .appendTo(pnotify.container); | ||
514 | +// } | ||
515 | + | ||
516 | + // Add a title. | ||
517 | + pnotify.title_container = $("<div />", { | ||
518 | + "class": "rf-ny-tl", | ||
519 | + "html": opts.pnotify_title | ||
520 | + }) | ||
521 | + .appendTo(pnotify.container); | ||
522 | + if (opts.pnotify_title === false) | ||
523 | + pnotify.title_container.hide(); | ||
524 | + | ||
525 | + // Replace new lines with HTML line breaks. | ||
526 | + if (opts.pnotify_insert_brs && typeof opts.pnotify_text == "string") | ||
527 | + opts.pnotify_text = opts.pnotify_text.replace(/\n/g, "<br />"); | ||
528 | + // Add text. | ||
529 | + pnotify.text_container = $("<div />", { | ||
530 | + "class": "rf-ny-te", | ||
531 | + "html": opts.pnotify_text | ||
532 | + }) | ||
533 | + .appendTo(pnotify.container); | ||
534 | + if (opts.pnotify_text === false) | ||
535 | + pnotify.text_container.hide(); | ||
536 | + | ||
537 | + // Set width and min height. | ||
538 | + if (typeof opts.pnotify_width == "string") | ||
539 | + pnotify.css("width", opts.pnotify_width); | ||
540 | + if (typeof opts.pnotify_min_height == "string") | ||
541 | + pnotify.container.css("min-height", opts.pnotify_min_height); | ||
542 | + | ||
543 | + // The history variable controls whether the notice gets redisplayed | ||
544 | + // by the history pull down. | ||
545 | + pnotify.pnotify_history = opts.pnotify_history; | ||
546 | + | ||
547 | + // Add the notice to the notice array. | ||
548 | + var body_data = body.data("pnotify"); | ||
549 | + if (body_data == null || typeof body_data != "object") | ||
550 | + body_data = []; | ||
551 | + if (opts.pnotify_stack.push == "top") | ||
552 | + body_data = $.merge([pnotify], body_data); | ||
553 | + else | ||
554 | + body_data = $.merge(body_data, [pnotify]); | ||
555 | + body.data("pnotify", body_data); | ||
556 | + | ||
557 | + // Run callback. | ||
558 | + if (opts.pnotify_after_init) | ||
559 | + opts.pnotify_after_init(pnotify); | ||
560 | + | ||
561 | + if (opts.pnotify_history) { | ||
562 | + // If there isn't a history pull down, create one. | ||
563 | + var body_history = body.data("pnotify_history"); | ||
564 | + if (typeof body_history == "undefined") { | ||
565 | + body_history = $("<div />", { | ||
566 | + "class": "rf-ny-hc", | ||
567 | + "mouseleave": function(){ | ||
568 | + body_history.animate({top: "-"+history_handle_top+"px"}, {duration: 100, queue: false}); | ||
569 | + } | ||
570 | + }) | ||
571 | + .append($("<div />", {"class": "rf-ny-hh", "text": "Redisplay"})) | ||
572 | + .append($("<button />", { | ||
573 | + "class": "rf-ny-ha", | ||
574 | + "text": "All", | ||
575 | +// "mouseenter": function(){ | ||
576 | +// $(this).addClass("ui-state-hover"); | ||
577 | +// }, | ||
578 | +// "mouseleave": function(){ | ||
579 | +// $(this).removeClass("ui-state-hover"); | ||
580 | +// }, | ||
581 | + "click": function(){ | ||
582 | + // Display all notices. (Disregarding non-history notices.) | ||
583 | + $.each(body.data("pnotify"), function(){ | ||
584 | + if (this.pnotify_history && this.pnotify_display) | ||
585 | + this.pnotify_display(); | ||
586 | + }); | ||
587 | + return false; | ||
588 | + } | ||
589 | + })) | ||
590 | + .append($("<button />", { | ||
591 | + "class": "rf-ny-hl", | ||
592 | + "text": "Last", | ||
593 | +// "mouseenter": function(){ | ||
594 | +// $(this).addClass("ui-state-hover"); | ||
595 | +// }, | ||
596 | +// "mouseleave": function(){ | ||
597 | +// $(this).removeClass("ui-state-hover"); | ||
598 | +// }, | ||
599 | + "click": function(){ | ||
600 | + // Look up the last history notice, and display it. | ||
601 | + var i = 1; | ||
602 | + var body_data = body.data("pnotify"); | ||
603 | + while (!body_data[body_data.length - i] || !body_data[body_data.length - i].pnotify_history || body_data[body_data.length - i].is(":visible")) { | ||
604 | + if (body_data.length - i === 0) | ||
605 | + return false; | ||
606 | + i++; | ||
607 | + } | ||
608 | + var n = body_data[body_data.length - i]; | ||
609 | + if (n.pnotify_display) | ||
610 | + n.pnotify_display(); | ||
611 | + return false; | ||
612 | + } | ||
613 | + })) | ||
614 | + .appendTo(body); | ||
615 | + | ||
616 | + // Make a handle so the user can pull down the history pull down. | ||
617 | + var handle = $("<span />", { | ||
618 | + "class": "rf-ny-hp", | ||
619 | + "mouseenter": function(){ | ||
620 | + body_history.animate({top: "0"}, {duration: 100, queue: false}); | ||
621 | + } | ||
622 | + }) | ||
623 | + .appendTo(body_history); | ||
624 | + | ||
625 | + // Get the top of the handle. | ||
626 | + history_handle_top = handle.offset().top + 2; | ||
627 | + // Hide the history pull down up to the top of the handle. | ||
628 | + body_history.css({top: "-"+history_handle_top+"px"}); | ||
629 | + // Save the history pull down. | ||
630 | + body.data("pnotify_history", body_history); | ||
631 | + } | ||
632 | + } | ||
633 | + | ||
634 | + // Mark the stack so it won't animate the new notice. | ||
635 | + opts.pnotify_stack.animation = false; | ||
636 | + | ||
637 | + // Display the notice. | ||
638 | + pnotify.pnotify_display(); | ||
639 | + | ||
640 | + return pnotify; | ||
641 | + } | ||
642 | + }); | ||
643 | + | ||
644 | + // Some useful regexes. | ||
645 | + var re_on = /^on/; | ||
646 | + var re_mouse_events = /^(dbl)?click$|^mouse(move|down|up|over|out|enter|leave)$|^contextmenu$/; | ||
647 | + var re_ui_events = /^(focus|blur|select|change|reset)$|^key(press|down|up)$/; | ||
648 | + var re_html_events = /^(scroll|resize|(un)?load|abort|error)$/; | ||
649 | + // Fire a DOM event. | ||
650 | + var dom_event = function(e, orig_e){ | ||
651 | + var event_object; | ||
652 | + e = e.toLowerCase(); | ||
653 | + if (document.createEvent && this.dispatchEvent) { | ||
654 | + // FireFox, Opera, Safari, Chrome | ||
655 | + e = e.replace(re_on, ''); | ||
656 | + if (e.match(re_mouse_events)) { | ||
657 | + // This allows the click event to fire on the notice. There is | ||
658 | + // probably a much better way to do it. | ||
659 | + $(this).offset(); | ||
660 | + event_object = document.createEvent("MouseEvents"); | ||
661 | + event_object.initMouseEvent( | ||
662 | + e, orig_e.bubbles, orig_e.cancelable, orig_e.view, orig_e.detail, | ||
663 | + orig_e.screenX, orig_e.screenY, orig_e.clientX, orig_e.clientY, | ||
664 | + orig_e.ctrlKey, orig_e.altKey, orig_e.shiftKey, orig_e.metaKey, orig_e.button, orig_e.relatedTarget | ||
665 | + ); | ||
666 | + } else if (e.match(re_ui_events)) { | ||
667 | + event_object = document.createEvent("UIEvents"); | ||
668 | + event_object.initUIEvent(e, orig_e.bubbles, orig_e.cancelable, orig_e.view, orig_e.detail); | ||
669 | + } else if (e.match(re_html_events)) { | ||
670 | + event_object = document.createEvent("HTMLEvents"); | ||
671 | + event_object.initEvent(e, orig_e.bubbles, orig_e.cancelable); | ||
672 | + } | ||
673 | + if (!event_object) return; | ||
674 | + this.dispatchEvent(event_object); | ||
675 | + } else { | ||
676 | + // Internet Explorer | ||
677 | + if (!e.match(re_on)) e = "on"+e; | ||
678 | + event_object = document.createEventObject(orig_e); | ||
679 | + this.fireEvent(e, event_object); | ||
680 | + } | ||
681 | + }; | ||
682 | + | ||
683 | + $.pnotify.defaults = { | ||
684 | + // The notice's title. | ||
685 | + pnotify_title: false, | ||
686 | + // The notice's text. | ||
687 | + pnotify_text: false, | ||
688 | + // Additional classes to be added to the notice. (For custom styling.) | ||
689 | + pnotify_addclass: "", | ||
690 | + // Create a non-blocking notice. It lets the user click elements underneath it. | ||
691 | + pnotify_nonblock: false, | ||
692 | + // The opacity of the notice (if it's non-blocking) when the mouse is over it. | ||
693 | + pnotify_nonblock_opacity: .2, | ||
694 | + // Display a pull down menu to redisplay previous notices, and place the notice in the history. | ||
695 | + pnotify_history: true, | ||
696 | + // Width of the notice. | ||
697 | + pnotify_width: "300px", | ||
698 | + // Minimum height of the notice. It will expand to fit content. | ||
699 | + pnotify_min_height: "16px", | ||
700 | + // Type of the notice. "notice" or "error". | ||
701 | + pnotify_type: "notice", | ||
702 | + // The icon class to use if type is notice. | ||
703 | + pnotify_notice_icon: "", | ||
704 | + // The icon class to use if type is error. | ||
705 | + pnotify_error_icon: "", | ||
706 | + // The animation to use when displaying and hiding the notice. "none", "show", "fade", and "slide" are built in to jQuery. Others require jQuery UI. Use an object with effect_in and effect_out to use different effects. | ||
707 | + pnotify_animation: "fade", | ||
708 | + // Speed at which the notice animates in and out. "slow", "def" or "normal", "fast" or number of milliseconds. | ||
709 | + pnotify_animate_speed: "slow", | ||
710 | + // Opacity of the notice. | ||
711 | + pnotify_opacity: 1, | ||
712 | + // Display a drop shadow. | ||
713 | + pnotify_shadow: false, | ||
714 | + // Provide a button for the user to manually close the notice. | ||
715 | + pnotify_closer: true, | ||
716 | + // After a delay, remove the notice. | ||
717 | + pnotify_hide: true, | ||
718 | + // Delay in milliseconds before the notice is removed. | ||
719 | + pnotify_delay: 8000, | ||
720 | + // Reset the hide timer if the mouse moves over the notice. | ||
721 | + pnotify_mouse_reset: true, | ||
722 | + // Remove the notice's elements from the DOM after it is removed. | ||
723 | + pnotify_remove: true, | ||
724 | + // Change new lines to br tags. | ||
725 | + pnotify_insert_brs: true, | ||
726 | + // The stack on which the notices will be placed. Also controls the direction the notices stack. | ||
727 | + pnotify_stack: {"dir1": "down", "dir2": "left", "push": "bottom"} | ||
728 | + }; | ||
729 | +})(jQuery); |
1 | +window.RichFaces = window.RichFaces || {}; | ||
2 | +RichFaces.NotifyStack = (function(){ | ||
3 | + var stacks = {}; | ||
4 | + return { | ||
5 | + register: function(id,stack) { | ||
6 | + var existingStack = stacks[id]; | ||
7 | + if(existingStack != null) { | ||
8 | + stack = jQuery.extend(existingStack,stack); | ||
9 | + delete stack.addpos1; | ||
10 | + delete stack.addpos2; | ||
11 | + delete stack.animation; | ||
12 | + delete stack.firstpos1; | ||
13 | + delete stack.firstpos2; | ||
14 | + delete stack.nextpos1; | ||
15 | + delete stack.nextpos2; | ||
16 | + } | ||
17 | + stacks[id] = stack; | ||
18 | + }, | ||
19 | + getStack: function(id) { | ||
20 | + var stack = stacks[id]; | ||
21 | + if(stack == null) { | ||
22 | + stack = {}; | ||
23 | + stacks[id] = stack; | ||
24 | + } | ||
25 | + return stack; | ||
26 | + } | ||
27 | + } | ||
28 | +})(); | ||
29 | + | ||
30 | +RichFaces.Notify = function(options) { | ||
31 | + if(options!=null && typeof options.pnotify_stack == "string") { | ||
32 | + options.pnotify_stack = RichFaces.NotifyStack.getStack(options.pnotify_stack); | ||
33 | + } | ||
34 | + jQuery(document).ready(function() { | ||
35 | + if(options.delay) { | ||
36 | + setTimeout(function(){ | ||
37 | + jQuery.pnotify(options); | ||
38 | + },options.delay); | ||
39 | + } else { | ||
40 | + jQuery.pnotify(options); | ||
41 | + } | ||
42 | + }); | ||
43 | +} |
src/main/templates/notify.jspx
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<f:root | ||
3 | + xmlns:f="http://jsf.exadel.com/template" | ||
4 | + xmlns:vcp=" http://jsf.exadel.com/vcp" | ||
5 | + xmlns:ui=" http://jsf.exadel.com/ui" | ||
6 | + xmlns:x=" http://jsf.exadel.com/vcp" | ||
7 | + xmlns:u="http://jsf.exadel.com/util" | ||
8 | + xmlns:h="http://jsf.exadel.com/header" | ||
9 | + component="org.richfaces.component.UINotify" | ||
10 | + baseclass="org.ajax4jsf.renderkit.HeaderResourcesRendererBase" | ||
11 | + class="org.richfaces.renderkit.html.NotifyRenderer"> | ||
12 | + <jsp:directive.page import="javax.faces.application.FacesMessage"/> | ||
13 | + | ||
14 | + <h:scripts>/org/richfaces/renderkit/html/scripts/jquery-1.4.2.js, | ||
15 | + /org/richfaces/renderkit/html/scripts/jquery.pnotify.js</h:scripts> | ||
16 | + <h:styles>/org/richfaces/renderkit/html/css/jquery.pnotify.xcss</h:styles> | ||
17 | + <f:clientid var="clientId"/> | ||
18 | + <div id="#{clientId}"> | ||
19 | + <jsp:scriptlet> | ||
20 | +<![CDATA[ | ||
21 | + variables.setVariable("details",component.getDetails()); | ||
22 | + variables.setVariable("summary",component.getSummary()); | ||
23 | + variables.setVariable("showHistory",component.isShowHistory()); | ||
24 | + variables.setVariable("nonblocking",component.isNonblocking()); | ||
25 | + variables.setVariable("shadow",component.isShowShadow()); | ||
26 | + variables.setVariable("closeButton",component.isShowCloseButton()); | ||
27 | + variables.setVariable("nonblockingOpacity",component.getNonblockingOpacity()); | ||
28 | + variables.setVariable("appearAnimation",component.getAppearAnimation()); | ||
29 | + variables.setVariable("hideAnimation",component.getHideAnimation()); | ||
30 | + variables.setVariable("animationSpeed",component.getAnimationSpeed()); | ||
31 | + variables.setVariable("stackDirVertical",component.getStackDirVertical()); | ||
32 | + variables.setVariable("stackDirHorizontal",component.getStackDirHorizontal()); | ||
33 | + variables.setVariable("stackPush",component.getStackPush()); | ||
34 | + variables.setVariable("time",component.getStayTime()!=null ? component.getStayTime() : 0); | ||
35 | + variables.setVariable("styleClass",component.getStyleClass()==null?"":component.getStyleClass()); | ||
36 | +]]> | ||
37 | + </jsp:scriptlet> | ||
38 | + <script type="text/javascript"> | ||
39 | + jQuery.pnotify({ | ||
40 | + pnotify_title: '#{summary}', | ||
41 | + pnotify_text :'#{details}', | ||
42 | + pnotify_addclass:'#{styleClass}', | ||
43 | + pnotify_hide:!#{sticky}, | ||
44 | + pnotify_nonblock:#{nonblocking}, | ||
45 | + pnotify_shadow:#{shadow}, | ||
46 | + pnotify_closer:#{closeButton}, | ||
47 | + pnotify_nonblock_opacity:#{nonblockingOpacity}, | ||
48 | + pnotify_animation:{effect_in:'#{appearAnimation}',effect_out:'#{hideAnimation}'}, | ||
49 | + pnotify_animate_speed:#{animationSpeed}, | ||
50 | + pnotify_history:#{showHistory}, | ||
51 | + pnotify_delay:#{time}, | ||
52 | + pnotify_stack:#{stack} | ||
53 | + }); | ||
54 | + </script> | ||
55 | + </div> | ||
56 | +</f:root> |
Please
register
or
login
to post a comment