diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-06-12 17:19:11 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-06-12 17:19:11 -0400 |
| commit | e37702d371b459847a43f7c6f953dff31684d823 (patch) | |
| tree | 0592cdd1f7f92b3718a3f66ac7b4f4d1009915ef /public/assets/javascripts/ui/editor/MediaViewer.js | |
| parent | 036427dfe207249ca5d6260ae1f6e8006ff90dd9 (diff) | |
media viewer appears
Diffstat (limited to 'public/assets/javascripts/ui/editor/MediaViewer.js')
| -rw-r--r-- | public/assets/javascripts/ui/editor/MediaViewer.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/public/assets/javascripts/ui/editor/MediaViewer.js b/public/assets/javascripts/ui/editor/MediaViewer.js new file mode 100644 index 0000000..8413e70 --- /dev/null +++ b/public/assets/javascripts/ui/editor/MediaViewer.js @@ -0,0 +1,41 @@ + +var MediaViewer = ModalView.extend({ + el: ".mediaDrawer.mediaViewer", + createAction: "/api/docs/new", + updateAction: "/api/docs/edit", + destroyAction: "/api/docs/destroy", + + show: function(){ + if (! this.loaded) { + this.load() + } + else { + this.__super__.show() + } + }, + + load: function(){ + $.get("/api/media/user", $.proxy(this.populate, this) + }, + + populate: function(data){ + data.forEach($.proxy(function(room){ + var $span = $("<span>") + // $span.html(JSON.stringify(room)) + $span.data("slug", room.slug) + $span.css("background-image", "url(" + room.photo + ")") + + this.$templates.append($span) + }, this)) + this.__super__.show() + }, + + destroy: function(name, cb){ + $.ajax({ + type: "delete", + url: this.destroyAction, + data: { name: name, _csrf: $("[name=_csrf]").val() } + }).complete(cb || function(){}) + }, + +}) |
