aboutsummaryrefslogtreecommitdiff
path: root/js/panels/binding-panel.reel/binding-panel.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/panels/binding-panel.reel/binding-panel.js')
-rw-r--r--js/panels/binding-panel.reel/binding-panel.js126
1 files changed, 126 insertions, 0 deletions
diff --git a/js/panels/binding-panel.reel/binding-panel.js b/js/panels/binding-panel.reel/binding-panel.js
new file mode 100644
index 00000000..c040c009
--- /dev/null
+++ b/js/panels/binding-panel.reel/binding-panel.js
@@ -0,0 +1,126 @@
1var Montage = require("montage/core/core").Montage,
2 Component = require("montage/ui/component").Component;
3
4
5exports.BindingPanel = Montage.create(Component, {
6
7 bindings : { value: null },
8 editView : { value: null },
9
10 _dockEditView : { value: null },
11 dockEditView : {
12 get : function() { return this._dockEditView; },
13 set : function(value) {
14 if(value === this._dockEditView) { return; }
15
16 this._dockEditView = value;
17
18 this.needsDraw = true;
19 }
20 },
21
22 _editing: { value: null },
23 editing: {
24 get: function() {
25 return this._editing;
26 },
27 set: function(value) {
28 if(value === this._editing) { return; }
29 this._editing = value;
30
31 if(!value) {
32 this.dockEditView = false;
33 }
34
35 this.needsDraw = true;
36 }
37 },
38 _translateDistance : {
39 value: null
40 },
41
42 displayEditView : {
43 value: function(bindingArgs) {
44 this.editView.bindingArgs = bindingArgs;
45 this.editing = true;
46 }
47 },
48
49 /* -------------------------
50 Event handlers
51 ------------------------- */
52
53 handleWebkitTransitionEnd : {
54 value: function(e) {
55 console.log("trans end");
56
57 this.dockEditView = this.editing;
58 }
59 },
60
61 /* -------------------------
62 Toolbar Button Actions
63 ------------------------- */
64
65 handleAddAction : {
66 value: function(e) {
67 var sourceObject = this.application.ninja.objectsController.currentObject;
68
69 if(sourceObject) {
70 this.displayEditView({
71 sourceObject: sourceObject
72 });
73 } else {
74 this.displayEditView();
75 }
76 }
77 },
78
79
80
81 templateDidLoad : {
82 value: function() {
83 Object.defineBinding(this, 'bindings', {
84 boundObject: this.application.ninja.objectsController,
85 boundObjectPropertyPath: "currentObjectBindings",
86 oneway: true
87 });
88 }
89 },
90
91 prepareForDraw : {
92 value: function() {
93
94 }
95 },
96
97 willDraw: {
98 value: function() {
99 this.editView.element.addEventListener('webkitTransitionEnd', this, false);
100
101 if(this.editing) {
102 this._translateDistance = this.element.offsetWidth;
103 }
104 }
105 },
106
107 draw : {
108 value: function() {
109 var transStr = '-webkit-transform',
110 editViewEl = this.editView.element;
111
112 if(this.dockEditView) {
113 editViewEl.classList.add('edit-view-docked');
114 editViewEl.style.removeProperty(transStr);
115 } else {
116 editViewEl.classList.remove('edit-view-docked');
117 if(this.editing) {
118 editViewEl.style.setProperty(transStr, 'translate3d(-'+ this._translateDistance + 'px,0,0)');
119 } else {
120 editViewEl.style.removeProperty(transStr);
121 }
122 }
123
124 }
125 }
126}); \ No newline at end of file