aboutsummaryrefslogtreecommitdiff
path: root/js/stage/objects-tray.reel/objects-tray.js
blob: 190abf57cf2db4688c8fa24e2c586bed44da5cfd (plain)
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
/* <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 },
    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;
        }
    },

    _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() {
            console.log('objects panel loaded');
        }
    },

    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);
            }
        }
    }

});