summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ui/editor/MediaViewer.js
diff options
context:
space:
mode:
authorryderr <r@okfoc.us>2014-11-17 11:23:53 -0500
committerryderr <r@okfoc.us>2014-11-17 11:23:53 -0500
commit21e23e63e089685a558d2e5c74439e9de5c33c4f (patch)
tree6ee8cf44e00aca897ec02d48a1e398c4e41092cb /public/assets/javascripts/ui/editor/MediaViewer.js
parent39fa1a5b835797deb4b28d7ba6faae766a979dca (diff)
parent84d606cc4c56778ae7e6b8b7d86e100131717a53 (diff)
Merge branch 'master' of github.com:okfocus/vvalls
Diffstat (limited to 'public/assets/javascripts/ui/editor/MediaViewer.js')
-rw-r--r--public/assets/javascripts/ui/editor/MediaViewer.js31
1 files changed, 26 insertions, 5 deletions
diff --git a/public/assets/javascripts/ui/editor/MediaViewer.js b/public/assets/javascripts/ui/editor/MediaViewer.js
index 9593ab7..029252d 100644
--- a/public/assets/javascripts/ui/editor/MediaViewer.js
+++ b/public/assets/javascripts/ui/editor/MediaViewer.js
@@ -16,13 +16,14 @@ var MediaViewer = ModalView.extend({
'click #randomize': "randomize",
'click .mediaContainer': "pick",
'click .viewMore': "load",
+ 'keydown #tumblr-url': 'enterTumblrUrl',
},
initialize: function(opt){
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")
@@ -37,12 +38,14 @@ var MediaViewer = ModalView.extend({
this.$deleteMedia = this.$("#deleteMedia")
this.$viewMore = this.$(".viewMore")
this.$noMedia = this.$(".noMedia")
+
+ this.$tumblrUrl = this.$("#tumblr-url")
},
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")
},
@@ -50,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")
},
@@ -58,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")
},
@@ -120,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() )
}
@@ -190,6 +193,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 +257,7 @@ var MediaViewer = ModalView.extend({
switch (media.type) {
case "video":
+ case "soundcloud":
$floatingImg.attr('src', '/assets/img/playbutton.png')
break
@@ -285,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))
+ },
})