diff options
Diffstat (limited to 'public/assets/javascripts/ui/editor/Presets.js')
| -rw-r--r-- | public/assets/javascripts/ui/editor/Presets.js | 85 |
1 files changed, 59 insertions, 26 deletions
diff --git a/public/assets/javascripts/ui/editor/Presets.js b/public/assets/javascripts/ui/editor/Presets.js index 1e70aa2..0a0e0fe 100644 --- a/public/assets/javascripts/ui/editor/Presets.js +++ b/public/assets/javascripts/ui/editor/Presets.js @@ -5,24 +5,10 @@ var Presets = View.extend({ "mousedown": "stopPropagation", "click .presets span": "selectPreset", "click .swatches span": "selectColor", + "change .url": "tileWalls", + "keydown .url": "enterSetUrl", }, - colors: [ - [255,94,58], - [255,149,0], - [255,219,76], - [76,217,100], - [52,170,220], - [29,98,240], - [198,68,252], - [0,0,0], - [74,74,74], - [125,126,127], - [209,211,212], - [235,235,235], - [255,255,255], - ], - presets: { wireframe: { wall: [255,255,255], @@ -35,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], @@ -48,21 +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.$colors = this.$(".colors") - this.colors.forEach(function(color){ - var $swatch = $("<span>") - $swatch.css("background-color","rgb(" + color + ")") - $swatch.data('color', color) - this.$colors.append($swatch) - }.bind(this)) + + 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(){ @@ -76,9 +73,9 @@ 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){ @@ -86,4 +83,40 @@ var Presets = View.extend({ 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 |
