Permalink
Browse files

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

  • Loading branch information...
1 parent 8e0904b commit 77637c79c4c7722b6e66f2c65e80993940e9cd5e @lfryc lfryc committed Apr 10, 2012
@@ -31,13 +31,16 @@
import org.richfaces.cdk.annotations.Tag;
/**
- * <p>The &lt;rich:notify&gt; component serves for advanced user interaction, using notification boxes to give the user
- * instant feedback on what's happening within the application. Each time this component is rendered, a floating
- * notification box is displayed in the selected corner of the browser screen.</p>
+ * <p>
+ * The &lt;rich:notify&gt; component serves for advanced user interaction, using notification boxes to give the user instant
+ * feedback on what's happening within the application. Each time this component is rendered, a floating notification box is
+ * displayed in the selected corner of the browser screen.
+ * </p>
*
* @author <a href="http://community.jboss.org/people/lfryc">Lukas Fryc</a>
*/
-@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 = {
+@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", "events-mouse-props.xml", "events-key-props.xml" }, facets = {
@Facet(name = "summary", description = @Description("Summary of the notification message")),
@Facet(name = "detail", description = @Description("Detail of the notification message")) })
public abstract class AbstractNotify extends UIComponentBase implements NotifyAttributes {
@@ -20,6 +20,8 @@
var defaultStackId = "org.richfaces.notifyStack.default";
+ var events = "click dblclick keydown keypress keyup mousedown mousemove mouseout mouseover mouseup";
+
var propertyTranslation = {
'summary':'pnotify_title',
'detail': 'pnotify_text',
@@ -45,7 +47,7 @@
var targetAttr = translation[attr] != null ? translation[attr] : attr;
target[targetAttr] = source[attr];
if (target[targetAttr] instanceof Object) {
- target[targetAttr] = extend({}, target[targetAttr], translation);
+ target[targetAttr] = $.extend({}, target[targetAttr], translation);
}
}
return target;
@@ -95,6 +97,11 @@
}
}
var pnotify = $.pnotify(pnotifyOptions);
+ pnotify.on(events, function(e) {
+ if (options['on' + e.type]) {
+ options['on' + e.type].call(this, e);
+ }
+ });
stack.addNotification(pnotify);
}
@@ -41,6 +41,7 @@ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
<script type="text/javascript">
<cdk:scriptObject name="options">
<cdk:scriptOption attributes="position sticky stayTime delay styleClass appearAnimation hideAnimation animationSpeed showHistory nonblocking showShadow showCloseButton nonblockingOpacity" />
+ <cdk:scriptOption wrapper="eventHandler" attributes="onclick ondblclick onkeydown onkeypress onkeyup onmousedown onmousemove onmouseout onmouseover onmouseup" />
</cdk:scriptObject>
<cdk:call expression="addStackIdOption(options, facesContext, component)" />
<cdk:call expression="addFacetOrAttributeAsOption(&quot;summary&quot;, options, facesContext, component)" />
@@ -28,6 +28,7 @@
<span id="#{clientId}" class="rf-ntf-msg" cdk:passThroughWithExclusions="id class">
<cdk:scriptObject name="options">
<cdk:scriptOption attributes="sticky stayTime delay styleClass appearAnimation hideAnimation animationSpeed showHistory nonblocking showShadow showCloseButton nonblockingOpacity" />
+ <cdk:scriptOption wrapper="eventHandler" attributes="onclick ondblclick onkeydown onkeypress onkeyup onmousedown onmousemove onmouseout onmouseover onmouseup" />
</cdk:scriptObject>
<cdk:call expression="addStackIdOption(options, facesContext, component)" />
<cdk:call>encodeScript(facesContext,component, options)</cdk:call>
@@ -28,6 +28,7 @@
<span id="#{clientId}" class="rf-ntf-msgs #{component.attributes['styleClass']}" cdk:passThroughWithExclusions="id class">
<cdk:scriptObject name="options">
<cdk:scriptOption attributes="sticky stayTime delay styleClass appearAnimation hideAnimation animationSpeed showHistory nonblocking showShadow showCloseButton nonblockingOpacity" />
+ <cdk:scriptOption wrapper="eventHandler" attributes="onclick ondblclick onkeydown onkeypress onkeyup onmousedown onmousemove onmouseout onmouseover onmouseup" />
</cdk:scriptObject>
<cdk:call expression="addStackIdOption(options, facesContext, component)" />
<cdk:call>encodeScript(facesContext,component, options)</cdk:call>

0 comments on commit 77637c7

Please sign in to comment.