Changeset 160
- Timestamp:
- 08/19/08 19:33:25 (3 months ago)
- Files:
-
- trunk/microfacts/public/behaviour/app/controllers/factlet_controller.js (modified) (1 diff)
- trunk/microfacts/public/behaviour/app/controllers/threadfactlets_controller.js (modified) (2 diffs)
- trunk/microfacts/public/behaviour/app/controllers/threadpage_controller.js (modified) (2 diffs)
- trunk/microfacts/public/behaviour/app/models/factlet.js (modified) (1 diff)
- trunk/microfacts/public/behaviour/app/models/model.js (added)
- trunk/microfacts/public/behaviour/app/models/thread.js (modified) (1 diff)
- trunk/microfacts/public/behaviour/lib/domainobject.js (moved) (moved from trunk/microfacts/public/behaviour/lib/model.js) (2 diffs)
- trunk/microfacts/public/behaviour/load.js (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/microfacts/public/behaviour/app/controllers/factlet_controller.js
r158 r160 4 4 initialize: function () { 5 5 this.parent.apply(this, arguments); 6 this.model = Model.Resource('Factlet', this.id());6 this.model = DomainObject.Resource('Factlet', this.id()); 7 7 this.views.push(new FillView()); 8 8 this.views.push(new PageTitleView('Factlets')); trunk/microfacts/public/behaviour/app/controllers/threadfactlets_controller.js
r159 r160 4 4 initialize: function () { 5 5 this.parent.apply(this, arguments); 6 // this.model = Model.Resource('Factlet', this.id());6 // this.model = DomainObject.Resource('Factlet', this.id()); 7 7 // this.views.push(new FillView()); 8 8 // this.views.push(new PageTitleView('Factlets')); … … 19 19 }, 20 20 21 onNewData: function(data) { 22 // if data is relevant to us: 23 // this.factlets.append ... 21 onThreadStart: function (thread) { 22 this.thread = thread; 23 //fctid = thread.factlets[0]; 24 //factlet = DomainObject.Resource('Factlet', fctid); 25 console.log("ThreadFactletsController saw threadStart event"); 26 console.log(thread); 24 27 }, 25 28 26 29 controls: { 27 30 '.factlet click': function (e) { trunk/microfacts/public/behaviour/app/controllers/threadpage_controller.js
r159 r160 9 9 10 10 initialize: function (element) { 11 this.initModel(); 12 console.log('ThreadPageController: initialize'); 11 13 this.controllers = []; 12 console.log('ThreadPageController: initialize');13 14 element.getElements('.thread-factlets').each(function (el) { 14 15 this.addController(new ThreadFactletsController(el)); 15 16 }, this); 16 console.log(threadId); 17 this.model = Model.Resource('Thread', threadId); 18 console.log('Model is'); 19 console.log(this.model); 17 18 this.model.startWithThread(threadId); 19 }, 20 21 initModel: function (threadId) { 22 this.model = new Model(); 23 this.model.addEvent('threadStart', this.onThreadStart.bind(this)); 24 }, 25 26 onThreadStart: function(thread) { 27 console.log('ThreadPageController: onThreadStart'); 28 this.fireEvent('threadStart', thread); 20 29 }, 21 30 … … 24 33 controller.addEvent('factletSelect', this.onFactletSelect.bind(this)); 25 34 this.addEvent('factletSelect', controller.onFactletSelect.bind(controller)); 35 this.addEvent('threadStart', controller.onThreadStart.bind(controller)); 26 36 } 27 37 }); trunk/microfacts/public/behaviour/app/models/factlet.js
r146 r160 1 1 var Factlet = new Class({ 2 Extends: Model,2 Extends: DomainObject, 3 3 options: { 4 4 name: 'factlet', trunk/microfacts/public/behaviour/app/models/thread.js
r159 r160 1 1 var Thread = new Class({ 2 Extends: Model,2 Extends: DomainObject, 3 3 options: { 4 4 name: 'thread', 5 5 prefix: 'api/rest' 6 }, 7 8 // TODO: sort out getting factlets back ... 9 10 setData: function (data, json) { 11 this.data = data; 12 // Copy list of factlet ids. 13 var factletIds = $A(this.data.factlets); 14 this.incompleteIds = $A(this.data.factlets); 15 // Loop over factlet ids. 16 factletIds.each(function(factletId) { 17 DomainObject.Resource( 'Factlet', factletId); 18 }); 19 }, 20 21 onFactletLoadSuccess: function () { 22 // Remove from incomplete list. 23 // If incomplete list empty, fire event. 24 }, 25 26 onFactletLoadFailure: function () { 27 // Remove from incomplete list. 28 // Mark as errorful. 6 29 } 7 30 8 // TODO: sort out getting factlets back ...9 31 }); 10 32 trunk/microfacts/public/behaviour/lib/domainobject.js
r153 r160 1 var Model= new Class({1 var DomainObject = new Class({ 2 2 Implements: [Events, Options], 3 3 … … 64 64 }); 65 65 66 Model.Register = {};66 DomainObject.Register = {}; 67 67 68 Model.Resource = function (name, id) {69 if ($type( Model.Register[name]) != 'object') {70 Model.Register[name] = {};68 DomainObject.Resource = function (name, id) { 69 if ($type(DomainObject.Register[name]) != 'object') { 70 DomainObject.Register[name] = {}; 71 71 } 72 if (!$chk( Model.Register[name][id])) {72 if (!$chk(DomainObject.Register[name][id])) { 73 73 // FIXME: don't use eval (or at least not in such a horrible way) 74 74 eval("var constructor = " + name); 75 Model.Register[name][id] = new constructor(id)75 DomainObject.Register[name][id] = new constructor(id) 76 76 } 77 return Model.Register[name][id];77 return DomainObject.Register[name][id]; 78 78 }; trunk/microfacts/public/behaviour/load.js
r159 r160 30 30 31 31 // ==================================================== 32 // = Base classes, Model, View, Controller, Delegator =32 // = Base classes, DomainObject, View, Controller, Delegator = 33 33 // ==================================================== 34 34 … … 36 36 name: "model", 37 37 type: "js", 38 path: " lib/model.js?" + Math.random(),38 path: "app/models/model.js?" + Math.random(), 39 39 requires: ['mootools'], 40 40 varName: "Model" 41 }); 42 43 loader.addModule({ 44 name: "domainobject", 45 type: "js", 46 path: "lib/domainobject.js?" + Math.random(), 47 requires: ['mootools'], 48 varName: "DomainObject" 41 49 }); 42 50 … … 66 74 67 75 // ========== 68 // = Models =76 // = DomainObjects = 69 77 // ========== 70 78 … … 73 81 type: "js", 74 82 path: "app/models/factlet.js?" + Math.random(), 75 requires: [' model'],83 requires: ['domainobject'], 76 84 varName: "Factlet" 77 85 }); … … 81 89 type: "js", 82 90 path: "app/models/thread.js?" + Math.random(), 83 requires: [' model'],91 requires: ['domainobject'], 84 92 varName: "Thread" 85 93 }); … … 165 173 type: "js", 166 174 path: "app/microfacts.js?" + Math.random(), 167 requires: [' model', 'view', 'controller', 'microfactscontroller', 'factletcontroller', 'threadfactletscontroller', 'mapcontroller', 'timelinecontroller'],175 requires: ['domainobject', 'view', 'controller', 'microfactscontroller', 'factletcontroller', 'threadfactletscontroller', 'mapcontroller', 'timelinecontroller'], 168 176 varName: "Microfacts" 169 177 }); … … 173 181 type: "js", 174 182 path: "app/controllers/threadpage_controller.js?" + Math.random(), 175 requires: ['model', ' view', 'controller', 'thread', 'threadfactletscontroller'],176 varName: "Th eadPageController"183 requires: ['model', 'domainobject', 'view', 'controller', 'thread', 'factlet', 'threadfactletscontroller'], 184 varName: "ThreadPageController" 177 185 }); 178 186
