Fix removing banner image, refactor

This commit is contained in:
Kasia Jarmołkowicz 2018-07-05 17:58:00 +02:00 committed by Eric Schultz
parent c713ef343b
commit e5419408ce
4 changed files with 16 additions and 7 deletions

View file

@ -20,7 +20,7 @@
Upload <%= image_url ? 'Different Image' : '' %>
</button>
<a class='button--small red u-marginTop--10 u-width--full' <%= image_url ? '' : 'disabled' %>>
<!--= on 'click' (confirm 'Are you sure?' remove_this_image -->
<!--= on 'click' (confirm 'Are you sure?' remove_background_image -->
Remove Image
</a>
</div>

View file

@ -20,7 +20,7 @@
Upload <%= image_url ? 'Different Image' : '' %>
</button>
<a class='button--small red u-marginTop--10 u-width--full' <%= image_url ? '' : 'disabled' %>>
<!--= on 'click' (confirm 'Are you sure?' remove_this_image -->
<!--= on 'click' (confirm 'Are you sure?' remove_banner_image ) -->
Remove Image
</a>
</div>

View file

@ -34,8 +34,17 @@ editable($('#js-customReceipt'), {
var path = '/nonprofits/' + app.nonprofit_id + '/campaigns/' + app.campaign_id
appl.def('remove_this_image', function() {
appl.remove_background_image(path, 'campaign')
appl.def('remove_banner_image', function() {
var url = '/nonprofits/' + app.nonprofit_id + '/campaigns/' + app.campaign_id
var notification = 'Removing banner image...'
var payload = {remove_banner_image : true}
appl.remove_image(url, 'campaign', notification, payload)
})
appl.def('remove_background_image', function(url, resource) {
var notification = 'Removing background image...'
var payload = {remove_background_image : true}
appl.remove_image(url, resource, notification, payload)
})
appl.def('count_story_words', function() {

View file

@ -17,10 +17,10 @@ $('.image-upload input').change(function(e) {
}
})
appl.def('remove_background_image', function(url, resource) {
appl.def('remove_image', function(url, resource, notification, payload) {
var data = {}
data[resource] = {remove_background_image: true}
appl.notify('Removing background image...')
data[resource] = payload
appl.notify(notification)
appl.def('loading', true)
$.ajax({
type: 'put',