Skip to content

Instantly share code, notes, and snippets.

@roman-manchenko
Created July 22, 2015 16:30
Show Gist options
  • Save roman-manchenko/76aa721de9de0d292a9c to your computer and use it in GitHub Desktop.
Save roman-manchenko/76aa721de9de0d292a9c to your computer and use it in GitHub Desktop.
+++ b/static/js/widgets/views/posts/edit_mode/media_form.js
@@ -11,7 +11,7 @@ define(function (require) {
WebSearchImagesView = require('whitelabel/widgets/views/edit_mode/web_search_images'),
ImageSearchCollection = require('widgets/collections/image_search_api'),
Pager = require('widgets/models/dashboard/stats/pager'),
- SaveImageModel = require('whitelabel/widgets/models/save_image'),
+ ProxyImageModel = require('widgets/models/posts/image_proxy'),
template = require('hgn!widgets/templates/posts/edit_mode/posts/add_media'),
loadingTemplate = require('hgn!widgets/templates/posts/edit_mode/posts/web_search_images_loading');
@@ -25,7 +25,7 @@ define(function (require) {
initialize: function () {
this.model && this.watchEvent(this.model, 'destroy', 'remove', this);
this.imageSearchCollection = new ImageSearchCollection();
- this.watchEvent(this.imageSearchCollection, 'change:isActive', 'saveCoverImage', this);
+ this.watchEvent(this.imageSearchCollection, 'change:isActive', 'saveImage', this);
},
preventInnerEvents: function (evnt) {
evnt.preventDefault();
@@ -38,18 +38,14 @@ define(function (require) {
this.$(e.target).hide();
this.$(e.target).parent().find('.form-container').show();
},
- saveCoverImage: function (image) {
- var modelInst = new SaveImageModel({
- parse: function (response) {
- return response;
- }
- }),
+ saveImage: function (image) {
+ var modelInst = new ProxyImageModel(),
seachedImgBox = this.$('.cover-thumbnail-box'),
errorMsg = 'Couldn\'t add an image, some error happened';
seachedImgBox.html(loadingTemplate());
seachedImgBox.addClass('loading-overlay');
- modelInst.save({image_url: image.get('imageUrl')}, {
+ modelInst.fetch({data: {image_url: image.get('imageUrl')},
success: _.bind(function (model) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment