1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
/* <copyright>
This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
</copyright> */
/**
@requires montage/core/core
@requires montage/ui/component
*/
var Montage = require("montage/core/core").Montage,
Component = require("montage/ui/component").Component;
exports.ObjectsTray = Montage.create(Component, {
hideClass : { value: 'hide-objects-tray'},
_empty : { value: null },
_workspaceMode : { value: null },
offStageObjectsController : {
value: null
},
_showAllObjects : { value: null },
showAllObjects : {
get : function() { return this._showAllObjects; },
set : function(value) {
if(value === this._showAllObjects) { return; }
this._showAllObjects = value;
this.needsDraw = true;
}
},
workspaceMode : {
get : function() { return this._workspaceMode; },
set : function(value) {
if(value === this._workspaceMode) { return; }
var toHide = (value !== 'binding');
setTimeout(function() {
this.hide = toHide;
}.bind(this), 200);
this._workspaceMode = value;
this.needsDraw = true;
}
},
_objects: { value: null },
objects: {
get: function() {
return this._objects;
},
set: function(value) {
this._objects = value;
this.needsDraw = true;
}
},
offStageObjectFilter : {
value: function(obj) {
if(this.showAllObjects) {
return true;
}
var isComponent = this.application.ninja.objectsController._hasPrototype(obj, "Component"),
hasValidElement = obj.element && obj.element.parentNode;
return !isComponent || !hasValidElement;
}
},
_hide : { value: null },
hide : {
get : function() { return this._hide; },
set : function(value) {
if(value === this._hide) { return; }
this._hide = value;
this.needsDraw = true;
}
},
templateDidLoad: {
value: function() {
this.offStageObjectsController.filterFunction = this.offStageObjectFilter.bind(this);
}
},
prepareForDraw : {
value: function() {
Object.defineBinding(this, 'workspaceMode', {
"boundObject": this.application.ninja,
"boundObjectPropertyPath": "workspaceMode",
"oneway": true
});
Object.defineBinding(this, 'objects', {
"boundObject": this.application.ninja.objectsController,
"boundObjectPropertyPath": "objects",
"oneway": true
});
if(this.objects) {
this.empty = !this.objects.length;
} else {
this.empty = true;
}
}
},
draw : {
value: function() {
if(this.hide || this._empty) {
this.element.classList.add(this.hideClass);
} else {
this.element.classList.remove(this.hideClass);
}
}
}
});
|