From d729d5f58fa4a4a30e252ab063bcf636559945b0 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 14 Nov 2014 16:43:26 -0500 Subject: soundcloud support --- public/assets/javascripts/ui/editor/MediaViewer.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'public/assets/javascripts/ui/editor') diff --git a/public/assets/javascripts/ui/editor/MediaViewer.js b/public/assets/javascripts/ui/editor/MediaViewer.js index 9593ab7..4af94e5 100644 --- a/public/assets/javascripts/ui/editor/MediaViewer.js +++ b/public/assets/javascripts/ui/editor/MediaViewer.js @@ -190,6 +190,10 @@ var MediaViewer = ModalView.extend({ image.src = media.url image.load() break + + case 'soundcloud': + image.src = media.thumbnail + break } $span.data("media", media) @@ -250,6 +254,7 @@ var MediaViewer = ModalView.extend({ switch (media.type) { case "video": + case "soundcloud": $floatingImg.attr('src', '/assets/img/playbutton.png') break -- cgit v1.2.3-70-g09d2 From 5b9b94d0dac5ddb70a5ea51b948cde40ae898202 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 14 Nov 2014 17:08:53 -0500 Subject: fix click/bind behavior --- .../javascripts/rectangles/engine/scenery/_scenery.js | 3 ++- public/assets/javascripts/ui/editor/MediaEditor.js | 18 +++++++++++++++--- public/assets/javascripts/ui/editor/TextEditor.js | 3 ++- public/assets/javascripts/ui/reader/MediaPlayer.js | 14 ++++++++++++-- 4 files changed, 31 insertions(+), 7 deletions(-) (limited to 'public/assets/javascripts/ui/editor') diff --git a/public/assets/javascripts/rectangles/engine/scenery/_scenery.js b/public/assets/javascripts/rectangles/engine/scenery/_scenery.js index a0f5b35..d03e0e1 100644 --- a/public/assets/javascripts/rectangles/engine/scenery/_scenery.js +++ b/public/assets/javascripts/rectangles/engine/scenery/_scenery.js @@ -34,7 +34,7 @@ var Scenery = new function(){ case 'text': scene_media = new Scenery.types.text (opt) - scene_media.focused = true + scene_media.focused = !! opt.newMedia break } base.list[scene_media.id] = scene_media @@ -42,6 +42,7 @@ var Scenery = new function(){ } base.addNextToWall = function(opt){ + opt.newMedia = true opt.media = base.nextMedia opt.index = opt.index || 0 var scene_media = base.add(opt) diff --git a/public/assets/javascripts/ui/editor/MediaEditor.js b/public/assets/javascripts/ui/editor/MediaEditor.js index de93f6e..21759d6 100644 --- a/public/assets/javascripts/ui/editor/MediaEditor.js +++ b/public/assets/javascripts/ui/editor/MediaEditor.js @@ -51,7 +51,7 @@ var MediaEditor = FormView.extend({ }, pick: function(scenery) { - if (this.scenery) { + if (this.scenery && scenery !== this.scenery) { this.unbind() } @@ -74,15 +74,17 @@ var MediaEditor = FormView.extend({ switch (media.type) { case "image": - this.$(".image").show() this.$(".video").hide() + this.$(".audio").hide() + this.$(".image").show() break case "youtube": case "vimeo": case "video": - this.$(".video").show() this.$(".image").hide() + this.$(".audio").hide() + this.$(".video").show() this.$playButton.toggleClass("paused", ! this.scenery.paused()) this.$autoplay.prop('checked', !! media.autoplay) @@ -90,6 +92,15 @@ var MediaEditor = FormView.extend({ this.$mute.prop('checked', !! media.mute) this.$keyframe.val( Number(media.keyframe || 0) ) break + + case "soundcloud": + this.$(".image").hide() + this.$(".video").hide() + this.$(".audio").show() + this.$playButton.toggleClass("paused", ! this.scenery.paused()) + this.$autoplay.prop('checked', !! media.autoplay) + this.$loop.prop('checked', !! media.loop) + break } }, @@ -161,6 +172,7 @@ var MediaEditor = FormView.extend({ unbind: function(){ if (this.scenery) { + this.scenery.focused = false if (this.tainted && this.scenery.media) { this.scenery.media.title = this.$name.val() this.scenery.media.description = this.$description.val() diff --git a/public/assets/javascripts/ui/editor/TextEditor.js b/public/assets/javascripts/ui/editor/TextEditor.js index d897f91..53d5b9f 100644 --- a/public/assets/javascripts/ui/editor/TextEditor.js +++ b/public/assets/javascripts/ui/editor/TextEditor.js @@ -96,6 +96,7 @@ var TextEditor = FormView.extend({ unbind: function(){ if (this.scenery) { + this.scenery.focused = false if (this.tainted) { Minotaur.watch( app.router.editorView.settings ) } @@ -119,7 +120,7 @@ var TextEditor = FormView.extend({ }, pick: function(scenery){ - if (this.scenery) { + if (this.scenery && scenery !== this.scenery) { this.unbind() } diff --git a/public/assets/javascripts/ui/reader/MediaPlayer.js b/public/assets/javascripts/ui/reader/MediaPlayer.js index f5a0d2c..8424d9c 100644 --- a/public/assets/javascripts/ui/reader/MediaPlayer.js +++ b/public/assets/javascripts/ui/reader/MediaPlayer.js @@ -61,8 +61,9 @@ var MediaPlayer = FormView.extend({ switch (media.type) { case "image": - this.$(".image").show() this.$(".video").hide() + this.$(".audio").hide() + this.$(".image").show() // this.$widthDimension.html( Number(media.widthDimension) || "" ) // this.$heightDimension.html( Number(media.heightDimension) || "" ) @@ -73,13 +74,22 @@ var MediaPlayer = FormView.extend({ case "youtube": case "vimeo": case "video": - this.$(".video").show() this.$(".image").hide() + this.$(".audio").hide() + this.$(".video").show() this.$playButton.toggleClass("paused", ! this.scenery.paused()) this.$muteButton.toggleClass("muted", this.scenery.muted()) break + + case "soundcloud": + this.$(".image").hide() + this.$(".video").hide() + this.$(".audio").show() + + this.$playButton.toggleClass("paused", ! this.scenery.paused()) + break } return true }, -- cgit v1.2.3-70-g09d2 From 2774191a6ab9a96574db5814a8056575add4c0bb Mon Sep 17 00:00:00 2001 From: Julie Lala Date: Fri, 14 Nov 2014 21:49:33 -0500 Subject: load a tumblr url --- public/assets/javascripts/ui/editor/MediaViewer.js | 16 ++++++++++++++++ public/assets/javascripts/ui/lib/Parser.js | 13 ++++++++----- views/controls/editor/media-drawer.ejs | 4 +--- 3 files changed, 25 insertions(+), 8 deletions(-) (limited to 'public/assets/javascripts/ui/editor') diff --git a/public/assets/javascripts/ui/editor/MediaViewer.js b/public/assets/javascripts/ui/editor/MediaViewer.js index 4af94e5..f3d75bf 100644 --- a/public/assets/javascripts/ui/editor/MediaViewer.js +++ b/public/assets/javascripts/ui/editor/MediaViewer.js @@ -16,6 +16,7 @@ var MediaViewer = ModalView.extend({ 'click #randomize': "randomize", 'click .mediaContainer': "pick", 'click .viewMore': "load", + 'keydown #tumblr-url': 'enterTumblrUrl', }, initialize: function(opt){ @@ -37,6 +38,8 @@ var MediaViewer = ModalView.extend({ this.$deleteMedia = this.$("#deleteMedia") this.$viewMore = this.$(".viewMore") this.$noMedia = this.$(".noMedia") + + this.$tumblrUrl = this.$("#tumblr-url") }, wallpaperToggle: function(){ @@ -290,4 +293,17 @@ var MediaViewer = ModalView.extend({ $ants.addClass('edit') _followCursor(e) }, + + enterTumblrUrl: function(e){ + e.stopPropagation() + if (e.keyCode !== 13) { return } + var url = this.$tumblrUrl.val() + Parser.tumblr(url, function(media_list){ + console.log(media_list) + this.$foundMediaContainer.empty() + media_list.reverse().forEach(function(media){ + this.add(media, this.$foundMediaContainer) + }.bind(this)) + }.bind(this)) + }, }) diff --git a/public/assets/javascripts/ui/lib/Parser.js b/public/assets/javascripts/ui/lib/Parser.js index ececa78..411f425 100644 --- a/public/assets/javascripts/ui/lib/Parser.js +++ b/public/assets/javascripts/ui/lib/Parser.js @@ -169,6 +169,9 @@ var Parser = { tumblr: function(url, cb){ var domain = url.replace(/^https?:\/\//,"").split("/")[0] + if (domain.indexOf(".") == -1) { + domain += ".tumblr.com" + } $.ajax({ type: 'GET', url: "http://" + domain + "/api/read", @@ -181,7 +184,7 @@ var Parser = { var blog = data.tumblelog data.posts.forEach(parse) - cb(parse) + cb(media_list) function parse(post){ var media, caption, url @@ -207,7 +210,7 @@ var Parser = { url: post['photo-url-1280'], type: "image", token: "", - thumbnail: photo['photo-url-500'], + thumbnail: post['photo-url-500'], description: caption, width: parseInt(post.width), height: parseInt(post.height), @@ -218,7 +221,7 @@ var Parser = { case 'video': url = post['video-source'] if (url.indexOf("http") !== 0) { break } - if (Parser.lookup.youtube.regex.test(url) { + if (Parser.lookup.youtube.regex.test(url)) { var id = (url.match(/v=([-_a-zA-Z0-9]{11})/i) || url.match(/youtu.be\/([-_a-zA-Z0-9]{11})/i) || url.match(/embed\/([-_a-zA-Z0-9]{11})/i))[1].split('&')[0]; var thumb = "http://i.ytimg.com/vi/" + id + "/hqdefault.jpg" media = { @@ -234,8 +237,8 @@ var Parser = { } break } - }) - console.log(result) + } +// console.log(post) } }) }, diff --git a/views/controls/editor/media-drawer.ejs b/views/controls/editor/media-drawer.ejs index e4ae935..df7910c 100644 --- a/views/controls/editor/media-drawer.ejs +++ b/views/controls/editor/media-drawer.ejs @@ -23,9 +23,7 @@
- +
-- cgit v1.2.3-70-g09d2 From a68382199889a931e5271e80b4e62a8066d4da23 Mon Sep 17 00:00:00 2001 From: Julie Lala Date: Fri, 14 Nov 2014 22:03:35 -0500 Subject: no filename from url plz --- public/assets/javascripts/ui/editor/MediaEditor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'public/assets/javascripts/ui/editor') diff --git a/public/assets/javascripts/ui/editor/MediaEditor.js b/public/assets/javascripts/ui/editor/MediaEditor.js index 21759d6..6068c48 100644 --- a/public/assets/javascripts/ui/editor/MediaEditor.js +++ b/public/assets/javascripts/ui/editor/MediaEditor.js @@ -67,7 +67,7 @@ var MediaEditor = FormView.extend({ // console.log(media) - this.$name.val(media.title || filenameFromUrl(media.url) ) + this.$name.val(media.title) // || filenameFromUrl(media.url) ) this.$description.val(media.description) this.setDimensions() this.$units.val( "ft" ) -- cgit v1.2.3-70-g09d2 From 84d606cc4c56778ae7e6b8b7d86e100131717a53 Mon Sep 17 00:00:00 2001 From: Julie Lala Date: Fri, 14 Nov 2014 22:11:14 -0500 Subject: randomize button uses active media pane --- public/assets/javascripts/ui/editor/MediaViewer.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'public/assets/javascripts/ui/editor') diff --git a/public/assets/javascripts/ui/editor/MediaViewer.js b/public/assets/javascripts/ui/editor/MediaViewer.js index f3d75bf..029252d 100644 --- a/public/assets/javascripts/ui/editor/MediaViewer.js +++ b/public/assets/javascripts/ui/editor/MediaViewer.js @@ -23,7 +23,7 @@ var MediaViewer = ModalView.extend({ this.__super__.initialize.call(this) this.parent = opt.parent - this.$myMedia = this.$(".myMedia") + this.$myMedia = this.$(".myMedia").addClass('active') this.$myMediaContainer = this.$(".myMedia > .container") this.$userToggle = this.$(".userToggle") @@ -45,7 +45,7 @@ var MediaViewer = ModalView.extend({ wallpaperToggle: function(){ this.$wallpaperMedia.addClass("active") this.$foundMedia.addClass("inactive") - this.$myMedia.addClass("inactive") + this.$myMedia.addClass("inactive").removeClass('active') this.$("a").removeClass("active") this.$foundToggle.addClass("active") }, @@ -53,7 +53,7 @@ var MediaViewer = ModalView.extend({ foundToggle: function(){ this.$wallpaperMedia.removeClass("active") this.$foundMedia.addClass("active") - this.$myMedia.addClass("inactive") + this.$myMedia.addClass("inactive").removeClass('active') this.$("a").removeClass("active") this.$foundToggle.addClass("active") }, @@ -61,7 +61,7 @@ var MediaViewer = ModalView.extend({ userToggle: function(){ this.$wallpaperMedia.removeClass("active") this.$foundMedia.removeClass("active") - this.$myMedia.removeClass("inactive") + this.$myMedia.removeClass("inactive").addClass('active') this.$("a").removeClass("active") this.$userToggle.addClass("active") }, @@ -123,7 +123,7 @@ var MediaViewer = ModalView.extend({ }, randomize: function(){ - var $divs = this.$myMediaContainer.find(".mediaContainer").toArray() + var $divs = this.$(".active .container").find(".mediaContainer").toArray() if ($divs.length < 3) { $divs = $divs.concat( this.$foundMediaContainer.find(".mediaContainer").toArray() ) } -- cgit v1.2.3-70-g09d2