- Timestamp:
- 08/09/12 18:31:49 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/2.4.2-expresso1/prototype/modules/calendar/js/helpers.js
r6976 r6981 164 164 $('.fc-header-right').append(print); 165 165 $('.fc-button-print').click(function(){ 166 167 166 alert('A tela de impressão será melhor visualizada com a preferência "Paisagem" do seu browser selecionada.'); 167 printNow(); 168 168 }); 169 169 } … … 1453 1453 }); 1454 1454 }); 1455 $('.attachment-list input').remove(); 1456 $('.row.fileupload-buttonbar .attachments-list p').remove(); 1455 $('div.new-event-win .attachment-list input').remove(); 1456 $('div.new-event-win .row.fileupload-buttonbar .attachments-list p').remove(); 1457 $('div.new-event-win .btn-danger.delete').addClass('hidden'); 1457 1458 } 1458 1459 }}); … … 1473 1474 text: false 1474 1475 }); 1475 var maxSizeFile = 2000000; 1476 $('#fileuploadevent').fileupload({ 1477 sequentialUploads: true, 1478 add: function (e, data) { 1479 if(data.files[0].size < maxSizeFile) 1480 data.submit(); 1481 }, 1482 change: function (e, data) { 1483 $.each(data.files, function (index, file) { 1484 var attach = {}; 1485 attach.fileName = file.name; 1486 var ext = file.name.split('.'); 1487 if(file.name.length > 10) 1488 attach.fileName = ext.length == 1 ? file.name.substr(0, 10) : file.name.substr(0, 6) + '.' + ext[ext.length -1]; 1489 attach.fileSize = formatBytes(file.size); 1490 if(file.size > maxSizeFile) 1491 attach.error = 'Tamanho de arquivo nao permitido!!' 1492 1493 $('div.new-event-win .attachments-list').append(DataLayer.render(path+'templates/attachment_add_itemlist.ejs', { 1494 file : attach 1495 })); 1496 1497 if(file.size < maxSizeFile){ 1498 $('div.new-event-win .fileinput-button.new').append(data.fileInput[0]).removeClass('new'); 1499 $('div.new-event-win .attachments-list').find('[type=file]').addClass('hidden'); 1500 1501 }else 1502 $('div.new-event-win .fileinput-button.new').removeClass('new'); 1503 1504 1505 $('div.new-event-win .attachments-list').find('.button.close').button({ 1506 icons: { 1507 primary: "ui-icon-close" 1508 }, 1509 text: false 1510 }).click(function(){ 1511 var idAttach = $(this).parent().find('input[name="fileId[]"]').val(); 1512 $('div.new-event-win .attachment-list').find('input[value="'+idAttach+'"]') 1513 $(this).parent().remove(); 1514 }); 1515 1516 }) 1517 }, 1518 done: function(e, data){ 1519 var currentUpload = $('div.new-event-win .progress.after-upload:first').removeClass('after-upload').addClass('on-complete').hide(); 1520 1521 if(!!data.result && data.result != "[]"){ 1522 var newAttach = (attch = jQuery.parseJSON(data.result)) ? attch : jQuery.parseJSON(data.result[0].activeElement.childNodes[0].data); 1523 $('div.new-event-win .attachment-list').append('<input tyepe="hidden" name="attachment[]" value="'+newAttach['attachment'][0][0].id+'"/>'); 1524 currentUpload.removeClass('on-complete').parents('p') 1525 .append('<input type="hidden" name="fileId[]" value="'+newAttach['attachment'][0][0].id+'"/>') 1526 .find('.status-upload').addClass('ui-icon ui-icon-check'); 1527 }else 1528 currentUpload.removeClass('on-complete').parents('p').find('.status-upload').addClass('ui-icon ui-icon-cancel'); 1529 } 1530 }); 1531 $('.attachments-list .button').button(); 1532 1533 if(!!window.FormData) 1534 $('#fileuploadevent').bind('fileuploadstart', function () { 1535 var widget = $(this), 1536 progressElement = $('#fileupload-progress-event').fadeIn(), 1537 interval = 500, 1538 total = 0, 1539 loaded = 0, 1540 loadedBefore = 0, 1541 progressTimer, 1542 progressHandler = function (e, data) { 1543 loaded = data.loaded; 1544 total = data.total; 1545 }, 1546 stopHandler = function () { 1547 widget 1548 .unbind('fileuploadprogressall', progressHandler) 1549 .unbind('fileuploadstop', stopHandler); 1550 window.clearInterval(progressTimer); 1551 progressElement.fadeOut(function () { 1552 progressElement.html(''); 1553 }); 1554 }, 1555 formatTime = function (seconds) { 1556 var date = new Date(seconds * 1000); 1557 return ('0' + date.getUTCHours()).slice(-2) + ':' + 1558 ('0' + date.getUTCMinutes()).slice(-2) + ':' + 1559 ('0' + date.getUTCSeconds()).slice(-2); 1560 }, 1561 /* formatBytes = function (bytes) { 1562 if (bytes >= 1000000000) { 1563 return (bytes / 1000000000).toFixed(2) + ' GB'; 1564 } 1565 if (bytes >= 1000000) { 1566 return (bytes / 1000000).toFixed(2) + ' MB'; 1567 } 1568 if (bytes >= 1000) { 1569 return (bytes / 1000).toFixed(2) + ' KB'; 1570 } 1571 return bytes + ' B'; 1572 },*/ 1573 formatPercentage = function (floatValue) { 1574 return (floatValue * 100).toFixed(2) + ' %'; 1575 }, 1576 updateProgressElement = function (loaded, total, bps) { 1577 progressElement.html( 1578 formatBytes(bps) + 'ps | ' + 1579 formatTime((total - loaded) / bps) + ' | ' + 1580 formatPercentage(loaded / total) + ' | ' + 1581 formatBytes(loaded) + ' / ' + formatBytes(total) 1582 ); 1583 }, 1584 intervalHandler = function () { 1585 var diff = loaded - loadedBefore; 1586 if (!diff) { 1587 return; 1588 } 1589 loadedBefore = loaded; 1590 updateProgressElement( 1591 loaded, 1592 total, 1593 diff * (1000 / interval) 1594 ); 1595 }; 1596 widget 1597 .bind('fileuploadprogressall', progressHandler) 1598 .bind('fileuploadstop', stopHandler); 1599 progressTimer = window.setInterval(intervalHandler, interval); 1600 }); 1476 1477 extendsFileupload('event', path); 1601 1478 1602 1479 if(objEvent.isShared){ … … 2573 2450 case 'basicDay': 2574 2451 case 'agendaDay': 2575 rangeStart = new Date ().add({2452 rangeStart = new Date.today().add({ 2576 2453 days: page_index 2577 2454 }).getTime(); 2578 rangeEnd = rangeStart ;2455 rangeEnd = rangeStart + 86400000; 2579 2456 break; 2580 2457 case 'agendaWeek': … … 2982 2859 } 2983 2860 } 2861 2862 function extendsFileupload(view, path){ 2863 var viewName = 'div.new-'+view+'-win'; 2864 2865 path = !!path ? path : ''; 2866 2867 var maxSizeFile = 2000000; 2868 $('#fileupload'+view).fileupload({ 2869 sequentialUploads: true, 2870 add: function (e, data) { 2871 if(data.files[0].size < maxSizeFile) 2872 data.submit(); 2873 }, 2874 change: function (e, data) { 2875 $.each(data.files, function (index, file) { 2876 var attach = {}; 2877 attach.fileName = file.name; 2878 var ext = file.name.split('.'); 2879 if(file.name.length > 10) 2880 attach.fileName = ext.length == 1 ? file.name.substr(0, 10) : file.name.substr(0, 6) + '.' + ext[ext.length -1]; 2881 attach.fileSize = formatBytes(file.size); 2882 if(file.size > maxSizeFile) 2883 attach.error = 'Tamanho de arquivo nao permitido!!' 2884 2885 $(viewName+' .attachments-list').append(DataLayer.render(path+'templates/attachment_add_itemlist.ejs', { 2886 file : attach 2887 })); 2888 2889 if(file.size < maxSizeFile){ 2890 $(viewName+' .fileinput-button.new').append(data.fileInput[0]).removeClass('new'); 2891 $(viewName+' .attachments-list').find('[type=file]').addClass('hidden'); 2892 2893 }else 2894 $(viewName+' .fileinput-button.new').removeClass('new'); 2895 2896 2897 $(viewName+' .attachments-list').find('.button.close').button({ 2898 icons: { 2899 primary: "ui-icon-close" 2900 }, 2901 text: false 2902 }).click(function(){ 2903 var idAttach = $(this).parent().find('input[name="fileId[]"]').val(); 2904 $(viewName+' .attachment-list').find('input[value="'+idAttach+'"]').remove(); 2905 $(this).parent().remove(); 2906 2907 if(!$(viewName+' .attachment-list input').length) 2908 $(viewName+' .btn-danger.delete').addClass('hidden'); 2909 2910 }); 2911 2912 }) 2913 }, 2914 done: function(e, data){ 2915 var currentUpload = $(viewName+' .progress.after-upload:first').removeClass('after-upload').addClass('on-complete').hide(); 2916 2917 if(!!data.result && data.result != "[]"){ 2918 $(viewName+' .btn-danger.delete').removeClass('hidden'); 2919 var newAttach = (attch = jQuery.parseJSON(data.result)) ? attch : jQuery.parseJSON(data.result[0].activeElement.childNodes[0].data); 2920 $(viewName+' .attachment-list').append('<input tyepe="hidden" name="attachment[]" value="'+newAttach['attachment'][0][0].id+'"/>'); 2921 currentUpload.removeClass('on-complete').parents('p') 2922 .append('<input type="hidden" name="fileId[]" value="'+newAttach['attachment'][0][0].id+'"/>') 2923 .find('.status-upload').addClass('ui-icon ui-icon-check'); 2924 }else 2925 currentUpload.removeClass('on-complete').parents('p').find('.status-upload').addClass('ui-icon ui-icon-cancel'); 2926 } 2927 }); 2928 $('.attachments-list .button').button(); 2929 2930 if(!!window.FormData) 2931 $('#fileupload'+view).bind('fileuploadstart', function () { 2932 var widget = $(this), 2933 progressElement = $('#fileupload-progress-'+view).fadeIn(), 2934 interval = 500, 2935 total = 0, 2936 loaded = 0, 2937 loadedBefore = 0, 2938 progressTimer, 2939 progressHandler = function (e, data) { 2940 loaded = data.loaded; 2941 total = data.total; 2942 }, 2943 stopHandler = function () { 2944 widget 2945 .unbind('fileuploadprogressall', progressHandler) 2946 .unbind('fileuploadstop', stopHandler); 2947 window.clearInterval(progressTimer); 2948 progressElement.fadeOut(function () { 2949 progressElement.html(''); 2950 }); 2951 }, 2952 formatTime = function (seconds) { 2953 var date = new Date(seconds * 1000); 2954 return ('0' + date.getUTCHours()).slice(-2) + ':' + 2955 ('0' + date.getUTCMinutes()).slice(-2) + ':' + 2956 ('0' + date.getUTCSeconds()).slice(-2); 2957 }, 2958 /* formatBytes = function (bytes) { 2959 if (bytes >= 1000000000) { 2960 return (bytes / 1000000000).toFixed(2) + ' GB'; 2961 } 2962 if (bytes >= 1000000) { 2963 return (bytes / 1000000).toFixed(2) + ' MB'; 2964 } 2965 if (bytes >= 1000) { 2966 return (bytes / 1000).toFixed(2) + ' KB'; 2967 } 2968 return bytes + ' B'; 2969 },*/ 2970 formatPercentage = function (floatValue) { 2971 return (floatValue * 100).toFixed(2) + ' %'; 2972 }, 2973 updateProgressElement = function (loaded, total, bps) { 2974 progressElement.html( 2975 formatBytes(bps) + 'ps | ' + 2976 formatTime((total - loaded) / bps) + ' | ' + 2977 formatPercentage(loaded / total) + ' | ' + 2978 formatBytes(loaded) + ' / ' + formatBytes(total) 2979 ); 2980 }, 2981 intervalHandler = function () { 2982 var diff = loaded - loadedBefore; 2983 if (!diff) { 2984 return; 2985 } 2986 loadedBefore = loaded; 2987 updateProgressElement( 2988 loaded, 2989 total, 2990 diff * (1000 / interval) 2991 ); 2992 }; 2993 widget 2994 .bind('fileuploadprogressall', progressHandler) 2995 .bind('fileuploadstop', stopHandler); 2996 progressTimer = window.setInterval(intervalHandler, interval); 2997 }); 2998 2999 }
Note: See TracChangeset
for help on using the changeset viewer.