diff options
| -rw-r--r-- | public/assets/img/palette.gif | bin | 0 -> 3262 bytes | |||
| -rw-r--r-- | public/assets/javascripts/mx/primitives/mx.video.js | 4 | ||||
| -rw-r--r-- | public/assets/javascripts/mx/primitives/mx.vimeo.js | 4 | ||||
| -rw-r--r-- | public/assets/javascripts/mx/primitives/mx.youtube.js | 4 | ||||
| -rw-r--r-- | public/assets/javascripts/ui/_router.js | 27 | ||||
| -rw-r--r-- | public/assets/javascripts/ui/editor/LightControl.js | 1 | ||||
| -rw-r--r-- | public/assets/javascripts/ui/editor/MediaEditor.js | 4 | ||||
| -rw-r--r-- | public/assets/javascripts/ui/editor/WallpaperPicker.js | 91 | ||||
| -rw-r--r-- | public/assets/javascripts/ui/lib/Router.js | 4 | ||||
| -rw-r--r-- | server/index.js | 2 | ||||
| -rw-r--r-- | views/modal.ejs | 2 |
11 files changed, 134 insertions, 9 deletions
diff --git a/public/assets/img/palette.gif b/public/assets/img/palette.gif Binary files differnew file mode 100644 index 0000000..39c134f --- /dev/null +++ b/public/assets/img/palette.gif diff --git a/public/assets/javascripts/mx/primitives/mx.video.js b/public/assets/javascripts/mx/primitives/mx.video.js index 5341226..7f91e34 100644 --- a/public/assets/javascripts/mx/primitives/mx.video.js +++ b/public/assets/javascripts/mx/primitives/mx.video.js @@ -19,8 +19,8 @@ MX.Video = MX.Object3D.extend({ ops.className && this.el.classList.add(ops.className) this.backface && this.el.classList.add("backface-visible") this.el.classList.add("video") - this.paused = true - this.muted = this.media.mute + this.paused = !! this.media.autoplay + this.muted = !! this.media.mute this.load() }, diff --git a/public/assets/javascripts/mx/primitives/mx.vimeo.js b/public/assets/javascripts/mx/primitives/mx.vimeo.js index e7555ef..0301e64 100644 --- a/public/assets/javascripts/mx/primitives/mx.vimeo.js +++ b/public/assets/javascripts/mx/primitives/mx.vimeo.js @@ -19,8 +19,8 @@ MX.Vimeo = MX.Object3D.extend({ ops.className && this.el.classList.add(ops.className) this.backface && this.el.classList.add("backface-visible") this.el.classList.add("video") - this.paused = true - this.muted = this.media.mute + this.paused = !! this.media.autoplay + this.muted = !! this.media.mute this.load() }, diff --git a/public/assets/javascripts/mx/primitives/mx.youtube.js b/public/assets/javascripts/mx/primitives/mx.youtube.js index a06cf5b..8c11da6 100644 --- a/public/assets/javascripts/mx/primitives/mx.youtube.js +++ b/public/assets/javascripts/mx/primitives/mx.youtube.js @@ -19,8 +19,8 @@ MX.Youtube = MX.Object3D.extend({ ops.className && this.el.classList.add(ops.className) this.backface && this.el.classList.add("backface-visible") this.el.classList.add("video") - this.paused = true - this.muted = this.media.mute + this.paused = !! this.media.autoplay + this.muted = !! this.media.mute this.load() }, diff --git a/public/assets/javascripts/ui/_router.js b/public/assets/javascripts/ui/_router.js index 2b2c7c0..b59d838 100644 --- a/public/assets/javascripts/ui/_router.js +++ b/public/assets/javascripts/ui/_router.js @@ -37,6 +37,8 @@ var SiteRouter = Router.extend({ "/project/new/:layout": 'projectNewWithLayout', "/project/:name": 'project', "/project/:name/view": 'projectViewer', + + "/test/wallpaper": 'testWallpaper', }, initialize: function(){ @@ -200,5 +202,30 @@ var SiteRouter = Router.extend({ // this.documentModal.destroy(name) }, + + testWallpaper: function(e){ + var content = document.getElementById("content") + content.style.width = "680px" + content.style.margin = "0 auto" + var wm = new WallpaperManager() + app.on('wallpaper-ready', function(){ + var black = [0,0,0,0] + var white = [255,255,255,1.0] + var swatches = wm.buildSwatches(black, white, 4) + document.body.style.backgroundColor = "#eee" + swatches.forEach(function(swatch){ + swatch.style.margin = "4px" + swatch.style.border = "1px solid lime" + swatch.style.backgroundColor = "#888" + content.appendChild(swatch) + swatch.onclick = function(){ + dataUrl = swatch.toDataURL() + document.body.style.backgroundImage = "url(" + dataUrl + ")" + } + }) + }) + wm.init() + }, + }) diff --git a/public/assets/javascripts/ui/editor/LightControl.js b/public/assets/javascripts/ui/editor/LightControl.js index 20c3577..93d97ed 100644 --- a/public/assets/javascripts/ui/editor/LightControl.js +++ b/public/assets/javascripts/ui/editor/LightControl.js @@ -3,6 +3,7 @@ var LightControl = View.extend({ el: ".lightcontrol", events: { + "mousedown": "stopPropagation", }, toggle: function(){ diff --git a/public/assets/javascripts/ui/editor/MediaEditor.js b/public/assets/javascripts/ui/editor/MediaEditor.js index 1ffe7b8..f9eaad5 100644 --- a/public/assets/javascripts/ui/editor/MediaEditor.js +++ b/public/assets/javascripts/ui/editor/MediaEditor.js @@ -39,7 +39,7 @@ var MediaEditor = FormView.extend({ togglePaused: function(state){ var state = this.scenery.toggle(state) - this.$playButton.toggleClass("playing", ! state) + this.$playButton.toggleClass("paused", ! state) }, pick: function(scenery) { @@ -72,7 +72,7 @@ var MediaEditor = FormView.extend({ this.$(".video").show() this.$(".image").hide() - this.$playButton.toggleClass("paused", this.scenery.paused()) + this.$playButton.toggleClass("paused", ! this.scenery.paused()) this.$autoplay.prop('checked', !! media.autoplay) this.$loop.prop('checked', !! media.loop) this.$mute.prop('checked', !! media.mute) diff --git a/public/assets/javascripts/ui/editor/WallpaperPicker.js b/public/assets/javascripts/ui/editor/WallpaperPicker.js index ffbd935..474d4c1 100644 --- a/public/assets/javascripts/ui/editor/WallpaperPicker.js +++ b/public/assets/javascripts/ui/editor/WallpaperPicker.js @@ -5,6 +5,9 @@ var WallpaperPicker = View.extend({ events: { "click .paper1": 'pick', }, + + initialize: function(){ + }, toggle: function(){ this.$el.toggleClass("active"); @@ -18,3 +21,91 @@ var WallpaperPicker = View.extend({ } }) + +// pattern +// scale +// foreground +// background + +var WallpaperManager = function () { + + var image = new Image () + var imageData + var w, h + + this.masks = [] + + this.init = function(){ + this.load() + } + + this.load = function(){ + image.onload = function(){ + this.loadImageData() + this.buildMasks() + app.tube('wallpaper-ready') + }.bind(this) + + image.src = "/assets/img/palette.gif" + } + + this.loadImageData = function(){ + var canvas = document.createElement('canvas') + var ctx = canvas.getContext('2d') + w = canvas.width = image.naturalWidth + h = canvas.height = image.naturalHeight + ctx.drawImage(image, 0,0) + imageData = ctx.getImageData(0,0,image.naturalWidth,image.naturalHeight).data + } + + this.buildMasks = function(){ + var mask + for (var y = 0; y < 6; y++) { + for (var x = 0; x < 16; x++) { + mask = this.buildMask(x,y) + this.masks.push(mask) + } + } + } + + this.buildMask = function(x,y){ + // add the offset of the top-left swatch + x = (x * 18) + 15 + y = (y * 16) + 5 + + var mask = new Array(64) + var t = 0 + for (var i = 0; i < 8; i++) { + for (var j = 0; j < 8; j++) { + t = ( w*(y+j) + x+i ) * 4 + mask[j*8+i] = imageData[t] === 0 + } + } + return mask + } + + this.buildSwatches = function(black, white, scale) { + var swatches = this.masks.map(function(mask){ + return this.buildSwatch(mask,black,white,scale) + }.bind(this)) + + return swatches + } + + this.buildSwatch = function(mask,black,white,scale){ + black = 'rgba(' + black.join(',') + ')' + white = 'rgba(' + white.join(',') + ')' + var canvas = document.createElement("canvas") + canvas.width = 8*scale + canvas.height = 8*scale + var ctx = canvas.getContext('2d') + for (var i = 0; i < 8; i++) { + for (var j = 0; j < 8; j++) { + ctx.fillStyle = mask[j*8+i] ? black : white + ctx.fillRect(i*scale, j*scale, scale, scale) + } + } + return canvas + } + +}
\ No newline at end of file diff --git a/public/assets/javascripts/ui/lib/Router.js b/public/assets/javascripts/ui/lib/Router.js index 214603c..d27654a 100644 --- a/public/assets/javascripts/ui/lib/Router.js +++ b/public/assets/javascripts/ui/lib/Router.js @@ -10,6 +10,10 @@ var Router = View.extend({ path[i] = null } } + + if (path[path.length-1] == null) { + path.pop() + } for (var route in this.routes) { var routePath = route.split("/") diff --git a/server/index.js b/server/index.js index 038b184..71cd862 100644 --- a/server/index.js +++ b/server/index.js @@ -140,6 +140,8 @@ site.route = function () { app.post('/api/media/upload', middleware.ensureAuthenticated, api.media.upload) app.delete('/api/media/destroy', middleware.ensureAuthenticated, api.media.destroy) + app.get('/test/*', middleware.ensureAuthenticated, middleware.ensureIsStaff, views.modal) + } diff --git a/views/modal.ejs b/views/modal.ejs index 6ed3fa1..7ca869c 100644 --- a/views/modal.ejs +++ b/views/modal.ejs @@ -8,7 +8,7 @@ <div class="rapper page" style="height: 100%;"> [[ include partials/header ]] - <div style="height: 70%; clear: both;"></div> + <div style="height: 70%; clear: both;" id="content"></div> [[ include partials/confirm-modal ]] [[ include partials/sign-in ]] |
