/*! * * Responsive Timetable for Wordpress * For Wordpress * * @author Rik de Vos * @link http://rikdevos.com/ * @version 1.7.0 * * This is not free software. Visit http://rikdevos.com/demos/wordpress-responsive-timetable/ to purchase a license * */ (function($){ var sched_url_opened = false; $(document).ready(function() { $("body").append('
'); $(".sched").each(function() { new Schedule($(this)); }); }); var Schedule = function($schedule) { var that = this; this.$schedule = $schedule; this.$columns = this.$schedule.find('.sched-column'); this.$events = this.$schedule.find('.sched-event'); this.$popup = $(".sched-popup"); this.$overlay = $(".sched-popup-overlay"); this.$sorts = this.$schedule.find('.sched-sort'); this.editor_mode = ($schedule.hasClass('sched-editor-mode')) ? true : false; this.id = this.$schedule.attr('id'); this.options = $.parseJSON(this.$schedule.attr('data-options')); this.info = { open_event_id: false, ios: ( navigator.userAgent.match(/(iPad|iPhone|iPod)/g) ? true : false ), mobile: ( navigator.userAgent.match(/(Android|webOS|iPad|iPhone|iPod|BlackBerry|Windows Phone)/g) ? true : false ), animations: true, animations_speed: 200, break_columns: false, popup_top_offset: 100, previous_width: 0, style_lighten_amount: 60, has_filters: that.$schedule.find('.sched-sort').length == 1, title_width: (that.$schedule.find('.sched-title').length === 0) ? 0 : that.$schedule.find('.sched-title').innerWidth(), filter_label_width: (that.$schedule.find('.sched-sort-label').length === 0) ? 0 : that.$schedule.find('.sched-sort-label').innerWidth(), filter_dropdown_closed_width: parseFloat(this.options.filter_dropdown_width)+38, filter_dropdown_open_width: parseFloat(this.options.filter_dropdown_hover_width)+18+38, hashchange_method: 'normal', next_event: false, previous_event: false, event_box_padding_break: 110, event_box_padding: 14, loader: this.$schedule.siblings('.sched-loader') } this.info.popup_top_offset = this.info.mobile ? 20 : this.info.popup_top_offset; this.info.animations = (this.options.animations == 0 || (this.info.mobile && this.options.animations_mobile == 0)) ? false : true; if(this.editor_mode) { if(this.options.animations_editor == 0) { this.info.animations = false; } } if(this.options.animations_speed == 'slow') { this.info.animations_speed = 280; }else if(this.options.animations_speed == 'normal') { this.info.animations_speed = 200; }else if(this.options.animations_speed == 'fast') { this.info.animations_speed = 150; } if(this.info.animations == 0) { this.info.animations_speed = 1; } this.init(); //$(window).on('resize', that.resize); setTimeout(function() { that.info.loader.remove(); that.$schedule.addClass('sched-visible'); }, 100); }; Schedule.prototype.init = function() { var that = this; $(window).on('resize', function() { that.resize(); }); if($('.sched[data-timetable-id='+this.$schedule.attr('data-timetable-id')+']').length > 1) { this.options.hashtag_url = 0; } //this.resize(); this.info.event_box_padding_break = parseFloat(this.options.event_box_padding_break); if(this.info.mobile) { this.$schedule.addClass('sched-is-mobile'); this.info.event_box_padding_break = 150; } if(this.info.ios) { this.$schedule.addClass('sched-is-ios'); } var style = this.$schedule.find('.sched-style').html(); if(style !== '') { $('').html(style).appendTo('head'); } this.$events.click(function(e) { var $this = $(this), click = $this.attr('data-onclick'); if(click == 'popup' || that.editor_mode) { e.preventDefault(); if(that.options.hashtag_url == 1) { //change url window.top.location.hash = 'event-'+$(this).attr('data-event-id'); }else { that.open_event($this); } }else if(click == '0') { e.preventDefault(); }else if(click == 'link') { } }); $(document).bind('keydown', function(e) { if(that.options.popup_arrows == 0) { return; } if(e.keyCode === 37 && that.info.previous_event !== false) { that.info.hashchange_method = 'previous'; that.queue_event(that.info.previous_event); e.preventDefault(); }else if(e.keyCode === 39 && that.info.next_event !== false) { that.info.hashchange_method = 'next'; that.queue_event(that.info.next_event); e.preventDefault(); }else if(e.keyCode === 37) { that.nudge_event_down(); e.preventDefault(); }else if(e.keyCode === 39) { that.nudge_event_up(); e.preventDefault(); } }); if(this.options.popup_arrows == 0 || this.info.mobile) { this.$popup.addClass('sched-popup-hide-arrows'); } this.$overlay.click(function(e) { e.preventDefault(); that.close_event(); }); this.$popup.find('.sched-popup-close').click(function(e) { e.preventDefault(); that.close_event(); }); this.$events.each(function() { that.init_event($(this)); }); this.$columns.each(function() { that.init_column($(this)); }); this.$sorts.each(function() { that.init_sort($(this)); }); $(document).keyup(function(e) { if(e.keyCode == 27) { that.close_event(); } }); this.resize(); 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) { var hash = window.top.location.hash.split('#event-'), event_id = parseFloat(hash[1]), $event = this.$schedule.find('.sched-event[data-event-id='+event_id+']'); if($event.length !== 0) { sched_url_opened = true; $('html, body').animate({ scrollTop: that.$schedule.offset().top }, 500, function() { that.open_event($event); }); } } if(this.options.hashtag_url == 1 ) { $(window).on('hashchange', function() { if(that.info.hashchange_method === 'normal') { if(that.info.open_event_id !== false) { var hash = window.top.location.hash; that.close_event(function() { window.top.location.hash = hash; }); //setTimeout(function() { // //}, 500); } if(window.top.location.hash !== '' && window.top.location.hash !== '#' && window.top.location.hash.split('#event-').length === 2) { var hash = window.top.location.hash.split('#event-'), event_id = parseFloat(hash[1]), $event = that.$schedule.find('.sched-event[data-event-id='+event_id+']'); if($event.length !== 0) { that.open_event($event); } /*else if($(".sched-event[data-event-id="+event_id+"]").length > 1) { 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".') }*/ } }else if(that.info.hashchange_method === 'next') { var hash = window.top.location.hash.split('#event-'), event_id = parseFloat(hash[1]), $event = that.$schedule.find('.sched-event[data-event-id='+event_id+']'); that.open_next_event($event, that.info.open_event_id); }else if(that.info.hashchange_method === 'previous') { var hash = window.top.location.hash.split('#event-'), event_id = parseFloat(hash[1]), $event = that.$schedule.find('.sched-event[data-event-id='+event_id+']'); that.open_previous_event($event, that.info.open_event_id); } }); } /*if(this.editor_mode) { var mouse_down_on_block = false, mouse_down_block_id = false; this.$schedule.mouseup(function(e) { if(mouse_down_on_block && $(e.target).hasClass('sched-column-bg-block-button')) { console.log($(e.target).attr('data-index')) } mouse_down_on_block = false; that.$schedule.find('.sched-column-bg-block-button-visible').removeClass('sched-column-bg-block-button-visible'); }); this.$schedule.find('.sched-column-bg-block-button').hover(function() { $(this).addClass('sched-column-bg-block-button-visible') }, function() { if(!mouse_down_on_block) { $(this).removeClass('sched-column-bg-block-button-visible') } }).mousedown(function(e) { mouse_down_on_block = true; console.log($(e.target).attr('data-index')); }).on('dragstart', function() { return false; }); }*/ }; Schedule.prototype.init_sort = function($sort) { var that = this, multisort = (this.options.filter_multiple == '1') ? true : false, $items = $sort.find('.sched-sort-item'); if(!this.info.mobile) { $sort.find('.sched-sort-dropdown').hover(function() { $sort.addClass('sched-sort-open'); }, function() { $sort.removeClass('sched-sort-open'); }); }else { $sort.find('.sched-sort-dropdown').click(function(e) { e.preventDefault(); var $target = $(e.target); if($target.parents('.sched-sort-dropdown-select').length == 0) { $sort.toggleClass('sched-sort-open'); } }); $sort.blur(function() { $sort.removeClass('sched-sort-open'); }); } $items.each(function() { var $item = $(this); $item.click(function() { $item.toggleClass('sched-sort-item-selected'); if($item.hasClass('sched-sort-item-selected')) { // Changed to 1 $sort.removeClass('sched-sort-empty'); if(!multisort) { // Uncheck other $item $items.each(function() { if($(this).html() === $item.html()) { return; } $(this).removeClass('sched-sort-item-selected'); }); } }else { // Changed to 0 if($sort.find('.sched-sort-item.sched-sort-item-selected').length === 0) { $sort.addClass('sched-sort-empty'); } } if(!multisort) { $sort.removeClass('sched-sort-open') // $sort.find('.sched-sort-dropdown-select').css('display', 'none'); // setTimeout(function() { // $sort.find('.sched-sort-dropdown-select').css('display', ''); // }, 300); } that.run_sort($sort); }); }); } Schedule.prototype.run_sort = function($sort) { var that = this; var $items_selected = $sort.find('.sched-sort-item.sched-sort-item-selected'); if($items_selected.length === 0) { $sort.find('.sched-sort-current-label').html($sort.attr('data-all-string')); //this.$schedule.find('.sched-event.sched-event-sort-hidden').removeClass('sched-event-sort-hidden'); //this.$events.removeClass('sched-event-sort-hidden'); this.$schedule.find('.sched-event.sched-event-sort-hidden').each(function() { that.sort_show_event($(this)); }); return; } var all_logic = []; var i = 0, current_string = ''; $items_selected.each(function() { // Run logic var logic = $.parseJSON($(this).attr('data-sort-item-json')); all_logic.push(logic); // Create String current_string += $(this).find('.sched-sort-item-label').html(); if(i !== $items_selected.length-1) { current_string += ', '; } i++; }); $sort.find('.sched-sort-current-label').html(current_string); this.sort_all_logic(all_logic); } Schedule.prototype.sort_all_logic = function(all_logic) { var that = this; this.$events.each(function() { var $event = $(this); //$event.removeClass('sched-event-sort-hidden'); for(var i = 0; i < all_logic.length; i++) { var logic = all_logic[i]; switch (logic.source) { case 'title': if($event.find('.sched-event-title').length !== 0 && that.sort_logic_title($event.find('.sched-event-title').html(), logic.matches, logic.method)) { // Show the event $event.addClass('sched-event-sort-visible'); return; // Skip rest of logic, this one is good } break; case 'specific_custom_field': 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+']'); if($custom_field.length === 0) { break; } var line_1 = $custom_field.attr('data-meta-field-line-one'), line_2 = $custom_field.attr('data-meta-field-line-two'); if(that.sort_logic_custom_field_line(logic.source_custom_field_line, line_1, line_2, logic.matches, logic.method)) { // Show the event $event.addClass('sched-event-sort-visible'); return; // Skip rest of logic, this one is good } break; case 'custom_field': var $custom_fields = that.$schedule.find('.sched-event-fulldescription[data-event-id='+$event.attr('data-event-id')+'] .sched-meta-field'); var done = false; $custom_fields.each(function() { var $custom_field = $(this), line_1 = $custom_field.attr('data-meta-field-line-one'), line_2 = $custom_field.attr('data-meta-field-line-two'); if(that.sort_logic_custom_field_line(logic.source_custom_field_line, line_1, line_2, logic.matches, logic.method)) { // Show the event done = true; return; // Skip rest of custom fields } }); if(done === true) { $event.addClass('sched-event-sort-visible'); return; // Skip rest of logic, this one is good } break; } } }); this.$events.each(function() { var $event = $(this); if($event.hasClass('sched-event-sort-visible') && $event.hasClass('sched-event-sort-hidden')) { // If currently hidden and should be visible, make visible that.sort_show_event($event); }else if($event.hasClass('sched-event-sort-visible') && !$event.hasClass('sched-event-sort-hidden')) { // If currently visible and should be visible, do nothing }else if(!$event.hasClass('sched-event-sort-visible') && $event.hasClass('sched-event-sort-hidden')) { // If currently hidden and should be hidden, do nothing }else { // Else it shouldn't be visible and is not hidden, make invisible that.sort_hide_event($event); } $event.removeClass('sched-event-sort-visible'); }); } Schedule.prototype.sort_logic_title = function(title, matches, method) { switch (method) { case 'equals': return sched_equals(matches, title); break; case 'not_equals': return sched_not_equals(matches, title); break; case 'contains': return sched_contains(matches, title); break; } } Schedule.prototype.sort_logic_custom_field_line = function(which_line, line_1, line_2, matches, method) { switch (which_line) { case 'line_1': switch (method) { case 'equals': return sched_equals(matches, line_1); break; case 'not_equals': return sched_not_equals(matches, line_1); break; case 'contains': return sched_contains(matches, line_1); break; } break; case 'line_2': switch (method) { case 'equals': return sched_equals(matches, line_2); break; case 'not_equals': return sched_not_equals(matches, line_2); break; case 'contains': return sched_contains(matches, line_2); break; } break; case 'line_1_or_2': switch (method) { case 'equals': return sched_equals(matches, line_1) || sched_equals(matches, line_2); break; case 'not_equals': return sched_not_equals(matches, line_1) || sched_not_equals(matches, line_2); break; case 'contains': return sched_contains(matches, line_1) || sched_contains(matches, line_2); break; } break; } } Schedule.prototype.sort_hide_event = function($event) { var that = this; var set_opacity = (that.options.filter_hidden_events == 'hide') ? 0 : parseFloat(that.options.filter_hidden_events_opacity)/100; $event.stop() .addClass('sched-event-sort-hidden') .animate({ 'opacity': set_opacity }, 100, function() { if(set_opacity === 0) { $event.css('display', 'none'); } }); } Schedule.prototype.sort_show_event = function($event) { $event.stop() .removeClass('sched-event-sort-hidden') .css('display', 'block') .animate({ 'opacity': 1 }, 100); } Schedule.prototype.init_event = function($event) { var that = this; //var color = $event.attr('data-color'); $event.attr('data-padding', that.info.event_box_padding).find('.sched-event-inner').css({ 'padding-left': that.info.event_box_padding+6, 'padding-right': that.info.event_box_padding+6, }); if(this.options.event_box_style == 1 && !$event.hasClass('sched-event-image-bg')) { if($event.attr('data-onclick') !== '0' || that.editor_mode) { $event.hover(function() { if(that.options.event_hover_color == 'custom') { $event.find('.sched-event-inner') .css('background', that.options.event_hover_background_color) .css('color', that.options.event_hover_text_color); }else if(that.options.event_hover_color == 'lighten') { $event.find('.sched-event-inner').css('background', sched_color_lighten($event.attr('data-color'), 20)); }else if(that.options.event_hover_color == 'darken') { $event.find('.sched-event-inner').css('background', sched_color_darken($event.attr('data-color'), 20)); } }, function() { $event.find('.sched-event-inner') .css('background', $event.attr('data-color')) .css('color', that.options.event_box_text_color); }); } }else if(this.options.event_box_style == 2 && !$event.hasClass('sched-event-image-bg')) { var $event_inner = $event.find('.sched-event-inner'); $event_inner.css('background', sched_color_lighten($event.attr('data-color'), that.info.style_lighten_amount)); $event.find('.sched-event-inner-bar').css('background', $event.attr('data-color')); if($event.attr('data-onclick') !== '0' || that.editor_mode) { $event.hover(function() { $event_inner.css('background', $event.attr('data-color')).css('color', '#ffffff'); }, function() { $event_inner.css('background', sched_color_lighten($event.attr('data-color'), that.info.style_lighten_amount)).css('color', $event.attr('data-color')); }); } }else if($event.hasClass('sched-event-image-bg')) { } if(this.options.title_attr == 0) { $event.removeAttr('title'); } if(this.options.event_tooltip == 1 && $event.find('.sched-event-tooltip > div').length > 1 && (!this.info.mobile || this.options.tooltips_mobile == 1)) { $event.find('.sched-event-inner').hover(function() { var $tooltip = $event.find('.sched-event-tooltip'), tooltip_height = $tooltip.innerHeight(); if(that.options.event_tooltip_width_type == 'event') { $tooltip.css('width', $tooltip.parent().innerWidth()-1); } if($tooltip.hasClass('sched-event-tooltip-first-child')) { $tooltip.css('width', $tooltip.innerWidth()-1); }else { //$tooltip.css('left', -1); } var tooltip_width = $tooltip.innerWidth(), event_width = $event.innerWidth(); $tooltip.css('left', Math.floor((event_width-tooltip_width)/2)); $tooltip.stop().css({ 'top': -tooltip_height-5, 'display': 'block', 'opacity': 0 }).animate({ 'top': -tooltip_height-10, 'opacity': 1 }, 150); }, function() { var $tooltip = $event.find('.sched-event-tooltip'), tooltip_height = $tooltip.innerHeight(); $tooltip.stop().animate({ 'top': -tooltip_height-15, 'opacity': 0 }, 150, function() { $tooltip.css({ 'display': 'none', 'opacity': 1 }) }); }); } if(this.editor_mode && this.options.editor_quick_tooltips == 1) { var $popup = $($event.find('.sched-event-edit-tooltip-html').html()); var original_color = $popup.find('.sched-color-picker').val(); $popup.find('.sched-color-picker').wpColorPicker({ palettes: false, change: function(event, ui) { var new_color = ui.color.toString(); $event.attr('data-color', new_color); if(that.options.event_box_style == 1) { $event.find('.sched-event-inner').css('background', new_color); }else if(that.options.event_box_style == 2) { $event.find('.sched-event-inner').css('color', new_color).css('background', sched_color_lighten(new_color, that.info.style_lighten_amount)); $event.find('.sched-event-inner-bar').css('background', new_color); } }, clear: function() { $popup.find('.sched-color-picker').wpColorPicker('color', original_color) } }); $popup.find('.sched-event-edit-tooltip-submit').click(function() { $popup.find('form').submit(); }); $popup.find("input[name=sched-event-edit-tooltip-title]").keyup(function (e) { if(e.keyCode == 13) { $popup.find('form').submit(); } }); $popup.find('form').on('submit', function(e) { e.preventDefault(); $popup.find('.sched-event-edit-tooltip-submit').addClass('sched-button-grey').html(' Updating') var start = encodeURIComponent($popup.find('select[name=sched-event-edit-tooltip-time-start]').val()), end = encodeURIComponent($popup.find('select[name=sched-event-edit-tooltip-time-end]').val()), id = parseFloat($popup.find('input[name=sched-event-edit-tooltip-id]').val()), column = parseFloat($popup.find('select[name=sched-event-edit-tooltip-column]').val()), title = encodeURIComponent($popup.find('input[name=sched-event-edit-tooltip-title]').val()), color = encodeURIComponent($popup.find('input[name=sched-event-edit-tooltip-color]').val()); 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; $.get(url, function(result) { result = $.parseJSON(result); setTimeout(function() { $popup.find('.sched-event-edit-tooltip-submit').removeClass('sched-button-grey').removeClass('sched-button-red').html(' Save'); }, 1000); if(result == null || typeof(result.success) == 'undefined' || result.success != '1') { $popup.find('.sched-event-edit-tooltip-submit').removeClass('sched-button-grey').addClass('sched-button-red').html(' An Error Occured'); return; } $popup.find('.sched-event-edit-tooltip-submit').html(' Done'); if(parseFloat($event.closest('.sched-column').attr('data-column-id')) !== result.column) { var $column = that.$schedule.find('.sched-column[data-column-id='+result.column+'] .sched-column-content'); $event.appendTo($column); that.$schedule.find('.sched-event-fulldescription[data-event-id='+result.event_id+']').appendTo($column); } $event.animate({ top: result.top, height: result.height }, 300, function() { // do a hard resize that.info.previous_width = false; that.resize(); }); $event.find('.sched-event-title, .sched-event-tooltip-title').html(result.title); $event.find('.sched-event-subtitle, .sched-event-tooltip-time').html(result.time_string); }); }); $event.hover(function() { var offset = $event.offset(); var position = { left: offset.left-306, top: offset.top + 5, opacity: 0, } if($popup.hasClass('sched-event-edit-tooltip-right')) { position = { left: offset.left + $event.innerWidth()+6, top: offset.top + 5, opacity: 0, } } $popup .stop() .css(position) .appendTo($('body')) .show() .animate({ opacity: 1, top: offset.top }, 150) }, function() { $popup .hide() }); $popup.hover(function() { $popup.stop().css('opacity', 1).show(); }, function() { $popup.stop().css('opacity', 1).hide(); }) } }; Schedule.prototype.init_column = function($column) { var that = this; if(this.options.title_attr == 0) { $column.find('.sched-column-header').removeAttr('title'); } if(this.options.column_tooltip == 1 && $column.find('.sched-column-tooltip > div').length > 1 && (!this.info.mobile || this.options.tooltips_mobile == 1)) { $column.find('.sched-column-header').hover(function() { var $tooltip = $(this).siblings('.sched-column-tooltip'), tooltip_height = $tooltip.innerHeight(); if(that.options.column_tooltip_width_type == 'column') { $tooltip.css('width', $tooltip.parent().innerWidth()-1); } var tooltip_width = $tooltip.innerWidth(), column_width = $(this).innerWidth(); $tooltip.css('left', Math.floor((column_width-tooltip_width)/2)); $tooltip.stop().css({ 'top': -tooltip_height-5, 'display': 'block', 'opacity': 0 }).animate({ 'top': -tooltip_height-10, 'opacity': 1 }, 150); }, function() { var $tooltip = $(this).siblings('.sched-column-tooltip'), tooltip_height = $tooltip.innerHeight(); $tooltip.stop().animate({ 'top': -tooltip_height-15, 'opacity': 0 }, 150, function() { $tooltip.css({ 'display': 'none', 'opacity': 1 }) }); }); } }; Schedule.prototype.resize = function() { var that = this; this.resize_popup(); var current_width = this.$schedule.innerWidth(); if(current_width == this.info.previous_width) { return; } this.info.previous_width = current_width; if(this.info.has_filters && this.options.filter_position !== 'below_title_left') { var total_filter_width = this.info.filter_label_width + this.info.filter_dropdown_open_width, title_width = this.info.title_width, margin_width = 32, total_width = total_filter_width + title_width + margin_width; if(total_width > this.$schedule.find('.sched-top').innerWidth()) { // Snap To Bottom this.$schedule.find('.sched-sort').removeClass('sched-sort-right').addClass('sched-sort-below-title'); }else { // Left/right position this.$schedule.find('.sched-sort').removeClass('sched-sort-below-title'); if(this.options.filter_position === 'right') { this.$schedule.find('.sched-sort').addClass('sched-sort-right'); } } } if(this.info.has_filters) { if(this.info.filter_label_width + this.info.filter_dropdown_open_width > this.$schedule.find('.sched-top').innerWidth()) { that.$schedule.find('.sched-sort-label').hide(); }else { that.$schedule.find('.sched-sort-label').show(); } } // Cut event descriptions this.$events.each(function() { var $event = $(this); // var size = parseFloat($(this).attr('data-size')), // split = size === 1 ? 1 : (size-size%10)/10; var event_width = $event.innerWidth(); if(event_width < that.info.event_box_padding_break) { $event.attr('data-padding', '0').find('.sched-event-inner').css({ 'padding-left': 6, 'padding-right': 6, }); }else { $event.attr('data-padding', that.info.event_box_padding).find('.sched-event-inner').css({ 'padding-left': that.info.event_box_padding+6, 'padding-right': that.info.event_box_padding+6, }); } if((that.options.event_box_description_method == 'short' || that.options.event_box_description_method == 'full') && $event.find('.sched-event-description').length !== 0) { // Cut description if neccesarry var $description = $event.find('.sched-event-description'), description = $description.attr('data-full'), offset = $description.position(), padding_top = 6, event_height = $event.innerHeight() - offset.top - 6; $description.html(description+'...'); while ($description.innerHeight() > event_height) { if(description == '') { break; } // Remove last word var lastIndex = description.lastIndexOf(" ") description = description.substring(0, lastIndex); // Remove last character if it matches dot, comma or space var last_char = description.substr(description.length - 1); if(last_char == ',' || last_char == '.' || last_char == ' ') { description = description.slice(0, -1); } $description.html(description+'...'); } if(description == '') { $description.html(''); }else if(description == $description.attr('data-full')) { $description.html(description); } } }) 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); var column_width = columns_width/this.$columns.length; if(this.options.column_break != 0 && !this.editor_mode && this.info.break_columns == false && column_width <= parseFloat(this.options.column_break_width)) { this.info.break_columns = true; var i = 0; this.$columns.each(function() { var $column = $(this); $column.css({ 'width': '100%', 'float': 'none', }); if(i == 0) { i++; return; } //var $row = $('').after(that.$schedule.find('.sched-row').last()); var $row = $('').attr('class', that.$schedule.find('.sched-row').first().attr('class')).appendTo(that.$schedule); that.$schedule.find('.sched-row').first().find('.sched-sidebar').clone().appendTo($row); var $column_wrap = $('').css({ 'margin-left': that.$schedule.find('.sched-row').first().find('.sched-columns').css('margin-left'), 'margin-right': that.$schedule.find('.sched-row').first().find('.sched-columns').css('margin-right'), }).appendTo($row); $column.appendTo($column_wrap); i++; }); if(this.options.column_break_hide_sidebar == 1) { this.$schedule.find('.sched-top').css('margin-left', 0).css('margin-right', 0); this.$schedule.find('.sched-sidebar').hide(); this.$schedule.find('.sched-columns').css({ 'margin-left': 0, 'margin-right': 0, }); } }else if(this.options.column_break != 0 && !this.editor_mode && this.info.break_columns == true && column_width > parseFloat(this.options.column_break_width)) { this.info.break_columns = false; var i = 0; this.$columns.each(function() { var $column = $(this); $column.css({ 'width': (100/that.$columns.length) + '%', 'float': 'left', }); if(i == 0) { i++; return; } var $row = $column.parent().parent(); $column.appendTo(that.$schedule.find('.sched-row').first().find('.sched-columns')); $row.remove(); i++; }); if(this.options.column_break_hide_sidebar == 1) { 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); this.$schedule.find('.sched-sidebar').show(); this.$schedule.find('.sched-columns').css({ 'margin-left': (this.options.sidebar_position == 'left' || this.options.sidebar_position == 'both') ? parseFloat(this.options.sidebar_width) : 0, 'margin-right': (this.options.sidebar_position == 'right' || this.options.sidebar_position == 'both') ? parseFloat(this.options.sidebar_width) : 0, }); } } }; Schedule.prototype.resize_popup = function() { var popup_width = this.popup_width(), window_width = $(window).width(); this.$popup.css({ 'width': popup_width, 'left': (window_width-popup_width)/2, }); if(popup_width+240 <= window_width) { //show arrows this.$popup.find('.sched-popup-navigate-right, .sched-popup-navigate-left').show() this.$popup.find('.sched-popup-navigate-right').css('left', popup_width+30) }else { //hide arrows this.$popup.find('.sched-popup-navigate-right, .sched-popup-navigate-left').hide() } var type = this.$popup.find('.sched-popup-media').attr('data-media-type'); if(type == 'youtube') { this.$popup.find('.sched-popup-media').css({ width: popup_width, height: popup_width/16*9 }); this.$popup.find('.sched-popup-media iframe').attr('width', popup_width).attr('height', popup_width/16*9); }else { this.$popup.find('.sched-popup-media').css({ width: '100%', height: '' }); } }; Schedule.prototype.open_event = function($event) { var that = this, position = $event.offset(), popup_width = this.popup_width(), event_id = $event.attr('data-event-id'), $popup = this.$popup, $overlay = this.$overlay, $event_description = this.$schedule.find('.sched-event-fulldescription[data-event-id='+event_id+']'), $event_inner = $event.find('.sched-event-inner'); if($event_description.attr('data-media-type') == 'image') { $popup.addClass('sched-popup-has-image').find('.sched-popup-media') .attr('data-media-type', 'image') .html(''); }else if($event_description.attr('data-media-type') == 'youtube') { $popup.addClass('sched-popup-has-image').find('.sched-popup-media') .attr('data-media-type', 'youtube') .html(''); }else { $popup.removeClass('sched-popup-has-image').find('.sched-popup-media') .attr('data-media-type', '0') .html(''); } this.$popup.attr('id', this.id+'-popup'); this.resize_popup(); $event_inner.css({ //'background': $event.attr('data-color'), 'color': '' }); $popup.find('.sched-popup-title').css({ 'width': '', }); var event_padding = parseFloat($event.attr('data-padding')) $popup.find('.sched-popup-title').html('