[Z3lab-checkins] r2372 - cpsskins/branches/jmo-perspectives/ui/framework
Author: jmorliaguet Date: Sun Feb 12 22:39:17 2006 New Revision: 2372 Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js Log: - removed rendering artefact where the template was displayed before being interpreted. 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 Sun Feb 12 22:39:17 2006 @@ -1244,8 +1244,10 @@ render: function(data) { if (this.source) { - this.widget.innerHTML = this.source; - ctal.process_ctal(this.widget, data); + var node = document.createElement("div"); + node.innerHTML = this.source; + ctal.process_ctal(node, data); + this.widget.innerHTML = node.innerHTML; } } -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2371 - cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/forms
Author: jmorliaguet Date: Sun Feb 12 22:34:08 2006 New Revision: 2371 Added: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/forms/form.css (contents, props changed) cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/forms/sampleform.pt (contents, props changed) Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/forms/browser.py cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/forms/configure.zcml cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/forms/cpsskins_form_validation.pt Log: - the sample form is drawn using a template (-70 lines) Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/forms/browser.py == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/forms/browser.py (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/forms/browser.py Sun Feb 12 22:34:08 2006 @@ -68,14 +68,22 @@ fields = [] for name in form_layout: field_def = FieldProperty(self.schema[name]) -fields.append({ +field_info = { 'name': name, 'label': field_def.title, 'hint': field_def.description, 'value': field_def.default, 'disabled': field_def.readonly, 'status': u'', -}) +} + +choices = getattr(field_def, 'vocabulary', None) +#if choices: + #print list(choices) + #field_info['values'] = choices() + +fields.append(field_info) + return {'fields': fields} def getFormData(self): @@ -97,7 +105,7 @@ field['status'] = u'' try: value = schema_field.fromUnicode(value) -except ConstraintNotSatisfied: +except (ValueError, ConstraintNotSatisfied): field['status'] = u"Incorrect value" except RequiredMissing: field['status'] = u"this field is required" @@ -105,6 +113,7 @@ field['value'] = value form_data = {'fields': fields} +print form_data cache.set(form_data, 'formdata', {}) return json.write(form_data) Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/forms/configure.zcml == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/forms/configure.zcml (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/forms/configure.zcml Sun Feb 12 22:34:08 2006 @@ -1,6 +1,10 @@ http://namespaces.zope.org/browser";> + + + + + - - form { -border: 1px solid #ccc; -background-color: #f6f3f0; -padding: 1em; -font: 1.3em arial, sans-serif; - } - - label { -padding: 1em; - } - - .hint { -padding: 1em; - } - - .status { -padding: 1em; -color: red; - } - - input { -border: 1px solid #999; -background-color: #fff; - } - - input.disabled { -border-style: none; -color: black; - } - - input:focus { -background-color: #ffc; - } - - button { -margin: 1em; -border: 1px solid #999; -background-color: #ddd; - } - - - - -Object.extend(Widgets, { - - sampleform: function(def) { -var widget = Canvas.createNode({ - tag: "form", - attributes: {"method": "post"} -}); -return new SampleForm(widget, def); - } - -}); - -SampleForm = Class.create(); -SampleForm.prototype = Object.extend(new CPSSkins.View(), { - - render: function(data) { -var widget = this.widget; -widget.innerHTML = ''; - -var fields = data.fields; - -var renderField = this._renderField; -$A(fields).each(function(f) { - widget.appendChild(renderField(f)); -}); - -var button = Canvas.createNode({ - tag: "button", - attributes: { -"type": "submit" - }, - text: "SEND!" -}); -widget.appendChild(button); - - }, - - _renderField: function(field) { -var p = Canvas.createNode({"tag": "p"}); - -var label = Canvas.createNode({ - tag: "label", - text: field.label -}); -p.appendChild(label); - - -var input_options = { - "tag": "input", - "attributes": { -"name": field.name, -"type": "text", -"value": field.value, - } -} - -if (field.disabled == true) { - input_options["attributes"]["disabled"] = "disabled"; - input_options["classes"] = "disabled"; -
[Z3lab-checkins] r2370 - cpsskins/branches/jmo-perspectives/ui/framework
Author: jmorliaguet Date: Sun Feb 12 22:25:25 2006 New Revision: 2370 Modified: cpsskins/branches/jmo-perspectives/ui/framework/ctal.js Log: - bug fix: 'tmpl' can only be removed in the end of the loop otherwise it cannot be cloned inside the loop. (could not produce a test case though) Modified: cpsskins/branches/jmo-perspectives/ui/framework/ctal.js == --- cpsskins/branches/jmo-perspectives/ui/framework/ctal.js (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/ctal.js Sun Feb 12 22:25:25 2006 @@ -156,7 +156,6 @@ var parent = tmpl.parentNode; if (!parent) return; var marker = tmpl.nextSibling; - parent.removeChild(tmpl); // the iterator variable has the same name as the looped through array. if (nmx[0] == nmx[1]) { @@ -183,6 +182,7 @@ data = ctal.deepcopy(saved_data); } } + parent.removeChild(tmpl); } /* general processor */ -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2369 - in cpsskins/branches/jmo-perspectives/ui/framework: . tests/unit
Author: jmorliaguet Date: Sun Feb 12 22:12:28 2006 New Revision: 2369 Modified: cpsskins/branches/jmo-perspectives/ui/framework/ctal.js cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html Log: - more protection against data corruption Modified: cpsskins/branches/jmo-perspectives/ui/framework/ctal.js == --- cpsskins/branches/jmo-perspectives/ui/framework/ctal.js (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/ctal.js Sun Feb 12 22:12:28 2006 @@ -152,11 +152,18 @@ throw e } } + var parent = tmpl.parentNode; if (!parent) return; var marker = tmpl.nextSibling; parent.removeChild(tmpl); + // the iterator variable has the same name as the looped through array. + if (nmx[0] == nmx[1]) { +throw new ctal.TALError(nmx[0] + + " iterator variable overwrites loop variable."); + } + for (var i=0; i... + +... + +
[Z3lab-checkins] r2368 - cpsskins/branches/jmo-perspectives/ui/framework
Author: jmorliaguet Date: Sun Feb 12 19:15:07 2006 New Revision: 2368 Modified: cpsskins/branches/jmo-perspectives/ui/framework/ctal.js Log: - bug fix Modified: cpsskins/branches/jmo-perspectives/ui/framework/ctal.js == --- cpsskins/branches/jmo-perspectives/ui/framework/ctal.js (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/ctal.js Sun Feb 12 19:15:07 2006 @@ -157,13 +157,12 @@ var marker = tmpl.nextSibling; parent.removeChild(tmpl); - var current_data, saved_data; for (var i=0; ihttp://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2367 - cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat
Author: jmorliaguet Date: Sun Feb 12 17:29:33 2006 New Revision: 2367 Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/cpsskins_chat.pt Log: - the default user is 'Guest' Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/cpsskins_chat.pt == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/cpsskins_chat.pt (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/cpsskins_chat.pt Sun Feb 12 17:29:33 2006 @@ -113,7 +113,7 @@ "data": { "status": "", "input": "", - "user": "" + "user": "Guest" }, "storage": { "type": "compound", -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2366 - cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat
Author: jmorliaguet Date: Sun Feb 12 15:54:34 2006 New Revision: 2366 Added: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/chat.css (contents, props changed) Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/chatinput.pt cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/configure.zcml cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/cpsskins_chat.pt Log: - updated the chat demo to make it work with templates Added: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/chat.css == --- (empty file) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/chat.css Sun Feb 12 15:54:34 2006 @@ -0,0 +1,55 @@ + +div.chatbox { + padding: 0.5em; + border: 1px solid #999; + background-color: #cd9; +} + +form { + border: 1px solid #ccc; + background-color: #eee; + padding: 0.7em; + margin: 1em 0; +} + +label { + font: 14px arial, sans-serif; +} + +input { + border: 1px solid #999; + padding: 0.2em; + margin: 0 1em 0 0; + font: 14px arial, sans-serif; +} + +input:focus { + background-color: #efc; +} + +button { + background-color: #efc; + border: 1px solid #999; + padding: 0.2em; + margin: 0 1em 0 0; + font: 15px arial, sans-serif; +} + +div.message { + border: 1px solid #999; + background-color: #efc; + padding: 0.5em; + margin: 0.2em; + font: 13px arial, sans-serif; +} + +div.status { + border: 1px solid #000; + background-color: #fc0; + padding: 0.5em; + margin: 0.3em 0; + margin-bottom: 1em; + position: absolute; + top: 40px; + right: 20px; +} Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/chatinput.pt == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/chatinput.pt (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/chatinput.pt Sun Feb 12 15:54:34 2006 @@ -1,3 +1,18 @@ - - not done yet + + + status message + + + + Your message: + + + + Chat as: + + + + SEND! + Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/configure.zcml == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/configure.zcml (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/configure.zcml Sun Feb 12 15:54:34 2006 @@ -1,9 +1,13 @@ http://namespaces.zope.org/browser";> + + Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/cpsskins_chat.pt == --- cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/cpsskins_chat.pt (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/chat/cpsskins_chat.pt Sun Feb 12 15:54:34 2006 @@ -16,134 +16,8 @@ - -div.chatbox { - padding: 0.5em; - border: 1px solid #999; - background-color: #cd9; -} - -form { - padding: 1em 0; -} - -input { - border: 1px solid #999; - padding: 0.2em; - margin: 0 1em 0 0; - font: 15px verdana, arial, sans-serif; -} - -input:focus { - background-color: #efc; -} - -button { - background-color: #efc; - border: 1px solid #999; - padding: 0.2em; - margin: 0 1em 0 0; - font: 15px arial, sans-serif; -} - -div.message { - border: 1px solid #999; - background-color: #efc; - padding: 0.5em; - margin: 0.2em; - font: 13px verdana, arial, sans-serif; -} - -div.status { - border: 1px solid #000; - background-color: #fc0; - padding: 0.5em; - margin: 0.3em 0; - margin-bottom: 1em; - position: absolute; - top: 40px; - right: 20px; -} - - - - - -Object.extend(Widgets, { - - inputbox: function(def) { -var widget = Canvas.createNode({ - tag: "form", - classes: "inputbox", - attributes: {"method": "post"} -}); -return new InputBox(widget, def); - } - -}); - -InputBox = Class.create(); -InputBox.prototype = Object.extend(new CPSSkins.View(), { - - render: function(data) { -var widget = this.widget; -widget.innerHTML = ''; - -var status = data.status; -if (status) { - var statusbox = Canvas.createNode({ -tag: "div", -classes: "status", -text: status - }); - widget.appendChild(statusbox); -} - -var input = Canvas.createNode({
[Z3lab-checkins] r2365 - cpsskins/branches/jmo-perspectives/ui/framework
Author: jmorliaguet Date: Sun Feb 12 15:53:53 2006 New Revision: 2365 Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js Log: - fixed the form controller to make it work with templates 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 Sun Feb 12 15:53:53 2006 @@ -241,10 +241,13 @@ } else { /* generic widget type */ widget_type = def.widget.type; +if (!widget_type) { + CPSSkins.warn("Must specify a widget type or a template", el); +} else if (!(widget_type in Widgets)) { + CPSSkins.warn("Unknown widget type: " + widget_type, el); +} } - if (widget_type && !(widget_type in Widgets)) { -CPSSkins.warn("Unknown widget type: " + widget_type, el); - } + factory = Widgets[widget_type]; view = factory(def); @@ -261,6 +264,8 @@ view.observe(model); }); CPSSkins.subscribe(evt_id, {'subscriber': view, 'target': null}); +} else { + CPSSkins.warn("Must specify a model for " + view.inspect(), el); } /* register the controller */ @@ -269,7 +274,7 @@ var evt_id = "registered controller " + controller_id; CPSSkins.registerEventHandler(evt_id, view, function(event) { var controller = event.target; -controller.register(view); +controller.control(view); }); CPSSkins.subscribe(evt_id, {'subscriber': view, 'target': null}); } @@ -280,6 +285,8 @@ var replaced = $(replace); if (replaced) { replaced.parentNode.replaceChild(view.widget, replaced); + } else { +CPSSkins.warn("Unknown node id: " + replace, el); } } else { el.parentNode.insertBefore(view.widget, el); @@ -381,7 +388,7 @@ this.def = def; }, - register: function(view) { + control: function(view) { /* to override */ } @@ -403,7 +410,7 @@ CPSSkins.CommandController = Class.create(); CPSSkins.CommandController.prototype = Object.extend(new CPSSkins.Controller(), { - register: function(view) { + control: function(view) { var controller = this; view.controller = controller; @@ -434,26 +441,21 @@ CPSSkins.FormController = Class.create(); CPSSkins.FormController.prototype = Object.extend(new CPSSkins.Controller(), { - register: function(view) { + control: function(view) { +this.view = view; var controller = this; view.controller = controller; -var form = view.widget; - -// prevent the browser from posting the form directly -form.setAttribute("onsubmit", "return false"); - -if (form.tagName.toLowerCase() != 'form') { - CPSSkins.warn("A form controller requires a form widget.", form); -} +var widget = view.widget; this.submitEvent = this.submitEvent.bindAsEventListener(this); -Event.observe(form, "submit", this.submitEvent); +Event.observe(widget, "submit", this.submitEvent); }, submitEvent: function(e) { -var widget = Event.element(e); -var model = widget.view.model; +var view = this.view; +var model = this.view.model; +var widget = this.view.widget; var form_data = {}; $A(Form.getInputs(widget)).each(function(i) { @@ -465,7 +467,6 @@ }); - // Identifiable DOM elements. if (!window.Identifiable) var Identifiable = new Object(); Object.extend(Identifiable, { @@ -1237,6 +1238,10 @@ }, + inspect: function() { +return "[Widget " + this.def.widget.template + "]"; + }, + render: function(data) { if (this.source) { this.widget.innerHTML = this.source; -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins