Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

RF-12103: notify: added event handler code for notifications

  • Loading branch information...
commit 77637c79c4c7722b6e66f2c65e80993940e9cd5e 1 parent 8e0904b
Lukáš Fryč authored April 10, 2012
11  validator/ui/src/main/java/org/richfaces/component/AbstractNotify.java
@@ -31,13 +31,16 @@
31 31
 import org.richfaces.cdk.annotations.Tag;
32 32
 
33 33
 /**
34  
- * <p>The &lt;rich:notify&gt; component serves for advanced user interaction, using notification boxes to give the user
35  
- * instant feedback on what's happening within the application. Each time this component is rendered, a floating
36  
- * notification box is displayed in the selected corner of the browser screen.</p>
  34
+ * <p>
  35
+ * The &lt;rich:notify&gt; component serves for advanced user interaction, using notification boxes to give the user instant
  36
+ * feedback on what's happening within the application. Each time this component is rendered, a floating notification box is
  37
+ * displayed in the selected corner of the browser screen.
  38
+ * </p>
37 39
  *
38 40
  * @author <a href="http://community.jboss.org/people/lfryc">Lukas Fryc</a>
39 41
  */
40  
-@JsfComponent(tag = @Tag(name = "notify"), type = AbstractNotify.COMPONENT_TYPE, family = AbstractNotify.COMPONENT_FAMILY, generate = "org.richfaces.component.UINotify", renderer = @JsfRenderer(type = "org.richfaces.NotifyRenderer"), attributes = "styleClass-prop.xml", facets = {
  42
+@JsfComponent(tag = @Tag(name = "notify"), type = AbstractNotify.COMPONENT_TYPE, family = AbstractNotify.COMPONENT_FAMILY, generate = "org.richfaces.component.UINotify", renderer = @JsfRenderer(type = "org.richfaces.NotifyRenderer"), attributes = {
  43
+        "styleClass-prop.xml", "events-mouse-props.xml", "events-key-props.xml" }, facets = {
41 44
         @Facet(name = "summary", description = @Description("Summary of the notification message")),
42 45
         @Facet(name = "detail", description = @Description("Detail of the notification message")) })
43 46
 public abstract class AbstractNotify extends UIComponentBase implements NotifyAttributes {
9  validator/ui/src/main/resources/META-INF/resources/org.richfaces/notify.js
@@ -20,6 +20,8 @@
20 20
     
21 21
     var defaultStackId = "org.richfaces.notifyStack.default";
22 22
     
  23
+    var events = "click dblclick  keydown keypress keyup mousedown mousemove mouseout mouseover mouseup";
  24
+    
23 25
     var propertyTranslation = {
24 26
         'summary':'pnotify_title',
25 27
         'detail': 'pnotify_text',
@@ -45,7 +47,7 @@
45 47
             var targetAttr = translation[attr] != null ? translation[attr] : attr;
46 48
             target[targetAttr] = source[attr];
47 49
             if (target[targetAttr] instanceof Object) {
48  
-                target[targetAttr] = extend({}, target[targetAttr], translation);
  50
+                target[targetAttr] = $.extend({}, target[targetAttr], translation);
49 51
             }
50 52
         }
51 53
         return target;
@@ -95,6 +97,11 @@
95 97
                 }
96 98
             }
97 99
             var pnotify = $.pnotify(pnotifyOptions);
  100
+            pnotify.on(events, function(e) {
  101
+                if (options['on' + e.type]) {
  102
+                    options['on' + e.type].call(this, e);
  103
+                }
  104
+            });
98 105
             stack.addNotification(pnotify);
99 106
         }
100 107
         
1  validator/ui/src/main/templates/notify.template.xml
@@ -41,6 +41,7 @@ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
41 41
 	        <script type="text/javascript">
42 42
                 <cdk:scriptObject name="options">
43 43
                     <cdk:scriptOption attributes="position sticky stayTime delay styleClass appearAnimation hideAnimation animationSpeed showHistory nonblocking showShadow showCloseButton nonblockingOpacity" />
  44
+                    <cdk:scriptOption wrapper="eventHandler" attributes="onclick ondblclick  onkeydown onkeypress onkeyup onmousedown onmousemove onmouseout onmouseover onmouseup" />
44 45
                 </cdk:scriptObject>
45 46
                 <cdk:call expression="addStackIdOption(options, facesContext, component)" />
46 47
                 <cdk:call expression="addFacetOrAttributeAsOption(&quot;summary&quot;, options, facesContext, component)" />
1  validator/ui/src/main/templates/notifyMessage.template.xml
@@ -28,6 +28,7 @@
28 28
         <span id="#{clientId}" class="rf-ntf-msg" cdk:passThroughWithExclusions="id class">
29 29
             <cdk:scriptObject name="options">
30 30
                 <cdk:scriptOption attributes="sticky stayTime delay styleClass appearAnimation hideAnimation animationSpeed showHistory nonblocking showShadow showCloseButton nonblockingOpacity" />
  31
+                <cdk:scriptOption wrapper="eventHandler" attributes="onclick ondblclick  onkeydown onkeypress onkeyup onmousedown onmousemove onmouseout onmouseover onmouseup" />
31 32
             </cdk:scriptObject>
32 33
             <cdk:call expression="addStackIdOption(options, facesContext, component)" />
33 34
             <cdk:call>encodeScript(facesContext,component, options)</cdk:call>
1  validator/ui/src/main/templates/notifyMessages.template.xml
@@ -28,6 +28,7 @@
28 28
         <span id="#{clientId}" class="rf-ntf-msgs #{component.attributes['styleClass']}" cdk:passThroughWithExclusions="id class">
29 29
             <cdk:scriptObject name="options">
30 30
                 <cdk:scriptOption attributes="sticky stayTime delay styleClass appearAnimation hideAnimation animationSpeed showHistory nonblocking showShadow showCloseButton nonblockingOpacity" />
  31
+                <cdk:scriptOption wrapper="eventHandler" attributes="onclick ondblclick  onkeydown onkeypress onkeyup onmousedown onmousemove onmouseout onmouseover onmouseup" />
31 32
             </cdk:scriptObject>
32 33
             <cdk:call expression="addStackIdOption(options, facesContext, component)" />
33 34
             <cdk:call>encodeScript(facesContext,component, options)</cdk:call>

0 notes on commit 77637c7

Please sign in to comment.
Something went wrong with that request. Please try again.