From dad4e3aa51b9f2b370f20f13bdb00ccc33f8d891 Mon Sep 17 00:00:00 2001
From: Eric Guzman
Date: Fri, 25 May 2012 16:34:52 -0700
Subject: Object component - Minor cleanup
---
js/panels/objects/object.reel/object.js | 32 +++++---------------------------
1 file changed, 5 insertions(+), 27 deletions(-)
(limited to 'js')
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, {
get: function() {
return this._montageLabel;
},
- set: function(value) {
- if(this._montageMetaData === value) { return false; }
+ set: function(data) {
+ if(this._montageMetaData === data) { return false; }
- this._montageMetaData = value;
+ this._montageMetaData = data;
- if(!this.identifier && value.label) {
- this.label = value.label;
+ if(!this.identifier && data.label) {
+ this.label = data.label;
this.needsDraw = true;
}
}
},
- templateDidLoad: {
- value: function() {
- console.log('object loaded');
- }
- },
-
- prepareForDraw : {
- value: function() {
-
- }
- },
-
- willDraw : {
- value: function() {
- if(this._needsPropertyInspection) {
-
- }
-
- console.log("This label ", this.label);
- }
- },
-
draw : {
value: function() {
--
cgit v1.2.3
From 1be5495b77c1dd426be3a6be05555254856de6ba Mon Sep 17 00:00:00 2001
From: Eric Guzman
Date: Fri, 25 May 2012 16:35:17 -0700
Subject: Object Component - Enable native dragging
---
js/panels/objects/object.reel/object.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'js')
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 @@
-
+
--
cgit v1.2.3
From 1f7c17d688c3340b31d2e1c2b7205b10bd806968 Mon Sep 17 00:00:00 2001
From: Eric Guzman
Date: Fri, 25 May 2012 16:37:24 -0700
Subject: Objects Controller - Now keeps track of document's object instances,
including added components
---
js/controllers/objects-controller.js | 83 +++++++++++++++++++++++++-----------
js/document/models/html.js | 5 +++
js/document/templates/app/main.js | 1 +
js/document/views/design.js | 6 ++-
4 files changed, 69 insertions(+), 26 deletions(-)
(limited to 'js')
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,
Component = require("montage/ui/component").Component;
var objectsController = exports.ObjectsController = Montage.create(Component, {
- objects : {
- value: []
- },
-
- handleAppLoaded : {
- value: function() {
- ///// Bind app's activeDocument property to
- ///// objects controller's _activeDocument property
- }
- },
-
- deserializedFromTemplate : {
- value: function() {
- this.eventManager.addEventListener( "appLoaded", this, false);
- },
- enumerable : false
- },
_activeDocument : {
value : null,
enumerable : false
},
-
activeDocument : {
get : function() {
return this._activeDocument;
},
- set : function(document) {
- ///// If the document is null set default stylesheets to null
- if(!document) { return false; }
+ set : function(doc) {
+ if(!doc) { return false; }
+ // TODO: remove setTimeout when timing of montage initialization is done
setTimeout(function() {
- this.objects = document._document.application._template._deserializer.getObjectsFromLastDeserialization();
+ this.bindToModelObjects();
}.bind(this), 1000);
-
- ///// setting document via binding
- this._activeDocument = document;
+ this._activeDocument = doc;
},
enumerable : false
+ },
+
+ objects : {
+ value: []
+ },
+
+ _isBoundToModelObjects : {
+ value: null
+ },
+ bindToModelObjects : {
+ value: function() {
+ //// Remove any previous bindings if previously bound
+ if(!this._isBoundToModelObjects) {
+ Object.deleteBinding(this, 'objects');
+ this._isBoundToModelObjects = true;
+ }
+
+ Object.defineBinding(this, 'objects', {
+ boundObject: this.activeDocument.model,
+ boundObjectPropertyPath: 'objects',
+ oneway: false
+ });
+ }
+ },
+
+ /* --------------------------
+ Binding Methods
+ ----------------------------- */
+
+ addBinding : {
+ value: function(bindingDescriptor) {
+ if(!bindingDescriptor.sourceObject || !bindingDescriptor.sourceObjectPropertyPath || !bindingDescriptor) { return; }
+
+ Object.defineBinding(bindingDescriptor.sourceObject, bindingDescriptor.sourceObjectPropertyPath, bindingDescriptor);
+ }
+ },
+
+ removeBinding : {
+ value: function(bindingDescriptor) {
+ if(!bindingDescriptor) { return; }
+
+ Object.deleteBinding(bindingDescriptor.sourceObject, bindingDescriptor.sourceObjectPropertyBindingPath);
+ }
+ },
+
+ editBindingPropertyPath : {
+ value: function(bindingDescriptor, newPropertyPath) {
+ this.removeBinding(bindingDescriptor);
+
+ //this.addBinding()
+
+
+ }
}
});
\ No newline at end of file
diff --git a/js/document/models/html.js b/js/document/models/html.js
index 9cc8ce92..10112565 100755
--- a/js/document/models/html.js
+++ b/js/document/models/html.js
@@ -69,6 +69,7 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, {
setComponentInstance: {
value: function(instance, el) {
this.userComponents[el.uuid] = instance;
+ this.objects.push(instance);
}
},
////////////////////////////////////////////////////////////////////
@@ -81,6 +82,10 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, {
return null;
}
}
+ },
+ ////////////////////////////////////////////////////////////////////
+ objects : {
+ value: null
}
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
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, {
var componentRequire = component[data.name];
var componentInstance = componentRequire.create();
+ componentInstance._montage_metadata.label = data.name;
componentInstance.element = element;
componentInstance.needsDraw = true;
diff --git a/js/document/views/design.js b/js/document/views/design.js
index b3887fdf..75eb3695 100755
--- a/js/document/views/design.js
+++ b/js/document/views/design.js
@@ -363,11 +363,15 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, {
initMontage: {
value: function (scripttags) {
//
+ //debugger;
this.iframe.contentWindow.document.body.addEventListener('mjsTemplateReady', function () {
//Initializing template with user's seriliazation
var template = this.iframe.contentWindow.mjsTemplate.create();
+
template.initWithDocument(this.iframe.contentWindow.document);
- template.instantiateWithOwnerAndDocument(null, this.iframe.contentWindow.document, function (e){/*Nothing just a required extra parameter*/});
+ template.instantiateWithOwnerAndDocument(null, this.iframe.contentWindow.document, function (e){
+ this.model.objects = template.deserializer.getObjectsFromLastDeserialization();
+ }.bind(this));
}.bind(this), false);
}
},
--
cgit v1.2.3
From e09efe3212e86ac794de3fc8ecfc6cdef7b15181 Mon Sep 17 00:00:00 2001
From: Eric Guzman
Date: Wed, 30 May 2012 15:02:23 -0700
Subject: Objects Controller - Add bindable controller properties, and bindings
getter
---
js/controllers/objects-controller.js | 75 +++++++++++++++++++++++++++++-------
js/ninja.reel/ninja.html | 2 +-
2 files changed, 62 insertions(+), 15 deletions(-)
(limited to 'js')
diff --git a/js/controllers/objects-controller.js b/js/controllers/objects-controller.js
index 5bab9eab..cd0139a0 100644
--- a/js/controllers/objects-controller.js
+++ b/js/controllers/objects-controller.js
@@ -9,13 +9,13 @@ var Montage = require("montage/core/core").Montage,
var objectsController = exports.ObjectsController = Montage.create(Component, {
- _activeDocument : {
+ _currentDocument : {
value : null,
enumerable : false
},
- activeDocument : {
+ currentDocument : {
get : function() {
- return this._activeDocument;
+ return this._currentDocument;
},
set : function(doc) {
if(!doc) { return false; }
@@ -25,7 +25,7 @@ var objectsController = exports.ObjectsController = Montage.create(Component, {
this.bindToModelObjects();
}.bind(this), 1000);
- this._activeDocument = doc;
+ this._currentDocument = doc;
},
enumerable : false
},
@@ -46,7 +46,7 @@ var objectsController = exports.ObjectsController = Montage.create(Component, {
}
Object.defineBinding(this, 'objects', {
- boundObject: this.activeDocument.model,
+ boundObject: this.currentDocument.model,
boundObjectPropertyPath: 'objects',
oneway: false
});
@@ -58,28 +58,75 @@ var objectsController = exports.ObjectsController = Montage.create(Component, {
----------------------------- */
addBinding : {
- value: function(bindingDescriptor) {
- if(!bindingDescriptor.sourceObject || !bindingDescriptor.sourceObjectPropertyPath || !bindingDescriptor) { return; }
+ value: function(bindingArgs) {
+ if(!bindingArgs.sourceObject || !bindingArgs.sourceObjectPropertyPath || !bindingArgs) { return; }
- Object.defineBinding(bindingDescriptor.sourceObject, bindingDescriptor.sourceObjectPropertyPath, bindingDescriptor);
+ Object.defineBinding(bindingArgs.sourceObject, bindingArgs.sourceObjectPropertyPath, bindingArgs);
}
},
removeBinding : {
- value: function(bindingDescriptor) {
- if(!bindingDescriptor) { return; }
+ value: function(bindingArgs) {
+ if(!bindingArgs) { return; }
- Object.deleteBinding(bindingDescriptor.sourceObject, bindingDescriptor.sourceObjectPropertyBindingPath);
+ Object.deleteBinding(bindingArgs.sourceObject, bindingArgs.sourceObjectPropertyPath);
}
},
editBindingPropertyPath : {
- value: function(bindingDescriptor, newPropertyPath) {
- this.removeBinding(bindingDescriptor);
+ value: function(bindingArgs, newPropertyPath) {
+ this.removeBinding(bindingArgs);
- //this.addBinding()
+ bindingArgs.boundObjectPropertyPath = 'newPropertyPath';
+ this.addBinding(bindingArgs);
+ }
+ },
+
+ getObjectBindings : {
+ value: function(object) {
+ var descriptors = object._bindingDescriptors,
+ bindingsArray = [],
+ property, descriptor, bindingArgsObject;
+
+ for(property in descriptors) {
+ if(descriptors.hasOwnProperty(property)) {
+ descriptor = descriptors[property];
+
+ bindingArgsObject = {
+ sourceObject : object,
+ sourceObjectPropertyPath : property,
+ boundObject : descriptor.boundObject,
+ boundObjectPropertyPath : descriptor.boundObjectPropertyPath,
+ onweway : descriptor.oneway
+ };
+
+ bindingsArray.push(bindingArgsObject);
+ }
+ }
+
+ return bindingsArray;
+ }
+ },
+
+ /* ---- Bindable controller properties ---- */
+
+ currentObjectBindings : {
+ value: null
+ },
+ _currentObject : {
+ value: null
+ },
+ currentObject : {
+ get: function() {
+ return this._currentObject;
+ },
+ set: function(value) {
+ if(value === this._currentObject) { return; }
+
+ this.currentObjectBindings = this.getObjectBindings(value);
+ this._currentObject = value;
}
}
diff --git a/js/ninja.reel/ninja.html b/js/ninja.reel/ninja.html
index 1f0582b1..53b8676f 100755
--- a/js/ninja.reel/ninja.html
+++ b/js/ninja.reel/ninja.html
@@ -326,7 +326,7 @@
"objectsController" : {
"prototype": "js/controllers/objects-controller",
"bindings": {
- "activeDocument": {"<-": "@owner.currentDocument"}
+ "currentDocument": {"<-": "@owner.currentDocument"}
}
},
--
cgit v1.2.3
From 04ef4ffcfde762a0aead4a7b702f3c019fdbeb69 Mon Sep 17 00:00:00 2001
From: Eric Guzman
Date: Thu, 31 May 2012 21:57:22 -0700
Subject: Binding Panel - Developed panel components.
---
js/panels/binding-panel.reel/binding-panel.css | 11 +++++++
js/panels/binding-panel.reel/binding-panel.html | 26 ++++++++++++++-
js/panels/binding-panel.reel/binding-panel.js | 14 ++++++++
.../binding/binding-item.reel/binding-item.css | 13 ++++++++
.../binding/binding-item.reel/binding-item.html | 37 ++++++++++++++++++++++
.../binding/binding-item.reel/binding-item.js | 26 +++++++++++++++
6 files changed, 126 insertions(+), 1 deletion(-)
create mode 100644 js/panels/binding/binding-item.reel/binding-item.css
create mode 100644 js/panels/binding/binding-item.reel/binding-item.html
create mode 100644 js/panels/binding/binding-item.reel/binding-item.js
(limited to 'js')
diff --git a/js/panels/binding-panel.reel/binding-panel.css b/js/panels/binding-panel.reel/binding-panel.css
index e69de29b..8597a926 100644
--- a/js/panels/binding-panel.reel/binding-panel.css
+++ b/js/panels/binding-panel.reel/binding-panel.css
@@ -0,0 +1,11 @@
+/*
+ This file contains proprietary software owned by Motorola Mobility, Inc.
+ No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
+ */
+
+
+.bindings-list {
+ padding: 0;
+ margin: 0;
+}
\ No newline at end of file
diff --git a/js/panels/binding-panel.reel/binding-panel.html b/js/panels/binding-panel.reel/binding-panel.html
index 0db7b95f..d2e18e99 100644
--- a/js/panels/binding-panel.reel/binding-panel.html
+++ b/js/panels/binding-panel.reel/binding-panel.html
@@ -15,6 +15,28 @@
"properties": {
"element": {"#": "binding"}
}
+ },
+ "arrayController": {
+ "prototype": "montage/ui/controller/array-controller",
+ "bindings": {
+ "content" : {"<-": "@owner.bindings" }
+ }
+ },
+ "repetition": {
+ "prototype": "montage/ui/repetition.reel",
+ "properties": {
+ "element": {"#": "bindings-list"},
+ "contentController": {"@": "arrayController"}
+ }
+ },
+ "bindingItem": {
+ "prototype": "js/panels/binding/binding-item.reel",
+ "properties": {
+ "element": {"#": "binding-item"}
+ },
+ "bindings": {
+ "sourceObjectPropertyPath": {"<-": "@repetition.objectAtCurrentIteration.sourceObjectPropertyPath"}
+ }
}
}
@@ -22,7 +44,9 @@