diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-12-01 19:05:47 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-12-01 19:05:47 -0500 |
| commit | 3894b197a61f7370597218cda6a2a5eccde9375b (patch) | |
| tree | 134c72dd76b2873994c428a0dd9e4c6a7c3ebfe7 /public/assets/javascripts/ui/editor/MediaTumblr.js | |
| parent | 598b7d86716d83f3f5c571c98dbf41ae1706cb40 (diff) | |
| parent | c423e246d4e18ce65861e384bee6c147aff79ddb (diff) | |
merge
Diffstat (limited to 'public/assets/javascripts/ui/editor/MediaTumblr.js')
| -rw-r--r-- | public/assets/javascripts/ui/editor/MediaTumblr.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/public/assets/javascripts/ui/editor/MediaTumblr.js b/public/assets/javascripts/ui/editor/MediaTumblr.js new file mode 100644 index 0000000..47419ae --- /dev/null +++ b/public/assets/javascripts/ui/editor/MediaTumblr.js @@ -0,0 +1,53 @@ + +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) + }, + +})
\ No newline at end of file |
