summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ui/editor/Presets.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2014-10-16 16:06:47 -0400
committerJules Laplace <jules@okfoc.us>2014-10-16 16:06:47 -0400
commit6842a993ac6aef50e79a08df9fcb0a1d769592a1 (patch)
treee210630d2d544eb6db5e6b8c46dfa86ed1192915 /public/assets/javascripts/ui/editor/Presets.js
parent6733c7626f109373bcd526a1e1707c9ccfee75a8 (diff)
parente25af0a7106c359faae2f73a7c2295ea93db8341 (diff)
merge
Diffstat (limited to 'public/assets/javascripts/ui/editor/Presets.js')
-rw-r--r--public/assets/javascripts/ui/editor/Presets.js71
1 files changed, 67 insertions, 4 deletions
diff --git a/public/assets/javascripts/ui/editor/Presets.js b/public/assets/javascripts/ui/editor/Presets.js
index a7e92b6..0a0e0fe 100644
--- a/public/assets/javascripts/ui/editor/Presets.js
+++ b/public/assets/javascripts/ui/editor/Presets.js
@@ -2,9 +2,13 @@ var Presets = View.extend({
el: "#presets",
events: {
+ "mousedown": "stopPropagation",
"click .presets span": "selectPreset",
+ "click .swatches span": "selectColor",
+ "change .url": "tileWalls",
+ "keydown .url": "enterSetUrl",
},
-
+
presets: {
wireframe: {
wall: [255,255,255],
@@ -17,8 +21,9 @@ var Presets = View.extend({
outline: [0,0,0],
floor: [109,116,106],
ceiling: [159,163,157],
+ background: [109,116,106],
},
- pfunk: {
+ "p.Funk": {
wall: [255,63,78],
outline: [255,246,0],
floor: [255,255,0],
@@ -30,14 +35,31 @@ var Presets = View.extend({
floor: [0,0,0],
ceiling: [0,0,0],
},
+ matrix: {
+ wall: { src: "http://dump.fm/images/20130225/1361818675427-dumpfm-melipone-matrixremixtransfast.gif", scale: 4.0, color: [0,0,0] },
+ outline: [0,0,0],
+ floor: [10,15,10],
+ ceiling: [0,0,0],
+ },
},
initialize: function(opt){
this.parent = opt.parent
+
+ this.$url = this.$(".url")
+
+ this.$presets = this.$(".presets")
+ _.keys(this.presets).forEach(function(name){
+ var $swatch = $("<span>")
+ $swatch.html(capitalize(name))
+ $swatch.data('preset', name)
+ this.$presets.append($swatch)
+ }.bind(this))
},
toggle: function(state){
- this.$el.toggleClass("active", state);
+ this.$el.toggleClass("active", state)
+ this.parent.cursor.message(state ? "presets" : "start")
},
show: function(){
@@ -51,9 +73,50 @@ var Presets = View.extend({
selectPreset: function(e){
var preset = $(e.currentTarget).data('preset')
if (! this.presets[preset]) return
- this.parent.lightControl.load(this.presets[preset])
this.$(".active").removeClass('active')
$(e.currentTarget).addClass('active')
+ this.load(this.presets[preset])
+ },
+
+ selectColor: function(e){
+ var preset = $(e.currentTarget).data('color')
+ console.log(preset)
},
+ lastPreset: {wall:[1],outline:[1],floor:[1],ceiling:[1]},
+ load: function(preset){
+ this.parent.colorControl.modes.forEach(function(mode){
+ if (! preset[mode].length) {
+ Walls.setWallpaper[mode](preset[mode])
+ Walls.setColor[mode](preset[mode].color)
+ }
+ else {
+ if (! this.lastPreset[mode].length) {
+ Walls.clearWallpaper[mode]()
+ }
+ Walls.setColor[mode](preset[mode])
+ this.parent.colorControl.$swatch[ mode ].css("background-color", rgb_string(preset[mode]))
+ }
+ }.bind(this))
+ this.parent.colorControl.setMode(preset.wall.color ? "wall" : "floor")
+ Walls.setBodyColor()
+ this.lastPreset = preset
+ },
+
+ tileWalls: function(){
+ var url = this.$url.sanitize()
+ if (url.length && url.indexOf("http://") == 0) {
+ Walls.setWallpaper.wall({ src: url })
+ Walls.setWallpaper.floor({ src: url })
+ Walls.setWallpaper.ceiling({ src: url })
+ }
+ app.controller.wallpaperPicker.addUrl(url)
+ },
+ enterSetUrl: function (e) {
+ e.stopPropagation()
+ if (e.keyCode == 13) {
+ setTimeout(this.tileWalls.bind(this), 100)
+ }
+ },
+
}) \ No newline at end of file