Dotclear

Changeset 1144:4af82896ca3d for admin/js


Ignore:
Timestamp:
06/04/13 22:51:35 (12 years ago)
Author:
Nicolas <nikrou77@…>
Branch:
default
Message:

Remplacement de l'upload utilisant swfupload par le plugin jQuery-File-Upload

Todo:

  • Gestion des suppressions
  • Gestion des annulations
  • Gestion des mises de l'interface sans rechargement de la page
  • Simplification (moins de javascript) ?
Location:
admin/js
Files:
8 added
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • admin/js/_media.js

    r1140 r1144  
    11$(function() { 
    2      // Replace remove links by a POST on hidden form 
    3      fileRemoveAct(); 
    4       
    5      function fileRemoveAct() { 
    6           $('a.media-remove').click(function() { 
    7                var m_name = $(this).parents('ul').find('li:first>a').text(); 
    8                if (window.confirm(dotclear.msg.confirm_delete_media.replace('%s',m_name))) { 
    9                     var f = $('#media-remove-hide').get(0); 
    10                     f.elements['remove'].value = this.href.replace(/^(.*)&remove=(.*?)(&|$)/,'$2'); 
    11                     this.href = ''; 
    12                     f.submit(); 
    13                } 
    14                return false; 
    15           }); 
    16      } 
    17       
    18      if (!$.browser.opera) { 
    19           var upldr = $('<a href="#" id="cu-enable">' + dotclear.msg.activate_enhanced_uploader + '</a>').click( function() { 
    20                candyUploadInit(); 
    21                return false; 
    22           }); 
    23           $('#media-upload').append($('<div></div>').append(upldr)); 
    24           if ((dotclear.candyUpload_force_init == '1') || (($.cookie('dc_candy_upl') == 1))) { 
    25                candyUploadInit(); 
    26           } 
    27      } 
    28       
    29      function candyUploadInit() 
    30      { 
    31           var candy_upload_success = false; 
    32           var candy_upload_form_url = $('#media-upload').attr('action') + '&file_sort=date-desc&d=' + $('#media-upload input[name=d]').val(); 
    33           var candy_upload_limit = $('#media-upload input[name=MAX_FILE_SIZE]').val(); 
    34           $('#media-upload').candyUpload({ 
    35                upload_url: dotclear.candyUpload.base_url + '/media.php', 
    36                flash_movie: dotclear.candyUpload.movie_url, 
    37                file_size_limit: candy_upload_limit + 'b', 
    38                params: 'swfupload=1&amp;' + dotclear.candyUpload.params, 
    39                 
    40                callbacks: { 
    41                     createControls: function() { 
    42                          var _this = this; 
    43                          this.ctrl.btn_browse.hide(); 
    44                          this.ctrl.msg.html(dotclear.msg.load_enhanced_uploader); 
    45                          var l = $('<a href="#">' + dotclear.msg.disable_enhanced_uploader + '</a>').click(function() { 
    46                               _this.upldr.destroy(); 
    47                               _this.ctrl.block.empty().remove(); 
    48                               $('#media-upload').show(); 
    49                               delete _this; 
    50                               $.cookie('dc_candy_upl','',{expires:-1}); 
    51                               return false; 
    52                          }); 
    53                          this.ctrl.disable = $('<div class="cu-disable"></div>').append(l).appendTo(this.ctrl.block); 
    54                     }, 
    55                     flashReady: function() { 
    56                          var _this = this; 
    57                          this.ctrl.msg.fadeOut('fast',function() { 
    58                               $(this).text(_this.locales.no_file_in_queue).fadeIn('fast'); 
    59                               _this.ctrl.btn_browse.fadeIn('fast',function() { 
    60                                    _this.upldr.container.children().css({ 
    61                                         width: $('.cu-btn-browse').width(), 
    62                                         height: $('.cu-btn-browse').height() 
    63                                    }); 
    64                               }); 
    65                          }); 
    66                     }, 
    67                     uploadSuccess: function(o,data) { 
    68                          if (data == 'ok') { 
    69                               candy_upload_success = true; 
    70                               this.fileMsg(o.id,this.locales.file_uploaded); 
    71                          } else { 
    72                               this.fileErrorMsg(o.id,data); 
    73                          } 
    74                           
    75                          // uploads finished and at least one success 
    76                          if (candy_upload_success && $('div.cu-file:has(span.cu-filecancel a)',this.ctrl.files).length == 0) { 
    77                               $.cookie('dc_candy_upl','1',{expires: 30}); 
    78                               $.get(candy_upload_form_url,function(data) { 
    79                                    var media = $('div.media-list'); 
    80                                    media.after($('div.media-list',data)).remove(); 
    81                                    fileRemoveAct(); 
    82                               }); 
    83                          } 
    84                     }, 
    85                     fileQueued: function() { 
    86                          ; 
    87                     } 
    88                } 
    89           }); 
    90      } 
     2    $('#fileupload') 
     3     .fileupload({ 
     4         url: $('#fileupload').attr('action'), 
     5         autoUpload: false 
     6     }); 
     7 
     8    // Load existing files: 
     9    $('#fileupload').addClass('fileupload-processing'); 
     10    $.ajax({ 
     11        url: $('#fileupload').fileupload('option', 'url'), 
     12        dataType: 'json', 
     13        context: $('#fileupload')[0] 
     14    }).always(function (result) { 
     15        $(this).removeClass('fileupload-processing'); 
     16    }).done(function (result) { 
     17        $(this).fileupload('option', 'done') 
     18            .call(this, null, {result: result}); 
     19    }); 
     20 
     21    // Replace remove links by a POST on hidden form 
     22    fileRemoveAct(); 
     23 
     24    function fileRemoveAct() { 
     25     $('a.media-remove').click(function() { 
     26         var m_name = $(this).parents('ul').find('li:first>a').text(); 
     27         if (window.confirm(dotclear.msg.confirm_delete_media.replace('%s',m_name))) { 
     28          var f = $('#media-remove-hide').get(0); 
     29          f.elements['remove'].value = this.href.replace(/^(.*)&remove=(.*?)(&|$)/,'$2'); 
     30          this.href = ''; 
     31          f.submit(); 
     32         } 
     33         return false; 
     34     }); 
     35    } 
    9136}); 
  • admin/js/jquery/jquery-ui.custom.js

    • Property exe deleted
  • admin/js/jquery/jquery.js

    • Property exe deleted
Note: See TracChangeset for help on using the changeset viewer.

Sites map