From 742f4cc410bb04421800d7462f81fc64c59aa0bc Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 30 Sep 2014 12:36:42 -0400 Subject: tracing menu appearing/disappearing logic ; set title from filename --- public/assets/javascripts/util.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'public/assets/javascripts/util.js') diff --git a/public/assets/javascripts/util.js b/public/assets/javascripts/util.js index 7812a4d..5a89c48 100644 --- a/public/assets/javascripts/util.js +++ b/public/assets/javascripts/util.js @@ -173,6 +173,10 @@ function invert_hash (h) { for (var i in h) { if (h.hasOwnProperty(i)) k[h[i]] = i } return k } +function filenameFromUrl (url) { + var partz = url.split( "/" ) + return partz[partz.length-1].split(".")[0] +} function bitcount(v) { v = v - ((v >>> 1) & 0x55555555); -- cgit v1.2.3-70-g09d2 From 7afac43f11d1ccae6f3b8d1febcd293db11bd2b7 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 1 Oct 2014 15:42:21 -0400 Subject: randomly place images on the walls --- .../rectangles/engine/scenery/randomize.js | 77 ++++++++++++++++++++++ .../javascripts/rectangles/models/surface.js | 4 +- public/assets/javascripts/ui/editor/MediaViewer.js | 21 ++++-- public/assets/javascripts/util.js | 5 +- views/partials/scripts.ejs | 1 + 5 files changed, 97 insertions(+), 11 deletions(-) create mode 100644 public/assets/javascripts/rectangles/engine/scenery/randomize.js (limited to 'public/assets/javascripts/util.js') diff --git a/public/assets/javascripts/rectangles/engine/scenery/randomize.js b/public/assets/javascripts/rectangles/engine/scenery/randomize.js new file mode 100644 index 0000000..4f1144a --- /dev/null +++ b/public/assets/javascripts/rectangles/engine/scenery/randomize.js @@ -0,0 +1,77 @@ +/* + // get the list of media we want to place + var media_data = $(".mediaContainer").toArray().map(function(el){ + return $(el).data("media") + }) + Scenery.randomize( media_data ) +*/ + +Scenery.randomize = function (media_data) { + var media_list = media_data.map(function(media){ + var width, height + if (media.width > media.height) { + width = Math.min(300, media.width) + height = media.height/media.width * width + } + else { + height = Math.min(300, media.height) + width = media.width/media.height * height + } + return { + dimensions: new vec2( width, height ), + media: media, + } + }) + + // get a list of all walls + var walls = {} + Walls.forEach(function(wall){ + walls[wall.id] = wall + }) + + // remove the walls that already have stuff on them + Scenery.forEach(function(scenery){ + delete walls[scenery.wall.id] + }) + + var wall_ids = _.keys(walls) + if (! wall_ids.length) { + return + } + + // randomize walls + shuffle(wall_ids) + + // assign each of the media to the walls, until we run out of either + media_list.some(function(media){ + if (wall_ids.length == 0) { + return true + } + + var i, fits = -1 + + for (i = 0; i < wall_ids.length; i++) { + if (walls[wall_ids[i]].surface.fits(media.dimensions)) { + // walls[wall_ids[i]] + fits = i + break + } + } + + if (fits != -1) { + var wall = walls[wall_ids[fits]] + wall_ids.splice(fits, 1) + + Scenery.add({ + media: media.media, + wall: wall, + index: 0, + }) + } + else { + // artwork won't fit anywhere?? + } + + return false + }) +} \ No newline at end of file diff --git a/public/assets/javascripts/rectangles/models/surface.js b/public/assets/javascripts/rectangles/models/surface.js index 53977c8..c85682a 100644 --- a/public/assets/javascripts/rectangles/models/surface.js +++ b/public/assets/javascripts/rectangles/models/surface.js @@ -36,7 +36,7 @@ Surface.prototype.fits = function(v){ var faces = this.faces var scratch - if (this.bounds.x.b < v.a || this.bounds.y.b < v.b) { + if (this.bounds.width() < v.a || this.bounds.height() < v.b) { return null } for (var i = 0; i < faces.length; i++) { @@ -46,7 +46,7 @@ } scratch = new Rect (0,0,0,0) for (var i = 0; i < faces.length; i++) { - if (faces[i].y.length() < v.b) { + if (faces[i].height() < v.b) { continue } scratch.x.a = faces[i].x.a diff --git a/public/assets/javascripts/ui/editor/MediaViewer.js b/public/assets/javascripts/ui/editor/MediaViewer.js index e2ed341..b51d8f2 100644 --- a/public/assets/javascripts/ui/editor/MediaViewer.js +++ b/public/assets/javascripts/ui/editor/MediaViewer.js @@ -3,6 +3,7 @@ var MediaViewer = ModalView.extend({ el: ".mediaDrawer.mediaViewer", destroyAction: "/api/media/destroy", usesFileUpload: true, + loaded: false, events: { 'click .foundToggle': "foundToggle", @@ -19,7 +20,7 @@ var MediaViewer = ModalView.extend({ this.$foundMedia = this.$(".foundMedia") this.$foundToggle = this.$(".foundToggle") this.$deleteMedia = this.$("#deleteMedia") - }, + }, foundToggle: function(){ this.$foundMedia.addClass("active"); @@ -52,9 +53,7 @@ var MediaViewer = ModalView.extend({ }, load: function(){ - $.get("/api/media/user", function(data){ - this.populate() - }.bind(this)) + $.get("/api/media/user", this.populate.bind(this)) }, loadTrending: function(){ @@ -90,11 +89,20 @@ var MediaViewer = ModalView.extend({ if (img.complete && ! loaded) { img.onload() } }.bind(this)) }, + + randomize: function(){ + var media_data = $(".mediaContainer").toArray().map(function(el){ + return $(el).data("media") + }) + Scenery.randomize( media_data ) + }, populate: function(data){ this.loaded = true if (data && data.length) { - data.forEach(this.add.bind(this)) + data.forEach(function(media){ + this.add(media, this.$myMedia) + }.bind(this)) this.$deleteMedia.show() } else { @@ -104,7 +112,6 @@ var MediaViewer = ModalView.extend({ }, add: function(media, $container){ - $container = $container || this.$myMedia var image = new Image () var $span = $("") $span.addClass("mediaContainer") @@ -131,7 +138,7 @@ var MediaViewer = ModalView.extend({ $span.data("media", media) $span.append(image) - $container.prepend($span) + $container.prepend($span) }, deleteIsArmed: false, diff --git a/public/assets/javascripts/util.js b/public/assets/javascripts/util.js index 5a89c48..76c5c7b 100644 --- a/public/assets/javascripts/util.js +++ b/public/assets/javascripts/util.js @@ -92,9 +92,10 @@ function smoothstep(min,max,n){ } function shuffle(a){ + var r, swap for (var i = a.length; i > 0; i--){ - var r = randint(i) - var swap = a[i-1] + r = randint(i) + swap = a[i-1] a[i-1] = a[r] a[r] = swap } diff --git a/views/partials/scripts.ejs b/views/partials/scripts.ejs index 11512b9..349d0d0 100644 --- a/views/partials/scripts.ejs +++ b/views/partials/scripts.ejs @@ -51,6 +51,7 @@ + -- cgit v1.2.3-70-g09d2 From 37851cbd12dcb17be77265164876184019d34602 Mon Sep 17 00:00:00 2001 From: Julie Lala Date: Thu, 16 Oct 2014 03:09:22 -0400 Subject: .. and floor and ceiling --- .../javascripts/rectangles/engine/rooms/_walls.js | 28 ++++++++++++++++++++-- .../assets/javascripts/rectangles/models/floor.js | 5 ++-- public/assets/javascripts/ui/editor/Presets.js | 25 ++++++++++++++++--- public/assets/javascripts/util.js | 3 ++- public/assets/stylesheets/app.css | 7 ++++++ views/controls/editor/presets.ejs | 1 + 6 files changed, 60 insertions(+), 9 deletions(-) (limited to 'public/assets/javascripts/util.js') diff --git a/public/assets/javascripts/rectangles/engine/rooms/_walls.js b/public/assets/javascripts/rectangles/engine/rooms/_walls.js index 5c16ce6..fe5913d 100644 --- a/public/assets/javascripts/rectangles/engine/rooms/_walls.js +++ b/public/assets/javascripts/rectangles/engine/rooms/_walls.js @@ -160,7 +160,19 @@ }.bind(this) img.src = background.src img.complete && img.onload() - } + }, + floor: function(background){ + Walls.floors.forEach(function(floor){ + if (floor.ceiling) return + floor.wallpaper(background) + }) + }, + ceiling: function(background){ + Walls.floors.forEach(function(floor){ + if (! floor.ceiling) return + floor.wallpaper(background) + }) + }, } base.clearWallpaper = { @@ -168,7 +180,19 @@ Walls.list.forEach(function(wall){ wall.wallpaper("none") }) - } + }, + floor: function(){ + Walls.floors.forEach(function(floor){ + if (floor.ceiling) return + wall.wallpaper("none") + }) + }, + ceiling: function(){ + Walls.floors.forEach(function(floor){ + if (! floor.ceiling) return + wall.wallpaper("none") + }) + }, } base.setColor = { diff --git a/public/assets/javascripts/rectangles/models/floor.js b/public/assets/javascripts/rectangles/models/floor.js index 7ed52a1..9838232 100644 --- a/public/assets/javascripts/rectangles/models/floor.js +++ b/public/assets/javascripts/rectangles/models/floor.js @@ -15,6 +15,7 @@ var Floor = function(opt){ this.id = opt.id this.side = opt.side + this.ceiling = opt.side & CEILING this.mx = opt.mx } @@ -114,8 +115,6 @@ this.background.x = background.x || this.background.x this.background.y = background.y || this.background.y this.background.scale = background.scale || this.background.scale || 1 - - var shouldFlip = this.side & (CEILING) var mx, dx, dy var w = Math.round( this.backgroundImage.naturalWidth * this.background.scale ) @@ -125,7 +124,7 @@ var region = mx.rect - if (shouldFlip) { + if (this.ceiling) { dx = Math.round( this.background.x - region.x.a ) dy = Math.round( this.background.y - region.y.a ) } diff --git a/public/assets/javascripts/ui/editor/Presets.js b/public/assets/javascripts/ui/editor/Presets.js index c34c826..cde2fdf 100644 --- a/public/assets/javascripts/ui/editor/Presets.js +++ b/public/assets/javascripts/ui/editor/Presets.js @@ -5,6 +5,8 @@ var Presets = View.extend({ "mousedown": "stopPropagation", "click .presets span": "selectPreset", "click .swatches span": "selectColor", + "change .url": "tileWalls", + "keydown .url": "enterSetUrl", }, presets: { @@ -21,7 +23,7 @@ var Presets = View.extend({ ceiling: [159,163,157], background: [109,116,106], }, - "p.funk": { + "p.Funk": { wall: [255,63,78], outline: [255,246,0], floor: [255,255,0], @@ -34,7 +36,7 @@ var Presets = View.extend({ ceiling: [0,0,0], }, matrix: { - wall: { src: "http://bibleway.biz/images/Matrix1.gif", scale: 4.0, color: [0,0,0] }, + wall: { src: "http://dump.fm/images/20130225/1361818675427-dumpfm-melipone-matrixremixtransfast.gif", scale: 4.0, color: [0,0,0] }, outline: [0,0,0], floor: [10,15,10], ceiling: [0,0,0], @@ -43,7 +45,9 @@ var Presets = View.extend({ initialize: function(opt){ this.parent = opt.parent - + + this.$url = this.$(".url") + this.$presets = this.$(".presets") _.keys(this.presets).forEach(function(name){ var $swatch = $("") @@ -99,4 +103,19 @@ var Presets = View.extend({ this.lastPreset = preset }, + tileWalls: function(){ + var url = this.$url.sanitize() + if (url.length && url.indexOf("http://") == 0) { + Walls.setWallpaper.wall({ src: url }) + Walls.setWallpaper.floor({ src: url }) + Walls.setWallpaper.ceiling({ src: url }) + } + }, + enterSetUrl: function (e) { + e.stopPropagation() + if (e.keyCode == 13) { + setTimeout(this.tileWalls.bind(this), 100) + } + }, + }) \ No newline at end of file diff --git a/public/assets/javascripts/util.js b/public/assets/javascripts/util.js index 76c5c7b..367e20e 100644 --- a/public/assets/javascripts/util.js +++ b/public/assets/javascripts/util.js @@ -4,10 +4,11 @@ if (window.$) { $.fn.string = function() { return trim($(this).val()) } $.fn.enable = function() { return $(this).attr("disabled",null) } $.fn.disable = function() { return $(this).attr("disabled","disabled") } + $.fn.sanitize = function(s) { return trim(sanitize($(this).val())) } $.fn.htmlSafe = function(s) { return $(this).html(sanitize(s)) } } -function trim(s){ return s.replace(/^\s+/,"").replace(/\s+$/,"") } +function trim (s){ return s.replace(/^\s+/,"").replace(/\s+$/,"") } function sanitize (s){ return (s || "").replace(new RegExp("[<>&]", 'g'), "") } function capitalize (s){ return s.split(" ").map(capitalizeWord).join(" ") } function capitalizeWord (s){ return s.charAt(0).toUpperCase() + s.slice(1) } diff --git a/public/assets/stylesheets/app.css b/public/assets/stylesheets/app.css index bd2d42c..a711baa 100755 --- a/public/assets/stylesheets/app.css +++ b/public/assets/stylesheets/app.css @@ -1698,6 +1698,13 @@ input[type="range"]::-webkit-slider-thumb { width: 100%; color: #555; } +#presets .url { + margin: 4px 0; + padding: 2px; + font-size: 12px; + border: 1px black solid; + width: 100%; +} .color-swatches span:nth-child(1),.color-swatches span:nth-child(2){ margin-bottom:5px; diff --git a/views/controls/editor/presets.ejs b/views/controls/editor/presets.ejs index 04b1cf1..02e9d42 100644 --- a/views/controls/editor/presets.ejs +++ b/views/controls/editor/presets.ejs @@ -2,4 +2,5 @@

Preset Styles

+ -- cgit v1.2.3-70-g09d2 From d9a6199f75d324c7b644beb1c732680a67ab8047 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 17 Oct 2014 13:37:23 -0400 Subject: layout editor stuff --- .../assets/javascripts/rectangles/models/floor.js | 34 ++++++++++++- public/assets/javascripts/ui/_router.js | 1 - .../assets/javascripts/ui/builder/BuilderInfo.js | 13 ++++- public/assets/javascripts/ui/editor/Presets.js | 11 ++--- public/assets/javascripts/ui/lib/UploadView.js | 4 +- public/assets/javascripts/util.js | 55 ++++++++++++++++++++++ public/assets/stylesheets/app.css | 22 ++++++--- views/controls/editor/media-drawer.ejs | 2 +- views/controls/editor/wallpaper.ejs | 17 ++----- 9 files changed, 125 insertions(+), 34 deletions(-) (limited to 'public/assets/javascripts/util.js') diff --git a/public/assets/javascripts/rectangles/models/floor.js b/public/assets/javascripts/rectangles/models/floor.js index a144ecd..3f452e1 100644 --- a/public/assets/javascripts/rectangles/models/floor.js +++ b/public/assets/javascripts/rectangles/models/floor.js @@ -36,8 +36,40 @@ this.mx.forEach(function(mx, index){ $(mx.el).bind({ + contextmenu: function(e){ + if (! (e.ctrlKey || e.metaKey || e.shiftKey) ) { + e.preventDefault() + } + if (Scenery.nextMedia) { + e.preventDefault() + Scenery.nextMedia = null + app.tube('cancel-scenery') + } + else if (Scenery.nextWallpaper) { + e.preventDefault() + Scenery.nextWallpaper = null + app.tube('cancel-wallpaper') + } + }, + mousedown: function(e){ - if (Scenery.nextWallpaper) { + + // right-click + if (e.which == 3) { + if (Scenery.nextMedia) { + e.preventDefault() + Scenery.nextMedia = null + app.tube('cancel-scenery') + } + else if (Scenery.nextWallpaper) { + e.preventDefault() + Scenery.nextWallpaper = null + app.tube('cancel-wallpaper') + } + return + } + + if (Scenery.nextWallpaper) { var oldState = base.serialize() base.wallpaper(Scenery.nextWallpaper) // Scenery.nextWallpaper = null diff --git a/public/assets/javascripts/ui/_router.js b/public/assets/javascripts/ui/_router.js index 794079e..bda0960 100644 --- a/public/assets/javascripts/ui/_router.js +++ b/public/assets/javascripts/ui/_router.js @@ -212,7 +212,6 @@ var SiteRouter = Router.extend({ // this.documentModal.destroy(name) }, - testWallpaper: function(e){ var content = document.getElementById("content") content.style.width = "680px" diff --git a/public/assets/javascripts/ui/builder/BuilderInfo.js b/public/assets/javascripts/ui/builder/BuilderInfo.js index 67834e7..c708275 100644 --- a/public/assets/javascripts/ui/builder/BuilderInfo.js +++ b/public/assets/javascripts/ui/builder/BuilderInfo.js @@ -10,8 +10,10 @@ var BuilderInfo = View.extend({ "change [name=width]": 'changeWidth', "change [name=depth]": 'changeDepth', "change [name=height]": 'changeHeight', + "keydown [name=width]": 'enterWidth', + "keydown [name=depth]": 'enterDepth', + "keydown [name=height]": 'enterHeight', "change [name=units]": 'changeUnits', - "change [name=resolution]": 'changeResolution', "change [name=viewHeight]": 'changeViewHeight', "click [data-role=destroy-room]": 'destroy', }, @@ -85,16 +87,25 @@ var BuilderInfo = View.extend({ this.hide() }, + enterWidth: function(e){ + if (e.keyCode == 13) this.changeWidth(e) + }, changeWidth: function(e){ e.stopPropagation() this.room.rect.x.setLength( this.$width.unitVal() ) Rooms.rebuild() }, + enterDepth: function(e){ + if (e.keyCode == 13) this.changeDepth(e) + }, changeDepth: function(e){ e.stopPropagation() this.room.rect.y.setLength( this.$depth.unitVal() ) Rooms.rebuild() }, + enterHeight: function(e){ + if (e.keyCode == 13) this.changeHeight(e) + }, changeHeight: function(e){ e.stopPropagation() this.room.height = this.$height.unitVal() diff --git a/public/assets/javascripts/ui/editor/Presets.js b/public/assets/javascripts/ui/editor/Presets.js index be86af3..ab311ef 100644 --- a/public/assets/javascripts/ui/editor/Presets.js +++ b/public/assets/javascripts/ui/editor/Presets.js @@ -84,15 +84,12 @@ var Presets = View.extend({ this.parent.colorControl.modes.forEach(function(mode){ if (! preset[mode].length) { Walls.setWallpaper[mode](preset[mode]) - Walls.setColor[mode](preset[mode].color) } else { - if (preset[mode].length) { - Walls.clearWallpaper[mode]() - } - Walls.setColor[mode](preset[mode]) - this.parent.colorControl.$swatch[ mode ].css("background-color", rgb_string(preset[mode])) - } + Walls.clearWallpaper[mode]() + } + Walls.setColor[mode](preset[mode]) + this.parent.colorControl.$swatch[ mode ].css("background-color", rgb_string(preset[mode])) }.bind(this)) this.parent.colorControl.setMode(preset.wall.color ? "wall" : "floor") Walls.setBodyColor() diff --git a/public/assets/javascripts/ui/lib/UploadView.js b/public/assets/javascripts/ui/lib/UploadView.js index efaa8c9..2d2c2c7 100644 --- a/public/assets/javascripts/ui/lib/UploadView.js +++ b/public/assets/javascripts/ui/lib/UploadView.js @@ -4,12 +4,12 @@ var UploadView = View.extend({ // define uploadAction events: { - "change .file": "handleFileSelect", + "change [type=file]": "handleFileSelect", "submit form": "preventDefault", }, initialize: function(){ - this.$file = this.$(".file") + this.$file = this.$("[type=file]") this.$upload = this.$(".upload-icon") }, diff --git a/public/assets/javascripts/util.js b/public/assets/javascripts/util.js index 367e20e..2fa994a 100644 --- a/public/assets/javascripts/util.js +++ b/public/assets/javascripts/util.js @@ -185,3 +185,58 @@ function bitcount(v) { v = (v & 0x33333333) + ((v >>> 2) & 0x33333333); return ((v + (v >>> 4) & 0xF0F0F0F) * 0x1010101) >>> 24; } + +// Function.bind polyfill +if (!Function.prototype.bind) { + Function.prototype.bind = function(oThis) { + if (typeof this !== 'function') { + // closest thing possible to the ECMAScript 5 + // internal IsCallable function + throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable'); + } + + var aArgs = Array.prototype.slice.call(arguments, 1), + fToBind = this, + fNOP = function() {}, + fBound = function() { + return fToBind.apply(this instanceof fNOP && oThis + ? this + : oThis, + aArgs.concat(Array.prototype.slice.call(arguments))); + }; + + fNOP.prototype = this.prototype; + fBound.prototype = new fNOP(); + + return fBound; + }; +} + +// rAF polyfill +(function() { + var lastTime = 0; + var vendors = ['ms', 'moz', 'webkit', 'o']; + for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { + window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; + window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] + || window[vendors[x]+'CancelRequestAnimationFrame']; + } + + if (!window.requestAnimationFrame) + window.requestAnimationFrame = function(callback, element) { + var currTime = new Date().getTime(); + var timeToCall = Math.max(0, 16 - (currTime - lastTime)); + var id = window.setTimeout(function() { callback(currTime + timeToCall); }, + timeToCall); + lastTime = currTime + timeToCall; + return id; + }; + + if (!window.cancelAnimationFrame) + window.cancelAnimationFrame = function(id) { + clearTimeout(id); + }; +}()); + + + diff --git a/public/assets/stylesheets/app.css b/public/assets/stylesheets/app.css index 28eabd9..9df1573 100755 --- a/public/assets/stylesheets/app.css +++ b/public/assets/stylesheets/app.css @@ -1507,9 +1507,12 @@ border-left: 1px solid black; .toolButton { border: 1px solid; - display: inline-block; - width: 100%; - margin-top: 5px; + position: relative; + display: block; + float: right; + margin-left: 3px; + width: 35px; + height: 35px; font-size: 14px; font-weight: 300; } @@ -1524,9 +1527,9 @@ border-left: 1px solid black; } .wallpaper form { position: relative; - padding: 2px 0 0 0; font-size: 14px; font-weight: 300; + overflow: hidden; } .toolButton:hover { background:black; @@ -1550,14 +1553,19 @@ border-left: 1px solid black; .wallpaper .wallpaperRemove:hover img { -webkit-filter:invert(100%); } +.wallpaperUpload .upload-icon { + margin: 0 8px; +} .wallpaperUpload .upload-icon.uploading { } .wallpaperUpload .upload-icon.uploading:before { content: ' ' !important; background-image: url("/assets/img/loader.gif"); background-repeat: no-repeat; - width: 40px; - height: 40px; + background-position: center; + width: 100%; + height: 100%; + position:absolute;top:0;left:0; } .wallpaperUpload input[type="text"]{ border: 1px solid #ccc; @@ -1575,7 +1583,7 @@ border-left: 1px solid black; top: 0; left: 0; background: blue; - height: 28px; + height: 100%; width: 100%; opacity: 0; cursor: pointer; diff --git a/views/controls/editor/media-drawer.ejs b/views/controls/editor/media-drawer.ejs index d1e2c99..1404d86 100644 --- a/views/controls/editor/media-drawer.ejs +++ b/views/controls/editor/media-drawer.ejs @@ -26,7 +26,7 @@

Upload File - +
~ or ~
diff --git a/views/controls/editor/wallpaper.ejs b/views/controls/editor/wallpaper.ejs index ed175ae..69a60ec 100644 --- a/views/controls/editor/wallpaper.ejs +++ b/views/controls/editor/wallpaper.ejs @@ -9,31 +9,20 @@
+ +
- - +
-
-
- - -
-- cgit v1.2.3-70-g09d2 From 5a35d057453f82aad1097f1a90e9bdd341018a17 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 7 Nov 2014 13:22:36 -0500 Subject: embed modal --- public/assets/javascripts/ui/reader/EmbedView.js | 50 ++++++++++++++++++++++++ public/assets/javascripts/ui/reader/ShareView.js | 2 + public/assets/javascripts/util.js | 13 ++++++ public/assets/stylesheets/app.css | 32 +++++++++++++-- views/controls/editor/share.ejs | 3 -- views/controls/reader/about-room.ejs | 1 + views/controls/reader/embed.ejs | 25 ++++++++++++ views/editor.ejs | 1 + views/partials/footer.ejs | 2 +- views/partials/scripts.ejs | 3 +- views/reader.ejs | 1 + 11 files changed, 124 insertions(+), 9 deletions(-) create mode 100644 public/assets/javascripts/ui/reader/EmbedView.js create mode 100644 views/controls/reader/embed.ejs (limited to 'public/assets/javascripts/util.js') diff --git a/public/assets/javascripts/ui/reader/EmbedView.js b/public/assets/javascripts/ui/reader/EmbedView.js new file mode 100644 index 0000000..a0b3c6f --- /dev/null +++ b/public/assets/javascripts/ui/reader/EmbedView.js @@ -0,0 +1,50 @@ +var EmbedView = ModalView.extend({ + el: ".embedView", + + events: { + "keydown": "stopPropagation", + "input [name=width]": "build", + "input [name=height]": "build", + "click [name=mute]": "build", + "click textarea": "selectAll", + }, + + defaultWidth: 600, + defaultHeight: 450, + + initialize: function(opt){ + this.parent = opt.parent + this.$embedCode = this.$("#embedCode") + this.$width = this.$("[name=width]") + this.$height = this.$("[name=height]") + this.$mute = this.$("[name=mute]") + + this.$width.val(this.defaultWidth) + this.$height.val(this.defaultHeight) + }, + + show: function(){ + this.build() + this.__super__.show.call(this) + }, + + build: function(){ + var mute = this.$mute.prop('checked') ? 1 : 0 + var width = clamp( this.$width.int(), 0, 2000) || this.defaultWidth + var height = clamp( this.$height.int(), 0, 2000) || this.defaultHeight + var link = this.parent.getLink() + link += "?mute=" + mute +// link += "&noui=1" + var kode = "" + + this.$embedCode.val( kode ) + }, + + selectAll: function(){ + this.$embedCode[0].select() + }, + +}) diff --git a/public/assets/javascripts/ui/reader/ShareView.js b/public/assets/javascripts/ui/reader/ShareView.js index 8a205ba..dbe6f64 100644 --- a/public/assets/javascripts/ui/reader/ShareView.js +++ b/public/assets/javascripts/ui/reader/ShareView.js @@ -10,6 +10,7 @@ var ShareView = View.extend({ initialize: function(opt){ this.parent = opt.parent + this.embedView = new EmbedView ({ parent: this }) this.$link = this.$("#share_link") }, @@ -55,6 +56,7 @@ var ShareView = View.extend({ embed: function (e) { e.preventDefault() + this.embedView.show() }, }) diff --git a/public/assets/javascripts/util.js b/public/assets/javascripts/util.js index 2fa994a..1749836 100644 --- a/public/assets/javascripts/util.js +++ b/public/assets/javascripts/util.js @@ -239,4 +239,17 @@ if (!Function.prototype.bind) { }()); +function selectElementContents(el) { + if (window.getSelection && document.createRange) { + var sel = window.getSelection(); + var range = document.createRange(); + range.selectNodeContents(el); + sel.removeAllRanges(); + sel.addRange(range); + } else if (document.selection && document.body.createTextRange) { + var textRange = document.body.createTextRange(); + textRange.moveToElementText(el); + textRange.select(); + } +} diff --git a/public/assets/stylesheets/app.css b/public/assets/stylesheets/app.css index 3fe9741..32fc817 100755 --- a/public/assets/stylesheets/app.css +++ b/public/assets/stylesheets/app.css @@ -2566,13 +2566,13 @@ a[data-role="forgot-password"] { /* COLLABORATORS */ -.collaborators .rap { +.mediaDrawer .rap { display: table; width: 100%; height: 100%; } -.collaborators .rap .holder .inner { +.mediaDrawer .rap .holder .inner { width: 480px; margin: 0 auto; text-align: left; @@ -2607,7 +2607,7 @@ a[data-role="forgot-password"] { background-color: black; border-color: black; } -.collaborators p { +.mediaDrawer .rap p { margin: 10px 0 20px; font-weight: 300; } @@ -2615,7 +2615,7 @@ a[data-role="forgot-password"] { font-size: 16px; width: 300px; } -.collaborators h2 { +.mediaDrawer .rap h2 { margin: 20px auto 0; } #collaborator-list { @@ -2672,6 +2672,30 @@ a[data-role="forgot-password"] { display: block; } +/* EMBED CODE GENERATOR */ + +.embedView textarea { + border: 1px solid black; + width: 100%; + height: 100px; + font-family: 'Menlo', 'Monaco', 'Lucida Sans Console', monospace; + padding: 5px; + line-height: 15px; +} +.embedView input[type=text] { + border: 1px solid black; + width: 40px; + padding: 2px; + font-size: 14px; + margin: 5px; +} +.embedView label { + font-size: 14px; +} +.embedView { + font-weight: 300; +} + /* MARCHING ANTS ANIMATION */ @-webkit-keyframes borderanimation { diff --git a/views/controls/editor/share.ejs b/views/controls/editor/share.ejs index 97f4ceb..7e7ad3c 100644 --- a/views/controls/editor/share.ejs +++ b/views/controls/editor/share.ejs @@ -14,6 +14,3 @@
- - \ No newline at end of file diff --git a/views/controls/reader/about-room.ejs b/views/controls/reader/about-room.ejs index c9ad626..eba8c98 100644 --- a/views/controls/reader/about-room.ejs +++ b/views/controls/reader/about-room.ejs @@ -13,6 +13,7 @@

Share on–

Facebook Twitter + Embed [[ if (canEdit) { ]] diff --git a/views/controls/reader/embed.ejs b/views/controls/reader/embed.ejs new file mode 100644 index 0000000..a897fbe --- /dev/null +++ b/views/controls/reader/embed.ejs @@ -0,0 +1,25 @@ +
+ X + +
+
+
+

Embed Vvalls

+ +

+ This code generates an iframe which will embed this room in your website or blog. +

+ + + dimensions: x + + + +
+
+
+
diff --git a/views/editor.ejs b/views/editor.ejs index b031759..efc4b9d 100755 --- a/views/editor.ejs +++ b/views/editor.ejs @@ -21,6 +21,7 @@ [[ include controls/editor/text-editor ]] [[ include controls/editor/collaborators ]] [[ include controls/editor/share ]] + [[ include controls/reader/embed ]] [[ include controls/editor/settings ]] [[ include controls/editor/presets ]] diff --git a/views/partials/footer.ejs b/views/partials/footer.ejs index f44b611..a94acb1 100644 --- a/views/partials/footer.ejs +++ b/views/partials/footer.ejs @@ -5,7 +5,7 @@ Terms Privacy - ©2014 VVALLS Inc. + ©2014 Dot Dash 3, Inc. [[ if (logged_in) { ]]

diff --git a/views/partials/scripts.ejs b/views/partials/scripts.ejs index 3e61a5a..70c3b27 100644 --- a/views/partials/scripts.ejs +++ b/views/partials/scripts.ejs @@ -7,7 +7,7 @@ - + @@ -115,6 +115,7 @@ + diff --git a/views/reader.ejs b/views/reader.ejs index e86bab1..b9b53d2 100644 --- a/views/reader.ejs +++ b/views/reader.ejs @@ -15,6 +15,7 @@
[[ include controls/reader/about-room ]] [[ include controls/reader/media-player ]] + [[ include controls/reader/embed ]]