/** * Render the shortcode * @param array $args Shortcode paramters * @param string $content Content between shortcode * @return string HTML output */ function render($args, $content = '') { $defaults = Magee_Core::set_shortcode_defaults(array('id' => '', 'class' => '', 'title' => '', 'trigger' => 'click', 'placement' => 'top'), $args); extract($defaults); self::$args = $defaults; $html = sprintf('<span class="%s tooltip-text" id="%s" data-toggle="tooltip" data-trigger="%s" data-placement="%s" data-original-title="%s" >%s</span>', $class, $id, $trigger, $placement, $title, do_shortcode(Magee_Core::fix_shortcodes($content))); return $html; }
/** * Render the shortcode * @param array $args Shortcode paramters * @param string $content Content between shortcode * @return string HTML output */ function render($args, $content = '') { $defaults = Magee_Core::set_shortcode_defaults(array('id' => '', 'class' => '', 'title' => '', 'background_color' => '', 'border_radius' => '', 'trigger' => 'click', 'placement' => 'top'), $args); extract($defaults); self::$args = $defaults; if (is_numeric($border_radius)) { $border_radius = $border_radius . 'px'; } $addclass = uniqid("tooltip-"); $class .= ' ' . $addclass; $html = ''; if ($background_color !== '') { $html .= '<style type="text/css">.' . $addclass . ' + .tooltip > .tooltip-inner {background-color: ' . $background_color . ';border-radius:' . $border_radius . ';} .' . $addclass . ' + .tooltip > .tooltip-arrow {border-' . $placement . '-color: ' . $background_color . ';}</style>'; } $html .= sprintf('<span class="%s tooltip-text" id="%s" data-toggle="tooltip" data-trigger="%s" data-placement="%s" data-original-title="%s" >%s</span>', $class, $id, $trigger, $placement, $title, do_shortcode(Magee_Core::fix_shortcodes($content))); $html .= "<script>\r\n\t\tjQuery(function(\$){\r\n\t\t\tif(jQuery('#magee-sc-form-preview').length>0){\r\n\t\t\t\t\$('#magee-sc-form-preview').ready(function(){\r\n\t\t\t\t\$('#magee-sc-form-preview').contents().find('.tooltip-text').css({\"position\":\"relative\",\"top\":\"50px\",\"left\":\"200px\"});\r\n\t\t\t\t\t\$('#magee-sc-form-preview').contents().find('.tooltip-text').on('" . $trigger . "',function(){\r\n\t\t\t\t\t if(\$('#magee-sc-form-preview').contents().find('#tooltip-hidden').length>0){\r\n\t\t\t\t\t \$('#magee-sc-form-preview').contents().find('#tooltip-hidden').remove();\r\n\t\t\t\t\t }else{\r\n\t\t\t\t\t var html = '<div class=\"tooltip fade " . $placement . " in\" id=\"tooltip-hidden\" role=\"tooltip\" style=\"display: block;\"><div class=\"tooltip-arrow\"></div><div class=\"tooltip-inner\">" . $title . "</div></div>';\r\n\t\t\t\t\t \$('#magee-sc-form-preview').contents().find('span.tooltip-text').after(html);\r\n\t\t\t\t\t var hidden = \$('#magee-sc-form-preview').contents().find('#tooltip-hidden');\r\n\t\t\t\t\t\t\tif(hidden.attr('class').indexOf('top')>=0){\r\n\t\t\t\t\t\t\t\tsize = (\$('#magee-sc-form-preview').contents().find('.tooltip-text').width()/2+200-hidden.width()/2).toString();\r\n\t\t\t\t\t\t\t\thidden.css({\"position\":\"absolute\",\"top\":\"25px\",\"left\":size+\"px\"});}\r\n\t\t\t\t\t\t\tif(hidden.attr('class').indexOf('bottom')>=0){\r\n\t\t\t\t\t\t\t\tsize = (\$('#magee-sc-form-preview').contents().find('.tooltip-text').width()/2+200-hidden.width()/2).toString();\r\n\t\t\t\t\t\t\t\thidden.css({\"position\":\"absolute\",\"top\":\"68px\",\"left\":size+\"px\"});}\r\n\t\t\t\t\t\t\tif(hidden.attr('class').indexOf('left')>=0){\r\n\t\t\t\t\t\t\t\tsize_width = (200-(hidden.width()+10)).toString();\r\n\t\t\t\t\t\t\t\tsize_height = (\$('#magee-sc-form-preview').contents().find('.tooltip-text').height()/2+50-hidden.height()/2).toString();\r\n\t\t\t\t\t\t\t\thidden.css({\"position\":\"absolute\",\"top\":size_height+\"px\",\"left\":size_width+\"px\"});}\r\n\t\t\t\t\t\t\tif(hidden.attr('class').indexOf('right')>=0){\r\n\t\t\t\t\t\t\t\tsize_width = (200+\$('#magee-sc-form-preview').contents().find('.tooltip-text').width()).toString();\r\n\t\t\t\t\t\t\t\tsize_height = (\$('#magee-sc-form-preview').contents().find('.tooltip-text').height()/2+50-hidden.height()/2).toString();\r\n\t\t\t\t\t\t\t\thidden.css({\"position\":\"absolute\",\"top\":size_height+\"px\",\"left\":size_width+\"px\"});}\t \r\n\t\t\t\t\t } \r\n\r\n\t\t\t\t\t});\r\n\t\t\t\t\t\r\n\t\t\t\t});\r\n\t\t }\r\n\t\t});\r\n\t\t</script>"; return $html; }