[5399] | 1 | $(document).ready(function() { |
---|
[5863] | 2 | //Remove o icone de configuraçõe padrão antigo do expresso |
---|
| 3 | $('#sideboxdragarea').addClass('hidden'); |
---|
| 4 | |
---|
[5399] | 5 | refresh_calendars(); |
---|
| 6 | $tabs = $('#tabs').tabs({ |
---|
| 7 | add: function( event, ui ) { |
---|
[5409] | 8 | Calendar.lastView = $tabs.tabs('option' ,'selected'); |
---|
| 9 | $('#tabs .events-list-win.active').removeClass('active'); |
---|
[5399] | 10 | $tabs.tabs('select', '#' + ui.panel.id); |
---|
| 11 | }, |
---|
| 12 | remove: function( event, ui ) { |
---|
[5409] | 13 | $tabs.tabs('select', Calendar.lastView); |
---|
[5399] | 14 | }, |
---|
| 15 | show: function( event, ui ){ |
---|
| 16 | delete Calendar.currentViewKey; |
---|
| 17 | $('#calendar').fullCalendar('refetchEvents'); |
---|
| 18 | } |
---|
| 19 | }) |
---|
| 20 | .tabs('option', 'tabTemplate', "<li><a href='#{href}'>#{label}</a><span class='ui-icon ui-icon-close'>Remove Tab</span></li>" ); |
---|
| 21 | |
---|
| 22 | /** |
---|
| 23 | * Make a button to close the tab |
---|
| 24 | */ |
---|
| 25 | $tabs.find( "span.ui-icon-close" ).live( "click", function() { |
---|
| 26 | var index = $( "li", $tabs ).index( $( this ).parent() ); |
---|
| 27 | if($tabs.tabs('option' ,'selected') == index){ |
---|
[5409] | 28 | if($tabs.tabs("length") == 2 && Calendar.lastView != 1) |
---|
[5399] | 29 | $tabs.tabs( "select", 0); |
---|
[5409] | 30 | $tabs.tabs( "select", Calendar.lastView); |
---|
[5399] | 31 | } |
---|
| 32 | if($tabs.tabs('option' ,'selected') == 0 || $tabs.tabs('option' ,'selected') == 1) |
---|
[5409] | 33 | Calendar.lastView = $tabs.tabs('option' ,'selected'); |
---|
[5399] | 34 | if(index != -1) |
---|
| 35 | $tabs.tabs( "remove", index ); |
---|
| 36 | |
---|
| 37 | |
---|
| 38 | }); |
---|
| 39 | $('.button.config-menu').button({ |
---|
| 40 | icons: { |
---|
| 41 | primary: "ui-icon-gear", |
---|
| 42 | secondary: "ui-icon-triangle-1-s" |
---|
| 43 | }, |
---|
| 44 | text: false |
---|
| 45 | }); |
---|
| 46 | $('.button.add').button({ |
---|
| 47 | icons: { |
---|
| 48 | secondary: "ui-icon-plus" |
---|
| 49 | } |
---|
| 50 | }) |
---|
| 51 | |
---|
| 52 | var miniCalendar = $('.block-vertical-toolbox .mini-calendar').datepicker({ |
---|
| 53 | dateFormat: 'yy-m-d', |
---|
| 54 | //dateFormat: 'DD, d MM, yy', |
---|
| 55 | //inline: true, |
---|
[5409] | 56 | firstDay: dateCalendar.dayOfWeek[User.preferences.weekStart], |
---|
[5399] | 57 | onSelect: function(dateText, inst) |
---|
| 58 | { |
---|
| 59 | $tabs.tabs("select", "#calendar"); |
---|
[5442] | 60 | var toDate = $('.block-vertical-toolbox .mini-calendar').datepicker("getDate").toString('yyyy-MM-dd').split('-'); |
---|
| 61 | $('#calendar').fullCalendar('gotoDate', toDate[0], parseInt(toDate[1]-1), toDate[2] ); |
---|
[5399] | 62 | $('#calendar').fullCalendar( 'changeView', 'agendaDay' ); |
---|
| 63 | } |
---|
| 64 | }) |
---|
| 65 | .find('.ui-icon-circle-triangle-e').removeClass('ui-icon-circle-triangle-e').addClass('ui-icon-triangle-1-e').end() |
---|
| 66 | .find('.ui-icon-circle-triangle-w').removeClass('ui-icon-circle-triangle-w').addClass('ui-icon-triangle-1-w'); |
---|
| 67 | |
---|
| 68 | //Onclick do mês |
---|
| 69 | $('.ui-datepicker-title .ui-datepicker-month').live('click',function(){ |
---|
| 70 | $tabs.tabs("select", "#calendar"); |
---|
[5442] | 71 | $('#calendar').fullCalendar('gotoDate',$(this).siblings('span').html(), Date.getMonthNumberFromName($(this).html() == 'Março' ? 'Mar' : $(this).html()),'01'); |
---|
[5399] | 72 | $('#calendar').fullCalendar( 'changeView', 'month'); |
---|
| 73 | }); |
---|
| 74 | //Onclick do ano |
---|
| 75 | $('.ui-datepicker-title .ui-datepicker-year').live('click',function(){ |
---|
| 76 | $tabs.tabs("select", "#calendar"); |
---|
[5442] | 77 | $('#calendar').fullCalendar('gotoDate',$(this).html(), '0', '01'); |
---|
[5399] | 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 | }); |
---|
[5592] | 102 | |
---|
| 103 | //efetua pesquisas pelo click na lupa de pesquisa |
---|
| 104 | $('.main-search span.ui-icon-search').click(function(event){ |
---|
| 105 | add_events_list($(this).parent().find('input.search').val()); |
---|
| 106 | $(this).parent().find('input.search').val(); |
---|
| 107 | }); |
---|
| 108 | |
---|
[5399] | 109 | $('.block-horizontal-toolbox .main-config-menu').menu({ |
---|
| 110 | content: $('.main-config-menu-content').html(), |
---|
| 111 | positionOpts: { |
---|
| 112 | posX: 'left', |
---|
| 113 | posY: 'bottom', |
---|
| 114 | offsetX: -140, |
---|
| 115 | offsetY: 0, |
---|
| 116 | directionH: 'right', |
---|
| 117 | directionV: 'down', |
---|
| 118 | detectH: true, // do horizontal collision detection |
---|
| 119 | detectV: true, // do vertical collision detection |
---|
| 120 | linkToFront: false |
---|
| 121 | }, |
---|
| 122 | flyOut: true, |
---|
| 123 | showSpeed: 100, |
---|
| 124 | crumbDefaultText: '>' |
---|
| 125 | }); |
---|
| 126 | |
---|
| 127 | $('#trash').droppable({ |
---|
| 128 | drop: function(event, ui){ |
---|
| 129 | // calendar.fullCalendar( 'removeEvents', ui.draggable.attr('event-id') ); |
---|
| 130 | DataLayer.remove( "event", ui.draggable.attr('event-id') ); |
---|
| 131 | $(this).switchClass('empty','full'); |
---|
| 132 | }, |
---|
| 133 | tolerance: "touch" |
---|
| 134 | }); |
---|
| 135 | |
---|
| 136 | /* initialize the calendar |
---|
| 137 | -----------------------------------------------------------------*/ |
---|
| 138 | $(".button.add.add-event").click(function(event){ |
---|
[6453] | 139 | var startEvent = new Date(); |
---|
| 140 | var configData = (startEvent.toString('mm') < 30) ? {minutes: (30 - parseInt(startEvent.toString('mm')))} : {hours: 1, minutes: '-'+startEvent.toString('mm')}; |
---|
| 141 | startEvent.add(configData); |
---|
| 142 | |
---|
[5399] | 143 | eventDetails({ |
---|
[5409] | 144 | startTime: startEvent.getTime(), |
---|
[6453] | 145 | endTime: dateCalendar.decodeRange(startEvent, (!!User.preferences.defaultCalendar ? ( !!Calendar.signatureOf[User.preferences.defaultCalendar].calendar.defaultDuration ? |
---|
| 146 | (Calendar.signatureOf[User.preferences.defaultCalendar].calendar.defaultDuration) : (User.preferences.defaultDuration)) : (User.preferences.defaultDuration))) |
---|
[5399] | 147 | }, true ); |
---|
| 148 | }); |
---|
[7228] | 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){ |
---|
[5399] | 163 | |
---|
[7228] | 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 | 'class':'1', |
---|
| 248 | status: '1', |
---|
| 249 | startTime: new Date().toString('yyyy-MM-dd 00:00:00'), |
---|
| 250 | endTime: new Date().toString('yyyy-MM-dd 00:00:00'), |
---|
| 251 | allDay: '1', |
---|
| 252 | priority: '1', |
---|
| 253 | participants: |
---|
| 254 | [{ |
---|
| 255 | user: User.me.id, |
---|
| 256 | isOrganizer: 1, |
---|
| 257 | acl: 'row' |
---|
| 258 | }] |
---|
| 259 | }); |
---|
| 260 | |
---|
| 261 | $(componente).qtip('destroy'); |
---|
| 262 | |
---|
| 263 | }); |
---|
| 264 | |
---|
| 265 | $('.qtip-active .button.advanced').button().click(function(){ |
---|
| 266 | |
---|
| 267 | var startEvent = new Date(); |
---|
| 268 | var configData = (startEvent.toString('mm') < 30) ? {minutes: (30 - parseInt(startEvent.toString('mm')))} : {hours: 1, minutes: '-'+startEvent.toString('mm')}; |
---|
| 269 | startEvent.add(configData); |
---|
| 270 | |
---|
| 271 | var componente = $(this); |
---|
| 272 | var description = $('div.qtip div.add-simple-task textarea[name="description"]').val(); |
---|
| 273 | |
---|
| 274 | taskDetails({ |
---|
| 275 | summary: $('div.qtip div.add-simple-task input[name="summary"]').val(), |
---|
| 276 | description: description == 'Descrição' ? '' : description, |
---|
| 277 | startTime: startEvent.getTime(), |
---|
| 278 | endTime: dateCalendar.decodeRange(startEvent, (!!User.preferences.defaultCalendar ? ( !!Calendar.signatureOf[User.preferences.defaultCalendar].calendar.defaultDuration ? |
---|
| 279 | (Calendar.signatureOf[User.preferences.defaultCalendar].calendar.defaultDuration) : (User.preferences.defaultDuration)) : (User.preferences.defaultDuration))) |
---|
| 280 | }, true ); |
---|
| 281 | |
---|
| 282 | $(componente).qtip('destroy'); |
---|
| 283 | }); |
---|
| 284 | |
---|
| 285 | $('.qtip-active .button.cancel').button().click(function(){ |
---|
| 286 | $(componente).qtip('destroy'); |
---|
| 287 | }); |
---|
| 288 | |
---|
| 289 | $('.qtip-active .button').button(); |
---|
| 290 | |
---|
| 291 | $('div.qtip.qtip-blue.qtip-active').addClass('new-task'); |
---|
| 292 | } |
---|
| 293 | } |
---|
| 294 | }); |
---|
| 295 | |
---|
| 296 | $(".button.add.add-activity").click(function(event){ |
---|
| 297 | var startEvent = new Date(); |
---|
| 298 | var configData = (startEvent.toString('mm') < 30) ? {minutes: (30 - parseInt(startEvent.toString('mm')))} : {hours: 1, minutes: '-'+startEvent.toString('mm')}; |
---|
| 299 | startEvent.add(configData); |
---|
| 300 | |
---|
| 301 | activityDetails({ |
---|
| 302 | startTime: startEvent.getTime(), |
---|
| 303 | endTime: dateCalendar.decodeRange(startEvent, (!!User.preferences.defaultCalendar ? ( !!Calendar.signatureOf[User.preferences.defaultCalendar].calendar.defaultDuration ? |
---|
| 304 | (Calendar.signatureOf[User.preferences.defaultCalendar].calendar.defaultDuration) : (User.preferences.defaultDuration)) : (User.preferences.defaultDuration))) |
---|
| 305 | }, true ); |
---|
| 306 | |
---|
| 307 | }); |
---|
| 308 | |
---|
[5409] | 309 | var calendar = $('#calendar').fullCalendar(DataLayer.merge({ |
---|
[5399] | 310 | |
---|
| 311 | defaultView: User.preferences.defaultCalView, |
---|
| 312 | timeFormat: User.preferences.hourFormat, |
---|
| 313 | axisFormat: User.preferences.hourFormat, |
---|
| 314 | eventSources: Calendar.sources, |
---|
| 315 | |
---|
| 316 | header: { |
---|
| 317 | left: 'prev,next today,basicWeek,basicDay', |
---|
| 318 | center: 'title', |
---|
| 319 | right: 'agendaDay,agendaWeek,month,year' |
---|
| 320 | }, |
---|
[5510] | 321 | firstHour: dateCalendar.getShortestTime(User.preferences.defaultStartHour ? User.preferences.defaultStartHour : '6'), |
---|
[5409] | 322 | firstDay: dateCalendar.dayOfWeek[User.preferences.weekStart], |
---|
[5399] | 323 | editable: true, |
---|
| 324 | selectable: true, |
---|
| 325 | selectHelper: true, |
---|
| 326 | droppable: true, // this allows things to be dropped onto the calendar !!! |
---|
| 327 | timeFormat: { |
---|
| 328 | agenda: 'HH:mm{ - HH:mm}', |
---|
| 329 | '': 'HH:mm{ - HH:mm} }' |
---|
| 330 | }, |
---|
| 331 | titleFormat: { |
---|
| 332 | month: 'MMMM yyyy', |
---|
| 333 | week: "dd[ yyyy] { 'a'[ MMM] dd 'de' MMMM '-' yyyy}", |
---|
| 334 | day: 'dddd, dd MMM , yyyy' |
---|
| 335 | }, |
---|
| 336 | columnFormat:{ |
---|
| 337 | month: 'ddd', |
---|
| 338 | week: 'ddd dd/MM', |
---|
| 339 | day: 'dddd dd/MM' |
---|
| 340 | }, |
---|
[5409] | 341 | |
---|
[5399] | 342 | allDayText: 'Dia todo', |
---|
| 343 | buttonText: { |
---|
| 344 | today: 'hoje', |
---|
| 345 | month: 'mês', |
---|
| 346 | week: 'semana', |
---|
| 347 | day: 'dia', |
---|
| 348 | year: 'ano' |
---|
| 349 | }, |
---|
[7228] | 350 | |
---|
[5399] | 351 | eventRender: function( event, element, view ){ |
---|
[7228] | 352 | $('#calendar td.fc-year-have-event').removeClass('fc-year-have-event'); |
---|
| 353 | |
---|
| 354 | var img_icon = ""; |
---|
| 355 | if(event.type == 1) |
---|
| 356 | img_icon = "mini-event.png"; |
---|
| 357 | if(event.type == 2) |
---|
| 358 | img_icon = "mini-task.png"; |
---|
| 359 | if(event.type == 3) |
---|
| 360 | img_icon = "mini-activity.png"; |
---|
| 361 | |
---|
| 362 | |
---|
| 363 | element.find(".fc-event-inner.fc-event-skin").prepend($('<img style="width: 11px; height: 13px;" class="" src="../prototype/modules/calendar/img/' + img_icon + '"></img>')); |
---|
[5399] | 364 | }, |
---|
[7228] | 365 | |
---|
[5399] | 366 | select: function( start, end, allDay, event, view ){ |
---|
[5510] | 367 | if (view.name == "month") { |
---|
| 368 | if (User.preferences.defaultStartHour) { |
---|
| 369 | _start = User.preferences.defaultStartHour; |
---|
| 370 | |
---|
| 371 | if (_start.length > 4) |
---|
| 372 | _start = _start.trim().substring(0,5); // remove o am/pm |
---|
| 373 | |
---|
| 374 | _start = _start.split(":"); |
---|
| 375 | start.setHours(_start[0]); |
---|
| 376 | start.setMinutes(_start[1]); |
---|
| 377 | } |
---|
| 378 | |
---|
| 379 | if (User.preferences.defaultEndHour) { |
---|
| 380 | _end = User.preferences.defaultEndHour; |
---|
| 381 | if (_end.length > 4) |
---|
| 382 | _end = _end.trim().substring(0,5); // remove o am/pm |
---|
| 383 | |
---|
| 384 | _end = _end.split(":"); |
---|
| 385 | end.setHours(_end[0]); |
---|
| 386 | end.setMinutes(_end[1]); |
---|
| 387 | } |
---|
| 388 | } // END if (view.name == "month") |
---|
| 389 | |
---|
[5399] | 390 | eventDetails( { 'start': start, |
---|
| 391 | 'end': end, |
---|
| 392 | 'allDay': allDay } ); |
---|
| 393 | }, |
---|
| 394 | |
---|
[5746] | 395 | eventDrop: function( evt, event, view ){ |
---|
| 396 | evt.id = evt.id.split('-')[0]; |
---|
| 397 | if(!evt.disableDragging){ |
---|
| 398 | |
---|
| 399 | if(evt.isRepeat){ |
---|
| 400 | var schedulable = copyAndMoveTo(false , evt.id , false, "3", evt); |
---|
| 401 | |
---|
| 402 | var repeat = mount_exception(evt.id, evt.occurrence); |
---|
| 403 | DataLayer.remove('repeat', false); |
---|
| 404 | DataLayer.put('repeat', repeat); |
---|
| 405 | DataLayer.commit('repeat', false, function(data){ |
---|
[5752] | 406 | |
---|
| 407 | DataLayer.remove('schedulable', repeat.schedulable, false); |
---|
[5746] | 408 | DataLayer.put('schedulable', schedulable); |
---|
| 409 | |
---|
| 410 | }); |
---|
[5427] | 411 | |
---|
[5746] | 412 | }else{ |
---|
| 413 | DataLayer.put( "schedulable:calendar", evt ); |
---|
| 414 | |
---|
[5592] | 415 | event.editable = false; |
---|
| 416 | event.className = "blocked-event"; |
---|
[5746] | 417 | calendar.fullCalendar( 'updateEvent', evt ); |
---|
| 418 | } |
---|
| 419 | |
---|
[5592] | 420 | }else |
---|
[5746] | 421 | Calendar.rerenderView(true); |
---|
[5399] | 422 | }, |
---|
| 423 | |
---|
[5746] | 424 | eventResize: function( evt, event, view ){ |
---|
| 425 | evt.id = evt.id.split('-')[0]; |
---|
| 426 | if(!evt.disableDragging){ |
---|
| 427 | if(evt.isRepeat){ |
---|
| 428 | var schedulable = copyAndMoveTo(false , evt.id , false, "3", evt); |
---|
| 429 | |
---|
| 430 | //Normaliza a data para o backend |
---|
| 431 | schedulable.startTime = new Date(parseInt(schedulable.startTime)).toString('yyyy-MM-dd hh:mm:00'); |
---|
| 432 | schedulable.endTime = new Date(parseInt(schedulable.endTime)).toString('yyyy-MM-dd hh:mm:00'); |
---|
| 433 | |
---|
| 434 | var repeat = mount_exception(evt.id, evt.occurrence); |
---|
| 435 | |
---|
| 436 | DataLayer.remove('repeat', false); |
---|
| 437 | DataLayer.put('repeat', repeat); |
---|
| 438 | DataLayer.commit('repeat', false, function(data){ |
---|
| 439 | |
---|
[5752] | 440 | DataLayer.remove('schedulable', repeat.schedulable, false); |
---|
[5746] | 441 | DataLayer.put('schedulable', schedulable); |
---|
| 442 | |
---|
| 443 | }); |
---|
| 444 | }else{ |
---|
| 445 | DataLayer.put( "schedulable:calendar", evt ); |
---|
| 446 | evt.editable = false; |
---|
| 447 | evt.className = "blocked-event"; |
---|
| 448 | calendar.fullCalendar( 'updateEvent', evt ); |
---|
| 449 | } |
---|
| 450 | |
---|
[5592] | 451 | }else |
---|
| 452 | Calendar.rerenderView(true); |
---|
[5399] | 453 | }, |
---|
| 454 | |
---|
| 455 | eventClick: function( evt, event, view ){ |
---|
[5746] | 456 | evt.id = evt.id.split('-')[0]; |
---|
[7228] | 457 | |
---|
| 458 | switch (parseInt(evt.type)){ |
---|
| 459 | case 1: |
---|
| 460 | if(evt.selectable){ |
---|
| 461 | if(evt.isRepeat){ |
---|
| 462 | $.Zebra_Dialog(evt.title + ' é um evento com repetição.', { |
---|
| 463 | 'type': 'question', |
---|
| 464 | 'overlay_opacity': '0.5', |
---|
| 465 | 'buttons': ['Editar todas ocorrências', 'Editar essa ocorrência'], |
---|
| 466 | 'onClose': function(clicked) { |
---|
| 467 | if(clicked == 'Editar todas ocorrências') { |
---|
| 468 | eventDetails( DataLayer.get( "schedulable", evt.id), true); |
---|
| 469 | }else{ |
---|
| 470 | /* |
---|
| 471 | * TODO - repeat foi adicionado pois melhorias devem ser feitas no rollback do |
---|
| 472 | *DataLayer, repeat somente é usado quando se trata da criação de um evento |
---|
| 473 | *pela edição de uma ocorrência. |
---|
| 474 | */ |
---|
| 475 | var repeat = mount_exception(evt.id, evt.occurrence); |
---|
| 476 | |
---|
| 477 | $('.calendar-copy-move input[name="typeEvent"]').val("3"); |
---|
| 478 | |
---|
| 479 | eventDetails(copyAndMoveTo(false , evt.id , false, "3", evt), true, '', false, repeat); |
---|
| 480 | } |
---|
| 481 | } |
---|
| 482 | }); |
---|
| 483 | }else{ |
---|
| 484 | var schedulable = DataLayer.get( "schedulable", evt.id); |
---|
| 485 | schedulable.calendar = evt.calendar; |
---|
| 486 | eventDetails( schedulable, true); |
---|
| 487 | } |
---|
[5746] | 488 | } |
---|
[7228] | 489 | break; |
---|
| 490 | case 2: |
---|
| 491 | var task = DataLayer.get( "schedulable", evt.id); |
---|
| 492 | task.group = evt.calendar; |
---|
| 493 | taskDetails( task, true); |
---|
| 494 | break; |
---|
| 495 | case 3: |
---|
| 496 | var activity = DataLayer.get( "schedulable", evt.id); |
---|
| 497 | activity.group = evt.calendar; |
---|
| 498 | activityDetails( activity, true); |
---|
| 499 | break; |
---|
| 500 | } |
---|
[5943] | 501 | }, |
---|
| 502 | |
---|
| 503 | eventAfterRender: function(event, element, view){ |
---|
| 504 | contentMenu(); |
---|
[5399] | 505 | } |
---|
[7228] | 506 | }, dateCalendar)); |
---|
| 507 | |
---|
| 508 | |
---|
[5592] | 509 | contentMenu(); |
---|
| 510 | |
---|
| 511 | $('body').click(function(){ |
---|
| 512 | $('#context-menu-event').html(''); |
---|
| 513 | }); |
---|
| 514 | |
---|
[5399] | 515 | if($(window).height() < $('body').height()){ |
---|
| 516 | var hei = $('body').height() - $(window).height(); |
---|
| 517 | hei = $('#divAppbox').height() - hei; |
---|
| 518 | $('#divAppbox').css('max-height', hei); |
---|
| 519 | $('#divAppbox').css('min-height', hei); |
---|
| 520 | $('body').css('overflow-y','hidden'); |
---|
| 521 | delete hei; |
---|
| 522 | } |
---|
| 523 | |
---|
| 524 | $(window).resize(function(){ |
---|
| 525 | $('#divAppbox').css('max-height', $(window).height() - 104); |
---|
| 526 | $('#divAppbox').css('min-height', $(window).height() - 104); |
---|
| 527 | $('#divAppbox').css('overflow-x', 'auto'); |
---|
| 528 | $('#divAppbox').css('overflow-y', 'scroll'); |
---|
| 529 | }); |
---|
| 530 | //Todo chamada do metodo que adiciona ao full calendar o botao de listagem de eventos |
---|
[7228] | 531 | printEvents(); |
---|
[6754] | 532 | }); |
---|
[7228] | 533 | |
---|
| 534 | |
---|
| 535 | function useDesktopNotification(){ |
---|
| 536 | return !!parseInt(User.preferences.useDesktopNotification); |
---|
| 537 | } |
---|