[Z3lab-checkins] r2411 - cpsskins/branches/jmo-perspectives/ui/framework
Author: jmorliaguet Date: Sat Feb 18 11:15:30 2006 New Revision: 2411 Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js Log: - removed all back-references. With the event model they are no longer needed and they can lead to circular references and memory leaks. 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 18 11:15:30 2006 @@ -273,9 +273,6 @@ var controller = event.publisher; controller.view = view; controller.register(view); -// add a back-reference -view.controller = controller; - }); CPSSkins.subscribe(evt_id, {'subscriber': view}); }); @@ -885,8 +882,6 @@ event.subscriber.display(data); }); CPSSkins.subscribe('modified', {'subscriber': view, 'publisher': model}); -// create a back-reference -view.model = model; }, removeObserver: function(view) { @@ -1197,9 +1192,6 @@ this.hide_effect = def.hide_effect || {}; this.setup(); - -// create a back-reference -this.widget.view = this; }, /* Public API */ -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2412 - cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview
Author: jmorliaguet Date: Sat Feb 18 12:24:30 2006 New Revision: 2412 Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/cpsskins_treeview.pt Log: - open / close nodes 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 18 12:24:30 2006 @@ -30,13 +30,19 @@ function openContainer(event) { var target = Event.element(event); var nodeid = target.getAttribute(nodeid); - debug(nodeid); + var model = CPSSkins.getModelById(tree-state); + var state_data = model.getData(); + state_data['state'][nodeid] = open; + model.setData(state_data); } function closeContainer(event) { var target = Event.element(event); var nodeid = target.getAttribute(nodeid); - debug(nodeid); + var model = CPSSkins.getModelById(tree-state); + var state_data = model.getData(); + delete state_data['state'][nodeid]; + model.setData(state_data); } CPSSkins.registerHandlers( -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2414 - in cpsskins/branches/jmo-perspectives/ui/framework: . tests/functional tests/functional/treeview tests/unit tests/zope3/functional/chat tests/zope3/functional/quiz tests/zope3
Author: jmorliaguet Date: Sat Feb 18 14:50:35 2006 New Revision: 2414 Added: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/treeview/ Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js 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/unit/cpsskins_test.html cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/cpsskins_chat.pt cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/quiz/cpsskins_quiz.pt cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/cpsskins_treeview.pt cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/unit/cpsskins_storage_adapters.pt Log: - renamed 'compound storage' as 'unified storage' and 'partitions' as 'units' 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 18 14:50:35 2006 @@ -1044,8 +1044,8 @@ return new CPSSkins.RemoteStorage(model); }, - compound: function(model) { -return new CPSSkins.CompoundStorage(model); + unified: function(model) { +return new CPSSkins.UnifiedStorage(model); } }); @@ -1138,8 +1138,8 @@ }); -CPSSkins.CompoundStorage = Class.create(); -CPSSkins.CompoundStorage.prototype = Object.extend( +CPSSkins.UnifiedStorage = Class.create(); +CPSSkins.UnifiedStorage.prototype = Object.extend( new CPSSkins.StorageAdapter(), { setup: function() { @@ -1153,7 +1153,7 @@ CPSSkins.notify('stored', {'publisher': storage}); }); -$A(this.model.def.storage.partitions).each(function(p) { +$A(this.model.def.storage.units).each(function(p) { var model = CPSSkins.getModelById(p); models.push(model); CPSSkins.subscribe('stored', 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 18 14:50:35 2006 @@ -110,9 +110,9 @@ !-- Controller -- script type=text/javascript -function displayChoice(info) { - var context = info.context; - var options = info.options; +function displayChoice(event) { + var context = event.context; + var options = event.options; $(message).innerHTML += context.getAttribute('id') + ' =gt; ' + options.choice + '\n'; 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 18 14:50:35 2006 @@ -170,9 +170,9 @@ !-- Controller -- script type=text/javascript -function displayChoice(info) { - var context = info.context; - var options = info.options; +function displayChoice(event) { + var context = event.context; + var options = event.options; $(message).innerHTML += context.getAttribute('id') + ' =gt; ' + options.choice + '\n'; } Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_test.html == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_test.html (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_test.html Sat Feb 18 14:50:35 2006 @@ -188,7 +188,7 @@ } /ins - !-- compound storages -- + !-- unified storages -- ins class=model {id: m1, data: {a: 1}, @@ -209,8 +209,8 @@ {id: c1, data: {a: 0, b: 0}, storage: { - type: compound, - partitions: [m1, m2] + type: unified, + units: [m1, m2] }} /ins @@ -422,14 +422,14 @@ $H({a: 2, c:true}).inspect()); }}, -testCompoundStoragesGetData: function() { with(this) { +testUnifiedStoragesGetData: function() { with(this) { var model_c1 = CPSSkins.getModelById('c1'); assertEqual($H(model_c1.getData()).inspect(), $H({a: 1,b: 2}).inspect()); }}, -testCompoundStoragesSetData: function() { with(this) { +
[Z3lab-checkins] r2415 - cpsskins/branches/jmo-perspectives
Author: jmorliaguet Date: Sat Feb 18 15:46:34 2006 New Revision: 2415 Modified: cpsskins/branches/jmo-perspectives/minjson.py Log: - upgraded to the latest version of minjson.py Modified: cpsskins/branches/jmo-perspectives/minjson.py == --- cpsskins/branches/jmo-perspectives/minjson.py (original) +++ cpsskins/branches/jmo-perspectives/minjson.py Sat Feb 18 15:46:34 2006 @@ -16,11 +16,24 @@ # reads minimal javascript objects. # str's objects and fixes the text to write javascript. +#UNICODE USAGE: Minjson tries hard to accommodate naive usage in a +#Do what I mean manner. Real applications should handle unicode separately. +# The right way to use minjson in an application is to provide minjson a +# python unicode string for reading and accept a unicode output from minjson's +# writing. That way, the assumptions for unicode are yours and not minjson's. + +# That said, the minjson code has some (optional) unicode handling that you +# may look at as a model for the unicode handling your application may need. + # Thanks to Patrick Logan for starting the json-py project and making so many # good test cases. -# Jim Washington 10 Oct 2005. +# Additional thanks to Balazs Ree for replacing the writing module. +# Jim Washington 30 Dec 2005. + +# 2005-12-30 writing now traverses the object tree instead of relying on +#str() or unicode() # 2005-10-10 on reading, looks for \\u and replaces with u'\u' # 2005-10-09 now tries hard to make all strings unicode when reading. # 2005-10-07 got rid of eval() completely, makes object as found by the @@ -37,17 +50,15 @@ from token import ENDMARKER, NAME, NUMBER, STRING, OP, ERRORTOKEN from tokenize import tokenize, TokenError, NL -# set to true if transmission size is much more important than speed -# only affects writing, and makes a minimal difference in output size. -alwaysStripWhiteSpace = False - -# set this to True if you want chars above 128 always expressed as /uxxx -# this is expensive. -doU = False - #Usually, utf-8 will work, set this to utf-16 if you dare. emergencyEncoding = 'utf-8' +class ReadException(Exception): +pass + +class WriteException(Exception): +pass + # # read JSON object # # @@ -76,6 +87,7 @@ class CommaToken: __slots__=[] pass + class JSONReader(object): raise SyntaxError if it is not JSON, and make the object available def __init__(self,data): @@ -85,7 +97,7 @@ self.lastOp = None self.objects = [] self.tokenize() - + def tokenize(self): try: tokenize(self._data.next,self.readTokens) @@ -143,7 +155,7 @@ if not isinstance(key,basestring): raise SyntaxError except IndexError: - + raise SyntaxError #salt the while comma = value @@ -241,8 +253,8 @@ def safeRead(aString, encoding=None): read the js, first sanitizing a bit and removing any c-style comments -If the input is a unicode string, that's OK. If the input is a byte string, -strings in the object will be produced as unicode anyway. +If the input is a unicode string, great. That's preferred. If the input +is a byte string, strings in the object will be produced as unicode anyway. # get rid of trailing null. Konqueror appends this. CHR0 = chr(0) @@ -264,7 +276,7 @@ s = aString else: if encoding: -# note: no try here. the encoding provided must work for the +# note: no try here. the encoding provided must work for the # incoming byte string. UnicodeDecode error will be raised # in that case. Often, it will be best not to provide the encoding # and allow the default @@ -294,213 +306,131 @@ # write object as JSON# # -#alwaysStripWhiteSpace is defined at the top of the module +import re, codecs +from cStringIO import StringIO -tfnTuple = (('True','true'),('False','false'),('None','null'),) +### Codec error handler -def _replaceTrueFalseNone(aString): -replace True, False, and None with javascript counterparts -for k in tfnTuple: -if k[0] in aString: -aString = aString.replace(k[0],k[1]) -return aString - -def _handleCode(subStr,stripWhiteSpace): -replace True, False, and None with javascript counterparts if - appropriate, remove unicode u's, fix long L's, make tuples - lists, and strip white space if requested - -if 'e' in subStr: -#True, False, and None have 'e' in them. :) -subStr = (_replaceTrueFalseNone(subStr)) -if stripWhiteSpace: -# re.sub might do a better job, but takes longer. -# Spaces are the majority of the whitespace,
[Z3lab-checkins] r2416 - cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview
Author: jmorliaguet Date: Sat Feb 18 16:26:42 2006 New Revision: 2416 Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/browser.py cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/cpsskins_treeview.pt Log: - we only store the tree state in a cookie (not the entire tree data) now both the server and the client have access to the tree state information: the server will use the information to filter out unwanted nodes in getTreeData() Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/browser.py == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/browser.py (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/browser.py Sat Feb 18 16:26:42 2006 @@ -1,4 +1,6 @@ +from urllib import unquote + from zope.app.publisher.browser import BrowserView from cpsskins import minjson as json @@ -18,9 +20,19 @@ class Views(BrowserView): def setTreeData(self, data): -print data +data = json.read(data) return json.write(data) def getTreeData(self): + +print self._getLocalStorageData(1) + + return json.write(data) +# TODO: moves this to an API +def _getLocalStorageData(self, id): +value = self.request.cookies.get('cpsskins_local_storage_%s' % id) +if value is not None: +return json.read(unquote(value)) +return None 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 18 16:26:42 2006 @@ -30,19 +30,17 @@ function openContainer(event) { var target = Event.element(event); var nodeid = target.getAttribute(nodeid); - var model = CPSSkins.getModelById(tree); - var state_data = model.getData(); + var state_data = CPSSkins.getModelById(tree-state).getData(); state_data['state'][nodeid] = open; - model.setData(state_data); + CPSSkins.getModelById(tree).setData(state_data); } function closeContainer(event) { var target = Event.element(event); var nodeid = target.getAttribute(nodeid); - var model = CPSSkins.getModelById(tree); - var state_data = model.getData(); + var state_data = CPSSkins.getModelById(tree-state).getData(); delete state_data['state'][nodeid]; - model.setData(state_data); + CPSSkins.getModelById(tree).setData(state_data); } CPSSkins.registerHandlers( -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2418 - cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview
Author: jmorliaguet Date: Sat Feb 18 17:05:19 2006 New Revision: 2418 Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/browser.py cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/configure.zcml cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/cpsskins_treeview.pt Log: - simplifications Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/browser.py == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/browser.py (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/browser.py Sat Feb 18 17:05:19 2006 @@ -19,15 +19,13 @@ class Views(BrowserView): -def setTreeData(self, data): -data = json.read(data) -return json.write(data) - def getTreeData(self): +local_data = self._getLocalStorageData(1) +if local_data is None: +local_data = {} +tree_state = local_data.get('states', {}) -print self._getLocalStorageData(1) - - +print local_data return json.write(data) # TODO: moves this to an API Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/configure.zcml == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/configure.zcml (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/configure.zcml Sat Feb 18 17:05:19 2006 @@ -48,11 +48,6 @@ attribute=getTreeData / -browser:page -name=setTreeData -attribute=setTreeData -/ - /browser:pages /configure 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 18 17:05:19 2006 @@ -30,17 +30,21 @@ function openContainer(event) { var target = Event.element(event); var nodeid = target.getAttribute(nodeid); - var state_data = CPSSkins.getModelById(tree-state).getData(); - state_data['state'][nodeid] = open; - CPSSkins.getModelById(tree).setData(state_data); + + var model = CPSSkins.getModelById(tree); + var data = model.getData(); + data['state'][nodeid] = open; + model.setData(data); } function closeContainer(event) { var target = Event.element(event); var nodeid = target.getAttribute(nodeid); - var state_data = CPSSkins.getModelById(tree-state).getData(); - delete state_data['state'][nodeid]; - CPSSkins.getModelById(tree).setData(state_data); + + var model = CPSSkins.getModelById(tree); + var data = model.getData(); + delete data['state'][nodeid]; + model.setData(data); } CPSSkins.registerHandlers( -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2419 - cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview
Author: jmorliaguet Date: Sat Feb 18 17:25:25 2006 New Revision: 2419 Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/cpsskins_treeview.pt Log: - setTreeData() is not used anymore (the server already has access to the cookie information) 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 18 17:25:25 2006 @@ -93,8 +93,7 @@ storage: { type: remote, accessors: { - get: @@getTreeData, - set: @@setTreeData + get: @@getTreeData } }} /ins -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2420 - cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview
Author: jmorliaguet Date: Sat Feb 18 18:00:29 2006 New Revision: 2420 Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/browser.py Log: - filter out closed nodes Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/browser.py == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/browser.py (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/browser.py Sat Feb 18 18:00:29 2006 @@ -5,28 +5,47 @@ from cpsskins import minjson as json -data = { +tree_data = { 'items': [ -{'id': 1, 'title': 'item 1', 'depth': 1, 'type': 'container'}, -{'id': 2, 'title': 'item 2', 'depth': 1, 'type': 'container'}, -{'id': 3, 'title': 'item 3', 'depth': 2}, -{'id': 4, 'title': 'item 4', 'depth': 2}, -{'id': 5, 'title': 'item 5', 'depth': 2, 'position': 'last'}, -{'id': 6, 'title': 'item 6', 'depth': 1, 'type': 'container'}, -{'id': 7, 'title': 'item 7', 'depth': 1, 'type': 'container'}, +{'id': '1', 'title': 'item 1', 'depth': 1, 'type': 'container'}, +{'id': '2', 'title': 'item 2', 'depth': 1, 'type': 'container'}, +{'id': '3', 'title': 'item 3', 'depth': 2, 'type': 'item'}, +{'id': '4', 'title': 'item 4', 'depth': 2, 'type': 'item'}, +{'id': '5', 'title': 'item 5', 'depth': 2, 'type': 'item', + 'position': 'last'}, +{'id': '6', 'title': 'item 6', 'depth': 1, 'type': 'container'}, +{'id': '7', 'title': 'item 7', 'depth': 1, 'type': 'container'}, +{'id': '8', 'title': 'item 7', 'depth': 2, 'type': 'item'}, ] } +MAX_DEPTH = 10 + class Views(BrowserView): def getTreeData(self): local_data = self._getLocalStorageData(1) if local_data is None: local_data = {} -tree_state = local_data.get('states', {}) +tree_state = local_data.get('state', {}) + +filtered_items = [] +filter_depth = MAX_DEPTH +for item in tree_data['items']: + +depth = item['depth'] +if depth filter_depth: +continue +else: +filter_depth = MAX_DEPTH + +if item['type'] == 'container': +state = tree_state.get(item['id']) +if state != 'open': +filter_depth = depth -print local_data -return json.write(data) +filtered_items.append(item) +return json.write({'items': filtered_items}) # TODO: moves this to an API def _getLocalStorageData(self, id): -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2421 - cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview
Author: jmorliaguet Date: Sat Feb 18 18:03:05 2006 New Revision: 2421 Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/cpsskins_treeview.pt Log: - functional tree - needs more polishing 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 18 18:03:05 2006 @@ -31,20 +31,24 @@ var target = Event.element(event); var nodeid = target.getAttribute(nodeid); - var model = CPSSkins.getModelById(tree); + var model = CPSSkins.getModelById(tree-state); var data = model.getData(); data['state'][nodeid] = open; model.setData(data); + + CPSSkins.getModelById(tree).getData() } function closeContainer(event) { var target = Event.element(event); var nodeid = target.getAttribute(nodeid); - var model = CPSSkins.getModelById(tree); + var model = CPSSkins.getModelById(tree-state); var data = model.getData(); delete data['state'][nodeid]; model.setData(data); + + CPSSkins.getModelById(tree).getData() } CPSSkins.registerHandlers( -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2422 - cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview
Author: jmorliaguet Date: Sat Feb 18 18:09:44 2006 New Revision: 2422 Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/browser.py cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/treeview_widget.pt Log: - renamed 'container' as 'inner' and 'item' as 'leaf' Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/browser.py == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/browser.py (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/browser.py Sat Feb 18 18:09:44 2006 @@ -7,15 +7,16 @@ tree_data = { 'items': [ -{'id': '1', 'title': 'item 1', 'depth': 1, 'type': 'container'}, -{'id': '2', 'title': 'item 2', 'depth': 1, 'type': 'container'}, -{'id': '3', 'title': 'item 3', 'depth': 2, 'type': 'item'}, -{'id': '4', 'title': 'item 4', 'depth': 2, 'type': 'item'}, -{'id': '5', 'title': 'item 5', 'depth': 2, 'type': 'item', +{'id': '1', 'title': 'item 1', 'depth': 1, 'type': 'inner'}, +{'id': '2', 'title': 'item 2', 'depth': 1, 'type': 'inner'}, +{'id': '3', 'title': 'item 3', 'depth': 2, 'type': 'leaf'}, +{'id': '4', 'title': 'item 4', 'depth': 2, 'type': 'inner'}, +{'id': '5', 'title': 'item 5', 'depth': 3, 'type': 'leaf', + 'position': 'last'}, +{'id': '6', 'title': 'item 6', 'depth': 1, 'type': 'inner'}, +{'id': '7', 'title': 'item 7', 'depth': 1, 'type': 'inner'}, +{'id': '8', 'title': 'item 7', 'depth': 2, 'type': 'leaf', 'position': 'last'}, -{'id': '6', 'title': 'item 6', 'depth': 1, 'type': 'container'}, -{'id': '7', 'title': 'item 7', 'depth': 1, 'type': 'container'}, -{'id': '8', 'title': 'item 7', 'depth': 2, 'type': 'item'}, ] } @@ -39,7 +40,7 @@ else: filter_depth = MAX_DEPTH -if item['type'] == 'container': +if item['type'] == 'inner': state = tree_state.get(item['id']) if state != 'open': filter_depth = depth Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/treeview_widget.pt == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/treeview_widget.pt (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/treeview_widget.pt Sat Feb 18 18:09:44 2006 @@ -7,19 +7,19 @@ img class=close ctal:attributes=nodeid item/id src=/++skin++cpsskins-test/@@/++resource++container-open.png ctal:condition=javascript:state[item['id']] == 'open' - item['type'] == 'container' / + item['type'] == 'inner' / img class=open ctal:attributes=nodeid item/id src=/++skin++cpsskins-test/@@/++resource++container.png ctal:condition=javascript:state[item['id']] != 'open' - item['type'] == 'container' / + item['type'] == 'inner' / img src=/++skin++cpsskins-test/@@/node-link-branch.png - ctal:condition=javascript:item['type'] != 'container' + ctal:condition=javascript:item['type'] == 'leaf' item['position'] != 'last'/ img src=/++skin++cpsskins-test/@@/node-link-last.png - ctal:condition=javascript:item['type'] != 'container' + ctal:condition=javascript:item['type'] == 'leaf' item['position'] == 'last'/ img src=/++skin++cpsskins-test/@@/folder.png / -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2423 - cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview
Author: jmorliaguet Date: Sat Feb 18 18:17:56 2006 New Revision: 2423 Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/browser.py cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/treeview_widget.pt Log: - cosmetic Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/browser.py == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/browser.py (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/browser.py Sat Feb 18 18:17:56 2006 @@ -8,14 +8,16 @@ tree_data = { 'items': [ {'id': '1', 'title': 'item 1', 'depth': 1, 'type': 'inner'}, -{'id': '2', 'title': 'item 2', 'depth': 1, 'type': 'inner'}, +{'id': '2', 'title': 'item 2', 'depth': 2, 'type': 'inner', + 'empty': True}, {'id': '3', 'title': 'item 3', 'depth': 2, 'type': 'leaf'}, {'id': '4', 'title': 'item 4', 'depth': 2, 'type': 'inner'}, {'id': '5', 'title': 'item 5', 'depth': 3, 'type': 'leaf', 'position': 'last'}, {'id': '6', 'title': 'item 6', 'depth': 1, 'type': 'inner'}, -{'id': '7', 'title': 'item 7', 'depth': 1, 'type': 'inner'}, -{'id': '8', 'title': 'item 7', 'depth': 2, 'type': 'leaf', +{'id': '7', 'title': 'item 7', 'depth': 2, 'type': 'inner', + 'empty': True}, +{'id': '8', 'title': 'item 8', 'depth': 2, 'type': 'leaf', 'position': 'last'}, ] } Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/treeview_widget.pt == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/treeview_widget.pt (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/treeview_widget.pt Sat Feb 18 18:17:56 2006 @@ -6,17 +6,18 @@ img class=close ctal:attributes=nodeid item/id src=/++skin++cpsskins-test/@@/++resource++container-open.png - ctal:condition=javascript:state[item['id']] == 'open' - item['type'] == 'inner' / + ctal:condition=javascript:state[item['id']] == 'open' !item['empty'] +item['type'] == 'inner' / img class=open ctal:attributes=nodeid item/id src=/++skin++cpsskins-test/@@/++resource++container.png - ctal:condition=javascript:state[item['id']] != 'open' - item['type'] == 'inner' / + ctal:condition=javascript:state[item['id']] != 'open' !item['empty'] +item['type'] == 'inner' / img src=/++skin++cpsskins-test/@@/node-link-branch.png - ctal:condition=javascript:item['type'] == 'leaf' -item['position'] != 'last'/ + ctal:condition=javascript:(item['type'] == 'leaf' +item['position'] != 'last') + || item['empty']/ img src=/++skin++cpsskins-test/@@/node-link-last.png ctal:condition=javascript:item['type'] == 'leaf' @@ -24,6 +25,6 @@ img src=/++skin++cpsskins-test/@@/folder.png / - a ctal:content=item/titleITEM/a + span ctal:content=item/titleITEM/span /div -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2424 - cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview
Author: jmorliaguet Date: Sat Feb 18 18:32:48 2006 New Revision: 2424 Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/cpsskins_treeview.pt cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/treeview_widget.pt Log: - cosmetic 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 18 18:32:48 2006 @@ -18,16 +18,19 @@ style type=text/css + #area0 { +border: 1px solid #ddd; +padding: 1em; +width: 175px; +margin: 1em; + } .tree img { vertical-align: middle; } - - .tree a { - } /style script type=text/javascript -function openContainer(event) { +function openNode(event) { var target = Event.element(event); var nodeid = target.getAttribute(nodeid); @@ -39,7 +42,7 @@ CPSSkins.getModelById(tree).getData() } -function closeContainer(event) { +function closeNode(event) { var target = Event.element(event); var nodeid = target.getAttribute(nodeid); @@ -52,8 +55,8 @@ } CPSSkins.registerHandlers( - {'open-container': openContainer, - 'close-container': closeContainer + {'open-node': openNode, + 'close-node': closeNode } ); /script @@ -63,6 +66,15 @@ h1CPSSkins treeview/h1 + pIn this example the tree view is entirely rendered on the client. + without reloading the page/p + + pThe tree state is stored in a local storage using cookies. Hence the user + may reload the page and the tree state will be restored as long as + the cookie information does not expire/p + + pThe server uses the tree state information to generate the tree data./p + div id=area0 ins class=controller @@ -70,10 +82,10 @@ type: behaviour, rules: { img.open: { - click: open-container + click: open-node }, img.close: { - click: close-container + click: close-node } }} /ins Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/treeview_widget.pt == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/treeview_widget.pt (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/treeview_widget.pt Sat Feb 18 18:32:48 2006 @@ -1,4 +1,6 @@ +div ctal:condition=javascript:items.length == 0Loading data .../div + div class=tree ctal:repeat=item items span ctal:attributes=style -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2425 - cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview
Author: jmorliaguet Date: Sat Feb 18 18:37:12 2006 New Revision: 2425 Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/treeview/cpsskins_treeview.pt Log: - no hardcoded data 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 18 18:37:12 2006 @@ -117,7 +117,7 @@ ins class=model {id: tree, data: { - state: {1: open, 2: open}, + state: {}, items: [] }, storage: { -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2427 - in cpsskins/branches/jmo-perspectives/ui/framework: . tests/functional
Author: jmorliaguet Date: Sat Feb 18 23:28:45 2006 New Revision: 2427 Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_progressive_enhancement.html cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_widget_templates.html Log: - simplified the effect API - added a 'render_effect' when the widget is rendered. 'show_effect' is when the widget is shown, and 'hide_effect' is when the widget is hidden 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 18 23:28:45 2006 @@ -1191,9 +1191,6 @@ this.widget = widget; this.def = def; -this.show_effect = def.show_effect || {}; -this.hide_effect = def.hide_effect || {}; - this.setup(); }, @@ -1238,6 +1235,10 @@ display: function(data) { this.render(data); +if (this.def.render_effect) { + Element.hide(this.widget); + this.applyEffect(this.widget, this.def.render_effect) +} CPSSkins.notify(displayed, {'publisher': this}); }, @@ -1254,17 +1255,10 @@ // prepare the view this.prepare(); -if (this.effect) { - this.effect.stop(); -} - -var widget = this.widget; -var show_effect = this.show_effect; -if (show_effect) { - show_effect.transition = show_effect.transition || show; - this.effect = this.applyEffect(widget, show_effect) +if (this.def.show_effect) { + this.applyEffect(this.widget, this.def.show_effect) } else { - Element.show(widget); + Element.show(this.widget); } this.visible = true; }, @@ -1273,17 +1267,11 @@ if (!this.visible) { return; } -var widget = this.widget; -if (this.effect !this.effect.started) { - this.effect.stop(); -} -var hide_effect = this.hide_effect; -if (hide_effect) { - hide_effect.transition = hide_effect.transition || hide; - this.effect = this.applyEffect(widget, hide_effect); +if (this.def.hide_effect) { + this.applyEffect(this.widget, this.def.hide_effect); } else { - Element.hide(widget); + Element.hide(this.widget); } this.visible = false; @@ -1294,9 +1282,12 @@ }, applyEffect: function(node, options) { - if (options.transition in CPSSkins.Effects) { -return CPSSkins.Effects[options.transition](node, options) - } +if (this.effect) { + this.effect.stop(); +} +if (options.transition in CPSSkins.Effects) { + this.effect = CPSSkins.Effects[options.transition](node, options) +} } } Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_progressive_enhancement.html == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_progressive_enhancement.html (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_progressive_enhancement.html Sat Feb 18 23:28:45 2006 @@ -58,8 +58,10 @@ template: ajax_widget_template.pt, replace: htmlwidget }, - model: ram-data-provider - } + model: ram-data-provider, + render_effect: { + transition: fadein + }} /ins /body Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_widget_templates.html == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_widget_templates.html (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_widget_templates.html Sat Feb 18 23:28:45 2006 @@ -70,7 +70,10 @@ {widget: { template: template.pt }, - model: template-data + model: template-data, + render_effect: { + transition: fadein + } } /ins -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2428 - cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/treeview
Author: jmorliaguet Date: Sat Feb 18 23:29:25 2006 New Revision: 2428 Removed: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/treeview/ Log: - was moved -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins