Ignore:
Timestamp:
08/09/12 18:31:49 (12 years ago)
Author:
acoutinho
Message:

Ticket #2966 - Correcao de bugs e refactoring das novas funcionalidades

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/2.4.2-expresso1/prototype/modules/calendar/js/activity.helpers.js

    r6977 r6981  
    363363                        }); 
    364364                }); 
    365                 $('.attachment-list input').remove(); 
    366                 $('.row.fileupload-buttonbar-activity .attachments-list p').remove(); 
     365                $('div.new-activity-win .attachment-list input').remove(); 
     366                $('div.new-activity-win .row.fileupload-buttonbar-activity .attachments-list p').remove(); 
     367                $('div.new-activity-win .btn-danger.delete').addClass('hidden'); 
    367368            } 
    368369        }}); 
     
    383384    text: false 
    384385}); 
    385 var maxSizeFile = 2000000; 
    386 $('#fileuploadactivity').fileupload({ 
    387     sequentialUploads: true, 
    388     add: function (e, data) { 
    389         if(data.files[0].size < maxSizeFile) 
    390             data.submit(); 
    391     }, 
    392     change: function (e, data) { 
    393         $.each(data.files, function (index, file) { 
    394             var attach = {}; 
    395             attach.fileName = file.name; 
    396             var ext = file.name.split('.'); 
    397             if(file.name.length > 10) 
    398                 attach.fileName = ext.length == 1 ? file.name.substr(0, 10) :  file.name.substr(0, 6) + '.' + ext[ext.length -1]; 
    399             attach.fileSize = formatBytes(file.size); 
    400             if(file.size > maxSizeFile) 
    401                 attach.error = 'Tamanho de arquivo nao permitido!!' 
    402                                  
    403             $('div.new-activity-win .attachments-list').append(DataLayer.render(path+'templates/attachment_add_itemlist.ejs', { 
    404                 file : attach 
    405             })); 
    406                                  
    407             if(file.size < maxSizeFile){ 
    408                 $('div.new-activity-win .fileinput-button.new').append(data.fileInput[0]).removeClass('new'); 
    409                 $('div.new-activity-win .attachments-list').find('[type=file]').addClass('hidden'); 
    410                                          
    411             }else 
    412                 $('div.new-activity-win .fileinput-button.new').removeClass('new'); 
    413                                  
    414                                  
    415             $('div.new-activity-win .attachments-list').find('.button.close').button({ 
    416                 icons: { 
    417                     primary: "ui-icon-close" 
    418                 }, 
    419                 text: false 
    420             }).click(function(){ 
    421                 var idAttach = $(this).parent().find('input[name="fileId[]"]').val(); 
    422                 $('.attachment-list').find('input[value="'+idAttach+'"]') 
    423                 $(this).parent().remove(); 
    424             });  
    425                                  
    426         }) 
    427         }, 
    428     done: function(e, data){ 
    429         var currentUpload = $('div.new-activity-win .progress.after-upload:first').removeClass('after-upload').addClass('on-complete').hide(); 
    430  
    431         if(!!data.result && data.result != "[]"){ 
    432             var newAttach = (attch = jQuery.parseJSON(data.result)) ? attch : jQuery.parseJSON(data.result[0].activeElement.childNodes[0].data); 
    433             $('div.new-activity-win .attachment-list').append('<input tyepe="hidden" name="attachment[]" value="'+newAttach['attachment'][0][0].id+'"/>'); 
    434             currentUpload.removeClass('on-complete').parents('p') 
    435             .append('<input type="hidden" name="fileId[]" value="'+newAttach['attachment'][0][0].id+'"/>') 
    436             .find('.status-upload').addClass('ui-icon ui-icon-check'); 
    437         }else 
    438             currentUpload.removeClass('on-complete').parents('p').find('.status-upload').addClass('ui-icon ui-icon-cancel'); 
    439         } 
    440 }); 
    441 $('.attachments-list .button').button(); 
    442  
    443 if(!!window.FormData)                    
    444 $('#fileuploadactivity').bind('fileuploadstart', function () { 
    445     var widget = $(this), 
    446     progressElement = $('#fileupload-progress-activity').fadeIn(), 
    447     interval = 500, 
    448     total = 0, 
    449     loaded = 0, 
    450     loadedBefore = 0, 
    451     progressTimer, 
    452     progressHandler = function (e, data) { 
    453         loaded = data.loaded; 
    454         total = data.total; 
    455     }, 
    456     stopHandler = function () { 
    457         widget 
    458         .unbind('fileuploadprogressall', progressHandler) 
    459         .unbind('fileuploadstop', stopHandler); 
    460         window.clearInterval(progressTimer); 
    461         progressElement.fadeOut(function () { 
    462             progressElement.html(''); 
    463         }); 
    464     }, 
    465     formatTime = function (seconds) { 
    466         var date = new Date(seconds * 1000); 
    467         return ('0' + date.getUTCHours()).slice(-2) + ':' + 
    468         ('0' + date.getUTCMinutes()).slice(-2) + ':' + 
    469         ('0' + date.getUTCSeconds()).slice(-2); 
    470     }, 
    471     /* formatBytes = function (bytes) { 
    472             if (bytes >= 1000000000) { 
    473                 return (bytes / 1000000000).toFixed(2) + ' GB'; 
    474             } 
    475             if (bytes >= 1000000) { 
    476                 return (bytes / 1000000).toFixed(2) + ' MB'; 
    477             } 
    478             if (bytes >= 1000) { 
    479                 return (bytes / 1000).toFixed(2) + ' KB'; 
    480             } 
    481             return bytes + ' B'; 
    482         },*/ 
    483     formatPercentage = function (floatValue) { 
    484         return (floatValue * 100).toFixed(2) + ' %'; 
    485     }, 
    486     updateProgressElement = function (loaded, total, bps) { 
    487         progressElement.html( 
    488             formatBytes(bps) + 'ps | ' + 
    489             formatTime((total - loaded) / bps) + ' | ' + 
    490             formatPercentage(loaded / total) + ' | ' + 
    491             formatBytes(loaded) + ' / ' + formatBytes(total) 
    492             ); 
    493     }, 
    494     intervalHandler = function () { 
    495         var diff = loaded - loadedBefore; 
    496         if (!diff) { 
    497             return; 
    498         } 
    499         loadedBefore = loaded; 
    500         updateProgressElement( 
    501             loaded, 
    502             total, 
    503             diff * (1000 / interval) 
    504             ); 
    505     }; 
    506     widget 
    507     .bind('fileuploadprogressall', progressHandler) 
    508     .bind('fileuploadstop', stopHandler); 
    509     progressTimer = window.setInterval(intervalHandler, interval); 
    510 }); 
     386 
     387extendsFileupload('activity', path); 
    511388 
    512389UI.dialogs.addActivity.find(':input').change(function(event){ 
Note: See TracChangeset for help on using the changeset viewer.