[Z3lab-checkins] r2431 - cpsskins/branches/jmo-perspectives/ui/framework
Author: jmorliaguet Date: Sun Feb 19 13:23:17 2006 New Revision: 2431 Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js Log: - renamed private variables using the js styleguide 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 19 13:23:17 2006 @@ -36,18 +36,13 @@ var CPSSkins = { Version: "0.7", - Subscribers: $H({}), - - Models: $H({}), - - Controllers: $H({}), - - Handlers: $H({}), - - Perspectives: $H({}), - - CurrentPerspective: "", - PreviousPerspective: "", + _subscribers: $H({}), + _models: $H({}), + _controllers: $H({}), + _handlers: $H({}), + _perspectives: $H({}), + _currentPerspective: "", + _previousPerspective: "", init: function() { CPSSkins.parse(document); @@ -55,7 +50,7 @@ getModelById: function(id) { var model = null; -$A(CPSSkins.Models).each(function(m) { +$A(CPSSkins._models).each(function(m) { var def = m[1].def; if (def.id == id) { model = m[1] @@ -66,7 +61,7 @@ getControllerById: function(id) { var controller = null; -$A(CPSSkins.Controllers).each(function(c) { +$A(CPSSkins._controllers).each(function(c) { var def = c[1].def; if (def.id == id) { controller = c[1] @@ -85,29 +80,29 @@ /* Public events */ registerHandlers: function(handlers) { -Object.extend(CPSSkins.Handlers, handlers); +Object.extend(CPSSkins._handlers, handlers); }, /* Internal events */ subscribe: function(eventid, event) { -if (!(eventid in CPSSkins.Subscribers)) { - CPSSkins.Subscribers[eventid] = $A([]); +if (!(eventid in CPSSkins._subscribers)) { + CPSSkins._subscribers[eventid] = $A([]); } -CPSSkins.Subscribers[eventid].push(event); +CPSSkins._subscribers[eventid].push(event); }, unsubscribe: function(eventid, event) { new_subscribers = $A([]); -CPSSkins.Subscribers[eventid].each(function(e) { +CPSSkins._subscribers[eventid].each(function(e) { if (!(event.subscriber == e.subscriber && event.publisher == e.publisher)) { new_subscribers.push(e); } }); -CPSSkins.Subscribers[eventid] = new_subscribers; +CPSSkins._subscribers[eventid] = new_subscribers; }, notify: function(eventid, event) { -var subscribers = CPSSkins.Subscribers[eventid]; +var subscribers = CPSSkins._subscribers[eventid]; var publisher = event.publisher; $A(subscribers).each(function(e) { var event_publisher = e.publisher; @@ -217,7 +212,7 @@ var factory = Controllers[controller_type]; if (factory) { var controller = factory(el, def); -CPSSkins.Controllers[name] = controller; +CPSSkins._controllers[name] = controller; CPSSkins.notify("registered controller " + def.id, {'publisher': controller}); } @@ -226,7 +221,7 @@ case "model": { var model = new CPSSkins.Model(el, def); - CPSSkins.Models[name] = model; + CPSSkins._models[name] = model; CPSSkins.notify("registered model " + def.id, {'publisher': model}); break; } @@ -294,10 +289,10 @@ var perspectives = def.perspectives || []; $A(perspectives).each(function(p) { if (!p) return; - if (!(p in CPSSkins.Perspectives)) { -CPSSkins.Perspectives[p] = $A([]); + if (!(p in CPSSkins._perspectives)) { +CPSSkins._perspectives[p] = $A([]); } - CPSSkins.Perspectives[p].push(view); + CPSSkins._perspectives[p].push(view); }); //CPSSkins.notify("registered view " + def.id, view); } @@ -308,7 +303,7 @@ }, _resolvePerspective: function(perspective) { -var path = CPSSkins.CurrentPerspective.split("/"); +var path = CPSSkins._currentPerspective.split("/"); var base = perspective; var ext = ""; @@ -319,7 +314,7 @@ } if (perspective.substr(0,2) == "./") { - base = CPSSkins.CurrentPerspective; + base = CPSSkins._currentPerspective; if (base) { base += "/"; } @@ -336,7 +331,7 @@ } if (perspective == '-') { - base = CPSSkins.PreviousPerspective; + base = CPSSkins._previousPerspective; } return base + ext; @@ -347,7 +342,7 @@ var to_hide = []; perspective = CPSSkins._resolvePerspective(perspective); -CPSSkins.Perspectives.each(function(s) { +CPSSkins._perspectives.each(function(s) { var elements = s[1]; var path = perspective.split("/"); path.each(function(p, index) { @@ -368,8 +363,8 @@ $A(to
[Z3lab-checkins] r2432 - in cpsskins/branches/jmo-perspectives/ui/framework: . tests/functional tests/unit tests/zope3/functional/latency tests/zope3/functional/quiz
Author: jmorliaguet Date: Sun Feb 19 14:01:07 2006 New Revision: 2432 Added: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_widget_template_test.html - copied unchanged from r2430, cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_widget_templates.html Removed: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_widget_templates.html Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_observer_test.html cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/tests.html cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_test.html cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/latency/cpsskins_latency.pt cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/latency/cpsskins_typewriter.pt cpsskins/branches/jmo-perspectives/ui/framework/tests/zope3/functional/quiz/cpsskins_quiz.pt Log: - cleaned up the global namespace, all classes / objects are now located under CPSSkins.___ 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 19 14:01:07 2006 @@ -209,7 +209,7 @@ case "controller": { var controller_type = def.type || "command"; - var factory = Controllers[controller_type]; + var factory = CPSSkins.Controllers[controller_type]; if (factory) { var controller = factory(el, def); CPSSkins._controllers[name] = controller; @@ -238,12 +238,12 @@ 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)) { +} else if (!(widget_type in CPSSkins.Widgets)) { CPSSkins.warn("Unknown widget type: " + widget_type, el); } } - factory = Widgets[widget_type]; + factory = CPSSkins.Widgets[widget_type]; view = factory(def); /* create the view */ @@ -387,8 +387,8 @@ } -if (!window.Controllers) { var Controllers = new Object(); } -Object.extend(Controllers, { +if (!CPSSkins.Controllers) { CPSSkins.Controllers = new Object(); } +Object.extend(CPSSkins.Controllers, { 'command': function(node, def) { return new CPSSkins.CommandController(node, def); @@ -507,7 +507,7 @@ var view = event.publisher; var selected = event.context; if (!view.def.model) { -var model = Canvas.getModel(selected); +var model = CPSSkins.Canvas.getModel(selected); if (model) { view.observe(model); } @@ -526,8 +526,8 @@ }); // Identifiable DOM elements. -if (!window.Identifiable) var Identifiable = new Object(); -Object.extend(Identifiable, { +if (!CPSSkins.Identifiable) { CPSSkins.Identifiable = new Object() } +Object.extend(CPSSkins.Identifiable, { isIdentifiable: function(node) { node = $(node); @@ -607,13 +607,14 @@ }); -if (!window.Canvas) { - var Canvas = new Object(); - Canvas.Styles = $({}); - Canvas.Script = $({}); +if (!CPSSkins.Canvas) { + CPSSkins.Canvas = { +_styles: {}, +_scripts: {} + } } -Object.extend(Canvas, { +Object.extend(CPSSkins.Canvas, { getModel: function(node) { if (!node) return null; @@ -688,7 +689,7 @@ }, addStyleSheet: function(id, src) { -if (id in Canvas.Styles) { +if (id in this._styles) { return; } var head = document.getElementsByTagName("head")[0]; @@ -698,12 +699,12 @@ link.href = src; link.type = "text/css"; head.appendChild(link); -Canvas.Styles[id] = src; +this._styles[id] = src; }, removeStyleSheet: function(id) { -if (id in Canvas.Styles) { - delete Canvas.Styles[id]; +if (id in this._styles) { + delete this._styles[id]; } var style = document.getElementById("cpsskins-style-" + id); if (style) { @@ -712,7 +713,7 @@ }, addScript: function(id, src) { -if (id in Canvas.Scripts) { +if (id in this._scripts) { return; } var head = document.getElementsByTagName("head")[0]; @@ -721,12 +722,12 @@ script.href = src; script.type = "text/javascript"; head.appendChild(script); -Canvas.Scripts[id] = src; +this._scripts[id] = src; }, removeScript: function(id) { -if (id in Canvas.Scripts) { - delete Canvas.Scripts[src]; +if (id in this._scripts) { + delete this._scripts[src]; } var script = document.getElementById("cpsskins-script-" + id); if (script) { @@ -903,7 +904,7 @@ this.def.stora
[Z3lab-checkins] r2433 - cpsskins/branches/jmo-perspectives/ui/framework
Author: jmorliaguet Date: Sun Feb 19 23:18:26 2006 New Revision: 2433 Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js Log: - optimisations 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 19 23:18:26 2006 @@ -810,14 +810,15 @@ }, fadein: function(node, options) { +var setOpacity = CPSSkins.Canvas.setOpacity; if (node.style.display == "none") { node.style.display = ""; - Canvas.setOpacity(node, 0); + setOpacity(node, 0); } return new CPSSkins.Scheduler(node, { delay: options.delay, action: function(value) { -Canvas.setOpacity(node, value); +setOpacity(node, value); }, onComplete: function() { Element.show(node); @@ -826,10 +827,11 @@ }, fadeout: function(node, options) { +var setOpacity = CPSSkins.Canvas.setOpacity; return new CPSSkins.Scheduler(node, { delay: options.delay, action: function(value) { -Canvas.setOpacity(node, 1-value); +setOpacity(node, 1-value); }, onComplete: function() { Element.hide(node); @@ -1482,6 +1484,7 @@ _renderFragment: function(container, fragment, data) { +var createNode = CPSSkins.Canvas.createNode; $A(fragment.items).each(function(item) { var type = item.type; @@ -1513,10 +1516,10 @@ options.attributes.disabled = true; options.classes.push("disabled"); } - var a = CPSSkins.Canvas.createNode(options); + var a = createNode(options); var icon = disabled ? "noicon.png": (item.icon || "noicon.png"); - a.appendChild(CPSSkins.Canvas.createNode({ + a.appendChild(createNode({ tag: "img", attributes: { "src": icon, @@ -1543,10 +1546,10 @@ href: "javascript:void(0)" } } -var a = CPSSkins.Canvas.createNode(options); +var a = createNode(options); var icon = disabled ? "noicon.png": (item.icon || "noicon.png"); -a.appendChild(CPSSkins.Canvas.createNode({ +a.appendChild(createNode({ tag: "img", attributes: { "src": icon, @@ -1561,7 +1564,7 @@ }; case "separator": { - var node = CPSSkins.Canvas.createNode({ + var node = createNode({ tag: "div", classes: "separator" }); @@ -1578,10 +1581,10 @@ }; if (disabled) { options.classes = "disabled"; } - var submenuitem = container.appendChild(CPSSkins.Canvas.createNode(options)); + var submenuitem = container.appendChild(createNode(options)); var icon = item.icon || "noicon.png"; - submenuitem.appendChild(CPSSkins.Canvas.createNode({ + submenuitem.appendChild(createNode({ tag: "img", attributes: { "src": icon, @@ -1593,7 +1596,7 @@ this.submenuLeft = Element.getDimensions(this.widget).width -2; } - var submenu = CPSSkins.Canvas.createNode({ + var submenu = createNode({ tag: "div", classes: "submenu", style: { @@ -1713,6 +1716,7 @@ }, _renderFragment: function(container, fragment, data) { +var createNode = CPSSkins.Canvas.createNode; $A(fragment.items).each(function(item) { if (item.type != "item") return; var visible = item.visible; @@ -1735,9 +1739,9 @@ options.attributes.confirm = confirm; } - var a = CPSSkins.Canvas.createNode(options); + var a = createNode(options); var icon = disabled ? "noicon.png": (item.icon || "noicon.png"); - a.appendChild(CPSSkins.Canvas.createNode({ + a.appendChild(createNode({ tag: "img", attributes: { "src": icon, -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2434 - cpsskins/branches/jmo-perspectives/ui/framework
Author: jmorliaguet Date: Mon Feb 20 01:33:38 2006 New Revision: 2434 Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js Log: - added a basic drag-and-drop controller 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 Mon Feb 20 01:33:38 2006 @@ -404,6 +404,10 @@ 'focus observer': function(node, def) { return new CPSSkins.FocusObserver(node, def); + }, + + 'drag-and-drop': function(node, def) { +return new CPSSkins.DragAndDropController(node, def); } }); @@ -490,7 +494,6 @@ }); model.setData(form_data); - return false; } @@ -525,6 +528,40 @@ }); +CPSSkins.DragAndDropController = Class.create(); +CPSSkins.DragAndDropController.prototype = Object.extend( + new CPSSkins.Controller(), { + + register: function(view) { +var widget = view.widget; + +this.dragEvent = this.dragEvent.bindAsEventListener(this); +this.moveEvent = this.moveEvent.bindAsEventListener(this); +this.dropEvent = this.dropEvent.bindAsEventListener(this); +Event.observe(widget, "mousedown", this.dragEvent); + }, + + dragEvent: function(e) { +var widget = this.view.widget; +Event.observe(document, "mousemove", this.moveEvent); +Event.observe(document, "mouseup", this.dropEvent); + }, + + moveEvent: function(e) { +var widget = this.view.widget; +var mouseX = Event.pointerX(e); +var mouseY = Event.pointerY(e); +CPSSkins.Canvas.moveTo(widget, parseInt(mouseX)-20, parseInt(mouseY-20)); + }, + + dropEvent: function(e) { +var widget = this.view.widget; +Event.stopObserving(document, "mousemove", this.moveEvent); +Event.stopObserving(document, "mouseup", this.dropEvent); + } + +}); + // Identifiable DOM elements. if (!CPSSkins.Identifiable) { CPSSkins.Identifiable = new Object() } Object.extend(CPSSkins.Identifiable, { @@ -1697,8 +1734,8 @@ // Contextual actions CPSSkins.ContextualActions = Class.create(); -Object.extend(CPSSkins.ContextualActions.prototype, new CPSSkins.View()); -Object.extend(CPSSkins.ContextualActions.prototype, CPSSkins.ContextualMenu.prototype); +Object.extend(CPSSkins.ContextualActions.prototype, + CPSSkins.ContextualMenu.prototype); Object.extend(CPSSkins.ContextualActions.prototype, { prepare: function() { -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins
[Z3lab-checkins] r2435 - cpsskins/branches/jmo-perspectives/ui/framework/tests/functional
Author: jmorliaguet Date: Mon Feb 20 01:33:56 2006 New Revision: 2435 Added: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_dragdrop_test.html (contents, props changed) cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/draggable.html (contents, props changed) Log: - drag and drop tests Added: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_dragdrop_test.html == --- (empty file) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/cpsskins_dragdrop_test.html Mon Feb 20 01:33:56 2006 @@ -0,0 +1,50 @@ +http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";> +http://www.w3.org/1999/xhtml";> + + CPSSkins Unit test file + + + + + + + + + + + + + + CPSSkins: drag-and-drop + + + {"id": "dnd", + "type": "drag-and-drop", + "action": "displayInfo" + } + + + + {"id": "dummy"} + + + + {"widget": { + "template": "draggable.html" + }, + "model": "dummy", + "controllers": ["dnd"] + } + + + +function displayInfo(event) { +} + +CPSSkins.registerHandlers({'displayInfo': displayInfo}); + + + + Added: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/draggable.html == --- (empty file) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/draggable.html Mon Feb 20 01:33:56 2006 @@ -0,0 +1,5 @@ + + + DRAG ME + -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins