# HG changeset patch # User rougeronj # Date 1360856247 -3600 # Node ID 5bb3aec02883b8faf1d3a9ecdcf2109b0709113d # Parent 7ef5c69b73b363d3e4cba382fcd4d743136b462f# Parent 38afc7be4a886c9cdfe7a76abd5102488f25be8e Merge with 38afc7be4a886c9cdfe7a76abd5102488f25be8e (chunked_upload) diff -r 38afc7be4a88 -r 5bb3aec02883 src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/create_content.html diff -r 38afc7be4a88 -r 5bb3aec02883 src/ldt/ldt/static/ldt/css/ldtform.css --- a/src/ldt/ldt/static/ldt/css/ldtform.css Thu Feb 14 16:26:20 2013 +0100 +++ b/src/ldt/ldt/static/ldt/css/ldtform.css Thu Feb 14 16:37:27 2013 +0100 @@ -163,7 +163,7 @@ } #media_fields_div { - width : 300px; + width : 338px; height : 50px; margin-top: 10px 0px; padding-left: 10px; diff -r 38afc7be4a88 -r 5bb3aec02883 src/ldt/ldt/static/ldt/js/projectscontents.js --- a/src/ldt/ldt/static/ldt/js/projectscontents.js Thu Feb 14 16:26:20 2013 +0100 +++ b/src/ldt/ldt/static/ldt/js/projectscontents.js Thu Feb 14 16:37:27 2013 +0100 @@ -386,6 +386,7 @@ function resize_modal_window (element, createcontent) { + var nm = parent.$.nmTop(); var iframe = $("iframe", window.parent.document); if ( $('#init_ldt_view', element).size() > 0) { // if contains ldt lpayer var h = 660; @@ -394,9 +395,17 @@ var h = $(element).innerHeight() + 10; var w = $(element).innerWidth() + 10; } - + + nm.sizes.minH = h + 10; + nm.sizes.minW = w; iframe.height(h); iframe.width(w); + + if ($.browser.mozilla && createcontent) { + $(".nyroModalCont", parent.window.document).height(h+10); + } else { + nm.resize(true); + } } // @@ -408,7 +417,11 @@ window.submit_asked = false; window.remove_temp_file_url = remove_url; window.ask_duration_url = ask_dur_url; - + + $("#close_button").click(function (e) { + e.preventDefault(); + parent.$.nmTop().close(); + }); $("#submit_button_write").click(function(e) { $(".submitcontent-loader-content").show(); resize_modal_window($("#add_content"), true); @@ -426,22 +439,103 @@ $('#my_form').bind('submit', function() { window.submit_asked = true; if($('#id_content-media_input_type').val()=="upload"){ - /*if(chunked_upload_complete == true){ - return true; + if(window.upload_from_local_done==false){ + // The form has sent but the uploading has not ended. + if($('#upload_progress_info').children().size()>0){ + $('#progress_info').remove(); + } + $('#upload_progress_info').append('
' + wait_label + '.
' + cancel_label + '.
' + success_label + '.
'); + $("#upload_progress_bar > div").css({ 'background': '#90ffa8' }); + window.upload_from_local_done = true; + // Now that the file is uploaded, we submit the form if asked + if(window.submit_asked==true){ + $('#my_form').submit(); + } + else{ + // We ask the uploaded media's duration + if(window.ask_duration_url){ + $.ajax({ + type: "GET", + url: window.ask_duration_url, + data: "filename="+ $('#id_media-local_file_name').val(), + cache: false, + success: function(data, status, request){ + if(data && data!=""){ + $('#id_content-duration').val(data); + } + } + }); + } + } + } + catch (ex) { + //this.debug(ex); + } + }, + file_queued_handler : displayUploadPath, + file_dialog_complete_handler: function() { + window.submit_asked = false; + this.startUpload(); + } + //upload_complete_handler: function() { this.startUpload(); }, + }); } - function displayUploadPath(file) { try { $('#id_media-local_file_name').val(file.name); @@ -450,6 +544,62 @@ //this.debug(ex); } } +function startLocalUpload(){ + swfupload.startUpload(); +} +function uploadProgress(file, bytesLoaded, bytesTotal) { + try { + var percent = Math.ceil((bytesLoaded / bytesTotal) * 100); + $("#upload_progress_bar").progressbar({ value: percent }); + } + catch (ex) { + //this.debug(ex); + } +} +function cancelSwfUpload(){ + swfupload.cancelUpload(); + if($('#media_field_upload').has($('#cancelupload')).length==0){ + $('#cancelupload').remove(); + } +} +function uploadError(file, errorCode, message) { + try { + if($('#upload_progress_info').children().size()>0){ + $('#progress_info').remove(); + } + switch (errorCode) { + case SWFUpload.UPLOAD_ERROR.HTTP_ERROR: + $('#upload_progress_info').append('' + "Error Code: HTTP Error, File name: " + file.name + ", Message: " + message + '
'); + break; + case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED: + $('#upload_progress_info').append('' + "Error Code: Upload Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message + '
'); + break; + case SWFUpload.UPLOAD_ERROR.IO_ERROR: + $('#upload_progress_info').append('' + "Error Code: IO Error, File name: " + file.name + ", Message: " + message + '
'); + break; + case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR: + $('#upload_progress_info').append('' + "Error Code: Security Error, File name: " + file.name + ", Message: " + message + '
'); + break; + case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED: + $('#upload_progress_info').append('' + "Error Code: Upload Limit Exceeded, File name: " + file.name + ", File size: " + file.size + ", Message: " + message + '
'); + break; + case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED: + $('#upload_progress_info').append('' + "Error Code: File Validation Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message + '
'); + break; + case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED: + $('#upload_progress_info').append('' + "Error Code: FILE_CANCELLED" + '
'); + break; + case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED: + $('#upload_progress_info').append('' + "STOPPED" + '
'); + break; + default: + $('#upload_progress_info').append('' + "unhandled error: File name: " + file.name + ", File size: " + file.size + ", Message: " + message + '
'); + break; + } + } catch (ex) { + //this.debug(ex); + } +} // Test the value of the URL from the form to load a picture in case it is a youtube video function testUrlValue(e){ @@ -554,4 +704,3 @@ $(checkbox_names).trigger("change"); }); } -