var MediaTumblr = ModalView.extend({ el: "#tumblrUpload", events: { 'mousedown': "stopPropagation", "keydown .url": "enterSubmit", "click .exampleTumblr": "loadExample", }, initialize: function(opt){ this.__super__.initialize.call(this) this.parent = opt.parent this.$url = this.$(".url") }, show: function(){ this.$el.addClass("active") this.$url.val("") }, hide: function(){ this.$el.removeClass("active") }, enterSubmit: function(e){ e.stopPropagation() if (e.keyCode == 13) { e.preventDefault() var url = this.$tumblrUrl.val() this.loadTumblr(url) } }, loadTumblr: function(url){ Parser.tumblr(url, function(media_list){ console.log(media_list) this.parent.mediaViewer.$foundMediaContainer.empty() media_list.reverse().forEach(function(media){ this.parent.mediaViewer.add(media, this.parent.mediaViewer.$foundMediaContainer) }.bind(this)) }.bind(this)) }, loadExample: function(e){ e.preventDefault() var name = $(e.currentTarget).html() var url = "http://" + name + ".tumblr.com/" this.$url.val(url) this.loadTumblr(url) }, })