From 98b3083849b71155a8cb37d300b216150db0dcb5 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Wed, 15 Feb 2012 21:44:01 -0800 Subject: Presets - Modify application of preset classes for new json structure --- .../presets/style-presets.reel/style-presets.js | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'js/panels/presets/style-presets.reel/style-presets.js') diff --git a/js/panels/presets/style-presets.reel/style-presets.js b/js/panels/presets/style-presets.reel/style-presets.js index 0c44e20c..7871683e 100644 --- a/js/panels/presets/style-presets.reel/style-presets.js +++ b/js/panels/presets/style-presets.reel/style-presets.js @@ -15,25 +15,17 @@ exports.StylesLibrary = Montage.create(Component, { presetData : { value : null }, - contentPanel : { - value: "presets" // get from local storage - }, templateDidLoad : { value: function() { this.presetData = DefaultPresets; } }, - treeList : { - value : null - }, - didDraw: { - value : function() { - } - }, handleNodeActivation: { value: function(presetData) { var selection = this.application.ninja.selectedElements, - self = this; + stylesController = this.application.ninja.stylesController, + selectorBase = presetData.selectorBase, + self = this, className; if(!selection || !selection.length || selection.length === 0) { return false; @@ -46,19 +38,27 @@ exports.StylesLibrary = Montage.create(Component, { .changeSelector(self.application.ninja.currentDocument.documentRoot, null, selector); } + selectorBase = stylesController.generateClassName(selectorBase); + + presetData.rules.forEach(function(rule) { + stylesController.addRule('.'+selectorBase + rule.selectorSuffix, rule.styles); + }, this); + selection.forEach(function(el) { el._element.style.webkitTransition = "all 450ms linear"; el._element.addEventListener("webkitTransitionEnd", function(e) { - console.log("calling transition end"); + el._element.style.webkitTransition = ''; setStopRuleSelector("*"); - }); - + }, true); setStopRuleSelector("transitionStopRule"); + el._element.classList.add(selectorBase); + + //// Keep track of elements with presets and don't add duplicates - this.application.ninja.stylesController.setElementStyles(el._element, presetData.styles); }, this); + } }, handleDragEnd : { -- cgit v1.2.3