aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/controllers/objects-controller.js83
-rwxr-xr-xjs/document/models/html.js5
-rw-r--r--js/document/templates/app/main.js1
-rwxr-xr-xjs/document/views/design.js6
-rw-r--r--js/panels/objects/object.reel/object.html2
-rw-r--r--js/panels/objects/object.reel/object.js32
6 files changed, 75 insertions, 54 deletions
diff --git a/js/controllers/objects-controller.js b/js/controllers/objects-controller.js
index 543aa96f..5bab9eab 100644
--- a/js/controllers/objects-controller.js
+++ b/js/controllers/objects-controller.js
@@ -8,46 +8,79 @@ var Montage = require("montage/core/core").Montage,
8 Component = require("montage/ui/component").Component; 8 Component = require("montage/ui/component").Component;
9 9
10var objectsController = exports.ObjectsController = Montage.create(Component, { 10var objectsController = exports.ObjectsController = Montage.create(Component, {
11 objects : {
12 value: []
13 },
14
15 handleAppLoaded : {
16 value: function() {
17 ///// Bind app's activeDocument property to
18 ///// objects controller's _activeDocument property
19 }
20 },
21
22 deserializedFromTemplate : {
23 value: function() {
24 this.eventManager.addEventListener( "appLoaded", this, false);
25 },
26 enumerable : false
27 },
28 11
29 _activeDocument : { 12 _activeDocument : {
30 value : null, 13 value : null,
31 enumerable : false 14 enumerable : false
32 }, 15 },
33
34 activeDocument : { 16 activeDocument : {
35 get : function() { 17 get : function() {
36 return this._activeDocument; 18 return this._activeDocument;
37 }, 19 },
38 set : function(document) { 20 set : function(doc) {
39 ///// If the document is null set default stylesheets to null 21 if(!doc) { return false; }
40 if(!document) { return false; }
41 22
23 // TODO: remove setTimeout when timing of montage initialization is done
42 setTimeout(function() { 24 setTimeout(function() {
43 this.objects = document._document.application._template._deserializer.getObjectsFromLastDeserialization(); 25 this.bindToModelObjects();
44 }.bind(this), 1000); 26 }.bind(this), 1000);
45 27
46 28 this._activeDocument = doc;
47 ///// setting document via binding
48 this._activeDocument = document;
49 }, 29 },
50 enumerable : false 30 enumerable : false
31 },
32
33 objects : {
34 value: []
35 },
36
37 _isBoundToModelObjects : {
38 value: null
39 },
40 bindToModelObjects : {
41 value: function() {
42 //// Remove any previous bindings if previously bound
43 if(!this._isBoundToModelObjects) {
44 Object.deleteBinding(this, 'objects');
45 this._isBoundToModelObjects = true;
46 }
47
48 Object.defineBinding(this, 'objects', {
49 boundObject: this.activeDocument.model,
50 boundObjectPropertyPath: 'objects',
51 oneway: false
52 });
53 }
54 },
55
56 /* --------------------------
57 Binding Methods
58 ----------------------------- */
59
60 addBinding : {
61 value: function(bindingDescriptor) {
62 if(!bindingDescriptor.sourceObject || !bindingDescriptor.sourceObjectPropertyPath || !bindingDescriptor) { return; }
63
64 Object.defineBinding(bindingDescriptor.sourceObject, bindingDescriptor.sourceObjectPropertyPath, bindingDescriptor);
65 }
66 },
67
68 removeBinding : {
69 value: function(bindingDescriptor) {
70 if(!bindingDescriptor) { return; }
71
72 Object.deleteBinding(bindingDescriptor.sourceObject, bindingDescriptor.sourceObjectPropertyBindingPath);
73 }
74 },
75
76 editBindingPropertyPath : {
77 value: function(bindingDescriptor, newPropertyPath) {
78 this.removeBinding(bindingDescriptor);
79
80 //this.addBinding()
81
82
83 }
51 } 84 }
52 85
53}); \ No newline at end of file 86}); \ No newline at end of file
diff --git a/js/document/models/html.js b/js/document/models/html.js
index fd42d4de..a93faa9e 100755
--- a/js/document/models/html.js
+++ b/js/document/models/html.js
@@ -74,6 +74,7 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, {
74 setComponentInstance: { 74 setComponentInstance: {
75 value: function(instance, el) { 75 value: function(instance, el) {
76 this.userComponents[el.uuid] = instance; 76 this.userComponents[el.uuid] = instance;
77 this.objects.push(instance);
77 } 78 }
78 }, 79 },
79 //////////////////////////////////////////////////////////////////// 80 ////////////////////////////////////////////////////////////////////
@@ -86,6 +87,10 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, {
86 return null; 87 return null;
87 } 88 }
88 } 89 }
90 },
91 ////////////////////////////////////////////////////////////////////
92 objects : {
93 value: null
89 } 94 }
90 //////////////////////////////////////////////////////////////////// 95 ////////////////////////////////////////////////////////////////////
91 //////////////////////////////////////////////////////////////////// 96 ////////////////////////////////////////////////////////////////////
diff --git a/js/document/templates/app/main.js b/js/document/templates/app/main.js
index a406abdb..91c46fda 100644
--- a/js/document/templates/app/main.js
+++ b/js/document/templates/app/main.js
@@ -29,6 +29,7 @@ exports.Main = Montage.create(Component, {
29 var componentRequire = component[data.name]; 29 var componentRequire = component[data.name];
30 var componentInstance = componentRequire.create(); 30 var componentInstance = componentRequire.create();
31 31
32 componentInstance._montage_metadata.label = data.name;
32 componentInstance.element = element; 33 componentInstance.element = element;
33 34
34 componentInstance.needsDraw = true; 35 componentInstance.needsDraw = true;
diff --git a/js/document/views/design.js b/js/document/views/design.js
index d772aa86..826b4058 100755
--- a/js/document/views/design.js
+++ b/js/document/views/design.js
@@ -397,11 +397,15 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
397 initMontage: { 397 initMontage: {
398 value: function (scripttags) { 398 value: function (scripttags) {
399 // 399 //
400 //debugger;
400 this.iframe.contentWindow.document.body.addEventListener('mjsTemplateReady', function () { 401 this.iframe.contentWindow.document.body.addEventListener('mjsTemplateReady', function () {
401 //Initializing template with user's seriliazation 402 //Initializing template with user's seriliazation
402 var template = this.iframe.contentWindow.mjsTemplate.create(); 403 var template = this.iframe.contentWindow.mjsTemplate.create();
404
403 template.initWithDocument(this.iframe.contentWindow.document); 405 template.initWithDocument(this.iframe.contentWindow.document);
404 template.instantiateWithOwnerAndDocument(null, this.iframe.contentWindow.document, function (e){/*Nothing just a required extra parameter*/}); 406 template.instantiateWithOwnerAndDocument(null, this.iframe.contentWindow.document, function (e){
407 this.model.objects = template.deserializer.getObjectsFromLastDeserialization();
408 }.bind(this));
405 }.bind(this), false); 409 }.bind(this), false);
406 } 410 }
407 }, 411 },
diff --git a/js/panels/objects/object.reel/object.html b/js/panels/objects/object.reel/object.html
index efc66d79..a072ab5e 100644
--- a/js/panels/objects/object.reel/object.html
+++ b/js/panels/objects/object.reel/object.html
@@ -38,7 +38,7 @@
38<body> 38<body>
39 39
40 40
41<li data-montage-id="object"> 41<li data-montage-id="object" draggable="true">
42 <div class="object-icon"></div> 42 <div class="object-icon"></div>
43 <span data-montage-id="label" class="object-label"></span> 43 <span data-montage-id="label" class="object-label"></span>
44</li> 44</li>
diff --git a/js/panels/objects/object.reel/object.js b/js/panels/objects/object.reel/object.js
index 953c1baf..43abafad 100644
--- a/js/panels/objects/object.reel/object.js
+++ b/js/panels/objects/object.reel/object.js
@@ -57,41 +57,19 @@ exports.Object = Montage.create(Component, {
57 get: function() { 57 get: function() {
58 return this._montageLabel; 58 return this._montageLabel;
59 }, 59 },
60 set: function(value) { 60 set: function(data) {
61 if(this._montageMetaData === value) { return false; } 61 if(this._montageMetaData === data) { return false; }
62 62
63 this._montageMetaData = value; 63 this._montageMetaData = data;
64 64
65 if(!this.identifier && value.label) { 65 if(!this.identifier && data.label) {
66 this.label = value.label; 66 this.label = data.label;
67 this.needsDraw = true; 67 this.needsDraw = true;
68 } 68 }
69 } 69 }
70 70
71 }, 71 },
72 72
73 templateDidLoad: {
74 value: function() {
75 console.log('object loaded');
76 }
77 },
78