Author: jmorliaguet Date: Tue Feb 7 14:51:20 2006 New Revision: 2319 Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js Log:
- notify() uses a data structure to communicate information about events Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js ============================================================================== --- cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js Tue Feb 7 14:51:20 2006 @@ -98,8 +98,9 @@ CPSSkins.Subscribers[eventid] = new_subscribers; }, - notify: function(eventid, target) { + notify: function(eventid, info) { var subscribers = CPSSkins.Subscribers[eventid]; + var target = info.target; $A(subscribers).each(function(e) { var event_target = e.target; if (event_target == target || event_target == null) { @@ -166,7 +167,7 @@ var options = { onComplete: function(req) { el.innerHTML = req.responseText; - CPSSkins.notify('initialized', el); + CPSSkins.notify('initialized', {"target": el}); } } var parts = url.split('?'); @@ -177,7 +178,7 @@ new Ajax.Request(url, options); } else { /* the definition is written inline */ - CPSSkins.notify('initialized', el); + CPSSkins.notify('initialized', {"target": el}); } }); }, @@ -208,7 +209,7 @@ if (factory) { var controller = factory(el, def); CPSSkins.Controllers[name] = controller; - CPSSkins.notify("registered controller " + def.id, controller); + CPSSkins.notify("registered controller " + def.id, {"target": controller}); } break; } @@ -217,7 +218,7 @@ var model = new CPSSkins.Model(el, def); model.id = index; CPSSkins.Models[name] = model; - CPSSkins.notify("registered model " + def.id, model); + CPSSkins.notify("registered model " + def.id, {"target": model}); break; } @@ -759,7 +760,7 @@ // the model reacts to events on the storage and notifies observers CPSSkins.registerEventHandler('stored', model, function(event) { - CPSSkins.notify('modified', model); + CPSSkins.notify('modified', {"target": model}); }); CPSSkins.subscribe('stored', {'subscriber': model, 'target': storage}); @@ -850,13 +851,13 @@ requestData: function() { /* nothing to do since the data is already there */ - CPSSkins.notify('stored', this); + CPSSkins.notify('stored', {"target": this}); }, storeData: function(data) { /* Store the data directly */ this.write(data); - CPSSkins.notify('stored', this); + CPSSkins.notify('stored', {"target": this}); } }); @@ -876,7 +877,7 @@ var value = unescape(results[1]); data = JSON.parse(value); this.write(data); - CPSSkins.notify('stored', this); + CPSSkins.notify('stored', {"target": this}); } else { return; } @@ -887,7 +888,7 @@ value = escape(JSON.stringify(data)); document.cookie = this.cookie_name + '=' + value + '; path=/'; - CPSSkins.notify('stored', this); + CPSSkins.notify('stored', {"target": this}); } }); @@ -906,7 +907,7 @@ onComplete: function(req) { var data = JSON.parse(req.responseText); storage.write(data); - CPSSkins.notify('stored', storage); + CPSSkins.notify('stored', {"target": storage}); } } var parts = url.split('?'); @@ -931,7 +932,7 @@ onComplete: function(req) { var data = JSON.parse(req.responseText); storage.write(data); - CPSSkins.notify('stored', storage); + CPSSkins.notify('stored', {"target": storage}); } }); } @@ -950,7 +951,7 @@ CPSSkins.registerEventHandler('stored', storage, function(event) { event.subscriber.merge(event.target.read()); // propagate the event - CPSSkins.notify('stored', storage); + CPSSkins.notify('stored', {"target": storage}); }); $A(this.model.def.storage.partitions).each(function(p) { -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins