Author: pyaschenko
Date: 2010-01-19 08:30:49 -0500 (Tue, 19 Jan 2010)
New Revision: 16332
Modified:
root/examples-sandbox/trunk/javascripts-draft/position/1.html
root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces-event.js
Log:
RicRichFaces.Event updates
Modified: root/examples-sandbox/trunk/javascripts-draft/position/1.html
===================================================================
--- root/examples-sandbox/trunk/javascripts-draft/position/1.html 2010-01-19 12:23:01 UTC
(rev 16331)
+++ root/examples-sandbox/trunk/javascripts-draft/position/1.html 2010-01-19 13:30:49 UTC
(rev 16332)
@@ -3,6 +3,7 @@
<script src="jquery/jquery-1.3.2.js"
type="text/javascript"></script>
<script src="jquery.utils.js"
type="text/javascript"></script>
<script src="jquery.position.js"
type="text/javascript"></script>
+ <script src="richfaces-event.js"
type="text/javascript"></script>
</head>
<body>
<div id="aaa" style="background-color:red">aaa</div>
@@ -10,9 +11,30 @@
<div id="ccc" style="background-color:green">ccc</div>
<div id="tooltip" style="position: absolute; background-color:
gray;">tooltip</div>
<script>
+/*
jQuery('#tooltip').position(jQuery('#aaa'));
jQuery('#bbb').bind("click",function(e){jQuery('#tooltip').position(e);});
jQuery('#tooltip').position({left:10,top:10,width:0,height:0});
+*/
+ function a (id, namespace) {
+ this.getComponentName = function() {return "a"};
+ this.getNamespace = function() {return
'.rf.'+this.getComponentName()+'.'+this.id+(namespace ?
'.'+namespace : '');}
+ this.onClick = function(event) {
+ alert(event.data.component.getComponentName());
+ };
+ this.clearEventHandlers = function() {
+ RichFaces.Event.unbind(id,'click'+this.getNamespace());
+ }
+
+ this.id = id;
+ jQuery(id).component = this;
+ RichFaces.Event.bind(id,'click'+this.getNamespace(), this.onClick, this);
+ };
+ var _a = new a('#aaa');
+ alert(_a.getComponentName());
+ var _b = new a('#bbb');
+ var _aa = new a('#aaa');
+ //_a.clearEventHandlers();
</script>
</boby>
</html>
\ No newline at end of file
Modified:
root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces-event.js
===================================================================
---
root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces-event.js 2010-01-19
12:23:01 UTC (rev 16331)
+++
root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces-event.js 2010-01-19
13:30:49 UTC (rev 16332)
@@ -1,9 +1,11 @@
-(function(jQuery, richfaces) {
- richfaces.event = richfaces.Event || {};
+(function(basefw, richfaces) {
+ richfaces.Event = richfaces.Event || {};
- jQuery.extend(richfaces.Event, {
+ basefw.extend(richfaces.Event, {
+ RICH_NAMESPACE : "RICH",
ready : function(fn) {
- return $(document).ready(fn);
+ // TODO: not completed yet
+ return basefw(document).ready(fn);
/*
function callback(jQueryReference) {
this; // document
@@ -12,30 +14,54 @@
},
bind : function(selector, type, fn, data) {
// type: namespace can be used, like onclick.rf.conponentName
- return jQuery(selector).bind(type, data, fn);
+ var f = function (e){
+ e.data.fn.call(e.data.component, e, this);
+ };
+ basefw(selector).bind(type, {component: data, fn:fn}, f);
+ return f;
},
bindOne: function(selector, type, fn, data) {
// type: namespace can be used, like onclick.rf.conponentName
- return jQuery(selector).one(type, data, fn);
+ var f = function (e){
+ e.data.fn.call(e.data.component, e, this);
+ };
+ basefw(selector).one(type, {component: data, fn:fn}, f);
+ return f;
},
unbind : function(selector, type, fn) {
// type: namespace can be used, like onclick.rf.conponentName
- return jQuery(selector).unbind(type, fn);
+ return basefw(selector).unbind(type, fn);
},
fire : function(selector, event, data) {
- return jQuery(selector).trigger(event, data);
+ return basefw(selector).trigger(event, data);
},
callHandler : function(selector, event, data) {
- return jQuery(selector).triggerHandler(event, data);
+ return basefw(selector).triggerHandler(event, data);
+ },
+ // TODO: rename argument names
+ createNamespace : function(componentName, id, prefix, suffix) {
+ var a = [];
+ a.push(prefix || RICH_NAMESPACE);
+ if (componentName) {
+ a.push(componentName);
+ if (id) {
+ a.push(id);
+ if (suffix) {
+ a.push(suffix);
+ }
+ }
+ }
+ return a.join('.');
}
-
});
-})(jQuery, RichFaces);
+})(jQuery, window.RichFaces || (window.RichFaces={}));
/*
-fn : function (eventObject) {
- this; // dom element
+fn : function (eventObject, element) {
+ this; // object passed as data to bind function
+ element; // dom element
+
}
*/