From 18f687974273b5ed7374ca5ae440c797064c5d0f Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Tue, 7 Feb 2012 13:35:27 -0800 Subject: Presets Panel - Initial commit with panel content --- .../presets/style-presets.reel/style-presets.js | 119 +++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 js/panels/presets/style-presets.reel/style-presets.js (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 new file mode 100644 index 00000000..3a71c344 --- /dev/null +++ b/js/panels/presets/style-presets.reel/style-presets.js @@ -0,0 +1,119 @@ +/* + This file contains proprietary software owned by Motorola Mobility, Inc.
+ No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ + +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' +// }); + } + }, + applyPresetSelection : { + value: function(presetData) { + var selection = this.application.ninja.selectedElements, + self = this; + + 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); + + } + }, + shouldChangeSelection : { + value : function(controller, newSelection, oldSelection) { + // + //debugger; + console.log('1Handle should change selection'); + return false; + } + } + + +}); -- cgit v1.2.3 From 586c3f7bbea04e62638e5ed8cdce9933e88c0b67 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Mon, 13 Feb 2012 10:27:27 -0800 Subject: Presets - Committing half-baked drag and drop --- js/panels/presets/style-presets.reel/style-presets.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (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 3a71c344..f25c8067 100644 --- a/js/panels/presets/style-presets.reel/style-presets.js +++ b/js/panels/presets/style-presets.reel/style-presets.js @@ -79,11 +79,15 @@ exports.StylesLibrary = Montage.create(Component, { // }); } }, - applyPresetSelection : { + 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 @@ -106,6 +110,11 @@ exports.StylesLibrary = Montage.create(Component, { } }, + handleDragEnd : { + value: function(sourceObject) { + console.log(sourceObject); + } + }, shouldChangeSelection : { value : function(controller, newSelection, oldSelection) { // -- cgit v1.2.3 From 6dc5d31b201d3578bf17b4f1fa7b1b9865d46153 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Mon, 13 Feb 2012 13:38:16 -0800 Subject: Style Presets - Separate out the style preset data to new file --- .../presets/style-presets.reel/style-presets.js | 61 +++------------------- 1 file changed, 6 insertions(+), 55 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 f25c8067..0c44e20c 100644 --- a/js/panels/presets/style-presets.reel/style-presets.js +++ b/js/panels/presets/style-presets.reel/style-presets.js @@ -5,78 +5,29 @@ */ var Montage = require("montage/core/core").Montage, - Component = require("montage/ui/component").Component; + Component = require("montage/ui/component").Component, + DefaultPresets = require("js/panels/presets/default-style-presets").stylePresets; exports.StylesLibrary = Montage.create(Component, { hasTemplate: { value: true }, + presetData : { + value : null + }, contentPanel : { value: "presets" // get from local storage }, templateDidLoad : { value: function() { - console.log('deserialized'); + this.presetData = DefaultPresets; } }, 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: { -- cgit v1.2.3 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