From eac88be42cc1a7f85c7a0533414e1047e0addc39 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 23 Jun 2014 18:11:59 -0400 Subject: stubbing in stuff for videos/embeds --- views/partials/scripts.ejs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'views/partials/scripts.ejs') diff --git a/views/partials/scripts.ejs b/views/partials/scripts.ejs index 39d27e2..6a50c04 100644 --- a/views/partials/scripts.ejs +++ b/views/partials/scripts.ejs @@ -48,6 +48,8 @@ + + -- cgit v1.2.3-70-g09d2 From d52c037ab7e01660a85363a2941052e4d4b8cf03 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 24 Jun 2014 15:31:49 -0400 Subject: removing old mx stuff --- public/assets/javascripts/environments/app.js | 28 -- .../javascripts/environments/tableaux/_empty.js | 32 -- .../javascripts/environments/tableaux/columns.js | 36 --- .../environments/tableaux/columns_circle.js | 42 --- .../environments/tableaux/columns_split.js | 63 ---- public/assets/javascripts/map/map.js | 337 --------------------- public/assets/javascripts/map/map_editor.js | 102 ------- public/assets/javascripts/mx/mx.minimap.js | 211 ------------- public/assets/javascripts/mx/primitives/mx.box.js | 62 ---- .../javascripts/mx/primitives/mx.boxDimensions.js | 154 ---------- .../assets/javascripts/mx/primitives/mx.coords.js | 61 ---- .../assets/javascripts/mx/primitives/mx.cutout.js | 66 ---- .../assets/javascripts/mx/primitives/mx.embed.js | 66 ---- .../javascripts/mx/primitives/mx.scaleBox.js | 140 --------- .../assets/javascripts/mx/primitives/mx.tableau.js | 48 --- .../javascripts/mx/primitives/mx.texturedBox.js | 121 -------- .../assets/javascripts/mx/primitives/mx.vimeo.js | 58 ++++ .../assets/javascripts/mx/primitives/mx.youtube.js | 58 ++++ views/partials/scripts.ejs | 7 +- 19 files changed, 122 insertions(+), 1570 deletions(-) delete mode 100644 public/assets/javascripts/environments/app.js delete mode 100644 public/assets/javascripts/environments/tableaux/_empty.js delete mode 100644 public/assets/javascripts/environments/tableaux/columns.js delete mode 100644 public/assets/javascripts/environments/tableaux/columns_circle.js delete mode 100644 public/assets/javascripts/environments/tableaux/columns_split.js delete mode 100644 public/assets/javascripts/map/map.js delete mode 100644 public/assets/javascripts/map/map_editor.js delete mode 100644 public/assets/javascripts/mx/mx.minimap.js delete mode 100644 public/assets/javascripts/mx/primitives/mx.box.js delete mode 100644 public/assets/javascripts/mx/primitives/mx.boxDimensions.js delete mode 100644 public/assets/javascripts/mx/primitives/mx.coords.js delete mode 100644 public/assets/javascripts/mx/primitives/mx.cutout.js delete mode 100644 public/assets/javascripts/mx/primitives/mx.embed.js delete mode 100644 public/assets/javascripts/mx/primitives/mx.scaleBox.js delete mode 100644 public/assets/javascripts/mx/primitives/mx.tableau.js delete mode 100644 public/assets/javascripts/mx/primitives/mx.texturedBox.js create mode 100644 public/assets/javascripts/mx/primitives/mx.vimeo.js create mode 100644 public/assets/javascripts/mx/primitives/mx.youtube.js (limited to 'views/partials/scripts.ejs') diff --git a/public/assets/javascripts/environments/app.js b/public/assets/javascripts/environments/app.js deleted file mode 100644 index cdc104b..0000000 --- a/public/assets/javascripts/environments/app.js +++ /dev/null @@ -1,28 +0,0 @@ -var scrubber, fish, floor - -var environment = new function(){} -environment.init = function(){ - - scene.camera.move({ - "x": 0, - "y": 0, - "z": 0, - "rotationX": 0.085, - "rotationY": 0.025 - }) - map && map.zoom(3.00) && map.recenter() - - // - // intro floor, models, etc - -} - - -environment.update = function(t){ - - // add continuous animations and stuff here - - map && map.update() - -} - diff --git a/public/assets/javascripts/environments/tableaux/_empty.js b/public/assets/javascripts/environments/tableaux/_empty.js deleted file mode 100644 index b69fa78..0000000 --- a/public/assets/javascripts/environments/tableaux/_empty.js +++ /dev/null @@ -1,32 +0,0 @@ -/* - -MX.Tableaux.Foo = MX.Tableau.extend({ - - init: function (opt) { - - this.opt = opt = defaults(opt, { - width: 100, - height: 100, - depth: 100, - x: 0, - y: 0, - z: 0, - rotationY: 0, - rotationX: 0, - scale: 1, - }) - - }, - - animate: function() { - }, - - show: function(){ - }, - - hide: function(){ - }, - -}) - -*/ diff --git a/public/assets/javascripts/environments/tableaux/columns.js b/public/assets/javascripts/environments/tableaux/columns.js deleted file mode 100644 index e961315..0000000 --- a/public/assets/javascripts/environments/tableaux/columns.js +++ /dev/null @@ -1,36 +0,0 @@ -MX.Tableaux.Columns = MX.Tableau.extend({ - - init: function (opt) { - - this.opt = opt = defaults(opt, { - width: 10, - height: 10, - depth: 10, - x: 0, - y: 0, - z: 0, - rotationY: 0, - rotationX: 0, - scale: 1, - count: 3, - spacingX: 0, - spacingZ: 100, - }) - - for (var i = 0; i < opt.count; i++) { - var scalebox = new MX.ScaleBox({ - "width": opt.width, - "height": opt.height, - "depth": opt.depth, - "x": opt.x + opt.spacingX * i, - "y": opt.y, - "z": opt.z + opt.spacingZ * i, - "color": opt.color, - "sides": "top bottom left right front back" - }); - scene.add(scalebox) - } - - } - -}) diff --git a/public/assets/javascripts/environments/tableaux/columns_circle.js b/public/assets/javascripts/environments/tableaux/columns_circle.js deleted file mode 100644 index 1816e51..0000000 --- a/public/assets/javascripts/environments/tableaux/columns_circle.js +++ /dev/null @@ -1,42 +0,0 @@ -MX.Tableaux.ColumnsCircle = MX.Tableau.extend({ - - init: function (opt) { - - this.opt = opt = defaults(opt, { - width: 10, - height: 10, - depth: 10, - radius: 10, - theta: 0, - skip: 0, - x: 0, - y: 0, - z: 0, - rotationY: 0, - rotationX: 0, - scale: 1, - count: 3, - }) - - var scalebox, theta - var radius = opt.radius - - for (var i = opt.skip; i < opt.count; i++) { - theta = i/opt.count * TWO_PI + opt.theta - scalebox = new MX.ScaleBox({ - "width": opt.width, - "height": opt.height, - "depth": opt.depth, - "x": opt.x + sin(theta) * radius, - "y": opt.y, - "z": opt.z + cos(theta) * radius, - "rotationY": PI - theta, - "color": opt.color, - "sides": "top bottom left right front back" - }); - scene.add(scalebox) - } - - } - -}) diff --git a/public/assets/javascripts/environments/tableaux/columns_split.js b/public/assets/javascripts/environments/tableaux/columns_split.js deleted file mode 100644 index b9981d6..0000000 --- a/public/assets/javascripts/environments/tableaux/columns_split.js +++ /dev/null @@ -1,63 +0,0 @@ -MX.Tableaux.ColumnsSplit = MX.Tableau.extend({ - - init: function (opt) { - - this.opt = opt = defaults(opt, { - width: 100, - height: 100, - depth: 100, - norm: 0.5, - gap: 5, - x: 0, - y: 0, - z: 0, - rotationY: 0, - scale: 1, - count: 1, - }) - - opt.colorBottom = opt.colorBottom || opt.color - - if ( ! (opt.norm instanceof Array) ) { - opt.norm = [ opt.norm, opt.norm ] - } - - var norm, spacingX, spacingZ, scalebox - - for (var i = 0; i < opt.count; i++) { - - norm = lerp( i/(opt.count-1), opt.norm[0], opt.norm[1] ) - - spacingX = opt.spacingX * i - spacingZ = opt.spacingZ * i - - scalebox = new MX.ScaleBox({ - "width": opt.width, - "height": opt.height * norm, - "depth": opt.depth, - "x": opt.x + spacingX, - "y": opt.y + opt.gap, - "z": opt.z + spacingZ, - "color": opt.color, - "sides": "top bottom left right front back", - "rotationY": opt.rotationY, - }); - scene.add(scalebox) - - scalebox = new MX.ScaleBox({ - "width": opt.width, - "height": opt.height * (1 - norm), - "depth": opt.depth, - "x": opt.x + spacingX, - "y": opt.y - opt.height * (1 - norm) - opt.gap, - "z": opt.z + spacingZ, - "color": opt.colorBottom, - "sides": "top bottom left right front back", - "rotationY": opt.rotationY, - }); - scene.add(scalebox) - } - - } - -}) diff --git a/public/assets/javascripts/map/map.js b/public/assets/javascripts/map/map.js deleted file mode 100644 index a90963f..0000000 --- a/public/assets/javascripts/map/map.js +++ /dev/null @@ -1,337 +0,0 @@ - -MX.Map = function(){ - var base = this; - - var parent = document.querySelector("#map") - var canvas = document.createElement("canvas") - var ctx = canvas.getContext("2d") - var w, h - - var visible = parent.style.display == "block" - if (visible) resize() - - var center = {x:0,y:0} - var gridSpace; - var zoom = 3.0 - - var gridStroke = '#ddd' - var boxFill = '#fff' - var boxStroke = '#000' - var playerColor = '#888' - - var xmin, xmax, ymin, ymax, xpos, ypos, scale, side; - - var tube = base.tube = new Tube () - - this.zoom = function(n){ if (n) zoom = n; return zoom } - this.recenter = function(){ center.x = cam.x; center.y = cam.z } - - function resize(){ - var rect = parent.getBoundingClientRect() - w = canvas.width = ~~rect.width - h = canvas.height = ~~rect.height - } - - this.on = function(){ - base.tube.on.apply(base.tube, arguments) - } - this.off = function(){ - base.tube.off.apply(base.tube, arguments) - } - - this.update = function(){ - if (! visible) return; - this.draw() - } - - this.bounds = function(){ - gridSpace = pow(10, ~~(zoom-0.25) + 0.25) - side = Math.pow(10, zoom+1) - scale = w / side - xpos = center.x // -cam.x - ypos = center.y // cam.z - - xmin = side/-2 - xpos - xmax = side/2 - xpos - ymin = side/-2 - ypos - ymax = side/2 - ypos - } - - this.draw = function(){ - ctx.clearRect(0,0,w,h) - - ctx.fillStyle = "#fff" - ctx.fillRect(0,0,w,h) - this.bounds() - this.grid() - this.boxes() - this.player() - } - - this.grid = function(){ - ctx.strokeStyle = gridStroke - ctx.lineWidth = 1 - ctx.fillStyle = "transparent" - - var x0 = norm(0, xmin, xmax) - var y0 = norm(0, ymin, ymax) - - var xg = norm(gridSpace, xmin, xmax) - var yg = norm(gridSpace, ymin, ymax) - - var xgw = (xg-x0) - - var xmod = mod(x0, xgw) - var ymod = mod(y0, xgw) - - var xend = 1 + xgw - var yend = h/w + xgw - - var xline, yline; - for (var x = -xmod; x < xend; x += xgw) { - xline = x * w - line(xline, 0, xline, h) - } - for (var y = -ymod; y < yend; y += xgw) { - yline = y * w - line(0, yline, w, yline) - } - - function line(x0,y0,x1,y1) { - ctx.beginPath() - ctx.moveTo(x0, y0) - ctx.lineTo(x1, y1) - ctx.stroke() - } - } - this.player = function(){ - ctx.save() - - ctx.translate(~~(w/2),~~(h/2)); - ctx.lineWidth = 0.5 - var tx = ((-xpos) * scale), - ty = ((-ypos) * scale); - ctx.translate(tx, ty) - - var obj_scale = (1) * scale - - var tx = ~~((cam.x) * obj_scale), - ty = ~~((cam.z) * obj_scale); - ctx.translate(-tx, ty) - ctx.rotate(-cam.rotationY) - - var radius = 5 - - ctx.fillStyle = playerColor; - - ctx.beginPath(); - ctx.arc(0, 0, radius, 0, 2*Math.PI, false); - ctx.fill(); - - ctx.beginPath(); - ctx.moveTo(0,0) - ctx.lineTo(-radius,0) - ctx.lineTo(0,radius*3) - ctx.lineTo(radius,0) - ctx.moveTo(0,0) - ctx.fill() - - ctx.fillStyle = "transparent" - ctx.restore() - } - - this.boxes = function(){ - - ctx.save() - ctx.translate(~~(w/2),~~(h/2)); - ctx.lineWidth = 0.5 - var tx = ((-xpos) * scale), - ty = ((-ypos) * scale); - ctx.translate(tx, ty) - - scene.inner.children.forEach(function(obj){ - if (obj.type == "BoxDimensions" || obj.type == "ScaleBox") { - - ctx.save() - ctx.fillStyle = obj.color - ctx.strokeStyle = "#222" - - var obj_scale = (obj.scale || 1) * scale - - var tx = ~~((obj.x) * scale), - ty = ~~((obj.z) * scale); - ctx.translate(-tx, ty) - ctx.rotate(-obj.rotationY) - - var ww = ~~(obj.width/2 * obj_scale) - var hh = ~~(obj.depth/2 * obj_scale) - ctx.beginPath(); - ctx.moveTo(ww, hh) - - ctx.lineTo(ww, -hh) - ctx.lineTo(-ww, -hh) - ctx.lineTo(-ww, hh) - ctx.closePath() - ctx.fill() - ctx.stroke() - ctx.restore() - } - if (obj.type == "Image" || obj.type == "Cutout") { - ctx.save() - ctx.strokeStyle = "#444" - - var obj_scale = (obj.scale || 1) * scale - - var tx = ~~((obj.x) * scale), - ty = ~~((obj.z) * scale); - ctx.translate(-tx, ty) - ctx.rotate(-obj.rotationY) - - var ww = ~~(obj.width/2 * obj_scale) - ctx.beginPath(); - ctx.moveTo(ww, 0) - ctx.lineTo(-ww, 0) - ctx.closePath() - ctx.stroke() - ctx.restore() - } - }) - ctx.restore() - } - - - var dragging = false, mx = 0, my = 0, mdx = 0, mdy = 0, cx, cy, - creating = false, moving = false; - - function positionFromMouse(e) { - var rect = canvas.getBoundingClientRect() - cx = center.x - cy = center.y - mx = e.pageX - rect.left - my = e.pageY - rect.top - mdx = (mx - w/2) / scale + cx - mdy = (my - h/2) / scale + cy - } - - canvas.addEventListener("mousedown", function(e){ - e.stopPropagation() - dragging = true - - positionFromMouse(e) - - if (e.shiftKey) { - creating = true - } - - hud.update( mdx, mdy ) - - base.tube("mousedown", e, -mdx, mdy) - }) - document.addEventListener("mousemove", function(e){ - if (dragging) { - e.stopPropagation() - - var rect = canvas.getBoundingClientRect() - var mnx = e.pageX - rect.left - var mny = e.pageY - rect.top - - mdx = (mnx - mx) / scale - mdy = (mny - my) / scale - - if (creating) { - hud.update( mdx, mdy ) - } - else if (moving) { - cam.x = cx - mdx - cam.z = cy + mdy - } - else { - center.x = cx - mdx - center.y = cy - mdy - hud.update(center.x, center.y) - } - - base.tube("mousedrag", e, -mdx, mdy) - } - else { - positionFromMouse(e) - hud.update( mdx, mdy ) - base.tube("mousemove", e, -mdx, mdy) - } - }) - document.addEventListener("mouseup", function(e){ - creating = dragging = moving = false; - base.tube("mouseup", e) - }) - - canvas.addEventListener("contextmenu", function(e){ - e.preventDefault() - e.stopPropagation() - dragging = true - - positionFromMouse(e) - - moving = true - cx = cam.x = -mdx - cy = cam.z = mdy - - hud.update( mdx, mdy ) - - base.tube("contextmenu", e) - }) - - canvas.addEventListener( 'mousewheel', onDocumentMouseWheel, false ); - canvas.addEventListener( 'DOMMouseScroll', onDocumentMouseWheel, false); - function onDocumentMouseWheel (e) { - e.preventDefault() - e.stopPropagation() - var delta = 0 - - // WebKit - if ( event.wheelDeltaY ) { - delta = - event.wheelDeltaY * 0.0003; - } - // Opera / Explorer 9 - else if ( event.wheelDelta ) { - delta = - event.wheelDelta * 0.0003; - } - // Firefox - else if ( event.detail ) { - delta = event.detail * 0.01; - } - - if (! e.shiftKey) { - zoom += delta - } - - positionFromMouse(e) - base.tube("mousewheel", e, mdx, mdy, delta) - - map.update() - } - - window.addEventListener('resize', resize) - - this.toggle = function(){ - (visible = ! visible) ? base.show() : base.hide() - } - this.show = function(){ - parent.style.display = "block" - resize() - } - this.hide = function(){ - parent.style.display = "none" - } - - var hud = new function(){ - var el = document.querySelector("#map .hud") - this.update = function(){ - el.innerHTML = Array.prototype.slice.call(arguments,0).map(function(s){ return typeof s == "number" ? Math.round(s) : s }).join(" ") - } - } - hud.update() - - this.update() - document.querySelector("#map .el").appendChild(canvas) -} - diff --git a/public/assets/javascripts/map/map_editor.js b/public/assets/javascripts/map/map_editor.js deleted file mode 100644 index 754172b..0000000 --- a/public/assets/javascripts/map/map_editor.js +++ /dev/null @@ -1,102 +0,0 @@ -var editor = new function (){ - - var base = this; - - var cube = null - var cx, cy - - base.init = function(){ - map.on("mousedown", base.mousedown) - map.on("mousemove", base.mousemove) - map.on("mousedrag", base.mousedrag) - map.on("mouseup", base.mouseup) - map.on("mousewheel", base.mousewheel) - document.getElementById("export").addEventListener("keydown", base.stopPropagation) - document.getElementById("export").addEventListener("mousedown", base.stopPropagation) - document.getElementById("export").addEventListener("mousemove", base.stopPropagation) - document.getElementById("export").addEventListener("mouseup", base.stopPropagation) - window.addEventListener('keydown', base.keydown) - } - - base.mousedown = function(e,x,y) { - if (! e.shiftKey) return - cx = x - cy = y - cube = new MX.BoxDimensions({ - x: cx, - y: -10, - z: cy, - width: 1, - height: 1, - depth: 1, - borderWidth: 1, - borderColor: "#000", - color: "#fff" - }) - cube.persisted = false - scene.add( cube ); - } - - base.mousemove = function(e,x,y) { - } - - base.mousedrag = function(e,dx,dy) { - if (! cube) return - cube.x = cx + dx/2 - cube.z = cy + dy/2 - cube.setWidth( abs(dx) ) - cube.setDepth( abs(dy) ) - cube.setHeight( max( cube.width, cube.depth ) ) - cube.update() - } - - base.mouseup = function(e){ - cube = null - } - - base.mousewheel = function(e,x,z,delta){ - if (! e.shiftKey) return; - - scene.inner.children.some(function(s){ - if (s.contains(-x, null, z)) { - s.y += delta * 1000 - s.persisted = false - console.log(s.id) - return true - } - return false - }) - - } - - base.stopPropagation = function(e){ e.stopPropagation() } - - base.exportObjects = function(){ - var s = scene.inner.children - .filter(function(s){ return ! s.persisted }) - .map(function(s){ return s.toString() }) - .join("\n\n") - document.getElementById("export").value = s - } - - base.exportCamera = function(){ - var s = scene.camera.toString() - document.getElementById("export").value = s - console.log(s) - } - - base.keydown = function(e){ - switch (e.keyCode) { - - case 67: // c - base.exportCamera() - break; - - case 86: // v - base.exportObjects() - break; - - } - } - -} diff --git a/public/assets/javascripts/mx/mx.minimap.js b/public/assets/javascripts/mx/mx.minimap.js deleted file mode 100644 index 252305c..0000000 --- a/public/assets/javascripts/mx/mx.minimap.js +++ /dev/null @@ -1,211 +0,0 @@ -MX.Minimap = function () { - var canvas = document.createElement("canvas") - var ctx = canvas.getContext("2d") - var w = canvas.width = 200 - var h = canvas.height = 200 - - var gridSpace; - var zoom = 2.7 - - var gridStroke = '#ddd' - var boxFill = '#fff' - var boxStroke = '#000' - var playerColor = '#888' - - var xmin, xmax, ymin, ymax, xpos, ypos, scale, side; - - this.update = function(){ - this.draw() - } - - this.bounds = function(){ - gridSpace = Math.pow(10, ~~(zoom-0.5)+0.5) - side = Math.pow(10, zoom+1) - scale = w / side - xpos = -cam.x - ypos = cam.z - - xmin = side/-2 - xpos - xmax = side/2 - xpos - ymin = side/-2 - ypos - ymax = side/2 - ypos - } - - this.draw = function(){ - ctx.clearRect(0,0,w,h) - - ctx.fillStyle = "#fff" - ctx.fillRect(0,0,w,h) - this.bounds() - this.grid() - this.boxes() - this.player() - } - - this.grid = function(){ - ctx.strokeStyle = gridStroke - ctx.lineWidth = 1 - ctx.fillStyle = "transparent" - - var xmod = xmin-(xmin % gridSpace) - var ymod = ymin-(ymin % gridSpace) - - for (var x = xmin; x < xmax+gridSpace; x += gridSpace) { - var xline = (x-xmod) * scale - line(xline, 0, xline, h) - } - for (var y = ymin; y < ymax+gridSpace; y += gridSpace) { - var yline = (y-ymod) * scale - line(0, yline, w, yline) - } - - function line(x0,y0,x1,y1) { - ctx.beginPath() - ctx.moveTo(x0, y0) - ctx.lineTo(x1, y1) - ctx.stroke() - } - } - this.player = function(){ - ctx.save() - - ctx.translate(~~(w/2),~~(h/2)); - ctx.rotate(-cam.rotationY) - - var radius = 5 - - ctx.fillStyle = playerColor; - - ctx.beginPath(); - ctx.arc(0, 0, radius, 0, 2*Math.PI, false); - ctx.fill(); - - ctx.beginPath(); - ctx.moveTo(0,0) - ctx.lineTo(-radius,0) - ctx.lineTo(0,radius*3) - ctx.lineTo(radius,0) - ctx.moveTo(0,0) - ctx.fill() - - ctx.fillStyle = "transparent" - ctx.restore() - } - - this.boxes = function(){ - - ctx.save() - ctx.translate(~~(w/2),~~(h/2)); - ctx.lineWidth = 0.5 - var tx = ((-xpos) * scale), - ty = ((-ypos) * scale); - ctx.translate(tx, ty) - - scene.inner.children.forEach(function(obj){ - if (obj.type == "BoxDimensions") { - - ctx.save() - ctx.fillStyle = obj.color - ctx.strokeStyle = obj.borderColor - - var obj_scale = (obj.scale || 1) * scale - - var tx = ~~((obj.x) * obj_scale), - ty = ~~((obj.z) * obj_scale); - ctx.translate(-tx, ty) - ctx.rotate(-obj.rotationY) - - var ww = ~~(obj.width/2 * obj_scale) - var hh = ~~(obj.depth/2 * obj_scale) - ctx.beginPath(); - ctx.moveTo(ww, hh) - - ctx.lineTo(ww, -hh) - ctx.lineTo(-ww, -hh) - ctx.lineTo(-ww, hh) - ctx.closePath() - ctx.fill() - ctx.stroke() - ctx.restore() - } - if (obj.type == "Image") { - - ctx.save() - ctx.strokeStyle = "#444" - - var obj_scale = (obj.scale || 1) * scale - - var tx = ~~((obj.x) * obj_scale), - ty = ~~((obj.z) * obj_scale); - ctx.translate(-tx, ty) - ctx.rotate(-obj.rotationY) - - var ww = ~~(obj.width/2 * obj_scale) - ctx.beginPath(); - ctx.moveTo(ww, 0) - ctx.lineTo(-ww, 0) - ctx.closePath() - ctx.stroke() - ctx.restore() - } - }) - ctx.restore() - } - - var dragging = false, mx = 0, my = 0, mdx = 0, mdy = 0, cx, cy; - canvas.addEventListener("mousedown", function(e){ - e.stopPropagation() - var rect = canvas.getBoundingClientRect() - dragging = true; - mx = e.pageX - rect.left - my = e.pageY - rect.top - mdx = (mx - w/2) / scale - mdy = (my - h/2) / scale - cx = cam.x // -= mdx - cy = cam.z // += mdy - - minimap.update() - }) - document.addEventListener("mousemove", function(e){ - if (dragging) { - e.stopPropagation() - var rect = canvas.getBoundingClientRect() - var mnx = e.pageX - rect.left - var mny = e.pageY - rect.top - mdx = (mnx - mx) / scale - mdy = (mny - my) / scale - - cam.x = cx + mdx - cam.z = cy - mdy - minimap.update() - } - }) - document.addEventListener("mouseup", function(e){ - dragging = false; - }) - - canvas.addEventListener( 'mousewheel', onDocumentMouseWheel, false ); - canvas.addEventListener( 'DOMMouseScroll', onDocumentMouseWheel, false); - function onDocumentMouseWheel (e) { - e.preventDefault() - e.stopPropagation() - // WebKit - if ( event.wheelDeltaY ) { - zoom -= event.wheelDeltaY * 0.0003; - } - // Opera / Explorer 9 - else if ( event.wheelDelta ) { - zoom -= event.wheelDelta * 0.0003; - } - // Firefox - else if ( event.detail ) { - zoom += event.detail * 0.01; - } - minimap.update() - } - - this.draw() - document.querySelector("#minimap .el").appendChild(canvas) - - return this; -} \ No newline at end of file diff --git a/public/assets/javascripts/mx/primitives/mx.box.js b/public/assets/javascripts/mx/primitives/mx.box.js deleted file mode 100644 index dfe3f5e..0000000 --- a/public/assets/javascripts/mx/primitives/mx.box.js +++ /dev/null @@ -1,62 +0,0 @@ -MX.Box = MX.Object3D.extend({ - - // this will be called within the contructor - init: function (size, color, borderColor) { - - this.type = "Box" - - size = size || 100 - color = color || 'rgba(0, 255, 122, .1)' - borderColor = borderColor || '#0f3' - - // an Object3D's associated DOM node is the "el" property - this.el.classList.add('box') - - var angle = MX.rotationUnit === 'deg' ? 90 : (Math.PI / 2) - - var top = this.top = new MX.Object3D('.face') - top.rotationX = angle - top.y = size / 2 - - var bottom = this.bottom = new MX.Object3D('.face') - bottom.rotationX = -angle - bottom.y = -size / 2 - - var left = this.left = new MX.Object3D('.face') - left.rotationY = -angle - left.x = -size / 2 - - var right = this.right = new MX.Object3D('.face') - right.rotationY = angle - right.x = size / 2 - - var front = this.front = new MX.Object3D('.face') - front.z = -size / 2 - - var back = this.back = new MX.Object3D('.face') - back.rotationY = angle * 2 - back.z = size / 2 - - // adding children, must also be instances of Object3D - this.add(top, bottom, left, right, front, back) - - this.children.forEach(function (face) { - face.width = size - 2 - face.height = size - 2 - face.el.style.backgroundColor = color - face.el.style.border = '1px solid ' + borderColor - }) - - // this applies the updated CSS style - // required for any change to take effect - // when a parent object's update() is called - // all its children will be updated as well - this.update() - - // if this object's children won't move by themselves - this.updateChildren = false - } - - // other properties will be mixed into the prototype of the new constructor - -}) \ No newline at end of file diff --git a/public/assets/javascripts/mx/primitives/mx.boxDimensions.js b/public/assets/javascripts/mx/primitives/mx.boxDimensions.js deleted file mode 100644 index 1d457ae..0000000 --- a/public/assets/javascripts/mx/primitives/mx.boxDimensions.js +++ /dev/null @@ -1,154 +0,0 @@ -MX.BoxDimensions = MX.Object3D.extend({ - - // this will be called within the contructor - init: function (opt) { - - var base = this - - this.type = "BoxDimensions" - - var id = this.id = opt.id || _.uniqueId() - this.x = opt.x || 0 - this.y = opt.y || 0 - this.z = opt.z || 0 - // this.scale = opt.scale || 1 - var scale = opt.scale || 1 - this.rotationX = opt.rotationX || 0 - this.rotationY = opt.rotationY || 0 - this.rotationZ = opt.rotationZ || 0 - var width = this.width = opt.width || 100 - var height = this.height = opt.height || 100 - var depth = this.depth = opt.depth || 100 - var color = this.color = opt.color || 'rgba(0, 255, 122, .1)' - var backgroundImage = this.backgroundImage = opt.backgroundImage; - var borderColor = this.borderColor = opt.borderColor || '#0f3' - var borderWidth = this.borderWidth = typeof opt.borderWidth !== 'undefined' ? opt.borderWidth : 3; - var borderRadius = this.borderRadius = typeof opt.borderRadius !== 'undefined' ? opt.borderRadius : undefined; - var sides = this.sides = opt.sides || "top bottom left right front back" - var className = this.className = opt.className || null - - // an Object3D's associated DOM node is the "el" property - this.el.classList.add('box') - - var angle = MX.rotationUnit === 'deg' ? 90 : (Math.PI / 2) - - this.top = this.bottom = this.left = this.right = this.front = this.back = null - if (-1 != sides.indexOf("top")) { - var top = this.top = new MX.Object3D('.face.top') - top.rotationX = angle - top.width = width - top.height = depth - top.y = height * scale - top.scale = scale - this.add(top) - } - if (-1 != sides.indexOf("bottom")) { - var bottom = this.bottom = new MX.Object3D('.face.bottom') - bottom.rotationX = -angle - bottom.width = width - bottom.height = depth - bottom.y = 0 - bottom.scale = scale - this.add(bottom) - } - if (-1 != sides.indexOf("left")) { - var left = this.left = new MX.Object3D('.face.left') - left.rotationY = -angle - left.width = depth - left.height = height - left.x = -width/2 * scale - left.y = height/2 * scale - left.scale = scale - this.add(left) - } - if (-1 != sides.indexOf("right")) { - var right = this.right = new MX.Object3D('.face.right') - right.rotationY = angle - right.width = depth - right.height = height - right.x = width/2 * scale - right.y = height/2 * scale - right.scale = scale - this.add(right) - } - if (-1 != sides.indexOf("front")) { - var front = this.front = new MX.Object3D('.face.front') - front.width = width - front.height = height - front.z = -depth/2 * scale - front.y = height/2 * scale - front.scale = scale - this.add(front) - } - if (-1 != sides.indexOf("back")) { - var back = this.back = new MX.Object3D('.face.back') - back.width = width - back.height = height - back.rotationY = angle * 2 - back.z = depth/2 * scale - back.y = height/2 * scale - back.scale = scale - this.add(back) - } - - this.children.forEach(function (face) { - if (borderRadius) { - face.el.style.borderRadius = borderRadius + "px" - } - if (className) { - face.el.classList.add(className) - } - else { - if (backgroundImage) { - face.el.style.backgroundImage = "url(" + backgroundImage + ")" - } - else if (color) { - face.el.style.backgroundColor = color - } - if (borderWidth) { - face.el.style.border = borderWidth + 'px solid ' + borderColor - } - } - }) - - // bottom.el.style.border = "0" - - // this applies the updated CSS style - // required for any change to take effect - // when a parent object's update() is called - // all its children will be updated as well - this.update() - - // if this object's children won't move by themselves - this.updateChildren = true - - this.setWidth = function(w){ - base.width = top.width = bottom.width = front.width = back.width = w - left.x = -w/2 - right.x = w/2 - base.dirty = true - } - this.setHeight = function(h){ - base.height = left.height = right.height = front.height = back.height = h - bottom.y = 0 - left.y = right.y = front.y = back.y = h/2 - top.y = h - base.dirty = true - } - this.setDepth = function(d){ - base.depth = top.height = bottom.height = left.width = right.width = d - front.z = -d/2 - back.z = d/2 - base.dirty = true - } - - }, - - toString: function(){ - var params = "id width height depth x y z rotationX rotationY scale color borderColor borderWidth backgroundImage borderRadius sides".split(" ") - return this.__toString(params) - }, - - // other properties will be mixed into the prototype of the new constructor - -}) \ No newline at end of file diff --git a/public/assets/javascripts/mx/primitives/mx.coords.js b/public/assets/javascripts/mx/primitives/mx.coords.js deleted file mode 100644 index 80b148c..0000000 --- a/public/assets/javascripts/mx/primitives/mx.coords.js +++ /dev/null @@ -1,61 +0,0 @@ -MX.Coords = (function () { - - var colors = { - x: '#f33', - y: '#3f3', - z: '#66f' - } - - var Axis = MX.Object3D.extend({ - init: function (axis, size) { - - var label = document.createElement('span') - label.textContent = axis.toUpperCase() - label.style.position = 'absolute' - label.style.right = '0px' - label.style.bottom = '3px' - label.style.fontSize = Math.round(size / 10) + 'px' - this.el.appendChild(label) - - var faceA = new MX.Object3D(), - faceB = new MX.Object3D() - faceA.rotationX = 90 - this.add(faceA, faceB) - - this.el.style.color = - faceA.el.style.backgroundColor = - faceB.el.style.backgroundColor = colors[axis] - - this.width = - faceA.width = - faceB.width = size - - this.height = - faceA.height = - faceB.height = Math.round(size / 100) - - var angle = MX.rotationUnit === 'deg' ? 90 : (Math.PI / 2) - - if (axis === 'y') { - this.rotationZ = -angle - } else if (axis === 'z') { - this.rotationY = angle - } - } - }) - - var Coords = MX.Object3D.extend({ - init: function (size) { - size = size || 100 - var x = new Axis('x', size), - y = new Axis('y', size), - z = new Axis('z', size) - this.add(x, y, z) - this.update() - this.updateChildren = false - } - }) - - return Coords - -})() \ No newline at end of file diff --git a/public/assets/javascripts/mx/primitives/mx.cutout.js b/public/assets/javascripts/mx/primitives/mx.cutout.js deleted file mode 100644 index 9d9043f..0000000 --- a/public/assets/javascripts/mx/primitives/mx.cutout.js +++ /dev/null @@ -1,66 +0,0 @@ -MX.Cutout = MX.Object3D.extend({ - init: function (ops) { - - this.type = "Cutout" - - var layer = this - layer.width = 0 - layer.height = 0 - - if (ops.src) this.loadTexture(ops) - - if (ops.texture) { - } - else if (ops.classname) { - layer.el.classList.add(ops.classname) - } - else { - } - layer.el.style.backgroundRepeat = 'no-repeat' - - this.dirty = true - this.updateChildren = true - this.update() - }, - - loadTexture: function(ops){ - var layer = this - var image = new Image() - var pattern = ops.pattern - var texture = ops.texture - - image.onload = function(){ - var canvas = document.createElement("canvas") - var ctx = canvas.getContext('2d') - - layer.width = canvas.width = image.naturalWidth - layer.height = canvas.height = image.naturalHeight - - ctx.drawImage(image, 0, 0, canvas.width, canvas.height) - ctx.globalCompositeOperation = "source-in" - - if (texture) { - ctx.fillStyle = ctx.createPattern(texture, 'repeat') - ctx.fillRect(0, 0, canvas.width, canvas.height) - } - if (pattern) { - ctx.fillStyle = ctx.createPattern(pattern, 'repeat') - ctx.fillRect(0, 0, canvas.width, canvas.height) - } - - layer.scale = ops.scale || 1 - layer.x = ops.x || 0 - layer.y = (ops.y || 0) + layer.height/2 + 1 - layer.z = ops.z || 0 - layer.rotationX = ops.rotationX || 0 - layer.rotationY = ops.rotationY || 0 - layer.el.appendChild(canvas) - - layer.el.classList.add('image') - ops.className && layer.el.classList.add(ops.className) - layer.dirty = true - layer.update() - } - image.src = ops.src; - } -}) diff --git a/public/assets/javascripts/mx/primitives/mx.embed.js b/public/assets/javascripts/mx/primitives/mx.embed.js deleted file mode 100644 index f15ec98..0000000 --- a/public/assets/javascripts/mx/primitives/mx.embed.js +++ /dev/null @@ -1,66 +0,0 @@ -MX.Embed = MX.Object3D.extend({ - - init: function (ops) { - - this.type = "Embed" - - var layer = this - layer.media = ops.media - layer.width = ops.media.width - layer.height = ops.media.height - layer.x = ops.x || 0 - layer.y = ops.y || 0 - layer.z = ops.z || 0 - layer.scale = ops.scale || 1 - layer.backface = ops.backface || false - - if (layer.backface) { - layer.el.classList.add("backface-visible") - } - - if (ops.src) { - this.loadEmbed(ops) - } - - if (ops.className) { - layer.el.classList.add(ops.className) - } - layer.el.style.backgroundRepeat = 'no-repeat' - - }, - - loadEmbed: function(ops){ - var layer = this - layer.ops = defaults(ops, layer.ops) - -// layer.scale = layer.ops.scale || 1 -// layer.width = layer.ops.width || image.naturalWidth -// layer.height = layer.ops.height || image.naturalHeight -// layer.x = layer.ops.x || 0 -// layer.y = layer.ops.y || 0 -// layer.z = layer.ops.z || 0 -// layer.rotationX = layer.ops.rotationX || 0 -// layer.rotationY = layer.ops.rotationY || 0 -// layer.rotationZ = layer.ops.rotationZ || 0 -// layer.el.style.backgroundImage = "url(" + image.src + ")" -// layer.el.classList.add('image') -// layer.dirty = true -// layer.update() - }, - - move: function(ops){ - var layer = this - layer.ops = defaults(ops, layer.ops) - for (var i in ops) { - layer[i] = ops[i] - } - layer.dirty = true - layer.update() - }, - - toString: function(){ - var params = "id src width height depth x y z rotationX rotationY rotationZ scale".split(" ") - return this.__toString(params) - }, - -}) diff --git a/public/assets/javascripts/mx/primitives/mx.scaleBox.js b/public/assets/javascripts/mx/primitives/mx.scaleBox.js deleted file mode 100644 index f635345..0000000 --- a/public/assets/javascripts/mx/primitives/mx.scaleBox.js +++ /dev/null @@ -1,140 +0,0 @@ -MX.ScaleBox = MX.Object3D.extend({ - - // this will be called within the contructor - init: function (opt) { - - var base = this - - this.type = "ScaleBox" - - var id = this.id = opt.id || _.uniqueId() - this.x = opt.x || 0 - this.y = opt.y || 0 - this.z = opt.z || 0 - this.rotationX = opt.rotationX || 0 - this.rotationY = opt.rotationY || 0 - this.rotationZ = opt.rotationZ || 0 - var scale = this.scale = opt.scale || 1 - var width = this.width = scale * (opt.width || 100) - var height = this.height = scale * (opt.height || 100) - var depth = this.depth = scale * (opt.depth || 100) - var color = this.color = opt.color || 'rgba(0, 255, 122, .1)' - var sides = this.sides = opt.sides || "top bottom left right front back" - - // an Object3D's associated DOM node is the "el" property - this.el.classList.add('box') - - var angle = MX.rotationUnit === 'deg' ? 90 : (Math.PI / 2) - - var top = this.top = new MX.Object3D('.face.top') - top.rotationX = angle - top.width = 1 - top.height = 1 - top.scaleX = width - top.scaleY = 1 - top.scaleZ = depth - top.y = height - - var bottom = this.bottom = new MX.Object3D('.face.bottom') - bottom.rotationX = -angle - bottom.width = 1 - bottom.height = 1 - bottom.scaleX = width - bottom.scaleY = 1 - bottom.scaleZ = depth - bottom.y = 0 - - var left = this.left = new MX.Object3D('.face.left') - left.rotationY = -angle - left.width = 1 - left.height = 1 - left.scaleX = 1 - left.scaleY = height - left.scaleZ = depth - left.x = -width/2 - left.y = height/2 - - var right = this.right = new MX.Object3D('.face.right') - right.rotationY = angle - right.width = 1 - right.height = 1 - right.scaleX = 1 - right.scaleY = height - right.scaleZ = depth - right.x = width/2 - right.y = height/2 - - var front = this.front = new MX.Object3D('.face.front') - front.width = 1 - front.height = 1 - front.scaleX = width - front.scaleY = height - front.scaleZ = 1 - front.z = -depth/2 - front.y = height/2 - - var back = this.back = new MX.Object3D('.face.back') - back.width = 1 - back.height = 1 - back.scaleX = width - back.scaleY = height - back.scaleZ = 1 - back.rotationY = angle * 2 - back.z = depth/2 - back.y = height/2 - - // adding children, must also be instances of Object3D - if (-1 != sides.indexOf("top")) this.add(top) - if (-1 != sides.indexOf("bottom")) this.add(bottom) - if (-1 != sides.indexOf("left")) this.add(left) - if (-1 != sides.indexOf("right")) this.add(right) - if (-1 != sides.indexOf("front")) this.add(front) - if (-1 != sides.indexOf("back")) this.add(back) - - this.children.forEach(function (face) { - face.el.style.backgroundColor = color - }) - - // this applies the updated CSS style - // required for any change to take effect - // when a parent object's update() is called - // all its children will be updated as well - this.update() - - // if this object's children won't move by themselves - this.updateChildren = true - - this.setWidth = function(w){ - base.width = top.width = bottom.width = front.width = back.width = w - left.x = -w/2 - right.x = w/2 - base.dirty = true - } - this.setHeight = function(h){ - base.height = left.height = right.height = front.height = back.height = h - bottom.y = 0 - left.y = right.y = front.y = back.y = h/2 - top.y = h - base.dirty = true - } - this.setDepth = function(d){ - base.depth = top.height = bottom.height = left.width = right.width = d - front.z = -d/2 - back.z = d/2 - base.dirty = true - } - - }, - - toString: function(){ - var params = "id width height depth x y z rotationX rotationY color sides".split(" ") - return this.__toString(params) - }, - - clone: function(){ - return new MX[this.type] (this) - } - - // other properties will be mixed into the prototype of the new constructor - -}) diff --git a/public/assets/javascripts/mx/primitives/mx.tableau.js b/public/assets/javascripts/mx/primitives/mx.tableau.js deleted file mode 100644 index 514e206..0000000 --- a/public/assets/javascripts/mx/primitives/mx.tableau.js +++ /dev/null @@ -1,48 +0,0 @@ - - -var Tableau = function(){ - this.extend = extend.bind(Tableau) - - function extend (props) { - var Super = this - var ExtendedTableau = function () { - Super.call(this) - props.init && props.init.apply(this, arguments) - } - ExtendedTableau.prototype = Object.create(Tableau.prototype) - for (var prop in props) { - if (props.hasOwnProperty(prop) && prop !== 'init') { - ExtendedTableau.prototype[prop] = props[prop] - } - } - ExtendedTableau.extend = extend.bind(ExtendedTableau) - return ExtendedTableau - } -} - -Tableau.prototype.init = function(opt){} -Tableau.prototype.animate = function(t){} -Tableau.prototype.show = function(){} -Tableau.prototype.hide = function(){} - -MX.Tableau = new Tableau() -MX.Tableaux = {} - -/* - -MX.Tableaux.Foo = MX.Tableau.extend({ - // this will be called within the contructor - init: function (opt) { - }, - - show: function(){ - }, - - hide: function(){ - }, - - animate: function() { - } -}) - -*/ diff --git a/public/assets/javascripts/mx/primitives/mx.texturedBox.js b/public/assets/javascripts/mx/primitives/mx.texturedBox.js deleted file mode 100644 index daec2d8..0000000 --- a/public/assets/javascripts/mx/primitives/mx.texturedBox.js +++ /dev/null @@ -1,121 +0,0 @@ -// Creates a box using a given texture image. -// Uses a texture image like this: -// -// ---------- ---------- -// | | | -// | top | bottom | -// | | | -// ---------- ---------- ---------- ---------- -// | | | | | -// | left | front | right | back | -// | | | | | -// ---------- ---------- ---------- ---------- -// -// See `examples/images/skins/` for some minecraft skin examples. - -// Options: -// -// - {number} `width` -// - {number} `height` -// - {number} `depth` -// - {string} `texture` path to texture image -// - {string} `classname` class to be added to dom element - -MX.TexturedBox = MX.Object3D.extend({ - - init: function (ops) { - - this.type = "TexturedBox" - - if (!ops.width || !ops.height || !ops.depth || (!ops.texture && !ops.classname)) { - console.warn('TextureBox: missing arguments') - return - } - - // faces - var angle = MX.rotationUnit === 'deg' ? 90 : (Math.PI / 2), - offsetX = ops.offset ? (ops.offset.x || 0) : 0, - offsetY = ops.offset ? (ops.offset.y || 0) : 0, - overlap = ops.overlap ? ops.overlap : 0 - var multiTexture = typeof ops.texture == "object"; - - var top = this.top = new MX.Object3D() - top.width = ops.width - top.height = ops.depth - top.rotationX = angle - top.y = ops.height / 2 - overlap - if (!multiTexture) - top.el.style.backgroundPosition = - (-(offsetX + ops.depth) + 'px ') + - (-offsetY + 'px') - - var bottom = this.bottom = new MX.Object3D() - bottom.width = ops.width - bottom.height = ops.depth - bottom.rotationX = -angle - bottom.y = -ops.height / 2 + overlap - if (!multiTexture) - bottom.el.style.backgroundPosition = - (-(offsetX + ops.depth + ops.width) + 'px ') + - (-offsetY + 'px') - - var left = this.left = new MX.Object3D() - left.width = ops.depth - left.height = ops.height - left.rotationY = -angle - left.x = -ops.width / 2 + overlap - if (!multiTexture) - left.el.style.backgroundPosition = - (-offsetX + 'px ') + - (-(offsetY + ops.depth) + 'px') - - var right = this.right = new MX.Object3D() - right.width = ops.depth - right.height = ops.height - right.rotationY = angle - right.x = ops.width / 2 - overlap - if (!multiTexture) - right.el.style.backgroundPosition = - (-(offsetX + ops.depth + ops.width) + 'px ') + - (-(offsetY + ops.depth) + 'px') - - var front = this.front = new MX.Object3D() - front.width = ops.width - front.height = ops.height - front.z = -ops.depth / 2 + overlap - if (!multiTexture) - front.el.style.backgroundPosition = - (-(offsetX + ops.depth) + 'px ') + - (-(offsetY + ops.depth) + 'px') - - var back = this.back = new MX.Object3D() - back.width = ops.width - back.height = ops.height - back.rotationY = angle * 2 - back.z = ops.depth / 2 - overlap - if (!multiTexture) - back.el.style.backgroundPosition = - (-(offsetX + ops.depth * 2 + ops.width) + 'px ') + - (-(offsetY + ops.depth) + 'px') - - this.add(top, bottom, left, right, front, back) - - this.children.forEach(function (c,i) { - if (multiTexture) { - c.el.style.backgroundImage = 'url(' + ops.texture[i] + ')' - } - else if (ops.texture) { - c.el.style.backgroundImage = 'url(' + ops.texture + ')' - } - if (ops.classname) { - c.el.classList.add(ops.classname) - } - c.el.style.backgroundRepeat = 'no-repeat' - }) - - this.update() - this.updateChildren = false - - } - -}) diff --git a/public/assets/javascripts/mx/primitives/mx.vimeo.js b/public/assets/javascripts/mx/primitives/mx.vimeo.js new file mode 100644 index 0000000..b65f35a --- /dev/null +++ b/public/assets/javascripts/mx/primitives/mx.vimeo.js @@ -0,0 +1,58 @@ +MX.Vimeo = MX.Object3D.extend({ + + init: function (ops) { + + this.type = "Vimeo" + + var layer = this + layer.media = ops.media + layer.width = ops.media.width + layer.height = ops.media.height + layer.x = ops.x || 0 + layer.y = ops.y || 0 + layer.z = ops.z || 0 + layer.rotationX = layer.ops.rotationX || 0 + layer.rotationY = layer.ops.rotationY || 0 + layer.rotationZ = layer.ops.rotationZ || 0 + layer.scale = ops.scale || 1 + layer.backface = ops.backface || false + + if (layer.backface) { + layer.el.classList.add("backface-visible") + } + + if (ops.src) { + this.loadEmbed(ops) + } + + if (ops.className) { + layer.el.classList.add(ops.className) + } + layer.el.style.backgroundRepeat = 'no-repeat' + + }, + + loadEmbed: function(ops){ + var layer = this + }, + + move: function(ops){ + var layer = this + layer.ops = defaults(ops, layer.ops) + for (var i in ops) { + layer[i] = ops[i] + } + layer.dirty = true + layer.update() + }, + + toString: function(){ + var params = "id src width height depth x y z rotationX rotationY rotationZ scale".split(" ") + return this.__toString(params) + }, + +}) + +window.onYouTubePlayerAPIReady = function(){ + console.log("youtube ready") +} diff --git a/public/assets/javascripts/mx/primitives/mx.youtube.js b/public/assets/javascripts/mx/primitives/mx.youtube.js new file mode 100644 index 0000000..068ef9f --- /dev/null +++ b/public/assets/javascripts/mx/primitives/mx.youtube.js @@ -0,0 +1,58 @@ +MX.Youtube = MX.Object3D.extend({ + + init: function (ops) { + + this.type = "Youtube" + + var layer = this + layer.media = ops.media + layer.width = ops.media.width + layer.height = ops.media.height + layer.x = ops.x || 0 + layer.y = ops.y || 0 + layer.z = ops.z || 0 + layer.rotationX = layer.ops.rotationX || 0 + layer.rotationY = layer.ops.rotationY || 0 + layer.rotationZ = layer.ops.rotationZ || 0 + layer.scale = ops.scale || 1 + layer.backface = ops.backface || false + + if (layer.backface) { + layer.el.classList.add("backface-visible") + } + + if (ops.src) { + this.loadEmbed(ops) + } + + if (ops.className) { + layer.el.classList.add(ops.className) + } + layer.el.style.backgroundRepeat = 'no-repeat' + + }, + + loadEmbed: function(ops){ + var layer = this + }, + + move: function(ops){ + var layer = this + layer.ops = defaults(ops, layer.ops) + for (var i in ops) { + layer[i] = ops[i] + } + layer.dirty = true + layer.update() + }, + + toString: function(){ + var params = "id src width height depth x y z rotationX rotationY rotationZ scale".split(" ") + return this.__toString(params) + }, + +}) + +window.onYouTubePlayerAPIReady = function(){ + console.log("youtube ready") +} diff --git a/views/partials/scripts.ejs b/views/partials/scripts.ejs index 6a50c04..6799aa7 100644 --- a/views/partials/scripts.ejs +++ b/views/partials/scripts.ejs @@ -49,7 +49,8 @@ - + + @@ -84,3 +85,7 @@ + + + + \ No newline at end of file -- cgit v1.2.3-70-g09d2 From f0dbdee5e68f3ebd66f7b27afc88fa44100bf924 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 24 Jun 2014 17:49:42 -0400 Subject: starting to add youtubes --- public/assets/javascripts/app.js | 2 +- public/assets/javascripts/mx/mx.js | 10 +++ public/assets/javascripts/mx/primitives/mx.face.js | 41 --------- .../assets/javascripts/mx/primitives/mx.image.js | 50 ++++------- public/assets/javascripts/mx/primitives/mx.text.js | 2 + .../assets/javascripts/mx/primitives/mx.video.js | 15 +--- .../assets/javascripts/mx/primitives/mx.vimeo.js | 21 +---- .../assets/javascripts/mx/primitives/mx.youtube.js | 96 +++++++++++++--------- views/partials/scripts.ejs | 2 + 9 files changed, 89 insertions(+), 150 deletions(-) delete mode 100644 public/assets/javascripts/mx/primitives/mx.face.js (limited to 'views/partials/scripts.ejs') diff --git a/public/assets/javascripts/app.js b/public/assets/javascripts/app.js index 3d0d3c4..0b441c7 100644 --- a/public/assets/javascripts/app.js +++ b/public/assets/javascripts/app.js @@ -17,7 +17,7 @@ else { var scene, cam, map; -var viewHeight = window.viewHeight || 150 +var viewHeight = window.viewHeight || 186 var app = new function(){} diff --git a/public/assets/javascripts/mx/mx.js b/public/assets/javascripts/mx/mx.js index 496aec0..6b36392 100644 --- a/public/assets/javascripts/mx/mx.js +++ b/public/assets/javascripts/mx/mx.js @@ -452,6 +452,16 @@ var MX = MX || (function (undefined) { return this }, + move: function(ops){ + var layer = this + layer.ops = defaults(ops, layer.ops) + for (var i in ops) { + layer[i] = ops[i] + } + layer.dirty = true + layer.update() + }, + onTransitionEnd: function (callback) { this.cancelTransitionEnd() var el = this.el diff --git a/public/assets/javascripts/mx/primitives/mx.face.js b/public/assets/javascripts/mx/primitives/mx.face.js deleted file mode 100644 index ac47ab4..0000000 --- a/public/assets/javascripts/mx/primitives/mx.face.js +++ /dev/null @@ -1,41 +0,0 @@ -MX.Face = MX.Object3D.extend({ - - // this will be called within the contructor - init: function (size, color, borderColor) { - - size = size || 100 - color = color || 'rgba(0, 255, 122, .1)' - borderColor = borderColor || '#0f3' - - // an Object3D's associated DOM node is the "el" property - this.el.classList.add('face') - - var angle = MX.rotationUnit === 'deg' ? 90 : (Math.PI / 2) - - var top = this.top = new MX.Object3D('.face') - top.rotationX = angle - top.y = size / 2 - - // adding children, must also be instances of Object3D - this.add(top) - - this.children.forEach(function (face) { - face.width = size - 2 - face.height = size - 2 - face.el.style.backgroundColor = color - face.el.style.border = '1px solid ' + borderColor - }) - - // this applies the updated CSS style - // required for any change to take effect - // when a parent object's update() is called - // all its children will be updated as well - this.update() - - // if this object's children won't move by themselves - this.updateChildren = false - } - - // other properties will be mixed into the prototype of the new constructor - -}) diff --git a/public/assets/javascripts/mx/primitives/mx.image.js b/public/assets/javascripts/mx/primitives/mx.image.js index 6ddc5d8..278fa1e 100644 --- a/public/assets/javascripts/mx/primitives/mx.image.js +++ b/public/assets/javascripts/mx/primitives/mx.image.js @@ -2,32 +2,25 @@ MX.Image = MX.Object3D.extend({ init: function (ops) { this.type = "Image" - - var layer = this - layer.width = 0 - layer.height = 0 - layer.x = ops.x || 0 - layer.y = ops.y || 0 - layer.z = ops.z || 0 - layer.scale = ops.scale || 1 - layer.backface = ops.backface || false - layer.media = ops.media + this.media = ops.media + this.width = 0 + this.height = 0 + this.x = ops.x || 0 + this.y = ops.y || 0 + this.z = ops.z || 0 + this.scale = ops.scale || 1 + this.backface = ops.backface || false - if (layer.backface) { - layer.el.classList.add("backface-visible") - } + ops.className && this.el.classList.add(ops.className) + this.backface && this.el.classList.add("backface-visible") + this.el.classList.add("image") - if (ops.src) { - this.loadTexture(ops) - } + this.el.style.backgroundRepeat = 'no-repeat' - if (ops.className) { - layer.el.classList.add(ops.className) - } - layer.el.style.backgroundRepeat = 'no-repeat' + this.load(ops) }, - loadTexture: function(ops){ + load: function(ops){ var layer = this layer.ops = defaults(ops, layer.ops) @@ -49,20 +42,5 @@ MX.Image = MX.Object3D.extend({ } image.src = ops.src; }, - - move: function(ops){ - var layer = this - layer.ops = defaults(ops, layer.ops) - for (var i in ops) { - layer[i] = ops[i] - } - layer.dirty = true - layer.update() - }, - - toString: function(){ - var params = "id src width height depth x y z rotationX rotationY rotationZ scale".split(" ") - return this.__toString(params) - }, }) diff --git a/public/assets/javascripts/mx/primitives/mx.text.js b/public/assets/javascripts/mx/primitives/mx.text.js index 0c278a9..9c7af5c 100644 --- a/public/assets/javascripts/mx/primitives/mx.text.js +++ b/public/assets/javascripts/mx/primitives/mx.text.js @@ -1,4 +1,5 @@ MX.Text = MX.Object3D.extend({ + init: function (ops) { this.type = "Text" @@ -31,4 +32,5 @@ MX.Text = MX.Object3D.extend({ this.updateChildren = true this.update() } + }) diff --git a/public/assets/javascripts/mx/primitives/mx.video.js b/public/assets/javascripts/mx/primitives/mx.video.js index b2727c0..1b17994 100644 --- a/public/assets/javascripts/mx/primitives/mx.video.js +++ b/public/assets/javascripts/mx/primitives/mx.video.js @@ -1,4 +1,5 @@ MX.Video = MX.Object3D.extend({ + init: function (ops) { this.type = "Video" @@ -22,7 +23,7 @@ MX.Video = MX.Object3D.extend({ } if (ops.src) { - this.loadVideo(ops) + this.load(ops) } if (ops.className) { @@ -31,7 +32,7 @@ MX.Video = MX.Object3D.extend({ layer.el.style.backgroundRepeat = 'no-repeat' }, - loadVideo: function(ops){ + load: function(ops){ var layer = this var video = document.createElement('video') @@ -50,15 +51,5 @@ MX.Video = MX.Object3D.extend({ this.el.appendChild(video) }, - - move: function(ops){ - var layer = this - layer.ops = defaults(ops, layer.ops) - for (var i in ops) { - layer[i] = ops[i] - } - layer.dirty = true - layer.update() - } }) diff --git a/public/assets/javascripts/mx/primitives/mx.vimeo.js b/public/assets/javascripts/mx/primitives/mx.vimeo.js index b8efa17..344a450 100644 --- a/public/assets/javascripts/mx/primitives/mx.vimeo.js +++ b/public/assets/javascripts/mx/primitives/mx.vimeo.js @@ -34,25 +34,6 @@ MX.Vimeo = MX.Object3D.extend({ loadEmbed: function(ops){ var layer = this - }, - - move: function(ops){ - var layer = this - layer.ops = defaults(ops, layer.ops) - for (var i in ops) { - layer[i] = ops[i] - } - layer.dirty = true - layer.update() - }, - - toString: function(){ - var params = "id src width height depth x y z rotationX rotationY rotationZ scale".split(" ") - return this.__toString(params) - }, + } }) - -window.onYouTubePlayerAPIReady = function(){ - console.log("youtube ready") -} diff --git a/public/assets/javascripts/mx/primitives/mx.youtube.js b/public/assets/javascripts/mx/primitives/mx.youtube.js index 3756d80..b21184d 100644 --- a/public/assets/javascripts/mx/primitives/mx.youtube.js +++ b/public/assets/javascripts/mx/primitives/mx.youtube.js @@ -4,53 +4,69 @@ MX.Youtube = MX.Object3D.extend({ this.type = "Youtube" - var layer = this - layer.media = ops.media - layer.width = ops.media.width - layer.height = ops.media.height - layer.x = ops.x || 0 - layer.y = ops.y || 0 - layer.z = ops.z || 0 - layer.rotationX = ops.rotationX || 0 - layer.rotationY = ops.rotationY || 0 - layer.rotationZ = ops.rotationZ || 0 - layer.scale = ops.scale || 1 - layer.backface = ops.backface || false + this.media = ops.media + this.width = ops.media.width + this.height = ops.media.height + this.x = ops.x || 0 + this.y = ops.y || 0 + this.z = ops.z || 0 + this.rotationX = ops.rotationX || 0 + this.rotationY = ops.rotationY || 0 + this.rotationZ = ops.rotationZ || 0 + this.scale = ops.scale || 1 + this.backface = ops.backface || false - if (layer.backface) { - layer.el.classList.add("backface-visible") - } - - if (ops.src) { - this.loadEmbed(ops) - } + ops.className && this.el.classList.add(ops.className) + this.backface && this.el.classList.add("backface-visible") + this.el.classList.add("video") - if (ops.className) { - layer.el.classList.add(ops.className) - } - layer.el.style.backgroundRepeat = 'no-repeat' - + this.load() }, - loadEmbed: function(ops){ - var layer = this + load: function (ops) { + var uid = 'player-' + Uid() + var preload = document.createElement("div") + preload.id = uid + preload.style.backgroundImage = "url(" + this.media.thumbnail + ")" + preload.style.width = this.media.width + "px" + preload.style.height = this.media.height + "px" + preload.style.pointerEvents = "none" + preload.className = "preload" + this.el.appendChild(preload) + + this.player = new YT.Player(uid, { + videoId: this.media.token, + width: this.width, + height: this.height, + events: { + onReady: $.proxy(this.ready, this), + onError: $.proxy(this.error, this), + } + }) }, - move: function(ops){ - var layer = this - layer.ops = defaults(ops, layer.ops) - for (var i in ops) { - layer[i] = ops[i] - } - layer.dirty = true - layer.update() + ready: function(){ + console.log("youtube ready") }, - - toString: function(){ - var params = "id src width height depth x y z rotationX rotationY rotationZ scale".split(" ") - return this.__toString(params) - }, - + + error: function(err){ + console.log("youtube error", err) + }, + + play: function(){ + this.player.playVideo() + }, + + pause: function(){ + this.player.pauseVideo() + }, + + seek: function(n){ + }, + + duration: function(){ + } + }) window.onYouTubePlayerAPIReady = function(){ diff --git a/views/partials/scripts.ejs b/views/partials/scripts.ejs index 6799aa7..80be29f 100644 --- a/views/partials/scripts.ejs +++ b/views/partials/scripts.ejs @@ -38,6 +38,8 @@ + + -- cgit v1.2.3-70-g09d2 From 221a14315b09946db2485036bbf4a80295dc4889 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 2 Jul 2014 16:22:51 -0400 Subject: password reset / username dupe stuff from PH --- .../assets/javascripts/ui/site/PasswordForgot.js | 26 ++ public/assets/javascripts/ui/site/PasswordReset.js | 25 ++ public/assets/javascripts/ui/site/UsernameTaken.js | 21 ++ public/assets/stylesheets/app.css | 1 - server/index.js | 8 + server/lib/auth.js | 201 ------------- server/lib/auth/index.js | 331 +++++++++++++++++++++ server/lib/auth/mail.js | 67 +++++ server/lib/auth/views.js | 33 ++ server/lib/middleware.js | 1 + server/lib/schemas/User.js | 33 +- server/lib/upload.js | 4 +- server/lib/util.js | 6 +- views/controls/editor/media-editor.ejs | 30 ++ views/controls/editor/settings.ejs | 4 +- views/mail/password.html.ejs | 25 ++ views/mail/password.text.ejs | 11 + views/mail/welcome.html.ejs | 17 ++ views/mail/welcome.text.ejs | 4 + views/partials/scripts.ejs | 3 + views/partials/sign-in.ejs | 75 +++++ 21 files changed, 712 insertions(+), 214 deletions(-) create mode 100644 public/assets/javascripts/ui/site/PasswordForgot.js create mode 100644 public/assets/javascripts/ui/site/PasswordReset.js create mode 100644 public/assets/javascripts/ui/site/UsernameTaken.js delete mode 100644 server/lib/auth.js create mode 100644 server/lib/auth/index.js create mode 100644 server/lib/auth/mail.js create mode 100644 server/lib/auth/views.js create mode 100644 views/controls/editor/media-editor.ejs create mode 100644 views/mail/password.html.ejs create mode 100644 views/mail/password.text.ejs create mode 100644 views/mail/welcome.html.ejs create mode 100644 views/mail/welcome.text.ejs (limited to 'views/partials/scripts.ejs') diff --git a/public/assets/javascripts/ui/site/PasswordForgot.js b/public/assets/javascripts/ui/site/PasswordForgot.js new file mode 100644 index 0000000..6ac23c0 --- /dev/null +++ b/public/assets/javascripts/ui/site/PasswordForgot.js @@ -0,0 +1,26 @@ +var PasswordForgot = ModalFormView.extend({ + el: ".mediaDrawer.passwordForgot", + action: "/auth/passwordForgot", + + validate: function(){ + var errors = [] + + var email = this.$("#emailInput").val() + + if (! email.length) { + errors.push("Please enter your email address"); + } + if (email.indexOf("@") === -1) { + errors.push("Sorry, that is not a valid email address"); + } + + return errors + }, + + success: function(res){ + AlertModal.alert("Check your email, you should receive further instructions momentarily.", function(e){ + window.location.href = "/" + }) + }, + +}) diff --git a/public/assets/javascripts/ui/site/PasswordReset.js b/public/assets/javascripts/ui/site/PasswordReset.js new file mode 100644 index 0000000..77e8684 --- /dev/null +++ b/public/assets/javascripts/ui/site/PasswordReset.js @@ -0,0 +1,25 @@ +var PasswordReset = ModalFormView.extend({ + el: ".mediaDrawer.passwordReset", + action: "/auth/password", + + validate: function(){ + var errors = [] + + var pw1 = this.$("#passwordInput1").val() + var pw2 = this.$("#passwordInput2").val() + + if (! pw1.length) { + errors.push("Please enter a password"); + } + if (pw1 !== pw2) { + errors.push("Passwords don't match"); + } + + return errors + }, + + success: function(res){ + window.location.href = "/profile" + } + +}) diff --git a/public/assets/javascripts/ui/site/UsernameTaken.js b/public/assets/javascripts/ui/site/UsernameTaken.js new file mode 100644 index 0000000..fc651e3 --- /dev/null +++ b/public/assets/javascripts/ui/site/UsernameTaken.js @@ -0,0 +1,21 @@ +var UsernameTaken = ModalFormView.extend({ + el: ".mediaDrawer.usernameTaken", + action: "/auth/usernameTaken", + + validate: function(){ + var errors = [] + + var username = this.$("#usernameInput").val() + + if (! username.length) { + errors.push("Please enter a username"); + } + + return errors + }, + + success: function(res){ + window.location.href = "/profile" + } + +}) diff --git a/public/assets/stylesheets/app.css b/public/assets/stylesheets/app.css index a2b5d8c..9c80987 100755 --- a/public/assets/stylesheets/app.css +++ b/public/assets/stylesheets/app.css @@ -1274,7 +1274,6 @@ button:hover { form { max-width: 440px; margin: 0 auto; - } form div { float:right; diff --git a/server/index.js b/server/index.js index b008131..bb242ee 100644 --- a/server/index.js +++ b/server/index.js @@ -61,6 +61,7 @@ site.setup = function(){ app.use(passport.initialize()); app.use(passport.session()); app.use(app.router); + app.enable('trust proxy') app.get('env') === 'development' && app.use(express.errorHandler()); // Essential middleware @@ -90,6 +91,13 @@ site.route = function () { app.get('/auth/twitter/callback', auth.loggedIn('twitter')); app.get('/auth/facebook', auth.login('facebook')); app.get('/auth/facebook/callback', auth.loggedIn('facebook')); + app.get('/auth/usernameTaken', auth.views.usernameTaken); + app.post('/auth/usernameTaken', auth.usernameFixed); + app.get('/auth/password', auth.views.resetPassword); + app.post('/auth/password', auth.resetPassword); + app.post('/auth/passwordForgot', auth.forgotPassword); + + app.get('/profile', views.profile) app.get('/profile/edit', views.profile) app.get('/profile/:name', views.profile) diff --git a/server/lib/auth.js b/server/lib/auth.js deleted file mode 100644 index 018c9ad..0000000 --- a/server/lib/auth.js +++ /dev/null @@ -1,201 +0,0 @@ -/* jshint node: true */ - -var passport = require('passport'), - FacebookStrategy = require('passport-facebook').Strategy, - TwitterStrategy = require('passport-twitter').Strategy, - LocalStrategy = require('passport-local').Strategy, - passportSocketIo = require("passport.socketio"), - cookieParser = require('express').cookieParser, - crypto = require('crypto'), - _ = require('lodash'), - util = require('./util'), - config = require('../../config.json'), - User = require('./schemas/User'); - -var auth = { - - init: function () { - passport.serializeUser(auth.serializeUser); - passport.deserializeUser(auth.deserializeUser); - - passport.use(new LocalStrategy(auth.verifyLocalUser)) - - passport.use(new TwitterStrategy({ - consumerKey: process.env.VVALLS_TWITTER_KEY || '0L5blfBIapqhpons8bCXdIoGM', - consumerSecret: process.env.VVALLS_TWITTER_SECRET || '5EKW7m7inoODqYSKbp7cadBKFp1FghBl4MBDoXNcUjKtodZfuP', - callbackURL: 'http://' + config.host + '/auth/twitter/callback' - }, auth.insertTwitterUser)); - - passport.use(new FacebookStrategy({ - clientID: process.env.VVALLS_FACEBOOK_KEY || '719828821410310', - clientSecret: process.env.VVALLS_FACEBOOK_SECRET || 'f9aba78e08f37f621eadb88b1409d48c', - callbackURL: 'http://' + config.host + '/auth/facebook/callback', - enableProof: false, - }, auth.insertFacebookUser)); - }, - - initSockets: function (io, express, SessionStore) { - io.set('authorization', passportSocketIo.authorize({ - cookieParser: cookieParser, - passport: passport, - key: 'vvalls.sid', // the name of the cookie where express/connect stores its session_id - secret: 'flibbertigibbet', // the session_secret to parse the cookie - store: SessionStore, // we NEED to use a sessionstore. no memorystore please - success: auth.socketSuccess, - fail: auth.socketFail, - })); - }, - - socketSuccess: function (data, accept) { - // console.error('successful connection to socket.io'); - accept(null, true); - }, - - socketFail: function (data, message, error, accept){ - if (error) { - throw new Error(message); - } - // console.log(data) - console.error('failed connection to socket.io:', message); - - // We use this callback to log all of our failed connections. - accept(null, false); - }, - - // technically these return the login middleware - login: function (strategy) { - return passport.authenticate(strategy); - }, - - loggedIn: function (strategy) { - return passport.authenticate(strategy, { - successReturnToOrRedirect: '/', - failureRedirect: '/login' - }); - }, - - loggedInLocal: function (req, res, next) { - passport.authenticate("local", function(err, user, info){ - if (err) { - return res.json({ error: err }); - } - if (! user) { - return info ? res.json(info) : res.redirect("/login"); - } - req.logIn(user, function(err) { - if (err) { return next(err); } - return res.json({ status: "OK" }) - }); - })(req, res, next); - }, - - logout: function (req, res) { - req.logout(); - res.redirect('/'); - }, - - serializeUser: function (user, done) { - done(null, user._id); - }, - - deserializeUser: function (id, done) { - User.findOne({ _id: id }, "_id displayName username photo isStaff", function (err, user) { - done(err, user); - }); - }, - - signup: function (req, res){ - var username = util.trim(req.body.username) - var password = req.body.password - var email = util.trim(req.body.email) - - var shasum = crypto.createHash('sha1') - shasum.update(password) - password = shasum.digest('hex'); - - User.findOne({ username: username }, "_id username", function (err, user) { - if (user) { - res.json({ error: { errors: { username: { message: "Username has been taken" } } } }) - return - } - var data = { - username: username, - displayName: username, - password: password, - email: email, - created_ip: util.ip2num(req.connection.remoteAddress), - last_ip: util.ip2num(req.connection.remoteAddress), - created_at: new Date () - } - new User(data).save(function(err, user){ - if (err || ! data) { return res.json({ error: err }) } - - req.login(user, function(){ - res.json({ status: "OK", payload: user }) - }) - }) - }) - }, - - verifyLocalUser: function (username, password, done) { - User.findOne({ username: username }, function(err, user){ - if (err) { return done(err); } - if (!user) { - return done(null, false, { error: { errors: { username: { message: 'Incorrect username.' } }}}) - } - if (! user.validPassword(password)) { - return done(null, false, { error: { errors: { password: { message: 'Incorrect password.' } }}}) - } - return done(null, user); - }); - }, - - insertTwitterUser: function (accessToken, refreshToken, profile, done) { - process.nextTick(function () { - var userData = { - twitter_id: profile.id, - username: profile.username, - displayName: profile.displayName, - photo: profile.photos[0].value, - twitterName: profile.username, - }; - - User.findOne({twitter_id: profile.id}, function(err, data){ - if (! err && data) { - return done(err, data); - } - new User(userData).save(function(err, data){ - if (err) { console.error(err) } - return done(err, data) - }) - }); - - }); - }, - - insertFacebookUser: function (accessToken, refreshToken, profile, done) { - process.nextTick(function () { - var userData = { - facebook_id: profile.id, - username: profile.username || profile.displayName.toLowerCase().replace(/ /g,'-'), - displayName: profile.displayName, - photo: "http://graph.facebook.com/" + profile.id + "/picture?type=large", - facebookUrl: profile.username ? "https://facebook.com/" + profile.username : "" - }; - - User.findOne({facebook_id: profile.id}, function(err, data){ - if (! err && data) { - return done(err, data); - } - new User(userData).save(function(err, data){ - if (err) { console.error(err) } - return done(err, data) - }) - }); - - }); - }, - -} - -module.exports = auth diff --git a/server/lib/auth/index.js b/server/lib/auth/index.js new file mode 100644 index 0000000..99af9b5 --- /dev/null +++ b/server/lib/auth/index.js @@ -0,0 +1,331 @@ +/* jshint node: true */ + +var passport = require('passport'), + FacebookStrategy = require('passport-facebook').Strategy, + TwitterStrategy = require('passport-twitter').Strategy, + LocalStrategy = require('passport-local').Strategy, + passportSocketIo = require("passport.socketio"), + cookieParser = require('express').cookieParser, + crypto = require('crypto'), + express = require('express'), + _ = require('lodash'), + mongoose = require('mongoose'), + util = require('../util'), + config = require('../../../config.json'), + User = require('../schemas/User'); + +var auth = { + views: require('./views'), + mail: require('./mail'), + + init: function () { + passport.serializeUser(auth.serializeUser); + passport.deserializeUser(auth.deserializeUser); + + passport.use(new LocalStrategy(auth.verifyLocalUser)) + + passport.use(new TwitterStrategy({ + consumerKey: process.env.VVALLS_TWITTER_KEY || 'brI5VqBak5yrhCcxU56lj5L3v', + consumerSecret: process.env.VVALLS_TWITTER_SECRET || 'ThzaEVWUgkmfzqOs3qcrdonGzgDBjDHTVzPkfY0wFJxjUH6JWZ', + callbackURL: 'http://' + config.host + '/auth/twitter/callback' + }, auth.insertTwitterUser)); + + /* + passport.use(new FacebookStrategy({ + clientID: process.env.VVALLS_FACEBOOK_KEY || '719828821410310', + clientSecret: process.env.VVALLS_FACEBOOK_SECRET || 'f9aba78e08f37f621eadb88b1409d48c', + callbackURL: 'http://' + config.host + '/auth/facebook/callback', + enableProof: false, + }, auth.insertFacebookUser)); + */ + auth.mail.init() + }, + + initSockets: function (io, SessionStore) { + io.set('authorization', passportSocketIo.authorize({ + cookieParser: express.cookieParser, + passport: passport, + key: 'vvalls.sid', // the name of the cookie where express/connect stores its session_id + secret: 'flibbertigibbet', // the session_secret to parse the cookie + store: SessionStore, // we NEED to use a sessionstore. no memorystore please + success: auth.socketSuccess, + fail: auth.socketFail, + })); + }, + + socketSuccess: function (data, accept) { + // console.error('successful connection to socket.io'); + accept(null, true); + }, + + socketFail: function (data, message, error, accept){ + if (error) { + throw new Error(message); + } + // console.log(data) + console.error('failed connection to socket.io:', message); + + // We use this callback to log all of our failed connections. + accept(null, false); + }, + + // technically these return the login middleware + login: function (strategy) { + return passport.authenticate(strategy); + }, + + loggedIn: function (strategy) { + return function (req, res, next) { + console.log("attempting to use", strategy) + + passport.authenticate(strategy, function(err, user, info){ + if (err) { + return next(err); + } + if (! user) { + req.session.userData = info + return res.redirect('/auth/usernameTaken'); + } + if (! user.created_ip) { + user.created_ip = util.ip2num( req.ip ) + } + user.last_ip = util.ip2num( req.ip ) + user.save(function(err, data){ if (err) console.err('error setting ip for user') }) + + req.logIn(user, function(err) { + if (err) { return next(err); } + var returnTo = req.session.returnTo + delete req.session.returnTo + return res.redirect( returnTo || "/profile" ); + }); + })(req, res, next); + } + }, + + loggedInLocal: function (req, res, next) { + passport.authenticate("local", function(err, user, info){ + if (err) { + return res.json({ error: err }); + } + if (! user) { + return info ? res.json(info) : res.redirect("/login"); + } + + user.last_ip = util.ip2num( req.ip ) + user.save(function(err, data){ if (err) console.err('error setting ip for user') }) + + req.logIn(user, function(err) { + if (err) { return next(err); } + var returnTo = req.session.returnTo + delete req.session.returnTo + return res.json({ status: "OK", returnTo: returnTo || "/profile" }) + }); + })(req, res, next); + }, + + logout: function (req, res) { + req.logout(); + res.redirect('/'); + }, + + serializeUser: function (user, done) { + done(null, user._id); + }, + + deserializeUser: function (id, done) { + try { + var _id = mongoose.Types.ObjectId(id) + User.findOne({ _id: _id }, "_id displayName username photo isStaff", function (err, user) { + done(err, user); + }); + } + catch (e) { + User.findOne({ twitter_id: id }, "_id displayName username photo isStaff", function (err, user) { + done(err, user); + }); + } + }, + + signup: function (req, res){ + var username = util.trim(req.body.username) + var password = req.body.password + var email = util.trim(req.body.email) + + var shasum = crypto.createHash('sha1') + shasum.update(password) + password = shasum.digest('hex'); + + User.findByUsername(username, function (err, user) { + if (user) { + res.json({ error: { errors: { username: { message: "Username has been taken" } } } }) + return + } + + User.findByEmail(email, function (err, user) { + if (user) { + res.json({ error: { errors: { username: { message: "Email has already been used" } } } }) + return + } + var data = { + username: username, + displayName: username, + password: password, + email: email, + created_ip: util.ip2num( req.ip ), + last_ip: util.ip2num( req.ip ), + created_at: new Date () + } + new User(data).save(function(err, user){ + if (err || ! data) { return res.json({ error: err }) } + req.login(user, function(){ + auth.mail.welcome(user, function(){ + res.json({ status: "OK", payload: user }) + }) + }) + }) + }) + }) + }, + + verifyLocalUser: function (username, password, done) { + User.findByUsername(username, function(err, user){ + if (err) { return done(err); } + if (! user) { + return done(null, false, { error: { errors: { username: { message: 'No such username.' } }}}) + } + if (! user.validPassword(password)) { + return done(null, false, { error: { errors: { password: { message: 'Incorrect password.' } }}}) + } + return done(null, user); + }); + }, + + insertTwitterUser: function (accessToken, refreshToken, profile, done) { + process.nextTick(function () { + var userData = { + twitter_id: profile.id, + username: profile.username, + displayName: profile.displayName, + photo: profile.photos[0].value, + twitterName: profile.username, + }; + User.findOne({twitter_id: profile.id}, function(err, data){ + if (! err && data) { + return done(err, data); + } + User.findByUsername(profile.username, function(err, data){ + if (data) { + return done(null, false, userData) + } + new User(userData).save(function(err, data){ + if (err) { + console.error(err) + } + return done(err, data) + }) + }) + }); + + }); + }, + + insertFacebookUser: function (accessToken, refreshToken, profile, done) { + process.nextTick(function () { + var userData = { + facebook_id: profile.id, + username: profile.username || profile.displayName.toLowerCase().replace(/ /g,'-'), + displayName: profile.displayName, + photo: "http://graph.facebook.com/" + profile.id + "/picture?type=large", + facebookUrl: profile.username ? "https://facebook.com/" + profile.username : "" + }; + + User.findOne({twitter_id: profile.id}, function(err, data){ + if (! err && data) { + return done(err, data); + } + User.findByUsername(profile.username, function(err, data){ + if (data) { + return done(null, false, userData) + } + new User(userData).save(function(err, data){ + if (err) { + console.error(err) + } + return done(err, data) + }) + }) + }); + + }); + }, + + usernameFixed: function (req, res) { + + var userData = req.session.userData + if (! userData) { + return res.redirect("/") + } + if (req.isAuthenticated()) { + delete req.session.userData + return res.redirect("/") + } + + var username = util.sanitize(req.body.username) + + User.findByUsername(username, function(err, doc){ + if (err || doc) { + res.json({ error: { errors: { username: { message: "Username has been taken" } } } }) + return + } + userData.username = username + + new User(userData).save(function(err, user){ + req.logIn(user, function(err) { + if (err) { return res.json(err); } + var returnTo = req.session.returnTo + delete req.session.returnTo + return res.json({ status: "OK", returnTo: returnTo || "/profile" }) + }); + }) + }) + }, + + forgotPassword: function (req, res) { + User.findByEmail(req.body.email, function(err, user){ + if (err || ! user) { + res.json({ error: { errors: { email: { message: "That email address was not found." } } } }) + return + } + User.resetPasswordNonce(user, function(err){ + auth.mail.forgotPassword(user, function(){ + res.json({ success: 'OK' }) + }) + }) + }) + }, + + resetPassword: function (req, res) { + var password = req.body.password + + var shasum = crypto.createHash('sha1') + shasum.update(password) + password = shasum.digest('hex'); + + User.findOne({ passwordNonce: req.body.nonce }, function (err, user){ + if (err || ! user) { + res.json({ error: { errors: { email: { message: "That reset token has already been used." } } } }) + return + } + user.password = password + user.passwordNonce = "" + user.save(function(){ + req.login(user, function(){ + res.json({ status: "OK", payload: user }) + }) + }) + }) + }, + +} + +module.exports = auth diff --git a/server/lib/auth/mail.js b/server/lib/auth/mail.js new file mode 100644 index 0000000..a4abccd --- /dev/null +++ b/server/lib/auth/mail.js @@ -0,0 +1,67 @@ + +var email = require("emailjs"), + ejs = require("ejs"), + fs = require("fs"), + util = require("../util"); + +var mail = { + + from: 'Vvalls ', + templates: {}, + + init: function(){ + var names = ["welcome","password"].forEach(function(name){ + mail.templates[name] = {}; + var types = ["text","html"].forEach(function(type){ + fs.readFile("views/mail/" + name + "." + type + ".ejs", function(err, data){ + mail.templates[name][type] = ejs.compile(data.toString()) + }) + }) + }) + }, + + connect: function(){ + var server = email.server.connect({ + user: process.env.OKFOCUS_EMAIL_USERNAME, + password: process.env.OKFOCUS_EMAIL_PASSWORD, + host: "smtp.sendgrid.net", + ssl: true + }) + return server + }, + + send: function(msg, cb){ + var server = mail.connect() + server.send(msg, cb) + }, + + welcome: function(user, cb){ + var message = { + text: mail.templates.welcome.text(user), + from: mail.from, + to: user.email, + subject: "Welcome to Vvalls", + attachment: [ + { data: mail.templates.welcome.html(user), alternative: true }, + ] + }; + mail.send(message, cb) + console.log("sent welcome email to", user.email) + }, + + forgotPassword: function(user, cb){ + var message = { + text: mail.templates.password.text(user), + from: mail.from, + to: user.email, + subject: "Recover your password", + attachment: [ + { data: mail.templates.password.html(user), alternative: true }, + ] + } + mail.send(message, cb) + console.log("sent password email to", user.email) + }, +} + +module.exports = mail diff --git a/server/lib/auth/views.js b/server/lib/auth/views.js new file mode 100644 index 0000000..591b06a --- /dev/null +++ b/server/lib/auth/views.js @@ -0,0 +1,33 @@ + +var util = require('../util'), + User = require("../schemas/User"); + + +var views = {} + +views.usernameTaken = function (req, res) { + var userData = req.session.userData + if (! userData) { + return res.redirect("/") + } + if (req.isAuthenticated()) { + delete req.session.userData + return res.redirect("/") + } + res.render("modal", { opt: { username: util.sanitize(userData.username) } }) +} + +views.resetPassword = function (req, res) { + var nonce = util.sanitize(req.query.nonce) + if (! nonce.length) { + return res.redirect("/") + } + User.findOne({ passwordNonce: nonce }, function (err, user){ + if (err || ! user) { + return res.redirect("/") + } + res.render("reset-password", { username: user.username, nonce: user.passwordNonce }) + }) +} + +module.exports = views diff --git a/server/lib/middleware.js b/server/lib/middleware.js index 0bc3f7a..aec54ad 100644 --- a/server/lib/middleware.js +++ b/server/lib/middleware.js @@ -39,6 +39,7 @@ var middleware = { res.locals.user = req.user || {} res.locals.config = config res.locals.profile = null + res.locals.opt = {} next() }, diff --git a/server/lib/schemas/User.js b/server/lib/schemas/User.js index 77e2e02..b64f8fc 100644 --- a/server/lib/schemas/User.js +++ b/server/lib/schemas/User.js @@ -41,10 +41,8 @@ var UserSchema = new mongoose.Schema({ }, "{PATH} is not an acceptable name"] }, email: { type: String, default: "" }, - emailVerified: { - type: Boolean, - default: false, - }, + emailVerified: { type: Boolean, default: false, }, + emailOptout: { type: Boolean, default: false, }, password: { type: String, validate: [function (val) { @@ -52,6 +50,11 @@ var UserSchema = new mongoose.Schema({ return true }, "{PATH} is not an acceptable password"] }, + passwordNonce: { + type: String, + default: "", + }, + location: { type: String, default: "" }, photo: { type: String, default: "" }, bio: { type: String, default: "" }, @@ -72,6 +75,26 @@ UserSchema.methods.validPassword = function (pw) { shasum.update(pw) return this.password === shasum.digest('hex'); } - +UserSchema.statics.findByUsername = function (username, cb) { + this.findOne({ username: new RegExp("^" + username + "$", "i") }, cb) +} +UserSchema.statics.findByEmail = function (email, cb) { + email = util.escapeRegExp(email) + this.findOne({ email: new RegExp("^" + email + "$", "i") }, cb) +} +UserSchema.statics.findByIP = function (ip, cb) { + ip = util.ip2num(ip) + this.findOne({ $or: [{ created_ip: ip }, { last_ip: ip }] }, cb) +} +UserSchema.statics.resetPasswordNonce = function(user, cb){ + crypto.pseudoRandomBytes(256, function (err, buf){ + var shasum = crypto.createHash('sha1') + shasum.update(buf) + user.passwordNonce = shasum.digest('hex') + user.save(function(err, doc){ + cb() + }) + }) +} module.exports = exports = mongoose.model('user', UserSchema); exports.schema = UserSchema; diff --git a/server/lib/upload.js b/server/lib/upload.js index 0f6c624..e206f7c 100644 --- a/server/lib/upload.js +++ b/server/lib/upload.js @@ -60,7 +60,9 @@ module.exports.put = function (key, file, opt) { }, function(err, s3res) { if (err || s3res.statusCode !== 200) { console.error(err); - s3res.resume() + if (s3res && s3res.resume) { + s3res.resume() + } return; } diff --git a/server/lib/util.js b/server/lib/util.js index aaa8274..6604abe 100644 --- a/server/lib/util.js +++ b/server/lib/util.js @@ -16,18 +16,18 @@ util.trim = function (s){ return (s || "").replace(whitespaceHead,"").replace(wh util.slugify = function (s){ return (s || "").toLowerCase().replace(whitespace,"-").replace(nonAlphanumerics, '-').replace(consecutiveDashes,"-") } - util.sanitize = function (s){ return (s || "").replace(entities, "") } - util.capitalize = function (s) { return (s || "").split(" ").map(util.capitalizeWord).join(" "); } - util.capitalizeWord = function (s) { return s.charAt(0).toUpperCase() + s.slice(1); } +util.escapeRegExp: function (s) { + return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&") +} util.cleanQuery = function (query) { diff --git a/views/controls/editor/media-editor.ejs b/views/controls/editor/media-editor.ejs new file mode 100644 index 0000000..93405fc --- /dev/null +++ b/views/controls/editor/media-editor.ejs @@ -0,0 +1,30 @@ +
+ + + +
+ +
+ +
+ +
+ +
+
+ + + + +
+
+ +
+ +
+ +
diff --git a/views/controls/editor/settings.ejs b/views/controls/editor/settings.ejs index a7d6213..867d5f3 100644 --- a/views/controls/editor/settings.ejs +++ b/views/controls/editor/settings.ejs @@ -16,9 +16,7 @@
-
- -
+
diff --git a/views/mail/password.html.ejs b/views/mail/password.html.ejs new file mode 100644 index 0000000..f266488 --- /dev/null +++ b/views/mail/password.html.ejs @@ -0,0 +1,25 @@ + + + +

+ Hey there, +

+ +

+ We received a request to reset the password associated with this email address. +

+ +

+ Click the link below to make a new password: +

+ +

+ http://vvalls.com/auth/password?nonce=[[- passwordNonce ]] +

+ +

+ If this was requested in error, please disregard this message. +

+ + + diff --git a/views/mail/password.text.ejs b/views/mail/password.text.ejs new file mode 100644 index 0000000..67e4b60 --- /dev/null +++ b/views/mail/password.text.ejs @@ -0,0 +1,11 @@ + +Hey there, + +We received a request to reset the password associated with this email address. + +Click the link below to make a new password: + +http://vvalls.com/auth/password?nonce=[[- passwordNonce ]] + +If this was requested in error, please disregard this message. + diff --git a/views/mail/welcome.html.ejs b/views/mail/welcome.html.ejs new file mode 100644 index 0000000..8b7194b --- /dev/null +++ b/views/mail/welcome.html.ejs @@ -0,0 +1,17 @@ + + + +

+ +

+ +

+ Welcome to Vvalls, [[- username ]] +

+ +

+ www.vvalls.com +

+ + + diff --git a/views/mail/welcome.text.ejs b/views/mail/welcome.text.ejs new file mode 100644 index 0000000..cab9c15 --- /dev/null +++ b/views/mail/welcome.text.ejs @@ -0,0 +1,4 @@ + +Welcome to Vvalls, [[- username ]] + +http://www.posthang.com diff --git a/views/partials/scripts.ejs b/views/partials/scripts.ejs index 80be29f..9f0c2f2 100644 --- a/views/partials/scripts.ejs +++ b/views/partials/scripts.ejs @@ -65,6 +65,9 @@ + + + diff --git a/views/partials/sign-in.ejs b/views/partials/sign-in.ejs index 3341aec..11b930f 100644 --- a/views/partials/sign-in.ejs +++ b/views/partials/sign-in.ejs @@ -74,4 +74,79 @@
+
+
+
+
  • + Forgot your password? Enter the email address you used to sign up + and we can reset it for you. +
  • +
  • + +
    + +
    +
  • +
  • + +
  • +
    +
    There was a problem with your submission:
    +
    +
    +
    +
    +
    + +
    +
    +
    + + Please reset your password. +

    +
  • + +
    + +
    +
  • +
  • + +
    + +
    +
  • +
  • + +
  • +
    +
    +
    +
    +
    +
    + +
    +
    +
    + We're sorry, the username [[- username ]] is already being used. +

    + Please choose another username. +

    +
  • + +
    + +
    +
  • +
  • + +
  • +
    +
    +
    +
    +
    +
    + [[ } ]] -- cgit v1.2.3-70-g09d2 From b19511eb75c6490ddc97ea59d82615ce4d9e0e91 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 10 Jul 2014 17:15:54 -0400 Subject: use view iframe on profile, spins on hover --- .../assets/javascripts/mx/primitives/mx.youtube.js | 3 +-- public/assets/javascripts/ui/_router.js | 7 ++---- .../assets/javascripts/ui/editor/EditorSettings.js | 2 +- public/assets/javascripts/ui/reader/ReaderView.js | 29 ++++++++++++++++++++++ public/assets/javascripts/ui/site/ProfileView.js | 29 ++++++++++++++++++++++ views/partials/scripts.ejs | 1 + 6 files changed, 63 insertions(+), 8 deletions(-) create mode 100644 public/assets/javascripts/ui/site/ProfileView.js (limited to 'views/partials/scripts.ejs') diff --git a/public/assets/javascripts/mx/primitives/mx.youtube.js b/public/assets/javascripts/mx/primitives/mx.youtube.js index 9925c22..118623b 100644 --- a/public/assets/javascripts/mx/primitives/mx.youtube.js +++ b/public/assets/javascripts/mx/primitives/mx.youtube.js @@ -41,7 +41,6 @@ MX.Youtube = MX.Object3D.extend({ defer: function (uid){ if (! YT || ! YT.loaded) { setTimeout(function(){ - console.log("hwat") this.defer(uid) }.bind(this), 300) } @@ -127,5 +126,5 @@ MX.Youtube = MX.Object3D.extend({ }) window.onYouTubePlayerAPIReady = function(){ - console.log("youtube ready") + // console.log("youtube api ready") } diff --git a/public/assets/javascripts/ui/_router.js b/public/assets/javascripts/ui/_router.js index ce18b2a..b3e868a 100644 --- a/public/assets/javascripts/ui/_router.js +++ b/public/assets/javascripts/ui/_router.js @@ -49,6 +49,7 @@ var SiteRouter = Router.extend({ this.editProfileModal = new EditProfileModal() this.passwordForgotModal = new PasswordForgot() this.documentModal = new DocumentModal() + this.profileView = new ProfileView() this.route() @@ -155,11 +156,7 @@ var SiteRouter = Router.extend({ }, profile: function(e){ - var classes = ['one', 'two', 'three', 'four', - 'five', 'six', 'seven', 'eight', - 'nine', 'ten', 'eleven', 'twelve', - 'thirteen']; - $(".bio").addClass(choice(classes)); + this.profileView.load() }, editProfile: function(e){ diff --git a/public/assets/javascripts/ui/editor/EditorSettings.js b/public/assets/javascripts/ui/editor/EditorSettings.js index 35bcbe0..1d68b1b 100644 --- a/public/assets/javascripts/ui/editor/EditorSettings.js +++ b/public/assets/javascripts/ui/editor/EditorSettings.js @@ -32,7 +32,7 @@ var EditorSettings = FormView.extend({ data.startPosition && scene.camera.move(data.startPosition) if (! data.isNew) { - console.log(data) + // console.log(data) this.$id.val( data._id ) this.$name.val( data.name ) diff --git a/public/assets/javascripts/ui/reader/ReaderView.js b/public/assets/javascripts/ui/reader/ReaderView.js index 860cc04..e86856c 100644 --- a/public/assets/javascripts/ui/reader/ReaderView.js +++ b/public/assets/javascripts/ui/reader/ReaderView.js @@ -26,6 +26,35 @@ var ReaderView = View.extend({ data.startPosition && scene.camera.move(data.startPosition) editor.permissions.clear() + + // + + var base = this + + $(window).on('message', function(event){ + if (event.origin !== window.location.origin) { + return + } + var message = event.originalEvent.data + switch (message) { + case "spin-on": + base.spinning = true + break + case "spin-off": + base.spinning = false + break + } + }) + + requestAnimationFrame(this.spin.bind(this)) + }, + + spinning: false, + spin: function(){ + requestAnimationFrame(this.spin.bind(this)) + if (this.spinning) { + scene.camera.rotationY -= 1/180 + } } }) diff --git a/public/assets/javascripts/ui/site/ProfileView.js b/public/assets/javascripts/ui/site/ProfileView.js new file mode 100644 index 0000000..41f04ef --- /dev/null +++ b/public/assets/javascripts/ui/site/ProfileView.js @@ -0,0 +1,29 @@ + +var ProfileView = View.extend({ + + initialize: function(){ + }, + + load: function(){ + var classes = ['one', 'two', 'three', 'four', + 'five', 'six', 'seven', 'eight', + 'nine', 'ten', 'eleven', 'twelve', + 'thirteen']; + $(".bio").addClass(choice(classes)); + + $("td.border").each(function(){ + var iframe = $(this).find("iframe").get('0') + if (! iframe) return + console.log(iframe) + $(this).on({ + mouseenter: function(e){ + iframe.contentWindow.postMessage("spin-on", window.location.origin) + }, + mouseleave: function(e){ + iframe.contentWindow.postMessage("spin-off", window.location.origin) + } + }) + }) + } + +}) diff --git a/views/partials/scripts.ejs b/views/partials/scripts.ejs index 9f0c2f2..6dd4480 100644 --- a/views/partials/scripts.ejs +++ b/views/partials/scripts.ejs @@ -72,6 +72,7 @@ + -- cgit v1.2.3-70-g09d2 From 9a2cfe7da6808a04b7c668075e9e9598ddb5ae04 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 11 Jul 2014 17:07:05 -0400 Subject: basic media editor --- .../javascripts/rectangles/engine/scenery/move.js | 6 ++ .../assets/javascripts/ui/editor/EditorToolbar.js | 2 +- public/assets/javascripts/ui/editor/EditorView.js | 2 +- public/assets/javascripts/ui/editor/MediaEditor.js | 69 ++++++++++++++++++++++ public/assets/stylesheets/app.css | 23 +++++--- views/controls/editor/media-editor.ejs | 30 ++++++---- views/editor.ejs | 2 +- views/partials/scripts.ejs | 3 +- 8 files changed, 115 insertions(+), 22 deletions(-) create mode 100644 public/assets/javascripts/ui/editor/MediaEditor.js (limited to 'views/partials/scripts.ejs') diff --git a/public/assets/javascripts/rectangles/engine/scenery/move.js b/public/assets/javascripts/rectangles/engine/scenery/move.js index bad0a55..aa7ddd1 100644 --- a/public/assets/javascripts/rectangles/engine/scenery/move.js +++ b/public/assets/javascripts/rectangles/engine/scenery/move.js @@ -26,6 +26,12 @@ Scenery.move = function(base){ Scenery.remove(base.id) return } + + if (editor.permissions.pick) { + // load the modal + app.router.editorView.mediaEditor.pick(base) + } + if (! (editor.permissions.move || editor.permissions.resize) ) { e.clickAccepted = false return diff --git a/public/assets/javascripts/ui/editor/EditorToolbar.js b/public/assets/javascripts/ui/editor/EditorToolbar.js index 4a7c3e8..a3abc5a 100644 --- a/public/assets/javascripts/ui/editor/EditorToolbar.js +++ b/public/assets/javascripts/ui/editor/EditorToolbar.js @@ -87,7 +87,7 @@ var EditorToolbar = View.extend({ var editor = new function(){ this.permissions = new Permissions({ - 'pick': false, + 'pick': true, 'move': true, 'resize': false, 'destroy': false, diff --git a/public/assets/javascripts/ui/editor/EditorView.js b/public/assets/javascripts/ui/editor/EditorView.js index 2bb2d61..017e241 100644 --- a/public/assets/javascripts/ui/editor/EditorView.js +++ b/public/assets/javascripts/ui/editor/EditorView.js @@ -13,6 +13,7 @@ var EditorView = View.extend({ this.settings = new EditorSettings ({ parent: this }) this.mediaViewer = new MediaViewer ({ parent: this }) this.mediaUpload = new MediaUpload ({ parent: this }) + this.mediaEditor = new MediaEditor ({ parent: this }) this.wallpaperPicker = new WallpaperPicker ({ parent: this }) this.lightControl = new LightControl ({ parent: this }) }, @@ -39,4 +40,3 @@ var EditorView = View.extend({ } }) - diff --git a/public/assets/javascripts/ui/editor/MediaEditor.js b/public/assets/javascripts/ui/editor/MediaEditor.js new file mode 100644 index 0000000..8d6d517 --- /dev/null +++ b/public/assets/javascripts/ui/editor/MediaEditor.js @@ -0,0 +1,69 @@ + +var MediaEditor = FormView.extend({ + el: "#mediaEditor", + + events: { + }, + + initialize: function(opt){ + this.parent = opt.parent + this.__super__.initialize.call(this) + + this.$name = this.$("[name=name]") + this.$description = this.$("[name=description]") + this.$autoplay = this.$("[name=autoplay]") + + // image fields + this.$widthDimension = this.$("[name=width]") + this.$heightDimension = this.$("[name=height]") + this.$units = this.$("[name=units]") + + // video fields + this.$playButton = this.$(".play") + this.$loop = this.$("[name=loop]") + this.$mute = this.$("[name=mute]") + this.$keyframe = this.$("[name=keyframe]") + }, + + toggle: function(state) { + this.$el.toggleClass("active", state); + }, + + pick: function(scenery) { + this.$el.addClass("active") + + var media = scenery.media + + this.$name.val(media.title) + this.$description.val(media.description) + + switch (media.type) { + case "image": + this.$(".image").show() + this.$(".video").hide() + /* + this.$widthDimension + this.$heightDimension + this.$units + */ + + break + + case "youtube": + case "vimeo": + case "video": + this.$(".video").show() + this.$(".image").hide() + + /* + this.$loop + this.$mute + this.$keyframe + */ + + + break + } + }, + +}) diff --git a/public/assets/stylesheets/app.css b/public/assets/stylesheets/app.css index 684761c..7389810 100755 --- a/public/assets/stylesheets/app.css +++ b/public/assets/stylesheets/app.css @@ -1106,7 +1106,7 @@ input[type=range] { -webkit-appearance: none; -moz-appearance: none; background-color: black; - width: 200px; + width: 180px; height:3px; } @@ -1176,13 +1176,15 @@ input[type="range"]::-webkit-slider-thumb { #startpoint.active:hover { text-decoration:none; } -.settings input[type="text"], textarea{ +.settings input[type="text"] { border: 1px solid #000; font-size: 15px; padding: 5px; } .settings textarea { + border: 1px solid #000; + padding: 5px; font-size: 12px; width: 100%; max-height: 200px; @@ -1193,7 +1195,7 @@ input[type="range"]::-webkit-slider-thumb { border: 1px solid #000; } -.settings .setting{ +.settings .setting { margin-bottom:10px; } .setting.subButtons { @@ -1210,6 +1212,13 @@ input[type="range"]::-webkit-slider-thumb { .settings .setting:last-child{ margin-bottom:0px; } +.settings input[type="text"].number { + width: 60px; +} + +.setting label { + padding-right: 5px; +} button { padding: 8px; @@ -1372,23 +1381,23 @@ form li textarea { margin-top: 20px; } -.video { +.demo .video { height:80vh; min-height:300px; } -.video span { +.demo .video span { font-size:100px; color:white; cursor:pointer; } -.video span.videoTitle { +.demo .video span.videoTitle { font-size: 29px; font-weight: 300; padding: 3px 7px; } -.video span.icon-ios7-play-outline:hover { +.demo .video span.icon-ios7-play-outline:hover { color:lightgreen; } diff --git a/views/controls/editor/media-editor.ejs b/views/controls/editor/media-editor.ejs index 95aabb5..483fa72 100644 --- a/views/controls/editor/media-editor.ejs +++ b/views/controls/editor/media-editor.ejs @@ -1,4 +1,4 @@ -
    +
    @@ -15,24 +15,32 @@ - - - Autoplay - Loop - Mute - Initial Still +
    +
    + + + + + + +
    + +
    + Initial Still +
    +
    - Dimensions - Width - Height + Dimensions
    + +
    diff --git a/views/editor.ejs b/views/editor.ejs index a79eb9a..5d1e052 100755 --- a/views/editor.ejs +++ b/views/editor.ejs @@ -13,8 +13,8 @@
    [[ include controls/editor/toolbar ]] - [[ include controls/editor/video-toolbar ]] [[ include controls/editor/media-drawer ]] + [[ include controls/editor/media-editor ]] [[ include controls/editor/wallpaper ]] [[ include controls/editor/light-control ]] [[ include controls/editor/settings ]] diff --git a/views/partials/scripts.ejs b/views/partials/scripts.ejs index 6dd4480..40bb306 100644 --- a/views/partials/scripts.ejs +++ b/views/partials/scripts.ejs @@ -78,13 +78,14 @@ + + - -- cgit v1.2.3-70-g09d2 From 7ded9f91d3f3ab538425122be07f7436275b9b8d Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 14 Jul 2014 18:04:21 -0400 Subject: play button and stuff on the viewer --- .../javascripts/rectangles/engine/scenery/move.js | 2 +- .../assets/javascripts/rectangles/models/wall.js | 3 + public/assets/javascripts/ui/_router.js | 8 +- public/assets/javascripts/ui/editor/EditorView.js | 8 ++ public/assets/javascripts/ui/editor/MediaEditor.js | 9 ++- public/assets/javascripts/ui/reader/MediaPlayer.js | 92 ++++++++++++++++++++++ public/assets/javascripts/ui/reader/ReaderView.js | 15 +++- public/assets/stylesheets/app.css | 11 +-- views/controls/reader/about-media.ejs | 16 ---- views/controls/reader/media-player.ejs | 14 ++++ views/partials/scripts.ejs | 3 +- views/reader.ejs | 1 + 12 files changed, 150 insertions(+), 32 deletions(-) create mode 100644 public/assets/javascripts/ui/reader/MediaPlayer.js delete mode 100644 views/controls/reader/about-media.ejs create mode 100644 views/controls/reader/media-player.ejs (limited to 'views/partials/scripts.ejs') diff --git a/public/assets/javascripts/rectangles/engine/scenery/move.js b/public/assets/javascripts/rectangles/engine/scenery/move.js index 6229162..94a4e52 100644 --- a/public/assets/javascripts/rectangles/engine/scenery/move.js +++ b/public/assets/javascripts/rectangles/engine/scenery/move.js @@ -28,7 +28,7 @@ Scenery.move = function(base){ } // load the modal - app.router.editorView.mediaEditor.pick(base) + app.controller.pick(base) if (! (editor.permissions.move || editor.permissions.resize) ) { e.clickAccepted = false diff --git a/public/assets/javascripts/rectangles/models/wall.js b/public/assets/javascripts/rectangles/models/wall.js index b2a5b12..cc298c6 100644 --- a/public/assets/javascripts/rectangles/models/wall.js +++ b/public/assets/javascripts/rectangles/models/wall.js @@ -45,6 +45,9 @@ window.Wall = (function(){ if (Scenery.nextMedia) { Scenery.addNextToWall(base) } + else { + app.controller.hideExtras() + } } }) } diff --git a/public/assets/javascripts/ui/_router.js b/public/assets/javascripts/ui/_router.js index 886b8be..c0f35b6 100644 --- a/public/assets/javascripts/ui/_router.js +++ b/public/assets/javascripts/ui/_router.js @@ -61,7 +61,7 @@ var SiteRouter = Router.extend({ app.mode.builder = true app.launch() - this.builderView = new BuilderView() + this.builderView = app.controller = new BuilderView() this.builderView.load(name) }, @@ -92,7 +92,7 @@ var SiteRouter = Router.extend({ layout = slugify(layout) window.history.pushState(null, document.title, "/project/new/" + layout) - this.editorView = new EditorView() + this.editorView = app.controller = new EditorView() this.editorView.loadLayout(layout) }, @@ -109,7 +109,7 @@ var SiteRouter = Router.extend({ app.mode.editor = true app.launch() - this.editorView = new EditorView() + this.editorView = app.controller = new EditorView() this.editorView.load(name) }, @@ -117,7 +117,7 @@ var SiteRouter = Router.extend({ app.mode.editor = true app.launch() - this.readerView = new ReaderView() + this.readerView = app.controller = new ReaderView() this.readerView.load(name) }, diff --git a/public/assets/javascripts/ui/editor/EditorView.js b/public/assets/javascripts/ui/editor/EditorView.js index 322637e..4067c4d 100644 --- a/public/assets/javascripts/ui/editor/EditorView.js +++ b/public/assets/javascripts/ui/editor/EditorView.js @@ -37,6 +37,14 @@ var EditorView = View.extend({ readyLayout: function(data){ data.isNew = true this.ready(data) + }, + + pick: function(scenery){ + this.mediaEditor.pick(scenery) + }, + + hideExtras: function(){ + this.mediaEditor.hide() } }) diff --git a/public/assets/javascripts/ui/editor/MediaEditor.js b/public/assets/javascripts/ui/editor/MediaEditor.js index aea78aa..4e1132c 100644 --- a/public/assets/javascripts/ui/editor/MediaEditor.js +++ b/public/assets/javascripts/ui/editor/MediaEditor.js @@ -5,6 +5,7 @@ var MediaEditor = FormView.extend({ events: { "click .playButton": "togglePlaying", "mousedown [name=keyframe]": "stopPropagation", + "mousedown": "stopPropagation", "change [name=keyframe]": "seek", "change [name=autoplay]": "setAutoplay", "change [name=loop]": "setLoop", @@ -17,7 +18,6 @@ var MediaEditor = FormView.extend({ this.$name = this.$("[name=name]") this.$description = this.$("[name=description]") - this.$autoplay = this.$("[name=autoplay]") // image fields this.$widthDimension = this.$("[name=width]") @@ -79,7 +79,13 @@ var MediaEditor = FormView.extend({ break } + }, + hide: function(scenery){ + if (this.scenery) { + this.unbind() + } + this.toggle(false) }, seek: function(){ @@ -88,7 +94,6 @@ var MediaEditor = FormView.extend({ this.scenery.media.keyframe = n }, - setAutoplay: function(){ var checked = this.$autoplay.prop('checked') this.scenery.media.autoplay = checked diff --git a/public/assets/javascripts/ui/reader/MediaPlayer.js b/public/assets/javascripts/ui/reader/MediaPlayer.js new file mode 100644 index 0000000..74054b4 --- /dev/null +++ b/public/assets/javascripts/ui/reader/MediaPlayer.js @@ -0,0 +1,92 @@ + +var MediaPlayer = FormView.extend({ + el: "#mediaPlayer", + + events: { + "click .playButton": "togglePlaying", + "mousedown": "stopPropagation", + }, + + initialize: function(opt){ + this.parent = opt.parent + this.__super__.initialize.call(this) + + this.$name = this.$(".name") + this.$description = this.$(".description") + + // image fields + this.$dimensions = this.$(".dimensions") + + // video fields + this.$playButton = this.$(".playButton") + }, + + toggle: function(state) { + this.$el.toggleClass("active", state); + }, + + togglePlaying: function(){ + var state = this.scenery.toggle() + this.$playButton.toggleClass("playing", ! state) + }, + + pick: function(scenery) { + var media = scenery.media + + if (this.scenery) { + this.unbind() + } + if (media.type == "image") { + if ((! media.title || ! media.title.length) && (! media.description || ! media.description.length)) { + this.hide() + return + } + } + + this.bind(scenery) + this.$el.addClass("active") + + this.$name.html(media.title) + this.$description.html(media.description) + + switch (media.type) { + case "image": + this.$(".image").show() + this.$(".video").hide() + + this.$widthDimension.html( Number(media.widthDimension) || "" ) + this.$heightDimension.html( Number(media.heightDimension) || "" ) + this.$units.html( media.units || "cm" ) + + break + + case "youtube": + case "vimeo": + case "video": + this.$(".video").show() + this.$(".image").hide() + + this.$playButton.toggleClass("playing", ! this.scenery.paused()) + + break + } + }, + + hide: function(scenery){ + if (this.scenery) { + this.unbind() + } + this.toggle(false) + }, + + bind: function(scenery){ + this.scenery = scenery + this.scenery.mx.bound = true + }, + + unbind: function(){ + this.scenery.mx.bound = false + this.scenery = null + }, + +}) diff --git a/public/assets/javascripts/ui/reader/ReaderView.js b/public/assets/javascripts/ui/reader/ReaderView.js index bbdd437..a2c2983 100644 --- a/public/assets/javascripts/ui/reader/ReaderView.js +++ b/public/assets/javascripts/ui/reader/ReaderView.js @@ -8,6 +8,7 @@ var ReaderView = View.extend({ }, initialize: function(){ + this.mediaPlayer = new MediaPlayer ({ parent: this }) }, load: function(name){ @@ -27,8 +28,10 @@ var ReaderView = View.extend({ editor.permissions.clear() - // - + this.listen() + }, + + listen: function(){ var base = this $(window).on('message', function(event){ @@ -55,6 +58,14 @@ var ReaderView = View.extend({ if (this.spinning) { scene.camera.rotationY -= 1/180 } + }, + + pick: function(scenery){ + this.mediaPlayer.pick(scenery) + }, + + hideExtras: function(){ + this.mediaPlayer.hide() } }) diff --git a/public/assets/stylesheets/app.css b/public/assets/stylesheets/app.css index 500f444..215bbab 100755 --- a/public/assets/stylesheets/app.css +++ b/public/assets/stylesheets/app.css @@ -1220,23 +1220,23 @@ input[type="range"]::-webkit-slider-thumb { padding-right: 5px; } -.setting .playButton { +.playButton { color: white; background: black; border-radius: 50px; padding: 6px 7px 5px; cursor: pointer; } -.setting .playButton .icon-play { +.playButton .icon-play { display: inline; } -.setting .playButton.playing .icon-play { +.playButton.playing .icon-play { display: none; } -.setting .playButton .icon-pause { +.playButton .icon-pause { display: none; } -.setting .playButton.playing .icon-pause { +.playButton.playing .icon-pause { display: inline; } @@ -1507,6 +1507,7 @@ form li textarea { bottom: 10px; padding-right:10px; background:rgba(255,255,255,0.95); + z-index: 2; } .share h2 { diff --git a/views/controls/reader/about-media.ejs b/views/controls/reader/about-media.ejs deleted file mode 100644 index c6365ad..0000000 --- a/views/controls/reader/about-media.ejs +++ /dev/null @@ -1,16 +0,0 @@ -
    - -
    -
    -
    -
    - -
    - - - - - -
    - -
    diff --git a/views/controls/reader/media-player.ejs b/views/controls/reader/media-player.ejs new file mode 100644 index 0000000..71f69a8 --- /dev/null +++ b/views/controls/reader/media-player.ejs @@ -0,0 +1,14 @@ +
    + + + + + + + + +
    +
    +
    + +
    diff --git a/views/partials/scripts.ejs b/views/partials/scripts.ejs index 40bb306..47a027e 100644 --- a/views/partials/scripts.ejs +++ b/views/partials/scripts.ejs @@ -38,8 +38,6 @@ - - @@ -88,6 +86,7 @@ + diff --git a/views/reader.ejs b/views/reader.ejs index c389431..44fb2dd 100644 --- a/views/reader.ejs +++ b/views/reader.ejs @@ -13,6 +13,7 @@
    [[ include controls/reader/about-room ]] + [[ include controls/reader/media-player ]]
    -- cgit v1.2.3-70-g09d2 From d81c96616859a57d5d5d63a6ae7b1492a5c4974a Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 16 Jul 2014 16:30:33 -0400 Subject: display room dimensions --- .../javascripts/rectangles/engine/map/ui_editor.js | 8 ++- .../javascripts/rectangles/engine/rooms/_rooms.js | 1 + .../assets/javascripts/ui/builder/BuilderInfo.js | 70 ++++++++++++++++++++++ .../javascripts/ui/builder/BuilderSettings.js | 5 +- .../assets/javascripts/ui/builder/BuilderView.js | 4 ++ .../assets/javascripts/ui/editor/EditorSettings.js | 1 + public/assets/javascripts/ui/editor/MediaEditor.js | 1 + public/assets/stylesheets/app.css | 11 ++++ server/lib/schemas/Layout.js | 1 + views/controls/builder/info.ejs | 7 ++- views/partials/scripts.ejs | 3 +- 11 files changed, 107 insertions(+), 5 deletions(-) create mode 100644 public/assets/javascripts/ui/builder/BuilderInfo.js (limited to 'views/partials/scripts.ejs') diff --git a/public/assets/javascripts/rectangles/engine/map/ui_editor.js b/public/assets/javascripts/rectangles/engine/map/ui_editor.js index ea7a356..577ea32 100644 --- a/public/assets/javascripts/rectangles/engine/map/ui_editor.js +++ b/public/assets/javascripts/rectangles/engine/map/ui_editor.js @@ -53,16 +53,21 @@ Map.UI.Editor = function(map){ if (intersects.length && base.permissions.destroy) { base.mouse.down = false Rooms.remove(intersects[0]) + app.tube("builder-destroy-room", intersects[0]) return } else if (intersects.length && (base.permissions.move || base.permissions.resize)) { base.dragging = intersects[0] base.resizing = base.permissions.resize && base.dragging.rect.nearEdge(cursor.x.a, cursor.y.a, resize_margin / map.zoom) base.dragging.rect.translation.sides = base.resizing + app.tube("builder-pick-room", intersects[0]) } else if (base.permissions.create) { base.creating = true } + else if (intersects.length) { + app.tube("builder-pick-room", intersects[0]) + } if (e.shiftKey && base.dragging) { base.dragging.rect.quantize(10/map.zoom) @@ -109,7 +114,8 @@ Map.UI.Editor = function(map){ if (cursor.height() > side_min && cursor.width() > side_min) { cursor.x.abs().quantize(1) cursor.y.abs().quantize(1) - Rooms.add_with_rect( cursor ) + var room = Rooms.add_with_rect( cursor ) + app.tube("builder-pick-room", room) } } diff --git a/public/assets/javascripts/rectangles/engine/rooms/_rooms.js b/public/assets/javascripts/rectangles/engine/rooms/_rooms.js index 48931e9..e0033e3 100644 --- a/public/assets/javascripts/rectangles/engine/rooms/_rooms.js +++ b/public/assets/javascripts/rectangles/engine/rooms/_rooms.js @@ -26,6 +26,7 @@ var Rooms = new function(){ height: 500 }) base.add(room) + return room } base.remove = function(room){ diff --git a/public/assets/javascripts/ui/builder/BuilderInfo.js b/public/assets/javascripts/ui/builder/BuilderInfo.js new file mode 100644 index 0000000..53a122d --- /dev/null +++ b/public/assets/javascripts/ui/builder/BuilderInfo.js @@ -0,0 +1,70 @@ + +var BuilderInfo = View.extend({ + el: "#builderInfo", + + events: { + "keydown": 'stopPropagation', + "change [name=x]": 'changePosition', + "change [name=z]": 'changePosition', + "change [name=width]": 'changeDimensions', + "change [name=depth]": 'changeDimensions', + "change [name=height]": 'changeDimensions', + "change [name=units]": 'changeUnits', + "change [name=resolution]": 'changeResolution', + "change [name=camera-height]": 'changeCameraHeight', + }, + + initialize: function(opt){ + this.parent = opt.parent + this.$x = this.$("[name=x]") + this.$z = this.$("[name=z]") + this.$width = this.$("[name=width]") + this.$depth = this.$("[name=depth]") + this.$height = this.$("[name=height]") + this.$units = this.$("[name=units]") + this.$resolution = this.$("[name=resolution]") + this.$cameraHeight = this.$("[name=camera-height]") + app.on("builder-pick-room", this.pick.bind(this)) + app.on("builder-destroy-room", this.destroy.bind(this)) + }, + + toggle: function(state){ + this.$el.toggleClass("active", state) + }, + + show: function(){ + this.toggle(true) + }, + + hide: function(){ + this.toggle(false) + }, + + room: null, + + pick: function(room){ + this.room = room + this.$width.val( room.rect.x.length() ) + this.$depth.val( room.rect.y.length() ) + this.$height.val( room.height ) + this.$x.val( room.rect.x.a ) + this.$z.val( room.rect.y.a ) + + console.log(room) + }, + + destroy: function(room){ + this.room = null + this.hide() + }, + + changeDimensions: function(){ + }, + + changeUnits: function(){ + }, + + changeCameraHeight: function(){ + }, + +}) diff --git a/public/assets/javascripts/ui/builder/BuilderSettings.js b/public/assets/javascripts/ui/builder/BuilderSettings.js index 6006868..c551f95 100644 --- a/public/assets/javascripts/ui/builder/BuilderSettings.js +++ b/public/assets/javascripts/ui/builder/BuilderSettings.js @@ -7,6 +7,7 @@ var BuilderSettings = FormView.extend({ destroyAction: "/api/layout/destroy", events: { + "keydown": 'stopPropagation', "keydown [name=name]": 'enterSubmit', "click [data-role='save-layout']": 'save', "click [data-role='clone-layout']": 'clone', @@ -69,8 +70,8 @@ var BuilderSettings = FormView.extend({ }.bind(this)) }, - toggle: function(){ - this.$el.toggleClass("active") + toggle: function(state){ + this.$el.toggleClass("active", state) }, enterSubmit: function (e) { diff --git a/public/assets/javascripts/ui/builder/BuilderView.js b/public/assets/javascripts/ui/builder/BuilderView.js index a83bf43..7a92738 100644 --- a/public/assets/javascripts/ui/builder/BuilderView.js +++ b/public/assets/javascripts/ui/builder/BuilderView.js @@ -8,6 +8,7 @@ var BuilderView = View.extend({ }, initialize: function(){ + this.info = new BuilderInfo ({ parent: this }) this.toolbar = new BuilderToolbar ({ parent: this }) this.settings = new BuilderSettings ({ parent: this }) }, @@ -26,5 +27,8 @@ var BuilderView = View.extend({ ready: function(data){ this.settings.load(data) }, + + hideExtras: function(){ + } }) diff --git a/public/assets/javascripts/ui/editor/EditorSettings.js b/public/assets/javascripts/ui/editor/EditorSettings.js index 887c894..13a6f60 100644 --- a/public/assets/javascripts/ui/editor/EditorSettings.js +++ b/public/assets/javascripts/ui/editor/EditorSettings.js @@ -7,6 +7,7 @@ var EditorSettings = FormView.extend({ destroyAction: "/api/project/destroy", events: { + "keydown": 'stopPropagation', "keydown [name=name]": 'enterSubmit', "click [data-role='save-project']": 'save', "click [data-role='clone-project']": 'clone', diff --git a/public/assets/javascripts/ui/editor/MediaEditor.js b/public/assets/javascripts/ui/editor/MediaEditor.js index f9eaad5..a075e6b 100644 --- a/public/assets/javascripts/ui/editor/MediaEditor.js +++ b/public/assets/javascripts/ui/editor/MediaEditor.js @@ -3,6 +3,7 @@ var MediaEditor = FormView.extend({ el: "#mediaEditor", events: { + "keydown": 'stopPropagation', "click [data-role=play-media]": "togglePaused", "mousedown [name=keyframe]": "stopPropagation", "mousedown": "stopPropagation", diff --git a/public/assets/stylesheets/app.css b/public/assets/stylesheets/app.css index 2e3358a..3e6dced 100755 --- a/public/assets/stylesheets/app.css +++ b/public/assets/stylesheets/app.css @@ -1247,6 +1247,17 @@ input[type="range"]::-webkit-slider-thumb { position: relative; top: 5px; } +.setting.number.halflines { + height: 30px; +} +.setting.number.halflines input[type=text] { + float: left; + width: 50px; +} +.setting.number.halflines label:nth-of-type(2) { + text-align: center; +} + .setting.number input[type=text] { width: 150px; } diff --git a/server/lib/schemas/Layout.js b/server/lib/schemas/Layout.js index b096b85..33a5262 100644 --- a/server/lib/schemas/Layout.js +++ b/server/lib/schemas/Layout.js @@ -25,6 +25,7 @@ var LayoutSchema = new mongoose.Schema({ }, rooms: [mongoose.Schema.Types.Mixed], startPosition: mongoose.Schema.Types.Mixed, + cameraHeight: { type: Number, default: 180 }, user_id: { type: mongoose.Schema.ObjectId, index: true }, created_at: { type: Date }, updated_at: { type: Date }, diff --git a/views/controls/builder/info.ejs b/views/controls/builder/info.ejs index af0a76d..2cc8132 100644 --- a/views/controls/builder/info.ejs +++ b/views/controls/builder/info.ejs @@ -11,6 +11,12 @@
    +
    + + + + +
    @@ -29,7 +35,6 @@
    -
    diff --git a/views/partials/scripts.ejs b/views/partials/scripts.ejs index 47a027e..2173cd5 100644 --- a/views/partials/scripts.ejs +++ b/views/partials/scripts.ejs @@ -72,9 +72,10 @@ + - + -- cgit v1.2.3-70-g09d2