diff --git a/css/core.less b/css/core.less
index 08c698a..ac6ff64 100755
--- a/css/core.less
+++ b/css/core.less
@@ -6,6 +6,25 @@
clear:both;
}
+.device
+{
+ position:absolute;
+ cursor:pointer;
+
+ .on { background-color:Green; }
+ .off { background-color:Red; }
+
+ .cpicker {
+ width:65px;
+ height:60px;
+ padding:2px;
+ input {
+ width:50px;
+ margin: 18px 0 0 4px;
+ }
+ }
+}
+
/* basic layout */
header {
width: 600px;
@@ -37,54 +56,36 @@ h1 {
}
nav {
+ ul li {
+ float:left;
+ width:100px;
+ height:80px;
+ border: 1px solid #fff;
+ margin: 9px;
+ text-align:center;
+ background-color: #444;
+ a {
+ display:block;
+ height: 80px;
+ text-decoration:none;
+ color: #fff;
+ line-height:80px;
+ }
+ a:hover { background-color:#777; }
+ }
}
-nav ul li {
- float:left;
- width:100px;
- height:80px;
- border: 1px solid #fff;
- margin: 9px;
- text-align:center;
-
- /*temp*/
- background-color: #444;
-}
-
-nav ul li a {
- display:block;
- height: 80px;
- text-decoration:none;
- color: #fff;
- line-height:80px;
-}
-
-nav ul li a:hover { background-color:#777; }
-
.room
{
position:relative;
height: 300px;
+
+ room1 { background:url(../img/room1.png) no-repeat center; }
+ room2 { background:url(../img/room2.png) no-repeat center; }
+ room3 { background:url(../img/room3.png) no-repeat center; }
+ room4 { background:url(../img/room4.png) no-repeat center; }
+ room5 { background:url(../img/room5.png) no-repeat center; }
}
-.room#room1 { background:url(../img/room1.png) no-repeat center; }
-.room#room2 { background:url(../img/room2.png) no-repeat center; }
-.room#room3 { background:url(../img/room3.png) no-repeat center; }
-.room#room4 { background:url(../img/room4.png) no-repeat center; }
-.room#room5 { background:url(../img/room5.png) no-repeat center; }
-.device
-{
- position:absolute;
- cursor:pointer;
-}
-.on
-{
- background-color:Green;
-}
-
-.off
-{
- background-color:Red;
-}
\ No newline at end of file
diff --git a/img/arrow.gif b/img/arrow.gif
new file mode 100644
index 0000000..246478a
Binary files /dev/null and b/img/arrow.gif differ
diff --git a/img/cross.gif b/img/cross.gif
new file mode 100644
index 0000000..0ee9c7a
Binary files /dev/null and b/img/cross.gif differ
diff --git a/img/hs.png b/img/hs.png
new file mode 100644
index 0000000..3d94486
Binary files /dev/null and b/img/hs.png differ
diff --git a/img/hv.png b/img/hv.png
new file mode 100644
index 0000000..1c5e01f
Binary files /dev/null and b/img/hv.png differ
diff --git a/index.html b/index.html
index 9d6d692..24748ec 100755
--- a/index.html
+++ b/index.html
@@ -5,6 +5,7 @@
Bunti backbone prototype
+
@@ -28,7 +29,7 @@
-
+
diff --git a/js/app.js b/js/app.js
index 220d9ea..4e37d1a 100755
--- a/js/app.js
+++ b/js/app.js
@@ -10,37 +10,30 @@
return modules[name] = { Views: {} };
};
} ()
-};
-
-var dataModel = {
+},
+dataModel = {
rooms: [
- {
- roomId: 1,
- title: "Raum 1",
- devices: [
- { deviceId: 1, type: "switch", options: [{ status: "off"}], pos:{x:280} },
- { deviceId: 2, type: "switch", options: [{ status: "on"}], pos:{x:500,y:280} },
- ]
- },
- { roomId: 2, title: "Raum 2" },
- { roomId: 3, title: "Raum 3" },
- { roomId: 4, title: "Raum 4" },
- { roomId: 5, title: "Raum 5" }
- ]
+ { roomId: 1, title: "Raum 1", devices: [
+ { deviceId: 1, type: "switch", options: [{ status: "off"}], pos:{x:280} },
+ { deviceId: 2, type: "switch", options: [{ status: "on"}], pos:{x:500,y:280} }
+ ]},
+ { roomId: 2, title: "Raum 2", devices: [
+ { deviceId: 3, type: "colorpicker", options: [{ color:'FF3300' }], pos:{x:400,y:0} },
+ { deviceId: 4, type: "colorpicker", options: [{ color:'FF3300' }], pos:{x:400,y:230} }
+ ]},
+ { roomId: 3, title: "Raum 3" },
+ { roomId: 4, title: "Raum 4" },
+ { roomId: 5, title: "Raum 5" }
+ ]
};
jQuery(function ($) {
// load the modules
app.util = app.module('util');
- app.util.preloadTemplates(['room','switch'], function () {
+ app.util.preloadTemplates(['room','switch','colorpicker'], function () {
app.router = app.module('router');
app.Router = new app.router.Router();
Backbone.history.start();
});
});
-//app.room = app.module('room');
-//app.option = app.module('option');
-
-//// create the model
-//dashboard = new app.room.View({ model: dataModel });
\ No newline at end of file
diff --git a/js/libs/jscolor.js b/js/libs/jscolor.js
new file mode 100644
index 0000000..2428a6a
--- /dev/null
+++ b/js/libs/jscolor.js
@@ -0,0 +1,953 @@
+/**
+ * jscolor, JavaScript Color Picker
+ *
+ * @version 1.4.0
+ * @license GNU Lesser General Public License, http://www.gnu.org/copyleft/lesser.html
+ * @author Jan Odvarko, http://odvarko.cz
+ * @created 2008-06-15
+ * @updated 2012-07-06
+ * @link http://jscolor.com
+ */
+
+
+var jscolor = {
+
+
+ dir : 'img/', // location of jscolor directory (leave empty to autodetect)
+ bindClass : 'color', // class name
+ binding : true, // automatic binding via
+ preloading : true, // use image preloading?
+
+
+ install : function() {
+ jscolor.addEvent(window, 'load', jscolor.init);
+ },
+
+
+ init : function() {
+ if(jscolor.binding) {
+ jscolor.bind();
+ }
+ if(jscolor.preloading) {
+ jscolor.preload();
+ }
+ },
+
+
+ getDir : function() {
+ if(!jscolor.dir) {
+ var detected = jscolor.detectDir();
+ jscolor.dir = detected!==false ? detected : 'jscolor/';
+ }
+ return jscolor.dir;
+ },
+
+
+ detectDir : function() {
+ var base = location.href;
+
+ var e = document.getElementsByTagName('base');
+ for(var i=0; i vs[a] ?
+ (-vp[a]+tp[a]+ts[a]/2 > vs[a]/2 && tp[a]+ts[a]-ps[a] >= 0 ? tp[a]+ts[a]-ps[a] : tp[a]) :
+ tp[a],
+ -vp[b]+tp[b]+ts[b]+ps[b]-l+l*c > vs[b] ?
+ (-vp[b]+tp[b]+ts[b]/2 > vs[b]/2 && tp[b]+ts[b]-l-l*c >= 0 ? tp[b]+ts[b]-l-l*c : tp[b]+ts[b]-l+l*c) :
+ (tp[b]+ts[b]-l+l*c >= 0 ? tp[b]+ts[b]-l+l*c : tp[b]+ts[b]-l-l*c)
+ ];
+ }
+ drawPicker(pp[a], pp[b]);
+ }
+ };
+
+
+ this.importColor = function() {
+ if(!valueElement) {
+ this.exportColor();
+ } else {
+ if(!this.adjust) {
+ if(!this.fromString(valueElement.value, leaveValue)) {
+ styleElement.style.backgroundImage = styleElement.jscStyle.backgroundImage;
+ styleElement.style.backgroundColor = styleElement.jscStyle.backgroundColor;
+ styleElement.style.color = styleElement.jscStyle.color;
+ this.exportColor(leaveValue | leaveStyle);
+ }
+ } else if(!this.required && /^\s*$/.test(valueElement.value)) {
+ valueElement.value = '';
+ styleElement.style.backgroundImage = styleElement.jscStyle.backgroundImage;
+ styleElement.style.backgroundColor = styleElement.jscStyle.backgroundColor;
+ styleElement.style.color = styleElement.jscStyle.color;
+ this.exportColor(leaveValue | leaveStyle);
+
+ } else if(this.fromString(valueElement.value)) {
+ // OK
+ } else {
+ this.exportColor();
+ }
+ }
+ };
+
+
+ this.exportColor = function(flags) {
+ if(!(flags & leaveValue) && valueElement) {
+ var value = this.toString();
+ if(this.caps) { value = value.toUpperCase(); }
+ if(this.hash) { value = '#'+value; }
+ valueElement.value = value;
+ }
+ if(!(flags & leaveStyle) && styleElement) {
+ styleElement.style.backgroundImage = "none";
+ styleElement.style.backgroundColor =
+ '#'+this.toString();
+ styleElement.style.color =
+ 0.213 * this.rgb[0] +
+ 0.715 * this.rgb[1] +
+ 0.072 * this.rgb[2]
+ < 0.5 ? '#FFF' : '#000';
+ }
+ if(!(flags & leavePad) && isPickerOwner()) {
+ redrawPad();
+ }
+ if(!(flags & leaveSld) && isPickerOwner()) {
+ redrawSld();
+ }
+ };
+
+
+ this.fromHSV = function(h, s, v, flags) { // null = don't change
+ if(h !== null) { h = Math.max(0.0, this.minH, Math.min(6.0, this.maxH, h)); }
+ if(s !== null) { s = Math.max(0.0, this.minS, Math.min(1.0, this.maxS, s)); }
+ if(v !== null) { v = Math.max(0.0, this.minV, Math.min(1.0, this.maxV, v)); }
+
+ this.rgb = HSV_RGB(
+ h===null ? this.hsv[0] : (this.hsv[0]=h),
+ s===null ? this.hsv[1] : (this.hsv[1]=s),
+ v===null ? this.hsv[2] : (this.hsv[2]=v)
+ );
+
+ this.exportColor(flags);
+ };
+
+
+ this.fromRGB = function(r, g, b, flags) { // null = don't change
+ if(r !== null) { r = Math.max(0.0, Math.min(1.0, r)); }
+ if(g !== null) { g = Math.max(0.0, Math.min(1.0, g)); }
+ if(b !== null) { b = Math.max(0.0, Math.min(1.0, b)); }
+
+ var hsv = RGB_HSV(
+ r===null ? this.rgb[0] : r,
+ g===null ? this.rgb[1] : g,
+ b===null ? this.rgb[2] : b
+ );
+ if(hsv[0] !== null) {
+ this.hsv[0] = Math.max(0.0, this.minH, Math.min(6.0, this.maxH, hsv[0]));
+ }
+ if(hsv[2] !== 0) {
+ this.hsv[1] = hsv[1]===null ? null : Math.max(0.0, this.minS, Math.min(1.0, this.maxS, hsv[1]));
+ }
+ this.hsv[2] = hsv[2]===null ? null : Math.max(0.0, this.minV, Math.min(1.0, this.maxV, hsv[2]));
+
+ // update RGB according to final HSV, as some values might be trimmed
+ var rgb = HSV_RGB(this.hsv[0], this.hsv[1], this.hsv[2]);
+ this.rgb[0] = rgb[0];
+ this.rgb[1] = rgb[1];
+ this.rgb[2] = rgb[2];
+
+ this.exportColor(flags);
+ };
+
+
+ this.fromString = function(hex, flags) {
+ var m = hex.match(/^\W*([0-9A-F]{3}([0-9A-F]{3})?)\W*$/i);
+ if(!m) {
+ return false;
+ } else {
+ if(m[1].length === 6) { // 6-char notation
+ this.fromRGB(
+ parseInt(m[1].substr(0,2),16) / 255,
+ parseInt(m[1].substr(2,2),16) / 255,
+ parseInt(m[1].substr(4,2),16) / 255,
+ flags
+ );
+ } else { // 3-char notation
+ this.fromRGB(
+ parseInt(m[1].charAt(0)+m[1].charAt(0),16) / 255,
+ parseInt(m[1].charAt(1)+m[1].charAt(1),16) / 255,
+ parseInt(m[1].charAt(2)+m[1].charAt(2),16) / 255,
+ flags
+ );
+ }
+ return true;
+ }
+ };
+
+
+ this.toString = function() {
+ return (
+ (0x100 | Math.round(255*this.rgb[0])).toString(16).substr(1) +
+ (0x100 | Math.round(255*this.rgb[1])).toString(16).substr(1) +
+ (0x100 | Math.round(255*this.rgb[2])).toString(16).substr(1)
+ );
+ };
+
+
+ function RGB_HSV(r, g, b) {
+ var n = Math.min(Math.min(r,g),b);
+ var v = Math.max(Math.max(r,g),b);
+ var m = v - n;
+ if(m === 0) { return [ null, 0, v ]; }
+ var h = r===n ? 3+(b-g)/m : (g===n ? 5+(r-b)/m : 1+(g-r)/m);
+ return [ h===6?0:h, m/v, v ];
+ }
+
+
+ function HSV_RGB(h, s, v) {
+ if(h === null) { return [ v, v, v ]; }
+ var i = Math.floor(h);
+ var f = i%2 ? h-i : 1-(h-i);
+ var m = v * (1 - s);
+ var n = v * (1 - s*f);
+ switch(i) {
+ case 6:
+ case 0: return [v,n,m];
+ case 1: return [n,v,m];
+ case 2: return [m,v,n];
+ case 3: return [m,n,v];
+ case 4: return [n,m,v];
+ case 5: return [v,m,n];
+ }
+ }
+
+
+ function removePicker() {
+ delete jscolor.picker.owner;
+ document.getElementsByTagName('body')[0].removeChild(jscolor.picker.boxB);
+ }
+
+
+ function drawPicker(x, y) {
+ if(!jscolor.picker) {
+ jscolor.picker = {
+ box : document.createElement('div'),
+ boxB : document.createElement('div'),
+ pad : document.createElement('div'),
+ padB : document.createElement('div'),
+ padM : document.createElement('div'),
+ sld : document.createElement('div'),
+ sldB : document.createElement('div'),
+ sldM : document.createElement('div'),
+ btn : document.createElement('div'),
+ btnS : document.createElement('span'),
+ btnT : document.createTextNode(THIS.pickerCloseText)
+ };
+ for(var i=0,segSize=4; i
+ {{color}}
+
\ No newline at end of file