//test jQuery(document).ready(function () { initialize_wpcmtt_tooltip_style(); jQuery.fn.qtip.zindex = 9999999; }); function get_WPCMTT_var(wpcmtt_vars, name) { return wpcmtt_vars[name]; } function set_WPCMTT_var(wpcmtt_vars, name, value) { return wpcmtt_vars[name] = value; } function get_wpcmtt_tooltip_styles(tooltipSettings) { var hide_event; if (tooltipSettings.tooltip_hide_event == 'hover') { hide_event = 'mouseleave'; } else if (tooltipSettings.tooltip_hide_event == 'click') { hide_event = 'click'; } else if (tooltipSettings.tooltip_hide_event == 'click_elsewhere') { hide_event = 'unfocus'; } else if (tooltipSettings.tooltip_hide_event == 'click_elsewhere_focus_out') { hide_event = 'focusout'; } var show_event; var page_load_ready = false; if (tooltipSettings.tooltip_show_event == 'hover') { show_event = 'mouseenter'; } else if (tooltipSettings.tooltip_show_event == 'click') { show_event = 'click'; } else if (tooltipSettings.tooltip_show_event == 'focus') { show_event = 'focus'; } else if (tooltipSettings.tooltip_show_event == 'click_focus') { show_event = 'click focus'; } else if (tooltipSettings.tooltip_show_event == 'page_load') { page_load_ready = true; } var tooltip_show_animation = tooltipSettings.tooltip_show_animation; var tooltip_show_animation_time = parseInt(tooltipSettings.tooltip_show_animation_time); var tooltip_show_animation_time_gsap = tooltip_show_animation_time / 1000; var animation_show_function = function () { jQuery(this).fadeIn(tooltip_show_animation_time); TweenMax.to(jQuery(this), tooltip_show_animation_time_gsap, {onStart: eval(tooltip_show_animation), onStartParams: [jQuery(this), tooltip_show_animation_time_gsap]}); } var tooltip_hide_animation = tooltipSettings.tooltip_hide_animation; var tooltip_hide_animation_time = parseInt(tooltipSettings.tooltip_hide_animation_time); var tooltip_hide_animation_time_gsap = tooltip_hide_animation_time / 1000; var animation_hide_function = function () { jQuery(this).fadeOut(tooltip_hide_animation_time); TweenMax.to(jQuery(this), tooltip_hide_animation_time_gsap, {onStart: eval(tooltip_hide_animation), onStartParams: [jQuery(this), tooltip_hide_animation_time_gsap]}); } var extra_classes = ''; if (tooltipSettings.tooltip_shadow == '1') { extra_classes += 'qtip-shadow '; } if (tooltipSettings.tooltip_arrow == 'disabled') { extra_classes += 'remove_arrow '; tooltipSettings.tooltip_arrow_width = '6'; tooltipSettings.tooltip_arrow_height = '6'; } var tooltip_button = false; if (tooltipSettings.tooltip_close == 'enabled') { tooltip_button = true; } var tooltip_style = tooltipSettings.tooltip_style; extra_classes += ' ' + tooltip_style; var svg = ''; if (tooltip_style == 'bloated') { svg = ""; } else if (tooltip_style == 'comic-1') { svg = ""; } else if (tooltip_style == 'comic-2') { svg = ""; } else if (tooltip_style == 'sharped') { svg = ""; } var tooltip_type = tooltipSettings.tooltip_type; var id, content, video_type, video_width, video_height; var events = ''; var target = tooltipSettings.tooltip_target == "event" ? 'default' : 'mouse'; if (tooltip_type == 'video') { extra_classes += ' video '; video_type = tooltipSettings.tooltip_video_type; video_height = tooltipSettings.tooltip_video_height; var video_id; var autoplay = tooltipSettings.tooltip_video_autoplay == "true" ? 1 : 0; if (video_type == 'youtube') { // youtube video video_id = tooltipSettings.tooltip_video_id + '_' + tooltipSettings.id; content = jQuery('
', {id: video_id}); events = { render: function (event, api) { new YT.Player(video_id, { playerVars: { autoplay: autoplay, enablejsapi: 1, origin: document.location.host }, origin: document.location.host, height: video_height, width: "100%", videoId: video_id.substr(0, 11), events: { 'onReady': function (e) { api.player = e.target; }, } }); }, hide: function (event, api) { api.player && api.player.stopVideo(); }, show: function (event, api) { if (autoplay == 1) { api.player && api.player.playVideo(); } }, }; } else { // vimeo video video_id = tooltipSettings.tooltip_video_id; schema = tooltipSettings.tooltip_video_schema; var autoplay = tooltipSettings.tooltip_video_autoplay == "true" ? 1 : 0; content = { text: '' }; events = { render: function (event, api) { var iframe = jQuery('iframe', this)[0]; api.player = new Vimeo.Player(iframe); }, hide: function (event, api) { api.player.pause(); }, show: function (event, api) { if (autoplay == 1) { api.player.play(); } }, }; } } else if (tooltip_type == 'map') { extra_classes += ' map '; var map_icon = tooltipSettings.tooltip_googlemap_pin; var snazzy_maps_code = tooltipSettings.tooltip_googlemap_snazzy; var map_height = tooltipSettings.tooltip_googlemap_height; var styles; if (snazzy_maps_code != '') { styles = jQuery.parseJSON(snazzy_maps_code); } content = { text: 'Loading map...', title: {button: true} // button: true }; events = { render: function (event, api) { var tooltip = jQuery(this), // Setup the map container and append it to the tooltip container = jQuery('') .appendTo(api.elements.content.empty()); // Temporarily show the tooltip so we don't get rendering bugs in GMaps tooltip.show(); // Create map object as api attribute for later use api.map = new google.maps.Map(container[0], { zoom: parseInt(tooltipSettings.tooltip_googlemap_zoom), // mapTypeId: google.maps.MapTypeId.ROADMAP // Use the classic roadmap styles: styles }); // Hide the tooltip again now we're done tooltip.hide(); }, show: function (event, api) { // Grab the map reference and target var map = api.map, target = api.elements.target, coords, latlong, map, marker, info; // Parse coordinates of event target coordsX = tooltipSettings.tooltip_googlemap_lat; coordsY = tooltipSettings.tooltip_googlemap_long; // Setup lat/long coordinates latlong = new google.maps.LatLng(parseFloat(coordsX), parseFloat(coordsY)); // Create marker at the new location and center map there if (map_icon != '') { marker = new google.maps.Marker({ map: map, position: latlong, icon: { url: map_icon } }); } else { marker = new google.maps.Marker({ map: map, position: latlong }); } map.setCenter(latlong); } }; } else if (tooltip_type == 'modal') { tooltipSettings.tooltip_my = 'center'; tooltipSettings.tooltip_at = 'center'; target = jQuery(window); content = { text: function () { var cont = jQuery("[data-wpcmtt-id=" + tooltipSettings.id + "]").clone(true, true).find("script,style").remove().end().html(); jQuery("[data-wpcmtt-id=" + tooltipSettings.id + "]").appendTo(document.body); return cont }, button: tooltip_button }; events = { render: function (event, api) { // Grab the overlay element api.elements.overlay.addClass("wpcmtt-modal-overlay-" + tooltipSettings.tooltip_style_id); } }; } else { extra_classes += ' ' + tooltip_type + ' '; events = { render: function (event, api) { if (svg != '') { var tooltip = jQuery(this); if (((tooltip_style == 'comic-1') || (tooltip_style == 'comic-2') || (tooltip_style == 'bloated')) && (tooltipSettings.tooltip_svg_width_mode == "fit")) { var temp_content = jQuery("[data-wpcmtt-id=" + tooltipSettings.id + "]").clone(true, true).find("script,style").remove().end().html(); var container_content = tooltip.find(".qtip-content"); container_content.addClass('fit-to-content-width'); container_content.html(temp_content); //Set a width tooltip.qtip('option', {'style.width': 700}); tooltip.show(); //Recalculate estimated square width var est_width = parseInt(Math.sqrt((container_content.outerWidth() * container_content.outerHeight()))); tooltip.hide(); tooltip.qtip('option', {'style.width': est_width}); tooltip.show(); //Recalculate final width var cont_width = container_content.outerWidth(); var cont_height = container_content.outerHeight(); var font_size = container_content.css("font-size"); font_size = parseInt(font_size.replace("px", "")); container_content.removeClass('fit-to-content-width'); tooltip.hide(); var offset = 4; switch (tooltip_style) { case 'comic-1': //(0.62*200)/(0.5*150) var calc_width = Math.sqrt((cont_width * cont_height) * (124 / 75)); calc_width = (calc_width / 0.62) + font_size + offset; break; case 'comic-2': //(0.76*200)/(0.58*150) var calc_width = Math.sqrt((cont_width * cont_height) * (152 / 87)); calc_width = (calc_width / 0.76) + font_size + offset; break; case 'bloated': //(0.8*200)/(0.65*200) var calc_width = Math.sqrt((cont_width * cont_height) * (8 / 6.5)); calc_width = (calc_width / 0.8) + font_size + offset; break; default: break; } tooltip.qtip('option', {'style.width': calc_width}); } var svg_cont = svg + '