Created
March 8, 2010 20:18
-
-
Save davemo/325612 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("#id_logo").uploadify({ | |
'uploader' : '{% vurl "/static/script/vendor/uploadify/uploadify.swf" %}', | |
'script' : '{% url business-listing-logo company.key %}', | |
'cancelImg' : '{% vurl "/static/script/vendor/uploadify/cancel.png" %}', | |
'scriptAccess' : 'always', | |
'auto' : true, | |
'queueID' : 'fileQueue', | |
'fileDataName' : 'logo', | |
'sizeLimit' : 1000000, // ah, the old 1mb limit rears its head :( | |
onComplete : function(evt, queueID, file, response) { | |
// by default flash just returns a string, need to parse the object | |
// note: this can be refactored if/when we upgrade to jquery 1.4.2 as it has support built in | |
var response = YAHOO.lang.JSON.parse(response); | |
if(response.success) { | |
$.gritter.add({ | |
title: 'Image Uploaded', | |
text: 'Your new logo has been uploaded!', | |
image: SREP.getVersionedImage("/static/compiledcss/images/form.success.png") | |
}); | |
// update the source of the logo inline so they can see it. | |
$("#business-logo").attr("src", response.images[0]); | |
} else { | |
$.gritter.add({ | |
title: 'Error Uploading Image', | |
text: response.errors[0], | |
image: SREP.getVersionedImage("/static/compiledcss/images/form.error.png") | |
}); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment