Changeset 6981 for sandbox/2.4.2-expresso1/prototype/modules/calendar/js
- Timestamp:
- 08/09/12 18:31:49 (12 years ago)
- Location:
- sandbox/2.4.2-expresso1/prototype/modules/calendar/js
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/2.4.2-expresso1/prototype/modules/calendar/js/activity.helpers.js
r6977 r6981 363 363 }); 364 364 }); 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'); 367 368 } 368 369 }}); … … 383 384 text: false 384 385 }); 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 387 extendsFileupload('activity', path); 511 388 512 389 UI.dialogs.addActivity.find(':input').change(function(event){ -
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 } -
sandbox/2.4.2-expresso1/prototype/modules/calendar/js/task.helpers.js
r6977 r6981 666 666 }); 667 667 }); 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'); 670 671 } 671 672 } … … 685 686 text: false 686 687 }); 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); 780 690 781 691 disponibily(objTask, path, attendees, 'task');
Note: See TracChangeset
for help on using the changeset viewer.