diff options
author | Pushkar Joshi | 2012-03-27 09:10:58 -0700 |
---|---|---|
committer | Pushkar Joshi | 2012-03-27 09:10:58 -0700 |
commit | 0c26aff9c19c2b39fca06fa6b3bc76b672204065 (patch) | |
tree | e778f2b9d5d525aa364360d5996536a0a06379bd /js/panels/presets/animations-presets.reel/animations-presets.js | |
parent | 753244b4713243ab19ca246be674f0b45fb85b72 (diff) | |
parent | 309dde5a8c4599cef6a1052c1ff9ee1ad8ec5858 (diff) | |
download | ninja-0c26aff9c19c2b39fca06fa6b3bc76b672204065.tar.gz |
Merge branch 'master' into brushtool
Conflicts:
js/controllers/elements/shapes-controller.js
Diffstat (limited to 'js/panels/presets/animations-presets.reel/animations-presets.js')
-rw-r--r-- | js/panels/presets/animations-presets.reel/animations-presets.js | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/js/panels/presets/animations-presets.reel/animations-presets.js b/js/panels/presets/animations-presets.reel/animations-presets.js new file mode 100644 index 00000000..ab200212 --- /dev/null +++ b/js/panels/presets/animations-presets.reel/animations-presets.js | |||
@@ -0,0 +1,73 @@ | |||
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-animation-presets").animationPresets; | ||
10 | |||
11 | exports.AnimationsLibrary = Montage.create(Component, { | ||
12 | hasTemplate: { | ||
13 | value: true | ||
14 | }, | ||
15 | presetData : { | ||
16 | value: null | ||
17 | }, | ||
18 | deserializedFromTemplate : { | ||
19 | value: function() { | ||
20 | this.presetData = DefaultPresets; | ||
21 | } | ||
22 | }, | ||
23 | handleNodeActivation: { | ||
24 | value: function(presetData) { | ||
25 | //debugger; | ||
26 | var selection = this.application.ninja.selectedElements, | ||
27 | stylesController = this.application.ninja.stylesController, | ||
28 | selectorBase = presetData.selectorBase, | ||
29 | self = this; | ||
30 | |||
31 | if(!selection || !selection.length || selection.length === 0) { | ||
32 | return false; | ||
33 | } | ||
34 | |||
35 | selectorBase = stylesController.generateClassName(selectorBase); | ||
36 | |||
37 | presetData.rules.forEach(function(rule) { | ||
38 | if(rule.isKeyFrameRule) { | ||
39 | this.application.ninja.stylesController.addRule( | ||
40 | '@-webkit-keyframes ' + presetData.selectorBase, | ||
41 | this.stringifyKeys(rule.keys) | ||
42 | ); | ||
43 | } else { | ||
44 | this.application.ninja.stylesController.addRule('.' + selectorBase + rule.selectorSuffix, rule.styles); | ||
45 | } | ||
46 | |||
47 | }, this); | ||
48 | |||
49 | selection.forEach(function(el) { | ||
50 | el._element.classList.add(selectorBase); | ||
51 | }, this); | ||
52 | |||
53 | } | ||
54 | }, | ||
55 | |||
56 | stringifyKeys : { | ||
57 | value: function(keysArray) { | ||
58 | var keysString = ''; | ||
59 | |||
60 | keysArray.forEach(function(key) { | ||
61 | var styles = '', style; | ||
62 | |||
63 | for(style in key.styles) { | ||
64 | styles += style + ':' + key.styles[style] + '; '; | ||
65 | } | ||
66 | |||
67 | keysString += key.keyText + ' {' + styles + ' }'; | ||
68 | }); | ||
69 | |||
70 | return keysString; | ||
71 | } | ||
72 | } | ||
73 | }); | ||