Author: jmorliaguet Date: Thu Mar 2 23:40:06 2006 New Revision: 2515 Modified: cpsskins/branches/jmo-perspectives/ui/framework/cpsskins.js cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panels/cpsskins_panel_test.html cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panels/panel5.html Log:
- Perspective Selector: made it possible to set an initial perspective 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 Thu Mar 2 23:40:06 2006 @@ -173,6 +173,7 @@ if (this._initialized[node] >= length) { CPSSkins._load(node); CPSSkins.unsubscribe("initialized", {'subscriber': progress}); + CPSSkins.notify("parsed", {'publisher': node}); } }.bind(this)); CPSSkins.subscribe("initialized", {'subscriber': progress}); @@ -205,13 +206,13 @@ ["view", "controller", "model"].each(function(type) { elements.each(function(el) { if (Element.hasClassName(el, type)) { - CPSSkins._register(el, type); + CPSSkins._register(node, el, type); } }); }); }, - _register: function(el, classid) { + _register: function(node, el, classid) { // make the element identifiable var def = this._jsonParse(el); var id = def.id; @@ -228,7 +229,7 @@ var controller_type = def.type || "command"; var factory = this.Controllers[controller_type]; if (factory) { - var controller = factory(el, def); + var controller = factory(node, def); controller.setup(); this._controllers[id] = controller; CPSSkins.notify("registered controller " + id, @@ -238,7 +239,7 @@ } case "model": { - var model = new CPSSkins.Model(el, def); + var model = new CPSSkins.Model(node, def); this._models[id] = model; CPSSkins.notify("registered model " + id, {'publisher': model}); break; @@ -366,7 +367,7 @@ CPSSkins.Controller.prototype = { initialize: function(node, def) { - this.node = this.node; + this.node = node; this.def = def; this.views = new CPSSkins.Set(); }, @@ -591,6 +592,13 @@ setup: function() { this._visible_views = {}; + CPSSkins.registerEventHandler("parsed", this, function(event) { + var initial = this.def.initial; + if (initial) { + this.switchTo(initial); + } + }.bind(this)); + CPSSkins.subscribe("parsed", {"subscriber": this, "publisher": this.node}); }, register: function(view) { Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panels/cpsskins_panel_test.html ============================================================================== --- cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panels/cpsskins_panel_test.html (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panels/cpsskins_panel_test.html Thu Mar 2 23:40:06 2006 @@ -45,7 +45,8 @@ <!-- perspective selectors --> <ins class="controller"> {"id": "controller1", - "type": "perspective selector" + "type": "perspective selector", + "initial": "perspective1" } </ins> Modified: cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panels/panel5.html ============================================================================== --- cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panels/panel5.html (original) +++ cpsskins/branches/jmo-perspectives/ui/framework/tests/functional/panels/panel5.html Thu Mar 2 23:40:06 2006 @@ -13,7 +13,8 @@ <ins class="controller"> {"id": "controller2", - "type": "perspective selector" + "type": "perspective selector", + "initial": "perspective2" } </ins> -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins