Changeset 25 for trunk/grails-app/taglib


Ignore:
Timestamp:
Mar 31, 2011, 12:07:02 PM (12 years ago)
Author:
robert@…
Message:

Implemented uploadify as upload tool

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/taglib/nl/tno/metagenomics/UploadTagLib.groovy

    r9 r25  
    1515        def fileUpload = { attrs ->
    1616                def multiple = attrs.multiple ?: false;
    17                
    18                 out << '<div id="upload_field_container_' + attrs.name + '"  class="upload_field_container upload_field_container_' + ( multiple ? 'multiple' : 'single' ) + '">';
    19                 out << '<div id="upload_field_' + attrs.name + '"  class="upload_field"></div>';
     17                out << '<div class="uploadContainer" id="uploadcontainer_' + attrs.name + '">'
     18                out << '<div class="files">'
    2019                out << '<div id="' + attrs.name + 'Example" class="upload_info"></div>';
    2120                out << '<a id="' + attrs.name + 'DeleteExisting" class="upload_del" href="#" onClick="if( confirm( \'Are you sure to delete this file?\' ) ) { deleteFileExisting( \'' + attrs.name + '\' ); } return false;"><img src="' + resource( dir: 'images/icons', file: 'delete.png', plugin: 'famfamfam' ) + '"></a>';
    2221                out << '<a id="' + attrs.name + 'DeleteUploaded" class="upload_del" href="#" onClick="if( confirm( \'Are you sure to delete this file?\' ) ) { deleteFileUploaded( \'' + attrs.name + '\' ); } return false;"><img src="' + resource( dir: 'images/icons', file: 'delete.png', plugin: 'famfamfam' ) + '"></a>';
     22                out << '</div>'
     23                out << '<input type="file" name="ajaxupload_' + attrs.name + '" id="upload_field_' + attrs.name + '" />'
    2324                out << '<script type="text/javascript">';
    24                 out << '  $(document).ready( function() { ';
     25                out << '  $(function() { ';
    2526                out << '    var filename = "' + ( attrs.value ?: '' ) + '";';
    2627                out << '    fileUploadField( "' + attrs.name + '", ' + ( multiple ? 'true' : 'false' ) + ( attrs.onUpload ? ', function(params) { ' + attrs.onUpload + '(params); }' : '' ) + ( attrs.onDelete ? ', function(params) { ' + attrs.onDelete + '(params); }' : '' ) + ');';
    2728                out << '    if( filename != "" ) {';
    2829                out << '      $("#' + attrs.name + 'DeleteExisting").show();';
    29                 out << '      $("#' + attrs.name + 'Example").html("Current file: " + createFileHTML( filename ) )';
     30                out << '      $("#' + attrs.name + 'Example").html("Current file: " + createFileHTML( filename ) );';
     31                out << '      $("#uploadcontainer_' + attrs.name + ' .files").show();';
    3032                out << '    }';
    3133                out << '  } );';
    3234                out << "</script>\n";
    33                
     35
    3436                // Show a custom list when uploading multiple files
    3537                if( multiple ) {
    36                         out << '<ul class="multipleFiles"></ul>';
     38                        out << '<ul class="files"></ul>';
    3739                } else {
    3840                        out << '<input type="hidden" name="' + attrs.name + '" id="' + attrs.name + '" value="' + attrs.value + '">';
     
    4042
    4143                out << '</div>';
     44               
    4245        }
     46       
     47//      def fileUpload = { attrs ->
     48//              def multiple = attrs.multiple ?: false;
     49//             
     50//              out << '<div id="upload_field_container_' + attrs.name + '"  class="upload_field_container upload_field_container_' + ( multiple ? 'multiple' : 'single' ) + '">';
     51//              out << '<div id="upload_field_' + attrs.name + '"  class="upload_field"></div>';
     52//              out << '<div id="' + attrs.name + 'Example" class="upload_info"></div>';
     53//              out << '<a id="' + attrs.name + 'DeleteExisting" class="upload_del" href="#" onClick="if( confirm( \'Are you sure to delete this file?\' ) ) { deleteFileExisting( \'' + attrs.name + '\' ); } return false;"><img src="' + resource( dir: 'images/icons', file: 'delete.png', plugin: 'famfamfam' ) + '"></a>';
     54//              out << '<a id="' + attrs.name + 'DeleteUploaded" class="upload_del" href="#" onClick="if( confirm( \'Are you sure to delete this file?\' ) ) { deleteFileUploaded( \'' + attrs.name + '\' ); } return false;"><img src="' + resource( dir: 'images/icons', file: 'delete.png', plugin: 'famfamfam' ) + '"></a>';
     55//              out << '<script type="text/javascript">';
     56//              out << '  $(document).ready( function() { ';
     57//              out << '    var filename = "' + ( attrs.value ?: '' ) + '";';
     58//              out << '    fileUploadField( "' + attrs.name + '", ' + ( multiple ? 'true' : 'false' ) + ( attrs.onUpload ? ', function(params) { ' + attrs.onUpload + '(params); }' : '' ) + ( attrs.onDelete ? ', function(params) { ' + attrs.onDelete + '(params); }' : '' ) + ');';
     59//              out << '    if( filename != "" ) {';
     60//              out << '      $("#' + attrs.name + 'DeleteExisting").show();';
     61//              out << '      $("#' + attrs.name + 'Example").html("Current file: " + createFileHTML( filename ) )';
     62//              out << '    }';
     63//              out << '  } );';
     64//              out << "</script>\n";
     65//             
     66//              // Show a custom list when uploading multiple files
     67//              if( multiple ) {
     68//                      out << '<ul class="multipleFiles"></ul>';
     69//              } else {
     70//                      out << '<input type="hidden" name="' + attrs.name + '" id="' + attrs.name + '" value="' + attrs.value + '">';
     71//              }
     72//
     73//              out << '</div>';
     74//      }
    4375
    4476        /**
Note: See TracChangeset for help on using the changeset viewer.