From 4c3aac5eabd93052b1554a03d78235215bb49db4 Mon Sep 17 00:00:00 2001
From: Valerio Virgillito
Date: Tue, 29 May 2012 00:34:40 -0700
Subject: document bindings phase 1

- using array controller to bind the current document to all ninja components
- removed open document event
- removed references to the document controller

Signed-off-by: Valerio Virgillito <valerio@motorola.com>
---
 js/components/menu/menu-item.reel/menu-item.js |  6 ++++--
 js/components/menu/menu.reel/menu.html         | 20 +++-----------------
 2 files changed, 7 insertions(+), 19 deletions(-)

(limited to 'js/components/menu')

diff --git a/js/components/menu/menu-item.reel/menu-item.js b/js/components/menu/menu-item.reel/menu-item.js
index fc3913b8..9c18ed37 100755
--- a/js/components/menu/menu-item.reel/menu-item.js
+++ b/js/components/menu/menu-item.reel/menu-item.js
@@ -82,7 +82,7 @@ exports.MenuItem = Montage.create(Component, {
                 });
 
             }
-
+/*
             if(this.data.enabled.boundProperty) {
 
                 boundObject = this.application.ninja[this.data.enabled.boundObj];
@@ -95,9 +95,11 @@ exports.MenuItem = Montage.create(Component, {
                 });
 
             } else {
+            */
                 this.enabled = this.data.enabled;
+            /*
             }
-
+            */
             if(this.data.submenu) {
                 this.submenu = true;
 
diff --git a/js/components/menu/menu.reel/menu.html b/js/components/menu/menu.reel/menu.html
index 49956f8a..7f2aeeef 100755
--- a/js/components/menu/menu.reel/menu.html
+++ b/js/components/menu/menu.reel/menu.html
@@ -21,11 +21,7 @@
                     "automaticallyOrganizeObjects": false
                 },
                 "bindings": {
-                    "content": {
-                        "boundObject": {"@": "menudata"},
-                        "boundObjectPropertyPath": "topLevelMenu",
-                        "oneway": true
-                    }
+                    "content": {"<-": "@menudata.topLevelMenu"}
                 }
             },
 
@@ -44,18 +40,8 @@
                     "element": { "#": "menuItem" }
                 },
                 "bindings": {
-                    "data": {
-                        "boundObject": {"@": "repetition"},
-                        "boundObjectPropertyPath": "objectAtCurrentIteration",
-                        "oneway": true
-                    },
-                    "_menu": {
-                        "boundObject": {"@": "repetition"},
-                        "boundObjectPropertyPath": "menuComponent",
-                        "oneway": true
-                    }
-
-
+                    "data": {"<-": "@repetition.objectAtCurrentIteration"},
+                    "_menu": {"<-": "@repetition.menuComponent"}
                 }
             },
             
-- 
cgit v1.2.3


From d8840eda0d3b3e31fb5a72306fe66608f4f99c2b Mon Sep 17 00:00:00 2001
From: Valerio Virgillito
Date: Tue, 29 May 2012 23:52:59 -0700
Subject: fixing the menu bindings and some cleanup of the stage

Signed-off-by: Valerio Virgillito <valerio@motorola.com>
---
 js/components/menu/menu-entry.reel/menu-entry.html | 13 +++----------
 js/components/menu/menu-item.reel/menu-item.html   | 13 +++----------
 js/components/menu/menu-item.reel/menu-item.js     | 20 +-------------------
 js/components/menu/menu.reel/menu.html             |  5 ++++-
 js/components/menu/menu.reel/menu.js               | 17 +++++++++++++++++
 5 files changed, 28 insertions(+), 40 deletions(-)

(limited to 'js/components/menu')

diff --git a/js/components/menu/menu-entry.reel/menu-entry.html b/js/components/menu/menu-entry.reel/menu-entry.html
index cd013a4e..f64de3cb 100755
--- a/js/components/menu/menu-entry.reel/menu-entry.html
+++ b/js/components/menu/menu-entry.reel/menu-entry.html
@@ -17,11 +17,7 @@
                     "automaticallyOrganizeObjects": false
                 },
                 "bindings": {
-                    "content": {
-                        "boundObject": {"@": "owner"},
-                        "boundObjectPropertyPath": "data.entries",
-                        "oneway": true
-                    }
+                    "content": {"<-": "@owner.data.entries"}
                 }
             },
 
