1 | $(document).ready(function() { |
---|
2 | |
---|
3 | refresh_calendars(); |
---|
4 | $tabs = $('#tabs').tabs({ |
---|
5 | add: function( event, ui ) { |
---|
6 | User.lastView = $tabs.tabs('option' ,'selected'); |
---|
7 | $tabs.tabs('select', '#' + ui.panel.id); |
---|
8 | }, |
---|
9 | remove: function( event, ui ) { |
---|
10 | $tabs.tabs('select', User.lastView); |
---|
11 | }, |
---|
12 | show: function( event, ui ){ |
---|
13 | delete Calendar.currentViewKey; |
---|
14 | $('#calendar').fullCalendar('refetchEvents'); |
---|
15 | } |
---|
16 | }) |
---|
17 | .tabs('option', 'tabTemplate', "<li><a href='#{href}'>#{label}</a><span class='ui-icon ui-icon-close'>Remove Tab</span></li>" ); |
---|
18 | |
---|
19 | /** |
---|
20 | * Make a button to close the tab |
---|
21 | */ |
---|
22 | $tabs.find( "span.ui-icon-close" ).live( "click", function() { |
---|
23 | var index = $( "li", $tabs ).index( $( this ).parent() ); |
---|
24 | if($tabs.tabs('option' ,'selected') == index){ |
---|
25 | if($tabs.tabs("length") == 2 && User.lastView != 1) |
---|
26 | $tabs.tabs( "select", 0); |
---|
27 | $tabs.tabs( "select", User.lastView); |
---|
28 | } |
---|
29 | if($tabs.tabs('option' ,'selected') == 0 || $tabs.tabs('option' ,'selected') == 1) |
---|
30 | User.lastView = $tabs.tabs('option' ,'selected'); |
---|
31 | if(index != -1) |
---|
32 | $tabs.tabs( "remove", index ); |
---|
33 | |
---|
34 | |
---|
35 | }); |
---|
36 | $('.button.config-menu').button({ |
---|
37 | icons: { |
---|
38 | primary: "ui-icon-gear", |
---|
39 | secondary: "ui-icon-triangle-1-s" |
---|
40 | }, |
---|
41 | text: false |
---|
42 | }); |
---|
43 | $('.button.add').button({ |
---|
44 | icons: { |
---|
45 | secondary: "ui-icon-plus" |
---|
46 | } |
---|
47 | }) |
---|
48 | |
---|
49 | var miniCalendar = $('.block-vertical-toolbox .mini-calendar').datepicker({ |
---|
50 | dateFormat: 'yy-m-d', |
---|
51 | //dateFormat: 'DD, d MM, yy', |
---|
52 | //inline: true, |
---|
53 | firstDay: dayOfWeek(User.preferences.weekStart), |
---|
54 | onSelect: function(dateText, inst) |
---|
55 | { |
---|
56 | $tabs.tabs("select", "#calendar"); |
---|
57 | var date = dateText.split('-'); |
---|
58 | var dateFullCalendar = $.fullCalendar.formatDate($('#calendar').fullCalendar('getDate'), "yyyy-MM-dd").split('-'); |
---|
59 | $('#calendar').fullCalendar('gotoDate',date[0],date[1]-1,date[2]); |
---|
60 | $('#calendar').fullCalendar( 'changeView', 'agendaDay' ); |
---|
61 | } |
---|
62 | }) |
---|
63 | .find('.ui-icon-circle-triangle-e').removeClass('ui-icon-circle-triangle-e').addClass('ui-icon-triangle-1-e').end() |
---|
64 | .find('.ui-icon-circle-triangle-w').removeClass('ui-icon-circle-triangle-w').addClass('ui-icon-triangle-1-w'); |
---|
65 | |
---|
66 | //Onclick do mês |
---|
67 | $('.ui-datepicker-title .ui-datepicker-month').live('click',function(){ |
---|
68 | $tabs.tabs("select", "#calendar"); |
---|
69 | var currentDate = $.fullCalendar.formatDate($('#calendar').fullCalendar('getDate'), "yyyy-MM-dd").split('-'); |
---|
70 | $('#calendar').fullCalendar('gotoDate',$('.ui-datepicker-title .ui-datepicker-year').html(), Date.getMonthNumberFromName($('.ui-datepicker-title .ui-datepicker-month').html()),currentDate[2]); |
---|
71 | $('#calendar').fullCalendar( 'changeView', 'month'); |
---|
72 | }); |
---|
73 | //Onclick do ano |
---|
74 | $('.ui-datepicker-title .ui-datepicker-year').live('click',function(){ |
---|
75 | $tabs.tabs("select", "#calendar"); |
---|
76 | var currentDate = $.fullCalendar.formatDate($('#calendar').fullCalendar('getDate'), "yyyy-MM-dd").split('-'); |
---|
77 | $('#calendar').fullCalendar('gotoDate',$('.ui-datepicker-title .ui-datepicker-year').html(), Date.getMonthNumberFromName($('.ui-datepicker-title .ui-datepicker-month').html()), currentDate[2]); |
---|
78 | $('.fc-button-year').click(); |
---|
79 | }); |
---|
80 | |
---|
81 | //Onclick em um dia do calendário anual |
---|
82 | $( ".fc-day-number" ).live( "click", function() { |
---|
83 | |
---|
84 | var date = $(this).parents('[class*="fc-day-"]').attr('class').match(/fc-day-(\d{4})-(\d{2})-(\d{2})/); |
---|
85 | |
---|
86 | if (date) date.shift(); |
---|
87 | else return false; |
---|
88 | |
---|
89 | $('#calendar').fullCalendar('gotoDate',date[0],date[1]-1,date[2]); |
---|
90 | $('#calendar').fullCalendar( 'changeView', 'agendaDay' ); |
---|
91 | }); |
---|
92 | |
---|
93 | $('.main-search input.search').keydown(function(event){ |
---|
94 | if(event.keyCode == 13) { |
---|
95 | Encoder.EncodeType = "entity"; |
---|
96 | //$(this).val($(this).val()); |
---|
97 | |
---|
98 | add_events_list($(this).val()); |
---|
99 | $(this).val(''); |
---|
100 | } |
---|
101 | }); |
---|
102 | |
---|
103 | $('.block-horizontal-toolbox .main-config-menu').menu({ |
---|
104 | content: $('.main-config-menu-content').html(), |
---|
105 | positionOpts: { |
---|
106 | posX: 'left', |
---|
107 | posY: 'bottom', |
---|
108 | offsetX: -140, |
---|
109 | offsetY: 0, |
---|
110 | directionH: 'right', |
---|
111 | directionV: 'down', |
---|
112 | detectH: true, // do horizontal collision detection |
---|
113 | detectV: true, // do vertical collision detection |
---|
114 | linkToFront: false |
---|
115 | }, |
---|
116 | flyOut: true, |
---|
117 | showSpeed: 100, |
---|
118 | crumbDefaultText: '>' |
---|
119 | }); |
---|
120 | |
---|
121 | $('#trash').droppable({ |
---|
122 | drop: function(event, ui){ |
---|
123 | // calendar.fullCalendar( 'removeEvents', ui.draggable.attr('event-id') ); |
---|
124 | DataLayer.remove( "event", ui.draggable.attr('event-id') ); |
---|
125 | $(this).switchClass('empty','full'); |
---|
126 | }, |
---|
127 | tolerance: "touch" |
---|
128 | }); |
---|
129 | |
---|
130 | /* initialize the calendar |
---|
131 | -----------------------------------------------------------------*/ |
---|
132 | $(".button.add.add-event").click(function(event){ |
---|
133 | eventDetails({ |
---|
134 | startTime: $.now(), |
---|
135 | endTime:!!User.preferences.defaultCalendar ? Calendar.signatureOf[User.preferences.defaultCalendar].calendar.defaultDuration != "" ? ($.now() + Calendar.signatureOf[User.preferences.defaultCalendar].calendar.defaultDuration * 60000) : (User.preferences.defaultDuration * 60000) |
---|
136 | : $.now() + (User.preferences.defaultDuration * 60000) |
---|
137 | }, true ); |
---|
138 | }); |
---|
139 | |
---|
140 | var calendar = $('#calendar').fullCalendar({ |
---|
141 | |
---|
142 | defaultView: User.preferences.defaultCalView, |
---|
143 | timeFormat: User.preferences.hourFormat, |
---|
144 | axisFormat: User.preferences.hourFormat, |
---|
145 | eventSources: Calendar.sources, |
---|
146 | |
---|
147 | header: { |
---|
148 | left: 'prev,next today,basicWeek,basicDay', |
---|
149 | center: 'title', |
---|
150 | right: 'agendaDay,agendaWeek,month,year' |
---|
151 | }, |
---|
152 | firstDay: dayOfWeek(!!User.preferences.weekStart), |
---|
153 | editable: true, |
---|
154 | selectable: true, |
---|
155 | selectHelper: true, |
---|
156 | droppable: true, // this allows things to be dropped onto the calendar !!! |
---|
157 | timeFormat: { |
---|
158 | agenda: 'HH:mm{ - HH:mm}', |
---|
159 | '': 'HH:mm{ - HH:mm} }' |
---|
160 | }, |
---|
161 | titleFormat: { |
---|
162 | month: 'MMMM yyyy', |
---|
163 | week: "dd[ yyyy] { 'a'[ MMM] dd 'de' MMMM '-' yyyy}", |
---|
164 | day: 'dddd, dd MMM , yyyy' |
---|
165 | }, |
---|
166 | columnFormat:{ |
---|
167 | month: 'ddd', |
---|
168 | week: 'ddd dd/MM', |
---|
169 | day: 'dddd dd/MM' |
---|
170 | }, |
---|
171 | monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro' ], |
---|
172 | monthNamesShort: ['Jan','Fev','Mar','Abr','Maio','Jun','Jul','Ago','Set','Out','Nov','Dez'], |
---|
173 | dayNames: [ 'Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sábado'], |
---|
174 | dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb'], |
---|
175 | dayNamesShortest: ['D','S','T','Q','Q','S','S'], |
---|
176 | allDayText: 'Dia todo', |
---|
177 | buttonText: { |
---|
178 | today: 'hoje', |
---|
179 | month: 'mês', |
---|
180 | week: 'semana', |
---|
181 | day: 'dia', |
---|
182 | year: 'ano' |
---|
183 | }, |
---|
184 | |
---|
185 | eventRender: function( event, element, view ){ |
---|
186 | $(element).attr( 'event-id', event.id ); |
---|
187 | }, |
---|
188 | |
---|
189 | select: function( start, end, allDay, event, view ){ |
---|
190 | eventDetails( { 'start': start, |
---|
191 | 'end': end, |
---|
192 | 'allDay': allDay } ); |
---|
193 | }, |
---|
194 | |
---|
195 | eventDrop: function( event ){ |
---|
196 | DataLayer.put( "schedulable:calendar", event ); |
---|
197 | }, |
---|
198 | |
---|
199 | eventResize: function( event ){ |
---|
200 | DataLayer.put( "schedulable:calendar", event ); |
---|
201 | }, |
---|
202 | |
---|
203 | eventClick: function( evt, event, view ){ |
---|
204 | eventDetails( DataLayer.get( "schedulable", evt.id), true); |
---|
205 | } |
---|
206 | }); |
---|
207 | |
---|
208 | if($(window).height() < $('body').height()){ |
---|
209 | var hei = $('body').height() - $(window).height(); |
---|
210 | hei = $('#divAppbox').height() - hei; |
---|
211 | $('#divAppbox').css('max-height', hei); |
---|
212 | $('#divAppbox').css('min-height', hei); |
---|
213 | $('body').css('overflow-y','hidden'); |
---|
214 | delete hei; |
---|
215 | } |
---|
216 | |
---|
217 | $(window).resize(function(){ |
---|
218 | $('#divAppbox').css('max-height', $(window).height() - 104); |
---|
219 | $('#divAppbox').css('min-height', $(window).height() - 104); |
---|
220 | $('#divAppbox').css('overflow-x', 'auto'); |
---|
221 | $('#divAppbox').css('overflow-y', 'scroll'); |
---|
222 | }); |
---|
223 | //Todo chamada do metodo que adiciona ao full calendar o botao de listagem de eventos |
---|
224 | //listEvents(); |
---|
225 | }); |
---|