From a5387d3cc74350dd06ecab2c8524d63d7540e57f Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Mon, 4 Jun 2012 16:37:09 -0700 Subject: Binding Panel - Add edit view --- js/panels/binding-panel.reel/binding-panel.css | 4 + js/panels/binding-panel.reel/binding-panel.html | 12 ++- js/panels/binding-panel.reel/binding-panel.js | 44 ++++++++- .../binding/binding-item.reel/binding-item.html | 1 + .../binding/binding-item.reel/binding-item.js | 6 ++ .../edit-binding-view.reel/edit-binding-view.css | 36 +++++++ .../edit-binding-view.reel/edit-binding-view.html | 103 +++++++++++++++++++++ .../edit-binding-view.reel/edit-binding-view.js | 21 +++++ 8 files changed, 222 insertions(+), 5 deletions(-) create mode 100644 js/panels/binding/edit-binding-view.reel/edit-binding-view.css create mode 100644 js/panels/binding/edit-binding-view.reel/edit-binding-view.html create mode 100644 js/panels/binding/edit-binding-view.reel/edit-binding-view.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 f29b66c1..e3dcf140 100644 --- a/js/panels/binding-panel.reel/binding-panel.css +++ b/js/panels/binding-panel.reel/binding-panel.css @@ -4,6 +4,10 @@ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ +.binding-panel { + position: relative; + height: 100%; +} .bindings-list { padding: 0; diff --git a/js/panels/binding-panel.reel/binding-panel.html b/js/panels/binding-panel.reel/binding-panel.html index 2850b67c..a926da8d 100644 --- a/js/panels/binding-panel.reel/binding-panel.html +++ b/js/panels/binding-panel.reel/binding-panel.html @@ -13,7 +13,8 @@ "owner": { "prototype": "js/panels/binding-panel.reel", "properties": { - "element": {"#": "binding"} + "element": {"#": "binding"}, + "editView": {"@": "editBinding"} } }, "arrayController": { @@ -41,16 +42,23 @@ "boundObject": {"<-": "@repetition.objectAtCurrentIteration.boundObject"}, "oneway": {"<-": "@repetition.objectAtCurrentIteration.oneway"} } + }, + "editBinding": { + "prototype": "js/panels/binding/edit-binding-view.reel", + "properties": { + "element": {"#": "edit-binding-view" } + } } } -
+
+
\ No newline at end of file diff --git a/js/panels/binding-panel.reel/binding-panel.js b/js/panels/binding-panel.reel/binding-panel.js index 9fdec416..c2ce556c 100644 --- a/js/panels/binding-panel.reel/binding-panel.js +++ b/js/panels/binding-panel.reel/binding-panel.js @@ -4,10 +4,34 @@ var Montage = require("montage/core/core").Montage, exports.BindingPanel = Montage.create(Component, { - bindings : { + bindings : { value: null }, + editView : { value: null }, + editingClass : { value: 'editing-binding' }, + _editing: { value: null }, + editing: { + get: function() { + return this._editing; + }, + set: function(value) { + if(value === this._editing) { return; } + this._editing = value; + this.needsDraw = true; + } + }, + _translateDistance : { value: null }, + displayEditView : { + value: function(bindingArgs) { + this.editing = true; + } + }, + + /* ------------------------- + Draw Cycle + ------------------------- */ + templateDidLoad : { value: function() { Object.defineBinding(this, 'bindings', { @@ -18,9 +42,23 @@ exports.BindingPanel = Montage.create(Component, { } }, - prepareForDraw: { + willDraw: { value: function() { - console.log("test- objects"); + if(this.editing) { + this._translateDistance = this.element.offsetWidth; + } + } + }, + + draw : { + value: function() { + var transStr = '-webkit-transform'; + + if(this.editing) { + this.editView.element.style.setProperty(transStr, 'translate3d(-'+ this._translateDistance + 'px,0,0)'); + } else { + this.editView.element.style.removeProperty(transStr); + } } } }); \ No newline at end of file diff --git a/js/panels/binding/binding-item.reel/binding-item.html b/js/panels/binding/binding-item.reel/binding-item.html index 79644a7a..95a349f8 100644 --- a/js/panels/binding/binding-item.reel/binding-item.html +++ b/js/panels/binding/binding-item.reel/binding-item.html @@ -14,6 +14,7 @@ "prototype": "js/panels/binding/binding-item.reel", "properties": { "element": {"#": "binding-item"}, + "editButton": {"@": "editButton" }, "directionToggleButton": {"@": "directionToggleButton" } } }, diff --git a/js/panels/binding/binding-item.reel/binding-item.js b/js/panels/binding/binding-item.reel/binding-item.js index 0fc06ea8..294e8d35 100644 --- a/js/panels/binding/binding-item.reel/binding-item.js +++ b/js/panels/binding/binding-item.reel/binding-item.js @@ -82,6 +82,12 @@ exports.BindingItem = Montage.create(Component, { } }, + handleEditButtonAction : { + value: function(e) { + this.parentComponent.parentComponent.displayEditView(); + } + }, + /* -------------- Component Draw Cycle -------------- */ templateDidLoad : { diff --git a/js/panels/binding/edit-binding-view.reel/edit-binding-view.css b/js/panels/binding/edit-binding-view.reel/edit-binding-view.css new file mode 100644 index 00000000..b0249c6c --- /dev/null +++ b/js/panels/binding/edit-binding-view.reel/edit-binding-view.css @@ -0,0 +1,36 @@ +/* + 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. +
*/ + +.edit-binding-view { + background: #474747; + color: #FFF; + font-size: 11px; + height: 100%; + /*left: 100%;*/ + /*position: absolute;*/ + /*top: 0;*/ + width: 100%; + -webkit-transition: -webkit-transform 140ms ease-in; +} + +.edit-binding-view ul { + padding: 0; + margin: 0; +} + +.edit-binding-view li { + padding: 3px; + list-style-type: none; +} + +/* hintable fields */ + +.so-pp, .bo-pp { + border: 1px solid #313131; + padding: 1px 4px; + background-color: #444; + margin-left: 5px; +} \ No newline at end of file diff --git a/js/panels/binding/edit-binding-view.reel/edit-binding-view.html b/js/panels/binding/edit-binding-view.reel/edit-binding-view.html new file mode 100644 index 00000000..1d502a3e --- /dev/null +++ b/js/panels/binding/edit-binding-view.reel/edit-binding-view.html @@ -0,0 +1,103 @@ + + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/js/panels/binding/edit-binding-view.reel/edit-binding-view.js b/js/panels/binding/edit-binding-view.reel/edit-binding-view.js new file mode 100644 index 00000000..700f3024 --- /dev/null +++ b/js/panels/binding/edit-binding-view.reel/edit-binding-view.js @@ -0,0 +1,21 @@ +/* + 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. +
*/ + +var Montage = require("montage/core/core").Montage, + Component = require("montage/ui/component").Component; + + +exports.EditBindingView = Montage.create(Component, { + objectsList : { + value: ["Object1", "Object2", "Object3"] + }, + + prepareForDraw : { + value: function() { + console.log("Preparing to draw edit view"); + } + } +}); \ No newline at end of file -- cgit v1.2.3 From 9274b3959384d21809c992f6f2e7860eb1682e06 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Tue, 5 Jun 2012 12:08:32 -0700 Subject: Binding Panel - Add getPropertyList and fix null currentObject --- js/controllers/objects-controller.js | 37 ++++++++++++++++++++-- .../binding/binding-item.reel/binding-item.js | 10 ++++-- 2 files changed, 41 insertions(+), 6 deletions(-) (limited to 'js') diff --git a/js/controllers/objects-controller.js b/js/controllers/objects-controller.js index 2c9f2d66..32f24d5c 100644 --- a/js/controllers/objects-controller.js +++ b/js/controllers/objects-controller.js @@ -113,12 +113,38 @@ var objectsController = exports.ObjectsController = Montage.create(Component, { /* ---- Bindable Properties ---- */ - getEnumerableProperties : { + getPropertyList : { value: function(object, excludeUnderscoreProperties) { + var object_i = object, + prototypes = [object_i]; + + ///// Collect prototypes + while(Object.getPrototypeOf(object_i)) { + object_i = Object.getPrototypeOf(object_i); + prototypes.push(object_i); + } + + return prototypes.map(function(proto) { + var metadata = proto._montage_metadata, + objectName = (metadata) ? metadata.objectName : "Object"; + + return { + category : objectName, + properties : this.getPropertiesFromObject(proto) + }; + }, this); + + } + }, + + getPropertiesFromObject : { + value: function (object, excludeUnderscoreProperties) { var properties = []; for(var key in object) { - properties.push(key); + if(object.hasOwnProperty(key)) { + properties.push(key); + } } if(excludeUnderscoreProperties) { @@ -146,7 +172,12 @@ var objectsController = exports.ObjectsController = Montage.create(Component, { set: function(value) { if(value === this._currentObject) { return; } - this.currentObjectBindings = this.getObjectBindings(value); + if(value) { + this.currentObjectBindings = this.getObjectBindings(value); + console.log("Property list", this.getPropertyList(value, true)); + } else { + this.currentObjectBindings = []; + } this._currentObject = value; } diff --git a/js/panels/binding/binding-item.reel/binding-item.js b/js/panels/binding/binding-item.reel/binding-item.js index 294e8d35..55230fc3 100644 --- a/js/panels/binding/binding-item.reel/binding-item.js +++ b/js/panels/binding/binding-item.reel/binding-item.js @@ -20,8 +20,10 @@ exports.BindingItem = Montage.create(Component, { set: function(value) { if(value === this._sourceObject) { return; } - this.sourceObjectLabel = value.identifier; - + if(value && value.identifier) { + this.sourceObjectLabel = value.identifier; + } + this._sourceObject = value; } }, @@ -33,7 +35,9 @@ exports.BindingItem = Montage.create(Component, { set: function(value) { if(value === this._boundObject) { return; } - this.boundObjectLabel = value.identifier; + if(value && value.identifier) { + this.boundObjectLabel = value.identifier; + } this._boundObject = value; } -- cgit v1.2.3