$(document).ready(function() { refresh_calendars(); $tabs = $('#tabs').tabs({ add: function( event, ui ) { User.lastView = $tabs.tabs('option' ,'selected'); $tabs.tabs('select', '#' + ui.panel.id); }, remove: function( event, ui ) { $tabs.tabs('select', User.lastView); }, show: function( event, ui ){ delete Calendar.currentViewKey; $('#calendar').fullCalendar('refetchEvents'); } }) .tabs('option', 'tabTemplate', "
  • #{label}Remove Tab
  • " ); /** * Make a button to close the tab */ $tabs.find( "span.ui-icon-close" ).live( "click", function() { var index = $( "li", $tabs ).index( $( this ).parent() ); if($tabs.tabs('option' ,'selected') == index){ if($tabs.tabs("length") == 2 && User.lastView != 1) $tabs.tabs( "select", 0); $tabs.tabs( "select", User.lastView); } if($tabs.tabs('option' ,'selected') == 0 || $tabs.tabs('option' ,'selected') == 1) User.lastView = $tabs.tabs('option' ,'selected'); if(index != -1) $tabs.tabs( "remove", index ); }); $('.button.config-menu').button({ icons: { primary: "ui-icon-gear", secondary: "ui-icon-triangle-1-s" }, text: false }); $('.button.add').button({ icons: { secondary: "ui-icon-plus" } }) var miniCalendar = $('.block-vertical-toolbox .mini-calendar').datepicker({ dateFormat: 'yy-m-d', //dateFormat: 'DD, d MM, yy', //inline: true, firstDay: dayOfWeek(User.preferences.weekStart), onSelect: function(dateText, inst) { $tabs.tabs("select", "#calendar"); var date = dateText.split('-'); var dateFullCalendar = $.fullCalendar.formatDate($('#calendar').fullCalendar('getDate'), "yyyy-MM-dd").split('-'); $('#calendar').fullCalendar('gotoDate',date[0],date[1]-1,date[2]); $('#calendar').fullCalendar( 'changeView', 'agendaDay' ); } }) .find('.ui-icon-circle-triangle-e').removeClass('ui-icon-circle-triangle-e').addClass('ui-icon-triangle-1-e').end() .find('.ui-icon-circle-triangle-w').removeClass('ui-icon-circle-triangle-w').addClass('ui-icon-triangle-1-w'); //Onclick do mês $('.ui-datepicker-title .ui-datepicker-month').live('click',function(){ $tabs.tabs("select", "#calendar"); var currentDate = $.fullCalendar.formatDate($('#calendar').fullCalendar('getDate'), "yyyy-MM-dd").split('-'); $('#calendar').fullCalendar('gotoDate',$('.ui-datepicker-title .ui-datepicker-year').html(), Date.getMonthNumberFromName($('.ui-datepicker-title .ui-datepicker-month').html()),currentDate[2]); $('#calendar').fullCalendar( 'changeView', 'month'); }); //Onclick do ano $('.ui-datepicker-title .ui-datepicker-year').live('click',function(){ $tabs.tabs("select", "#calendar"); var currentDate = $.fullCalendar.formatDate($('#calendar').fullCalendar('getDate'), "yyyy-MM-dd").split('-'); $('#calendar').fullCalendar('gotoDate',$('.ui-datepicker-title .ui-datepicker-year').html(), Date.getMonthNumberFromName($('.ui-datepicker-title .ui-datepicker-month').html()), currentDate[2]); $('.fc-button-year').click(); }); //Onclick em um dia do calendário anual $( ".fc-day-number" ).live( "click", function() { var date = $(this).parents('[class*="fc-day-"]').attr('class').match(/fc-day-(\d{4})-(\d{2})-(\d{2})/); if (date) date.shift(); else return false; $('#calendar').fullCalendar('gotoDate',date[0],date[1]-1,date[2]); $('#calendar').fullCalendar( 'changeView', 'agendaDay' ); }); $('.main-search input.search').keydown(function(event){ if(event.keyCode == 13) { Encoder.EncodeType = "entity"; //$(this).val($(this).val()); add_events_list($(this).val()); $(this).val(''); } }); $('.block-horizontal-toolbox .main-config-menu').menu({ content: $('.main-config-menu-content').html(), positionOpts: { posX: 'left', posY: 'bottom', offsetX: -140, offsetY: 0, directionH: 'right', directionV: 'down', detectH: true, // do horizontal collision detection detectV: true, // do vertical collision detection linkToFront: false }, flyOut: true, showSpeed: 100, crumbDefaultText: '>' }); $('#trash').droppable({ drop: function(event, ui){ // calendar.fullCalendar( 'removeEvents', ui.draggable.attr('event-id') ); DataLayer.remove( "event", ui.draggable.attr('event-id') ); $(this).switchClass('empty','full'); }, tolerance: "touch" }); /* initialize the calendar -----------------------------------------------------------------*/ $(".button.add.add-event").click(function(event){ eventDetails({ startTime: $.now(), endTime:!!User.preferences.defaultCalendar ? Calendar.signatureOf[User.preferences.defaultCalendar].calendar.defaultDuration != "" ? ($.now() + Calendar.signatureOf[User.preferences.defaultCalendar].calendar.defaultDuration * 60000) : (User.preferences.defaultDuration * 60000) : $.now() + (User.preferences.defaultDuration * 60000) }, true ); }); var calendar = $('#calendar').fullCalendar({ defaultView: User.preferences.defaultCalView, timeFormat: User.preferences.hourFormat, axisFormat: User.preferences.hourFormat, eventSources: Calendar.sources, header: { left: 'prev,next today,basicWeek,basicDay', center: 'title', right: 'agendaDay,agendaWeek,month,year' }, firstDay: dayOfWeek(!!User.preferences.weekStart ? User.preferences.weekStart : User.defaultPreferences.weekStart ), editable: true, selectable: true, selectHelper: true, droppable: true, // this allows things to be dropped onto the calendar !!! timeFormat: { agenda: 'HH:mm{ - HH:mm}', '': 'HH:mm{ - HH:mm} }' }, titleFormat: { month: 'MMMM yyyy', week: "dd[ yyyy] { 'a'[ MMM] dd 'de' MMMM '-' yyyy}", day: 'dddd, dd MMM , yyyy' }, columnFormat:{ month: 'ddd', week: 'ddd dd/MM', day: 'dddd dd/MM' }, monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro' ], monthNamesShort: ['Jan','Fev','Mar','Abr','Maio','Jun','Jul','Ago','Set','Out','Nov','Dez'], dayNames: [ 'Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sábado'], dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb'], dayNamesShortest: ['D','S','T','Q','Q','S','S'], allDayText: 'Dia todo', buttonText: { today: 'hoje', month: 'mês', week: 'semana', day: 'dia', year: 'ano' }, eventRender: function( event, element, view ){ $(element).attr( 'event-id', event.id ); }, select: function( start, end, allDay, event, view ){ eventDetails( { 'start': start, 'end': end, 'allDay': allDay } ); }, eventDrop: function( event ){ DataLayer.put( "schedulable:calendar", event ); }, eventResize: function( event ){ DataLayer.put( "schedulable:calendar", event ); }, eventClick: function( evt, event, view ){ eventDetails( DataLayer.get( "schedulable", evt.id), true); } }); if($(window).height() < $('body').height()){ var hei = $('body').height() - $(window).height(); hei = $('#divAppbox').height() - hei; $('#divAppbox').css('max-height', hei); $('#divAppbox').css('min-height', hei); $('body').css('overflow-y','hidden'); delete hei; } $(window).resize(function(){ $('#divAppbox').css('max-height', $(window).height() - 104); $('#divAppbox').css('min-height', $(window).height() - 104); $('#divAppbox').css('overflow-x', 'auto'); $('#divAppbox').css('overflow-y', 'scroll'); }); //Todo chamada do metodo que adiciona ao full calendar o botao de listagem de eventos //listEvents(); });