1/*! 2 * 3 * Responsive Timetable for Wordpress 4 * For Wordpress 5 * 6 * @author Rik de Vos 7 * @link http://rikdevos.com/ 8 * @version 1.10.0 9 * 10 * This is not free software. Visit http://rikdevos.com/demos/wordpress-responsive-timetable/ to purchase a license 11 * 12 */ 13 14(function($){ 15 16 var sched_url_opened = false; 17 18 $(document).ready(function() { 19 20 $("body").append('<div class="sched-popup-overlay"><div class="sched-popup-overlay-close"></div></div><div class="sched-popup"><div class="sched-popup-navigate-left"></div><div class="sched-popup-navigate-right"></div><a href="#" class="sched-popup-close"><i class="sched-icon sched-icon-times"></i></a><div class="sched-popup-media"></div><div class="sched-popup-title">Mark Sixma</div><div class="sched-popup-description"></div></div>'); 21 22 $(".sched").each(function() { 23 new Schedule($(this)); 24 }); 25 }); 26 27 var Schedule = function($schedule) { 28 29 var that = this; 30 this.$schedule = $schedule; 31 this.$columns = this.$schedule.find('.sched-column'); 32 this.$h_columns = this.$schedule.find('.sched-h-column'); 33 this.$events = this.$schedule.find('.sched-event'); 34 this.$popup = $(".sched-popup"); 35 this.$overlay = $(".sched-popup-overlay"); 36 this.$sorts = this.$schedule.find('.sched-sort'); 37 this.editor_mode = ($schedule.hasClass('sched-editor-mode')) ? true : false; 38 this.type = this.$schedule.attr('data-type'), 39 this.layout = this.$schedule.attr('data-layout'), 40 this.id = this.$schedule.attr('id'); 41 42 this.options = $.parseJSON(this.$schedule.attr('data-options')); 43 44 this.info = { 45 open_event_id: false, 46 ios: ( navigator.userAgent.match(/(iPad|iPhone|iPod)/g) ? true : false ), 47 mobile: ( navigator.userAgent.match(/(Android|webOS|iPad|iPhone|iPod|BlackBerry|Windows Phone)/g) ? true : false ), 48 animations: true, 49 animations_speed: 200, 50 break_columns: false, 51 popup_top_offset: 100, 52 previous_width: 0, 53 style_lighten_amount: 60, 54 has_filters: that.$schedule.find('.sched-sort').length == 1, 55 title_width: (that.$schedule.find('.sched-title').length === 0) ? 0 : that.$schedule.find('.sched-title').innerWidth(), 56 filter_label_width: (that.$schedule.find('.sched-sort-label').length === 0) ? 0 : that.$schedule.find('.sched-sort-label').innerWidth(), 57 filter_dropdown_closed_width: parseFloat(this.options.filter_dropdown_width)+38, 58 filter_dropdown_open_width: parseFloat(this.options.filter_dropdown_hover_width)+18+38, 59 hashchange_method: 'normal', 60 next_event: false, 61 previous_event: false, 62 event_box_padding_break: 110, 63 event_box_padding: 14, 64 loader: this.$schedule.siblings('.sched-loader'), 65 type: 'full', 66 } 67 68 69 this.info.popup_top_offset = this.info.mobile ? 20 : this.info.popup_top_offset; 70 71 this.info.animations = (this.options.animations == 0 || (this.info.mobile && this.options.animations_mobile == 0)) ? false : true; 72 73 if(this.editor_mode) { 74 if(this.options.animations_editor == 0) { 75 this.info.animations = false; 76 } 77 } 78 if(this.options.animations_speed == 'slow') { 79 this.info.animations_speed = 280; 80 }else if(this.options.animations_speed == 'normal') { 81 this.info.animations_speed = 200; 82 }else if(this.options.animations_speed == 'fast') { 83 this.info.animations_speed = 150; 84 } 85 86 if(this.info.animations == 0) { 87 this.info.animations_speed = 1; 88 } 89 90 this.$schedule_list = (this.$schedule.attr('data-list-id') == 0) ? false : $(this.$schedule.attr('data-list-id')); 91 92 this.init(); 93 94 //$(window).on('resize', that.resize); 95 96 97 setTimeout(function() { 98 that.info.loader.remove(); 99 that.$schedule.addClass('sched-visible'); 100 }, 100); 101 102 }; 103 104 Schedule.prototype.init = function() { 105 var that = this; 106 107 $(window).on('resize', function() { 108 that.resize(); 109 }); 110 111 if($('.sched[data-timetable-id='+this.$schedule.attr('data-timetable-id')+']').length > 1) { 112 this.options.hashtag_url = 0; 113 } 114 //this.resize(); 115 116 this.info.event_box_padding_break = parseFloat(this.options.event_box_padding_break); 117 if(this.info.mobile) { 118 this.$schedule.addClass('sched-is-mobile'); 119 this.info.event_box_padding_break = 150; 120 } 121 if(this.info.ios) { 122 this.$schedule.addClass('sched-is-ios'); 123 } 124 125 var style = this.$schedule.find('.sched-style').html(); 126 if(style !== '') { 127 $('<style type="text/css" />').html(style).appendTo('head'); 128 } 129 130 this.$events.click(function(e) { 131 var $this = $(this), 132 click = $this.attr('data-onclick'); 133 134 if(click == 'popup' || that.editor_mode) { 135 e.preventDefault(); 136 if(that.options.hashtag_url == 1) { 137 //change url 138 window.top.location.hash = 'event-'+$(this).attr('data-event-id'); 139 }else { 140 that.open_event($this); 141 } 142 143 }else if(click == '0') { 144 e.preventDefault(); 145 }else if(click == 'link') { 146 147 } 148 149 }); 150 151 if(this.$schedule_list !== false) { 152 this.$schedule_list.find('.sched-list-event').click(function(e) { 153 var $event = $(this).data('$event'), 154 click = $event.attr('data-onclick'); 155 156 // console.log($event); 157 158 if(click == 'popup' || that.editor_mode) { 159 if(that.options.hashtag_url == 1) { 160 // open the hashtag, so do nothing 161 }else { 162 e.preventDefault(); 163 that.open_event($event); 164 } 165 }else if(click == '0') { 166 e.preventDefault(); 167 }else if(click == 'link') { 168 169 } 170 }); 171 } 172 173 $(document).bind('keydown', function(e) { 174 if(that.options.popup_arrows == 0) { 175 return; 176 } 177 if(!that.info.open_event_id) { 178 return; 179 } 180 if(e.keyCode === 37 && that.info.previous_event !== false) { 181 that.info.hashchange_method = 'previous'; 182 that.queue_event(that.info.previous_event); 183 e.preventDefault(); 184 }else if(e.keyCode === 39 && that.info.next_event !== false) { 185 that.info.hashchange_method = 'next'; 186 that.queue_event(that.info.next_event); 187 e.preventDefault(); 188 }else if(e.keyCode === 37) { 189 that.nudge_event_down(); 190 e.preventDefault(); 191 }else if(e.keyCode === 39) { 192 that.nudge_event_up(); 193 e.preventDefault(); 194 } 195 }); 196 197 if(this.options.columns_sticky_header == '1') { 198 199 $(window).scroll(function() { 200 var offset = that.$schedule.find('.sched-columns').offset(), 201 height = that.$schedule.find('.sched-columns').innerHeight(), 202 scrollTop = $(this).scrollTop(); 203 204 if(scrollTop + parseFloat(that.options.columns_sticky_header_offset) > offset.top && scrollTop < offset.top+height-parseFloat(that.options.columns_sticky_header_offset)-100 && that.info.break_columns == false) { 205 that.$schedule.addClass('sched-sticky-header-visible'); 206 }else { 207 that.$schedule.removeClass('sched-sticky-header-visible'); 208 } 209 }); 210 } 211 212 if(this.options.popup_arrows == 0 || this.info.mobile) { 213 this.$popup.addClass('sched-popup-hide-arrows'); 214 } 215 216 this.$overlay.click(function(e) { 217 e.preventDefault(); 218 that.close_event(); 219 }); 220 221 this.$popup.find('.sched-popup-close').click(function(e) { 222 e.preventDefault(); 223 that.close_event(); 224 }); 225 226 this.$events.each(function() { 227 that.init_event($(this)); 228 }); 229 230 this.$columns.each(function() { 231 that.init_column($(this)); 232 }); 233 234 this.$h_columns.each(function() { 235 that.init_h_column($(this)); 236 }); 237 238 this.$sorts.each(function() { 239 that.init_sort($(this)); 240 }); 241 242 this.$schedule.find('.sched-h-content-scroll').each(function() { 243 $(this).perfectScrollbarTimetable({ 244 'suppressScrollY': true, 245 'useBothWheelAxes': true, 246 'scroll': function(e) { that.horizontal_scroll_update(e); }, 247 }); 248 $(document).on('ps-scroll-x', function () { 249 that.horizontal_scroll_update(); 250 }); 251 }); 252 253 $(document).keyup(function(e) { 254 if(e.keyCode == 27) { 255 that.close_event(); 256 } 257 }); 258 259 this.resize(); 260 261 if(this.options.hashtag_url == 1 && sched_url_opened === false && window.top.location.hash !== '' && window.top.location.hash !== '#' && window.top.location.hash.split('#event-').length === 2) { 262 var hash = window.top.location.hash.split('#event-'), 263 event_id = parseFloat(hash[1]), 264 $event = this.$schedule.find('.sched-event[data-event-id='+event_id+']'); 265 266 if($event.length !== 0) { 267 sched_url_opened = true; 268 $('html, body').animate({ 269 scrollTop: that.$schedule.offset().top 270 }, 500, function() { 271 that.open_event($event); 272 }); 273 274 } 275 276 } 277 278 if(this.options.hashtag_url == 1 ) { 279 $(window).on('hashchange', function() { 280 if(that.info.hashchange_method === 'normal') { 281 282 if(that.info.open_event_id !== false) { 283 var hash = window.top.location.hash; 284 that.close_event(function() { 285 window.top.location.hash = hash; 286 }); 287 //setTimeout(function() { 288 // 289 //}, 500); 290 291 } 292 293 if(window.top.location.hash !== '' && window.top.location.hash !== '#' && window.top.location.hash.split('#event-').length === 2) { 294 var hash = window.top.location.hash.split('#event-'), 295 event_id = parseFloat(hash[1]), 296 $event = that.$schedule.find('.sched-event[data-event-id='+event_id+']'); 297 298 if($event.length !== 0) { 299 that.open_event($event); 300 } 301 /*else if($(".sched-event[data-event-id="+event_id+"]").length > 1) { 302 console.log('Timetable Error: You have multiple copies of the same timetable running on 1 page. Go to Timetable > Settings > General Settings and turn OFF "ENABLE HASHTAGS".') 303 }*/ 304 305 } 306 }else if(that.info.hashchange_method === 'next') { 307 var hash = window.top.location.hash.split('#event-'), 308 event_id = parseFloat(hash[1]), 309 $event = that.$schedule.find('.sched-event[data-event-id='+event_id+']'); 310 that.open_next_event($event, that.info.open_event_id); 311 }else if(that.info.hashchange_method === 'previous') { 312 var hash = window.top.location.hash.split('#event-'), 313 event_id = parseFloat(hash[1]), 314 $event = that.$schedule.find('.sched-event[data-event-id='+event_id+']'); 315 that.open_previous_event($event, that.info.open_event_id); 316 } 317 }); 318 } 319 320 }; 321 322 Schedule.prototype.init_sort = function($sort) { 323 var that = this, 324 multisort = (this.options.filter_multiple == '1') ? true : false, 325 $items = $sort.find('.sched-sort-item'), 326 $items_checked = $sort.find('.sched-sort-item[data-checked-on-load="1"]'); 327 328 if(!this.info.mobile) { 329 $sort.find('.sched-sort-dropdown').hover(function() { 330 $sort.addClass('sched-sort-open'); 331 }, function() { 332 $sort.removeClass('sched-sort-open'); 333 }); 334 }else { 335 $sort.find('.sched-sort-dropdown').click(function(e) { 336 e.preventDefault(); 337 var $target = $(e.target); 338 if($target.parents('.sched-sort-dropdown-select').length == 0) { 339 $sort.toggleClass('sched-sort-open'); 340 } 341 }); 342 $sort.blur(function() { 343 $sort.removeClass('sched-sort-open'); 344 }); 345 } 346 347 // $items.each(function() { 348 // var $item = $(this); 349 // $(this).click(function() { 350 // run_sort_item($(this)); 351 // }); 352 // }); 353 354 $items.click(function() { 355 that.run_sort_item($(this), $sort); 356 }); 357 358 $items_checked.each(function() { 359 that.run_sort_item($(this), $sort); 360 }) 361 362 } 363 364 Schedule.prototype.run_sort_item = function($item, $sort) { 365 var that = this, 366 multisort = (this.options.filter_multiple == '1') ? true : false, 367 sort_json = $item.attr('data-sort-item-json'); 368 369 $item.toggleClass('sched-sort-item-selected'); 370 if($item.hasClass('sched-sort-item-selected')) { 371 // Changed to 1 372 $sort.removeClass('sched-sort-empty'); 373 if(!multisort) { 374 // Uncheck other $item 375 376 $sort.find('.sched-sort-item.sched-sort-item-selected').each(function() { 377 if($(this).attr('data-sort-item-json') !== sort_json) { 378 $(this).removeClass('sched-sort-item-selected') 379 } 380 }); 381 382 } 383 }else { 384 // Changed to 0 385 if($sort.find('.sched-sort-item.sched-sort-item-selected').length === 0) { 386 $sort.addClass('sched-sort-empty'); 387 } 388 } 389 if(!multisort) { 390 $sort.removeClass('sched-sort-open') 391 // $sort.find('.sched-sort-dropdown-select').css('display', 'none'); 392 // setTimeout(function() { 393 // $sort.find('.sched-sort-dropdown-select').css('display', ''); 394 // }, 300); 395 } 396 that.run_sort($sort); 397 } 398 399 Schedule.prototype.run_sort = function($sort) { 400 var that = this; 401 var $items_selected = $sort.find('.sched-sort-item.sched-sort-item-selected'); 402 if($items_selected.length === 0) { 403 $sort.find('.sched-sort-current-label').html($sort.attr('data-all-string')); 404 //this.$schedule.find('.sched-event.sched-event-sort-hidden').removeClass('sched-event-sort-hidden'); 405 //this.$events.removeClass('sched-event-sort-hidden'); 406 this.$schedule.find('.sched-event.sched-event-sort-hidden').each(function() { 407 that.sort_show_event($(this)); 408 }); 409 return; 410 } 411 412 var all_logic = []; 413 414 var i = 0, 415 current_string = ''; 416 $items_selected.each(function() { 417 // Run logic 418 var logic = $.parseJSON($(this).attr('data-sort-item-json')); 419 420 all_logic.push(logic); 421 422 // Create String 423 current_string += $(this).find('.sched-sort-item-label').html(); 424 if(i !== $items_selected.length-1) { 425 current_string += ', '; 426 } 427 i++; 428 });
429 $sort.find('.sched-sort-current-label').html(current_string); 430 431 this.sort_all_logic(all_logic); 432 } 433 434 Schedule.prototype.sort_all_logic = function(all_logic) { 435 var that = this; 436 437 this.$events.each(function() { 438 var $event = $(this); 439 //$event.removeClass('sched-event-sort-hidden'); 440 441 for(var i = 0; i < all_logic.length; i++) { 442 var logic = all_logic[i]; 443 444 switch (logic.source) { 445 case 'title': 446 if($event.find('.sched-event-title').length !== 0 && that.sort_logic_title($event.find('.sched-event-title').html(), logic.matches, logic.method)) { 447 // Show the event 448 $event.addClass('sched-event-sort-visible'); 449 return; // Skip rest of logic, this one is good 450 } 451 break; 452 case 'specific_custom_field': 453 var $custom_field = that.$schedule.find('.sched-event-fulldescription[data-event-id='+$event.attr('data-event-id')+'] .sched-meta-field[data-meta-field-id='+logic.source_custom_field+']'); 454 455 if($custom_field.length === 0) { 456 break; 457 } 458 459 var line_1 = $custom_field.attr('data-meta-field-line-one'), 460 line_2 = $custom_field.attr('data-meta-field-line-two'); 461 462 if(that.sort_logic_custom_field_line(logic.source_custom_field_line, line_1, line_2, logic.matches, logic.method)) { 463 // Show the event 464 $event.addClass('sched-event-sort-visible'); 465 return; // Skip rest of logic, this one is good 466 } 467 468 break; 469 case 'custom_field': 470 var $custom_fields = that.$schedule.find('.sched-event-fulldescription[data-event-id='+$event.attr('data-event-id')+'] .sched-meta-field'); 471 472 var done = false; 473 $custom_fields.each(function() { 474 var $custom_field = $(this), 475 line_1 = $custom_field.attr('data-meta-field-line-one'), 476 line_2 = $custom_field.attr('data-meta-field-line-two'); 477 478 if(that.sort_logic_custom_field_line(logic.source_custom_field_line, line_1, line_2, logic.matches, logic.method)) { 479 // Show the event 480 done = true; 481 return; // Skip rest of custom fields 482 } 483 }); 484 485 if(done === true) { 486 $event.addClass('sched-event-sort-visible'); 487 return; // Skip rest of logic, this one is good 488 } 489 490 break; 491 } 492 493 } 494 495 }); 496 497 this.$events.each(function() { 498 499 500 501 var $event = $(this); 502 503 if($event.hasClass('sched-event-sort-visible') && $event.hasClass('sched-event-sort-hidden')) { 504 505 // If currently hidden and should be visible, make visible 506 that.sort_show_event($event); 507 508 }else if($event.hasClass('sched-event-sort-visible') && !$event.hasClass('sched-event-sort-hidden')) { 509 510 // If currently visible and should be visible, do nothing 511 512 }else if(!$event.hasClass('sched-event-sort-visible') && $event.hasClass('sched-event-sort-hidden')) { 513 514 // If currently hidden and should be hidden, do nothing 515 516 }else { 517 518 // Else it shouldn't be visible and is not hidden, make invisible 519 that.sort_hide_event($event); 520 521 } 522 523 $event.removeClass('sched-event-sort-visible'); 524 }); 525 } 526 527 Schedule.prototype.sort_logic_title = function(title, matches, method) { 528 switch (method) { 529 case 'equals': 530 return sched_equals(matches, title); 531 break; 532 case 'not_equals': 533 return sched_not_equals(matches, title); 534 break; 535 case 'contains': 536 return sched_contains(matches, title); 537 break; 538 } 539 } 540 541 Schedule.prototype.sort_logic_custom_field_line = function(which_line, line_1, line_2, matches, method) { 542 switch (which_line) { 543 case 'line_1': 544 switch (method) { 545 case 'equals': 546 return sched_equals(matches, line_1); 547 break; 548 case 'not_equals': 549 return sched_not_equals(matches, line_1); 550 break; 551 case 'contains': 552 return sched_contains(matches, line_1); 553 break; 554 } 555 break; 556 case 'line_2': 557 switch (method) { 558 case 'equals': 559 return sched_equals(matches, line_2); 560 break; 561 case 'not_equals': 562 return sched_not_equals(matches, line_2); 563 break; 564 case 'contains': 565 return sched_contains(matches, line_2); 566 break; 567 } 568 break; 569 case 'line_1_or_2': 570 switch (method) { 571 case 'equals': 572 return sched_equals(matches, line_1) || sched_equals(matches, line_2); 573 break; 574 case 'not_equals': 575 return sched_not_equals(matches, line_1) || sched_not_equals(matches, line_2); 576 break; 577 case 'contains': 578 return sched_contains(matches, line_1) || sched_contains(matches, line_2); 579 break; 580 } 581 break; 582 } 583 } 584 585 Schedule.prototype.sort_hide_event = function($event) { 586 587 var set_opacity = (this.options.filter_hidden_events == 'hide') ? 0 : parseFloat(this.options.filter_hidden_events_opacity)/100; 588 589 $event.stop() 590 .addClass('sched-event-sort-hidden') 591 .animate({
592 'opacity': set_opacity 593 }, 100, function() { 594 if(set_opacity === 0) { 595 $event.css('display', 'none'); 596 } 597 }); 598 599 if(this.$schedule_list !== false) { 600 if(this.options.filter_hidden_events == 'hide') { 601 $event.data('$list_event').stop().slideUp(100); 602 }else { 603 $event.data('$list_event').animate({ 604 'opacity': set_opacity 605 }, 100); 606 } 607 } 608 } 609 610 Schedule.prototype.sort_show_event = function($event) { 611 $event.stop() 612 .removeClass('sched-event-sort-hidden') 613 .css('display', 'block') 614 .animate({ 615 'opacity': 1 616 }, 100); 617 618 if(this.$schedule_list !== false) { 619 if(this.options.filter_hidden_events == 'hide') { 620 $event.data('$list_event').stop().slideDown(100); 621 }else { 622 $event.data('$list_event').animate({ 623 'opacity': 1 624 }, 100); 625 } 626 } 627 628 629 630 } 631 632 Schedule.prototype.init_event = function($event) { 633 var that = this; 634 635 //var color = $event.attr('data-color'); 636 $event.attr('data-padding', that.info.event_box_padding).find('.sched-event-inner').css({ 637 'padding-left': that.info.event_box_padding+6, 638 'padding-right': that.info.event_box_padding+6, 639 }); 640 641 if(that.$schedule_list !== false) { 642 $event.data('$list_event', that.$schedule_list.find('.sched-list-event[data-event-id='+$event.attr('data-event-id')+']')); 643 $event.data('$list_event').data('$event', $event); 644 } 645 646 if(this.options.event_box_style == 1 && !$event.hasClass('sched-event-image-bg')) { 647 if($event.attr('data-onclick') !== '0' || that.editor_mode) { 648 $event.hover(function() { 649 if(that.options.event_hover_color == 'custom') { 650 $event.find('.sched-event-inner') 651 .css('background', that.options.event_hover_background_color) 652 .css('color', that.options.event_hover_text_color); 653 654 }else if(that.options.event_hover_color == 'lighten') { 655 $event.find('.sched-event-inner').css('background', sched_color_lighten($event.attr('data-color'), 20)); 656 }else if(that.options.event_hover_color == 'darken') { 657 $event.find('.sched-event-inner').css('background', sched_color_darken($event.attr('data-color'), 20)); 658 } 659 660 }, function() { 661 $event.find('.sched-event-inner') 662 .css('background', $event.attr('data-color')) 663 .css('color', that.options.event_box_text_color); 664 }); 665 } 666 }else if(this.options.event_box_style == 2 && !$event.hasClass('sched-event-image-bg')) { 667 var $event_inner = $event.find('.sched-event-inner'); 668 669 $event_inner.css('background', sched_color_lighten($event.attr('data-color'), that.info.style_lighten_amount)); 670 $event.find('.sched-event-inner-bar').css('background', $event.attr('data-color')); 671 672 if($event.attr('data-onclick') !== '0' || that.editor_mode) { 673 $event.hover(function() { 674 $event_inner.css('background', $event.attr('data-color')).css('color', '#ffffff'); 675 }, function() { 676 $event_inner.css('background', sched_color_lighten($event.attr('data-color'), that.info.style_lighten_amount)).css('color', $event.attr('data-color')); 677 }); 678 } 679 }else if($event.hasClass('sched-event-image-bg')) { 680 681 } 682 683 if(this.options.title_attr == 0) { 684 $event.removeAttr('title'); 685 } 686 687 if(this.options.event_tooltip == 1 && $event.find('.sched-event-tooltip > div').length > 1 && (!this.info.mobile || this.options.tooltips_mobile == 1)) { 688 $event.find('.sched-event-inner').hover(function() { 689 var $tooltip = $event.find('.sched-event-tooltip'), 690 tooltip_height = $tooltip.innerHeight(); 691 692 if(that.options.event_tooltip_width_type == 'event') { 693 $tooltip.css('width', $tooltip.parent().innerWidth()-1); 694 } 695 696 if($tooltip.hasClass('sched-event-tooltip-first-child')) { 697 $tooltip.css('width', $tooltip.innerWidth()-1); 698 }else { 699 //$tooltip.css('left', -1); 700 } 701 702 var tooltip_width = $tooltip.innerWidth(), 703 event_width = $event.innerWidth(); 704 705 $tooltip.css('left', Math.floor((event_width-tooltip_width)/2)); 706 707 $tooltip.stop().css({ 708 'top': -tooltip_height-5, 709 'display': 'block', 710 'opacity': 0 711 }).animate({ 712 'top': -tooltip_height-10, 713 'opacity': 1 714 }, 150); 715 716 }, function() { 717 718 var $tooltip = $event.find('.sched-event-tooltip'), 719 tooltip_height = $tooltip.innerHeight(); 720 721 $tooltip.stop().animate({ 722 'top': -tooltip_height-15, 723 'opacity': 0 724 }, 150, function() { 725 $tooltip.css({ 726 'display': 'none', 727 'opacity': 1 728 }) 729 }); 730 }); 731 } 732 733 if(this.editor_mode && this.options.editor_quick_tooltips == 1) { 734 var $popup = $($event.find('.sched-event-edit-tooltip-html').html()); 735 736 var original_color = $popup.find('.sched-color-picker').val(); 737 $popup.find('.sched-color-picker').wpColorPicker({ 738 palettes: false, 739 change: function(event, ui) {
740 var new_color = ui.color.toString(); 741 $event.attr('data-color', new_color); 742 if(that.options.event_box_style == 1) { 743 $event.find('.sched-event-inner').css('background', new_color); 744 }else if(that.options.event_box_style == 2) { 745 $event.find('.sched-event-inner').css('color', new_color).css('background', sched_color_lighten(new_color, that.info.style_lighten_amount)); 746 $event.find('.sched-event-inner-bar').css('background', new_color); 747 } 748 749 }, 750 clear: function() { 751 $popup.find('.sched-color-picker').wpColorPicker('color', original_color) 752 } 753 }); 754 $popup.find('.sched-event-edit-tooltip-submit').click(function() { 755 $popup.find('form').submit(); 756 }); 757 $popup.find('.sched-event-edit-tooltip-edit').click(function(e) { 758 e.preventDefault(); 759 sched_open_event_editor($event.attr('data-event-id')); 760 }); 761 $popup.find('.sched-event-edit-tooltip-duplicate').click(function(e) { 762 e.preventDefault(); 763 sched_open_event_copy($event.attr('data-event-id')); 764 }); 765 $popup.find('.sched-event-edit-tooltip-delete').click(function(e) { 766 e.preventDefault(); 767 if(!confirm('Are you sure you want to delete this event?')) { 768 return; 769 } 770 window.top.location = sched_action_url + '&method=delete_event&event_id='+$event.attr('data-event-id'); 771 }); 772 $popup.find("input[name=sched-event-edit-tooltip-title]").keyup(function (e) { 773 if(e.keyCode == 13) { 774 $popup.find('form').submit(); 775 } 776 }); 777 $popup.find('form').on('submit', function(e) { 778 e.preventDefault(); 779 780 $popup.find('.sched-event-edit-tooltip-submit').addClass('sched-button-grey').html('<i class="fa fa-spinner fa-spin"></i> Updating') 781 782 var start = encodeURIComponent($popup.find('select[name=sched-event-edit-tooltip-time-start]').val()), 783 end = encodeURIComponent($popup.find('select[name=sched-event-edit-tooltip-time-end]').val()), 784 id = parseFloat($popup.find('input[name=sched-event-edit-tooltip-id]').val()), 785 column = parseFloat($popup.find('select[name=sched-event-edit-tooltip-column]').val()), 786 title = encodeURIComponent($popup.find('input[name=sched-event-edit-tooltip-title]').val()), 787 color = encodeURIComponent($popup.find('input[name=sched-event-edit-tooltip-color]').val()); 788 789 var url = sched_ajax_url + '&method=ajax_update_event_tooltip&id='+schedule_id+'&event_id='+id+'&start='+start+'&column='+column+'&end='+end+'&title='+title+'&color='+color; 790 $.get(url, function(result) { 791 result = $.parseJSON(result); 792 setTimeout(function() { 793 $popup.find('.sched-event-edit-tooltip-submit').removeClass('sched-button-grey').removeClass('sched-button-red').html('<i class="fa fa-save"></i> Save'); 794 }, 1000); 795 if(result == null || typeof(result.success) == 'undefined' || result.success != '1') { 796 $popup.find('.sched-event-edit-tooltip-submit').removeClass('sched-button-grey').addClass('sched-button-red').html('<i class="fa fa-times"></i> An Error Occured'); 797 return; 798 } 799 $popup.find('.sched-event-edit-tooltip-submit').html('<i class="fa fa-check"></i> Done'); 800 801 802 if(parseFloat($event.closest('.sched-column').attr('data-column-id')) !== result.column) { 803 var $column = that.$schedule.find('.sched-column[data-column-id='+result.column+'] .sched-column-content'); 804 $event.appendTo($column); 805 that.$schedule.find('.sched-event-fulldescription[data-event-id='+result.event_id+']').appendTo($column); 806 } 807 808 $event.animate({ 809 top: result.top, 810 height: result.height 811 }, 300, function() { 812 // do a hard resize 813 that.info.previous_width = false; 814 that.resize(); 815 }); 816 $event.find('.sched-event-title, .sched-event-tooltip-title').html(result.title); 817 $event.find('.sched-event-subtitle, .sched-event-tooltip-time').html(result.time_string); 818 }); 819 }); 820 821 $event.hover(function() { 822 var offset = $event.offset(); 823 824 var position = { 825 left: offset.left-306, 826 top: offset.top + 5, 827 opacity: 0, 828 } 829 830 if($popup.hasClass('sched-event-edit-tooltip-right')) { 831 position = { 832 left: offset.left + $event.innerWidth()+6, 833 top: offset.top + 5, 834 opacity: 0, 835 } 836 } 837 838 $popup 839 .stop() 840 .css(position) 841 .appendTo($('body')) 842 .show() 843 .animate({ 844 opacity: 1, 845 top: offset.top 846 }, 150) 847 848 }, function() { 849 $popup 850 .hide() 851 852 }); 853 854 $popup.hover(function() { 855 $popup.stop().css('opacity', 1).show(); 856 }, function() { 857 $popup.stop().css('opacity', 1).hide(); 858 }) 859 } 860 }; 861 862 Schedule.prototype.init_column = function($column) { 863 var that = this; 864 865 if(this.options.title_attr == 0) { 866 $column.find('.sched-column-header').removeAttr('title'); 867 } 868 869 if(this.options.column_tooltip == 1 && $column.find('.sched-column-tooltip > div').length > 1 && (!this.info.mobile || this.options.tooltips_mobile == 1)) { 870 $column.find('.sched-column-header').hover(function() { 871 var $tooltip = $(this).siblings('.sched-column-tooltip'), 872 tooltip_height = $tooltip.innerHeight(); 873 874 if(that.options.column_tooltip_width_type == 'column') { 875 $tooltip.css('width', $tooltip.parent().innerWidth()-1); 876 } 877 878 var tooltip_width = $tooltip.innerWidth(), 879 column_width = $(this).innerWidth(); 880 $tooltip.css('left', Math.floor((column_width-tooltip_width)/2)); 881 882 883 $tooltip.stop().css({ 884 'top': -tooltip_height-5, 885 'display': 'block', 886 'opacity': 0 887 }).animate({ 888 'top': -tooltip_height-10, 889 'opacity': 1 890 }, 150); 891 892 }, function() { 893 var $tooltip = $(this).siblings('.sched-column-tooltip'), 894 tooltip_height = $tooltip.innerHeight(); 895 896 $tooltip.stop().animate({ 897 'top': -tooltip_height-15, 898 'opacity': 0 899 }, 150, function() { 900 $tooltip.css({ 901 'display': 'none', 902 'opacity': 1 903 }) 904 }); 905 }); 906 } 907 908 }; 909 910 Schedule.prototype.init_h_column = function($column) { 911 var that = this; 912 913 914 if(this.options.column_tooltip == 1 && $column.find('.sched-column-tooltip > div').length > 1 && (!this.info.mobile || this.options.tooltips_mobile == 1)) { 915 $column.hover(function() { 916 var $tooltip = $column.find('.sched-column-tooltip'), 917 tooltip_height = $tooltip.innerHeight(); 918 919 if(that.options.column_tooltip_width_type == 'column') { 920 $tooltip.css('width', $column.innerWidth()-1); 921 } 922 923 var tooltip_width = $tooltip.innerWidth(), 924 column_width = $column.innerWidth(); 925 $tooltip.css('left', Math.floor((column_width-tooltip_width)/2)); 926 927 928 $tooltip.stop().css({ 929 'top': -tooltip_height-5, 930 'display': 'block', 931 'opacity': 0 932 }).animate({ 933 'top': -tooltip_height-10, 934 'opacity': 1 935 }, 150); 936 937 }, function() { 938 var $tooltip = $column.find('.sched-column-tooltip'), 939 tooltip_height = $tooltip.innerHeight(); 940 941 $tooltip.stop().animate({ 942 'top': -tooltip_height-15, 943 'opacity': 0 944 }, 150, function() { 945 $tooltip.css({ 946 'display': 'none', 947 'opacity': 1 948 }) 949 }); 950 }); 951 } 952 } 953 954 Schedule.prototype.resize = function() { 955 var that = this; 956 this.resize_popup(); 957 958 var current_width = this.$schedule.innerWidth(); 959 if(this.info.type === 'list') { 960 current_width = this.$schedule_list.innerWidth(); 961 } 962 if(current_width == this.info.previous_width) { 963 return; 964 } 965 this.info.previous_width = current_width; 966 967 968 if(this.options.filter_position !== 'below_title_left') { 969 // var top_buttons_width = this.$schedule.find('.sched-top-buttons').innerWidth(); 970 var top_buttons_width = this.$schedule.find('.sched-download-button').innerWidth() + this.$schedule.find('.sched-sort').innerWidth(); 971 972 973 if(this.info.has_filters) { 974 top_buttons_width += this.info.filter_dropdown_open_width - this.info.filter_dropdown_closed_width; 975 } 976 var title_width = this.info.title_width, 977 margin_width = 90, 978 total_width = top_buttons_width + title_width + margin_width; 979 980 if(total_width > this.$schedule.find('.sched-top').innerWidth()) { 981 this.$schedule.find('.sched-top-buttons').removeClass('sched-top-buttons-right').addClass('sched-top-buttons-below-title'); 982 }else { 983 this.$schedule.find('.sched-top-buttons').removeClass('sched-top-buttons-below-title'); 984 if(this.options.filter_position === 'right') { 985 this.$schedule.find('.sched-top-buttons').addClass('sched-top-buttons-right'); 986 } 987 } 988 } 989 // console.log(this.$schedule.find('.sched-sort-dropdown').innerWidth(), this.info.filter_dropdown_open_width - this.info.filter_dropdown_closed_width, this.$schedule.find('.sched-download-button').innerWidth(), this.$schedule.innerWidth()) 990 // if(this.$schedule.find('.sched-sort').innerWidth() + this.info.filter_dropdown_open_width - this.info.filter_dropdown_closed_width + this.$schedule.find('.sched-download-button').innerWidth() + 100 > this.$schedule.innerWidth()) { 991 // this.$schedule.find('.sched-sort').addClass('sched-sort-clear') 992 // }else { 993 // this.$schedule.find('.sched-sort').removeClass('sched-sort-clear') 994 // } 995 // console.log(top_buttons_width, this.info.filter_dropdown_open_width, this.info.filter_dropdown_closed_width); 996 997 /*if(this.info.has_filters && this.options.filter_position !== 'below_title_left') { 998 var total_filter_width = this.info.filter_label_width + this.info.filter_dropdown_open_width, 999 title_width = this.info.title_width, 1000 margin_width = 32, 1001 total_width = total_filter_width + title_width + margin_width; 1002 1003 1004 if(total_width > this.$schedule.find('.sched-top').innerWidth()) { 1005 this.$schedule.find('.sched-sort').removeClass('sched-sort-right').addClass('sched-sort-below-title'); 1006 }else { 1007 this.$schedule.find('.sched-sort').removeClass('sched-sort-below-title'); 1008 if(this.options.filter_position === 'right') { 1009 this.$schedule.find('.sched-sort').addClass('sched-sort-right'); 1010 } 1011 } 1012 }*/ 1013 1014 if(this.options.columns_sticky_header == 1) { 1015 this.$schedule.find('.sched-column-header-sticky').each(function() {
1016 var $sticky = $(this); 1017 var $column_title = $sticky.siblings('.sched-column-header'); 1018 $sticky.css('width', $column_title.width()).css('top', parseFloat(that.options.columns_sticky_header_offset)); 1019 }); 1020 if(that.info.break_columns == true) { 1021 that.$schedule.removeClass('sched-sticky-header-visible'); 1022 } 1023 } 1024 1025 if(this.info.has_filters) { 1026 if(this.info.filter_label_width + this.info.filter_dropdown_open_width > this.$schedule.find('.sched-top').innerWidth()) { 1027 that.$schedule.find('.sched-sort-label').hide(); 1028 }else { 1029 that.$schedule.find('.sched-sort-label').show(); 1030 } 1031 } 1032 // Cut event descriptions 1033 this.$events.each(function() { 1034 var $event = $(this); 1035 1036 // var size = parseFloat($(this).attr('data-size')), 1037 // split = size === 1 ? 1 : (size-size%10)/10; 1038 1039 var event_width = $event.innerWidth(); 1040 if(event_width < that.info.event_box_padding_break) { 1041 $event.attr('data-padding', '0').find('.sched-event-inner').css({ 1042 'padding-left': 6, 1043 'padding-right': 6, 1044 }); 1045 }else { 1046 $event.attr('data-padding', that.info.event_box_padding).find('.sched-event-inner').css({ 1047 'padding-left': that.info.event_box_padding+6, 1048 'padding-right': that.info.event_box_padding+6, 1049 }); 1050 } 1051 1052 if((that.options.event_box_description_method == 'short' || that.options.event_box_description_method == 'full') && $event.find('.sched-event-description').length !== 0) { 1053 // Cut description if neccesarry 1054 var $description = $event.find('.sched-event-description'), 1055 description = $description.attr('data-full'), 1056 offset = $description.position(), 1057 padding_top = 6, 1058 event_height = $event.innerHeight() - offset.top - 6; 1059 1060 $description.html(description+'...'); 1061 1062 while ($description.innerHeight() > event_height) { 1063 if(description == '') { 1064 break; 1065 } 1066 1067 // Remove last word 1068 var lastIndex = description.lastIndexOf(" ") 1069 description = description.substring(0, lastIndex); 1070 1071 // Remove last character if it matches dot, comma or space 1072 var last_char = description.substr(description.length - 1); 1073 if(last_char == ',' || last_char == '.' || last_char == ' ') { 1074 description = description.slice(0, -1); 1075 } 1076 1077 $description.html(description+'...'); 1078 } 1079 1080 if(description == '') { 1081 $description.html(''); 1082 }else if(description == $description.attr('data-full')) { 1083 $description.html(description); 1084 } 1085 } 1086 }); 1087 1088 var columns_width = this.$schedule.find('.sched-row').first().innerWidth() - this.$schedule.find('.sched-row').first().find('.sched-sidebar').length * parseFloat(this.options.sidebar_width); 1089 1090 // 1091 if(this.info.type === 'list') { 1092 columns_width = this.$schedule_list.innerWidth() - this.$schedule.find('.sched-row').first().find('.sched-sidebar').length * parseFloat(this.options.sidebar_width); 1093 } 1094 1095 var column_width = columns_width/this.$columns.length; 1096 1097 1098 1099 if(this.options.column_break_action != 0 && !this.editor_mode && this.info.break_columns == false && column_width <= parseFloat(this.options.column_break_width)) { 1100 this.info.break_columns = true; 1101 1102 if(this.options.column_break_action === 'list') { 1103 this.show_list(); 1104 }else if(this.options.column_break_action === 'stack') { 1105 this.stack_columns(); 1106 } 1107 1108 1109 }else if(this.options.column_break_action != 0 && !this.editor_mode && this.info.break_columns == true && column_width > parseFloat(this.options.column_break_width)) { 1110 1111 this.info.break_columns = false; 1112 1113 if(this.options.column_break_action === 'list') { 1114 this.hide_list(); 1115 }else if(this.options.column_break_action === 'stack') { 1116 this.unstack_columns(); 1117 } 1118 1119 } 1120 1121 if(this.layout == 'horizontal' && this.options.h_break == 1 && !this.editor_mode) { 1122 var container_width = this.$schedule_list.innerWidth()-parseFloat(this.options.h_column_width); 1123 1124 if(this.info.type === 'full' && container_width < parseFloat(this.options.h_width_break_point)) { 1125 //convert to list 1126 this.show_list(); 1127 }else if(this.info.type === 'list' && container_width >= parseFloat(this.options.h_width_break_point)) { 1128 //convert to full 1129 this.hide_list(); 1130 } 1131 1132 } 1133 1134 }; 1135 1136 Schedule.prototype.resize_popup = function() { 1137 var popup_width = this.popup_width(), 1138 window_width = $(window).width(); 1139 1140 this.$popup.css({ 1141 'width': popup_width, 1142 'left': (window_width-popup_width)/2, 1143 }); 1144
1145 if(popup_width+240 <= window_width) { 1146 //show arrows 1147 this.$popup.find('.sched-popup-navigate-right, .sched-popup-navigate-left').show() 1148 this.$popup.find('.sched-popup-navigate-right').css('left', popup_width+30) 1149 }else { 1150 //hide arrows 1151 this.$popup.find('.sched-popup-navigate-right, .sched-popup-navigate-left').hide() 1152 } 1153 1154 var type = this.$popup.find('.sched-popup-media').attr('data-media-type'); 1155 if(type == 'youtube') { 1156 this.$popup.find('.sched-popup-media').css({ 1157 width: popup_width, 1158 height: popup_width/16*9 1159 }); 1160 this.$popup.find('.sched-popup-media iframe').attr('width', popup_width).attr('height', popup_width/16*9); 1161 }else { 1162 this.$popup.find('.sched-popup-media').css({ 1163 width: '100%', 1164 height: '' 1165 }); 1166 } 1167 1168 }; 1169 1170 Schedule.prototype.show_list = function() { 1171 this.info.type = 'list'; 1172 this.$schedule.addClass('sched-hidden'); 1173 this.$schedule_list.removeClass('sched-hidden'); 1174 this.$schedule.find('.sched-top-buttons').appendTo(this.$schedule_list.find('.sched-list-top')); 1175 if(this.options.pdf_enable_list == 0) { 1176 this.$schedule_list.find('.sched-top-buttons .sched-download-button').hide(); 1177 } 1178 1179 }; 1180 1181 Schedule.prototype.hide_list = function() { 1182 this.info.type = 'full'; 1183 this.$schedule_list.addClass('sched-hidden'); 1184 this.$schedule.removeClass('sched-hidden'); 1185 this.$schedule_list.find('.sched-top-buttons').appendTo(this.$schedule.find('.sched-top')); 1186 1187 if(this.options.pdf_enable_list == 0) { 1188 this.$schedule.find('.sched-top-buttons .sched-download-button').show(); 1189 } 1190 }; 1191 1192 Schedule.prototype.stack_columns = function() { 1193 var that = this, 1194 i = 0; 1195 this.$columns.each(function() { 1196 var $column = $(this); 1197 $column.css({ 1198 'width': '100%', 1199 'float': 'none', 1200 }); 1201 if(i == 0) { 1202 i++; 1203 return; 1204 } 1205 //var $row = $('<div class="sched-row" />').after(that.$schedule.find('.sched-row').last()); 1206 var $row = $('<div />').attr('class', that.$schedule.find('.sched-row').first().attr('class')).appendTo(that.$schedule); 1207 1208 that.$schedule.find('.sched-row').first().find('.sched-sidebar').clone().appendTo($row); 1209 1210 var $column_wrap = $('<div class="sched-columns" />').css({ 1211 'margin-left': that.$schedule.find('.sched-row').first().find('.sched-columns').css('margin-left'), 1212 'margin-right': that.$schedule.find('.sched-row').first().find('.sched-columns').css('margin-right'), 1213 }).appendTo($row); 1214 1215 $column.appendTo($column_wrap); 1216 1217 i++; 1218 }); 1219 1220 if(this.options.column_break_hide_sidebar == 1) { 1221 this.$schedule.find('.sched-top').css('margin-left', 0).css('margin-right', 0); 1222 this.$schedule.find('.sched-sidebar').hide(); 1223 this.$schedule.find('.sched-columns').css({ 1224 'margin-left': 0, 1225 'margin-right': 0, 1226 }); 1227 } 1228 }; 1229 1230 Schedule.prototype.unstack_columns = function() { 1231 var that = this, 1232 i = 0; 1233 1234 this.$columns.each(function() { 1235 var $column = $(this); 1236 $column.css({ 1237 'width': (100/that.$columns.length) + '%', 1238 'float': 'left', 1239 }); 1240 if(i == 0) { 1241 i++; 1242 return; 1243 } 1244 1245 var $row = $column.parent().parent(); 1246 $column.appendTo(that.$schedule.find('.sched-row').first().find('.sched-columns')); 1247 1248 1249 $row.remove(); 1250 1251 i++; 1252 }); 1253 1254 if(this.options.column_break_hide_sidebar == 1) { 1255 this.$schedule.find('.sched-top').css('margin-left', (this.options.sidebar_position == 'left' || this.options.sidebar_position == 'both') ? parseFloat(this.options.sidebar_width) : 0).css('margin-right', (this.options.sidebar_position == 'right' || this.options.sidebar_position == 'both') ? parseFloat(this.options.sidebar_width) : 0); 1256 this.$schedule.find('.sched-sidebar').show(); 1257 this.$schedule.find('.sched-columns').css({ 1258 'margin-left': (this.options.sidebar_position == 'left' || this.options.sidebar_position == 'both') ? parseFloat(this.options.sidebar_width) : 0, 1259 'margin-right': (this.options.sidebar_position == 'right' || this.options.sidebar_position == 'both') ? parseFloat(this.options.sidebar_width) : 0, 1260 }); 1261 1262 } 1263 }; 1264 1265 Schedule.prototype.open_event = function($event) { 1266 var that = this, 1267 position = $event.offset(), 1268 popup_width = this.popup_width(), 1269 event_id = $event.attr('data-event-id'), 1270 $popup = this.$popup,
1271 $overlay = this.$overlay, 1272 $event_description = this.$schedule.find('.sched-event-fulldescription[data-event-id='+event_id+']'), 1273 $event_inner = $event.find('.sched-event-inner'); 1274 1275 if($event_description.attr('data-media-type') == 'image') { 1276 $popup.addClass('sched-popup-has-image').find('.sched-popup-media') 1277 .attr('data-media-type', 'image') 1278 .html('<img src="'+$event_description.attr('data-media-link')+'" />'); 1279 }else if($event_description.attr('data-media-type') == 'youtube') { 1280 $popup.addClass('sched-popup-has-image').find('.sched-popup-media') 1281 .attr('data-media-type', 'youtube') 1282 .html('<i class="sched-icon sched-icon-spinner sched-icon-spin"></i>'); 1283 }else { 1284 $popup.removeClass('sched-popup-has-image').find('.sched-popup-media') 1285 .attr('data-media-type', '0') 1286 .html(''); 1287 1288 } 1289 this.$popup.attr('id', this.id+'-popup'); 1290 1291 this.resize_popup(); 1292 1293 $event_inner.css({ 1294 //'background': $event.attr('data-color'), 1295 'color': '' 1296 }); 1297 1298 $popup.find('.sched-popup-title').css({ 1299 'width': '', 1300 }); 1301 1302 var event_padding = parseFloat($event.attr('data-padding')) 1303 1304 $popup.find('.sched-popup-title').html('<div>'+$event.find('.sched-event-title').html()+'</div>').css({ 1305 'font-size': '14px', 1306 'line-height': '18px', 1307 'padding': '14px 20px 0px 20px', 1308 'padding-right': event_padding+6, 1309 'padding-left': event_padding+6, 1310 'height': $event.innerHeight()-14, 1311 'background-color': $event.attr('data-color'), 1312 'text-align': $event.find('.sched-event-inner').css('text-align'), 1313 'color': $event_inner.css('color'), 1314 'font-weight': 'bold' 1315 // $event.find('.sched-event-inner') 1316 }); 1317 1318 $popup.find('.sched-popup-close').css('color', $event_inner.css('color')) 1319 1320 var $popup_title_div = $popup.find('.sched-popup-title div'); 1321 1322 if(this.options.event_box_truncate_title == 1) { 1323 $popup_title_div.css({ 1324 'text-overflow': 'ellipsis', 1325 'white-space': 'nowrap', 1326 'overflow': 'hidden' 1327 }); 1328 } 1329 1330 this.bind_arrows($event, event_id); 1331 1332 var social_html = ''; 1333 //social_html = '<div class="sched-popup-social-buttons"><a href="#" class="sched-popup-social-button sched-popup-social-facebook"><i class="sched-icon sched-icon-facebook"></i></a><a href="#" class="sched-popup-social-button sched-popup-social-twitter"><i class="sched-icon sched-icon-twitter"></i></a><a href="#" class="sched-popup-social-button sched-popup-social-google-plus"><i class="sched-icon sched-icon-google-plus"></i></a></div>'; 1334 1335 var extra_html = ''; 1336 if(this.editor_mode) { 1337 extra_html = '<div class="sched-popup-buttons"><a href="'+sched_action_url + '&method=delete_event&event_id='+$event.attr('data-event-id')+'" class="sched-popup-delete-event sched-button sched-button-red" onclick="return confirm(\'Are you sure you want to delete this event\')" style="color: #e74c3c;"><i class="sched-icon sched-icon-times"></i>Delete Event</a><a href="#" class="sched-popup-edit-event sched-button" style="float: right;"><i class="sched-icon sched-icon-edit"></i>Edit Event</a></div>'; 1338 } 1339 1340 $popup.find('.sched-popup-description').html($event_description.html()+social_html+extra_html); 1341 1342 $popup.find('.sched-popup-edit-event').click(function(e) { 1343 e.preventDefault(); 1344 sched_open_event_editor($event.attr('data-event-id')); 1345 that.close_event(); 1346 }); 1347 1348 var fix_width_offset = 0; 1349 if($event.hasClass('sched-event-size-21') || $event.hasClass('sched-event-size-33')) { 1350 fix_width_offset = 1; 1351 } 1352 1353 $popup.css({ 1354 'width': $event_inner.innerWidth()-fix_width_offset, 1355 }); 1356 1357 if(this.info.type === 'list') { 1358 $popup.css('visibility', 'hidden'); 1359 }else { 1360 $popup.css('visibility', 'visible'); 1361 } 1362 1363 1364 var document_width = $(window).width(); 1365 1366 var animations_speed = this.info.type === 'full' ? that.info.animations_speed : 1; 1367 1368 $popup.css(position).fadeIn(that.info.animations_speed, function() { 1369 // return; 1370 $event.hide(); 1371 $popup.find('.sched-popup-title').animate({ 1372 'font-size': 18, 1373 'line-height': 18, 1374 'padding': 30, 1375 'height': '18', 1376 'width': popup_width-60, 1377 }, {duration: animations_speed}); 1378 1379 //$popup.show(); 1380 1381 1382 $popup.animate({ 1383 left: ($(window).width()-popup_width)/2, 1384 top: $(window).scrollTop()+that.info.popup_top_offset, 1385 }, animations_speed, function() { 1386 $popup.css('width', popup_width); 1387 1388 if(that.info.type === 'list') { 1389 $popup.css('visibility', 'visible'); 1390 } 1391 1392 1393 // $popup.find('.sched-popup-description > div, .sched-popup-description > p').css('visibility', 'hidden') 1394 $popup.find('.sched-popup-description').slideDown(that.info.animations_speed); 1395 $popup.addClass('sched-popup-done'); 1396 $popup.find('.sched-popup-title').css('width', ''); 1397 1398 that.info.open_event_id = ($event.attr('data-event-id')); 1399 1400 $popup.find('.sched-popup-media').slideDown(that.info.animations_speed, function() { 1401 if($event_description.attr('data-media-type') == 'youtube') { 1402 var autoplay = (that.options.autoplay_videos == 1) ? '?autoplay=1' : ''; 1403 $popup.find('.sched-popup-media').html('<iframe width="560" height="315" src="//www.youtube.com/embed/'+$event_description.attr('data-media-link')+autoplay+'" frameborder="0" allowfullscreen></iframe>'); 1404 that.resize_popup(); 1405 } 1406 }); 1407 }); 1408 that.show_overlay(); 1409 }); 1410 }; 1411 1412 Schedule.prototype.close_event = function(callback) { 1413 1414 1415 1416 if(!this.info.open_event_id) { 1417 return; 1418 } 1419 1420 var that = this, 1421 popup_width = this.popup_width() 1422 $event = this.$schedule.find(".sched-event[data-event-id="+this.info.open_event_id+"]"), 1423 $popup = this.$popup,
1424 $overlay = this.$overlay; 1425 1426 var position = $event 1427 .css({ 1428 'visibility': 'hidden', 1429 'display': 'block', 1430 }) 1431 .offset(); 1432 1433 $event.hide().css({ 1434 'visibility': '', 1435 }); 1436 1437 this.hide_overlay(); 1438 1439 if(this.options.hashtag_url == 1) { 1440 window.location.hash = '#rdv-calendar'; 1441 if(history.pushState) { 1442 //history.pushState(null, null, '#'); 1443 } 1444 else { 1445 //location.hash = '#'; 1446 } 1447 } 1448 1449 var fix_width_offset = 0; 1450 if($event.hasClass('sched-event-size-21') || $event.hasClass('sched-event-size-33')) { 1451 fix_width_offset = 1; 1452 } 1453 var event_padding = parseFloat($event.attr('data-padding')) 1454 $popup.removeClass('sched-popup-done'); 1455 $popup.find('.sched-popup-media').slideUp(this.info.animations_speed); 1456 $popup.find('.sched-popup-description').slideUp(this.info.animations_speed, function() { 1457 1458 var animations_speed = that.info.type === 'full' ? that.info.animations_speed : 1; 1459 1460 if(that.info.type === 'list') { 1461 $popup.css('visibility', 'hidden'); 1462 } 1463 $popup.find('.sched-popup-title').stop().animate({ 1464 'font-size': '14px', 1465 'line-height': '18px', 1466 'padding': '14px 20px 0px 20px', 1467 'padding-left': event_padding+6, 1468 'padding-right': event_padding+6, 1469 'height': $event.innerHeight()-14, 1470 'width': $event.innerWidth()-12-2*event_padding-1-fix_width_offset, 1471 }, animations_speed, function() { 1472 //return; 1473 $popup.find('.sched-popup-media').html(''); 1474 $event.show(); 1475 $popup.fadeOut(that.info.animations_speed); 1476 that.info.open_event_id = false; 1477 if(that.info.type === 'list') { 1478 //$popup.css('visibility', 'visible'); 1479 } 1480 if(typeof(callback) !== typeof(undefined)) { 1481 callback(); 1482 } 1483 }); 1484 $popup.css('width', '') 1485 $popup.animate(position, that.info.animations_speed); 1486 }); 1487 1488 }; 1489 1490 Schedule.prototype.find_next_event = function(event_id) { 1491 var $event = this.$schedule.find('.sched-event[data-event-id='+event_id+']'), 1492 sort_index = parseFloat($event.attr('data-sort-index')), 1493 $next_event = $event.siblings('.sched-event[data-sort-index='+(sort_index + 1)+']'); 1494 1495 if($next_event.length === 0) { 1496 return false; 1497 } 1498 1499 if($next_event.hasClass('sched-event-sort-hidden')) { 1500 $next_event = this.find_next_event($next_event.attr('data-event-id')) 1501 } 1502 1503 return $next_event; 1504 1505 } 1506 1507 Schedule.prototype.find_previous_event = function(event_id) { 1508 var $event = this.$schedule.find('.sched-event[data-event-id='+event_id+']'), 1509 sort_index = parseFloat($event.attr('data-sort-index')), 1510 $previous_event = $event.siblings('.sched-event[data-sort-index='+(sort_index - 1)+']'); 1511 1512 if($previous_event.length === 0) { 1513 return false; 1514 } 1515 1516 if($previous_event.hasClass('sched-event-sort-hidden')) { 1517 $previous_event = this.find_previous_event($previous_event.attr('data-event-id')) 1518 } 1519 1520 return $previous_event; 1521 1522 } 1523 1524 Schedule.prototype.queue_event = function($event) { 1525 var that = this; 1526 if($event !== false) { 1527 if(this.options.hashtag_url == 1) { 1528 //change url 1529 window.top.location.hash = 'event-'+$event.attr('data-event-id'); 1530 }else { 1531 //var hash = window.top.location.hash; 1532 this.close_event(function() { 1533 that.open_event($event); 1534 }); 1535 1536 } 1537 } 1538 1539 }; 1540 1541 Schedule.prototype.open_next_event = function($event, previous_event_id) { 1542 var that = this; 1543 1544 if($event == false) { 1545 return; 1546 } 1547 1548 if(this.options.hashtag_url == 0) { 1549 this.close_event(function() { 1550 that.open_event($event); 1551 }); 1552 return; 1553 } 1554 1555 that.info.hashchange_method = 'normal'; 1556 var $previous_event = this.$schedule.find('.sched-event[data-event-id='+previous_event_id+']'); 1557 1558 //change url 1559 //window.top.location.hash = 'event-'+$event.attr('data-event-id'); 1560 var offset = this.$popup.offset(), 1561 height = this.$popup.innerHeight() 1562 1563 this.$popup.animate({ 1564 top: offset.top-(offset.top-$(window).scrollTop())-height, 1565 }, this.info.animations_speed/1.5, function() { 1566 that.$popup.css('top', $(window).scrollTop()+$(window).height()) 1567 that.open_event_data($event, $previous_event) 1568 that.$popup.animate({ 1569 // 'top': offset.top 1570 'top': $(window).scrollTop()+that.info.popup_top_offset 1571 }, that.info.animations_speed/1.5) 1572 }); 1573 1574 } 1575 1576 Schedule.prototype.open_previous_event = function($event, previous_event_id) { 1577 var that = this; 1578 1579 if($event == false) { 1580 return; 1581 } 1582 1583 if(this.options.hashtag_url == 0) { 1584 this.close_event(function() { 1585 that.open_event($event); 1586 }); 1587 return; 1588 } 1589 1590 that.info.hashchange_method = 'normal'; 1591 var $previous_event = this.$schedule.find('.sched-event[data-event-id='+previous_event_id+']'); 1592 1593 //change url 1594 //window.top.location.hash = 'event-'+$event.attr('data-event-id'); 1595 var offset = this.$popup.offset(), 1596 height = this.$popup.innerHeight() 1597 1598 this.$popup.animate({ 1599 top: $(window).scrollTop()+$(window).height(), 1600 }, this.info.animations_speed/1.5, function() { 1601 that.$popup.css('top', offset.top-(offset.top-$(window).scrollTop())-height) 1602 that.open_event_data($event, $previous_event) 1603 that.$popup.animate({ 1604 // 'top': offset.top 1605 'top': $(window).scrollTop()+that.info.popup_top_offset 1606 }, that.info.animations_speed/1.5) 1607 }); 1608 1609 } 1610 1611 Schedule.prototype.open_event_data = function($event, $previous_event) { 1612 var that = this, 1613 event_id = $event.attr('data-event-id'), 1614 $popup = this.$popup, 1615 $event_description = this.$schedule.find('.sched-event-fulldescription[data-event-id='+event_id+']'), 1616 $event_inner = $event.find('.sched-event-inner'); 1617 1618 // $previous_event.fadeIn(this.info.animations_speed); 1619 // $event.fadeOut(this.info.animations_speed); 1620 1621 $previous_event.show(); 1622 $event.hide(); 1623 1624 if($event_description.attr('data-media-type') == 'image') { 1625 $popup.addClass('sched-popup-has-image').find('.sched-popup-media') 1626 .attr('data-media-type', 'image') 1627 .html('<img src="'+$event_description.attr('data-media-link')+'" />'); 1628 }else if($event_description.attr('data-media-type') == 'youtube') { 1629 $popup.addClass('sched-popup-has-image').find('.sched-popup-media') 1630 .attr('data-media-type', 'youtube') 1631 .html('<i class="sched-icon sched-icon-spinner sched-icon-spin"></i>'); 1632 }else { 1633 $popup.removeClass('sched-popup-has-image').find('.sched-popup-media') 1634 .attr('data-media-type', '0') 1635 .html(''); 1636 1637 } 1638 1639 this.resize_popup(); 1640 1641 $popup.find('.sched-popup-title').html('<div style="text-overflow: ellipsis; white-space: nowrap; overflow: hidden; color: '+that.options.event_box_text_color+'">'+$event.find('.sched-event-title').html()+'</div>').css({ 1642 'background-color': $event.attr('data-color'), 1643 'color': '', 1644 }); 1645 1646 $popup.find('.sched-popup-close').css('color', $event_inner.css('color')) 1647
1648 var $popup_title_div = $popup.find('.sched-popup-title div'); 1649 1650 this.bind_arrows($event, event_id); 1651 1652 1653 var social_html = ''; 1654 //social_html = '<div class="sched-popup-social-buttons"><a href="#" class="sched-popup-social-button sched-popup-social-facebook"><i class="sched-icon sched-icon-facebook"></i></a><a href="#" class="sched-popup-social-button sched-popup-social-twitter"><i class="sched-icon sched-icon-twitter"></i></a><a href="#" class="sched-popup-social-button sched-popup-social-google-plus"><i class="sched-icon sched-icon-google-plus"></i></a></div>'; 1655 1656 var extra_html = ''; 1657 if(this.editor_mode) { 1658 extra_html = '<div class="sched-popup-buttons"><a href="'+sched_action_url + '&method=delete_event&event_id='+$event.attr('data-event-id')+'" class="sched-popup-delete-event sched-button sched-button-red" onclick="return confirm(\'Are you sure you want to delete this event\')" style="color: #e74c3c;"><i class="sched-icon sched-icon-times"></i>Delete Event</a><a href="#" class="sched-popup-edit-event sched-button" style="float: right;"><i class="sched-icon sched-icon-edit"></i>Edit Event</a></div>'; 1659 } 1660 1661 $popup.find('.sched-popup-description').html($event_description.html()+social_html+extra_html); 1662 1663 $popup.find('.sched-popup-edit-event').click(function(e) { 1664 e.preventDefault(); 1665 sched_open_event_editor($event.attr('data-event-id')); 1666 that.close_event(); 1667 }); 1668 1669 // var document_width = $(document).width(); 1670 // $popup.css(position).fadeIn(that.info.animations_speed, function() { 1671 1672 // $event.hide(); 1673 // $popup.find('.sched-popup-title').animate({ 1674 // 'font-size': 18, 1675 // 'line-height': 18, 1676 // 'padding': 30, 1677 // 'height': '18', 1678 // 'width': popup_width-60, 1679 // }, {duration: that.info.animations_speed}); 1680 1681 // $popup.animate({ 1682 // left: ($(document).width()-popup_width)/2, 1683 // top: $(window).scrollTop()+that.info.popup_top_offset, 1684 // }, that.info.animations_speed, function() { 1685 // $popup.css('width', popup_width); 1686 1687 // $popup.find('.sched-popup-description').slideDown(that.info.animations_speed); 1688 // $popup.addClass('sched-popup-done'); 1689 // $popup.find('.sched-popup-title').css('width', ''); 1690 1691 that.info.open_event_id = event_id; 1692 1693 // $popup.find('.sched-popup-media').slideDown(that.info.animations_speed, function() { 1694 if($event_description.attr('data-media-type') == 'youtube') { 1695 var autoplay = (that.options.autoplay_videos == 1) ? '?autoplay=1' : ''; 1696 $popup.find('.sched-popup-media').html('<iframe width="560" height="315" src="//www.youtube.com/embed/'+$event_description.attr('data-media-link')+autoplay+'" frameborder="0" allowfullscreen></iframe>'); 1697 that.resize_popup(); 1698 } 1699 // }); 1700 // }); 1701 // that.show_overlay(); 1702 // }); 1703 } 1704 1705 Schedule.prototype.nudge_event_up = function() { 1706 var that = this; 1707 if(this.info.open_event_id === false || this.$popup.is(':animated')) { 1708 return; 1709 } 1710 var top = parseFloat(this.$popup.css('top')); 1711 this.$popup.animate({ 1712 top: top-10 1713 }, 100, function() { 1714 that.$popup.animate({ 1715 'top': top 1716 }, 50) 1717 }) 1718 }; 1719 1720 Schedule.prototype.nudge_event_down = function() { 1721 var that = this; 1722 if(this.info.open_event_id === false || this.$popup.is(':animated')) { 1723 return; 1724 } 1725 var top = parseFloat(this.$popup.css('top')); 1726 this.$popup.animate({ 1727 top: top+10 1728 }, 100, function() { 1729 that.$popup.animate({ 1730 'top': top 1731 }, 50) 1732 }) 1733 }; 1734 1735 Schedule.prototype.horizontal_scroll_update = function(pos) { 1736 // console.log(pos) 1737 } 1738 1739 Schedule.prototype.bind_arrows = function($event, event_id) { 1740 var that = this, 1741 $popup = this.$popup; 1742 1743 var next_event = this.find_next_event(event_id), 1744 previous_event = this.find_previous_event(event_id); 1745 1746 this.info.next_event = false; 1747 this.info.previous_event = false; 1748 1749 if(next_event !== false) { 1750 this.info.next_event = next_event; 1751 $popup.find('.sched-popup-navigate-right').show().unbind('click').bind('click', function() { 1752 that.info.hashchange_method = 'next'; 1753 that.queue_event(next_event); 1754 }); 1755 }else { 1756 $popup.find('.sched-popup-navigate-right').hide().unbind('click'); 1757 } 1758 1759 if(previous_event !== false) { 1760 this.info.previous_event = previous_event; 1761 $popup.find('.sched-popup-navigate-left').show().unbind('click').bind('click', function() { 1762 // that.queue_event(previous_event); 1763 that.info.hashchange_method = 'previous'; 1764 that.queue_event(previous_event); 1765 }); 1766 }else { 1767 $popup.find('.sched-popup-navigate-left').hide().unbind('click'); 1768 } 1769 } 1770
1771 Schedule.prototype.show_overlay = function(buttons) { 1772 if(typeof(buttons) === typeof(undefined)) { 1773 buttons = {left: false, right: false}; 1774 } 1775 if(!this.info.animations && false) { 1776 this.$overlay.removeClass('sched-popup-overlay-hide').css('display', 'block').css('opacity', .5); 1777 }else if(this.options.animations_css3 == 1 && !this.info.mobile) { 1778 this.$overlay.addClass('sched-popup-overlay-show'); 1779 }else { 1780 this.$overlay.stop().removeClass('sched-popup-overlay-hide').css('display', 'none').css('opacity', 1).fadeTo(500, .5); 1781 } 1782 1783 }; 1784 1785 Schedule.prototype.hide_overlay = function() { 1786 var that = this; 1787 if(!this.info.animations && false) { 1788 this.$overlay.hide(); 1789 }else if(this.options.animations_css3 == 1 && !this.info.mobile) { 1790 this.$overlay.removeClass('sched-popup-overlay-show'); 1791 this.$overlay.addClass('sched-popup-overlay-hide'); 1792 setTimeout(function() { 1793 that.$overlay.removeClass('sched-popup-overlay-hide'); 1794 }, 500) 1795 }else { 1796 this.$overlay.stop().css('display', 'block').fadeTo(500, 0, function() { 1797 that.$overlay.css('display', 'none'); 1798 }); 1799 } 1800 1801 }; 1802 1803 Schedule.prototype.popup_width = function() { 1804 var max_width = parseFloat(this.options.popup_max_width), 1805 width = $(window).width(); 1806 1807 if(width < max_width+20) { 1808 return width-20; 1809 } 1810 1811 return max_width; 1812 } 1813 1814})(jQuery); 1815 1816 1817function sched_equals(needle, haystack) { 1818 return haystack.trim().toLowerCase() == needle.toLowerCase(); 1819} 1820 1821function sched_not_equals(needle, haystack) { 1822 return !sched_equals(needle, haystack); 1823} 1824 1825function sched_contains(needle, haystack) { 1826 return haystack.toLowerCase().indexOf(needle.toLowerCase()) > -1; 1827} 1828 1829function sched_color_lighten(color, percent) { 1830 var C1 = new ColorMix.Color(color), 1831 C2 = new ColorMix.Color(255, 255, 255), 1832 mix = ColorMix.mix([C1, C2], [100-percent, percent]); 1833 return mix.toString('hex'); 1834} 1835 1836function sched_color_darken(color, percent) { 1837 var C1 = new ColorMix.Color(color), 1838 C2 = new ColorMix.Color(0, 0, 0), 1839 mix = ColorMix.mix([C1, C2], [100-percent, percent]); 1840 return mix.toString('hex'); 1841}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.