Dotclear

source: admin/js/_media.js @ 1159:887a30463ee0

Revision 1159:887a30463ee0, 1.8 KB checked in by Nicolas <nikrou77@…>, 12 years ago (diff)

Improve upload multiple
Restore option to enable/disable enhanced interface

Line 
1$(function() {
2    var jqXHR = null;
3    $('#fileupload').fileupload({
4     url: $('#fileupload').attr('action'),
5     autoUpload: false,
6     disabled: true
7    }).bind('fileuploaddone', function(e, data) {
8     if (data.result.files[0].html !==undefined) {
9         $('.media-list').append(data.result.files[0].html);
10     }
11    });
12
13    if (!$.browser.opera) {
14     var $container = $('#fileupload').parent().parent();
15     var $msg;
16
17     if ($container.hasClass('enhanced_uploader')) {
18         $msg = dotclear.msg.enhanced_uploader_disable;
19         $('#fileupload').fileupload({disabled:false});
20     } else {
21         $msg = dotclear.msg.enhanced_uploader_activate;
22     }
23
24     $('<div><a href="#">' + $msg + '</a></div>').click( function() {
25         if ($container.hasClass('enhanced_uploader')) {
26          $msg = dotclear.msg.enhanced_uploader_activate;
27          $('#upfile').attr('multiple', false);
28
29          // when a user has clicked enhanced_uploader, and has added files
30          // We must remove files in table
31          $('.table-files tr', '#fileupload').remove();
32          $('#fileupload').fileupload({disabled:true});
33         } else {
34          $msg = dotclear.msg.enhanced_uploader_disable;
35          $('#upfile').attr('multiple', true);
36          $('#fileupload').fileupload({disabled:false});
37         }
38         $(this).find('a').text($msg);
39
40         $container.toggleClass('enhanced_uploader');
41     }).appendTo($('#fileupload'));
42    }
43
44    // Replace remove links by a POST on hidden form
45    fileRemoveAct();
46
47    function fileRemoveAct() {
48     $('a.media-remove').live('click', function() {
49         var m_name = $(this).parents('ul').find('li:first>a').text();
50         if (window.confirm(dotclear.msg.confirm_delete_media.replace('%s',m_name))) {
51          var f = $('#media-remove-hide').get(0);
52          f.elements['remove'].value = this.href.replace(/^(.*)&remove=(.*?)(&|$)/,'$2');
53          this.href = '';
54          f.submit();
55         }
56         return false;
57     });
58    }
59});
Note: See TracBrowser for help on using the repository browser.

Sites map