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/task.helpers.js

    r6977 r6981  
    666666                        }); 
    667667                    }); 
    668                     $('.attachment-list input').remove(); 
    669                     $('.row.fileupload-buttonbar .attachments-list p').remove(); 
     668                    $('div.new-task-win .attachment-list input').remove(); 
     669                    $('div.new-task-win .row.fileupload-buttonbar .attachments-list p').remove(); 
     670                    $('div.new-task-win .btn-danger.delete').addClass('hidden'); 
    670671                } 
    671672            } 
     
    685686        text: false 
    686687    }); 
    687     var maxSizeFile = 2000000; 
    688     $('#fileuploadtask').fileupload({ 
    689         sequentialUploads: true, 
    690         add: function (e, data) { 
    691             if (data.files[0].size < maxSizeFile) data.submit(); 
    692         }, 
    693         change: function (e, data) { 
    694             $.each(data.files, function (index, file) { 
    695                 var attach = {}; 
    696                 attach.fileName = file.name; 
    697                 var ext = file.name.split('.'); 
    698                 if (file.name.length > 10) attach.fileName = ext.length == 1 ? file.name.substr(0, 10) : file.name.substr(0, 6) + '.' + ext[ext.length - 1]; 
    699                 attach.fileSize = formatBytes(file.size); 
    700                 if (file.size > maxSizeFile) attach.error = 'Tamanho de arquivo nao permitido!!' 
    701  
    702                 $('div.new-task-win .attachments-list').append(DataLayer.render(path + 'templates/attachment_add_itemlist.ejs', { 
    703                     file: attach 
    704                 })); 
    705  
    706                 if (file.size < maxSizeFile) { 
    707                     $('div.new-task-win .fileinput-button.new').append(data.fileInput[0]).removeClass('new'); 
    708                     $('div.new-task-win .attachments-list').find('[type=file]').addClass('hidden'); 
    709  
    710                 } else $('div.new-task-win .fileinput-button.new').removeClass('new'); 
    711  
    712  
    713                 $('div.new-task-win .attachments-list').find('.button.close').button({ 
    714                     icons: { 
    715                         primary: "ui-icon-close" 
    716                     }, 
    717                     text: false 
    718                 }).click(function () { 
    719                     var idAttach = $(this).parent().find('input[name="fileId[]"]').val(); 
    720                     $('div.new-task-win .attachment-list').find('input[value="' + idAttach + '"]') 
    721                     $(this).parent().remove(); 
    722                 }); 
    723  
    724             }) 
    725         }, 
    726         done: function (e, data) { 
    727             var currentUpload = $('div.new-task-win .progress.after-upload:first').removeClass('after-upload').addClass('on-complete').hide(); 
    728  
    729             if ( !! data.result && data.result != "[]") { 
    730                 var newAttach = (attch = jQuery.parseJSON(data.result)) ? attch : jQuery.parseJSON(data.result[0].activeElement.childNodes[0].data); 
    731                 $('div.new-task-win .attachment-list').append('<input tyepe="hidden" name="attachment[]" value="' + newAttach['attachment'][0][0].id + '"/>'); 
    732                 currentUpload.removeClass('on-complete').parents('p').append('<input type="hidden" name="fileId[]" value="' + newAttach['attachment'][0][0].id + '"/>').find('.status-upload').addClass('ui-icon ui-icon-check'); 
    733             } else currentUpload.removeClass('on-complete').parents('p').find('.status-upload').addClass('ui-icon ui-icon-cancel'); 
    734         } 
    735     }); 
    736     $('div.new-task-win .attachments-list .button').button(); 
    737  
    738     if ( !! window.FormData) $('#fileuploadtask').bind('fileuploadstart', function () { 
    739         var widget = $(this), 
    740             progressElement = $('#fileupload-progress-task').fadeIn(), 
    741             interval = 500, 
    742             total = 0, 
    743             loaded = 0, 
    744             loadedBefore = 0, 
    745             progressTimer, progressHandler = function (e, data) { 
    746                 loaded = data.loaded; 
    747                 total = data.total; 
    748             }, 
    749             stopHandler = function () { 
    750                 widget.unbind('fileuploadprogressall', progressHandler).unbind('fileuploadstop', stopHandler); 
    751                 window.clearInterval(progressTimer); 
    752                 progressElement.fadeOut(function () { 
    753                     progressElement.html(''); 
    754                 }); 
    755             }, 
    756             formatTime = function (seconds) { 
    757                 var date = new Date(seconds * 1000); 
    758                 return ('0' + date.getUTCHours()).slice(-2) + ':' + ('0' + date.getUTCMinutes()).slice(-2) + ':' + ('0' + date.getUTCSeconds()).slice(-2); 
    759             }, 
    760  
    761             formatPercentage = function (floatValue) { 
    762                 return (floatValue * 100).toFixed(2) + ' %'; 
    763             }, 
    764             updateProgressElement = function (loaded, total, bps) { 
    765                 progressElement.html( 
    766                 formatBytes(bps) + 'ps | ' + formatTime((total - loaded) / bps) + ' | ' + formatPercentage(loaded / total) + ' | ' + formatBytes(loaded) + ' / ' + formatBytes(total)); 
    767             }, 
    768             intervalHandler = function () { 
    769                 var diff = loaded - loadedBefore; 
    770                 if (!diff) { 
    771                     return; 
    772                 } 
    773                 loadedBefore = loaded; 
    774                 updateProgressElement( 
    775                 loaded, total, diff * (1000 / interval)); 
    776             }; 
    777         widget.bind('fileuploadprogressall', progressHandler).bind('fileuploadstop', stopHandler); 
    778         progressTimer = window.setInterval(intervalHandler, interval); 
    779     }); 
     688 
     689    extendsFileupload('task', path); 
    780690 
    781691    disponibily(objTask, path, attendees, 'task'); 
Note: See TracChangeset for help on using the changeset viewer.