Skip to content

Commit

Permalink
Merge pull request SpinaCMS#48 from idl3/aviary-undefined
Browse files Browse the repository at this point in the history
Only load aviary if library is present
  • Loading branch information
Bram Jetten committed Jun 19, 2015
2 parents a8c2c9a + dd70348 commit 6aba152
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions app/assets/javascripts/spina/admin/aviary.js.coffee
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
$(document).ready ->
featherEditor = new Aviary.Feather
apiKey: $('body').attr('aviary_api_key'),
theme: 'dark',
language: $('body').attr('aviary_language'),
tools: 'crop,enhance,contrast,sharpness,text,whiten,effects,warmth,orientation,brightness,saturation,redeye,blemish',
onSave: (imageID, newURL) ->
img = $('#' + imageID)
img.attr('src', newURL)
$.post(img.attr('data-posturl'), { new_image: newURL })
,
onError: (errorObj) ->
alert(errorObj.message)
if(typeof(Aviary) != "undefined")
featherEditor = new Aviary.Feather
apiKey: $('body').attr('aviary_api_key'),
theme: 'dark',
language: $('body').attr('aviary_language'),
tools: 'crop,enhance,contrast,sharpness,text,whiten,effects,warmth,orientation,brightness,saturation,redeye,blemish',
onSave: (imageID, newURL) ->
img = $('#' + imageID)
img.attr('src', newURL)
$.post(img.attr('data-posturl'), { new_image: newURL })
,
onError: (errorObj) ->
alert(errorObj.message)

launchEditor = (id, src) ->
featherEditor.launch
image: id,
url: ($('body').attr('ngrok_address') + src)
return false
launchEditor = (id, src) ->
featherEditor.launch
image: id,
url: ($('body').attr('ngrok_address') + src)
return false

$(document).on 'click', '[data-aviary]', (e) ->
e.preventDefault()
image = $(this).parents('.item').find('img')
return launchEditor(image.attr('id'), image.attr('data-image'))
$(document).on 'click', '[data-aviary]', (e) ->
e.preventDefault()
image = $(this).parents('.item').find('img')
return launchEditor(image.attr('id'), image.attr('data-image'))

0 comments on commit 6aba152

Please sign in to comment.