Changeset 6815 for sandbox/2.4.2-expresso1/prototype/modules/calendar/js
- Timestamp:
- 07/19/12 11:18:12 (12 years ago)
- Location:
- sandbox/2.4.2-expresso1/prototype/modules/calendar/js
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/2.4.2-expresso1/prototype/modules/calendar/js/helpers.js
r6812 r6815 1691 1691 1692 1692 1693 function add_tab_configure_calendar(calendar )1693 function add_tab_configure_calendar(calendar, type) 1694 1694 { 1695 1695 var calendars = []; … … 1699 1699 1700 1700 for (var i=0; i<Calendar.signatures.length; i++) { 1701 if( !!!parseInt(Calendar.signatures[i].calendar.type)){1701 if(parseInt(Calendar.signatures[i].calendar.type) == type){ 1702 1702 calendars.push(Calendar.signatures[i].calendar); 1703 1703 signatures.push(Calendar.signatures[i]); … … 1708 1708 } 1709 1709 } 1710 1711 if(!(document.getElementById( 'configure_tab')))1710 var tab_selector = ['configure_tab', 'configure_tab_group']; 1711 if(!(document.getElementById(tab_selector[type]))) 1712 1712 { 1713 1713 $('.positionHelper').css('display', 'none'); 1714 1714 $('.cal-list-options-btn').removeClass('fg-menu-open ui-state-active'); 1715 var tab_title = "Configurações de agendas"; 1716 $tabs.tabs( "add", "#configure_tab", tab_title ); 1715 if(type == 0){ 1716 var tab_title = "Configurações de agendas"; 1717 }else{ 1718 var tab_title = "Configurações de Grupos"; 1719 } 1720 $tabs.tabs( "add", "#"+tab_selector[type], tab_title ); 1717 1721 1718 1722 var dataColorPicker = { … … 1741 1745 signature:signatures[nowActive] 1742 1746 }, function( form_template ){ 1743 var form_content = jQuery('# configure_tab.accordion-user-calendars .ui-accordion-content').eq(nowActive).html( form_template ).find('form');1747 var form_content = jQuery('#'+tab_selector[type]+' .accordion-user-calendars .ui-accordion-content').eq(nowActive).html( form_template ).find('form'); 1744 1748 form_content.find('.preferences-alarms-list .button').button({ 1745 1749 text:false, … … 1870 1874 signatures:signatures 1871 1875 }, function( template ){ 1872 var template_content = jQuery('# configure_tab').html( template ).find('.configure-calendars-win');1876 var template_content = jQuery('#'+tab_selector[type]).html( template ).find('.configure-calendars-win'); 1873 1877 template_content.find('.button').button().filter('.save').click(function(evt){ 1874 1878 if(calendarAlarms.length) 1875 1879 DataLayer.removeFilter('calendarSignatureAlarm', {filter: ['IN','id', calendarAlarms]}); 1876 1880 template_content.find('form').submit(); 1877 $tabs.tabs( "remove", "# configure_tab");1881 $tabs.tabs( "remove", "#"+tab_selector[type]); 1878 1882 DataLayer.commit( false, false, function( received ){ 1879 1883 delete Calendar.currentViewKey; … … 1884 1888 Calendar.load(); 1885 1889 }).end().filter('.cancel').click(function(evt){ 1886 $tabs.tabs( "remove", "# configure_tab");1890 $tabs.tabs( "remove", "#"+tab_selector[type]); 1887 1891 }); 1888 1892 … … 1910 1914 $('.positionHelper').css('display','none'); 1911 1915 $('.cal-list-options-btn').removeClass('fg-menu-open ui-state-active'); 1912 $tabs.tabs("select", "# configure_tab");1916 $tabs.tabs("select", "#"+tab_selector[type]); 1913 1917 $('.accordion-user-calendars').accordion( "activate" , previewActiveCalendarConf ); 1914 1918 … … 2034 2038 2035 2039 2036 function remove_calendar( ){2040 function remove_calendar(type){ 2037 2041 /* Pode ser assim $('.cal-list-options-btn.ui-state-active').attr('class').replace(/[a-zA-Z-]+/g, ''); */ 2038 $.Zebra_Dialog('Todos os eventos desta agenda serão removidos. Deseja prosseguir com a operação?', { 2042 if(!!parseInt(type)) 2043 var title = 'Todas as tarefas deste grupo serão removidas. Deseja prosseguir com a operação?'; 2044 else 2045 var title = 'Todos os eventos desta agenda serão removidos. Deseja prosseguir com a operação?'; 2046 $.Zebra_Dialog(title, { 2039 2047 'type': 'question', 2040 2048 'overlay_opacity': '0.5', -
sandbox/2.4.2-expresso1/prototype/modules/calendar/js/init.js
r6812 r6815 4 4 5 5 refresh_calendars(); 6 refresh_groups();7 6 $tabs = $('#tabs').tabs({ 8 7 add: function( event, ui ) { -
sandbox/2.4.2-expresso1/prototype/modules/calendar/js/task.helpers.js
r6812 r6815 588 588 UI.dialogs.addTask.dialog('open'); 589 589 } 590 591 function add_tab_configure_groups(calendar)592 {593 var calendars = [];594 var signatures = [];595 var previewActiveCalendarConf = 0;596 var calendarAlarms = [];597 598 for (var i=0; i<Calendar.signatures.length; i++) {599 if(!!parseInt(Calendar.signatures[i].calendar.type)){600 calendars.push(Calendar.signatures[i].calendar);601 signatures.push(Calendar.signatures[i]);602 length = signatures.length - 1;603 signatures[length].numberDefaultAlarm = signatures[length].defaultAlarms != '' ? signatures[length].defaultAlarms.length: 0;604 if (calendar && calendars[length].id == calendar)605 previewActiveCalendarConf = length;606 }607 }608 609 if(!(document.getElementById('configure_tab_group')))610 {611 $('.positionHelper').css('display', 'none');612 $('.cal-list-options-btn').removeClass('fg-menu-open ui-state-active');613 var tab_title = "Configurações de Grupos";614 $tabs.tabs( "add", "#configure_tab_group", tab_title );615 616 var dataColorPicker = {617 colorsSuggestions: colors_suggestions()618 };619 620 621 622 var populateAccordionOnActive = function(event, ui) {623 var nowActive = (typeof(event) == 'number') ? event : $(event.target).accordion( "option", "active" );624 if (nowActive === false)625 return;626 dataColorPicker.colorsDefined = {627 border: '#'+signatures[nowActive].borderColor,628 font:'#'+signatures[nowActive].fontColor,629 background:'#'+signatures[nowActive].backgroundColor630 };631 if (!jQuery('.accordion-user-calendars .ui-accordion-content').eq(nowActive).has('form')) {632 return true;633 }634 635 DataLayer.render( 'templates/configure_calendars_itemlist.ejs', {636 user:User,637 type: 1,638 calendar:calendars[nowActive],639 signature:signatures[nowActive]640 }, function( form_template ){641 var form_content = jQuery('#configure_tab_group .accordion-user-calendars .ui-accordion-content').eq(nowActive).html( form_template ).find('form');642 form_content.find('.preferences-alarms-list .button').button({643 text:false,644 icons:{645 primary:'ui-icon-close'646 }647 });648 form_content.find('.button').button();649 jQuery('.preferences-alarms-list').find('.button.remove').click(function(el){650 calendarAlarms[calendarAlarms.length] = $(this).parent('li').find('input[name="alarmId[]"]').val();651 $(this).parent().remove();652 });653 654 DataLayer.render( 'templates/timezone_list.ejs', {}, function( timezones_options ){655 var valueTimeZone = calendars[nowActive].timezone;656 form_content.find('select[name="timezone"]').html(timezones_options).find('option[value="'+valueTimeZone+'"]').attr('selected','selected').trigger('change');657 });658 659 form_content.find('.button-add-alarms').click(function(){660 DataLayer.render( 'templates/alarms_add_itemlist.ejs', {type: 1}, function( template ){661 jQuery('.preferences-alarms-list').append(template)662 .find('li:last label:eq(0)').remove().end()663 .find('.number').numeric().end()664 .find('.button.remove').button({665 text:false,666 icons:{667 primary:'ui-icon-close'668 }669 }).click(function(el) {670 $(this).parent().remove();671 });672 });673 });674 675 676 /**677 * Set color picker678 */679 DataLayer.render( 'templates/calendar_colorpicker.ejs', dataColorPicker, function( template ){680 form_content.find('.calendar-colorpicker').html( template );681 682 var f = $.farbtastic(form_content.find('.colorpicker'), colorpickerPreviewChange);683 var selected;684 var colorpicker = form_content.find('.calendar-colorpicker');685 686 var colorpickerPreviewChange = function(color) {687 var pickedup = form_content.find('.colorwell-selected').val(color).css('background-color', color);688 689 var colorpicker = form_content.find('.calendar-colorpicker');690 691 if (pickedup.is('input[name="backgroundColor"]')) {692 colorpicker.find('.fc-event-skin').css('background-color',color);693 } else if (pickedup.is('input[name="fontColor"]')) {694 colorpicker.find('.fc-event-skin').css('color',color);695 } else if (pickedup.is('input[name="borderColor"]')) {696 colorpicker.find('.fc-event-skin').css('border-color',color);697 }698 }699 700 form_content.find('.colorwell').each(function () {701 f.linkTo(this);702 703 if ($(this).is('input[name="backgroundColor"]')) {704 colorpicker.find('.fc-event-skin').css('background-color', $(this).val());705 } else if ($(this).is('input[name="fontColor"]')) {706 colorpicker.find('.fc-event-skin').css('color', $(this).val());707 } else if ($(this).is('input[name="borderColor"]')) {708 colorpicker.find('.fc-event-skin').css('border-color', $(this).val());709 }710 })711 .focus(function() {712 if (selected) {713 $(selected).removeClass('colorwell-selected');714 }715 716 $(selected = this).addClass('colorwell-selected');717 f.linkTo(this, colorpickerPreviewChange);718 f.linkTo(colorpickerPreviewChange);719 720 });721 722 form_content.find('select.color-suggestions').change(function() {723 var colors;724 725 if(colors = dataColorPicker.colorsSuggestions[$(this).val()]) {726 colorpicker727 .find('input[name="fontColor"]').val(colors.font).focus().end()728 .find('input[name="backgroundColor"]').val(colors.background).focus().end()729 .find('input[name="borderColor"]').val(colors.border).focus().end()730 731 .find('.fc-event-skin').css({732 'background-color':dataColorPicker.colorsSuggestions[$(this).val()].background,733 'border-color':dataColorPicker.colorsSuggestions[$(this).val()].border,734 'color':dataColorPicker.colorsSuggestions[$(this).val()].font735 });736 }737 });738 739 /**740 * Trata a mudança dos valores dos campos de cores.741 * Se mudar um conjunto de cores sugerido,742 * este vira um conjunto de cores personalizado.743 */744 form_content.find('.colorwell').change(function (element, ui) {745 if (true) {746 form_content.find('select.color-suggestions')747 .find('option:selected').removeAttr('selected').end()748 .find('option[value="custom"]').attr('selected', 'selected').trigger('change');749 }750 });751 }); //END set colorpicker752 753 form_content.find('.phone').mask("+99 (99) 9999-9999");754 form_content.find('.number').numeric();755 756 }); //END DataLayer.render( 'templates/configure_calendars_itemlist.ejs' ...757 758 // === validations preferences ====759 760 761 } //END populateAccordionOnActive(event, ui)762 763 DataLayer.render( 'templates/configure_calendars.ejs', {764 user:User,765 type: 1,766 calendars:calendars,767 signatures:signatures768 }, function( template ){769 var template_content = jQuery('#configure_tab_group').html( template ).find('.configure-calendars-win');770 template_content.find('.button').button().filter('.save').click(function(evt){771 if(calendarAlarms.length)772 DataLayer.removeFilter('calendarSignatureAlarm', {filter: ['IN','id', calendarAlarms]});773 template_content.find('form').submit();774 $tabs.tabs( "remove", "#configure_tab_group");775 DataLayer.commit( false, false, function( received ){776 delete Calendar.currentViewKey;777 Calendar.load();778 refresh_calendars();779 });780 if(calendarAlarms.length)781 Calendar.load();782 }).end().filter('.cancel').click(function(evt){783 $tabs.tabs( "remove", "#configure_tab_group");784 });785 786 /**787 * Muda a estrutura do template para a aplicação do plugin accordion788 */789 template_content.find('.header-menu-container').after('<div class="accordion-user-calendars"></div>').end().find('.accordion-user-calendars')790 .append(template_content.children('fieldset'));791 792 template_content.find('.accordion-user-calendars').children('fieldset').each(function(index) {793 $(this).before($('<h3></h3>').html($(this).children('legend')));794 });795 796 template_content.find('.accordion-user-calendars').accordion({797 autoHeight: false,798 collapsible: true,799 clearStyle: true,800 active: previewActiveCalendarConf,801 changestart: populateAccordionOnActive802 });803 populateAccordionOnActive(previewActiveCalendarConf);804 });805 806 } else {807 $('.positionHelper').css('display','none');808 $('.cal-list-options-btn').removeClass('fg-menu-open ui-state-active');809 $tabs.tabs("select", "#configure_tab_group");810 $('.accordion-user-calendars').accordion( "activate" , previewActiveCalendarConf );811 812 return true;813 }814 815 }816 817 818 819 820 function refresh_groups(){821 822 var colorsSuggestions = colors_suggestions();823 var buttons_colors = "";824 for(var i = 0; i < colorsSuggestions.length; i++){825 buttons_colors += "<a class=\"cal-colors-options-btn ui-icon ui-button-icon-primary signed-cal-colors-options-btn-"+i+"\" style=\"background-color:"+colorsSuggestions[i]['background']+"; border-color:"+colorsSuggestions[i]['border']+"; color:"+colorsSuggestions[i]['font']+"\">•</a>";826 }827 828 //DataLayer.render( 'templates/calendar_list.ejs', 'calendar:list', ["IN", "id", Calendar.calendarIds], function( html ){829 DataLayer.render( 'templates/calendar_list.ejs', Calendar, function( html ){830 831 var meu_container = $(".calendars-list").html( html );832 833 var doMenu = function(){834 $('ul.list-calendars .cal-list-options-btn').each(function(){835 $(this).menu({836 content: $(this).next().html(),837 width: '120',838 positionOpts: {839 posX: 'left',840 posY: 'bottom',841 offsetX: 0,842 offsetY: 0,843 directionH: 'right',844 directionV: 'down',845 detectH: true, // do horizontal collision detection846 detectV: true, // do vertical collision detection847 linkToFront: false848 },849 flyOut: true,850 showSpeed: 100,851 crumbDefaultText: '>'852 });853 });854 }855 856 doMenu();857 858 $('#divAppbox').on('scroll',function(){859 if ($('.cal-list-options-btn.fg-menu-open.ui-state-active')){860 var offset = $('.cal-list-options-btn.fg-menu-open.ui-state-active').offset();861 if (offset)862 $('.positionHelper').css('top',offset.top);863 }864 });865 866 $('ul.list-calendars .cal-list-options-btn').on('click',function(){doMenu();});867 868 meu_container.find(".button.new-calendar").button({869 icons: {870 primary: "ui-icon-plus"871 },872 text: false873 }).click(function () {874 875 if( $('.qtip.qtip-blue.qtip-active').val() !== ''){876 $(this).qtip({877 show: {878 ready: true,879 solo: true,880 when: {881 event: 'click'882 }883 },884 hide: false,885 content: {886 text: $('<div></div>').html( DataLayer.render( 'templates/calendar_quick_add.ejs', {} ) ),887 title: {888 text:'Novo Grupo',889 button: '<a class="button close" href="#">close</a>'890 }891 },892 style: {893 name: 'blue',894 tip: {895 corner: 'leftMiddle'896 },897 border: {898 width: 4,899 radius: 8900 },901 width: {902 min: 230,903 max:230904 }905 },906 position: {907 corner: {908 target: 'rightMiddle',909 tooltip: 'leftMiddle'910 },911 adjust: {912 x:0,913 y:-12914 }915 }916 })917 .qtip("api").onShow = function(arg0) {918 $('.qtip-active .button.close').button({919 icons: {920 primary: "ui-icon-close"921 },922 text: false923 })924 .click(function(){925 meu_container.find(".button.new-calendar").qtip('destroy');926 });927 //TODO emplementar tratamento de duplicação de valores no location928 $('.qtip-active .button.save').button().click(function(){929 for(var i = 0; i < Calendar.calendars.length; i++){930 if(Calendar.calendars[i].location == ( User.me.uid + '/' + $('.qtip-active input').val())){931 $.Zebra_Dialog('O nome desta agenda já está sendo utilizada em uma Url de outra agenda. Por favor, informe outro nome para agenda.',{932 'overlay_opacity': '0.5',933 'type': 'warning'934 });935 meu_container.find(".button.new").qtip('destroy');936 return;937 }938 }939 940 var selected;941 var color = $('.cal-colors-options-btn').each(function(index){942 if ($(this).is('.color-selected'))943 selected = index;944 });945 DataLayer.put( "calendarSignature", {946 user: User.me.id,947 calendar: {948 name: Encoder.htmlEncode($('.qtip-active input').val()),949 timezone: User.preferences.timezone,950 type: 1951 },952 isOwner: 1,953 fontColor: colorsSuggestions[selected]['font'].substring(1) ,954 backgroundColor: colorsSuggestions[selected]['background'].substring(1) ,955 borderColor: colorsSuggestions[selected]['border'].substring(1)956 });957 DataLayer.commit( false, false, function( received ){958 delete Calendar.currentViewKey;959 Calendar.load();960 refresh_groups();961 });962 meu_container.find(".button.new").qtip('destroy');963 });964 965 $('.qtip-active .button.cancel').button().click(function(){966 meu_container.find(".button.new").qtip('destroy');967 });968 969 $(".qtip-active input").Watermark("Nome da agenda");970 971 $('.qtip-active').keydown(function(event) {972 if (event.keyCode == '27')973 meu_container.find(".button.new").qtip('destroy');974 });975 976 $('.colors-options').prepend(buttons_colors);977 $('.colors-options .signed-cal-colors-options-btn-0').addClass('color-selected');978 979 var buttons = $('.cal-colors-options-btn').button();980 981 buttons.click(function(){982 buttons.removeClass('color-selected');983 $(this).addClass('color-selected');984 });985 }986 }987 });988 989 $("img.cal-list-img").click(function(evt) {990 $(".cal-list-options_1").toggleClass( "hidden" );991 });992 993 $(".my-calendars a.title-my-calendars").click(function() {994 $(".my-calendars ul.my-list-calendars").toggleClass("hidden")995 $('.my-calendars .status-list').toggleClass("ui-icon-triangle-1-s");996 $('.my-calendars .status-list').toggleClass("ui-icon-triangle-1-e");997 });998 999 $(".signed-calendars a.title-signed-calendars").click(function() {1000 $(".signed-calendars ul.signed-list-calendars").toggleClass( "hidden");1001 });1002 1003 $("ul li.list-calendars-item").click(function(evt) {1004 1005 });1006 1007 $("ul li.list-calendars-item .ui-corner-all").click(function(evt) {1008 //alert('teste');1009 });1010 1011 meu_container.find(".button.new-calendar-shared").button({1012 icons: {1013 primary: "ui-icon-plus"1014 },1015 text: false1016 }).click(function (event) {1017 show_modal_search_shared();1018 });1019 1020 1021 //TODO Implementar ocultar agendas.1022 meu_container.find('.title-signed-calendars').click(function(evt){1023 var status = $(this).parent().find('.status-list-shared');1024 1025 if(status.hasClass('ui-icon-triangle-1-s'))1026 status.removeClass('ui-icon-triangle-1-s').addClass('ui-icon-triangle-1-e');1027 else1028 status.removeClass('ui-icon-triangle-1-e').addClass('ui-icon-triangle-1-s');1029 });1030 1031 $('.calendar-view').click(function(evt){1032 if($tabs.tabs('option' ,'selected') == 1){1033 pageselectCallback('', 0);1034 }1035 1036 if(Calendar.currentView){1037 var checkBox = $(this);1038 if(!!Calendar.currentView[ checkBox.val() ]){1039 Calendar.currentView[ checkBox.val() ].hidden = !checkBox.is(':checked');1040 $('#calendar').fullCalendar( 'refetchEvents' );1041 }1042 }1043 });1044 });1045 }
Note: See TracChangeset
for help on using the changeset viewer.