Changeset 6996 for trunk/prototype/modules/calendar/js
- Timestamp:
- 08/10/12 19:11:37 (12 years ago)
- Location:
- trunk/prototype/modules/calendar/js
- Files:
-
- 6 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/prototype/modules/calendar/js/calendar.codecs.js
r6533 r6996 22 22 fontColor: "fff", 23 23 timezone: 'America/Sao_Paulo', 24 weekStart: 'SUN' 24 weekStart: 'SUN', 25 useDesktopNotification: 0 25 26 }; 26 27 … … 31 32 } 32 33 } 34 35 updateActivity = false; 33 36 34 37 constantsParticipant = { … … 195 198 DataLayer.commit( false, false, function(){ 196 199 Calendar.rerenderView(true); 200 if(updateActivity) 201 refreshTaskActivity(); 197 202 }); 198 203 } … … 262 267 user: User.me.id, 263 268 calendar: { 264 id: Calendar.calendarOf[form.signature].id,269 id: !!!parseInt(form.type) ? Calendar.calendarOf[form.signature].id : Calendar.groupOf[form.signature].id, 265 270 name: Encoder.htmlEncode(form.name), 266 271 description: Encoder.htmlEncode(form.description), … … 384 389 385 390 391 }); 392 393 DataLayer.codec( "schedulable", "taskEdit", { 394 395 decoder: function( evtObj ){ 396 Encoder.EncodeType = "entity"; 397 398 if( notArray = $.type(evtObj) !== "array" ) 399 evtObj = [ evtObj ]; 400 401 var pref = User.preferences; 402 403 var res = $.map(evtObj, function( form ){ 404 405 return DataLayer.merge({ 406 id: form.idTask, 407 percentage: form.percentage, 408 type: '2', 409 status: form.taskStatus, 410 participants : $.map(form.attendee, function( attendee, i ){ 411 if(isNaN(attendee)){ 412 return{ 413 id: attendee, 414 acl: form.attendeeAcl[i], 415 delegatedFrom: !!form.delegatedFrom[i] ? form.delegatedFrom[i] : 0, 416 isOrganizer: (form.attendee_organizer == attendee ? 1 : 0 ), 417 isExternal: !!parseInt(form.attendeeType[i]) ? 1 : 0, 418 acl: form.attendeeAcl[i].replace('o', '') 419 }; 420 }else{ 421 if(DataLayer.get('participant', attendee).user == User.me.id){ 422 var me = { 423 user: User.me.id, 424 status: form.status, 425 id: attendee, 426 isOrganizer: 0, 427 receiveNotification : (!!form.receiveNotification ? 1 : 0), 428 alarms: typeof(form.alarmTime) != 'undefined' ? 429 $.map( form.alarmTime || [], function( alarmTime, i ){ 430 431 if( alarmTime === "" ) 432 return( null ); 433 434 return !!form.alarmId[i] ? 435 { 436 type: form.alarmType[i], 437 unit: form.alarmUnit[i], 438 time: form.alarmTime[i], 439 id: form.alarmId[i] 440 } : 441 { 442 type: form.alarmType[i], 443 unit: form.alarmUnit[i], 444 time: form.alarmTime[i] 445 }; 446 }) : [] 447 }; 448 449 if(form.startDate){ 450 var tzId = DataLayer.get('schedulable', form.idEvent).timezone || User.preferences.timezone, 451 formatString = pref.dateFormat + " " + pref.hourFormat; 452 453 DataLayer.put('notification', { 454 participant: me.id, 455 type: 'suggestion', 456 startTime: Date.parseExact(form.startDate + (!!form.allDay ? " 00:00": " "+$.trim(form.startHour)) , formatString ).toString('yyyy-MM-dd HH:mm:00'), 457 endTime: Date.parseExact(form.endDate + ( !!form.allDay ? " 00:00": " "+$.trim(form.endHour)), formatString ).toString('yyyy-MM-dd HH:mm:00'), 458 allDay: ( !!form.allDay ? 1 : 0 ), 459 schedulable: form.idEvent 460 }); 461 462 } 463 return me; 464 }else return(null); 465 }; 466 }) 467 }, (form.group != form.lastGroup? {calendar: form.group, lastCalendar: form.lastGroup} : {})) 468 }); 469 return notArray ? res[0] : res; 470 }, 471 472 encoder: function( evtObj ){} 473 386 474 }); 387 475 … … 510 598 calendar: objEvent.calendar, 511 599 summary: objEvent.summary, 600 type: !!objEvent.type ? objEvent.type : 1, 512 601 description: objEvent.description, 513 602 timezone: objEvent.timezone, … … 595 684 }); 596 685 686 DataLayer.codec( "schedulable", "task", { 687 688 decoder: function( evtObj ){ 689 Encoder.EncodeType = "entity"; 690 691 if( notArray = $.type(evtObj) !== "array" ) 692 evtObj = [ evtObj ]; 693 694 var pref = User.preferences; 695 696 var res = $.map(evtObj, function( form ){ 697 698 var tzId = form.timezone || Calendar.signatureOf[form.group].calendar.timezone || User.preferences.timezone, 699 700 formatString = pref.dateFormat + " " + pref.hourFormat; 701 702 return DataLayer.merge({ 703 "class": form["class"], 704 startTime: Date.parseExact(form.startDate + " "+$.trim(form.startHour) , formatString ).toString(!!form.allDay ? 'yyyy-MM-dd 00:00:00' : 'yyyy-MM-dd HH:mm:00'), 705 endTime: Date.parseExact(form.endDate + " "+$.trim(form.endHour), formatString ).toString(!!form.allDay ? 'yyyy-MM-dd 00:00:00' : 'yyyy-MM-dd HH:mm:00'), //+ (!!form.allDay ? 86400000 : 0) , 706 due: (form.dueDate == '' )? 0 : Date.parseExact(form.dueDate + " "+$.trim(form.dueTime) , formatString ).toString(!!form.allDay ? 'yyyy-MM-dd 00:00:00' : 'yyyy-MM-dd HH:mm:00'), 707 allDay: ( !!form.allDay ? 1 : 0 ), 708 status: form.taskStatus, 709 id: form.idTask, 710 location: form.location, 711 type: !!form.type ? form.type : 2, 712 percentage: form.percentage, 713 priority: form.priority, 714 category: form.category, 715 summary: form.summary == '' ? 'Tarefa sem título' : form.summary, 716 description: form.description, 717 timezone: tzId, 718 attachments: $.map(form.attachment || [], function( attachment, i ){ 719 return { 720 attachment: attachment 721 } 722 }), 723 participants: $.map( form.attendee || [], function( attendee, i ){ 724 725 if( !attendee || attendee === "" ) 726 return( null ); 727 728 var participant = {}; 729 participant.user = (attendee!= User.me.id) ? DataLayer.get('participant', attendee).user : attendee ; 730 731 if( participant.user === User.me.id ){ 732 return DataLayer.merge({ 733 id: attendee, 734 isOrganizer: (form.attendee_organizer == attendee ? 1 : 0 ), 735 alarms: participant.alarms = $.map( form.alarmTime || [], function( alarmTime, i ){ 736 if( alarmTime === "" ) 737 return( null ); 738 return !!form.alarmId[i] ? { 739 type: form.alarmType[i], 740 unit: form.alarmUnit[i], 741 time: form.alarmTime[i], 742 id: form.alarmId[i] 743 }: 744 745 { 746 type: form.alarmType[i], 747 unit: form.alarmUnit[i], 748 time: form.alarmTime[i] 749 }; 750 }), 751 status: !!form.status ? form.status : 3 752 }, (form.delegatedFrom[i] != '0' && form.delegatedFrom[i] != '') ? { 753 delegatedFrom: form.delegatedFrom[i] 754 } : {}); 755 }else{ 756 return { 757 id: attendee, 758 isOrganizer: (form.attendee_organizer == attendee ? 1 : 0 ), 759 isExternal: !!parseInt(form.attendeeType[i]) ? 1 : 0 760 }; 761 }; 762 }) 763 }, form.lastGroup ? (( form.lastGroup == form.group ) ? {} : {calendar: form.group, lastGroup: form.lastGroup}) : {calendar: form.group}); 764 }); 765 766 return notArray ? res[0] : res; 767 }, 768 769 encoder: function( evtObj ){ 770 771 var notArray = false; 772 773 if( notArray = $.type(evtObj) !== "array" ) 774 evtObj = [ evtObj ]; 775 776 var statusParticipants = {}, isAttendee = false, 777 778 statusLabels = [ '', 'accepted', 'tentative', 'cancelled', 'unanswered', 'delegated' ], 779 780 participantInfo = {}, delegatedFrom = {}, me = DataLayer.copy( User.me ); 781 782 var delegateAttendee = {}; 783 784 for( var i = 0; i < statusLabels.length; i++ ) 785 statusParticipants[ statusLabels[i] ] = 0; 786 787 var res = $.map(evtObj, function( objEvent ){ 788 789 if(!(typeof(objEvent) == 'object')) 790 return (null); 791 792 var limitAttendee = false; 793 794 return { 795 "class": objEvent["class"], 796 id: objEvent.id, 797 location: objEvent.location, 798 category: objEvent.category, 799 taskStatus: objEvent.status, 800 groups: Calendar.groups, 801 group: objEvent.group ? objEvent.group : objEvent.calendar, 802 summary: objEvent.summary, 803 type: !!objEvent.type ? objEvent.type : 2, 804 description: objEvent.description, 805 timezone: objEvent.timezone, 806 timezones: Timezone.timezones, 807 percentage: (objEvent.percentage) ? objEvent.percentage : '0', 808 priority: objEvent.priority, 809 startDate: new Date( parseInt(objEvent.startTime) ).setTimezoneOffset( Timezone.timezone( objEvent.timezone ) ).toString( User.preferences.dateFormat ), 810 startHour: dateCalendar.formatDate(Timezone.getDateEvent(new Date( parseInt(objEvent.startTime)), objEvent.timezone, objEvent.calendar, objEvent.DayLigth, 'startTime'), User.preferences.hourFormat), 811 endDate: new Date( parseInt(objEvent.endTime) - (!!parseInt(objEvent.allDay) ? 86400000 : 0) ).setTimezoneOffset( Timezone.timezone( objEvent.timezone ) ).toString( User.preferences.dateFormat ), 812 endHour: dateCalendar.formatDate(Timezone.getDateEvent(new Date(parseInt(objEvent.endTime)), objEvent.timezone, objEvent.calendar, objEvent.DayLigth, 'endTime'), User.preferences.hourFormat), 813 dueDate: (!objEvent.due || objEvent.due == '' || objEvent.due == '0') ? '' : new Date( parseInt(objEvent.due) ).setTimezoneOffset( Timezone.timezone( objEvent.timezone ) ).toString( User.preferences.dateFormat ), 814 dueTime: (!objEvent.due || objEvent.due == '' || objEvent.due == '0') ? '' : dateCalendar.formatDate(Timezone.getDateEvent(new Date( parseInt(objEvent.due)), objEvent.timezone, objEvent.calendar, objEvent.DayLigth, 'startTime'), User.preferences.hourFormat), 815 allDay: !!parseInt( objEvent.allDay ), 816 historic: !!objEvent.historic ? decodeHistoric(objEvent) : [] , 817 attachments: $.map(objEvent.attachments || [], function( attachment, i ){ 818 var attach = DataLayer.get('schedulableToAttachment', attachment, false); 819 //TODO - Verificar na API retorno de id sobre os conceitos em que s?o utilizados tabelas de liga??o 820 if(!attach.name) return(null); 821 822 var ext = attach.name.split('.'); 823 attach.name = attach.name.length < 10 ? attach.name : ( ext.length == 1 ? attach.name.substr(0, 10) : (attach.name.substr(0, 6) + '.' + ext[ext.length -1])); 824 attach.size = formatBytes(attach.size); 825 return attach; 826 }), 827 attendee: $.map(objEvent.participants || [], function( participant, i ){ 828 829 if(delegateAttendee[participant]) 830 return(null); 831 832 var attend = DataLayer.get('participant', (participant.id || participant)); 833 attend.user = DataLayer.get('user', attend.user); 834 835 statusParticipants[ statusLabels[attend.status] ]++; 836 837 if(attend.user.mail == User.me.mail) 838 isAttendee = true; 839 840 if( attend.user.id === me.id ){ 841 participantInfo.user = { 842 id: attend.id, 843 status : attend.status, 844 delegatedFrom: attend.delegatedFrom || '0', 845 acl: attend.acl, 846 receiveNotification : attend.receiveNotification, 847 alarms : $.map(attend.alarms || [], function( alarm ){ 848 var alarm = DataLayer.get('alarm', alarm); 849 return (alarm == "" ? (null) : alarm); 850 }) 851 }; 852 me = attend; 853 return(null); 854 }; 855 856 var person = { 857 id: attend.id, 858 name: attend.user.name != 'false' ? attend.user.name : '', 859 mail: attend.user.mail, 860 status : attend.status, 861 isExternal: attend.isExternal, 862 acl: attend.acl, 863 delegatedFrom: attend.delegatedFrom 864 }; 865 866 if(!!parseInt(attend.delegatedFrom)){ 867 delegatedFrom[attend.delegatedFrom] = DataLayer.copy(person); 868 return(null); 869 } 870 871 if( !!parseInt(attend.isOrganizer)){ 872 participantInfo.organizer = DataLayer.copy(person); 873 return(null); 874 }; 875 876 return (person); 877 }), 878 organizer: participantInfo.organizer || me, 879 isOrganizer: (participantInfo.organizer || me).id == me.id, 880 alarms: !!participantInfo.user ? participantInfo.user.alarms : [], 881 status: !!participantInfo.user ? participantInfo.user.status : 1, 882 isAttendee: isAttendee, 883 me: me, 884 delegatedFrom: delegatedFrom, 885 statusParticipants: (objEvent.sizeAttendees != "") ? objEvent.statusAttendees : statusParticipants, 886 sizeAttendeeLimit: (objEvent.sizeAttendees != "") ? objEvent.sizeAttendees : false 887 }; 888 }); 889 return (notArray ? res[0] : res); 890 } 891 }); 892 893 function decodeHistoric ( evt ) { 894 var historic = evt.historic; 895 var decoded = []; 896 var attributeDecoded = { 897 'startTime': 'Data de inicio', 898 'endTime' : 'Data de fim', 899 'summary' : 'Título', 900 'description': 'Descrição', 901 'status': 'Status', 902 'percentage': 'Porcentagem', 903 'priority': 'Priorudade', 904 'due' : 'Previsão de término' 905 } 906 907 var statusDecoded = { 908 1: 'Sem ações', 909 2: 'Em processo', 910 3: 'Finalzada', 911 4: 'Cancelada', 912 } 913 914 var decodeDate = function(time){ 915 return new Date( parseInt( time) ).setTimezoneOffset( Timezone.timezone( evt.timezone ) ).toString( User.preferences.dateFormat+' - '+User.preferences.hourFormat ); 916 }; 917 918 var decodeItem = function(historic){ 919 switch(historic.attribute){ 920 case 'startTime': 921 case 'endTime' : 922 case 'due': 923 return { 924 user :$.type(historic.user) == 'object' ? historic.user : DataLayer.get('user', historic.user), 925 attribute : attributeDecoded[historic.attribute], 926 beforeValue : decodeDate(historic.beforeValue), 927 afterValue : decodeDate(historic.afterValue), 928 time: decodeDate(historic.time) 929 } 930 break; 931 case 'participant': 932 return{ 933 user :$.type(historic.user) == 'object' ? historic.user : DataLayer.get('user', historic.user), 934 attribute : historic.beforeValue == '' ? ('Novo participante') : ('Rem. participante'), 935 beforeValue : historic.beforeValue == '' ? '' : historic.beforeValue.mail, 936 afterValue : historic.afterValue == '' ? '' : historic.afterValue.mail, 937 time: decodeDate(historic.time) 938 } 939 break; 940 case 'attachment': 941 return{ 942 user : $.type(historic.user) == 'object' ? historic.user : DataLayer.get('user', historic.user), 943 attribute : historic.beforeValue == '' ? ('Novo anexo') : ('Rem. anexo'), 944 beforeValue : historic.beforeValue, 945 afterValue : historic.afterValue, 946 time: decodeDate(historic.time) 947 } 948 case 'percentage': 949 return{ 950 user :$.type(historic.user) == 'object' ? historic.user : DataLayer.get('user', historic.user), 951 attribute :attributeDecoded[historic.attribute], 952 beforeValue : historic.beforeValue+' %', 953 afterValue : historic.afterValue+' %', 954 time: decodeDate(historic.time) 955 } 956 case 'status': 957 return{ 958 user :$.type(historic.user) == 'object' ? historic.user : DataLayer.get('user', historic.user), 959 attribute :attributeDecoded[historic.attribute], 960 beforeValue : statusDecoded[historic.beforeValue], 961 afterValue : statusDecoded[historic.afterValue], 962 time: decodeDate(historic.time) 963 } 964 break; 965 default: 966 return { 967 user : $.type(historic.user) == 'object' ? historic.user : DataLayer.get('user', historic.user), 968 attribute : attributeDecoded[historic.attribute], 969 beforeValue : historic.beforeValue, 970 afterValue : historic.afterValue, 971 time: decodeDate(historic.time) 972 } 973 break; 974 975 } 976 } 977 978 for(var i = 0; i < historic.length; i++) 979 decoded.push(decodeItem(historic[i])); 980 981 return decoded; 982 983 } 984 985 DataLayer.codec( "schedulable", "taskSearch", { 986 987 decoder: function( evtObj ){ 988 989 }, 990 991 encoder: function( evtObj ){ 992 993 var notArray = false; 994 995 if( notArray = $.type(evtObj) !== "array" ) 996 evtObj = [ evtObj ]; 997 998 var res = $.map(evtObj, function( objEvent ){ 999 1000 if(!(typeof(objEvent) == 'object')) 1001 return (null); 1002 1003 return { 1004 id: objEvent.id, 1005 description: !!objEvent.summary ? objEvent.summary : objEvent.description, 1006 startDate: new Date( parseInt(objEvent.startTime) ).setTimezoneOffset( Timezone.timezone( objEvent.timezone ) ).toString( User.preferences.dateFormat ), 1007 startHour: dateCalendar.formatDate(Timezone.getDateEvent(new Date( parseInt(objEvent.startTime)), objEvent.timezone, objEvent.calendar, objEvent.DayLigth, 'startTime'), User.preferences.hourFormat), 1008 endDate: new Date( parseInt(objEvent.endTime) - (!!parseInt(objEvent.allDay) ? 86400000 : 0) ).setTimezoneOffset( Timezone.timezone( objEvent.timezone ) ).toString( User.preferences.dateFormat ), 1009 endHour: dateCalendar.formatDate(Timezone.getDateEvent(new Date(parseInt(objEvent.endTime)), objEvent.timezone, objEvent.calendar, objEvent.DayLigth, 'endTime'), User.preferences.hourFormat), 1010 dueDate: (!objEvent.due || objEvent.due == '' || objEvent.due == '0') ? '' : new Date( parseInt(objEvent.due) ).setTimezoneOffset( Timezone.timezone( objEvent.timezone ) ).toString( User.preferences.dateFormat ), 1011 dueTime: (!objEvent.due || objEvent.due == '' || objEvent.due == '0') ? '' : dateCalendar.formatDate(Timezone.getDateEvent(new Date( parseInt(objEvent.due)), objEvent.timezone, objEvent.calendar, objEvent.DayLigth, 'startTime'), User.preferences.hourFormat), 1012 allDay: !!parseInt( objEvent.allDay ), 1013 percentage: (objEvent.percentage) ? objEvent.percentage : '0', 1014 status: objEvent.status 1015 } 1016 }); 1017 return (notArray ? res[0] : res); 1018 } 1019 }); 1020 1021 DataLayer.codec( "schedulable", "activity", { 1022 1023 decoder: function( evtObj ){ 1024 Encoder.EncodeType = "entity"; 1025 1026 if( notArray = $.type(evtObj) !== "array" ) 1027 evtObj = [ evtObj ]; 1028 1029 var pref = User.preferences; 1030 1031 var res = $.map(evtObj, function( form ){ 1032 1033 var tzId = form.timezone || Calendar.signatureOf[form.group].calendar.timezone || User.preferences.timezone, 1034 formatString = pref.dateFormat + " " + pref.hourFormat; 1035 1036 var decodeParticipants = function(attend){ 1037 return [DataLayer.merge( 1038 { 1039 user: User.me.id, 1040 isOrganizer: 1, 1041 acl: 'row', 1042 alarms: $.map( form.alarmTime || [], function( alarmTime, i ){ 1043 if( alarmTime === "" ) 1044 return( null ); 1045 return !!form.alarmId[i] ? { 1046 type: form.alarmType[i], 1047 unit: form.alarmUnit[i], 1048 time: form.alarmTime[i], 1049 id: form.alarmId[i] 1050 }: 1051 1052 { 1053 type: form.alarmType[i], 1054 unit: form.alarmUnit[i], 1055 time: form.alarmTime[i] 1056 }; 1057 }) 1058 }, attend != '0' ? {id: attend} : {})]; 1059 }; 1060 1061 return DataLayer.merge({ 1062 "class": form["class"], 1063 startTime: Date.parseExact(form.startDate + " "+$.trim(form.startHour) , formatString ).toString(!!form.allDay ? 'yyyy-MM-dd 00:00:00' : 'yyyy-MM-dd HH:mm:00'), 1064 endTime: Date.parseExact(form.endDate + " "+$.trim(form.endHour), formatString ).toString(!!form.allDay ? 'yyyy-MM-dd 00:00:00' : 'yyyy-MM-dd HH:mm:00'), //+ (!!form.allDay ? 86400000 : 0) , 1065 due: (form.dueDate == '' )? 0 : Date.parseExact(form.dueDate + " "+$.trim(form.dueHour) , formatString ).toString(!!form.allDay ? 'yyyy-MM-dd 00:00:00' : 'yyyy-MM-dd HH:mm:00'), 1066 allDay: ( !!form.allDay ? 1 : 0 ), 1067 status: form.activityStatus, 1068 id: form.idActivity, 1069 type: !!form.type ? form.type : 2, 1070 percentage: form.percentage, 1071 priority: form.priority, 1072 category: form.category, 1073 summary: form.summary == '' ? 'Atividade sem título' : form.summary, 1074 description: form.description, 1075 timezone: tzId, 1076 attachments: $.map(form.attachment || [], function( attachment, i ){ 1077 return { 1078 attachment: attachment 1079 } 1080 }), 1081 participants: decodeParticipants(form.idAttendee), 1082 taskToActivity:$.map( form.idtask || [], function( task, i ){ 1083 1084 return DataLayer.merge({ 1085 task: task, 1086 owner: User.me.id 1087 }, form.idTaskToActivity[i] != '' ? {id: form.idTaskToActivity[i]} : {}); 1088 1089 }) 1090 }, form.lastGroup ? (( form.lastGroup == form.group ) ? {} : {calendar: form.group, lastGroup: form.lastGroup}) : {calendar: form.group}); 1091 }); 1092 1093 return notArray ? res[0] : res; 1094 }, 1095 1096 encoder: function( evtObj ){ 1097 1098 var notArray = false; 1099 1100 if( notArray = $.type(evtObj) !== "array" ) 1101 evtObj = [ evtObj ]; 1102 1103 var res = $.map(evtObj, function( objEvent ){ 1104 1105 if(!(typeof(objEvent) == 'object')) 1106 return (null); 1107 1108 var historic = []; 1109 1110 var decodeTasks = function(obj){ 1111 1112 var tasks = {}, task = {}; 1113 1114 for(var i =0; i < obj.taskToActivity.length; i++){ 1115 1116 taskToActivity = DataLayer.get('taskToActivity', obj.taskToActivity[i]); 1117 task = taskToActivity.task; 1118 1119 if($.type(task) != 'object') 1120 task = DataLayer.get('schedulable', task); 1121 1122 tasks[task.id] = { 1123 taskToActivity: taskToActivity.id, 1124 allDay: !!parseInt(task.allDay), 1125 dueDate: (!task.due || task.due == '' || task.due == '0') ? '' : new Date( parseInt(task.due) ).setTimezoneOffset( Timezone.timezone( task.timezone ) ).toString( User.preferences.dateFormat ), 1126 dueTime: (!task.due || task.due == '' || task.due == '0') ? '' : dateCalendar.formatDate(Timezone.getDateEvent(new Date( parseInt(task.due)), task.timezone, obj.calendar, obj.DayLigth, 'startTime'), User.preferences.hourFormat), 1127 startDate: new Date( parseInt(task.startTime) ).setTimezoneOffset( Timezone.timezone( task.timezone ) ).toString( User.preferences.dateFormat ), 1128 startHour: dateCalendar.formatDate(Timezone.getDateEvent(new Date( parseInt(task.startTime)), task.timezone, task.calendar, obj.DayLigth, 'startTime'), User.preferences.hourFormat), 1129 endDate: new Date( parseInt(task.endTime) - (!!parseInt(task.allDay) ? 86400000 : 0) ).setTimezoneOffset( Timezone.timezone( task.timezone ) ).toString( User.preferences.dateFormat ), 1130 endHour: dateCalendar.formatDate(Timezone.getDateEvent(new Date(parseInt(task.endTime)), task.timezone, obj.calendar, obj.DayLigth, 'endTime'), User.preferences.hourFormat), 1131 status: task.status, 1132 percentage: task.percentage 1133 } 1134 1135 tasks[task.id].description = tasks[task.id].startDate + ' - ' + (!!task.summary ? task.summary : task.description); 1136 1137 historic.push({'task': (!!task.summary ? task.summary : task.description) , 'historic': decodeHistoric(task)}); 1138 } 1139 1140 tasks.length = obj.taskToActivity.length; 1141 return tasks; 1142 1143 }; 1144 1145 return { 1146 "class": objEvent["class"], 1147 id: objEvent.id, 1148 location: objEvent.location, 1149 category: objEvent.category, 1150 activityStatus: objEvent.status, 1151 groups: Calendar.groups, 1152 group: objEvent.group ? objEvent.group : objEvent.calendar, 1153 summary: objEvent.summary, 1154 type: !!objEvent.type ? objEvent.type : 2, 1155 description: objEvent.description, 1156 timezone: objEvent.timezone, 1157 timezones: Timezone.timezones, 1158 percentage: (objEvent.percentage) ? objEvent.percentage : '0', 1159 priority: objEvent.priority, 1160 startDate: new Date( parseInt(objEvent.startTime) ).setTimezoneOffset( Timezone.timezone( objEvent.timezone ) ).toString( User.preferences.dateFormat ), 1161 startHour: dateCalendar.formatDate(Timezone.getDateEvent(new Date( parseInt(objEvent.startTime)), objEvent.timezone, objEvent.calendar, objEvent.DayLigth, 'startTime'), User.preferences.hourFormat), 1162 endDate: new Date( parseInt(objEvent.endTime) - (!!parseInt(objEvent.allDay) ? 86400000 : 0) ).setTimezoneOffset( Timezone.timezone( objEvent.timezone ) ).toString( User.preferences.dateFormat ), 1163 endHour: dateCalendar.formatDate(Timezone.getDateEvent(new Date(parseInt(objEvent.endTime)), objEvent.timezone, objEvent.calendar, objEvent.DayLigth, 'endTime'), User.preferences.hourFormat), 1164 dueDate: (!objEvent.due || objEvent.due == '' || objEvent.due == '0') ? '' : new Date( parseInt(objEvent.due) ).setTimezoneOffset( Timezone.timezone( objEvent.timezone ) ).toString( User.preferences.dateFormat ), 1165 dueTime: (!objEvent.due || objEvent.due == '' || objEvent.due == '0') ? '' : dateCalendar.formatDate(Timezone.getDateEvent(new Date( parseInt(objEvent.due)), objEvent.timezone, objEvent.calendar, objEvent.DayLigth, 'startTime'), User.preferences.hourFormat), 1166 allDay: !!parseInt( objEvent.allDay ), 1167 historic: historic, 1168 tasks: objEvent.taskToActivity ? decodeTasks(objEvent) : {}, 1169 attachments: $.map(objEvent.attachments || [], function( attachment, i ){ 1170 var attach = DataLayer.get('schedulableToAttachment', attachment, false); 1171 //TODO - Verificar na API retorno de id sobre os conceitos em que s?o utilizados tabelas de liga??o 1172 if(!attach.name) return(null); 1173 1174 var ext = attach.name.split('.'); 1175 attach.name = attach.name.length < 10 ? attach.name : ( ext.length == 1 ? attach.name.substr(0, 10) : (attach.name.substr(0, 6) + '.' + ext[ext.length -1])); 1176 attach.size = formatBytes(attach.size); 1177 return attach; 1178 }), 1179 me : User.me, 1180 attendee: $.map(objEvent.participants || [], function( participant, i ){ 1181 1182 var attend = DataLayer.get('participant', (participant.id || participant)); 1183 attend.user = DataLayer.get('user', attend.user); 1184 1185 return { 1186 id: attend.id, 1187 alarms : $.map(attend.alarms || [], function( alarm ){ 1188 var alarm = DataLayer.get('alarm', alarm); 1189 return (alarm == "" ? (null) : alarm); 1190 }) 1191 }; 1192 }) 1193 1194 }; 1195 }); 1196 return (notArray ? res[0] : res); 1197 } 1198 }); 597 1199 598 1200 function decodeOwnerCalendar(calendar){ … … 727 1329 id: form.idEvent, 728 1330 location: form.location, 1331 type: 1, 729 1332 category: form.category, 730 summary: form.summary ,1333 summary: form.summary == '' ? 'Evento sem título' : form.summary, 731 1334 description: form.description, 732 1335 timezone: tzId, … … 800 1403 801 1404 var pref = User.preferences; 802 803 var res = DataLayer.encode('schedulable:preview', evtObj); 1405 var res = []; 1406 1407 for(var i = 0; i < evtObj.length; i++){ 1408 res.push(DataLayer.encode('schedulable:' + (evtObj[i].type == '1' ? 'preview' : ( !!evtObj[i].taskToActivity ? 'activity': 'task')) , evtObj[i])); 1409 } 804 1410 805 1411 if( !notArray ){ … … 814 1420 815 1421 for (var i=0; i < res.length; i++) { 1422 1423 res[i].type = (res[i].type == '2' && !!res[i].tasks) ? '3' : res[i].type; 816 1424 817 1425 var startDate = Date.parseExact( res[i]['startDate'], User.preferences.dateFormat ); … … 836 1444 'endDate': new Date( occurrences[ii] + duration ).toString( User.preferences.dateFormat ) 837 1445 } ); 838 839 840 841 842 res2.repeat = typeRepeat[res[i].repeat.frequency]; 1446 1447 if(res[i].repeat) 1448 res2.repeat = typeRepeat[res[i].repeat.frequency]; 843 1449 844 1450 while (counter.compareTo( currentDate ) == 0) { … … 864 1470 865 1471 return notArray ? res[0] : res; 1472 } 1473 1474 }); 1475 1476 1477 DataLayer.codec( "schedulable", "print", { 1478 1479 decoder: function( evtObj ){ 1480 1481 }, 1482 1483 1484 encoder: function( evtObj ){ 1485 1486 if(!(!!evtObj)) 1487 evtObj = []; 1488 1489 var notArray = false; 1490 1491 if( notArray = $.type(evtObj) !== "array" ) 1492 evtObj = [ evtObj ]; 1493 1494 var pref = User.preferences; 1495 var res = []; 1496 1497 for(var i = 0; i < evtObj.length; i++){ 1498 res.push(DataLayer.encode('schedulable:' + (evtObj[i].type == '1' ? 'preview' : 'task'), evtObj[i])); 1499 } 1500 1501 if( !notArray ){ 1502 var dates = {}; 1503 1504 var typeRepeat = { 1505 'none': false, 1506 'daily': 'Repetição diária', 1507 'weekly': 'Repetição semanal', 1508 'monthly': 'Repetição mensal', 1509 'yearly': 'repetição anual' 1510 } 1511 1512 for (var i=0; i < res.length; i++) { 1513 var startDate = Date.parseExact( res[i]['startDate'], User.preferences.dateFormat ); 1514 var endDate = Date.parseExact( res[i]['endDate'], User.preferences.dateFormat ); 1515 1516 var duration = parseInt( endDate.getTime() ) - parseInt( startDate.getTime() ); 1517 1518 var occurrences = [ startDate.getTime() ]; 1519 1520 if( res[i].occurrences ) 1521 { 1522 occurrences = res[i].occurrences; 1523 } 1524 1525 for( var ii = 0; ii < occurrences.length; ii++ ) 1526 { 1527 var currentDate = new Date( occurrences[ii] ); 1528 var counter = currentDate.clone(); 1529 1530 var res2 = $.extend( {}, res[i], { 1531 'startDate': currentDate.toString( User.preferences.dateFormat ), 1532 'endDate': new Date( occurrences[ii] + duration ).toString( User.preferences.dateFormat ) 1533 }); 1534 1535 if(res[i].repeat) 1536 res2.repeat = typeRepeat[res[i].repeat.frequency]; 1537 1538 var index = dateCalendar.dayNames[counter.getDay()] +' '+counter.toString('dd/MM'); 1539 1540 if(!dates[index] || !$.isArray(dates[index].events)) 1541 dates[index] = {events: []}; 1542 1543 res2['isOneDay'] = res2.startDate == res2.endDate ? true : false; 1544 1545 dates[index].events.push(res2); 1546 1547 } 1548 } 1549 1550 var calendarView = $('#calendar').fullCalendar('getView'); 1551 var start = calendarView.start.getTime(); 1552 var end = (calendarView.end.getTime() - (calendarView.name == 'month' ? 86400000 : 0 )); 1553 var next = start; 1554 var response = []; 1555 1556 while (next){ 1557 var index = dateCalendar.dayNames[new Date(next).getDay()] +' '+ new Date(next).toString('dd/MM'); 1558 1559 var event = {}; 1560 event[index] = {events: dates[index] ? dates[index].events : false}; 1561 1562 response[response.length] = event; 1563 next = (next + 86400000) > end ? false : (next + 86400000); 1564 } 1565 res = {events: response}; 1566 } 1567 1568 return notArray ? res[0] : res; 866 1569 } 867 1570 … … 952 1655 attendee = DataLayer.get('participant', evt.participants[i]); 953 1656 if(attendee.user == User.me.id) 954 return (attendee.acl.indexOf('w') >= 0 || attendee.acl.indexOf('o') >= 0 ) ? { 1657 return (attendee.acl.indexOf('w') >= 0 || attendee.acl.indexOf('o') >= 0 ) ? 1658 { 955 1659 selectable: true, 956 1660 className: 'fullcalendar-context-menu event-id-'+idEvent+' calendar-id-'+calendar.id+ (isRecurrence ? ' isRecurrence Recurrence-id-'+Recurrence : '') … … 978 1682 return returns; 979 1683 } 980 return DataLayer.merge({ 1684 return DataLayer.merge( 1685 { 981 1686 editable: aclSignature.acl['write'] && !isRecurrence, 982 1687 disableResizing : (((aclSignature.acl['busy'] && !aclSignature.acl['write']) || (!aclSignature.acl['write'] && aclSignature.acl['read'])) ? true : false), 983 1688 disableDragging : (((aclSignature.acl['busy'] && !aclSignature.acl['write']) || (!aclSignature.acl['write'] && aclSignature.acl['read'])) ? true: false), 984 1689 className: mountClass(aclSignature.acl) 985 }, aclSignature.acl['busy'] ? { 986 title: 'Ocupado', 987 selectable: false 988 } : { 989 selectable: true 990 }); 1690 }, aclSignature.acl['busy'] ? 1691 { 1692 title: 'Ocupado', 1693 selectable: false 1694 } : { 1695 selectable: true 1696 }); 991 1697 } 992 993 1698 } 994 1699 … … 1005 1710 1006 1711 //occurrences = DataLayer.unique( occurrences ).sort(); 1007 1008 for( var i = 0; i < occurrences.length; i++ ) 1009 grouped[ evt.calendar ].push( DataLayer.merge({ 1010 id: evt.URI || evt.id+ '-' + i, 1011 title: Encoder.htmlDecode(evt.summary), 1012 start: Timezone.getDateCalendar(new Date( parseInt( occurrences[i] ) ), calendar.timezone, !!evt.DayLigth ? evt.DayLigth.calendar.startTime : Timezone.daylightSaving), 1013 end: Timezone.getDateCalendar(new Date( parseInt( occurrences[i] ) + duration - (!!parseInt(evt.allDay) ? 86400000 : 0)), calendar.timezone, !!evt.DayLigth ? evt.DayLigth.calendar.startTime : Timezone.daylightSaving), 1014 allDay: parseInt( evt.allDay ), 1015 isRepeat: isRepeat, 1016 occurrence: i, 1017 calendar: evt.calendar 1018 }, eventEditable(evt.id, isRepeat, i ) ) ); 1712 var typeEvent; 1713 for( var i = 0; i < occurrences.length; i++ ){ 1714 1715 typeEvent = (evt.type == 2 && evt.taskToActivity ? 3 : evt.type) 1716 grouped[ evt.calendar ].push( DataLayer.merge( 1717 { 1718 id: evt.URI || evt.id+ '-' + i, 1719 title: Encoder.htmlDecode(evt.summary), 1720 start: Timezone.getDateCalendar(new Date( parseInt( occurrences[i] ) ), calendar.timezone, !!evt.DayLigth ? evt.DayLigth.calendar.startTime : Timezone.daylightSaving), 1721 end: Timezone.getDateCalendar(new Date( parseInt( occurrences[i] ) + duration - (!!parseInt(evt.allDay) ? 86400000 : 0)), calendar.timezone, !!evt.DayLigth ? evt.DayLigth.calendar.startTime : Timezone.daylightSaving), 1722 allDay: parseInt( evt.allDay ), 1723 isRepeat: isRepeat, 1724 occurrence: i, 1725 type: typeEvent, 1726 calendar: evt.calendar 1727 }, (parseInt(typeEvent) == 1 ? eventEditable(evt.id, isRepeat, i ) : (parseInt(typeEvent) == 2 ? {editable: true, disableResizing: false, disableDragging: false} : {editable: false, disableResizing: true, disableDragging: true}) )) ); 1728 } 1019 1729 }); 1020 1730 … … 1049 1759 ] 1050 1760 ], 1051 ['IN', 'calendar', Calendar.calendarIds]1761 ['IN', 'calendar', $.merge( Calendar.calendarIds, Calendar.groupIds )] 1052 1762 ], 1053 1763 criteria: { -
trunk/prototype/modules/calendar/js/calendar.shared.js
r6992 r6996 1 1 function show_modal_shared(calendarId){ 2 3 var html = DataLayer.render('templates/shared_calendar.ejs', { 2 $('.qtip.qtip-blue').remove(); 3 4 var html = DataLayer.render('templates/shared_calendar.ejs', { 4 5 calendar: Calendar.calendars, 5 6 signature : Calendar.signatures … … 337 338 338 339 function show_modal_search_shared(){ 340 $('.qtip.qtip-blue').remove(); 339 341 340 342 var html = DataLayer.render('templates/shared_calendar.ejs', {}); -
trunk/prototype/modules/calendar/js/helpers.js
r6956 r6996 101 101 } 102 102 103 /* 104 function listEvents(){ 105 var list = $('.fc-header-right').find('.fc-button.fc-button-agendaDay').clone(); 103 function printNow(){ 104 105 var window_print = window.open('','ExpressoCalendar','width=800,height=600,scrollbars=yes'); 106 window_print.document.open(); 107 108 var start = $("#calendar").fullCalendar('getView').visStart.getTime()/1000; 109 var end = $("#calendar").fullCalendar('getView').visEnd.getTime()/1000; 110 var criteria = DataLayer.criteria("schedulable:calendar", {'start':start, 'end':end} ); 111 112 var data = DataLayer.get("schedulable:print", criteria); 113 114 if($("#calendar").fullCalendar('getView').name == "month"){ 115 window_print.document.write(DataLayer.render('templates/calendar_month_print.ejs', { 116 'InfoPage' : $("#calendar").fullCalendar('getView').title, 117 'days' : data 118 } )); 119 } 120 if($("#calendar").fullCalendar('getView').name == "agendaDay"){ 121 window_print.document.write(DataLayer.render('templates/calendar_day_print.ejs', { 122 'InfoPage' : $("#calendar").fullCalendar('getView').title, 123 'days' : data 124 } )); 125 } 126 if($("#calendar").fullCalendar('getView').name == "agendaWeek"){ 127 window_print.document.write(DataLayer.render('templates/calendar_week_print.ejs', { 128 'InfoPage' : $("#calendar").fullCalendar('getView').title, 129 'days' : data 130 })); 131 132 var aux = 0; 133 setTimeout(function(){$(window_print.document).find(".all-day").each(function(){ 134 if($(this).height() > aux) 135 aux = $(this).height(); 136 }); 137 $(window_print.document).find(".all-day").each(function(){ 138 $(this).height(aux); 139 }); 140 $(window_print.document).find(".all-day-line .write").height(aux); 141 aux = 0; 142 },20); 143 } 144 if($("#calendar").fullCalendar('getView').name == "year"){ 145 window_print.document.write(DataLayer.render('templates/calendar_year_print.ejs', { 146 'html' : $('#calendar .fc-content').html(), 147 'header': $('#calendar').find('.fc-header-center h2').text() 148 } )); 149 } 150 window_print.document.close(); 151 setTimeout(window_print.print(), 300); 152 } 153 154 function printEvents(){ 155 //var html = DataLayer.render( path + 'templates/attendee_permissions.ejs', {} ); 156 var print = $('.fc-header-right').find('.fc-button.fc-button-agendaDay').clone(); 157 106 158 $('.fc-header-right').find('.fc-button-year').toggleClass('fc-corner-right'); 107 list.addClass('fc-corner-right'); 108 list.addClass('fc-button-listagem'); 109 list.removeClass('fc-button-agendaDay'); 110 list.removeClass('fc-corner-left'); 111 list.find('.fc-button-content').html('Listagem'); 112 $('.fc-header-right').append(list); 113 } 114 */ 159 print.addClass('fc-corner-right'); 160 print.addClass('fc-button-print'); 161 print.removeClass('fc-button-agendaDay'); 162 print.removeClass('fc-corner-left'); 163 print.find('.fc-button-content').html('Imprimir'); 164 $('.fc-header-right').append(print); 165 $('.fc-button-print').click(function(){ 166 alert('A tela de impressão será melhor visualizada com a preferência "Paisagem" do seu browser selecionada.'); 167 printNow(); 168 }); 169 } 115 170 116 171 /* … … 122 177 function eventDetails( objEvent, decoded, path, isMail, repeat) 123 178 { 179 180 $('.qtip.qtip-blue').remove(); 181 124 182 attendees = {}; 125 183 … … 399 457 modal:true, 400 458 autoOpen: false, 401 width:70 2,459 width:701, 402 460 position: 'center', 403 461 close: function(event, ui) { … … 936 994 // load template of attendees 937 995 var blkAddAtendee = UI.dialogs.addEvent.find('#calendar_addevent_details6').append(attendeeHtml); 938 if(objEvent.attendee.length) 939 callbackAttendee(); 996 if(objEvent.attendee.length) 997 callbackAttendee(); 940 998 /** 941 942 999 Opções de delegação do participante/organizer 1000 */ 943 1001 blkAddAtendee.find(".button.participant-delegate").button({ 944 1002 icons: { … … 968 1026 969 1027 UI.dialogs.addEvent.find(".attendee-list-add .add-attendee-input input").Watermark("digite um email para convidar"); 970 /* Trata a edição de um novo participante adicionado971 * 972 1028 /* 1029 * Trata a edição de um novo participante adicionado 1030 */ 973 1031 var hasNewAttendee = false; 974 1032 … … 978 1036 979 1037 blkAddAtendee.find('.attendee-list-add .add-attendee-input input').keydown(function(event) { 980 981 1038 if (event.keyCode == '13' && $(this).val() != '' || (event.keyCode == undefined && $(this).val() != '')) { 982 1039 Encoder.EncodeType = "entity"; … … 990 1047 991 1048 /** 992 993 1049 * email válido? 1050 */ 994 1051 info.match(/^[\w!#$%&'*+\/=?^`{|}~-]+(\.[\w!#$%&'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/) ? 995 1052 newAttendeeEmail = info : newAttendeeName = info; 996 1053 997 1054 /** 998 999 1000 1001 1002 1003 1004 1005 1055 * 1) busca no banco para saber se o usuário já existe 1056 * 1.1) se existe, atualiza as info na lista de participantes e nao abre o tooltip 1057 * 1.2) se não existe 1058 * a) salva como novo usuario externo no banco (apenas com email) 1059 * b) exibe tooltip pedindo o nome 1060 * c) se o usuário preenche tooltip e salva, atualiza com o nome o usuário recém criado 1061 * d) se o usuário cancela o tooltip, fica o usuário salvo apenas com email e sem nome 1062 */ 1006 1063 1007 1064 var user = DataLayer.get('user', ["=", "mail", $(this).val()]); … … 1012 1069 1013 1070 /** 1014 1015 1071 * guarda o último tooltip aberto referente à lista de participantes 1072 */ 1016 1073 lastEditAttendeeToolTip = []; 1017 1074 1018 1075 /** 1019 1020 1076 * Valida email e salva um participante externo 1077 */ 1021 1078 var saveContact = function() { 1022 1079 Encoder.EncodeType = "entity"; … … 1192 1249 $(this).val(''); 1193 1250 1194 } else if (!skipAddNewLine) { 1251 } else if (!skipAddNewLine) { 1195 1252 /** 1196 1197 1198 1253 * a) salva como novo usuario externo no banco (apenas com email) e... 1254 * adiciona novo contato externo à lista de convidados 1255 */ 1199 1256 1200 1257 userId = DataLayer.put('user', { … … 1285 1342 1286 1343 /** 1287 1288 1344 * Trata a busca de usuários para adição de participantes 1345 */ 1289 1346 blkAddAtendee.find('.add-attendee-search .ui-icon-search').click(function(event) { 1290 1347 blkAddAtendee.find('.add-attendee-search input').keydown(); … … 1374 1431 } 1375 1432 }); 1433 1376 1434 //$('.block-add-attendee .search-result-list').selectable(); 1377 1435 … … 1395 1453 }); 1396 1454 }); 1397 $('.attachment-list input').remove(); 1398 $('.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'); 1399 1458 } 1400 1459 }}); … … 1415 1474 text: false 1416 1475 }); 1417 var maxSizeFile = 2000000; 1418 $('#fileupload').fileupload({ 1419 sequentialUploads: true, 1420 add: function (e, data) { 1421 if(data.files[0].size < maxSizeFile) 1422 data.submit(); 1423 }, 1424 change: function (e, data) { 1425 $.each(data.files, function (index, file) { 1426 var attach = {}; 1427 attach.fileName = file.name; 1428 var ext = file.name.split('.'); 1429 if(file.name.length > 10) 1430 attach.fileName = ext.length == 1 ? file.name.substr(0, 10) : file.name.substr(0, 6) + '.' + ext[ext.length -1]; 1431 attach.fileSize = formatBytes(file.size); 1432 if(file.size > maxSizeFile) 1433 attach.error = 'Tamanho de arquivo nao permitido!!' 1434 1435 $('.attachments-list').append(DataLayer.render(path+'templates/attachment_add_itemlist.ejs', { 1436 file : attach 1437 })); 1438 1439 if(file.size < maxSizeFile){ 1440 $('.fileinput-button.new').append(data.fileInput[0]).removeClass('new'); 1441 $('.attachments-list').find('[type=file]').addClass('hidden'); 1442 1443 }else 1444 $('.fileinput-button.new').removeClass('new'); 1445 1446 1447 $('.attachments-list').find('.button.close').button({ 1448 icons: { 1449 primary: "ui-icon-close" 1450 }, 1451 text: false 1452 }).click(function(){ 1453 var idAttach = $(this).parent().find('input[name="fileId[]"]').val(); 1454 $('.attachment-list').find('input[value="'+idAttach+'"]') 1455 $(this).parent().remove(); 1456 }); 1457 1458 }) 1459 }, 1460 done: function(e, data){ 1461 var currentUpload = $('.progress.after-upload:first').removeClass('after-upload').addClass('on-complete').hide(); 1462 1463 if(!!data.result && data.result != "[]"){ 1464 var newAttach = (attch = jQuery.parseJSON(data.result)) ? attch : jQuery.parseJSON(data.result[0].activeElement.childNodes[0].data); 1465 $('.attachment-list').append('<input tyepe="hidden" name="attachment[]" value="'+newAttach['attachment'][0][0].id+'"/>'); 1466 currentUpload.removeClass('on-complete').parents('p') 1467 .append('<input type="hidden" name="fileId[]" value="'+newAttach['attachment'][0][0].id+'"/>') 1468 .find('.status-upload').addClass('ui-icon ui-icon-check'); 1469 }else 1470 currentUpload.removeClass('on-complete').parents('p').find('.status-upload').addClass('ui-icon ui-icon-cancel'); 1471 } 1472 }); 1473 $('.attachments-list .button').button(); 1474 1475 if(!!window.FormData) 1476 $('#fileupload').bind('fileuploadstart', function () { 1477 var widget = $(this), 1478 progressElement = $('#fileupload-progress').fadeIn(), 1479 interval = 500, 1480 total = 0, 1481 loaded = 0, 1482 loadedBefore = 0, 1483 progressTimer, 1484 progressHandler = function (e, data) { 1485 loaded = data.loaded; 1486 total = data.total; 1487 }, 1488 stopHandler = function () { 1489 widget 1490 .unbind('fileuploadprogressall', progressHandler) 1491 .unbind('fileuploadstop', stopHandler); 1492 window.clearInterval(progressTimer); 1493 progressElement.fadeOut(function () { 1494 progressElement.html(''); 1495 }); 1496 }, 1497 formatTime = function (seconds) { 1498 var date = new Date(seconds * 1000); 1499 return ('0' + date.getUTCHours()).slice(-2) + ':' + 1500 ('0' + date.getUTCMinutes()).slice(-2) + ':' + 1501 ('0' + date.getUTCSeconds()).slice(-2); 1502 }, 1503 /* formatBytes = function (bytes) { 1504 if (bytes >= 1000000000) { 1505 return (bytes / 1000000000).toFixed(2) + ' GB'; 1506 } 1507 if (bytes >= 1000000) { 1508 return (bytes / 1000000).toFixed(2) + ' MB'; 1509 } 1510 if (bytes >= 1000) { 1511 return (bytes / 1000).toFixed(2) + ' KB'; 1512 } 1513 return bytes + ' B'; 1514 },*/ 1515 formatPercentage = function (floatValue) { 1516 return (floatValue * 100).toFixed(2) + ' %'; 1517 }, 1518 updateProgressElement = function (loaded, total, bps) { 1519 progressElement.html( 1520 formatBytes(bps) + 'ps | ' + 1521 formatTime((total - loaded) / bps) + ' | ' + 1522 formatPercentage(loaded / total) + ' | ' + 1523 formatBytes(loaded) + ' / ' + formatBytes(total) 1524 ); 1525 }, 1526 intervalHandler = function () { 1527 var diff = loaded - loadedBefore; 1528 if (!diff) { 1529 return; 1530 } 1531 loadedBefore = loaded; 1532 updateProgressElement( 1533 loaded, 1534 total, 1535 diff * (1000 / interval) 1536 ); 1537 }; 1538 widget 1539 .bind('fileuploadprogressall', progressHandler) 1540 .bind('fileuploadstop', stopHandler); 1541 progressTimer = window.setInterval(intervalHandler, interval); 1542 }); 1476 1477 extendsFileupload('event', path); 1543 1478 1544 1479 if(objEvent.isShared){ … … 1557 1492 } 1558 1493 1559 disponibily(objEvent, path, attendees );1494 disponibily(objEvent, path, attendees, 'event'); 1560 1495 1561 1496 /*Seleciona a agenda padrão para criação de um evento*/ … … 1573 1508 1574 1509 UI.dialogs.addEvent.dialog('open'); 1575 //$('[href="#calendar_addevent_details7"]').trigger('click'); 1576 //$('[href="#calendar_addevent_details2"]').trigger('click'); 1510 1577 1511 } 1578 1512 … … 1691 1625 1692 1626 1693 function add_tab_configure_calendar(calendar )1627 function add_tab_configure_calendar(calendar, type) 1694 1628 { 1629 $('.qtip.qtip-blue').remove(); 1630 1695 1631 var calendars = []; 1696 1632 var signatures = []; … … 1698 1634 var calendarAlarms = []; 1699 1635 1700 for (var i=0; i<Calendar.signatures.length; i++) { 1701 calendars[i] = Calendar.signatures[i].calendar; 1702 signatures[i] = Calendar.signatures[i]; 1703 signatures[i].numberDefaultAlarm = signatures[i].defaultAlarms != '' ? signatures[i].defaultAlarms.length: 0; 1704 if (calendar && calendars[i].id == calendar) 1705 previewActiveCalendarConf = i; 1706 } 1707 1708 if(!(document.getElementById('configure_tab'))) 1636 for (var i=0; i<Calendar.signatures.length; i++) { 1637 if(parseInt(Calendar.signatures[i].calendar.type) == type){ 1638 calendars.push(Calendar.signatures[i].calendar); 1639 signatures.push(Calendar.signatures[i]); 1640 length = signatures.length - 1; 1641 signatures[length].numberDefaultAlarm = signatures[length].defaultAlarms != '' ? signatures[length].defaultAlarms.length: 0; 1642 if (calendar && calendars[length].id == calendar) 1643 previewActiveCalendarConf = length; 1644 } 1645 } 1646 var tab_selector = ['configure_tab', 'configure_tab_group']; 1647 if(!(document.getElementById(tab_selector[type]))) 1709 1648 { 1710 1649 $('.positionHelper').css('display', 'none'); 1711 1650 $('.cal-list-options-btn').removeClass('fg-menu-open ui-state-active'); 1712 var tab_title = "Configurações de agendas"; 1713 $tabs.tabs( "add", "#configure_tab", tab_title ); 1651 if(type == 0){ 1652 var tab_title = "Configurações de agendas"; 1653 }else{ 1654 var tab_title = "Configurações de Grupos"; 1655 } 1656 $tabs.tabs( "add", "#"+tab_selector[type], tab_title ); 1714 1657 1715 1658 var dataColorPicker = { … … 1734 1677 DataLayer.render( 'templates/configure_calendars_itemlist.ejs', { 1735 1678 user:User, 1679 type:0, 1736 1680 calendar:calendars[nowActive], 1737 1681 signature:signatures[nowActive] 1738 1682 }, function( form_template ){ 1739 var form_content = jQuery(' .accordion-user-calendars .ui-accordion-content').eq(nowActive).html( form_template ).find('form');1683 var form_content = jQuery('#'+tab_selector[type]+' .accordion-user-calendars .ui-accordion-content').eq(nowActive).html( form_template ).find('form'); 1740 1684 form_content.find('.preferences-alarms-list .button').button({ 1741 1685 text:false, … … 1756 1700 1757 1701 form_content.find('.button-add-alarms').click(function(){ 1758 DataLayer.render( 'templates/alarms_add_itemlist.ejs', { }, function( template ){1702 DataLayer.render( 'templates/alarms_add_itemlist.ejs', {type: 0}, function( template ){ 1759 1703 jQuery('.preferences-alarms-list').append(template) 1760 1704 .find('li:last label:eq(0)').remove().end() … … 1862 1806 DataLayer.render( 'templates/configure_calendars.ejs', { 1863 1807 user:User, 1808 type: 0, 1864 1809 calendars:calendars, 1865 1810 signatures:signatures 1866 1811 }, function( template ){ 1867 var template_content = jQuery('# configure_tab').html( template ).find('.configure-calendars-win');1812 var template_content = jQuery('#'+tab_selector[type]).html( template ).find('.configure-calendars-win'); 1868 1813 template_content.find('.button').button().filter('.save').click(function(evt){ 1869 1814 if(calendarAlarms.length) 1870 1815 DataLayer.removeFilter('calendarSignatureAlarm', {filter: ['IN','id', calendarAlarms]}); 1871 1816 template_content.find('form').submit(); 1872 $tabs.tabs( "remove", "# configure_tab");1817 $tabs.tabs( "remove", "#"+tab_selector[type]); 1873 1818 DataLayer.commit( false, false, function( received ){ 1874 1819 delete Calendar.currentViewKey; … … 1879 1824 Calendar.load(); 1880 1825 }).end().filter('.cancel').click(function(evt){ 1881 $tabs.tabs( "remove", "# configure_tab");1826 $tabs.tabs( "remove", "#"+tab_selector[type]); 1882 1827 }); 1883 1828 … … 1905 1850 $('.positionHelper').css('display','none'); 1906 1851 $('.cal-list-options-btn').removeClass('fg-menu-open ui-state-active'); 1907 $tabs.tabs("select", "# configure_tab");1852 $tabs.tabs("select", "#"+tab_selector[type]); 1908 1853 $('.accordion-user-calendars').accordion( "activate" , previewActiveCalendarConf ); 1909 1854 … … 1913 1858 } 1914 1859 1915 function getSelectedCalendars( reverse ){ 1860 function getSelectedCalendars( reverse, type ){ 1861 var selector = ""; 1862 if(type == 0) 1863 selector = ".my-calendars"; 1864 if(type == 1) 1865 selector = ".my-groups-task"; 1916 1866 var selecteds = {}; 1917 1867 var cont = 0; 1918 1868 jQuery(function() { 1919 jQuery( ".my-calendars.calendar-view").each(function(i, obj) {1869 jQuery(selector+" .calendar-view").each(function(i, obj) { 1920 1870 var check_box = obj; 1921 1871 if( reverse ? !check_box.checked : check_box.checked ) { … … 1975 1925 1976 1926 function remove_event(eventId, idCalendar){ 1977 $.Zebra_Dialog('Tem certeza que deseja excluir o evento?', {1927 $.Zebra_Dialog('Tem certeza que deseja excluir?', { 1978 1928 'type': 'question', 1979 1929 'overlay_opacity': '0.5', … … 2029 1979 2030 1980 2031 function remove_calendar( ){1981 function remove_calendar(type){ 2032 1982 /* Pode ser assim $('.cal-list-options-btn.ui-state-active').attr('class').replace(/[a-zA-Z-]+/g, ''); */ 2033 $.Zebra_Dialog('Todos os eventos desta agenda serão removidos. Deseja prosseguir com a operação?', { 1983 if(!!parseInt(type)) 1984 var title = 'Todas as tarefas deste grupo serão removidas. Deseja prosseguir com a operação?'; 1985 else 1986 var title = 'Todos os eventos desta agenda serão removidos. Deseja prosseguir com a operação?'; 1987 $.Zebra_Dialog(title, { 2034 1988 'type': 'question', 2035 1989 'overlay_opacity': '0.5', … … 2047 2001 delete Calendar.currentViewKey; 2048 2002 Calendar.load(); 2049 refresh_calendars( );2003 refresh_calendars(type); 2050 2004 }); 2051 2005 } … … 2056 2010 } 2057 2011 2058 function refresh_calendars( ){2012 function refresh_calendars(type){ 2059 2013 2060 2014 var colorsSuggestions = colors_suggestions(); … … 2091 2045 }); 2092 2046 } 2047 2093 2048 doMenu(); 2049 var currentToolTip = null; 2094 2050 $('#divAppbox').on('scroll',function(){ 2095 2051 if ($('.cal-list-options-btn.fg-menu-open.ui-state-active')){ 2096 2052 var offset = $('.cal-list-options-btn.fg-menu-open.ui-state-active').offset(); 2097 2053 if (offset) 2098 2054 $('.positionHelper').css('top',offset.top); 2099 2055 } 2056 2100 2057 if ($('.button.config-menu.fg-menu-open')){ 2101 2058 var offset = $('.button.config-menu.fg-menu-open').offset(); 2102 2059 if (offset) 2103 2060 $('.positionHelper').css('top',offset.top); 2104 2061 } 2062 2063 2064 if ($(".new-group.qtip-active").length || $(".new-calendar.qtip-active").length) 2065 $('.qtip-active').css('top',currentToolTip.offset().top - 50); 2066 2105 2067 }); 2068 2106 2069 $('ul.list-calendars .cal-list-options-btn').on('click',function(){doMenu();}); 2107 2070 2071 2072 /***************************************New Calendar***************************************/ 2108 2073 meu_container.find(".button.new-calendar").button({ 2109 2074 icons: { … … 2112 2077 text: false 2113 2078 }).click(function () { 2114 2115 if( $('.qtip.qtip-blue.qtip-active').val() !== ''){ 2116 $(this).qtip({ 2117 show: { 2118 ready: true, 2119 solo: true, 2120 when: { 2121 event: 'click' 2122 } 2123 }, 2124 hide: false, 2125 content: { 2126 text: $('<div></div>').html( DataLayer.render( 'templates/calendar_quick_add.ejs', {} ) ), 2127 title: { 2128 text:'Nova Agenda', 2129 button: '<a class="button close" href="#">close</a>' 2130 } 2131 }, 2132 style: { 2133 name: 'blue', 2134 tip: { 2135 corner: 'leftMiddle' 2136 }, 2137 border: { 2138 width: 4, 2139 radius: 8 2140 }, 2141 width: { 2142 min: 230, 2143 max:230 2144 } 2145 }, 2146 position: { 2147 corner: { 2148 target: 'rightMiddle', 2149 tooltip: 'leftMiddle' 2150 }, 2151 adjust: { 2152 x:0, 2153 y:-12 2154 } 2155 } 2156 }) 2157 .qtip("api").onShow = function(arg0) { 2158 $('.qtip-active .button.close').button({ 2159 icons: { 2160 primary: "ui-icon-close" 2161 }, 2162 text: false 2163 }) 2164 .click(function(){ 2165 meu_container.find(".button.new-calendar").qtip('destroy'); 2166 }); 2167 //TODO emplementar tratamento de duplicação de valores no location 2168 $('.qtip-active .button.save').button().click(function(){ 2169 for(var i = 0; i < Calendar.calendars.length; i++){ 2170 if(Calendar.calendars[i].location == ( User.me.uid + '/' + $('.qtip-active input').val())){ 2171 $.Zebra_Dialog('O nome desta agenda já está sendo utilizada em uma Url de outra agenda. Por favor, informe outro nome para agenda.',{ 2172 'overlay_opacity': '0.5', 2173 'type': 'warning' 2174 }); 2175 meu_container.find(".button.new").qtip('destroy'); 2176 return; 2177 } 2178 } 2079 currentToolTip = $(this); 2080 var typeCalendar = !!parseInt($(this).attr('class').match(/[0-9]+/g)) ? 2081 {type: 'new-group', title: 'Novo Grupo', typeValue: 1, prompt: 'Nome do grupo'} : 2082 {type: 'new-calendar', title: 'Nova Agenda', typeValue: 0, prompt: 'Nome da agenda'} 2083 2084 if(!$('.qtip.qtip-blue.qtip-active.'+typeCalendar.type).length){ 2085 2086 $('.qtip.qtip-blue').remove(); 2087 2088 $(this).qtip({ 2089 show: { 2090 ready: true, 2091 solo: true, 2092 when: { 2093 event: 'click' 2094 } 2095 }, 2096 hide: false, 2097 content: { 2098 text: $('<div></div>').html( DataLayer.render( 'templates/calendar_quick_add.ejs', {} ) ), 2099 title: { 2100 text: typeCalendar.title, 2101 button: '<a class="button close" href="#">close</a>' 2102 } 2103 }, 2104 style: { 2105 name: 'blue', 2106 tip: { 2107 corner: 'leftMiddle' 2108 }, 2109 border: { 2110 width: 4, 2111 radius: 8 2112 }, 2113 width: { 2114 min: 230, 2115 max:230 2116 } 2117 }, 2118 position: { 2119 corner: { 2120 target: 'rightMiddle', 2121 tooltip: 'leftMiddle' 2122 }, 2123 adjust: { 2124 x:0, 2125 y: -12 2126 2127 } 2128 } 2129 }) 2130 .qtip("api").onShow = function(arg0) { 2179 2131 2180 var selected; 2181 var color = $('.cal-colors-options-btn').each(function(index){ 2182 if ($(this).is('.color-selected')) 2183 selected = index; 2184 }); 2185 DataLayer.put( "calendarSignature", { 2186 user: User.me.id, 2187 calendar: { 2188 name: Encoder.htmlEncode($('.qtip-active input').val()), 2189 timezone: User.preferences.timezone 2190 }, 2191 isOwner: 1, 2192 fontColor: colorsSuggestions[selected]['font'].substring(1) , 2193 backgroundColor: colorsSuggestions[selected]['background'].substring(1) , 2194 borderColor: colorsSuggestions[selected]['border'].substring(1) 2195 }); 2196 DataLayer.commit( false, false, function( received ){ 2197 delete Calendar.currentViewKey; 2198 Calendar.load(); 2199 refresh_calendars(); 2200 }); 2201 meu_container.find(".button.new").qtip('destroy'); 2202 }); 2203 2204 $('.qtip-active .button.cancel').button().click(function(){ 2205 meu_container.find(".button.new").qtip('destroy'); 2206 }); 2207 2208 $(".qtip-active input").Watermark("Nome da agenda"); 2209 2210 $('.qtip-active').keydown(function(event) { 2211 if (event.keyCode == '27') { 2212 meu_container.find(".button.new").qtip('destroy'); 2213 } 2214 }); 2215 2216 $('.colors-options').prepend(buttons_colors); 2217 $('.colors-options .signed-cal-colors-options-btn-0').addClass('color-selected'); 2218 2219 var buttons = $('.cal-colors-options-btn').button(); 2220 2221 buttons.click(function(){ 2222 buttons.removeClass('color-selected'); 2223 $(this).addClass('color-selected'); 2224 }); 2225 } 2226 } 2132 $('.qtip-active .button.close').button({ 2133 icons: { 2134 primary: "ui-icon-close" 2135 }, 2136 text: false 2137 }) 2138 .click(function(){ 2139 $('.qtip.qtip-blue').remove(); 2140 }); 2141 2142 $('.qtip-active').addClass(typeCalendar.type); 2143 2144 $('.qtip-active .button.save').button().click(function(){ 2145 if(!typeCalendar.typeValue) 2146 for(var i = 0; i < Calendar.calendars.length; i++){ 2147 if(Calendar.calendars[i].location == ( User.me.uid + '/' + $('.qtip-active input').val())){ 2148 $.Zebra_Dialog('O nome desta agenda já está sendo utilizada em uma Url de outra agenda. Por favor, informe outro nome para agenda.',{ 2149 'overlay_opacity': '0.5', 2150 'type': 'warning' 2151 }); 2152 $('.qtip.qtip-blue').remove(); 2153 return; 2154 } 2155 } 2156 2157 var selected; 2158 var color = $('.cal-colors-options-btn').each(function(index){ 2159 if ($(this).is('.color-selected')) 2160 selected = index; 2161 }); 2162 DataLayer.put( "calendarSignature", { 2163 user: User.me.id, 2164 calendar: { 2165 name: Encoder.htmlEncode($('.qtip-active input').val()), 2166 timezone: User.preferences.timezone, 2167 type: typeCalendar.typeValue 2168 }, 2169 isOwner: 1, 2170 fontColor: colorsSuggestions[selected]['font'].substring(1) , 2171 backgroundColor: colorsSuggestions[selected]['background'].substring(1) , 2172 borderColor: colorsSuggestions[selected]['border'].substring(1) 2173 }); 2174 DataLayer.commit( false, false, function( received ){ 2175 delete Calendar.currentViewKey; 2176 Calendar.load(); 2177 refresh_calendars(); 2178 }); 2179 $('.qtip.qtip-blue').remove(); 2180 }); 2181 2182 $('.qtip-active .button.cancel').button().click(function(){ 2183 meu_container.find(".button.new").qtip('destroy'); 2184 }); 2185 2186 $(".qtip-active input").Watermark(typeCalendar.prompt); 2187 2188 $('.qtip-active').keydown(function(event) { 2189 if (event.keyCode == '27') 2190 meu_container.find(".button.new").qtip('destroy'); 2191 }); 2192 2193 $('.colors-options').prepend(buttons_colors); 2194 $('.colors-options .signed-cal-colors-options-btn-0').addClass('color-selected'); 2195 2196 var buttons = $('.cal-colors-options-btn').button(); 2197 2198 buttons.click(function(){ 2199 buttons.removeClass('color-selected'); 2200 $(this).addClass('color-selected'); 2201 }); 2202 } 2203 } 2227 2204 }); 2228 2205 2229 2206 $("img.cal-list-img").click(function(evt) { 2230 $(".cal-list-options_1").toggleClass( "hidden" );2207 $(".cal-list-options_1").toggleClass( "hidden" ); 2231 2208 }); 2232 2209 2210 $(".my-groups-task a.title-my-calendars").click(function() { 2211 $(".my-groups-task ul.my-list-calendars").toggleClass("hidden") 2212 $('.my-groups-task .status-list').toggleClass("ui-icon-triangle-1-s"); 2213 $('.my-groups-task .status-list').toggleClass("ui-icon-triangle-1-e"); 2214 }); 2215 2233 2216 $(".my-calendars a.title-my-calendars").click(function() { 2234 $(".my-calendars ul.my-list-calendars").toggleClass("hidden")2235 $('.my-calendars .status-list').toggleClass("ui-icon-triangle-1-s");2236 $('.my-calendars .status-list').toggleClass("ui-icon-triangle-1-e");2217 $(".my-calendars ul.my-list-calendars").toggleClass("hidden") 2218 $('.my-calendars .status-list').toggleClass("ui-icon-triangle-1-s"); 2219 $('.my-calendars .status-list').toggleClass("ui-icon-triangle-1-e"); 2237 2220 }); 2238 2221 2239 2222 $(".signed-calendars a.title-signed-calendars").click(function() { 2240 $(".signed-calendars ul.signed-list-calendars").toggleClass( "hidden");2223 $(".signed-calendars ul.signed-list-calendars").toggleClass( "hidden"); 2241 2224 }); 2242 2225 … … 2270 2253 2271 2254 $('.calendar-view').click(function(evt){ 2272 if($tabs.tabs('option' ,'selected') == 1){2273 pageselectCallback('', 0 );2255 if($tabs.tabs('option' ,'selected') != 0){ 2256 pageselectCallback('', 0, false, type); 2274 2257 } 2275 2258 … … 2285 2268 } 2286 2269 2287 function add_events_list(keyword )2270 function add_events_list(keyword, type) 2288 2271 { 2289 2272 var tab_title = ""; 2290 2273 if (keyword){ 2291 if(keyword.length < 10) 2292 tab_title = keyword; 2293 else 2294 tab_title = keyword.substr(0,10) + '..."'; 2274 type = 2; 2275 if(keyword.length < 10) 2276 tab_title = keyword; 2277 else 2278 tab_title = keyword.substr(0,10) + '..."'; 2295 2279 }else{ 2296 tab_title = "Lista de eventos"; 2297 } 2280 if(type){ 2281 if(!!parseInt(type)) 2282 tab_title = "Lista de tarefas"; 2283 else 2284 tab_title = "Lista de eventos"; 2285 } 2286 } 2287 var tab_selector = ['tab_events_list_', 'tab_tasks_list_', 'tab_all_list_']; 2298 2288 keyword = ( keyword || '' ).replace( /\s+/g, "_" ); 2299 2289 2300 if(!(document.getElementById( 'tab_events_list_'+ (Base64.encode(keyword)).replace(/[^\w\s]/gi, "") )))2290 if(!(document.getElementById(tab_selector[type] + (Base64.encode(keyword)).replace(/[^\w\s]/gi, "") ))) 2301 2291 { 2302 2292 Encoder.EncodeType = "entity"; 2303 $tabs.tabs( "add", "# tab_events_list_"+ (Base64.encode(keyword)).replace(/[^\w\s]/gi, ""), Encoder.htmlEncode(tab_title) );2293 $tabs.tabs( "add", "#"+tab_selector[type] + (Base64.encode(keyword)).replace(/[^\w\s]/gi, ""), Encoder.htmlEncode(tab_title) ); 2304 2294 } 2305 2295 else /* Tab already opened */ 2306 2296 { 2307 $tabs.tabs("option", "selected", 2);2308 2309 2310 pageselectCallback(keyword, 0 ); // load page 1 and insert data on event_list.ejs2297 //$tabs.tabs("option", "selected", 2); 2298 } 2299 2300 pageselectCallback(keyword, 0, false, type); // load page 1 and insert data on event_list.ejs 2311 2301 2312 2302 $('.preferences-win.active .button.save, .preferences-win.active .button.cancel, .preferences-win.active .button.import, .preferences-win.active .button.export').button(); … … 2328 2318 if(paginator.indexOf('next') > 0){ 2329 2319 if(parseInt($(currentView+' [name = results]').val()) > 25) 2330 pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($(currentView+' [name = page_index]').val())) +1) );2320 pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($(currentView+' [name = page_index]').val())) +1), false, 2); 2331 2321 }else{ 2332 2322 if(parseInt($(currentView+' [name = page_index]').val()) > 0) 2333 pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($(currentView+' [name = page_index]').val())) -1) );2323 pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($(currentView+' [name = page_index]').val())) -1), false, 2); 2334 2324 } 2335 2325 }); … … 2369 2359 } 2370 2360 2371 function paginatorList(currentView, view ){2372 $(currentView+' .events-list.events-list-win.active .list-events-paginator .fc-header-title').html('<h2>'+mountTitleList( parseInt($( '[name = page_index]').val()),view)+'</h2>');2361 function paginatorList(currentView, view, type){ 2362 $(currentView+' .events-list.events-list-win.active .list-events-paginator .fc-header-title').html('<h2>'+mountTitleList( parseInt($(currentView+' [name = page_index]').val()),view)+'</h2>'); 2373 2363 $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right .fc-button').removeClass('fc-state-active') 2374 2364 if(view == 'basicDay') … … 2390 2380 var goView = $(this).attr('class'); 2391 2381 if(goView.indexOf('agendaDay') > 0) 2392 pageselectCallback($(currentView+' [name = keyword]').val(), 0, ' ', 'agendaDay');2382 pageselectCallback($(currentView+' [name = keyword]').val(), 0, 'agendaDay', type); 2393 2383 else if(goView.indexOf('month') > 0) 2394 pageselectCallback($(currentView+' [name = keyword]').val(), 0, ' ', 'month');2384 pageselectCallback($(currentView+' [name = keyword]').val(), 0, 'month', type); 2395 2385 else if(goView.indexOf('year') > 0) 2396 pageselectCallback($(currentView+' [name = keyword]').val(), 0, ' ', 'year');2386 pageselectCallback($(currentView+' [name = keyword]').val(), 0, 'year', type); 2397 2387 else if(goView.indexOf('agendaWeek') > 0) 2398 pageselectCallback($(currentView+' [name = keyword]').val(), 0, ' ', 'agendaWeek');2388 pageselectCallback($(currentView+' [name = keyword]').val(), 0, 'agendaWeek', type); 2399 2389 2400 2390 }); … … 2412 2402 var paginator = $(this).attr('class'); 2413 2403 if(paginator.indexOf('next') > 0) 2414 pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($( '[name = page_index]').val())) +1), '', view);2404 pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($(currentView+' [name = page_index]').val())) +1), view, type); 2415 2405 else 2416 pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($( '[name = page_index]').val())) -1), '', view);2406 pageselectCallback($(currentView+' [name = keyword]').val(), ((parseInt($(currentView+' [name = page_index]').val())) -1), view, type); 2417 2407 }); 2418 2408 } 2419 2409 2420 function paginatorListEvent(currentView, typeView, view){ 2410 function printEventList(view){ 2411 $('.fc-button-print.print-list-events').click(function(){ 2412 var window_print = window.open('','ExpressoCalendar','width=800,height=600,scrollbars=yes'); 2413 var listEvents = $(view).clone(); 2414 listEvents.find('.fc-button').remove(); 2415 listEvents.find('.details-event-list').remove(); 2416 listEvents.find('.list-events-paginator').attr( "align" , "center" ); 2417 listEvents = listEvents.html(); 2418 type = $(this).parents('.ui-tabs-panel').attr("id").split("_")[1]; 2419 var data = { 2420 type : type == "tasks" ? "task-list" : ( type == "events" ? "event-list" : "search"), 2421 html : listEvents 2422 } 2423 window_print.document.open(); 2424 window_print.document.write(DataLayer.render('templates/calendar_list_print.ejs', data)); 2425 window_print.document.close(); 2426 window_print.print(); 2427 }); 2428 } 2429 2430 function paginatorListEvent(currentView, typeView, view, type){ 2421 2431 if(!!$(currentView).find('.fc-calendar').length) 2422 2432 return; … … 2430 2440 $(currentView+' .events-list.events-list-win.active .fc-header .fc-header-center').addClass('list-events-paginator'); 2431 2441 $(currentView+' .events-list.events-list-win.active .fc-header .list-events-paginator').removeClass('fc-header-center'); 2432 2442 2433 2443 //Adicionar class no header padronizar com a tela principal 2434 $(currentView+' .events-list.events-list-win.active .fc-header').addClass('header-paginator'); 2435 $(currentView+' .events-list.events-list-win.active .header-paginator').removeClass('fc-header'); 2436 2444 $(currentView+' .events-list.events-list-win.active .fc-header .fc-button-print').addClass('print-list-events'); 2445 $(currentView+' .events-list.events-list-win.active .fc-header').addClass('header-paginator'); 2446 $(currentView+' .events-list.events-list-win.active .header-paginator').removeClass('fc-header'); 2447 2448 printEventList(currentView); 2449 2437 2450 if(typeView == 'search'){ 2438 $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right ').remove()2451 $(currentView+' .events-list.events-list-win.active .header-paginator .fc-header-right span.fc-button:not(.fc-button-print)').remove(); 2439 2452 $(currentView+' .events-list.events-list-win.active .list-events-paginator .fc-header-title').html('<h2>Resultados para: '+$(currentView+' [name = keyword]').val()+'</h2>'); 2440 2453 if((parseInt($(currentView+' [name = page_index]').val()) == 0) && (parseInt($(currentView+' [name = results]').val()) <= 25)) … … 2442 2455 paginatorSearch(currentView); 2443 2456 }else 2444 paginatorList(currentView, view );2457 paginatorList(currentView, view, type); 2445 2458 } 2446 2459 … … 2450 2463 case 'basicDay': 2451 2464 case 'agendaDay': 2452 rangeStart = new Date ().add({2465 rangeStart = new Date.today().add({ 2453 2466 days: page_index 2454 2467 }).getTime(); 2455 rangeEnd = rangeStart ;2468 rangeEnd = rangeStart + 86400000; 2456 2469 break; 2457 2470 case 'agendaWeek': … … 2519 2532 } 2520 2533 2521 function pageselectCallback(keyword, page_index, jq, view){ 2522 2523 var selecteds = getSelectedCalendars(); 2524 if(!selecteds && (keyword != '' && keyword != null)){ 2525 jQuery('#tab_events_list_' + ((Base64.encode(keyword)).replace(/[^\w\s]/gi, "")|| '')).html( 2526 '<div title="Lista de eventos" class="events-list events-list-win active empty">' + 2527 '<label>Por favor selecione ao menos uma agenda.</label>' + 2534 function pageselectCallback(keyword, page_index, view, type){ 2535 $('.qtip.qtip-blue').remove(); 2536 var tab_selector = ['tab_events_list_', 'tab_tasks_list_', 'tab_all_list_']; 2537 var tab_title = ['Lista de eventos', 'Lista de tarefas']; 2538 var label_noselect_calendar = ['Por favor selecione ao menos uma agenda.', 'Por favor selecione ao menos um grupo.', 'Por favor selecione ao menos uma agenda ou grupo.']; 2539 var label_nofound_search = ['Não foi encontrado nenhum evento correspondente à sua pesquisa.', 'Não foi encontrado nenhuma tarefa ou atividade correspondente à sua pesquisa.', 'Não foi encontrado nenhum evento ou tarefa ou atividade correspondente à sua pesquisa.']; 2540 var label_nofound = ['Não foram encontrados eventos neste intervalo.', 'Não foram encontradas tarefas ou atividades neste intervalo.', 'Não foram encontrados eventos ou tarefas ou atividades neste intervalo.']; 2541 var selecteds = getSelectedCalendars(false, type); 2542 2543 if(!selecteds && (keyword != '' && keyword != null)){ 2544 jQuery('#'+tab_selector[type] + ((Base64.encode(keyword)).replace(/[^\w\s]/gi, "")|| '')).html( 2545 '<div title="'+tab_title[type]+'" class="events-list events-list-win active empty">' + 2546 '<label>'+label_noselect_calendar[type]+'</label>' + 2528 2547 '</div>' 2529 2548 ); … … 2545 2564 var results = DataLayer.get('schedulable:detail', criteria); 2546 2565 keyword = ( keyword || '' ).replace( /\s+/g, "_" ); 2547 }2566 } 2548 2567 // não há resultados 2549 2568 2550 var currentView = '# tab_events_list_'+ ((Base64.encode(keyword)).replace(/[^\w\s]/gi, "") || '');2569 var currentView = '#'+tab_selector[type] + ((Base64.encode(keyword)).replace(/[^\w\s]/gi, "") || ''); 2551 2570 2552 2571 if ((((typeof(results) == 'undefined') || (!results.events_list )) && selecteds) &&(keyword != '' && keyword != null)) { 2553 2572 $(currentView).html( 2554 '<div title=" Lista de eventos" class="events-list events-list-win active empty">' +2555 '<label> Não foi encontrado nenhum evento correspondente à sua pesquisa.</label>' +2573 '<div title="'+title+'" class="events-list events-list-win active empty">' + 2574 '<label>'+label_nofound_search[type]+'</label>' + 2556 2575 '</div>' 2557 2576 ); … … 2561 2580 results['page_index'] = page_index; 2562 2581 results['keyword'] = keyword; 2563 2582 results['tab_title'] = tab_title[type]; 2564 2583 DataLayer.render( 'templates/event_list.ejs', results, function( html ){ 2565 2584 … … 2567 2586 $('.events-list-win .menu-container .button').button(); 2568 2587 2569 $(".event-details-item").parent().click(function( ){2570 2588 $(".event-details-item").parent().click(function(event){ 2589 event.stopImmediatePropagation(); 2571 2590 $(this).siblings("div.details-event-list").toggleClass("hidden") 2572 .find('.button.delete').click(function( ){2591 .find('.button.delete').click(function(event){ 2573 2592 var eventId = $(this).siblings('[name="eventid"]').val(); 2574 2593 var calendarId = $(this).siblings('[name="calendarid"]').val(); 2575 2576 2594 remove_event(eventId, calendarId); 2595 event.stopImmediatePropagation() 2577 2596 }) 2578 .end().find('.button.edit').click(function(){ 2579 eventDetails( DataLayer.get( "schedulable", $(this).siblings('[name="eventid"]').val() ), true ); 2597 .end().find('.button.edit').click(function(event){ 2598 if($(this).siblings('[name="eventtype"]').val() == 1) 2599 eventDetails( DataLayer.get( "schedulable", $(this).siblings('[name="eventid"]').val() ), true ); 2600 else 2601 taskDetails( DataLayer.get( "schedulable", $(this).siblings('[name="eventid"]').val() ), true ); 2602 2603 event.stopImmediatePropagation() 2604 }) 2605 .end().find('.button.print').click(function(event){ 2606 var window_print = window.open('','ExpressoCalendar','width=800,height=600,scrollbars=yes'); 2607 var html = $(this).parents("td:first").clone(); 2608 html.find(".menu-container.footer-container").remove(); 2609 var html = html.html(); 2610 var data = { 2611 type : $(this).parents('.details-event-list').hasClass("details-event") ? "event-detail" : "task-detail", 2612 html : html 2613 } 2614 window_print.document.open(); 2615 window_print.document.write(DataLayer.render('templates/calendar_list_print.ejs', data)); 2616 window_print.document.close(); 2617 window_print.print(); 2618 2619 event.stopImmediatePropagation() 2580 2620 }); 2581 2621 2582 2622 }); 2583 paginatorListEvent(currentView, (keyword == '' || keyword == null) ? 'list' : 'search', !!view ? view : User.preferences.defaultCalView );2623 paginatorListEvent(currentView, (keyword == '' || keyword == null) ? 'list' : 'search', !!view ? view : User.preferences.defaultCalView, type); 2584 2624 }); 2585 2625 }else{ 2586 2626 $(currentView).html( 2587 '<div title=" Lista de eventos" class="events-list events-list-win active empty">' +2627 '<div title="'+title+'" class="events-list events-list-win active empty">' + 2588 2628 '<input type="hidden" name="page_index" value="'+page_index+'"></inpunt>'+ 2589 2629 '<input type="hidden" name="keyword" value="'+keyword+'"></inpunt>'+ 2590 '<label class="empty-result"> Não foram encontrados eventos neste intervalo.</label>' +2630 '<label class="empty-result">'+label_nofound[type]+'</label>' + 2591 2631 '</div>' 2592 2632 ); 2593 paginatorListEvent(currentView, 'list', !!view ? view : User.preferences.defaultCalView );2594 } 2595 } 2596 if(currentView != '# tab_events_list_')2633 paginatorListEvent(currentView, 'list', !!view ? view : User.preferences.defaultCalView, type); 2634 } 2635 } 2636 if(currentView != '#'+tab_selector[type]) 2597 2637 $tabs.tabs("select", currentView); 2598 2638 } 2599 2639 2600 function show_modal_import_export(tab, calendarId) { 2640 function show_modal_import_export(tab, calendarId, typeView){ 2641 $('.qtip.qtip-blue').remove(); 2601 2642 DataLayer.render( 'templates/import_export.ejs', { 2602 calendars: Calendar.calendars, 2603 owner: User.me.id 2643 calendars: typeView == 0 ? Calendar.calendars : Calendar.groups, 2644 owner: User.me.id, 2645 typeView: typeView 2604 2646 }, function( html ){ 2605 2647 2606 2648 if (!UI.dialogs.importCalendar) { 2607 2649 UI.dialogs.importCalendar = jQuery('#div-import-export-calendar') 2608 .append('<div title="Importar e Exportar Eventos" class="import-export import-export-win active"> <div>')2650 .append('<div title="Importar e Exportar "' + (typeView == 0 ? 'Eventos' : 'Tarefas') + '" class="import-export import-export-win active"> <div>') 2609 2651 .find('.import-export-win.active').html(html).dialog({ 2610 2652 resizable: false, … … 2831 2873 } 2832 2874 } 2875 2876 function extendsFileupload(view, path){ 2877 var viewName = 'div.new-'+view+'-win'; 2878 2879 path = !!path ? path : ''; 2880 2881 var maxSizeFile = 2000000; 2882 $('#fileupload'+view).fileupload({ 2883 sequentialUploads: true, 2884 add: function (e, data) { 2885 if(data.files[0].size < maxSizeFile) 2886 data.submit(); 2887 }, 2888 change: function (e, data) { 2889 $.each(data.files, function (index, file) { 2890 var attach = {}; 2891 attach.fileName = file.name; 2892 var ext = file.name.split('.'); 2893 if(file.name.length > 10) 2894 attach.fileName = ext.length == 1 ? file.name.substr(0, 10) : file.name.substr(0, 6) + '.' + ext[ext.length -1]; 2895 attach.fileSize = formatBytes(file.size); 2896 if(file.size > maxSizeFile) 2897 attach.error = 'Tamanho de arquivo nao permitido!!' 2898 2899 $(viewName+' .attachments-list').append(DataLayer.render(path+'templates/attachment_add_itemlist.ejs', { 2900 file : attach 2901 })); 2902 2903 if(file.size < maxSizeFile){ 2904 $(viewName+' .fileinput-button.new').append(data.fileInput[0]).removeClass('new'); 2905 $(viewName+' .attachments-list').find('[type=file]').addClass('hidden'); 2906 2907 }else 2908 $(viewName+' .fileinput-button.new').removeClass('new'); 2909 2910 2911 $(viewName+' .attachments-list').find('.button.close').button({ 2912 icons: { 2913 primary: "ui-icon-close" 2914 }, 2915 text: false 2916 }).click(function(){ 2917 var idAttach = $(this).parent().find('input[name="fileId[]"]').val(); 2918 $(viewName+' .attachment-list').find('input[value="'+idAttach+'"]').remove(); 2919 $(this).parent().remove(); 2920 2921 if(!$(viewName+' .attachment-list input').length) 2922 $(viewName+' .btn-danger.delete').addClass('hidden'); 2923 2924 }); 2925 2926 }) 2927 }, 2928 done: function(e, data){ 2929 var currentUpload = $(viewName+' .progress.after-upload:first').removeClass('after-upload').addClass('on-complete').hide(); 2930 2931 if(!!data.result && data.result != "[]"){ 2932 $(viewName+' .btn-danger.delete').removeClass('hidden'); 2933 var newAttach = (attch = jQuery.parseJSON(data.result)) ? attch : jQuery.parseJSON(data.result[0].activeElement.childNodes[0].data); 2934 $(viewName+' .attachment-list').append('<input tyepe="hidden" name="attachment[]" value="'+newAttach['attachment'][0][0].id+'"/>'); 2935 currentUpload.removeClass('on-complete').parents('p') 2936 .append('<input type="hidden" name="fileId[]" value="'+newAttach['attachment'][0][0].id+'"/>') 2937 .find('.status-upload').addClass('ui-icon ui-icon-check'); 2938 }else 2939 currentUpload.removeClass('on-complete').parents('p').find('.status-upload').addClass('ui-icon ui-icon-cancel'); 2940 } 2941 }); 2942 $('.attachments-list .button').button(); 2943 2944 if(!!window.FormData) 2945 $('#fileupload'+view).bind('fileuploadstart', function () { 2946 var widget = $(this), 2947 progressElement = $('#fileupload-progress-'+view).fadeIn(), 2948 interval = 500, 2949 total = 0, 2950 loaded = 0, 2951 loadedBefore = 0, 2952 progressTimer, 2953 progressHandler = function (e, data) { 2954 loaded = data.loaded; 2955 total = data.total; 2956 }, 2957 stopHandler = function () { 2958 widget 2959 .unbind('fileuploadprogressall', progressHandler) 2960 .unbind('fileuploadstop', stopHandler); 2961 window.clearInterval(progressTimer); 2962 progressElement.fadeOut(function () { 2963 progressElement.html(''); 2964 }); 2965 }, 2966 formatTime = function (seconds) { 2967 var date = new Date(seconds * 1000); 2968 return ('0' + date.getUTCHours()).slice(-2) + ':' + 2969 ('0' + date.getUTCMinutes()).slice(-2) + ':' + 2970 ('0' + date.getUTCSeconds()).slice(-2); 2971 }, 2972 /* formatBytes = function (bytes) { 2973 if (bytes >= 1000000000) { 2974 return (bytes / 1000000000).toFixed(2) + ' GB'; 2975 } 2976 if (bytes >= 1000000) { 2977 return (bytes / 1000000).toFixed(2) + ' MB'; 2978 } 2979 if (bytes >= 1000) { 2980 return (bytes / 1000).toFixed(2) + ' KB'; 2981 } 2982 return bytes + ' B'; 2983 },*/ 2984 formatPercentage = function (floatValue) { 2985 return (floatValue * 100).toFixed(2) + ' %'; 2986 }, 2987 updateProgressElement = function (loaded, total, bps) { 2988 progressElement.html( 2989 formatBytes(bps) + 'ps | ' + 2990 formatTime((total - loaded) / bps) + ' | ' + 2991 formatPercentage(loaded / total) + ' | ' + 2992 formatBytes(loaded) + ' / ' + formatBytes(total) 2993 ); 2994 }, 2995 intervalHandler = function () { 2996 var diff = loaded - loadedBefore; 2997 if (!diff) { 2998 return; 2999 } 3000 loadedBefore = loaded; 3001 updateProgressElement( 3002 loaded, 3003 total, 3004 diff * (1000 / interval) 3005 ); 3006 }; 3007 widget 3008 .bind('fileuploadprogressall', progressHandler) 3009 .bind('fileuploadstop', stopHandler); 3010 progressTimer = window.setInterval(intervalHandler, interval); 3011 }); 3012 3013 } -
trunk/prototype/modules/calendar/js/init.js
r6444 r6996 147 147 }, true ); 148 148 }); 149 150 var currentToolTip = null; 151 $('#divAppbox').on('scroll',function(){ 152 if ($(".new-task").length) 153 currentToolTip.qtip('destroy'); 154 }); 155 156 /* Quick add task 157 -----------------------------------------------------------------*/ 158 $(".button.add.add-task").click(function(event){ 159 currentToolTip = $(this); 160 var componente = $(this); 161 162 if(!$('div.qtip.qtip-blue.new-task').length){ 163 164 $('div.qtip.qtip-blue').remove(); 165 166 $(componente).qtip({ 167 show: { 168 ready: true, 169 solo: true, 170 when: { 171 event: 'click' 172 } 173 }, 174 hide: false, 175 content: { 176 text: $('<div></div>').html( DataLayer.render( 'templates/task_quick_add.ejs', {"componente" : componente} ) ), 177 title: { 178 text:'Nova tarefa', 179 button: '<a class="button close" href="#">close</a>' 180 } 181 }, 182 style: { 183 name: 'blue', 184 tip: { 185 corner: 'leftMiddle' 186 }, 187 border: { 188 width: 4, 189 radius: 8 190 }, 191 width: { 192 min: 225, 193 max:225 194 } 195 }, 196 position: { 197 corner: { 198 target: 'rightMiddle', 199 tooltip: 'leftMiddle' 200 }, 201 adjust: { 202 x:0, 203 y:0 204 } 205 } 206 }) 207 .qtip("api").onShow = function(arg0) { 208 209 /*------------------------------------------------------------------------*/ 210 /* Seta os valores padrões nos inputs do qtip */ 211 $('div.qtip div.add-simple-task input.task').Watermark("Tarefa sem título"); 212 $('div.qtip div.add-simple-task textarea').Watermark("Descrição"); 213 /*------------------------------------------------------------------------*/ 214 215 $('.qtip-active .button.close').button({ 216 icons: { 217 primary: "ui-icon-close" 218 }, 219 text: false 220 }) 221 .click(function(){ 222 $(componente).qtip('destroy'); 223 }); 224 225 $('.qtip-active .button.save').button().click(function(){ 226 227 var title = $('div.qtip div.add-simple-task input.task').val(); 228 var description = $('div.qtip div.add-simple-task textarea').val(); 229 230 var calendar, timezone = ''; 231 232 for (var i = 0; i < Calendar.signatures.length; i++){ 233 if(Calendar.signatures[i].type == 1 && Calendar.signatures[i].calendar.type == 1){ 234 calendar = Calendar.signatures[i].calendar.id; 235 timezone = Calendar.signatures[i].calendar.timezone; 236 break; 237 } 238 } 239 240 DataLayer.put('schedulable', 241 { 242 summary: title, 243 description: description, 244 type: '2', 245 calendar: calendar, 246 timezone: timezone, 247 status: '1', 248 startTime: new Date().toString('yyyy-MM-dd 00:00:00'), 249 endTime: new Date().toString('yyyy-MM-dd 00:00:00'), 250 allDay: '1', 251 participants: 252 [{ 253 user: User.me.id, 254 isOrganizer: 1, 255 acl: 'row' 256 }] 257 }); 258 259 $(componente).qtip('destroy'); 260 261 }); 262 263 $('.qtip-active .button.advanced').button().click(function(){ 264 265 var startEvent = new Date(); 266 var configData = (startEvent.toString('mm') < 30) ? {minutes: (30 - parseInt(startEvent.toString('mm')))} : {hours: 1, minutes: '-'+startEvent.toString('mm')}; 267 startEvent.add(configData); 268 269 var componente = $(this); 270 var description = $('div.qtip div.add-simple-task textarea[name="description"]').val(); 271 272 taskDetails({ 273 summary: $('div.qtip div.add-simple-task input[name="summary"]').val(), 274 description: description == 'Descrição' ? '' : description, 275 startTime: startEvent.getTime(), 276 endTime: dateCalendar.decodeRange(startEvent, (!!User.preferences.defaultCalendar ? ( !!Calendar.signatureOf[User.preferences.defaultCalendar].calendar.defaultDuration ? 277 (Calendar.signatureOf[User.preferences.defaultCalendar].calendar.defaultDuration) : (User.preferences.defaultDuration)) : (User.preferences.defaultDuration))) 278 }, true ); 279 280 $(componente).qtip('destroy'); 281 }); 282 283 $('.qtip-active .button.cancel').button().click(function(){ 284 $(componente).qtip('destroy'); 285 }); 286 287 $('.qtip-active .button').button(); 288 289 $('div.qtip.qtip-blue.qtip-active').addClass('new-task'); 290 } 291 } 292 }); 293 294 $(".button.add.add-activity").click(function(event){ 295 var startEvent = new Date(); 296 var configData = (startEvent.toString('mm') < 30) ? {minutes: (30 - parseInt(startEvent.toString('mm')))} : {hours: 1, minutes: '-'+startEvent.toString('mm')}; 297 startEvent.add(configData); 298 299 activityDetails({ 300 startTime: startEvent.getTime(), 301 endTime: dateCalendar.decodeRange(startEvent, (!!User.preferences.defaultCalendar ? ( !!Calendar.signatureOf[User.preferences.defaultCalendar].calendar.defaultDuration ? 302 (Calendar.signatureOf[User.preferences.defaultCalendar].calendar.defaultDuration) : (User.preferences.defaultDuration)) : (User.preferences.defaultDuration))) 303 }, true ); 304 305 }); 149 306 150 307 var calendar = $('#calendar').fullCalendar(DataLayer.merge({ … … 189 346 year: 'ano' 190 347 }, 348 349 eventRender: function( event, element, view ){ 191 350 /* 192 eventRender: function( event, element, view ){ 193 $(element).attr( 'event-id', event.id ); 194 }, 195 */ 351 * TODO - Encontrar icones mais filé 352 */ 353 var img_icon = ""; 354 if(event.type == 1) 355 img_icon = "mini-event.png"; 356 if(event.type == 2) 357 img_icon = "mini-task.png"; 358 if(event.type == 3) 359 img_icon = "activity_icon.jpg"; 360 361 362 element.find(".fc-event-inner.fc-event-skin").prepend($('<img style="width: 11px; height: 13px;" class="" src="../prototype/modules/calendar/img/' + img_icon + '"></img>')); 363 }, 364 196 365 select: function( start, end, allDay, event, view ){ 197 366 if (view.name == "month") { … … 285 454 eventClick: function( evt, event, view ){ 286 455 evt.id = evt.id.split('-')[0]; 287 if(evt.selectable){288 if(evt.isRepeat){289 $.Zebra_Dialog(evt.title + ' é um evento com repetição.', {290 'type': 'question',291 'overlay_opacity': '0.5',292 'buttons': ['Editar todas ocorrências', 'Editar essa ocorrência'],293 'onClose': function(clicked) {294 if(clicked == 'Editar todas ocorrências') {295 eventDetails( DataLayer.get( "schedulable", evt.id), true);296 }else{297 /*298 * TODO - repeat foi adicionado pois melhorias devem ser feitas no rollback do299 *DataLayer, repeat somente é usado quando se trata da criação de um evento300 *pela edição de uma ocorrência.301 */302 var repeat = mount_exception(evt.id, evt.occurrence);303 304 $('.calendar-copy-move input[name="typeEvent"]').val("3");305 306 eventDetails(copyAndMoveTo(false , evt.id , false, "3", evt), true, '', false, repeat);307 }308 }309 });310 311 }else{312 var schedulable = DataLayer.get( "schedulable", evt.id);313 schedulable.calendar = evt.calendar; 314 eventDetails( schedulable, true);315 316 } 317 456 457 switch (parseInt(evt.type)){ 458 case 1: 459 if(evt.selectable){ 460 if(evt.isRepeat){ 461 $.Zebra_Dialog(evt.title + ' é um evento com repetição.', { 462 'type': 'question', 463 'overlay_opacity': '0.5', 464 'buttons': ['Editar todas ocorrências', 'Editar essa ocorrência'], 465 'onClose': function(clicked) { 466 if(clicked == 'Editar todas ocorrências') { 467 eventDetails( DataLayer.get( "schedulable", evt.id), true); 468 }else{ 469 /* 470 * TODO - repeat foi adicionado pois melhorias devem ser feitas no rollback do 471 *DataLayer, repeat somente é usado quando se trata da criação de um evento 472 *pela edição de uma ocorrência. 473 */ 474 var repeat = mount_exception(evt.id, evt.occurrence); 475 476 $('.calendar-copy-move input[name="typeEvent"]').val("3"); 477 478 eventDetails(copyAndMoveTo(false , evt.id , false, "3", evt), true, '', false, repeat); 479 } 480 } 481 }); 482 }else{ 483 var schedulable = DataLayer.get( "schedulable", evt.id); 484 schedulable.group = evt.calendar; 485 eventDetails( schedulable, true); 486 } 318 487 } 488 break; 489 case 2: 490 var task = DataLayer.get( "schedulable", evt.id); 491 task.group = evt.calendar; 492 taskDetails( task, true); 493 break; 494 case 3: 495 var activity = DataLayer.get( "schedulable", evt.id); 496 activity.group = evt.calendar; 497 activityDetails( activity, true); 498 break; 499 } 319 500 }, 320 501 … … 322 503 contentMenu(); 323 504 } 324 }, dateCalendar)); 325 505 }, dateCalendar)); 506 507 326 508 contentMenu(); 327 509 … … 346 528 }); 347 529 //Todo chamada do metodo que adiciona ao full calendar o botao de listagem de eventos 348 //listEvents();530 printEvents(); 349 531 }); 532 533 534 function useDesktopNotification(){ 535 return !!parseInt(User.preferences.useDesktopNotification); 536 } -
trunk/prototype/modules/calendar/js/load.js
r6444 r6996 1 1 Refresh = { 2 //Tempo em que ap ós a ultima sincronização será verificado atualizações2 //Tempo em que após a ultima sincronização será verificado atualizações 3 3 timeRefresh : 180, 4 4 clookRefresh: false, … … 8 8 delete DataLayer.tasks[this.clookRefresh]; 9 9 10 //Realiza agendamentos de atualiza ção de view somente se o módulo aberto for expressoCalendar10 //Realiza agendamentos de atualização de view somente se o módulo aberto for expressoCalendar 11 11 if(User.moduleName == "expressoCalendar"){ 12 12 this.clookRefresh = (parseInt(($.now()) / 1000) + this.timeRefresh); … … 54 54 } 55 55 56 this.calendarIds = [], this. signatureOf = {}, this.calendars = [], this.calendarOf= {};56 this.calendarIds = [], this.groupIds = [], this.signatureOf = {}, this.calendars = [], this.groups = [], this.calendarOf = {}, this.groupOf= {}; 57 57 58 58 for( var i = 0; i < this.signatures.length; i++ ){ 59 59 if(this.signatures[i].isOwner == "0") 60 60 this.signatures[i].permission = DataLayer.encode('calendarToPermission:detail', this.signatures[i].permission); 61 this.signatureOf[ this.calendarIds[i] = ( this.calendars[ this.calendars.length ] = this.calendarOf[ this.signatures[i].id ] = this.signatures[i].calendar ).id ] = this.signatures[i]; 61 62 if(this.signatures[i].calendar.type == '1') 63 this.signatureOf[ this.groupIds[this.groupIds.length] = ( this.groups[ this.groups.length ] = this.groupOf[ this.signatures[i].id ] = this.signatures[i].calendar ).id ] = this.signatures[i]; 64 else 65 this.signatureOf[ this.calendarIds[ this.calendarIds.length] = ( this.calendars[ this.calendars.length ] = this.calendarOf[ this.signatures[i].id ] = this.signatures[i].calendar ).id ] = this.signatures[i]; 62 66 } 63 67 … … 67 71 68 72 rerenderView: function(force){ 69 //TODO - Remover if quando centralizar o objeto User que contem as informa ções do usuário logado em um local acessÃvel a todos módulos73 //TODO - Remover if quando centralizar o objeto User que contem as informações do usuário logado em um local acessível a todos módulos 70 74 if(User.moduleName == "expressoCalendar"){ 71 75 if((typeof($tabs) != "undefined") && $tabs.tabs('option' ,'selected') == 0){ … … 89 93 contentMenu(); 90 94 }else if((typeof($tabs) != "undefined") && $tabs.tabs('option' ,'selected') != 0) 91 pageselectCallback($('.events-list-win.active [name=keyword]').val(), 0); 95 96 pageselectCallback($('.events-list-win.active [name=keyword]').val(), 0, false, ($tabs.tabs('option' ,'selected') > 2) ? 2 : ($tabs.tabs('option' ,'selected') == 1) ? 0 : 1); 92 97 } 93 98 } 94 99 } 95 100 96 Alarms = {97 load: function(){98 var eventsDay = DataLayer.get('alarm:schedulable',['=', 'date', Date.today().getTime()]);99 if(eventsDay)100 for(var i = 0; i < eventsDay.length; i++){101 this.addAlarm( eventsDay[i] );102 }103 },104 105 addAlarm: function( eventDay ){106 if(!DataLayer.tasks[parseInt(eventDay.sendTime)]){107 DataLayer.task( parseInt(eventDay.sendTime) , function( timestamp ){108 var path = User.moduleName == 'expressoCalendar' ? '' : '../prototype/modules/calendar/';109 DataLayer.render(path+'templates/alarm.ejs',{110 event: eventDay111 }, function( html ){112 $.Zebra_Dialog(html , {113 'type': 'question',114 'overlay_opacity': '0.5',115 'buttons': ['Fechar'],116 'onClose': function(clicked) {}117 });118 });119 });120 }121 }122 }123 124 101 Calendar.load(); 125 Alarms.load(); -
trunk/prototype/modules/calendar/js/map.disponibility.js
r6444 r6996 8 8 9 9 10 function updateMap( data){11 var start_date = $(".new- event-win.active .start-date").val();12 var end_date = $(".new- event-win.active .end-date").val();13 var start_time = $(".new- event-win.active .start-time").val();14 var end_time = $(".new- event-win.active .end-time").val();15 var isAllDay = $('.new- event-win.active input[name="allDay"]').is(':checked');10 function updateMap(viewName){ 11 var start_date = $(".new-"+viewName+"-win.active .start-date").val(); 12 var end_date = $(".new-"+viewName+"-win.active .end-date").val(); 13 var start_time = $(".new-"+viewName+"-win.active .start-time").val(); 14 var end_time = $(".new-"+viewName+"-win.active .end-time").val(); 15 var isAllDay = $('.new-'+viewName+'-win.active input[name="allDay"]').is(':checked'); 16 16 17 17 var formatString = User.preferences.dateFormat + " " + User.preferences.hourFormat; … … 21 21 22 22 23 var event = $( "#new_event_map").fullCalendar('clientEvents', 'map')[0];23 var event = $('.new-'+viewName+'-win .map_disponibility').fullCalendar('clientEvents', 'map')[0]; 24 24 25 25 … … 28 28 event.end = endDate; 29 29 event.allDay = isAllDay; 30 $( "#new_event_map").fullCalendar( 'updateEvent', event )30 $('.new-'+viewName+'-win .map_disponibility').fullCalendar( 'updateEvent', event ) 31 31 } 32 32 … … 35 35 36 36 37 function disponibily(objEvent, path, attendees ){37 function disponibily(objEvent, path, attendees, viewName){ 38 38 var formatString = User.preferences.dateFormat + " " + User.preferences.hourFormat; 39 39 var startDate = Date.parseExact( objEvent.startDate + " " + $.trim(objEvent.startHour) , formatString ); 40 40 var endDate = Date.parseExact( objEvent.endDate + " " + $.trim(objEvent.endHour) , formatString ); 41 42 var dialogName = {event: 'addEvent', task: 'addTask', activity: 'addActivity'} 41 43 42 44 var mapHtml = DataLayer.render( path+'templates/availability_map.ejs', {}); 43 $( "#calendar_addevent_details7").html(mapHtml);44 $( "#new_event_map").fullCalendar(DataLayer.merge({45 $('#calendar_add'+viewName+'_details7').html(mapHtml); 46 $('.new-'+viewName+'-win .map_disponibility').fullCalendar(DataLayer.merge({ 45 47 height : 300, 46 48 timeFormat: User.preferences.hourFormat, … … 77 79 if(!allDay){ 78 80 $('[name="allDay"]').attr("checked", false); 79 UI.dialogs .addEvent.find('.start-time, .end-time').removeClass('hidden');81 UI.dialogs[dialogName[viewName]].find('.start-time, .end-time').removeClass('hidden'); 80 82 81 83 $('[name="startHour"]').val(start.toString(User.preferences.hourFormat)); … … 85 87 }else{ 86 88 $('[name="allDay"]').attr("checked", true); 87 UI.dialogs .addEvent.find('.start-time, .end-time').addClass('hidden');89 UI.dialogs[dialogName[viewName]].find('.start-time, .end-time').addClass('hidden'); 88 90 } 89 91 }, … … 98 100 className : "map-event", 99 101 backgroundColor : "transparent !important", 100 editable : objEvent.acl .write || objEvent.acl.organization102 editable : objEvent.acl ? (objEvent.acl.write || objEvent.acl.organization) : true 101 103 } 102 104 ], … … 104 106 if(event.allDay){ 105 107 $('[name="allDay"]').attr("checked", true); 106 UI.dialogs .addEvent.find('.start-time, .end-time').addClass('hidden');108 UI.dialogs[dialogName[viewName]].find('.start-time, .end-time').addClass('hidden'); 107 109 108 110 $('[name="startDate"]').val(dateCalendar.toString(event.start, User.preferences.dateFormat)); … … 111 113 }else{ 112 114 $('[name="allDay"]').attr("checked", false); 113 UI.dialogs .addEvent.find('.start-time, .end-time').removeClass('hidden');115 UI.dialogs[dialogName[viewName]].find('.start-time, .end-time').removeClass('hidden'); 114 116 115 117 $('[name="startHour"]').val(dateCalendar.formatDate(event.start, User.preferences.hourFormat)); … … 132 134 var eventSource = new Array(); 133 135 var updateMapView = function(){ 134 updateMap( );135 var view = $( "#new_event_map").fullCalendar('getView');136 updateMap(viewName); 137 var view = $('.new-'+viewName+'-win .map_disponibility').fullCalendar('getView'); 136 138 var map = {}; 137 $( "#new_event_map").fullCalendar( 'removeEventSource', eventSource );139 $('.new-'+viewName+'-win .map_disponibility').fullCalendar( 'removeEventSource', eventSource ); 138 140 eventSource = new Array(); 139 141 map = {startTime : view.start.getTime(), endTime : view.end.getTime(), attendees: {}, timezone: (objEvent.timezone || User.preferences.timezone)}; … … 167 169 } 168 170 if(eventSource.length) 169 $( "#new_event_map").fullCalendar( 'addEventSource', eventSource );171 $('.new-'+viewName+'-win .map_disponibility').fullCalendar( 'addEventSource', eventSource ); 170 172 }; 171 $('[href="#calendar_addevent_details7"]').click(function(eventData, eventObject){ 172 $("#new_event_map").fullCalendar( 'gotoDate', Date.parseExact($('[name="startDate"]').val() + " " + $.trim($('[name="startHour"]').val()), formatString) , formatString); 173 //if(eventObject == undefined) 174 updateMapView(); 173 $('[href="#calendar_add'+viewName+'_details7"]').click(function(eventData, eventObject){ 174 $('.new-'+viewName+'-win .map_disponibility').fullCalendar( 'gotoDate', Date.parseExact($('[name="startDate"]').val() + " " + $.trim($('[name="startHour"]').val()), formatString) , formatString); 175 updateMapView(); 175 176 }); 176 $( "#new_event_map").find(".fc-button-prev, .fc-button-next, .fc-button-today").click(function(){177 $('.new-'+viewName+'-win .map_disponibility').find(".fc-button-prev, .fc-button-next, .fc-button-today").click(function(){ 177 178 updateMapView(); 178 179 });
Note: See TracChangeset
for help on using the changeset viewer.