aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xjs/controllers/elements/component-controller.js4
-rw-r--r--js/document/templates/app/main.js52
-rw-r--r--js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js96
-rwxr-xr-xjs/panels/components-panel.reel/components-panel.js56
-rw-r--r--node_modules/components-data/feed-reader.json1
-rw-r--r--node_modules/components-data/picasa-carousel.json1
6 files changed, 138 insertions, 72 deletions
diff --git a/js/controllers/elements/component-controller.js b/js/controllers/elements/component-controller.js
index 5b0aaeac..dd0766df 100755
--- a/js/controllers/elements/component-controller.js
+++ b/js/controllers/elements/component-controller.js
@@ -11,7 +11,7 @@ exports.ComponentController = Montage.create(ElementController, {
11 11
12 getProperty: { 12 getProperty: {
13 value: function(el, prop) { 13 value: function(el, prop) {
14 var component = el.controller || this.application.ninja.currentDocument.model.getComponentFromElement(el); 14 var component = el.controller;
15 15
16 switch(prop) { 16 switch(prop) {
17 case "id": 17 case "id":
@@ -34,7 +34,7 @@ exports.ComponentController = Montage.create(ElementController, {
34 34
35 setProperty: { 35 setProperty: {
36 value: function(el, p, value) { 36 value: function(el, p, value) {
37 var component = el.controller || this.application.ninja.currentDocument.model.getComponentFromElement(el); 37 var component = el.controller;
38 38
39 switch(p) { 39 switch(p) {
40 case "id": 40 case "id":
diff --git a/js/document/templates/app/main.js b/js/document/templates/app/main.js
index a406abdb..fbd2e138 100644
--- a/js/document/templates/app/main.js
+++ b/js/document/templates/app/main.js
@@ -8,12 +8,38 @@ var Montage = require("montage/core/core").Montage,
8 Template = require("montage/ui/template").Template, 8 Template = require("montage/ui/template").Template,
9 TemplateCreator = require("tools/template/template-creator").TemplateCreator; 9 TemplateCreator = require("tools/template/template-creator").TemplateCreator;
10 10
11
12//var njmodelGet = function njmodelGet() {
13// return (this.hasOwnProperty("_model") ? this._model: document.modelGenerator.call(this));
14//};
15//
16//Object.defineProperty(Object.prototype, "_model", {
17// enumerable: false,
18// value: null,
19// writable: true
20//});
21//
22//Object.defineProperty(Object.prototype, "elementModel", {
23// configurable: true,
24// get: njmodelGet,
25// set: function() {
26// }
27//});
28
11exports.Main = Montage.create(Component, { 29exports.Main = Montage.create(Component, {
12 30
13 hasTemplate: { 31 hasTemplate: {
14 value: false 32 value: false
15 }, 33 },
16 34
35 componentToInsert: {
36 value: null
37 },
38
39 firstDrawCallback: {
40 value: null
41 },
42
17 /** 43 /**
18 * Adding window hooks to callback into this object from Ninja. 44 * Adding window hooks to callback into this object from Ninja.
19 */ 45 */
@@ -24,6 +50,12 @@ exports.Main = Montage.create(Component, {
24 window.addComponent = function(element, data, callback) { 50 window.addComponent = function(element, data, callback) {
25 var component; 51 var component;
26 52
53 if(!self.firstDrawCallback) {
54 self.firstDrawCallback = {};
55 self.firstDrawCallback.callback = data.firstDraw.cb;
56 self.firstDrawCallback.context = data.firstDraw.ctx;
57 }
58
27 component = require.async(data.path) 59 component = require.async(data.path)
28 .then(function(component) { 60 .then(function(component) {
29 var componentRequire = component[data.name]; 61 var componentRequire = component[data.name];
@@ -34,6 +66,9 @@ exports.Main = Montage.create(Component, {
34 componentInstance.needsDraw = true; 66 componentInstance.needsDraw = true;
35 componentInstance.ownerComponent = self; 67 componentInstance.ownerComponent = self;
36 68
69 self.componentToInsert = componentInstance;
70 componentInstance.addEventListener("firstDraw", self, false);
71
37 callback(componentInstance, element); 72 callback(componentInstance, element);
38 }) 73 })
39 .end(); 74 .end();
@@ -46,16 +81,15 @@ exports.Main = Montage.create(Component, {
46 // 81 //
47 var templateEvent = document.createEvent("CustomEvent"); 82 var templateEvent = document.createEvent("CustomEvent");
48 templateEvent.initCustomEvent("mjsTemplateReady", false, true); 83 templateEvent.initCustomEvent("mjsTemplateReady", false, true);
49 document.body.dispatchEvent(templateEvent); 84 }
50 85 },
51 86
52 // Dispatch event when this template has loaded. 87 handleFirstDraw: {
53 /* 88 value: function() {
54 var newEvent = document.createEvent( "CustomEvent" ); 89 this.firstDrawCallback.callback.call(this.firstDrawCallback.context, this.componentToInsert);
55 newEvent.initCustomEvent( "userTemplateDidLoad", false, true );
56 document.body.dispatchEvent( newEvent );
57 */
58 90
91 this.componentToInsert.removeEventListener("firstDraw", this, false);
92 this.componentToInsert = null;
59 } 93 }
60 } 94 }
61}); \ No newline at end of file 95}); \ No newline at end of file
diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
index 6e9513f2..d7329ac7 100644
--- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
+++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
@@ -24,6 +24,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
24 return this._currentDocument; 24 return this._currentDocument;
25 }, 25 },
26 set : function(value) { 26 set : function(value) {
27 // If it's the same document, do nothing.
27 if (value === this._currentDocument) { 28 if (value === this._currentDocument) {
28 return; 29 return;
29 } 30 }
@@ -35,6 +36,9 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
35 this._currentDocument = value; 36 this._currentDocument = value;
36 37
37 if(!value) { 38 if(!value) {
39 this._boolCacheArrays = false;
40 this.clearTimelinePanel();
41 this._boolCacheArrays = true;
38 this.enablePanel(false); 42 this.enablePanel(false);
39 } else if(this._currentDocument.currentView === "design") { 43 } else if(this._currentDocument.currentView === "design") {
40 this._boolCacheArrays = false; 44 this._boolCacheArrays = false;
@@ -43,9 +47,40 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
43 47
44 // Rebind the document events for the new document context 48 // Rebind the document events for the new document context
45 this._bindDocumentEvents(); 49 this._bindDocumentEvents();
46 50
47 // TODO: Fix the init function so that it can be called here instead of when container changes 51 // Initialize the timeline for the document.
48 // this.initTimelineForDocument(); 52 this.initTimelineForDocument();
53 }
54 }
55 },
56
57 _currentSelectedContainer: {
58 value: null
59 },
60 currentSelectedContainer: {
61 get: function() {
62 return this._currentSelectedContainer;
63 },
64 set: function(newVal) {
65 if(this._currentSelectedContainer !== newVal) {
66 this._currentSelectedContainer = newVal;
67 if (this._ignoreNextContainerChange === true) {
68 this._ignoreNextContainerChange = false;
69 return;
70 }
71 this.application.ninja.currentDocument.setLevel = true;
72
73 if(this._currentDocument.currentView === "design") {
74 this._boolCacheArrays = false;
75 this.clearTimelinePanel();
76 this._boolCacheArrays = true;
77
78 // Rebind the document events for the new document context
79 this._bindDocumentEvents();
80
81 // Initialize the timeline for the document.
82 this.initTimelineForDocument();
83 }
49 } 84 }
50 } 85 }
51 }, 86 },
@@ -170,27 +205,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
170 this.cacheTimeline(); 205 this.cacheTimeline();
171 } 206 }
172 }, 207 },
173
174 _currentSelectedContainer: {
175 value: null
176 },
177 currentSelectedContainer: {
178 get: function() {
179 return this._currentSelectedContainer;
180 },
181 set: function(newVal) {
182 if(this._currentSelectedContainer !== newVal) {
183 this._currentSelectedContainer = newVal;
184 208
185 this._boolCacheArrays = false;
186 this.clearTimelinePanel();
187 this._boolCacheArrays = true;
188
189 // TODO: Fix the function so that we can remove this call here.