@@ -39,11 +35,8 @@
                     "element": { "#": "menuEntryItem" }
                 },
                 "bindings": {
-                    "data": {
-                        "boundObject": {"@": "repetition"},
-                        "boundObjectPropertyPath": "objectAtCurrentIteration",
-                        "oneway": true
-                    }
+                    "data": {"<-": "@repetition.objectAtCurrentIteration"},
+                    "enabled": {"<-": "@repetition.objectAtCurrentIteration.enabled"}
                 }
             },
 
diff --git a/js/components/menu/menu-item.reel/menu-item.html b/js/components/menu/menu-item.reel/menu-item.html
index 5ff8c0fc..1902833a 100755
--- a/js/components/menu/menu-item.reel/menu-item.html
+++ b/js/components/menu/menu-item.reel/menu-item.html
@@ -17,11 +17,7 @@
                     "automaticallyOrganizeObjects": false
                 },
                 "bindings": {
-                    "content": {
-                        "boundObject": {"@": "owner"},
-                        "boundObjectPropertyPath": "subentries",
-                        "oneway": true
-                    }
+                    "content": {"<-": "@owner.subentries"}
                 }
             },
 
@@ -39,11 +35,8 @@
                     "element": {"#": "menuEntryItem" }
                 },
                 "bindings": {
-                    "data": {
-                        "boundObject": {"@": "repetition"},
-                        "boundObjectPropertyPath": "objectAtCurrentIteration",
-                        "oneway": true
-                    }
+                    "data": {"<-": "@repetition.objectAtCurrentIteration"},
+                    "enabled": {"<-": "@repetition.objectAtCurrentIteration.enabled"}
                 }
             },
 
diff --git a/js/components/menu/menu-item.reel/menu-item.js b/js/components/menu/menu-item.reel/menu-item.js
index 9c18ed37..c00c4412 100755
--- a/js/components/menu/menu-item.reel/menu-item.js
+++ b/js/components/menu/menu-item.reel/menu-item.js
@@ -14,7 +14,7 @@ exports.MenuItem = Montage.create(Component, {
     },
 
     _enabled: {
-        value: null
+        value: false
     },
 
     enabled: {
@@ -61,7 +61,6 @@ exports.MenuItem = Montage.create(Component, {
 
     prepareForDraw: {
         value: function() {
-            var boundObject = this.application.ninja, strArr = null, i=0;
 
             if(!this.data) return;
 
@@ -82,24 +81,7 @@ exports.MenuItem = Montage.create(Component, {
                 });
 
             }
-/*
-            if(this.data.enabled.boundProperty) {
-
-                boundObject = this.application.ninja[this.data.enabled.boundObj];
-
-                Object.defineBinding(this, "enabled", {
-                  boundObject: boundObject,
-                  boundObjectPropertyPath: this.data.enabled.boundProperty,
-                  boundValueMutator: this.data.enabled.boundValueMutator,
-                  oneway : this.data.enabled.oneway
-                });
 
-            } else {
-            */
-                this.enabled = this.data.enabled;
-            /*
-            }
-            */
             if(this.data.submenu) {
                 this.submenu = true;
 
diff --git a/js/components/menu/menu.reel/menu.html b/js/components/menu/menu.reel/menu.html
index 7f2aeeef..f15cf119 100755
--- a/js/components/menu/menu.reel/menu.html
+++ b/js/components/menu/menu.reel/menu.html
@@ -12,7 +12,10 @@
     <script type="text/montage-serialization">
         {
             "menudata": {
-                "prototype": "js/data/menu-data"
+                "prototype": "js/data/menu-data",
+                "bindings": {
+                    "currentDocument": {"<-": "@owner.currentDocument"}
+                }
             },
 
             "menuController": {
diff --git a/js/components/menu/menu.reel/menu.js b/js/components/menu/menu.reel/menu.js
index fb221640..50d3f0bc 100755
--- a/js/components/menu/menu.reel/menu.js
+++ b/js/components/menu/menu.reel/menu.js
@@ -9,6 +9,23 @@ var Montage = require("montage/core/core").Montage,
 
 exports.Menu = Montage.create(Component, {
 
+    _currentDocument: {
+            value : null
+    },
+
+    currentDocument : {
+        get : function() {
+            return this._currentDocument;
+        },
+        set : function(value) {
+            if (value === this._currentDocument) {
+                return;
+            }
+
+            this._currentDocument = value;
+        }
+    },
+
     _active: {
         value: false
     },
-- 
cgit v1.2.3