aboutsummaryrefslogtreecommitdiff
path: root/views/default/js/photos/uploading.php
diff options
context:
space:
mode:
authorBrett Profitt <brett.profitt@gmail.com>2012-03-16 22:51:12 -0700
committerBrett Profitt <brett.profitt@gmail.com>2012-03-16 22:51:12 -0700
commit5cc8de829c0a7b86c8df27293f4825d0e340d592 (patch)
tree62b71d96d02fce3a75393da08219714fdad4789d /views/default/js/photos/uploading.php
parente6e33ca1a7afb00a855f57df5a5263674b23c93c (diff)
downloadelgg-5cc8de829c0a7b86c8df27293f4825d0e340d592.tar.gz
elgg-5cc8de829c0a7b86c8df27293f4825d0e340d592.tar.bz2
Fixes #14. Fixed uploadify.
Diffstat (limited to 'views/default/js/photos/uploading.php')
-rw-r--r--views/default/js/photos/uploading.php85
1 files changed, 75 insertions, 10 deletions
diff --git a/views/default/js/photos/uploading.php b/views/default/js/photos/uploading.php
index 59448dd46..cb79dc77c 100644
--- a/views/default/js/photos/uploading.php
+++ b/views/default/js/photos/uploading.php
@@ -1,27 +1,92 @@
<?php
/**
- *
+ * AJAX uploading
*/
-
-$site_url = elgg_get_site_url();
-$upload_endpoint_url = "{$site_url}action/tidypics/ajax_upload/";
-$upload_complete_url = "{$site_url}action/tidypics/ajax_upload_complete/";
-
?>
+//<script>
elgg.provide('elgg.tidypics.uploading');
elgg.tidypics.uploading.init = function() {
+
+ var fields = ['Elgg', 'user_guid', 'album_guid', 'batch', 'tidypics_token'];
+ var data = elgg.security.token;
+
+ $(fields).each(function(i, name) {
+ var value = $('input[name=' + name + ']').val();
+ if (value) {
+ data[name] = value;
+ }
+ });
+
+ data['XDEBUG_SESSION_START'] = 'netbeans-xdebug';
+
$("#uploadify").uploadify({
- 'uploader' : '<?php echo $site_url; ?>mod/tidypics/vendors/uploadify/uploadify.swf',
- 'script' : '<?php echo $upload_endpoint_url; ?>',
+ 'uploader' : elgg.config.wwwroot + 'mod/tidypics/vendors/uploadify/uploadify.swf',
+ 'script' : elgg.config.wwwroot + 'action/photos/image/ajax_upload',
+ 'cancelImg' : elgg.config.wwwroot + 'mod/tidypics/vendors/uploadify/cancel.png',
'fileDataName' : 'Image',
'multi' : true,
'auto' : false,
'wmode' : 'transparent',
'buttonImg' : " ",
- 'height' : 20,
- 'width' : 130
+ 'height' : $('#tidypics-choose-button').height(),
+ 'width' : $('#tidypics-choose-button').width(),
+ 'scriptData' : data,
+ 'onEmbedFlash' : function(event) {
+ // @todo This is supposed to mimick hovering over the link.
+ // hover events aren't firing for the object.
+ $("#" + event.id).hover(
+ function(){
+ $("#tidypics-choose-button").addClass('tidypics-choose-button-hover');
+ },
+ function(){
+ $("#tidypics-choose-button").removeClass('tidypics-choose-button-hover');
+ }
+ );
+ },
+ 'onSelectOnce' : function() {
+ $("#tidypics-upload-button").removeClass('tidypics-disable');
+ },
+ 'onAllComplete' : function() {
+ // @todo they can keep adding pics if they want. no need to disable this.
+ $("#tidypics-choose-button").addClass('tidypics-disable');
+ $("#tidypics-upload-button").addClass('tidypics-disable').die();
+ $("#tidypics-describe-button").removeClass('tidypics-disable');
+
+ elgg.action('photos/image/ajax_upload_complete', {
+ data: {
+ album_guid: data.album_guid,
+ batch: data.batch
+ },
+ success: function(json) {
+ var url = elgg.normalize_url('photos/edit/' + json.batch_guid)
+ $('#tidypics-describe-button').attr('href', url);
+ }
+ });
+ },
+ 'onComplete' : function(event, queueID, fileObj, response) {
+ // check for errors here
+ if (response != 'success') {
+ $("#uploadify" + queueID + " .percentage").text(" - " + response);
+ $("#uploadify" + queueID).addClass('uploadifyError');
+ }
+ $("#uploadify" + queueID + " > .cancel").remove();
+ return false;
+ },
+ 'onCancel' : function(event, queueID, fileObj, data) {
+ if (data.fileCount == 0) {
+ $("#tidypics-upload-button").addClass('tidypics-disable');
+ }
+ }
+
+ });
+
+ // bind to upload button
+ $('#tidypics-upload-button').live('click', function(e) {
+ var $uploadify = $('#uploadify');
+ $uploadify.uploadifyUpload();
+ e.preventDefault();
});
}