Dotclear

Changeset 1320:e3b4f3b9169a


Ignore:
Timestamp:
08/09/13 16:18:50 (12 years ago)
Author:
Nicolas <nikrou77@…>
Branch:
default
Message:

Revert jquery.fileupload files and upgrade them to latest state.
Start button is allways shown but disabled if any file is in the list to be send.

Location:
admin
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • admin/js/_media.js

    r1280 r1320  
    22     if ($('#fileupload').length==0) { 
    33          return; 
     4     } 
     5 
     6     function enableButton(button) { 
     7          button.prop('disabled',false).removeClass('disabled'); 
     8     } 
     9 
     10     function disableButton(button) { 
     11          button.prop('disabled',true).addClass('disabled'); 
    412     } 
    513 
     
    1018     }); 
    1119 
    12      $('.button.cancel', '#fileupload').click(function(e) { 
    13           $('.button.cancel, .button.start','#fileupload .fileupload-buttonbar').hide(); 
     20     $('.button.cancel', '#fileupload .fileupload-buttonbar').click(function(e) { 
     21          $('.button.cancel','#fileupload .fileupload-buttonbar').hide(); 
     22          disableButton($('.button.start','#fileupload .fileupload-buttonbar')); 
     23     }); 
     24 
     25     $('.cancel').live('click', function(e) { 
     26          if ($('.fileupload-ctrl .files .template-upload', '#fileupload').length==0) { 
     27               $('.button.cancel','#fileupload .fileupload-buttonbar').hide(); 
     28               disableButton($('.button.start','#fileupload .fileupload-buttonbar')); 
     29          } 
    1430     }); 
    1531 
     
    2844          disabled: true 
    2945     }).bind('fileuploadadd', function(e, data) { 
    30           $('.button.cancel, .button.start', '#fileupload .fileupload-buttonbar').show(); 
     46          $('.button.cancel','#fileupload .fileupload-buttonbar').show(); 
     47          enableButton($('.button.start','#fileupload .fileupload-buttonbar')); 
    3148     }).bind('fileuploaddone', function(e, data) { 
    3249          if (data.result.files[0].html !==undefined) { 
     
    3653     }).bind('fileuploadalways', function(e, data) { 
    3754         if ($('.fileupload-ctrl .files .template-upload', '#fileupload').length==0) { 
    38           $('.button.start, .button.cancel','#fileupload .fileupload-buttonbar').hide(); 
     55          $('.button.cancel','#fileupload .fileupload-buttonbar').hide(); 
     56          disableButton($('.button.start','#fileupload .fileupload-buttonbar')); 
    3957         } 
    4058     }); 
     
    4765          label = dotclear.jsUpload.msg.choose_files; 
    4866          $('#fileupload').fileupload({disabled:false}); 
     67          disableButton($('.button.start','#fileupload .fileupload-buttonbar')); 
    4968     } else { 
    5069          $msg = dotclear.msg.enhanced_uploader_activate; 
     
    6180               // We must remove files in table 
    6281               $('.files .upload-file', '#fileupload').remove(); 
    63                $('.button.cancel, .button.start','#fileupload .fileupload-buttonbar').hide(); 
    64                $('.button.start','#fileupload').show(); 
     82               $('.button.cancel,.button.clean','#fileupload .fileupload-buttonbar').hide(); 
    6583               $('#fileupload').fileupload({disabled:true}); 
    6684          } else { 
     
    6886               label = dotclear.jsUpload.msg.choose_files; 
    6987               $('#upfile').attr('multiple', true); 
    70                $('.button.start','#fileupload').hide(); 
     88               var startButton = $('.button.start','#fileupload .fileupload-buttonbar'); 
     89               disableButton(startButton); 
     90               startButton.show(); 
    7191               $('#fileupload').fileupload({disabled:false}); 
    7292          } 
  • admin/js/jsUpload/jquery.fileupload-process.js

    r1144 r1320  
    11/* 
    2  * jQuery File Upload Processing Plugin 1.1 
     2 * jQuery File Upload Processing Plugin 1.2.2 
    33 * https://github.com/blueimp/jQuery-File-Upload 
    44 * 
     
    9999            var processQueue = []; 
    100100            $.each(options.processQueue, function () { 
    101                 var settings = {}; 
     101                var settings = {}, 
     102                    action = this.action, 
     103                    prefix = this.prefix === true ? action : this.prefix; 
    102104                $.each(this, function (key, value) { 
    103105                    if ($.type(value) === 'string' && 
    104106                            value.charAt(0) === '@') { 
    105                         settings[key] = options[value.slice(1)]; 
     107                        settings[key] = options[ 
     108                            value.slice(1) || (prefix ? prefix + 
     109                                key.charAt(0).toUpperCase() + key.slice(1) : key) 
     110                        ]; 
    106111                    } else { 
    107112                        settings[key] = value; 
    108113                    } 
     114 
    109115                }); 
    110116                processQueue.push(settings); 
     
    128134                    this._trigger('processstart'); 
    129135                } 
    130                 $.each(data.files, function (index, file) { 
     136                $.each(data.files, function (index) { 
    131137                    var opts = index ? $.extend({}, options) : options, 
    132138                        func = function () { 
  • admin/js/jsUpload/jquery.fileupload-ui.js

    r1206 r1320  
    11/* 
    2  * jQuery File Upload User Interface Plugin 8.2.1 
     2 * jQuery File Upload User Interface Plugin 8.7.1 
    33 * https://github.com/blueimp/jQuery-File-Upload 
    44 * 
     
    2020            'jquery', 
    2121            'tmpl', 
    22             './jquery.fileupload-resize', 
     22            './jquery.fileupload-image', 
     23            './jquery.fileupload-audio', 
     24            './jquery.fileupload-video', 
    2325            './jquery.fileupload-validate' 
    2426        ], factory); 
     
    104106                    ); 
    105107                }); 
    106  
    107             /* 
    108              *   
    109              *  Activation du bouton si un fichier trouvé 
    110              */ 
    111                 var fileUploadButtonBar = that.element.find('.fileupload-buttonbar'); 
    112                 fileUploadButtonBar.find('.start').prop('disabled', false); 
    113                 fileUploadButtonBar.find('.start').removeClass('disabled'); 
    114              /* 
    115              * 
    116              */ 
    117108            }, 
    118109            // Callback for the start of each file upload request: 
    119110            send: function (e, data) { 
    120                 $(this).find('.start').hide(); 
    121111                var that = $(this).data('blueimp-fileupload') || 
    122112                        $(this).data('fileupload'); 
     
    140130            // Callback for successful uploads: 
    141131            done: function (e, data) { 
    142  
    143132                var that = $(this).data('blueimp-fileupload') || 
    144133                        $(this).data('fileupload'), 
     
    151140                    data.context.each(function (index) { 
    152141                        var file = files[index] || 
    153                                 {error: 'Empty file upload result'}, 
    154                             deferred = that._addFinishedDeferreds(); 
     142                                {error: 'Empty file upload result'}; 
     143                        deferred = that._addFinishedDeferreds(); 
    155144                        that._transition($(this)).done( 
    156145                            function () { 
     
    171160                    }); 
    172161                } else { 
    173                     template = that._renderDownload(files) 
    174                         .appendTo(that.options.filesContainer); 
     162                    template = that._renderDownload(files)[ 
     163                        that.options.prependFiles ? 'prependTo' : 'appendTo' 
     164                    ](that.options.filesContainer); 
    175165                    that._forceReflow(template); 
    176166                    deferred = that._addFinishedDeferreds(); 
     
    227217                    }); 
    228218                } else if (data.errorThrown !== 'abort') { 
    229                     data.context = that._renderUpload(data.files) 
    230                         .appendTo(that.options.filesContainer) 
     219                    data.context = that._renderUpload(data.files)[ 
     220                        that.options.prependFiles ? 'prependTo' : 'appendTo' 
     221                    ](that.options.filesContainer) 
    231222                        .data('data', data); 
    232223                    that._forceReflow(data.context); 
     
    281272            // Callback for uploads start, equivalent to the global ajaxStart event: 
    282273            start: function (e) { 
    283                 $(this).find('.start').hide(); 
    284274                var that = $(this).data('blueimp-fileupload') || 
    285                 $(this).data('fileupload'); 
     275                        $(this).data('fileupload'); 
    286276                that._resetFinishedDeferreds(); 
    287277                that._transition($(this).find('.fileupload-progress')).done( 
    288  
    289278                    function () { 
    290  
    291279                        that._trigger('started', e); 
    292280                    } 
     
    295283            // Callback for uploads stop, equivalent to the global ajaxStop event: 
    296284            stop: function (e) { 
    297                 $(this).find('.start').show(); 
    298285                var that = $(this).data('blueimp-fileupload') || 
    299286                        $(this).data('fileupload'), 
     
    312299                    } 
    313300                ); 
    314             /* 
    315              *  Recherche des fichers restants à uploader 
    316              *  Désactivation du bouton si plus rien 
    317              */ 
    318              var filesList = that.options.filesContainer; 
    319              if(filesList.find('.start').size() == 0) { 
    320                 var fileUploadButtonBar = that.element.find('.fileupload-buttonbar'); 
    321                 fileUploadButtonBar.find('.start').prop('disabled', true); 
    322                 fileUploadButtonBar.find('.start').addClass('disabled'); 
    323              } 
    324             /* 
    325              * 
    326              */ 
    327301            }, 
    328302            processstart: function () { 
     
    335309            destroy: function (e, data) { 
    336310                var that = $(this).data('blueimp-fileupload') || 
    337                         $(this).data('fileupload'); 
    338                 if (data.url) { 
    339                     $.ajax(data).done(function () { 
     311                        $(this).data('fileupload'), 
     312                    removeNode = function () { 
    340313                        that._transition(data.context).done( 
    341314                            function () { 
     
    344317                            } 
    345318                        ); 
    346                     }); 
     319                    }; 
     320                if (data.url) { 
     321                    $.ajax(data).done(removeNode); 
     322                } else { 
     323                    removeNode(); 
    347324                } 
    348325            } 
     
    637614            this._super(); 
    638615            this._resetFinishedDeferreds(); 
     616            if (!$.support.fileInput) { 
     617                this._disableFileInputButton(); 
     618            } 
    639619        }, 
    640620 
  • admin/js/jsUpload/jquery.fileupload.js

    r1144 r1320  
    11/* 
    2  * jQuery File Upload Plugin 5.31.1 
     2 * jQuery File Upload Plugin 5.32.2 
    33 * https://github.com/blueimp/jQuery-File-Upload 
    44 * 
     
    1111 
    1212/*jslint nomen: true, unparam: true, regexp: true */ 
    13 /*global define, window, document, File, Blob, FormData, location */ 
     13/*global define, window, document, location, File, Blob, FormData */ 
    1414 
    1515(function (factory) { 
     
    2828    'use strict'; 
    2929 
     30    // Detect file input support, based on 
     31    // http://viljamis.com/blog/2012/file-upload-support-on-mobile/ 
     32    $.support.fileInput = !(new RegExp( 
     33        // Handle devices which give false positives for the feature detection: 
     34        '(Android (1\\.[0156]|2\\.[01]))' + 
     35            '|(Windows Phone (OS 7|8\\.0))|(XBLWP)|(ZuneWP)|(WPDesktop)' + 
     36            '|(w(eb)?OSBrowser)|(webOS)' + 
     37            '|(Kindle/(1\\.0|2\\.[05]|3\\.0))' 
     38    ).test(window.navigator.userAgent) || 
     39        // Feature detection for all other devices: 
     40        $('<input type="file">').prop('disabled')); 
     41 
    3042    // The FileReader API is not actually used, but works as feature detection, 
    3143    // as e.g. Safari supports XHR file uploads via the FormData API, 
     
    3345    $.support.xhrFileUpload = !!(window.XMLHttpRequestUpload && window.FileReader); 
    3446    $.support.xhrFormDataFileUpload = !!window.FormData; 
     47 
     48    // Detect support for Blob slicing (required for chunked uploads): 
     49    $.support.blobSlice = window.Blob && (Blob.prototype.slice || 
     50        Blob.prototype.webkitSlice || Blob.prototype.mozSlice); 
    3551 
    3652    // The fileupload widget listens for change events on file input fields defined 
     
    145161            // widget (via file input selection, drag & drop, paste or add API call). 
    146162            // If the singleFileUploads option is enabled, this callback will be 
    147             // called once for each file in the selection for XHR file uplaods, else 
     163            // called once for each file in the selection for XHR file uploads, else 
    148164            // once for each file selection. 
     165            // 
    149166            // The upload starts when the submit method is invoked on the data parameter. 
    150167            // The data object contains a files property holding the added files 
    151             // and allows to override plugin options as well as define ajax settings. 
     168            // and allows you to override plugin options as well as define ajax settings. 
     169            // 
    152170            // Listeners for this callback can also be bound the following way: 
    153171            // .bind('fileuploadadd', func); 
     172            // 
    154173            // data.submit() returns a Promise object and allows to attach additional 
    155174            // handlers using jQuery's Deferred callbacks: 
     
    233252            'forceIframeTransport' 
    234253        ], 
     254 
     255        _blobSlice: $.support.blobSlice && function () { 
     256            var slice = this.slice || this.webkitSlice || this.mozSlice; 
     257            return slice.apply(this, arguments); 
     258        }, 
    235259 
    236260        _BitrateTimer: function () { 
     
    380404                options.headers['Content-Range'] = options.contentRange; 
    381405            } 
    382             if (!multipart) { 
     406            if (!multipart || options.blob || !this._isInstanceOf('File', file)) { 
    383407                options.headers['Content-Disposition'] = 'attachment; filename="' + 
    384408                    encodeURI(file.name) + '"'; 
     409            } 
     410            if (!multipart) { 
    385411                options.contentType = file.type; 
    386412                options.data = options.blob || file; 
     
    415441                    } 
    416442                    if (options.blob) { 
    417                         options.headers['Content-Disposition'] = 'attachment; filename="' + 
    418                             encodeURI(file.name) + '"'; 
    419443                        formData.append(paramName, options.blob, file.name); 
    420444                    } else { 
     
    440464 
    441465        _initIframeSettings: function (options) { 
     466            var targetHost = $('<a></a>').prop('href', options.url).prop('host'); 
    442467            // Setting the dataType to iframe enables the iframe transport: 
    443468            options.dataType = 'iframe ' + (options.dataType || ''); 
     
    445470            options.formData = this._getFormData(options); 
    446471            // Add redirect url to form data on cross-domain uploads: 
    447             if (options.redirect && $('<a></a>').prop('href', options.url) 
    448                     .prop('host') !== location.host) { 
     472            if (options.redirect && targetHost && targetHost !== location.host) { 
    449473                options.formData.push({ 
    450474                    name: options.redirectParamName || 'redirect', 
     
    628652        // upload requests: 
    629653        _chunkedUpload: function (options, testOnly) { 
     654            options.uploadedBytes = options.uploadedBytes || 0; 
    630655            var that = this, 
    631656                file = options.files[0], 
    632657                fs = file.size, 
    633                 ub = options.uploadedBytes = options.uploadedBytes || 0, 
     658                ub = options.uploadedBytes, 
    634659                mcs = options.maxChunkSize || fs, 
    635                 slice = file.slice || file.webkitSlice || file.mozSlice, 
     660                slice = this._blobSlice, 
    636661                dfd = $.Deferred(), 
    637662                promise = dfd.promise(), 
     
    851876                    pipe = slot.pipe(send); 
    852877                } else { 
    853                     pipe = (this._sequence = this._sequence.pipe(send, send)); 
     878                    this._sequence = this._sequence.pipe(send, send); 
     879                    pipe = this._sequence; 
    854880                } 
    855881                // Return the piped Promise object, enhanced with an abort method, 
     
    11011127 
    11021128        _onDrop: function (e) { 
     1129            e.dataTransfer = e.originalEvent && e.originalEvent.dataTransfer; 
    11031130            var that = this, 
    1104                 dataTransfer = e.dataTransfer = e.originalEvent && 
    1105                     e.originalEvent.dataTransfer, 
     1131                dataTransfer = e.dataTransfer, 
    11061132                data = {}; 
    11071133            if (dataTransfer && dataTransfer.files && dataTransfer.files.length) { 
     
    11171143 
    11181144        _onDragOver: function (e) { 
    1119             var dataTransfer = e.dataTransfer = e.originalEvent && 
    1120                 e.originalEvent.dataTransfer; 
     1145            e.dataTransfer = e.originalEvent && e.originalEvent.dataTransfer; 
     1146            var dataTransfer = e.dataTransfer; 
    11211147            if (dataTransfer) { 
    11221148                if (this._trigger('dragover', e) === false) { 
     
    11401166                }); 
    11411167            } 
    1142             this._on(this.options.fileInput, { 
    1143                 change: this._onChange 
    1144             }); 
     1168            if ($.support.fileInput) { 
     1169                this._on(this.options.fileInput, { 
     1170                    change: this._onChange 
     1171                }); 
     1172            } 
    11451173        }, 
    11461174 
     
    12761304                                return; 
    12771305                            } 
     1306                            if (!files.length) { 
     1307                                dfd.reject(); 
     1308                                return; 
     1309                            } 
    12781310                            data.files = files; 
    12791311                            jqXHR = that._onSend(null, data).then( 
  • admin/js/jsUpload/jquery.iframe-transport.js

    r1144 r1320  
    11/* 
    2  * jQuery Iframe Transport Plugin 1.6.2 
     2 * jQuery Iframe Transport Plugin 1.7 
    33 * https://github.com/blueimp/jQuery-File-Upload 
    44 * 
     
    171171 
    172172    // The iframe transport returns the iframe content document as response. 
    173     // The following adds converters from iframe to text, json, html, and script: 
     173    // The following adds converters from iframe to text, json, html, xml 
     174    // and script. 
     175    // Please note that the Content-Type for JSON responses has to be text/plain 
     176    // or text/html, if the browser doesn't include application/json in the 
     177    // Accept header, else IE will show a download dialog. 
     178    // The Content-Type for XML responses on the other hand has to be always 
     179    // application/xml or text/xml, so IE properly parses the XML response. 
     180    // See also 
     181    // https://github.com/blueimp/jQuery-File-Upload/wiki/Setup#content-type-negotiation 
    174182    $.ajaxSetup({ 
    175183        converters: { 
     
    182190            'iframe html': function (iframe) { 
    183191                return iframe && $(iframe[0].body).html(); 
     192            }, 
     193            'iframe xml': function (iframe) { 
     194                var xmlDoc = iframe && iframe[0]; 
     195                return xmlDoc && $.isXMLDoc(xmlDoc) ? xmlDoc : 
     196                        $.parseXML((xmlDoc.XMLDocument && xmlDoc.XMLDocument.xml) || 
     197                            $(xmlDoc.body).html()); 
    184198            }, 
    185199            'iframe script': function (iframe) { 
  • admin/style/jsUpload/style.css

    r1209 r1320  
    7676} 
    7777 
    78 .button.clean, .button.cancel, .button.add, .enhanced_uploader .fileupload-buttonbar .button.start { 
     78.button.clean, .button.cancel, .button.add { 
    7979     display: none; 
    8080} 
Note: See TracChangeset for help on using the changeset viewer.

Sites map