[Z3lab-checkins] r2452 - cpsskins/branches/jmo-perspectives/ui/framework
Author: jmorliaguet Date: Sat Feb 25 10:56:40 2006 New Revision: 2452 Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js Log: - simpler code 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 Sat Feb 25 10:56:40 2006 @@ -889,20 +889,17 @@ fadeout: function(node, options) { var setOpacity = CPSSkins.Canvas.setOpacity; setOpacity(node, 1); -return new CPSSkins.Scheduler(node, { - delay: options.delay, - duration: options.duration, +Object.extend(options, { action: function(value) { setOpacity(node, 1-value) }, onComplete: function() { Element.hide(node) } }); +return new CPSSkins.Scheduler(node, options); }, blinddown: function(node, options) { var height = parseInt(Element.getStyle(node, 'height')); Element.makeClipping(node); -return new CPSSkins.Scheduler(node, { - delay: options.delay, - duration: options.duration, +Object.extend(options, { action: function(value) { Element.setStyle(node, {height: height*value + 'px'}); }, @@ -911,21 +908,19 @@ Element.undoClipping(node); } }); +return new CPSSkins.Scheduler(node, options); }, blindup: function(node, options) { var height = parseInt(Element.getStyle(node, 'height')); Element.makeClipping(node); -return new CPSSkins.Scheduler(node, { - delay: options.delay, - duration: options.duration, +Object.extend(options, { action: function(value) { Element.setStyle(node, {height: height*(1-value) + 'px'}); }, - onComplete: function() { -Element.setStyle(node, {height: '0px'}); - } + onComplete: function() { Element.setStyle(node, {height: '0px'}); } }); +return new CPSSkins.Scheduler(node, options); } } -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2453 - cpsskins/branches/jmo-perspectives/ui/framework
Author: jmorliaguet Date: Sat Feb 25 12:03:26 2006 New Revision: 2453 Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js Log: - code simplifications 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 Sat Feb 25 12:03:26 2006 @@ -92,28 +92,25 @@ }, unsubscribe: function(eventid, event) { -new_subscribers = []; -CPSSkins._subscribers[eventid].each(function(e) { - if (!(event.subscriber == e.subscriber event.publisher == e.publisher)) { -new_subscribers.push(e); - } -}); -CPSSkins._subscribers[eventid] = new_subscribers; +var subscribers = CPSSkins._subscribers; +subscribers[eventid] = subscribers[eventid].reject(function(e) { + return (event.subscriber == e.subscriber + event.publisher == e.publisher) + }); }, notify: function(eventid, event) { -var subscribers = CPSSkins._subscribers[eventid] || []; +var subscribers = CPSSkins._subscribers; var publisher = event.publisher; -subscribers.each(function(e) { - var event_publisher = e.publisher; - if (event_publisher == publisher || event_publisher == null) { -var handler = CPSSkins.getEventHandler(eventid, e.subscriber); -if (handler) { - // set the publisher in case no publisher is specified in the subscription. - event.subscriber = e.subscriber; - event.publisher = publisher; - handler(event); -} +(subscribers[eventid] || []).findAll(function(e) { + return (e.publisher == publisher || e.publisher == null) +}).each(function(e) { + var handler = CPSSkins.getEventHandler(eventid, e.subscriber); + if (handler) { +// set the publisher in case no publisher is specified. +event.subscriber = e.subscriber; +event.publisher = publisher; +handler(event); } }); }, @@ -127,12 +124,7 @@ }, getEventHandler: function(eventid, subscriber) { -var handlers = subscriber._handlers; -if (handlers) { - return handlers[eventid]; -} else { - return null; -} +return (subscriber._handlers || {})[eventid]; }, /* Document parsing */ @@ -164,7 +156,7 @@ } }); - elements.each(function(el, index) { +elements.each(function(el, index) { var url = el.getAttribute(cite); if (url) { var options = { -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2454 - cpsskins/branches/jmo-perspectives/ui/framework
Author: jmorliaguet Date: Sat Feb 25 12:28:24 2006 New Revision: 2454 Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js Log: - we unsubscribe from events that are only used once (initialization, setup) - the subscription list is cleaned up when there are no subscribers left. 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 Sat Feb 25 12:28:24 2006 @@ -94,9 +94,11 @@ unsubscribe: function(eventid, event) { var subscribers = CPSSkins._subscribers; subscribers[eventid] = subscribers[eventid].reject(function(e) { + if (typeof event == 'undefined') return true; return (event.subscriber == e.subscriber event.publisher == e.publisher) }); +if (subscribers[eventid].length == 0) {delete subscribers[eventid]} }, notify: function(eventid, event) { @@ -145,7 +147,7 @@ // first stage parse: function(node) { var elements = $A(node.getElementsByTagName(ins)); -var progress = new Object({'initialized': 0}); +var progress = {'initialized': 0}; var length = elements.length; CPSSkins.subscribe(initialized, {'subscriber': progress}); @@ -153,6 +155,7 @@ progress.initialized += 1; if (progress.initialized = length) { CPSSkins.load(node); +CPSSkins.unsubscribe(initialized); } }); @@ -249,6 +252,7 @@ CPSSkins.registerEventHandler(evt_id, view, function(event) { var model = event.publisher; view.observe(model); +CPSSkins.unsubscribe(evt_id); }); CPSSkins.subscribe(evt_id, {'subscriber': view}); } @@ -261,6 +265,7 @@ var controller = event.publisher; controller.view = view; controller.register(view); +CPSSkins.unsubscribe(evt_id); }); CPSSkins.subscribe(evt_id, {'subscriber': view}); }); @@ -1443,6 +1448,7 @@ CPSSkins.registerEventHandler(evt_id, view, function(event) { view.getData(); +CPSSkins.unsubscribe(evt_id); }); CPSSkins.subscribe(evt_id, {'subscriber': view}); -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2456 - cpsskins/branches/jmo-perspectives/ui/framework
Author: jmorliaguet Date: Sat Feb 25 13:44:27 2006 New Revision: 2456 Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js Log: - simplifications: the scheduler doesn't need to know about the node on which the effect is applied. 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 Sat Feb 25 13:44:27 2006 @@ -805,12 +805,11 @@ CPSSkins.Scheduler = Class.create(); CPSSkins.Scheduler.prototype = { - initialize: function(element, options) { -this.element = $(element); -this.action = options.action || function(value) {}; + initialize: function(options) { this.delay = options.delay || 0; -this.onComplete = options.onComplete || function() {}; this.duration = options.duration || 300; +this.action = options.action || function(value) {}; +this.onComplete = options.onComplete || function() {}; this.started = false; this.start(); @@ -848,11 +847,9 @@ show: function(node, options) { var delay = options.delay; if (delay) { - return new CPSSkins.Scheduler(node, { + return new CPSSkins.Scheduler({ delay: delay, -onComplete: function() { - Element.show(node); -} +onComplete: function() { Element.show(node); } }); } else { Element.show(node); @@ -862,11 +859,9 @@ hide: function(node, options) { var delay = options.delay; if (delay) { - return new CPSSkins.Scheduler(node, { + return new CPSSkins.Scheduler({ delay: delay, -onComplete: function() { - Element.hide(node); -} +onComplete: function() { Element.hide(node); } }); } else { Element.hide(node); @@ -876,7 +871,7 @@ fadein: function(node, options) { var setOpacity = CPSSkins.Canvas.setOpacity; setOpacity(node, 0); -return new CPSSkins.Scheduler(node, { +return new CPSSkins.Scheduler({ delay: options.delay, duration: options.duration, action: function(value) { setOpacity(node, value) }, @@ -891,7 +886,7 @@ action: function(value) { setOpacity(node, 1-value) }, onComplete: function() { Element.hide(node) } }); -return new CPSSkins.Scheduler(node, options); +return new CPSSkins.Scheduler(options); }, blinddown: function(node, options) { @@ -906,7 +901,7 @@ Element.undoClipping(node); } }); -return new CPSSkins.Scheduler(node, options); +return new CPSSkins.Scheduler(options); }, blindup: function(node, options) { @@ -918,7 +913,7 @@ }, onComplete: function() { Element.setStyle(node, {height: '0px'}); } }); -return new CPSSkins.Scheduler(node, options); +return new CPSSkins.Scheduler(options); } } -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2457 - cpsskins/branches/jmo-perspectives/ui/framework
Author: jmorliaguet Date: Sat Feb 25 15:17:08 2006 New Revision: 2457 Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js Log: - we compare the new data to store with the old data to avoid firing an event for nothing if the data is the same. 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 Sat Feb 25 15:17:08 2006 @@ -95,7 +95,7 @@ var subscribers = CPSSkins._subscribers; if (!(eventid in subscribers)) { return; } subscribers[eventid] = subscribers[eventid].reject(function(e) { - if (typeof event == 'undefined') return true; + if (event == undefined) return true; return (event.subscriber == e.subscriber event.publisher == e.publisher) }); @@ -1069,19 +1069,19 @@ var next = this._queue[0]; if (next in this._queued_data) { data = this._queued_data[next]; - stored = this._writeFields(data); + stored = this._storeFields(data); this._queue.shift(); } else { break; } } } else { - stored = this._writeFields(data); + stored = this._storeFields(data); } return stored; }, - _writeFields: function(data) { + _storeFields: function(data) { // filter out fields with the wrong data type var schema = this.model.schema; var filtered_data = new Object(); @@ -1092,12 +1092,17 @@ filtered_data[field] = value; } }); -// TODO compare old and new data -this.model.def.data = filtered_data; -CPSSkins.notify('stored', {'publisher': this}); +if (!this._compareData(this.model.def.data, filtered_data)) {; + this.model.def.data = filtered_data; + CPSSkins.notify('stored', {'publisher': this}); +} return filtered_data; }, + _compareData: function(a, b) { +return JSON.stringify(a) == JSON.stringify(b); + }, + merge: function(data) { var current_data = this.read(); var new_data = $H(current_data).merge(data); -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2458 - cpsskins/branches/jmo-perspectives/ui/framework
Author: jmorliaguet Date: Sat Feb 25 16:17:33 2006 New Revision: 2458 Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js Log: - added a function for refreshing the view 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 Sat Feb 25 16:17:33 2006 @@ -1312,6 +1312,11 @@ } }, + refresh: function() { +var data = this.getData(); +if (data) this.display(data); + }, + display: function(data) { this.render(data); if (this.def.render_effect) { @@ -1327,9 +1332,8 @@ CPSSkins.notify(gained focus, {'publisher': this, 'context': this.selected}); -// get new data and display the view -var data = this.getData(); -if (data) this.display(data); +// refresh the view +this.refresh(); // prepare the view this.prepare(); -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2461 - cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview
Author: jmorliaguet Date: Sat Feb 25 18:30:18 2006 New Revision: 2461 Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/cpsskins_treeview.pt Log: - using readData() instead of getData() otherwise the requested data can arrive after the data returned get setData(data) (fixes race condition) Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/cpsskins_treeview.pt == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/cpsskins_treeview.pt (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/cpsskins_treeview.pt Sat Feb 25 18:30:18 2006 @@ -35,7 +35,7 @@ var nodeid = target.getAttribute(nodeid); var model = this.view.model; - var data = model.getData(); + var data = model.readData(); data['state'][nodeid] = open; model.setData(data); } @@ -45,7 +45,7 @@ var nodeid = target.getAttribute(nodeid); var model = this.view.model; - var data = model.getData(); + var data = model.readData(); delete data['state'][nodeid]; model.setData(data); } -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2463 - cpsskins/branches/jmo-perspectives/ui/framework
Author: jmorliaguet Date: Sat Feb 25 19:07:38 2006 New Revision: 2463 Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js Log: - more robust code 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 Sat Feb 25 19:07:38 2006 @@ -890,7 +890,7 @@ }, blinddown: function(node, options) { -var height = parseInt(Element.getStyle(node, 'height')); +var height = Element.getHeight(node); Element.makeClipping(node); Object.extend(options, { action: function(value) { @@ -905,7 +905,7 @@ }, blindup: function(node, options) { -var height = parseInt(Element.getStyle(node, 'height')); +var height = Element.getHeight(node); Element.makeClipping(node); Object.extend(options, { action: function(value) { -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2464 - cpsskins/branches/jmo-perspectives/ui/framework/doc
Author: jmorliaguet Date: Sat Feb 25 20:42:07 2006 New Revision: 2464 Modified: cpsskins/branches/jmo-perspectives/ui/framework/doc/index.txt Log: - doc update Modified: cpsskins/branches/jmo-perspectives/ui/framework/doc/index.txt == --- cpsskins/branches/jmo-perspectives/ui/framework/doc/index.txt (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/doc/index.txt Sat Feb 25 20:42:07 2006 @@ -114,24 +114,186 @@ Controller classes have access to the model and to the view. -Available widgets -= +Definitions +=== -Panels --- +The Model, View and Controller elements are registered in the HTML page using +the HTML *ins* tag:: -... + ins class=model + ... + /ins -Contextual menus + ins class=view + ... + /ins + + ins class=controller + ... + /ins + + +The definitions are written in the JSON format, either inline :: + + ins class=view + {widget: { + type: menu + }} + /ins + +or they can be inserted from a remote location:: + + ins class=view cite=/def/viewDefinition.html + /ins + + +Note: the ins tag is part of the HTML specification. +Semantically it denotes an editorial insertion of content. + +Model += + +The model contains some initial data (used to define a schema) and a storage. + +* id: the model's id + +* data: the model's initial data and schema definition + +* storage: the data storage + + There are different types of storages: + + - RAM (the data is stored in the browser's RAM) + + - local (the data is stored in a cookie) + + - remote (the data is stored on a remote server) + + - unified (a combination of several data storages to provide unified +data access) + +Storage adapters -... +* type: the storage type + + - ram (used by default) -Tooltip + - local + + - remote + +- accessors: the storage accessors (get, set) + +- refresh: the refresh rate + +- access: the type of access + + - sequence type: queue, stack + + - sequence signature + + + +View + + +* widget type + +* template: a CTAL template (optional) + +* model: the model's id (optional) + +* show_effect: the effect to applied when the widget is shown (optional) + +* render_effect: the effect to applied when the widget is rendered (optional) + +* hide_effect: the effect to applied when the widget is hidden (optional) + +* controllers: a list of controllers that apply to the view (optional) + +* perspectives: the perspectives in which the view is visible (optional) + +Widgets --- -... +* Panel + + +* Contextual menus + + - items + +- type (item, submenu, separator) + +- label + +- icon + +- action + +- confirm + + +* Contextual actions + + (same options as the Contextual menu) + + +* Tooltip + + +* Custom + + a custom widget, requires a 'template'. + +Effects +--- + +* transition type + + - fadein + + - fadeout + + - blinddown + + - blindup + + +* effect options: + + - delay + + - duration + + +Controllers +=== + +* form controller + + +* behaviour controller + + - rules + + +* focus observer + + +* command controller + + - handlers + + +* drag-and-drop + + - action + + - droppable + - draggable .. Emacs -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2465 - in cpsskins/branches/jmo-perspectives/ui: authoring screens
Author: jmorliaguet Date: Sat Feb 25 21:07:42 2006 New Revision: 2465 Modified: cpsskins/branches/jmo-perspectives/ui/authoring/configure.zcml cpsskins/branches/jmo-perspectives/ui/authoring/definitions.py cpsskins/branches/jmo-perspectives/ui/authoring/views.py cpsskins/branches/jmo-perspectives/ui/screens/editor.pt Log: - the panels' url and css information is now stored in the model Modified: cpsskins/branches/jmo-perspectives/ui/authoring/configure.zcml == --- cpsskins/branches/jmo-perspectives/ui/authoring/configure.zcml (original) +++ cpsskins/branches/jmo-perspectives/ui/authoring/configure.zcml Sat Feb 25 21:07:42 2006 @@ -115,10 +115,14 @@ / browser:page + name=getModel + attribute=getModel + / + + browser:page name=getView attribute=getView / - /browser:pages /configure Modified: cpsskins/branches/jmo-perspectives/ui/authoring/definitions.py == --- cpsskins/branches/jmo-perspectives/ui/authoring/definitions.py (original) +++ cpsskins/branches/jmo-perspectives/ui/authoring/definitions.py Sat Feb 25 21:07:42 2006 @@ -3,14 +3,91 @@ _ = MessageFactory(cpsskins) +MODELS = { +'action-pad': { +'id': 'action-pad', +'data': { +'url': '@@actionPad.html', +} +}, + +'perspective-selector': { +'id': 'perspective-selector', +'data': { +'url': '@@perspectiveSelector.html', +} +}, + +'theme-tabs': { +'id': 'theme-tabs', +'data': { +'url': '@@themeTabs.html', +} +}, + +'page-tabs': { +'id': 'page-tabs', +'data': { +'url': '@@pageTabs.html', +} +}, + +'location-selector': { +'id': 'location-selector', +'data': { +'url': '@@locationSelector.html', +} +}, + +'page-designer': { +'id': 'page-designer', +'data': { +'url': '@@renderPage.html?engine=page-designer', +'css': '/++skin++cpsskins/@@/++resource++page-designer.css', +} +}, + +'layout-designer': { +'id': 'layout-designer', +'data': { +'url': '@@renderPage.html?engine=layout-designer', +'css': '/++skin++cpsskins/@@/++resource++layout-designer.css', +} +}, + +'content-author': { +'id': 'content-author', +'data': { +'url': '@@renderPage.html?engine=content-author', +'css': '/++skin++cpsskins/@@/++resource++content-author.css', +} +}, + +'site-designer': { +'id': 'site-designer', +'data': { +'url': '@@site-designer.html', +'css': '/++skin++cpsskins/@@/++resource++site-designer.css', +} +}, + +'portlet-factory': { +'id': 'portlet-factory', +'data': { +'url': '@@portletFactory.html', +} +}, + +} + VIEWS = { # Top area 'action-pad': { 'widget': { 'type': 'panel', -'url': '@@actionPad.html', }, +'model': 'action-pad', 'perspectives': ['site-designer', 'page-designer', 'layout-designer', 'content-author'], }, @@ -28,8 +105,8 @@ 'perspective-selector': { 'widget': { 'type': 'panel', -'url': '@@perspectiveSelector.html', }, +'model': 'perspective-selector', 'perspectives': ['page-designer', 'layout-designer', 'content-author'], }, @@ -37,24 +114,24 @@ 'theme-tabs': { 'widget': { 'type': 'panel', -'url': '@@themeTabs.html', }, +'model': 'theme-tabs', 'perspectives': ['page-designer', 'layout-designer'], }, 'page-tabs': { 'widget': { 'type': 'panel', -'url': '@@pageTabs.html', }, +'model': 'page-tabs', 'perspectives': ['page-designer', 'layout-designer'], }, 'location-selector': { 'widget': { 'type': 'panel', -'url': '@@locationSelector.html', }, +'model': 'location-selector', 'perspectives': ['content-author'], 'show_effect': { 'transition': 'fadein', @@ -65,27 +142,24 @@ 'page-designer': { 'widget': { 'type': 'panel', -'url': '@@renderPage.html?engine=page-designer', -'css': '/++skin++cpsskins/@@/++resource++page-designer.css', }, +'model': 'page-designer', 'perspectives': ['page-designer'], }, 'layout-designer': { 'widget': { 'type': 'panel', -'url': '@@renderPage.html?engine=layout-designer', -
[Z3lab-checkins] r2466 - cpsskins/branches/jmo-perspectives/ui/framework/tests/functional
Author: jmorliaguet Date: Sat Feb 25 21:11:13 2006 New Revision: 2466 Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/tests.html Log: - added link to the effects test Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/tests.html == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/tests.html (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/tests.html Sat Feb 25 21:11:13 2006 @@ -44,4 +44,8 @@ a target=main href=cpsskins_dragdrop_test.htmlDrag and drop/a /li + li +a target=main + href=cpsskins_effects_test.htmlVisual effects/a + /li /ul -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2467 - cpsskins/branches/jmo-perspectives/ui/framework
Author: jmorliaguet Date: Sat Feb 25 21:38:44 2006 New Revision: 2467 Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js Log: - better API for registering controllers, storage adapters, widgets, effects 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 Sat Feb 25 21:38:44 2006 @@ -44,6 +44,11 @@ _currentPerspective: , _previousPerspective: , + Controllers: $H({}), + Effects: $H({}), + Storages: $H({}), + Widgets: $H({}), + init: function() { CPSSkins.parse(document); }, @@ -70,6 +75,22 @@ return controller; }, + registerControllers: function(controllers) { +Object.extend(CPSSkins.Controllers, controllers) + }, + + registerEffects: function(effects) { +Object.extend(CPSSkins.Effects, effects) + }, + + registerStorages: function(storages) { +Object.extend(CPSSkins.Storages, storages) + }, + + registerWidgets: function(widgets) { +Object.extend(CPSSkins.Widgets, widgets) + }, + /* Error handling */ warn: function(msg, context) { var div = document.createElement(div); @@ -390,8 +411,7 @@ } -if (!CPSSkins.Controllers) { CPSSkins.Controllers = new Object(); } -Object.extend(CPSSkins.Controllers, { +CPSSkins.registerControllers({ 'command': function(node, def) { return new CPSSkins.CommandController(node, def); @@ -842,7 +862,7 @@ // Effects -CPSSkins.Effects = { +CPSSkins.registerEffects({ show: function(node, options) { var delay = options.delay; @@ -915,7 +935,7 @@ }); return new CPSSkins.Scheduler(options); } -} +}); // Model @@ -1114,8 +1134,7 @@ } -if (!CPSSkins.Storages) { CPSSkins.Storages = new Object(); } -Object.extend(CPSSkins.Storages, { +CPSSkins.registerStorages({ ram: function(model) { return new CPSSkins.RAMStorage(model); @@ -1381,15 +1400,7 @@ } -// Renderer: instanciate a widget. -if (!CPSSkins.Widgets) { CPSSkins.Widgets = new Object(); } - -Object.extend(CPSSkins, { - registerWidgets: function(widgets) { -Object.extend(CPSSkins.Widgets, widgets) - } -}); - +// Widgets CPSSkins.registerWidgets({ custom: function(def) { -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2468 - cpsskins/branches/jmo-perspectives/ui/framework/doc
Author: jmorliaguet Date: Sat Feb 25 21:39:06 2006 New Revision: 2468 Modified: cpsskins/branches/jmo-perspectives/ui/framework/doc/index.txt Log: - doc update Javascript API Modified: cpsskins/branches/jmo-perspectives/ui/framework/doc/index.txt == --- cpsskins/branches/jmo-perspectives/ui/framework/doc/index.txt (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/doc/index.txt Sat Feb 25 21:39:06 2006 @@ -296,6 +296,96 @@ - draggable +Javascript API +== + +CPSSkins + + + - getModelById(id) + + - getControllerById(id) + + + - registerControllers(controllers) + + - registerEffects(effects) + + - registerStorages(storages) + + - registerWidgets(widgets) + + + - switchPerspective(perspective) + + + - registerHandlers(handlers) + + + - subscribe(eventid, event) + + - unsubscribe(eventid, event) + + - notify(eventid, event) + + - registerEventHandler(eventid, subscriber, handler) + + - getEventHandler(eventid, subscriber) + + +CPSSkins.Model +-- + + - readData() + + - getData() + + - setData(data) + + - updateData(data) + + - addObserver(view) + + - removeObserver(view) + + +CPSSkins.StorageAdapter +--- + + - setup() + + - requestData() + + - storeData(data) + + +CPSSkins.View +- + + - setup() + + - render(data) + + - prepare() + + - teardown() + + - refresh() + + - display() + + - show() + + - hide() + + +CPSSkins.Controller +--- + + - setup() + + - register(view) + .. Emacs .. Local Variables: .. mode: rst -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2469 - in cpsskins/branches/jmo-perspectives/ui/framework: . doc tests/functional tests/functional/behaviour tests/unit tests/zope3/functional/treeview
Author: jmorliaguet Date: Sat Feb 25 22:09:31 2006 New Revision: 2469 Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js cpsskins/branches/jmo-perspectives/ui/framework/doc/index.txt cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/behaviour/cpsskins_behaviour_test.html cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_contextualactions_test.html cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_contextualmenu_test.html cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_dragdrop_test.html cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_observer_test.html cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_widget_template_test.html cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_test.html cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/cpsskins_treeview.pt Log: - renamed registerHandlers as addActions 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 Sat Feb 25 22:09:31 2006 @@ -36,6 +36,11 @@ var CPSSkins = { Version: 0.7, + Controllers: $H({}), + Effects: $H({}), + Storages: $H({}), + Widgets: $H({}), + _subscribers: $H({}), _models: $H({}), _controllers: $H({}), @@ -44,11 +49,6 @@ _currentPerspective: , _previousPerspective: , - Controllers: $H({}), - Effects: $H({}), - Storages: $H({}), - Widgets: $H({}), - init: function() { CPSSkins.parse(document); }, @@ -99,12 +99,12 @@ context.parentNode.replaceChild(div, context); }, - /* Public events */ - registerHandlers: function(handlers) { + /* Action handlers */ + addActions: function(handlers) { Object.extend(CPSSkins._handlers, handlers); }, - /* Internal events */ + /* Event system */ subscribe: function(eventid, event) { if (!(eventid in CPSSkins._subscribers)) { CPSSkins._subscribers[eventid] = []; Modified: cpsskins/branches/jmo-perspectives/ui/framework/doc/index.txt == --- cpsskins/branches/jmo-perspectives/ui/framework/doc/index.txt (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/doc/index.txt Sat Feb 25 22:09:31 2006 @@ -319,7 +319,7 @@ - switchPerspective(perspective) - - registerHandlers(handlers) + - addActions(handlers) - subscribe(eventid, event) Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/behaviour/cpsskins_behaviour_test.html == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/behaviour/cpsskins_behaviour_test.html (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/behaviour/cpsskins_behaviour_test.html Sat Feb 25 22:09:31 2006 @@ -44,7 +44,7 @@ Element.setStyle(target, {'background-color': null}); } -CPSSkins.registerHandlers( +CPSSkins.addActions( {'say-hello': sayHello, 'focus-area': focusArea, 'unfocus-area': unfocusArea Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_contextualactions_test.html == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_contextualactions_test.html (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_contextualactions_test.html Sat Feb 25 22:09:31 2006 @@ -118,7 +118,7 @@ context.getAttribute('id') + ' =gt; ' + options.choice + '\n'; } -CPSSkins.registerHandlers({'displayChoice': displayChoice}); +CPSSkins.addActions({'displayChoice': displayChoice}); /script pre id=message/pre Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_contextualmenu_test.html == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_contextualmenu_test.html (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_contextualmenu_test.html Sat Feb 25 22:09:31 2006 @@ -177,7 +177,7 @@ context.getAttribute('id') + ' =gt; ' + options.choice + '\n'; } -CPSSkins.registerHandlers({'displayChoice': displayChoice}); +CPSSkins.addActions({'displayChoice': displayChoice}); /script pre id=message/pre Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_dragdrop_test.html
[Z3lab-checkins] r2470 - cpsskins/branches/jmo-perspectives/ui/framework
Author: jmorliaguet Date: Sat Feb 25 23:06:41 2006 New Revision: 2470 Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js Log: - fixes: the model's data is stored in model._data and the data schema definition is in model.def.data - added low-level IO methods (readData / getData) 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 Sat Feb 25 23:06:41 2006 @@ -951,11 +951,20 @@ this.storage = this._setStorageAdapter(); }, - // high-level I/O + // low-level I/O readData: function() { -return this.storage.read(); +return this._data || this.def.data; + }, + + writeData: function(data) { +this._data = data; }, + hasData: function() { +return this._data != undefined; + }, + + // high-level I/O getData: function() { this.storage.readTransaction(); /* asynchronous call */ return this.readData(); @@ -975,7 +984,7 @@ var model = this; // observers subscribes to events on the model CPSSkins.registerEventHandler('modified', view, function(event) { - var data = event.publisher.def.data; + var data = event.publisher.readData(); event.subscriber.display(data); }); CPSSkins.subscribe('modified', {'subscriber': view, 'publisher': model}); @@ -1078,7 +1087,8 @@ // low-level I/O read: function() { -return this.model.def.data; +// TODO implement a policy for reading data +return this.model.readData(); }, write: function(data) { @@ -1107,19 +1117,19 @@ _storeFields: function(data) { // filter out fields with the wrong data type var schema = this.model.schema; -var filtered_data = new Object(); +var new_data = new Object(); schema.each(function(f) { var field = f.key; var value = data[field]; if (value != null typeof value == f.value) { -filtered_data[field] = value; +new_data[field] = value; } }); -if (!this._compareData(this.model.def.data, filtered_data)) {; - this.model.def.data = filtered_data; +if (!this.model.hasData() || !this._compareData(this.read(), new_data)) {; + this.model.writeData(new_data); CPSSkins.notify('stored', {'publisher': this}); } -return filtered_data; +return new_data; }, _compareData: function(a, b) { @@ -1903,7 +1913,7 @@ var model = CPSSkins.Canvas.getModel(selected); if (!model) return; -var data = model.def.data; +var data = model.readData(); if (!data) return; if (data.hint == null) return; -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2471 - cpsskins/branches/jmo-perspectives/ui/framework/doc
Author: jmorliaguet Date: Sat Feb 25 23:11:22 2006 New Revision: 2471 Modified: cpsskins/branches/jmo-perspectives/ui/framework/doc/index.txt Log: - doc update Modified: cpsskins/branches/jmo-perspectives/ui/framework/doc/index.txt == --- cpsskins/branches/jmo-perspectives/ui/framework/doc/index.txt (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/doc/index.txt Sat Feb 25 23:11:22 2006 @@ -307,6 +307,8 @@ - getControllerById(id) +- plugin registration + - registerControllers(controllers) - registerEffects(effects) @@ -316,12 +318,18 @@ - registerWidgets(widgets) +- perspectives + - switchPerspective(perspective) +- action handlers + - addActions(handlers) +- events + - subscribe(eventid, event) - unsubscribe(eventid, event) @@ -336,14 +344,24 @@ CPSSkins.Model -- +- low-level IO + - readData() + - writeData(data) + + +- high-level IO + - getData() - setData(data) - updateData(data) + +- observer pattern + - addObserver(view) - removeObserver(view) -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2472 - cpsskins/branches/jmo-perspectives/ui/framework
Author: jmorliaguet Date: Sat Feb 25 23:14:22 2006 New Revision: 2472 Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js Log: - private methods begin with _ 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 Sat Feb 25 23:14:22 2006 @@ -50,7 +50,7 @@ _previousPerspective: , init: function() { -CPSSkins.parse(document); +CPSSkins._parse(document); }, getModelById: function(id) { @@ -153,7 +153,7 @@ /* Document parsing */ - jsonParse: function(el) { + _jsonParse: function(el) { var res = null; var text = el.innerHTML; if (!text) return; @@ -167,7 +167,7 @@ }, // first stage - parse: function(node) { + _parse: function(node) { var elements = $A(node.getElementsByTagName(ins)); var progress = {'initialized': 0}; var length = elements.length; @@ -176,7 +176,7 @@ CPSSkins.registerEventHandler(initialized, progress, function(event) { progress.initialized += 1; if (progress.initialized = length) { -CPSSkins.load(node); +CPSSkins._load(node); CPSSkins.unsubscribe(initialized); } }); @@ -204,22 +204,22 @@ }, // second stage - load: function(node) { + _load: function(node) { var elements = $A(node.getElementsByTagName(ins)); [view, controller, model].each(function(type) { elements.each(function(el, index) { if (Element.hasClassName(el, type)) { - CPSSkins.register(el, type, index); + CPSSkins._register(el, type, index); } }); }); }, - register: function(el, classid, index) { + _register: function(el, classid, index) { // make the element identifiable var name = classid + index; el.setAttribute(name, name); - var def = CPSSkins.jsonParse(el); + var def = CPSSkins._jsonParse(el); def.name = name; switch(classid) { @@ -1531,7 +1531,7 @@ var widget = this.widget; var options = { onComplete: function() { - CPSSkins.load(widget); + CPSSkins._load(widget); } }; -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2474 - cookbook/trunk
Author: tziade Date: Sun Feb 26 00:34:20 2006 New Revision: 2474 Added: cookbook/trunk/macros.tex cookbook/trunk/recipe0.tex Log: added macros and recipe 0 Added: cookbook/trunk/macros.tex == --- (empty file) +++ cookbook/trunk/macros.tex Sun Feb 26 00:34:20 2006 @@ -0,0 +1,104 @@ +% Import all the nice and important packages +\usepackage{amssymb, amsmath} % Allows math symbols. +\usepackage{epsfig} % Allows us to insert EPS figures. +\usepackage{eso-pic} +\usepackage{graphicx} +\usepackage{fancyvrb} +\usepackage[obeyspaces]{url} +\usepackage{listings} +\usepackage{nameref} +\usepackage[usenames]{color} + +% Setup up listings. +\lstnewenvironment{python} +{ +\lstset{language=Python, +fancyvrb=true, +morekeywords={self}, +basicstyle=\footnotesize\ttfamily, +basewidth=0.51em, +stringstyle=\ttfamily\color{Blue}, +keywordstyle=\color{BlueViolet}\bfseries, +commentstyle=\color{BrickRed}\itshape, +showstringspaces=false} +}{} + +\lstnewenvironment{codetext} +{ +\lstset{language=Python, +fancyvrb=true, +basicstyle=\footnotesize\ttfamily, +basewidth=0.51em, +showstringspaces=false} +}{} + +\lstnewenvironment{zcml} +{ +\lstset{language=XML, +fancyvrb=true, +basicstyle=\footnotesize\ttfamily, +basewidth=0.51em, +stringstyle=\ttfamily\color{Blue}, +keywordstyle=\color{BlueViolet}\bfseries, +commentstyle=\color{BrickRed}\itshape, +showstringspaces=false} +}{} + +\lstnewenvironment{xml} +{ +\lstset{language=XML, +fancyvrb=true, +basicstyle=\footnotesize\ttfamily, +basewidth=0.51em, +stringstyle=\ttfamily\color{Blue}, +keywordstyle=\color{BlueViolet}\bfseries, +commentstyle=\color{BrickRed}\itshape, +showstringspaces=false} +}{} + +\lstnewenvironment{zpt} +{ +\lstset{language=XML, +fancyvrb=true, +basicstyle=\footnotesize\ttfamily, +basewidth=0.51em, +stringstyle=\ttfamily\color{Blue}, +keywordstyle=\color{BlueViolet}\bfseries, +commentstyle=\color{BrickRed}\itshape, +showstringspaces=false} +}{} + +\lstnewenvironment{css} +{ +\lstset{fancyvrb=true, +basicstyle=\footnotesize\ttfamily, +basewidth=0.51em, +stringstyle=\ttfamily\color{Blue}, +keywordstyle=\color{BlueViolet}\bfseries, +commentstyle=\color{BrickRed}\itshape, +showstringspaces=false} +}{} + +\lstnewenvironment{shell} +{ +\lstset{fancyvrb=true, +basicstyle=\footnotesize\ttfamily, +basewidth=0.51em, +showstringspaces=false} +}{} + + +% Problem/Task +\newenvironment{problem} +{ +% todo: see later +} +{} + +% Solution +\newenvironment{solution} +{ +% todo: see later +} +{} + Added: cookbook/trunk/recipe0.tex == --- (empty file) +++ cookbook/trunk/recipe0.tex Sun Feb 26 00:34:20 2006 @@ -0,0 +1,105 @@ +\documentclass{book} +\pagestyle{headings} +\include{macros} + +\begin{document} + +\chapter{Dummy Recipe} + +\begin{problem} +This dummy recipe is a tutorial on how to write a recipe. +\end{problem} + +\begin{solution} + +\section*{Recipe structure} + +A recipe is made of a problem and a solution section. + +\begin{itemize} +\item The problem describe in less than 20 lines the problem to solve. + +\item The solution is made of sections and subsections, and provide the +solution. +\end{itemize} + +The solution can contain text and code. The code can be made with several +specific commands. + +\section*{Specific commands for the code blocs} + +You can define special sections to present Python, ZPT, XML, CSS, +and ZCML examples. They are all defined in macros.tex. They help +you write examples. + +\subsection*{Python} + +\begin{python} + import math + math.pow(2, 4) +16.0 +\end{python} + +\subsection*{Codetext} + +\begin{codetext} + import math + math.pow(2, 4) +16.0 +\end{codetext} + + +The only difference between Codetext and Python is that Python blocs are +executed for real. + +\subsection*{ZCML} +\begin{zcml} +page + for=IMyInterface + name=mypage.html + permission=the.permission + layer=the_layer + class=MyClass + template=my_template.pt / +\end{zcml} + +\subsection*{XML or HTML} +\begin{xml} +PERSONS + PERSON +NAMEJohn/NAME + /PERSON +/PERSONS +\end{xml} + +\subsection*{CSS} +\begin{css} +.style { + background: 1px; + color: red; +} +\end{css} + +\subsection*{Shell} +\begin{shell} +[EMAIL PROTECTED]:/home/svn.z3lab.org/cookbook\$ ls -lh +total 72K +-rw-r--r-- 1 tziade tziade 647 2006-02-25 23:30 cookbookmacros.aux +-rw-r--r-- 1 tziade tziade 2,9K 2006-02-25 23:30 cookbookmacros.tex +-rw-r--r-- 1 tziade tziade 158 2006-02-25 23:30 recipe1.aux +
[Z3lab-checkins] r2476 - cookbook/trunk
Author: tziade Date: Sun Feb 26 00:50:55 2006 New Revision: 2476 Modified: cookbook/trunk/macros.tex cookbook/trunk/recipe0.en.tex Log: added status Modified: cookbook/trunk/macros.tex == --- cookbook/trunk/macros.tex (original) +++ cookbook/trunk/macros.tex Sun Feb 26 00:50:55 2006 @@ -102,3 +102,5 @@ } {} +\newcommand{\status}[1]{ +} Modified: cookbook/trunk/recipe0.en.tex == --- cookbook/trunk/recipe0.en.tex (original) +++ cookbook/trunk/recipe0.en.tex Sun Feb 26 00:50:55 2006 @@ -1,6 +1,7 @@ \documentclass{book} \pagestyle{headings} \include{macros} +\status{draft} \begin{document} -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins