diff options
author | Ananya Sen | 2012-02-17 14:26:56 -0800 |
---|---|---|
committer | Ananya Sen | 2012-02-17 14:26:56 -0800 |
commit | 2980816130a44cd478b2a9d6606e021efbcebd4a (patch) | |
tree | 762d98ba8852b858c03760f4b9bef294fae6486c /js/panels/presets/style-presets.reel | |
parent | 96178309ddcdb54c0c451b69ea6fb8cdf76fcf62 (diff) | |
parent | a42c536c2b3209afc058eabd31167bd0aa6f71c8 (diff) | |
download | ninja-2980816130a44cd478b2a9d6606e021efbcebd4a.tar.gz |
Merge branch 'refs/heads/FileIO-jose' into FileIO
Conflicts:
css/ninja.css
js/controllers/document-controller.js
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/panels/presets/style-presets.reel')
-rw-r--r-- | js/panels/presets/style-presets.reel/style-presets.css | 0 | ||||
-rw-r--r-- | js/panels/presets/style-presets.reel/style-presets.html | 59 | ||||
-rw-r--r-- | js/panels/presets/style-presets.reel/style-presets.js | 79 |
3 files changed, 138 insertions, 0 deletions
diff --git a/js/panels/presets/style-presets.reel/style-presets.css b/js/panels/presets/style-presets.reel/style-presets.css new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/js/panels/presets/style-presets.reel/style-presets.css | |||
diff --git a/js/panels/presets/style-presets.reel/style-presets.html b/js/panels/presets/style-presets.reel/style-presets.html new file mode 100644 index 00000000..0db4d3c0 --- /dev/null +++ b/js/panels/presets/style-presets.reel/style-presets.html | |||
@@ -0,0 +1,59 @@ | |||
1 | <!DOCTYPE html> | ||
2 | <!-- <copyright> | ||
3 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
4 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
5 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
6 | </copyright> --> | ||
7 | <html lang="en"> | ||
8 | <head> | ||
9 | <meta http-equiv="content-type" content="text/html; charset=utf-8" /> | ||
10 | <link rel="stylesheet" href="style-presets.css" type="text/css"> | ||
11 | <script type="text/montage-serialization"> | ||
12 | { | ||
13 | "owner": { | ||
14 | "module" : "js/panels/presets/style-presets.reel", | ||
15 | "name" : "StylesLibrary", | ||
16 | "properties" : { | ||
17 | "element" : {"#" : "stylesLibrary"}, | ||
18 | "treeList" : {"@" : "treeList"} | ||
19 | } | ||
20 | }, | ||
21 | "presetsController" : { | ||
22 | "module": "js/controllers/tree-controller", | ||
23 | "name": "TreeController", | ||
24 | "properties" : { | ||
25 | "branchKey" : "children", | ||
26 | "labelKey" : "text", | ||
27 | "delegate": {"@": "owner" } | ||
28 | }, | ||
29 | "bindings": { | ||
30 | "content": { | ||
31 | "boundObject": {"@": "owner"}, | ||
32 | "boundObjectPropertyPath": "presetData" | ||
33 | } | ||
34 | } | ||
35 | }, | ||
36 | "presetsContainer" : { | ||
37 | "module" : "js/components/treeview/treeview.reel", | ||
38 | "name" : "Treeview", | ||
39 | "properties" : { | ||
40 | "element" : {"#": "libraryContainer"}, | ||
41 | "branchComponent" : {"@": "branch" }, | ||
42 | "contentController": {"@": "presetsController"}, | ||
43 | "activationEvent" : "dblclick", | ||
44 | "showRoot" : false | ||
45 | } | ||
46 | }, | ||
47 | "branch" : { | ||
48 | "module" : "js/components/treeview/ninja-branch.reel", | ||
49 | "name" : "Branch" | ||
50 | } | ||
51 | } | ||
52 | </script> | ||
53 | </head> | ||
54 | <body> | ||
55 | <section id="stylesLibrary" class="stylesLibrary"> | ||
56 | <div id="libraryContainer"></div> | ||
57 | </section> | ||
58 | </body> | ||
59 | </html> \ No newline at end of file | ||
diff --git a/js/panels/presets/style-presets.reel/style-presets.js b/js/panels/presets/style-presets.reel/style-presets.js new file mode 100644 index 00000000..7871683e --- /dev/null +++ b/js/panels/presets/style-presets.reel/style-presets.js | |||
@@ -0,0 +1,79 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | |||
7 | var Montage = require("montage/core/core").Montage, | ||
8 | Component = require("montage/ui/component").Component, | ||
9 | DefaultPresets = require("js/panels/presets/default-style-presets").stylePresets; | ||
10 | |||
11 | exports.StylesLibrary = Montage.create(Component, { | ||
12 | hasTemplate: { | ||
13 | value: true | ||
14 | }, | ||
15 | presetData : { | ||
16 | value : null | ||
17 | }, | ||
18 | templateDidLoad : { | ||
19 | value: function() { | ||
20 | this.presetData = DefaultPresets; | ||
21 | } | ||
22 | }, | ||
23 | handleNodeActivation: { | ||
24 | value: function(presetData) { | ||
25 | var selection = this.application.ninja.selectedElements, | ||
26 | stylesController = this.application.ninja.stylesController, | ||
27 | selectorBase = presetData.selectorBase, | ||
28 | self = this, className; | ||
29 | |||
30 | if(!selection || !selection.length || selection.length === 0) { | ||
31 | return false; | ||
32 | } | ||
33 | |||
34 | function setStopRuleSelector(selector) { | ||
35 | self.application.ninja | ||
36 | .currentDocument.documentRoot | ||
37 | .elementModel.controller | ||
38 | .changeSelector(self.application.ninja.currentDocument.documentRoot, null, selector); | ||
39 | } | ||
40 | |||
41 | selectorBase = stylesController.generateClassName(selectorBase); | ||
42 | |||
43 | presetData.rules.forEach(function(rule) { | ||
44 | stylesController.addRule('.'+selectorBase + rule.selectorSuffix, rule.styles); | ||
45 | }, this); | ||
46 | |||
47 | selection.forEach(function(el) { | ||
48 | el._element.style.webkitTransition = "all 450ms linear"; | ||
49 | |||
50 | el._element.addEventListener("webkitTransitionEnd", function(e) { | ||
51 | el._element.style.webkitTransition = ''; | ||
52 | setStopRuleSelector("*"); | ||
53 | }, true); | ||
54 | setStopRuleSelector("transitionStopRule"); | ||
55 | el._element.classList.add(selectorBase); | ||
56 | |||
57 | //// Keep track of elements with presets and don't add duplicates | ||
58 | |||
59 | }, this); | ||
60 | |||
61 | |||
62 | } | ||
63 | }, | ||
64 | handleDragEnd : { | ||
65 | value: function(sourceObject) { | ||
66 | console.log(sourceObject); | ||
67 | } | ||
68 | }, | ||
69 | shouldChangeSelection : { | ||
70 | value : function(controller, newSelection, oldSelection) { | ||
71 | // | ||
72 | //debugger; | ||
73 | console.log('1Handle should change selection'); | ||
74 | return false; | ||
75 | } | ||
76 | } | ||
77 | |||
78 | |||
79 | }); | ||