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