aboutsummaryrefslogtreecommitdiff
path: root/js/panels/presets/style-presets.reel/style-presets.js
blob: f25c8067760b3587bc8c5abbd3f66a4f2197ceea (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
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> */

var Montage = require("montage/core/core").Montage,
    Component = require("montage/ui/component").Component;

exports.StylesLibrary = Montage.create(Component, {
    hasTemplate: {
        value: true
    },
    contentPanel : {
        value: "presets" // get from local storage
    },
    templateDidLoad : {
        value: function() {
            console.log('deserialized');
        }
    },
    treeList : {
        value : null
    },
    data2: {
        value: {
            "text": "styles",
            "children": [{
                "text": "Box Styles",
                "children": [
                    {
                        "text": "Border-Radius",
                        "classNameBase" : "border-radius",
                        "styles" : {
                            "border-radius": "100px",
                            "border" : "1px solid #333"
                        }
                    },
                    {
                        "text": "Drop Shadow",
                        "classNameBase" : "drop-shadow",
                        "styles" : {
                            "box-shadow": "2px 2px 50px rgba(0,0,0,0.5)",
                            "border" : "1px solid #CCC"
                        }
                    },
                    {
                        "text": "Fancy Box",
                        "classNameBase" : "fancy-box",
                        "styles" : {
                            "box-shadow": "inset 0 0 0 1px #666, inset 0 0 0 2px rgba(225, 225, 225, 0.4), 0 0 20px -10px #333",
                            "border" : "1px solid #FFF",
                            "border-radius": "30px",
                            "background-color": "#7db9e8",
                            "background-image": "-webkit-linear-gradient(top, rgba(255,255,255,0.74) 0%,rgba(255,255,255,0) 100%)"
                        }
                    }]
            }, {
                "text": "Text Styles",
                "children": [
                    { "text": "Italic" },
                    { "text": "Text Shadow" },
                    { "text": "Text Color" } ]
            }, {
                "text": "Color Styles",
                "children": [
                    { "text": "Background Gradient" },
                    { "text": "Background Color" },
                    { "text": "Text Highlight" } ]
            }]
        }
    },
    didDraw: {
        value : function() {
            console.log('Presets Panel prepare for draw.');
//            this.treeList.items.push({
//                label : "Box Style",
//                type : 'leaf'
//            });
        }
    },
    handleNodeActivation: {
        value: function(presetData) {
            var selection = this.application.ninja.selectedElements,
                self = this;

            if(!selection || !selection.length || selection.length === 0) {
                return false;
            }

            function setStopRuleSelector(selector) {
                self.application.ninja
                    .currentDocument.documentRoot
                    .elementModel.controller
                    .changeSelector(self.application.ninja.currentDocument.documentRoot, null, selector);
            }

            selection.forEach(function(el) {
                el._element.style.webkitTransition = "all 450ms linear";

                el._element.addEventListener("webkitTransitionEnd", function(e) {
                    console.log("calling transition end");
                    setStopRuleSelector("*");
                });

                setStopRuleSelector("transitionStopRule");

                this.application.ninja.stylesController.setElementStyles(el._element, presetData.styles);
            }, this);

        }
    },
    handleDragEnd : {
        value: function(sourceObject) {
            console.log(sourceObject);
        }
    },
    shouldChangeSelection : {
        value : function(controller, newSelection, oldSelection) {
            //
            //debugger;
            console.log('1Handle should change selection');
            return false;
        }
    }


});