From c6d1a1da9e7cdf477daf32410d80691eb1e828d5 Mon Sep 17 00:00:00 2001
From: Valerio Virgillito
Date: Tue, 31 Jan 2012 13:54:35 -0800
Subject: Montage Native Widgets: Cleanup of current components
Cleaning up the current components support files:
- Clean the component tree
- Clean the app delegate and panel
Signed-off-by: Valerio Virgillito
---
js/data/pi/pi-data.js | 4 +++
js/panels/Components/Components.xml | 22 -------------
.../ComponentsPanelBase.js | 36 +++++++++++++---------
3 files changed, 26 insertions(+), 36 deletions(-)
(limited to 'js')
diff --git a/js/data/pi/pi-data.js b/js/data/pi/pi-data.js
index f162e919..189d1dae 100644
--- a/js/data/pi/pi-data.js
+++ b/js/data/pi/pi-data.js
@@ -505,6 +505,10 @@ exports.PiData = Montage.create( Montage, {
]
}
]
+ },
+
+ componentPi: {
+ value: []
}
});
diff --git a/js/panels/Components/Components.xml b/js/panels/Components/Components.xml
index b3056330..e076602e 100644
--- a/js/panels/Components/Components.xml
+++ b/js/panels/Components/Components.xml
@@ -2,27 +2,5 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js
index 41afefa5..c8624b29 100644
--- a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js
+++ b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js
@@ -59,15 +59,20 @@ var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component
addComponentToStage:{
value:function(componentType, dropX, dropY){
- var compW = 100,
- compH = 100,
- elementType = "div",
- componentContainer,
- componentElement;
+// var compW = 100,
+// compH = 100,
+// elementType = "div",
+// componentContainer,
+// componentElement;
+ var componentEl;
if(componentType == "Button"){
- compW = 118;
- compH = 52;
+ componentEl = NJUtils.makeNJElement("button", componentType, "component");//, {"type": "button"});
+ componentEl.setAttribute("type", "button");
+ componentEl.innerHTML = "Button";
+ console.log(componentEl);
+// compW = 118;
+// compH = 52;
}else if(componentType == "Checkbox"){
compW = 53;
compH = 53;
@@ -117,28 +122,31 @@ var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component
compH = 25;
}
+
+ /*
componentContainer = NJUtils.makeNJElement("div", componentType, "component");
componentContainer.elementModel.isComponent = true;
-
+ */
var styles = {
'position': 'absolute',
'top' : dropY + 'px',
'left' : dropX + 'px',
- 'width' : compW + 'px',
- 'height' : compH + 'px',
+// 'width' : compW + 'px',
+// 'height' : compH + 'px',
'-webkit-transform-style' : 'preserve-3d',
'-webkit-transform' : 'perspective(1400) matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)'
};
- componentElement = NJUtils.makeNJElement(elementType, "ComponentDiv", "block");
-
- componentContainer.appendChild(componentElement);
+ //componentElement = NJUtils.makeNJElement(elementType, "ComponentDiv", "block");
- NJevent("elementAdding", {"el": componentContainer, "data":styles});
+ //componentContainer.appendChild(componentElement);
+ NJevent("elementAdding", {"el": componentEl, "data":styles});
+ /*
var componentRef = this.application.ninja.currentDocument._window.addComponent(componentElement, componentType);
this.application.ninja.currentDocument._userComponentSet[componentContainer.uuid] = componentRef;
+ */
}
}
--
cgit v1.2.3
From d26a13de2aca25c36cb35f85604de1ac2b9befbb Mon Sep 17 00:00:00 2001
From: Valerio Virgillito
Date: Wed, 1 Feb 2012 14:37:30 -0800
Subject: Simple button native widget test. Added a controller, pi and panel
code.
Signed-off-by: Valerio Virgillito
---
js/controllers/elements/component-controller.js | 23 +++++++++++
js/data/pi/pi-data.js | 18 ++++++++-
js/io/document/html-document.js | 47 +++++++++++++---------
.../ComponentsPanelBase.js | 33 ++++++---------
4 files changed, 80 insertions(+), 41 deletions(-)
(limited to 'js')
diff --git a/js/controllers/elements/component-controller.js b/js/controllers/elements/component-controller.js
index 458e6b46..7a8acb3a 100644
--- a/js/controllers/elements/component-controller.js
+++ b/js/controllers/elements/component-controller.js
@@ -9,4 +9,27 @@ var Montage = require("montage/core/core").Montage,
exports.ComponentController = Montage.create(ElementController, {
+ getProperty: {
+ value: function(el, prop) {
+ switch(prop) {
+ case "label":
+ return this.application.ninja.currentDocument.getComponentFromElement(el).label;
+ break;
+ default:
+ return ElementController.getProperty(el, prop);
+ }
+ }
+ },
+
+ setProperty: {
+ value: function(el, p, value) {
+ switch(p) {
+ case "label":
+ this.application.ninja.currentDocument.getComponentFromElement(el).label = value;
+ break;
+ default:
+ ElementController.setProperty(el, p, value);
+ }
+ }
+ }
});
diff --git a/js/data/pi/pi-data.js b/js/data/pi/pi-data.js
index 189d1dae..30b1f60d 100644
--- a/js/data/pi/pi-data.js
+++ b/js/data/pi/pi-data.js
@@ -508,7 +508,23 @@ exports.PiData = Montage.create( Montage, {
},
componentPi: {
- value: []
+ value: [
+ {
+ label: "Button",
+
+ Section: [
+ [
+ {
+ type: "textbox",
+ id: "Label",
+ prop: "label",
+ defaultValue: "Button",
+ label: "Label"
+ }
+ ]
+ ]
+ }
+ ]
}
});
diff --git a/js/io/document/html-document.js b/js/io/document/html-document.js
index c44dfe75..a8e06c69 100644
--- a/js/io/document/html-document.js
+++ b/js/io/document/html-document.js
@@ -27,6 +27,7 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base
_initialUserDocument: { value: null, enumerable: false },
_htmlSource: {value: "", enumerable: false},
_glData: {value: null, enumerable: false },
+ _userComponents: { value: {}, enumarable: false},
_elementCounter: { value: 1, enumerable: false },
_snapping : { value: true, enumerable: false },
@@ -108,23 +109,11 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base
}
},
- _userComponentSet: {
- value: {},
- writable: true,
- enumerable:true
+ userComponents: {
+ get: function() {
+ return this._userComponents;
+ }
},
-
-// userComponentSet:{
-// enumerable: true,
-// get: function() {
-// return this._userComponentSet;
-// },
-// set: function(value) {
-// this._userComponentSet = value;
-// this._drawUserComponentsOnOpen();
-// }
-// },
-//
// _drawUserComponentsOnOpen:{
// value:function(){
// for(var i in this._userComponentSet){
@@ -191,6 +180,29 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base
set: function(value) { this._zoomFactor = value; }
},
+ /**
+ * Add a reference to a component instance to the userComponents hash using the
+ * element UUID
+ */
+ setComponentInstance: {
+ value: function(instance, el) {
+ this.userComponents[el.uuid] = instance;
+ }
+ },
+
+ /**
+ * Returns the component instance obj from the element
+ */
+ getComponentFromElement: {
+ value: function(el) {
+ if(el) {
+ if(el.uuid) return this.userComponents[el.uuid];
+ } else {
+ return null;
+ }
+ }
+ },
+
//****************************************//
// PUBLIC METHODS
initialize: {
@@ -353,9 +365,6 @@ var HTMLDocument = exports.HTMLDocument = Montage.create(baseDocumentModule.Base
this.callback(this);
}
}.bind(this), 50);
-
- // TODO - Not sure where this goes
- this._userComponentSet = {};
} else {
this._styles = this._document.styleSheets[this._document.styleSheets.length - 1];
this._stylesheets = this._document.styleSheets; // Entire stlyesheets array
diff --git a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js
index c8624b29..58a798d8 100644
--- a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js
+++ b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js
@@ -27,18 +27,6 @@ var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component
this.eventManager.addEventListener( "executeAddComponent", this, false);
}
},
- willDraw: {
- enumerable: false,
- value: function() {
-
- }
- },
- draw: {
- enumerable: false,
- value: function() {
-
- }
- },
_loadXMLDoc: {
value:function(dname) {
@@ -61,18 +49,17 @@ var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component
value:function(componentType, dropX, dropY){
// var compW = 100,
// compH = 100,
-// elementType = "div",
-// componentContainer,
-// componentElement;
- var componentEl;
+//
+ var componentEl, componentInstance;
if(componentType == "Button"){
componentEl = NJUtils.makeNJElement("button", componentType, "component");//, {"type": "button"});
componentEl.setAttribute("type", "button");
- componentEl.innerHTML = "Button";
- console.log(componentEl);
-// compW = 118;
-// compH = 52;
+ //componentEl.innerHTML = "Button";
+
+ componentInstance = this.application.ninja.currentDocument._window.addComponent(componentEl, {type: componentType, path: "montage/ui/button.reel", name: "Button"});
+
+
}else if(componentType == "Checkbox"){
compW = 53;
compH = 53;
@@ -142,12 +129,16 @@ var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component
//componentContainer.appendChild(componentElement);
+ this.application.ninja.currentDocument.setComponentInstance(componentInstance, componentEl);
+
NJevent("elementAdding", {"el": componentEl, "data":styles});
/*
var componentRef = this.application.ninja.currentDocument._window.addComponent(componentElement, componentType);
- this.application.ninja.currentDocument._userComponentSet[componentContainer.uuid] = componentRef;
+
*/
+
+
}
}
});
\ No newline at end of file
--
cgit v1.2.3
From 7ccadc20c96539988290999982d7483e013732f9 Mon Sep 17 00:00:00 2001
From: Valerio Virgillito
Date: Thu, 2 Feb 2012 14:49:34 -0800
Subject: adding a componentController and callback for lazy loading.
Signed-off-by: Valerio Virgillito
---
.../ComponentsPanelBase.html | 11 ++++++++
.../ComponentsPanelBase.js | 29 +++++++++++++++++++---
2 files changed, 36 insertions(+), 4 deletions(-)
(limited to 'js')
diff --git a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.html b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.html
index df104ecc..1e040e35 100644
--- a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.html
+++ b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.html
@@ -11,6 +11,17 @@
@@ -37,8 +69,9 @@
+
+
+
+
+
diff --git a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js
index 51822150..338e7e0d 100644
--- a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js
+++ b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js
@@ -11,12 +11,74 @@ var Montage = require("montage/core/core").Montage,
var treeControlModule = require("js/components/tree.reel");
var PIData = require("js/data/pi/pi-data").PiData;
+String.prototype.capitalizeFirstChar = function() {
+ return this.charAt(0).toUpperCase() + this.slice(1);
+};
+
+
var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component, {
components: {
value: null
},
+ componentsToLoad: {
+ value: null
+ },
+
+ componentsLoaded: {
+ value: 0
+ },
+
+ 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" } ]
+ }]
+ }
+ },
+
_testButtonJson: {
value: {
"component": "button",
@@ -42,14 +104,8 @@ var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component
didCreate: {
value: function() {
- this._loadComponents();
-// var req = new XMLHttpRequest();
-// req.identifier = "searchRequest";
-// req.open("GET", url);
-// req.addEventListener("load", this, false);
-// req.addEventListener("error", this, false);
-// req.send();
+ this._loadComponents();
}
},
@@ -61,6 +117,8 @@ var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component
{name: "Textfield", data: "node_modules/components-data/textfield.json"}
];
+ this.componentsToLoad = this.components.length;
+
// Build the PI objects for each component
for(var i = 0, component; component = this.components[i]; i++) {
var req = new XMLHttpRequest();
@@ -70,39 +128,44 @@ var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component
req.addEventListener("error", this, false);
req.send();
-/*
- var piIdentifier = component.name + "Pi";
- var piObj = [];
- var section = {};
+ }
+
+ }
+ },
+
+ handleLoad: {
+ value: function(evt) {
+ var response = JSON.parse(evt.target.responseText);
+ var component = response.component.capitalizeFirstChar();
- section.label = component.name + " Properties";
- section.Section = [];
+ var piIdentifier = component + "Pi";
+ var piObj = [];
+ var section = {};
- for(var j = 0, props; props = this._testButtonJson.properties[j]; j++) {
- var row = {};
- row.type = this.getControlType(props.type);
- row.id = props.name;
- row.prop = props.name;
- row.defaultValue = props["default"];
- row.label = props.name;
- section.Section.push([row]);
- }
+ section.label = component + " Properties";
+ section.Section = [];
- PIData[piIdentifier] = [];
- PIData[piIdentifier].push(section);
- */
+ for(var j = 0, props; props = response.properties[j]; j++) {
+ var row = {};
+ row.type = this.getControlType(props.type);
+ row.id = props.name;
+ row.prop = props.name;
+ row.defaultValue = props["default"];
+ row.label = props.name;
+ section.Section.push([row]);
}
- }
- },
+ PIData[piIdentifier] = [];
+ PIData[piIdentifier].push(section);
- handleLoad: {
- value: function(evt) {
- var response = JSON.parse(evt.target.responseText);
- console.log(response);
+ this.componentsLoaded++;
+
+ if(this.componentsLoaded === this.componentsToLoad) {
+ console.log("all loaded");
+ }
}
},
@@ -123,6 +186,7 @@ var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component
prepareForDraw: {
enumerable: false,
value: function() {
+
var treeHolderDiv = document.getElementById("comp_tree");
var componentsTree = treeControlModule.Tree.create();
componentsTree.element = treeHolderDiv;
@@ -130,6 +194,7 @@ var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component
componentsTree.needsDraw = true;
this.eventManager.addEventListener( "executeAddComponent", this, false);
+
}
},
--
cgit v1.2.3
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
---
.../PanelContainer.reel/PanelContainer.js | 4 +-
js/panels/presets/content.reel/content.css | 55 ++++++++++
js/panels/presets/content.reel/content.html | 66 ++++++++++++
js/panels/presets/content.reel/content.js | 106 ++++++++++++++++++
js/panels/presets/presets-panel.js | 15 +++
.../presets/style-presets.reel/style-presets.css | 0
.../presets/style-presets.reel/style-presets.html | 58 ++++++++++
.../presets/style-presets.reel/style-presets.js | 119 +++++++++++++++++++++
.../transitions-presets.css | 0
.../transitions-presets.html | 58 ++++++++++
.../transitions-presets.js | 67 ++++++++++++
11 files changed, 547 insertions(+), 1 deletion(-)
create mode 100644 js/panels/presets/content.reel/content.css
create mode 100644 js/panels/presets/content.reel/content.html
create mode 100644 js/panels/presets/content.reel/content.js
create mode 100644 js/panels/presets/presets-panel.js
create mode 100644 js/panels/presets/style-presets.reel/style-presets.css
create mode 100644 js/panels/presets/style-presets.reel/style-presets.html
create mode 100644 js/panels/presets/style-presets.reel/style-presets.js
create mode 100644 js/panels/presets/transitions-presets.reel/transitions-presets.css
create mode 100644 js/panels/presets/transitions-presets.reel/transitions-presets.html
create mode 100644 js/panels/presets/transitions-presets.reel/transitions-presets.js
(limited to 'js')
diff --git a/js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js b/js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js
index 66333cc0..0569cc51 100644
--- a/js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js
+++ b/js/panels/PanelContainer/PanelContainer.reel/PanelContainer.js
@@ -15,6 +15,7 @@ var CSSPanel = require("js/panels/CSSPanel/CSSPanel").CSSPanel;
var ComponentsPanel = require("js/panels/Components/ComponentsPanel").ComponentsPanel;
var ProjectPanel = require("js/panels/Project/ProjectPanel").ProjectPanel;
var MaterialsPanel = require("js/panels/Materials/MaterialsPanel").MaterialsPanel;
+var PresetsPanel = require("js/panels/presets/presets-panel").PresetsPanel;
exports.PanelContainer = Montage.create(Component, {
lastOffset: {
@@ -44,7 +45,7 @@ exports.PanelContainer = Montage.create(Component, {
},
initPanelOrder: {
- value: ['PropertiesPanel','ColorPanel','ComponentsPanel','ProjectPanel','CSSPanel','MaterialsPanel']
+ value: ['PresetsPanel','PropertiesPanel','ColorPanel','ComponentsPanel','ProjectPanel','CSSPanel','MaterialsPanel']
},
panelOrder: {
@@ -93,6 +94,7 @@ exports.PanelContainer = Montage.create(Component, {
// this.needsDraw = true;
+ this.addEventListener("change@appModel.PresetsPanel", this, false);
this.addEventListener("change@appModel.PropertiesPanel", this, false);
this.addEventListener("change@appModel.ProjectPanel", this, false);
this.addEventListener("change@appModel.ColorPanel", this, false);
diff --git a/js/panels/presets/content.reel/content.css b/js/panels/presets/content.reel/content.css
new file mode 100644
index 00000000..a6a1545f
--- /dev/null
+++ b/js/panels/presets/content.reel/content.css
@@ -0,0 +1,55 @@
+.presetsPanel {
+ display: -webkit-box;
+ text-shadow: 1px 1px 0 #000;
+ -webkit-box-orient: vertical;
+ -webkit-box-flex: 1;
+}
+.presetsPanel .treeRoot {
+ margin: 0 8px;
+}
+.tab-bar {
+ -webkit-box-flex: 0;
+ background-color: #282828;
+ color: #FFF;
+ display: -webkit-box;
+ font-size: 12px;
+ -webkit-box-orient: horizontal;
+}
+
+.tab-bar div {
+ -webkit-box-flex: 0;
+ border-top-right-radius: 2px;
+ border-top-left-radius: 2px;
+ background-color: #474747;
+ background-image: -webkit-linear-gradient(bottom, rgba(0,0,0,0.2) 0,rgba(0,0,0,0) 3px);
+ border-top: 1px solid rgb(100, 100, 100);
+ border-left: 1px solid rgba(100, 100, 100, 0.3);
+ border-right: 1px solid rgba(100, 100, 100, 0.3);
+ padding: 4px 9px;
+ cursor: pointer;
+ opacity: 0.6;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ overflow: hidden;
+ position: relative;
+ z-index: 999;
+}
+.tab-bar div.active-tab {
+ background-image: none;
+ box-shadow: 0 -5px 2px 3px rgba(0,0,0,0.2);
+ position: relative;
+ opacity: 1;
+ text-overflow: clip;
+ z-index: 1001;
+}
+
+.librarySlot {
+ -webkit-box-flex: 1;
+ overflow: auto;
+ background-color: #474747;
+
+ color: #FFF;
+
+ position: relative;
+ z-index: 1000;
+}
\ No newline at end of file
diff --git a/js/panels/presets/content.reel/content.html b/js/panels/presets/content.reel/content.html
new file mode 100644
index 00000000..38de2a6d
--- /dev/null
+++ b/js/panels/presets/content.reel/content.html
@@ -0,0 +1,66 @@
+
+
+
+
+
+
+
+
+
+