/** * DEFINE setting options of shortcode * * @return type */ public function element_shortcode($atts = null, $content = null) { $document = JFactory::getDocument(); $document->addStyleSheet(JURI::root(true) . "/plugins/system/jsnframework/assets/3rd-party/jquery-tipsy/tipsy.css", 'text/css'); $document->addScript(JURI::root(true) . "/plugins/system/jsnframework/assets/3rd-party/jquery-tipsy/jquery.tipsy.js", 'text/javascript'); $arr_params = JSNPagebuilderHelpersShortcode::shortcodeAtts($this->config['params'], $atts); extract($arr_params); $random_id = JSNPagebuilderHelpersShortcode::generateRandomString(); $tooltip_id = "tooltip_{$random_id}"; $button_color = !$button_color || strtolower($button_color) == 'default' ? '' : $button_color; $position = strtolower($position); $delay_show = !empty($show) ? $show : 500; $delay_hide = !empty($hide) ? $hide : 100; $direction = array('top' => 's', 'bottom' => 'n', 'left' => 'e', 'right' => 'w'); $content = str_replace(array("\n", "\r"), '', $content); $script = "( function (\$) {\n\t\t\t\t\$( document ).ready( function ()\n\t\t\t\t{\n\t\t\t\t\t\$('#{$tooltip_id}').click(function(e){\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t});\n\t\t\t\t\t\$('#{$tooltip_id}').tipsy({\n\t\t\t\t\t\tfallback: '{$content}',\n\t\t\t\t\t\thtml: true,\n\t\t\t\t\t\tlive: true,\n\t\t\t\t\t\tdelayIn: {$delay_show},\n\t\t\t\t\t\tdelayOut: {$delay_hide},\n\t\t\t\t\t\tgravity: '{$direction[$position]}'\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t} )( JoomlaShine.jQuery );"; if ($tooltips_button == 'no') { $html = "<a id='{$tooltip_id}' class='pb-label-des-tipsy' original-title='' href='#'>{$text}</a>"; } else { $html = "<a id='{$tooltip_id}' class='pb-label-des-tipsy btn {$button_color}' original-title='' href='#'>{$text}</a>"; } $document->addScriptDeclaration($script, 'text/javascript'); //$html = $html; //if ( is_admin() ) { // $custom_style = "style='margin-top: 50px;'"; // $html_element = "<center $custom_style>$html</center>"; //} else // $html_element = $html; return $this->element_wrapper($html, $arr_params); }
/** * DEFINE shortcode content * * @param array|null $atts * @param array|null $content * * @return string */ public function element_shortcode($atts = null, $content = null) { $document = JFactory::getDocument(); $document->addStyleSheet(JSNPB_ELEMENT_URL . '/tab/assets/css/tab.css', 'text/css'); $arr_params = JSNPagebuilderHelpersShortcode::shortcodeAtts($this->config['params'], $atts); extract($arr_params); $initial_open = intval($initial_open); $tab_position = $tab_position; $random_id = JSNPagebuilderHelpersShortcode::generateRandomString(); $tab_navigator = array(); $tab_navigator[] = '<ul class="nav nav-tabs">'; // extract icons of tab items $sub_sc_data = JSNPagebuilderHelpersShortcode::extractSubShortcode($content); $sub_sc_data = $sub_sc_data[$this->config['has_subshortcode']]; $items_data = array('icons' => array(), 'heading' => array()); foreach ($sub_sc_data as $idx => $shortcode) { $extract_params = JSNPagebuilderHelpersShortcode::shortcodeParseAtts($shortcode); $items_data['icons'][] = !empty($extract_params['icon']) ? "<i class='{$extract_params['icon']}'></i> " : ''; $items_data['heading'][] = isset($extract_params['heading']) ? $extract_params['heading'] : ''; } $sub_shortcode = empty($content) ? JSNPagebuilderHelpersShortcode::removeAutop($content) : JSNPagebuilderHelpersBuilder::generateShortCode($content, false, 'frontend', true); $items = explode('<!--seperate-->', $sub_shortcode); $items = array_filter($items); $initial_open = $initial_open > count($items) ? 1 : $initial_open; if ($fade_effect == 'yes') { $fade_effect = 'fade in'; } else { $fade_effect = ''; } foreach ($items as $idx => $item) { $active = $idx + 1 == $initial_open ? 'active' : ''; $item = str_replace('{index}', $random_id . '_' . $idx, $item); $item = str_replace('{active}', $active, $item); $item = str_replace('{fade_effect}', $fade_effect, $item); $items[$idx] = $item; $active_li = $idx + 1 == $initial_open ? "class='active'" : ''; $href = "#pane_" . $random_id . '_' . $idx; $tab_navigator[] = "<li {$active_li}><a href='{$href}' data-toggle='tab'>{$items_data['icons'][$idx]}{$items_data['heading'][$idx]}</a></li>"; } $sub_shortcode = implode('', $items); $tab_content = "<div class='tab-content'>{$sub_shortcode}</div>"; // update min-height of each tab content in case tap position is left/right if (in_array($tab_position, array('left', 'right'))) { $min_height = 36 * count($items); $tab_content = str_replace('STYLE', "style='min-height: {$min_height}px'", $tab_content); } $tab_navigator[] = '</ul>'; $tab_positions = array('top' => '', 'left' => 'tabs-left', 'right' => 'tabs-right', 'bottom' => 'tabs-below'); $extra_class = $tab_positions[$tab_position]; if ($tab_position == 'bottom') { $tab_content .= implode('', $tab_navigator); } else { $tab_content = implode('', $tab_navigator) . $tab_content; } $html_element = "<div class='tabbable {$extra_class}' id='tab_{ID}'>{$tab_content}</div>"; $html_element = str_replace('{ID}', "{$random_id}", $html_element); return $this->element_wrapper($html_element, $arr_params); }
/** * define shortcode structure of element * * @return string */ function element_shortcode($atts = null, $content = null) { $extra_class = $style = $common_style = $data_attr = ''; $extra_id = !empty($atts['id_wrapper']) ? $atts['id_wrapper'] : JSNPagebuilderHelpersShortcode::generateRandomString(); if (isset($atts) && is_array($atts)) { $arr_styles = array(); // if(isset($atts['width'])){ // if($atts['width'] == 'full'){ // $extra_class = 'pb_fullwidht'; // $script = "$(body).addClass('pb_fullwidht');"; // $custom_script = JSNPagebuilderHelpersShortcode::script_box($script); // $arr_styles[] = '-webkit-box-sizing: content-box;-moz-box-sizing: content-box;box-sizing: content-box;width: 100%;padding-left: 1000px;padding-right: 1000px;margin:0 -1000px;'; // } // } $background = ""; switch ($atts['background']) { case 'solid': $solid_color = $atts['solid_color_value']; $background = "background-color: {$solid_color};"; break; case 'gradient': if (!isset($atts['gradient_color_css'])) { $background = "background:linear-gradient(center top , #ffffff 0%, #000000 100%);background:-moz-linear-gradient(center top , #ffffff 0%, #000000 100%); background: -webkit-linear-gradient(#FFFFFF, #000000);background:-o-linear-gradient(center top , #ffffff 0%, #000000 100%);background:-ms-linear-gradient(center top , #ffffff 0%, #000000 100%);"; } else { $background = $atts['gradient_color_css']; } break; case 'pattern': $pattern_img = isset($atts['pattern']) ? $atts['pattern'] : ''; $pattern_repeat = isset($atts['repeat']) ? $atts['repeat'] : ''; $background = "background-image:url('{$pattern_img}');"; switch ($pattern_repeat) { case 'full': $background_repeat = "repeat"; break; case 'vertical': $background_repeat = "repeat-y"; break; case 'horizontal': $background_repeat = "repeat-x"; break; default: $background_repeat = "repeat"; } $background .= "background-repeat:{$background_repeat};"; break; case 'image': if (isset($atts['image'])) { $image = $atts['image']; } $image_position = $atts['position']; $pattern_stretch = isset($atts['stretch']) ? $atts['stretch'] : ''; $url_pattern = '/^(http|https)/'; preg_match($url_pattern, $image, $_f); if (!count($_f)) { $image = JUri::root() . $image; } $background = "background-image:url('{$image}');background-position:{$image_position};"; switch ($pattern_stretch) { case 'none': $background_size = ""; break; case 'full': $background_size = "100% 100%"; break; case 'cover': $background_size = "cover"; break; case 'contain': $background_size = "contain"; break; } $background .= !empty($background_size) ? "background-size:{$background_size};" : ""; break; case 'video': $url = $atts['video_url']; // Youtube video $pattern = '#^(?:https?://)?'; # Optional URL scheme. Either http or https. $pattern .= '(?:www\\.)?'; # Optional www subdomain. $pattern .= '(?:'; # Group host alternatives: $pattern .= 'youtu\\.be/'; # Either youtu.be, $pattern .= '|youtube\\.com'; # or youtube.com $pattern .= '(?:'; # Group path alternatives: $pattern .= '/embed/'; # Either /embed/, $pattern .= '|/v/'; # or /v/, $pattern .= '|/watch\\?v='; # or /watch?v=, $pattern .= '|/watch\\?.+&v='; # or /watch?other_param&v= $pattern .= ')'; # End path alternatives. $pattern .= ')'; # End host alternatives. $pattern .= '([\\w-]{11})'; # 11 characters (Length of Youtube video ids). $pattern .= '(?:.+)?$#x'; # Optional other ending URL parameters. if (preg_match($pattern, $url, $matches)) { $extra_class .= 'pb_video_bg'; $youtube_url = end($matches); $data_attr = sprintf("data-property=\"{videoURL:'http://youtu.be/%s', containment:'%s', autoplay:%s, mute:true, startAt:0, opacity:1, showControls:false}\"", $youtube_url, "#{$extra_id}", $atts['autoplay']); $script = "\n\t (function(\$){\n\t \$(document).ready(function(){\n\t \$('.pb_video_bg').mb_YTPlayer();\n\t \$('.pb_video_bg').click(function(){ \$(this).playYTP()})\n\t })\n\t })(jQuery);\n\t "; JFactory::getDocument()->addScriptDeclaration($script, 'text/javascript'); self::enqueue_player_scripts(); } else { JSNPagebuilderHelpersFunctions::print_asset_tag(JUri::root(true) . '/administrator/components/com_pagebuilder/helpers/shortcode/row/assets/css/row.css', 'css'); $autoplay = $atts['autoplay'] == 1 ? 'autoplay="true"' : ''; $script = "\n\t\t\t\t\t\t\tjQuery(document).ready(function(\$){\n\t\t\t\t\t\t\tvar bgwidth = \$('#{$extra_id}').width();\n\t\t\t\t\t\t\tvar bgheight = \$('#{$extra_id}').height();\n\t\t\t\t\t\t\tconsole.log(bgwidth)\n\t\t\t\t\t\t\t\$('#{$extra_id}').css({'position':'relative','z-index':'1','overflow':'hidden'})\n\t\t\t\t\t\t\t\$('video').attr({'width':bgheight, 'height': bgheight});\n\t\t\t\t\t\t\t\$('object').attr({'width':bgheight, 'height': bgheight});\n\t\t\t\t\t\t\t\t\$('video').mediaelementplayer({\n\t\t\t\t\t\t\t\t'loop':true,\n\t\t\t\t\t\t\t\t'clickToPlayPause': false,\n\t\t\t\t\t\t\t\t'controls': false,\n\t\t\t\t\t\t\t\tsuccess: function(player, dom, mediaelement){\n\t\t\t\t\t\t\t\t\tmediaelement.container[0].style.position = 'absolute';\n\t\t\t\t\t\t\t\t\tmediaelement.container[0].style.zIndex = '1';\n\t\t\t\t\t\t\t\t\t\$('.mejs-controls').css('display', 'none');\n\t\t\t\t\t\t\t\t\tplayer.play();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\t\tvar source = \$('<object type=\"application/x-shockwave-flash\" width=\"'+bgwidth+'\" height=\"'+bgheight+'\" data=\"" . JSNPB_PLG_SYSTEM_ASSETS_URL . "/3rd-party/mediaelement/flashmediaelement.swf\">'+\n\t\t\t\t\t\t\t\t\t\t\t\t'<param name=\"movie\" value=\"" . JSNPB_PLG_SYSTEM_ASSETS_URL . "/3rd-party/mediaelement/flashmediaelement.swf\" />'+\n \t\t\t\t\t'<param name=\"flashVars\" value=\"controls=false&file=" . $url . "\" />'+\n \t\t\t\t\t'</object>'+\n '<img src=\"" . JSNPB_PLG_SYSTEM_ASSETS_URL . "/3rd-party/mediaelement/bigplay.png\" width=\"'+bgwidth+'\" height=\"'+bgheight+'\" title=\"No video playback capabilities\" />');\n\t\t\t\t\t var video = \$('<video controls=\"controls\" width=\"'+bgwidth+'\" height=\"\" {$autoplay} loop=\"true\" style=\"position: absolute; left: 0px; top: -20px; overflow: hidden; opacity: 1; transition-property: opacity; transition-duration: 2000ms; z-index: -1; min-width: 101%; min-height: 100%;\" ><source src=\"" . $url . "\" /></video>').append(source);\n\n\t\t\t\t\t \$('#{$extra_id}').append(video);\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t"; JFactory::getDocument()->addScriptDeclaration($script, 'text/javascript'); $document = JFactory::getDocument(); $document->addStyleSheet(JSNPB_PLG_SYSTEM_ASSETS_URL . '3rd-party/mediaelement/mediaelementplayer.min.css', 'text/css'); $document->addScript(JSNPB_PLG_SYSTEM_ASSETS_URL . '3rd-party/mediaelement/mediaelement-and-player.min.js', 'text/javascript'); } break; } $arr_styles[] = $background; if (isset($atts['paralax']) && $atts['paralax'] == 'yes') { $arr_styles[] = "background-attachment:fixed;"; } if (isset($atts['parallax_scroll']) && $atts['parallax_scroll'] == 'yes') { $extra_class .= 'parallax'; $document = JFactory::getDocument(); $document->addScript(JUri::root(true) . '/administrator/components/com_pagebuilder/helpers/shortcode/row/assets/js/parallax.js', 'text/javascript'); } if (isset($atts['border_width_value_']) && intval($atts['border_width_value_'])) { $border = array(); $border[] = $atts['border_width_value_'] . "px"; $border[] = $atts['border_style']; $border[] = $atts['border_color']; $border = implode(" ", $border); $arr_styles[] = "border-top:{$border}; border-bottom:{$border};"; } $arr_styles[] = "padding-top:{$atts['div_padding_top']}px;"; $arr_styles[] = "padding-bottom:{$atts['div_padding_bottom']}px;"; $arr_styles[] = "padding-left:{$atts['div_padding_left']}px;"; $arr_styles[] = "padding-right:{$atts['div_padding_right']}px;"; if (@$atts['width_value']) { $arr_styles[] = "width:" . $atts['width_value'] . $atts['width_unit'] . '; margin:0 auto'; } $arr_styles = implode("", $arr_styles); $style = !empty($arr_styles) ? "style=\"{$arr_styles}\"" : ""; } $column_html = empty($content) ? JSNPagebuilderHelpersShortcode::removeAutop($content) : JSNPagebuilderHelpersBuilder::generateShortCode($content, true, 'frontend'); $extra_class .= !empty($atts['css_suffix']) ? ' ' . htmlspecialchars($atts['css_suffix']) : ''; $extra_class = ltrim($extra_class, ' '); return $common_style . "<div class='jsn-bootstrap3'><div id='{$extra_id}' class='{$extra_class} row' {$style} {$data_attr}>" . $column_html . "</div></div>"; }
/** * DEFINE shortcode content * * @param type $atts * @param type $content * * @return string */ public function element_shortcode($atts = null, $content = null) { $document = JFactory::getDocument(); $document->addStyleSheet(JSNPB_ELEMENT_URL . '/accordion/assets/css/accordion.css', 'text/css'); $arr_params = JSNPagebuilderHelpersShortcode::shortcodeAtts($this->config['params'], $atts); $initial_open = intval($arr_params['initial_open']); $multi_open = $arr_params['multi_open']; $filter = $arr_params['filter']; $random_id = JSNPagebuilderHelpersShortcode::generateRandomString(); $script = ""; $scriptFilter = ""; if ($multi_open == "yes") { $script .= "<script type='text/javascript'>( function (\$) {\n\t\t\t\t\t\$( document ).ready( function ()\n\t\t\t\t\t{\n\t\t\t\t\t\t\$( '#accordion_{$random_id} .panel-title a' ).click( function(e ){\n\t\t\t\t\t\t\tvar collapse_item = \$( '#accordion_{$random_id} '+this.hash )\n\t\t\t\t\t\t\tcollapse_item.collapse( 'toggle' )\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t} )( JoomlaShine.jQuery );</script>"; } else { // some case the collapse doesn't work, need this code $script .= "<script type='text/javascript'>( function (\$) {\n\t\t\t\t\t\$( document ).ready( function ()\n\t\t\t\t\t{\n\t\t\t\t\t\t\$( '#accordion_{$random_id} .panel-collapse' ).click( function(e ){\n\t\t\t\t\t\t\tvar collapse_item = \$( '#accordion_{$random_id} '+this.hash )\n\t\t\t\t\t\t\t\$( '#accordion_{$random_id} .panel-body' ).each(function(){\n\t\t\t\t\t\t\t\t\$( this ).addClass( 'panel-collapse' );\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tcollapse_item.removeClass( 'panel-collapse' );\n\t\t\t\t\t\t\tcollapse_item.attr( 'style', '' );\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t} )( JoomlaShine.jQuery );</script>"; } $sub_shortcode = empty($content) ? JSNPagebuilderHelpersShortcode::removeAutop($content) : JSNPagebuilderHelpersBuilder::generateShortCode($content, false, 'frontend', true); $items = explode("<!--seperate-->", $sub_shortcode); // remove empty element $items = array_filter($items); $initial_open = $initial_open > count($items) ? 1 : $initial_open; foreach ($items as $idx => $item) { $open = $idx + 1 == $initial_open ? "in" : ""; $item = str_replace("{index}", $random_id . $idx, $item); $item = str_replace("{show_hide}", $open, $item); $items[$idx] = $item; } $sub_shortcode = implode("", $items); $filter_html = ""; if ($filter == "yes") { $sub_sc_data = JSNPagebuilderHelpersShortcode::extractSubShortcode($content); $sub_sc_data = $sub_sc_data[$this->config['has_subshortcode']]; $tags = array(); $tags[] = 'all'; foreach ($sub_sc_data as $shortcode) { $extract_params = JSNPagebuilderHelpersShortcode::shortcodeParseAtts($shortcode); $tags[] = isset($extract_params["tag"]) ? $extract_params["tag"] : ''; } $tags = array_filter($tags); if (count($tags) > 1) { $tags = implode(",", $tags); $tags = explode(",", $tags); $tags = array_unique($tags); $filter_html = "<ul id='filter_{$random_id}' class='nav nav-pills elementFilter' style='margin-bottom:2px;'>"; foreach ($tags as $idx => $value) { $active = $idx == 0 ? "active" : ""; $filter_html .= "<li class='{$active}'><a href='#' class='" . str_replace(" ", "_", $value) . "'>" . ucfirst($value) . "</a></li>"; } $filter_html .= "</ul>"; // remove "All" tag array_shift($tags); $inner_tags = implode(',', $tags); $scriptFilter .= "<script type='text/javascript'>( function (\$) {\n\t\t\t\t\$( document ).ready( function ()\n\t\t\t\t\t{\n\t\t\t\t\t\twindow.parent.jQuery.noConflict()( '#jsn_view_modal').contents().find( 'data-tag' ).text( '{$inner_tags}')\n\t\t\t\t\t\tvar parent_criteria = '#filter_{$random_id}'\n\t\t\t\t\t\tvar clientsClone = \$( '#accordion_{$random_id}' );\n\t\t\t\t\t\tvar tag_to_filter = 'div';\n\t\t\t\t\t\tvar class_to_filter = '.panel-default';\n\t\n\t\t\t\t\t\t\$( parent_criteria + ' a' ).click( function(e ) {\n\t\t\t\t\t\t\t// stop running filter\n\t\t\t\t\t\t\t\$( class_to_filter ).each(function(){\n\t\t\t\t\t\t\t\t\$( this ).stop( true )\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\te.preventDefault();\n\t\n\t\t\t\t\t\t\t//active clicked criteria\n\t\t\t\t\t\t\t\$( parent_criteria + ' li' ).removeClass( 'active' );\n\t\t\t\t\t\t\t\$( this ).parent().addClass( 'active' );\n\t\n\t\t\t\t\t\t\tvar filterData = \$( this ).attr( 'class' );\n\t\t\t\t\t\t\tvar filters;\n\t\t\t\t\t\t\tif( filterData == 'all' ){\n\t\t\t\t\t\t\t\tfilters = clientsClone.find( tag_to_filter );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tfilters = clientsClone.find( tag_to_filter + '[data-tag~='+ filterData +']' );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tclientsClone.find( class_to_filter ).each(function(){\n\t\t\t\t\t\t\t\t\$( this ).fadeOut();\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tfilters.each(function(){\n\t\t\t\t\t\t\t\t\$( this ).fadeIn();\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t} )( jQuery )</script>"; } } $html = '<div class="panel-group" id="accordion_{ID}">' . $sub_shortcode . '</div>'; $html = str_replace("{ID}", "{$random_id}", $html); $html .= $script . $scriptFilter; return $this->element_wrapper($filter_html . $html, $arr_params); }
/** * define shortcode structure of element * * @return string */ function element_shortcode($atts = null, $content = null) { $extra_class = $style = $common_style = $data_attr = ''; $extra_id = !empty($atts['id_wrapper']) ? $atts['id_wrapper'] : JSNPagebuilderHelpersShortcode::generateRandomString(); if (isset($atts) && is_array($atts)) { $arr_styles = array(); // if(isset($atts['width'])){ // if($atts['width'] == 'full'){ // $extra_class = 'pb_fullwidht'; // $script = "$(body).addClass('pb_fullwidht');"; // $custom_script = JSNPagebuilderHelpersShortcode::script_box($script); // $arr_styles[] = '-webkit-box-sizing: content-box;-moz-box-sizing: content-box;box-sizing: content-box;width: 100%;padding-left: 1000px;padding-right: 1000px;margin:0 -1000px;'; // } // } $background = ""; switch ($atts['background']) { case 'solid': $solid_color = $atts['solid_color_value']; $background = "background-color: {$solid_color};"; break; case 'gradient': if (!isset($atts['gradient_color_css'])) { $background = "background:linear-gradient(center top , #ffffff 0%, #000000 100%);background:-moz-linear-gradient(center top , #ffffff 0%, #000000 100%); background: -webkit-linear-gradient(#FFFFFF, #000000);background:-o-linear-gradient(center top , #ffffff 0%, #000000 100%);background:-ms-linear-gradient(center top , #ffffff 0%, #000000 100%);"; } else { $background = $atts['gradient_color_css']; } break; case 'pattern': $pattern_img = isset($atts['pattern']) ? $atts['pattern'] : ''; $pattern_repeat = isset($atts['repeat']) ? $atts['repeat'] : ''; $background = "background-image:url('{$pattern_img}');"; switch ($pattern_repeat) { case 'full': $background_repeat = "repeat"; break; case 'vertical': $background_repeat = "repeat-y"; break; case 'horizontal': $background_repeat = "repeat-x"; break; default: $background_repeat = "repeat"; } $background .= "background-repeat:{$background_repeat};"; break; case 'image': if (isset($atts['image'])) { $image = $atts['image']; } $image_position = $atts['position']; $pattern_stretch = isset($atts['stretch']) ? $atts['stretch'] : ''; $background = "background-image:url('{$image}');background-position:{$image_position};"; switch ($pattern_stretch) { case 'none': $background_size = ""; break; case 'full': $background_size = "100% 100%"; break; case 'cover': $background_size = "cover"; break; case 'contain': $background_size = "contain"; break; } $background .= !empty($background_size) ? "background-size:{$background_size};" : ""; break; case 'video': $url = $atts['video_url']; // Youtube video if (preg_match('/youtube\\.com/', $url)) { $extra_class .= 'pb_video_bg'; parse_str($url, $youtube_url); $data_attr = sprintf("data-property=\"{videoURL:'http://youtu.be/%s', containment:'%s', autoplay:%s, mute:true, startAt:0, opacity:1, showControls:false}\"", reset($youtube_url), "#{$extra_id}", $atts['autoplay']); $script = "\r\n (function(\$){\r\n \$(document).ready(function(){\r\n \$('.pb_video_bg').mb_YTPlayer();\r\n \$('.pb_video_bg').click(function(){ \$(this).playYTP()})\r\n })\r\n })(jQuery)\r\n "; JFactory::getDocument()->addScriptDeclaration($script, 'text/javascript'); self::enqueue_player_scripts(); } break; } $arr_styles[] = $background; if (isset($atts['paralax']) && $atts['paralax'] == 'yes') { $arr_styles[] = "background-attachment:fixed;"; } if (isset($atts['parallax_scroll']) && $atts['parallax_scroll'] == 'yes') { $extra_class .= 'parallax'; $document = JFactory::getDocument(); $document->addScript(JUri::root(true) . '/administrator/components/com_pagebuilder/helpers/shortcode/row/assets/js/parallax.js', 'text/javascript'); } if (isset($atts['border_width_value_']) && intval($atts['border_width_value_'])) { $border = array(); $border[] = $atts['border_width_value_'] . "px"; $border[] = $atts['border_style']; $border[] = $atts['border_color']; $border = implode(" ", $border); $arr_styles[] = "border-top:{$border}; border-bottom:{$border};"; } $arr_styles[] = "padding-top:{$atts['div_padding_top']}px;"; $arr_styles[] = "padding-bottom:{$atts['div_padding_bottom']}px;"; $arr_styles[] = "padding-left:{$atts['div_padding_left']}px;"; $arr_styles[] = "padding-right:{$atts['div_padding_right']}px;"; if (@$atts['width_value']) { $arr_styles[] = "width:" . $atts['width_value'] . $atts['width_unit'] . '; margin:0 auto'; } $arr_styles = implode("", $arr_styles); $style = !empty($arr_styles) ? "style=\"{$arr_styles}\"" : ""; } $column_html = empty($content) ? JSNPagebuilderHelpersShortcode::removeAutop($content) : JSNPagebuilderHelpersBuilder::generateShortCode($content, true, 'frontend'); $extra_class .= !empty($atts['css_suffix']) ? ' ' . htmlspecialchars($atts['css_suffix']) : ''; $extra_class = ltrim($extra_class, ' '); return $common_style . "<div class='jsn-bootstrap3'><div id='{$extra_id}' class='{$extra_class} row' {$style} {$data_attr}>" . $column_html . "</div></div>"; }
/** * Generate HTML for Vimeo * * @return string */ function generate_vimeo($params) { $random_id = JSNPagebuilderHelpersShortcode::generateRandomString(); $_w = ' width="' . $params['video_vimeo_dimension_width'] . '" '; $_h = $params['video_vimeo_dimension_height'] ? ' height="' . $params['video_vimeo_dimension_height'] . '" ' : ''; // Alignment $container_class = ''; $object_style = ''; if ($params['video_alignment'] === 'right') { $object_style .= 'float:right;'; $container_class .= 'clearafter '; } else { if ($params['video_alignment'] === 'center') { $object_style .= 'margin: 0 auto;'; } else { if ($params['video_alignment'] === 'left') { $object_style .= 'float:left;'; $container_class .= 'clearafter '; } } } // Genarate Container class $container_class = $container_class ? 'class="' . $container_class . '" ' : ''; // Margin. $container_style = ''; $container_style .= isset($params['video_margin_left']) && $params['video_margin_left'] != '' ? 'margin-left:' . $params['video_margin_left'] . 'px;' : ''; $container_style .= isset($params['video_margin_top']) && $params['video_margin_top'] != '' ? 'margin-top:' . $params['video_margin_top'] . 'px;' : ''; $container_style .= isset($params['video_margin_right']) && $params['video_margin_right'] != '' ? 'margin-right:' . $params['video_margin_right'] . 'px;' : ''; $container_style .= isset($params['video_margin_bottom']) && $params['video_margin_bottom'] != '' ? 'margin-bottom:' . $params['video_margin_bottom'] . 'px;' : ''; $container_style = $container_style ? ' style=" ' . $container_style . ' " ' : ''; // Get video ID. $params['video_source_link_vimeo'] = urldecode($params['video_source_link_vimeo']); $video_info = JSNPbVideoHelper::getVimeoVideoInfo($params['video_source_link_vimeo']); $video_info = json_decode($video_info); if (!$video_info) { return; } $video_info = $video_info->html; $_arr = array(); $video_src = ''; preg_match('/src\\s*\\n*=\\s*\\n*"([^"]*)"/i', $video_info, $_arr); if (count($_arr)) { $video_src = $_arr[1]; $video_src .= '?innerframe=true'; $video_src .= isset($params['video_vimeo_autoplay']) ? '&autoplay=' . (string) $params['video_vimeo_autoplay'] : ''; $video_src .= isset($params['video_vimeo_loop']) ? '&loop=' . (string) $params['video_vimeo_loop'] : ''; $video_src .= isset($params['video_vimeo_title']) ? '&title=' . (string) $params['video_vimeo_title'] : ''; $video_src .= isset($params['video_vimeo_color']) ? '&color=' . str_replace('#', '', (string) $params['video_vimeo_color']) : ''; } $embed = '<div ' . $container_class . $container_style . '>'; $embed .= '<iframe webkitallowfullscreen mozallowfullscreen allowfullscreen style="display:block;' . $object_style . '" ' . $_w . $_h . '" src="' . $video_src . '" frameborder="0"></iframe>'; $embed .= '</div>'; $embed .= '<div class="clear:both"></div>'; return $embed; }
/** * DEFINE shortcode content * * @param type $atts * @param type $content * * @return string */ public function element_shortcode($atts = null, $content = null) { $document = JFactory::getDocument(); $app = JFactory::getApplication(); if ($app->isAdmin()) { $this->load_assets_frontend(); } $arr_params = JSNPagebuilderHelpersShortcode::shortcodeAtts($this->config['params'], $atts); extract($arr_params); $random_id = JSNPagebuilderHelpersShortcode::generateRandomString(); $testimonial_id = "testimonial_{$random_id}"; $styles = "style='width:100%'"; $image_container_style = $author_image_style != 'no-styling' ? "{$author_image_style}" : ''; $content_elements = array_filter(explode('__#__', $content_elements)); $testimonial_indicators = array(); $testimonial_indicators[] = '<ol class="carousel-indicators">'; $sub_shortcode = empty($content) ? JSNPagebuilderHelpersShortcode::removeAutop($content) : JSNPagebuilderHelpersBuilder::generateShortCode($content, false, 'frontend', true); $testimonial_content = array(); $items = explode('<!--seperate-->', $sub_shortcode); $items = array_filter($items); $count_items = count($items); foreach ($items as $idx => $item) { $pathRoot = JURI::root(); $item = unserialize($item); $url_pattern = '/^(http|https)/'; $image_file = @$item['image_file']; preg_match($url_pattern, $image_file, $m); if (count($m)) { $pathRoot = ''; } if ($idx % $items_per_slide == 0) { $active = $idx == 0 ? 'active' : ''; $testimonial_content[] = "<div class='item row {$active}'>"; $active_li = $idx == 0 ? "class='active'" : ''; $testimonial_indicators[] = "<li {$active_li}></li>"; } $divide = $count_items > $items_per_slide ? $items_per_slide : $count_items; $colmd = 'col-md-' . 12 / $divide; $colsm = 'col-sm-' . 12 / $divide; $item_html = "<div class='pb-testimonial-item {$colmd} {$colsm}'>"; $testimonial_info = array(); if (in_array('content', $content_elements)) { $item_content = JSNPagebuilderHelpersShortcode::removeAutop($item['testimonial_content']); $item_content = JSNPagebuilderHelpersShortcode::pbTrimContent($item_content, $content_count, $content_type); $testimonial_info['content'] = "<div class='pb-testimonial-box top'><div class='arrow'></div><div class='pb-testimonial-content'><p>" . $item_content . '</p></div></div>'; } $img = !empty($item['image_file']) ? "<div class='pb-testimonial-avatar'><img class='{$image_container_style}' src='{$pathRoot}{$item['image_file']}' /></div>" : ''; $testimonial_info['image'] = in_array('image', $content_elements) ? $img : ''; // Process company field if (isset($item['company']) && $item['company'] != '') { $company_link = "<a href='{$item['web_url']}' target='_blank'>{$item['company']}</a>"; } else { $company_link = "<a href='{$item['web_url']}' target='_blank'>{$item['web_url']}</a>"; } if (!isset($item['web_url']) || empty($item['web_url'])) { $company_link = $item['company']; } // Process testimonial metadata $arr_style = array(); if (isset($item['name_height'])) { $arr_style[] = 'font-size: ' . $item['name_height'] . 'px'; } if (isset($item['name_color'])) { $arr_style[] = 'color: ' . $item['name_color']; } $style = $arr_style ? "style='" . implode(';', $arr_style) . "'" : ''; $name = in_array('name', $content_elements) ? "<strong {$style} class='pb-testimonial-name'>" . @$item['name'] . "</strong>" : ''; $job_title = in_array('job_title', $content_elements) ? "<span class='pb-testimonial-jobtitle'>" . @$item['job_title'] . "</span>" : ''; $country = in_array('country', $content_elements) ? "<span class='pb-testimonial-country'>" . @$item['country'] . "</span>" : ''; if ($company_link) { $company = in_array('company', $content_elements) ? "<span class='pb-testimonial-company'>{$company_link}</span>" : ''; } $html_metadata = ''; if ($name != '' || $job_title != '' || $country != '' || $company != '') { $html_metadata .= '<div class="pb-testimonial-meta">'; $html_metadata .= $name . $job_title . $country . $company; $html_metadata .= '</div>'; } foreach ($content_elements as $element) { $item_html .= isset($testimonial_info[$element]) ? $testimonial_info[$element] : ''; } $item_html .= $html_metadata; $item_html .= '</div>'; $testimonial_content[] = $item_html; if (($idx + 1) % $items_per_slide == 0 || $idx + 1 == count($items)) { $testimonial_content[] = '</div>'; } } $testimonial_content = "<div class='carousel-inner'>" . implode('', $testimonial_content) . '</div>'; $testimonial_indicators[] = "</ol>"; $testimonial_indicators = implode('', $testimonial_indicators); $slider_time = $slider_time . '000'; if ($auto_play == 'yes') { $script = "<script type='text/javascript'>\n\t\t\t\t\t\t(function(\$){\n\t\t\t\t\t\t\t\$(document).ready(function(){\n\t\t\t\t\t\t\t\tif(\$('#{$testimonial_id}').length){\n\t\t\t\t\t\t\t\t\t\$('#{$testimonial_id}').carousel({\n\t\t\t\t\t\t\t\t interval: " . (int) $slider_time . "\n\t\t\t\t\t\t\t\t });\n\t\t\t\t\t\t\t\t\t\$('#{$testimonial_id} .carousel-indicators li').each(function(i){\n\t\t\t\t\t\t\t\t\t\t\$(this).on('click', function(){\n\t\t\t\t\t\t\t\t\t\t\t\$('#{$testimonial_id}').carousel(i);\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t})(jQuery)\n\t\t\t\t</script>"; } else { $script = "<script type='text/javascript'>\n\t\t\t\t\t\t(function(\$){\n\t\t\t\t\t\t\t\$(document).ready(function(){\n\t\t\t\t\t\t\t\tif(\$('#{$testimonial_id}').length){\n\t\t\t\t\t\t\t\t\t\$('#{$testimonial_id}').carousel({\n\t\t\t\t\t\t\t\t interval: false\n\t\t\t\t\t\t\t\t });\n\t\t\t\t\t\t\t\t\t\$('#{$testimonial_id} .carousel-indicators li').each(function(i){\n\t\t\t\t\t\t\t\t\t\t\$(this).on('click', function(){\n\t\t\t\t\t\t\t\t\t\t\t\$('#{$testimonial_id}').carousel(i);\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t})(jQuery)\n\t\t\t\t</script>"; } $slider_elements = explode('__#__', $slider_elements); if ($count_items <= (int) $items_per_slide || !in_array('indicator', $slider_elements)) { $testimonial_indicators = ''; } $testimonial_navigator = $count_items > $items_per_slide && in_array('arrows', $slider_elements) ? "<a class='carousel-control left icon-arrow-left pb-arrow-left'></a><a class='carousel-control right icon-arrow-right pb-arrow-right'></a>" : ''; $html = "<div class='carousel slide pb-testimonial' {$styles} id='{$testimonial_id}'> {$testimonial_content} {$testimonial_indicators} {$testimonial_navigator}</div>"; return $this->element_wrapper($script . $html, $arr_params); }
/** * Display the button * * @return */ function onDisplay($name) { $app = JFactory::getApplication(); if ($app->isSite()) { return; } include_once JPATH_ROOT . '/administrator/components/com_pagebuilder/helpers/articles.php'; $listId = JSNPagebuilderHelpersArticles::getListArticleUedPagebuilderFromPlugin(); $pbTotal = JSNPagebuilderHelpersArticles::getCountArticleUsedPageBuilderFromPlugin(); JSNPagebuilderHelpersArticles::updateArticleUsedPageBuilderToPlugin(); //Check if JoomlaShine extension framework is enabled? global $id, $option, $framework, $conf, $supported_list, $params, $random_id; // Check if JoomlaShine extension framework is enabled? $framework = JTable::getInstance('Extension'); $framework->load(array('element' => 'jsnframework', 'type' => 'plugin', 'folder' => 'system')); $isInstalledPbExtension = false; $option = JRequest::getVar('option'); $com_advancedmodules = JSNPagebuilderHelpersPagebuilder::checkComponentEnabled('com_advancedmodules') ? array('com_advancedmodules') : ''; $flexiContent = JSNPagebuilderHelpersPagebuilder::checkComponentEnabled('com_flexicontent') ? array('com_flexicontent') : ''; $supported_list = array('com_content', 'com_modules'); if ($com_advancedmodules != '') { $supported_list = array_merge($supported_list, $com_advancedmodules); } if ($flexiContent != '') { $supported_list = array_merge($supported_list, $flexiContent); } if (isset($params)) { if ($params->extension_support != '') { $supported_list = json_decode($params->extension_support); } } $installedPbExtensions = JSNPagebuilderHelpersExtensions::getPbExtensions(); if (count($installedPbExtensions)) { foreach ($installedPbExtensions as $installedPbExtension) { if ($option == "com_" . $installedPbExtension->element) { if (!$installedPbExtension->enabled) { $app->enqueueMessage(sprintf('Please enable the %s plugin before using. How to enable it, click <a href="%s" target="_blank">here</a>', 'JSN PageBuilder ' . strtoupper($installedPbExtension->element) . ' element', 'index.php?option=com_pagebuilder&view=configuration&s=maintainence&g=extensions'), 'warning'); return; } else { $isInstalledPbExtension = true; } break; } } } if ($isInstalledPbExtension) { if (!in_array($option, $supported_list)) { $app->enqueueMessage(sprintf('Please enable the JSN PageBuilder %s Extention Support before using. How to enable it, click <a href="%s" target="_blank">here</a>', strtoupper($installedPbExtension->element), 'index.php?option=com_pagebuilder&view=configuration&s=configuration&g=msgs'), 'warning'); return; } } if ($framework->extension_id && in_array($option, $supported_list)) { // Get PageBuilder configuration if (!in_array($option, $supported_list)) { $isInstalled = JSNPagebuilderHelpersExtensions::checkInstalledPlugin(str_replace('com_', '', $option)); if (!$isInstalled['isInstalled']) { return; } } // Check if it's enabled or not $isEnabled = $params->get('enable_pagebuilder', 1); if ($isEnabled) { $conf = JFactory::getConfig(); $editor = $conf->get('editor'); // Inlcude the entry js file. JSNHtmlAsset::addScript(JSNPB_ADMIN_URL . '/assets/js/joomlashine.noconflict.js'); JSNHtmlAsset::addScript(JSNPB_PLG_SYSTEM_ASSETS_URL . '3rd-party/jquery-ui/js/jquery-ui-1.10.3.custom.js'); JSNHtmlAsset::addScript(JSNPB_PLG_SYSTEM_ASSETS_URL . '3rd-party/jquery-livequery/jquery.livequery.min.js'); JSNHtmlAsset::addScript(JSNPB_ADMIN_URL . '/assets/js/builder-layout.js'); JSNHtmlAsset::addScript(JSNPB_ADMIN_URL . '/assets/joomlashine/js/jsn-modal.js'); JSNHtmlAsset::addScript(JSNPB_ADMIN_URL . '/assets/js/elements-lang.js'); JSNHtmlAsset::addScript(JSNPB_ADMIN_URL . '/assets/js/jquery.alphanumeric/jquery.alphanumeric.js'); JSNHtmlAsset::addScript(JSNPB_ADMIN_URL . '/assets/js/shortcodesetting/settings-handler.js'); JSNHtmlAsset::addScript(JSNPB_ADMIN_URL . '/assets/js/handle.js'); // Include supoported editor script switch ($editor) { case 'codemirror': JSNHtmlAsset::addScript(JURI::root(true) . '/plugins/editors-xtd/pagebuilder/assets/js/supported-editor/codemirror.js'); break; case 'tinymce': JSNHtmlAsset::addScript(JURI::root(true) . '/plugins/editors-xtd/pagebuilder/assets/js/supported-editor/tiny-mce.js'); break; case 'jce': JSNHtmlAsset::addScript(JURI::root(true) . '/plugins/editors-xtd/pagebuilder/assets/js/supported-editor/jce.js'); break; case 'jckeditor': JSNHtmlAsset::addScript(JURI::root(true) . '/plugins/editors-xtd/pagebuilder/assets/js/supported-editor/jckeditor.js'); break; case 'ckeditor': JSNHtmlAsset::addScript(JURI::root(true) . '/plugins/editors-xtd/pagebuilder/assets/js/supported-editor/ckeditor.js'); break; case 'artofeditor': JSNHtmlAsset::addScript(JURI::root(true) . '/plugins/editors-xtd/pagebuilder/assets/js/supported-editor/artofeditor.js'); break; case 'arkeditor': JSNHtmlAsset::addScript(JURI::root(true) . '/plugins/editors-xtd/pagebuilder/assets/js/supported-editor/arkeditor.js'); break; default: JSNHtmlAsset::addScript(JURI::root(true) . '/plugins/editors-xtd/pagebuilder/assets/js/supported-editor/default.js'); break; } // Generate random string to assign to switcher button $random_id = JSNPagebuilderHelpersShortcode::generateRandomString(); JSNHtmlAsset::addScript(JSNPB_ADMIN_URL . '/assets/js/entry.js'); $js = "\n\t\t\t\t\tvar Pb_Ajax\t= {};\n\n\t\t\t\t\tvar JSNPbParams = {pbstrings:{}};\n\t\t\t\t\tJSNPbParams.rootUrl = '" . JUri::root() . "';\n\t\t\t\t\tJSNPbParams.pbstrings.COPY = '" . JText::_('copy') . "';\n\t\t\t\t\tJSNPbParams.pbstrings.EMPTY = '" . JText::_('(Untitled)') . "';\n\t\t\t\t\tJSNPbParams.pbstrings.ALERT_DELETE_ROW = '" . JText::_('Are you sure you want to delete the whole row including all elements it contains?') . "';\n\t\t\t\t\tJSNPbParams.pbstrings.ALERT_DELETE_COLUMN = '" . JText::_('Are you sure you want to delete the whole column including all elements it contains?') . "';\n\t\t\t\t\tJSNPbParams.pbstrings.ALERT_DELETE_ELEMENT = '" . JText::_('Are you sure you want to delete the element?') . "';\n\t\t\t\t\tvar pb;\n\t\t\t\t\tvar pbContentStatus_{$random_id}\t= 'normal';\n\n\t\t\t\t\t// Set global pagebuilder instance\n\t\t\t\t\tvar jsnpb_{$random_id};\n\n\t\t\t\t\t// Method to switch between Joomla editor and PageBuilder\n\t\t\t\t\tfunction switchPagebuilder(id, status){\n\t\t\t\t\t\t(function (\$){\n\t\t\t\t\t\t\tif (status == 'on') {\n\t\t\t\t\t\t\t\tjsnpb_{$random_id}\t= new \$.JSNPageBuilder(id);\n\t\t\t\t\t\t\t\tpbContentStatus_{$random_id} = 'pb';\n\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\tjsnpb_{$random_id}.transformToSource();\n\t\t\t\t\t\t\t\tpbContentStatus_{$random_id} = 'normal';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})(JoomlaShine.jQuery);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Entry button group structure which will be appended to the aditor\n\t\t\t\t\tvar pbEntryButtons\t= '<div class=\"jsn-form-bar pb-switcher-group\">'\n\t\t\t\t\t\t\t+ '<div id=\"pb-editor-switcher\" class=\"btn-group\">'\n\t\t\t\t\t\t\t+\t'<button type=\"button\" class=\"switchmode-button pb-off btn active btn-success\" id=\"pagebuilder-off-{$random_id}\" >Default Editor</button>'\n\t\t\t\t\t\t\t+\t'<button type=\"button\" class=\"switchmode-button pb-on btn\" id=\"pagebuilder-on-{$random_id}\" >PageBuilder</button>'\n\t\t\t\t\t\t\t+'</div>'\n\t\t\t\t\t\t\t+\t'<input type=\"hidden\" id=\"jform_pb_total\" name=\"jform_pb_total\" value=\"{$pbTotal}\">'\n\t\t\t\t\t\t\t+\t'<input type=\"hidden\" id=\"jform_content_id\" name=\"jform_content_id\" value=\"{$id}\">'\n\t\t\t\t\t\t\t+\t'<input type=\"hidden\" id=\"jform_list_id\" name=\"jform_list_id\" value=\"{$listId}\">'\n\t\t\t\t\t\t\t+'<div class=\"pull-right\" id=\"top-btn-actions\">'\n +'<!--<button class=\"btn btn-default page-custom-css\" onclick=\"return false;\">Custom CSS</button>-->'\n + '<input type=\"hidden\" id=\"pb_content_id\" name=\"pb_content_id\" value=\"{$id}\">'\n +'</div>'\n\t\t\t\t\t\t+'</div>';\n\n\t\t\t\t\t(function (\$){\n\t\t\t\t\t\t\$(window).load(function (){\n\t\t\t\t\t\t\$('body').find('ul#myTabTabs li:first').on('click', function(){\n\t\t\t\t\t\t\t\$('.switchmode-button.pb-off').click();\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (\$('#jform_module').length)\n\t\t\t\t\t\t \t\t{\n\t\t\t\t\t\t\t\t\tif (\$('#jform_module').val() != 'mod_custom')\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t \treturn false;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\tvar editorHelper_{$random_id}\t= new \$.JSNPbEditorHelper();\n\t\t\t\t\t\t\tvar buttonGroups\t= editorHelper_{$random_id}.initEntryButtons('" . $name . "', pbEntryButtons);\n\n\t\t\t\t\t\t\t//Auto switch to PageBuilder if shortcode structure detected\n\t\t\t\t\t\t\tvar _content\t= \$('#" . $name . "').val();\n\t\t\t\t\t\t\tif (_content.indexOf('[pb_row') >= 0) {\n\t\t\t\t\t\t\t\t//setTimeout(function (){\n\t\t\t\t\t\t\t\t\t\$('.switchmode-button.pb-on', buttonGroups).click();\n\t\t\t\t\t\t\t\t//}, 500);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t})(JoomlaShine.jQuery);\n\t\t\t\t"; JSNHtmlAsset::addInlineScript($js); JSNHtmlAsset::addStyle(JSNPB_FRAMEWORK_ASSETS . '/3rd-party/jquery-ui/css/ui-bootstrap/jquery-ui-1.9.0.custom.css'); JSNHtmlAsset::addStyle(JSNPB_FRAMEWORK_ASSETS . '/joomlashine/css/jsn-gui.css'); JSNHtmlAsset::addStyle(JSNPB_PLG_SYSTEM_ASSETS_URL . 'css/pagebuilder.css'); JSNHtmlAsset::addStyle(JSNPB_ADMIN_URL . '/assets/css/jsn-element-font.css'); JSNHtmlAsset::addStyle(JSNPB_FRAMEWORK_ASSETS . '/joomlashine/css/jsn-advanced-parameters.css'); // for text, JSNHtmlAsset::addStyle(JSNPB_ADMIN_URL . '/assets/css/settings.css'); } } }
/** * DEFINE shortcode content * * @param array $attributes * @param mixed $content * * @return string */ function element_shortcode($attributes = null, $content = null) { $document = JFactory::getDocument(); $document->addScript(JSNPB_ELEMENT_URL . '/market/assets/js/3rd-party/slick/slick.min.js', 'text/javascript'); $document->addStyleSheet(JSNPB_ELEMENT_URL . '/market/assets/js/3rd-party/slick/slick.css', 'text/css'); $document->addStyleSheet(JSNPB_ELEMENT_URL . '/market/assets/css/market.css', 'text/css'); $arrParams = JSNPagebuilderHelpersShortcode::shortcodeAtts($this->config['params'], $attributes); $htmlElement = ''; $itemShortcode = empty($content) ? JSNPagebuilderHelpersShortcode::removeAutop($content) : JSNPagebuilderHelpersBuilder::generateShortCode($content, false, 'frontend', true); $itemsData = explode('<!--separate-->', $itemShortcode); // remove empty element $itemsData = array_filter($itemsData); $dataMarket = array(); // decode foreach ($itemsData as $_key => $_value) { $dataMarket[] = json_decode($_value, true); } $randomMarketId = "market-" . JSNPagebuilderHelpersShortcode::generateRandomString(); $marketLayoutClass = $attributes['market_layout'] == self::PB_MARKET_CAROUSEL_LAYOUT ? 'pb-market-carousel' : 'pb-market-table'; $htmlElement .= "<div id='{$randomMarketId}' class='pb-market-wrapper {$marketLayoutClass}'><div class='pb-market-header'><div class='pb-market-title'>{$attributes['market_title']}</div>"; if (count($dataMarket) <= 0) { } else { if ($attributes['market_show_time_update'] == 'yes') { $timeStamp = new DateTime($dataMarket[0]['time_stamp']); $timeStamp->setTimezone(new DateTimeZone('UTC')); $htmlElement .= "<div class='pb-market-update-time'>{$timeStamp->format('D, M d, Y, g:iA e')}</div>"; } $headerList = explode("__#__", $attributes['market_show_data']); foreach ($headerList as $_key => $_value) { if ($_value == null || $_value == " ") { unset($headerList[$_key]); } } $marketDataType = JSNPbMarketHelper::getMarketDataType(); if ($attributes['market_layout'] == self::PB_MARKET_CAROUSEL_LAYOUT) { if ($attributes['market_show_carousel_control'] == JSNPagebuilderHelpersType::PB_HELPER_ANSWER_YES) { $htmlElement .= "<div class='pb-market-carousel-control'>"; if ($attributes['market_slide_dimension'] == JSNPbMarketHelper::PB_MARKET_SLIDE_DIMENSION_HORIZONTAL) { $htmlElement .= "<div class='button pb-market-carousel-up'><i class='fa fa-chevron-up'></i></div>"; $htmlElement .= "<div class='button pb-market-carousel-down'><i class='fa fa-chevron-down'></i></div>"; } else { $htmlElement .= "<div class='button pb-market-carousel-back'><i class='fa fa-chevron-left'></i></div>"; $htmlElement .= "<div class='button pb-market-carousel-next'><i class='fa fa-chevron-right'></i></div>"; } $htmlElement .= "</div>"; } // End of header $htmlElement .= "</div>"; $htmlElement .= "<div class='pb-market-content pb-market-layout-{$attributes['market_slide_dimension']}'>"; // Show carousel layout foreach ($dataMarket as $_key => $_item) { if (strpos($_item['data'][JSNPbMarketHelper::PB_MARKET_DATA_TYPE_CHANGE], "+") !== false) { $htmlElement .= "<div class='pb-market-carousel-item change-up'>"; } else { $htmlElement .= "<div class='pb-market-carousel-item change-down'>"; } $style = ""; if ($attributes['market_slide_dimension'] == JSNPbMarketHelper::PB_MARKET_SLIDE_DIMENSION_HORIZONTAL) { $style .= "style='width: " . 100 / count($headerList) . "%'"; } if ($_item['data'][JSNPbMarketHelper::PB_MARKET_DATA_TYPE_CHANGE] == null) { $index = 0; foreach ($headerList as $_value) { if ($_value == JSNPbMarketHelper::PB_MARKET_DATA_TYPE_NAME || $_value == JSNPbMarketHelper::PB_MARKET_DATA_TYPE_SYMBOL) { $htmlElement .= "<div {$style} class='market-" . strtolower(str_replace("% ", "percent-", $marketDataType[$_value])) . "'>{$_item['data'][$_value]}</div>"; $index++; } } if (count($headerList) - $index > 0) { if (isset($_item['error'])) { $htmlElement .= "<div class='error'>" . $_item['error'] . "</div>"; } else { $htmlElement .= "<div class='error'>" . JText::_('JSN_PAGEBUILDER_MARKET_ERROR_SYMBOL') . "</div>"; } } } else { foreach ($headerList as $_value) { if (isset($_item['data'][$_value])) { $htmlElement .= "<div {$style} class='market-" . strtolower(str_replace("% ", "percent-", $marketDataType[$_value])) . "'>{$_item['data'][$_value]}</div>"; } } } $htmlElement .= "</div>"; } } else { // End of header $htmlElement .= "</div>"; $htmlElement .= "<div class='pb-market-content'>"; // Show table layout $htmlElement .= "<table class='table'>"; $htmlElement .= "<thead><tr>"; foreach ($headerList as $_key => $_value) { if (isset($marketDataType[$_value]) && $_value != JSNPbMarketHelper::PB_MARKET_DATA_TYPE_CHART) { $htmlElement .= "<th class='market-" . strtolower(str_replace("% ", "percent-", $marketDataType[$_value])) . "'>{$marketDataType[$_value]}</th>"; } } $htmlElement .= "</tr></thead>"; $htmlElement .= "<tbody>"; foreach ($dataMarket as $_key => $_item) { if ($_item['data'][JSNPbMarketHelper::PB_MARKET_DATA_TYPE_CHANGE] == null) { $htmlElement .= "<tr class='error'>"; $index = 0; foreach ($headerList as $_value) { if ($_value == JSNPbMarketHelper::PB_MARKET_DATA_TYPE_NAME || $_value == JSNPbMarketHelper::PB_MARKET_DATA_TYPE_SYMBOL) { $htmlElement .= "<td class='market-" . strtolower(str_replace("% ", "percent-", $marketDataType[$_value])) . "'>{$_item['data'][$_value]}</td>"; $index++; } } if (count($headerList) - $index > 0) { $htmlElement .= "<td colspan='" . (count($headerList) - 1) . "'>" . JText::_('JSN_PAGEBUILDER_MARKET_ERROR_SYMBOL') . "</td>"; } } else { if (strpos($_item['data'][JSNPbMarketHelper::PB_MARKET_DATA_TYPE_CHANGE], "+") !== false) { $htmlElement .= "<tr class='change-up'>"; } else { $htmlElement .= "<tr class='change-down'>"; } foreach ($headerList as $_value) { if (isset($_item['data'][$_value])) { $htmlElement .= "<td class='market-" . strtolower(str_replace("% ", "percent-", $marketDataType[$_value])) . "'>{$_item['data'][$_value]}</td>"; } } } $htmlElement .= "</tr>"; } $htmlElement .= "</tbody>"; $htmlElement .= "</table>"; } } $htmlElement .= "</div></div>"; if ($attributes['market_layout'] == self::PB_MARKET_CAROUSEL_LAYOUT) { $scriptCarousel = "<script type='text/javascript'>(function (\$) {\n\t\t\t\t\t\$(document).ready(function ()\n\t\t\t\t\t{\n \$('#{$randomMarketId} .pb-market-content').slick({\n infinite: true"; if ($attributes['market_slide_dimension'] == JSNPbMarketHelper::PB_MARKET_SLIDE_DIMENSION_HORIZONTAL) { $scriptCarousel .= ", vertical: true, slidesToShow: " . (int) $attributes['market_number_to_show']; } else { $scriptCarousel .= ", variableWidth: true"; } if ($attributes['market_auto_play_carousel'] == JSNPagebuilderHelpersType::PB_HELPER_ANSWER_YES) { $scriptCarousel .= ", autoplay: true"; if (is_numeric($attributes['market_auto_play_speed']) && (int) $attributes['market_auto_play_speed'] > 0) { $scriptCarousel .= ", autoplaySpeed: {$attributes['market_auto_play_speed']}000"; } else { $scriptCarousel .= ", autoplaySpeed: 3000"; } } if ($attributes['market_show_carousel_control'] == JSNPagebuilderHelpersType::PB_HELPER_ANSWER_YES) { if ($attributes['market_slide_dimension'] == JSNPbMarketHelper::PB_MARKET_SLIDE_DIMENSION_HORIZONTAL) { $scriptCarousel .= ", prevArrow: \$('#{$randomMarketId}').find('.pb-market-carousel-up'), nextArrow: \$('#{$randomMarketId}').find('.pb-market-carousel-down')"; } else { $scriptCarousel .= ", prevArrow: \$('#{$randomMarketId}').find('.pb-market-carousel-back'), nextArrow: \$('#{$randomMarketId}').find('.pb-market-carousel-next')"; } } else { $scriptCarousel .= ", arrows: false"; } $scriptCarousel .= ", swipe: false\n });\n\t\t\t\t\t});\n\t\t\t\t})(JoomlaShine.jQuery);</script>"; $htmlElement .= $scriptCarousel; } return $this->element_wrapper($htmlElement, $arrParams); }
/** * DEFINE shortcode content * * @param type $atts * @param type $content * * @return string */ function element_shortcode($atts = null, $content = null) { $arr_params = JSNPagebuilderHelpersShortcode::shortcodeAtts($this->config['params'], $atts); if (empty($content) && isset($atts['text'])) { $content = $atts['text']; } $content = preg_replace("/^<\\/p>/", "", $content); extract($arr_params); $html_element = $html_style = $html_width = ''; if (isset($enable_dropcap) && $enable_dropcap == 'yes') { if ($content) { $styles = array(); if ($dropcap_font_face_type == 'google fonts' and $dropcap_font_face_value != '') { $document = JFactory::getDocument(); $document->addStyleSheet("http://fonts.googleapis.com/css?family={$dropcap_font_face_value}", 'text/css'); $styles[] = 'font-family:' . $dropcap_font_face_value; } elseif ($dropcap_font_face_type == 'standard fonts' and $dropcap_font_face_value) { $styles[] = 'font-family:' . $dropcap_font_face_value; } if (intval($dropcap_font_size) > 0) { $styles[] = 'font-size:' . intval($dropcap_font_size) . 'px'; $styles[] = 'line-height:' . intval($dropcap_font_size / 2) . 'px'; } switch ($dropcap_font_style) { case 'bold': $styles[] = 'font-weight:700'; break; case 'italic': $styles[] = 'font-style:italic'; break; case 'normal': $styles[] = 'font-weight:normal'; break; } if (strpos($dropcap_font_color, '#') !== false) { $styles[] = 'color:' . $dropcap_font_color; } $random_id = JSNPagebuilderHelpersShortcode::generateRandomString(6, true); if (count($styles)) { $html_style .= 'div.pb-element-text div.dropcap.' . $random_id . ' :first-child::first-letter { float:left;margin-top:5px;margin-right:5px;'; $html_style .= implode(';', $styles); $html_style .= '}'; } $html_element .= "<div class='dropcap {$random_id}'>{$content}</div>"; } } else { $html_element .= '<div>' . $content . '</div>'; } if ($width_value) { $width_style = 'width:' . $width_value . $width_unit; } if (!empty($width_style)) { $html_width .= 'div.pb-element-text{margin:0 auto;'; $html_width .= $width_style; $html_width .= '}'; } $document = JFactory::getDocument(); if ($html_style) { $document->addStyleDeclaration($html_style, 'text/css'); } if ($html_width) { $document->addStyleDeclaration($html_width, 'text/css'); } $html_element = JSNPagebuilderHelpersFunctions::add_absolute_path_to_image_url($html_element); return $this->element_wrapper($html_element, $arr_params); }
/** * Generate HTML for local audio player */ function generate_local_files($params) { $random_id = JSNPagebuilderHelpersShortcode::generateRandomString(); $audio_size = array(); $audio_size['width'] = ' width="' . $params['audio_local_dimension_width'] . '" '; $audio_size['height'] = $params['audio_local_dimension_height'] != '' ? ' height="' . $params['audio_local_dimension_height'] . '" ' : ''; $player_options = '{'; $player_options .= $params['audio_local_start_volume'] != '' ? 'startVolume: ' . (int) $params['audio_local_start_volume'] / 100 . ',' : ''; $player_options .= $params['audio_local_loop'] != '' ? 'loop: ' . $params['audio_local_loop'] . ',' : ''; if (!isset($params['audio_local_player_image'])) { $_player_color = isset($params['audio_local_player_color']) ? '$( ".mejs-mediaelement, .mejs-controls", audio_container ).css( "background", "none repeat scroll 0 0 ' . $params['audio_local_player_color'] . '" );' : ''; } else { $_player_color = isset($params['audio_local_player_color']) ? '$( ".mejs-mediaelement, .mejs-controls", audio_container ).css( "background", "url(\'' . $params['audio_local_player_image'] . '\' ) repeat scroll 0 0 ' . $params['audio_local_player_color'] . '");' : ''; } $_progress_bar_color = isset($params['audio_local_progress_color']) ? '$( ".mejs-time-loaded, .mejs-horizontal-volume-current", audio_container ).css( "background", "none repeat scroll 0 0 ' . $params['audio_local_progress_color'] . '" );' : ''; $params['audio_local_elements'] = explode('__#__', $params['audio_local_elements']); $player_elements = ''; $player_elements .= in_array('play_button', $params['audio_local_elements']) ? '' : '$( ".mejs-playpause-button", audio_container ).hide();'; $player_elements .= in_array('current_time', $params['audio_local_elements']) ? '' : '$( ".mejs-currenttime-container", audio_container ).hide();'; $player_elements .= in_array('time_rail', $params['audio_local_elements']) ? '' : '$( ".mejs-time-rail", audio_container ).hide();'; $player_elements .= in_array('track_duration', $params['audio_local_elements']) ? '' : '$( ".mejs-duration-container", audio_container ).hide();'; $player_elements .= in_array('volume_button', $params['audio_local_elements']) ? '' : '$( ".mejs-volume-button", audio_container ).hide();'; $player_elements .= in_array('volume_slider', $params['audio_local_elements']) ? '' : '$( ".mejs-horizontal-volume-slider", audio_container ).hide();'; $container_class = ''; if ($params['audio_alignment'] === 'right') { $player_elements .= 'audio_container.css( "float", "right" )'; $container_class .= 'clearafter '; } else { if ($params['audio_alignment'] === 'center') { $player_elements .= 'audio_container.css( "margin", "0 auto" )'; } else { if ($params['audio_alignment'] === 'left') { $player_elements .= 'audio_container.css( "float", "left" )'; $container_class .= 'clearafter '; } } } // Genarate Container class $container_class = $container_class ? ' class="' . $container_class . '" ' : ''; $player_options .= 'success: function( mediaElement, domObject ){ var audio_container = $( domObject ).parents( ".mejs-container" ); ' . $player_elements . ' },'; $player_options .= 'keyActions:[]}'; if (isset($params['audio_source_local']) && !empty($params['audio_source_local'])) { $script = 'JoomlaShine.jQuery( document ).ready( function ($ ){ new MediaElementPlayer("#' . $random_id . '", ' . $player_options . ' ); });'; $document = JFactory::getDocument(); $document->addScriptDeclaration($script, 'text/javascript'); } $container_style = ''; $container_style .= isset($params['audio_margin_left']) && $params['audio_margin_left'] != '' ? 'margin-left:' . $params['audio_margin_left'] . 'px;' : ''; $container_style .= isset($params['audio_margin_top']) && $params['audio_margin_top'] != '' ? 'margin-top:' . $params['audio_margin_top'] . 'px;' : ''; $container_style .= isset($params['audio_margin_right']) && $params['audio_margin_right'] != '' ? 'margin-right:' . $params['audio_margin_right'] . 'px;' : ''; $container_style .= isset($params['audio_margin_bottom']) && $params['audio_margin_bottom'] != '' ? 'margin-bottom:' . $params['audio_margin_bottom'] . 'px;' : ''; $container_style = $container_style ? ' style=" ' . $container_style . ' " ' : ''; // Define the media type $src = str_replace(' ', '+', $params['audio_source_local']); $source = '<source type="%s" src="%s" />'; $type = JSNPagebuilderHelpersShortcode::checkFiletype($src); $source = sprintf($source, $type['type'], $src); return '<div ' . $container_class . $container_style . '> <audio controls="controls" preload="none" ' . $audio_size['width'] . $audio_size['height'] . ' id="' . $random_id . '" src="' . $src . '" > ' . $source . ' </audio> </div><div style="clear: both"></div>'; }
/** * DEFINE shortcode content * * @param type $atts * @param type $content * * @return string */ public function element_shortcode($atts = null, $content = null) { $document = JFactory::getDocument(); $document->addStyleSheet(JSNPB_ELEMENT_URL . '/carousel/assets/css/carousel.css', 'text/css'); $document->addStyleSheet(JSNPB_ELEMENT_URL . '/carousel/assets/css/carousel-responsive.css', 'text/css'); $document->addScriptDeclaration("if (typeof jQuery != 'undefined' && typeof MooTools != 'undefined' ) {\n\t\t\t\t\t\t\t\t\t\t Element.implement({\n\t\t\t\t\t\t\t\t\t\t slide: function(how, mode){\n\t\t\t\t\t\t\t\t\t\t return this;\n\t\t\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t\t\t\t });\n\n\t\t\t\t\t\t\t\t\t\t}", 'text/javascript'); $arr_params = JSNPagebuilderHelpersShortcode::shortcodeAtts($this->config['params'], $atts); extract($arr_params); $random_id = JSNPagebuilderHelpersShortcode::generateRandomString(); $carousel_id = "carousel_{$random_id}"; // Set fixed stylesheet $document->addStyleDeclaration("#{$carousel_id} .item{\n\t\t\twidth: 100% !important;\n\t\t\tmargin: 0;\n\t\t}", 'text/css'); $interval_time = !empty($cycling_interval) ? intval($cycling_interval) * 1000 : 5000; $interval = $automatic_cycling == 'yes' ? $interval_time : 'false'; $pause = $pause_mouseover == 'yes' ? 'pause : "hover"' : 'pause : "false"'; $script = "<script type='text/javascript'>\n\t\t\t(function (\$){ \n\t\t\t\t\$( document ).ready(function(){\n\t\t\t\t\tif( \$( '#{$carousel_id}' ).length ){ \n\t\t\t\t\t\t\$( '#{$carousel_id}' ).carousel( {interval: {$interval},{$pause}} );\n\t\t\t\t\t\t\n\t\t\t\t\t\t\$( '#{$carousel_id} .carousel-indicators li' ).each(function (i) {\n\t\t\t\t\t\t\t\$(this).on('click', function () {\n\t\t\t\t\t\t\t\t\$('#{$carousel_id}').carousel(i);\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t} )( JoomlaShine.jQuery );\n\t\t</script>"; $styles = array(); if (!empty($dimension_width)) { $styles[] = "width : {$dimension_width}{$dimension_width_unit};"; } if (!isset($atts['dimension_height'])) { $styles[] = "min-height : 0px;"; } else { if (!empty($dimension_height)) { $styles[] = "min-height : {$dimension_height}px;"; } } if (in_array($align, array('left', 'right', 'inherit'))) { $styles[] = 'float : ' . $align . ';'; } else { if ($align == 'center') { $styles[] = 'margin : 0 auto;'; } } $styles = trim(implode(' ', $styles)); $styles = !empty($styles) ? "style='{$styles}'" : ''; $carousel_indicators = array(); $carousel_indicators[] = '<ol class="carousel-indicators">'; $sub_shortcode = empty($content) ? JSNPagebuilderHelpersShortcode::removeAutop($content) : JSNPagebuilderHelpersBuilder::generateShortCode($content, false, 'frontend', true); $items = explode('<!--seperate-->', $sub_shortcode); $items = array_filter($items); $initial_open = isset($initial_open) ? $initial_open > count($items) ? 1 : $initial_open : 1; foreach ($items as $idx => $item) { $active = $idx + 1 == $initial_open ? 'active' : ''; $item = str_replace('{active}', $active, $item); $item = str_replace('{WIDTH}', !empty($dimension_width) ? 'width : ' . $dimension_width . $dimension_width_unit . ';' : '', $item); $item = str_replace('{HEIGHT}', !empty($dimension_height) ? 'height : ' . $dimension_height . 'px;' : '', $item); $items[$idx] = $item; $active_li = $idx + 1 == $initial_open ? "class='active'" : ''; $carousel_indicators[] = "<li data-target='#{$carousel_id}' {$active_li}></li>"; } $carousel_content = "<div class='carousel-inner'>" . implode('', $items) . '</div>'; $carousel_indicators[] = '</ol>'; $carousel_indicators = implode('', $carousel_indicators); if ($show_indicator == 'no') { $carousel_indicators = ''; } $carousel_navigator = ''; if ($show_arrows == 'yes') { $carousel_navigator = "<a class='left carousel-control' href='#{$carousel_id}' data-slide='prev'><span class='icon-arrow-left'></span></a><a class='right carousel-control' href='#{$carousel_id}' data-slide='next'><span class='icon-arrow-right'></span></a>"; } $html = "<div class='carousel slide' {$styles} id='{$carousel_id}'>{$carousel_indicators} {$carousel_content} {$carousel_navigator}</div><div style=\"clear: both\"></div>"; return $this->element_wrapper($html . $script, $arr_params); }
/** * DEFINE shortcode content * * @param type $atts * @param type $content * * @return string */ public function element_shortcode($atts = null, $content = null) { $html_element = $container_class = $str_scripts = ''; $arr_params = JSNPagebuilderHelpersShortcode::shortcodeAtts($this->config['params'], $atts); extract($arr_params); $arrDefaultOptions = array('streetViewControl', 'zoomControl', 'panControl', 'mapTypeControl', 'scaleControl', 'overviewControl'); if ($gmap_elements) { $arr_elements = array_filter(explode('__#__', $gmap_elements)); foreach ($arrDefaultOptions as $i => $item) { if (in_array($item, $arr_elements)) { $str_scripts .= $item . ':true, '; } else { $str_scripts .= $item . ':false, '; } } } $random_id = JSNPagebuilderHelpersShortcode::generateRandomString(); $player_elements = ''; if ($gmap_alignment == 'right') { $player_elements .= '$("#pb-gmap-' . $random_id . '").css({"float" : "right"});'; } elseif ($gmap_alignment == 'center') { $player_elements .= '$("#pb-gmap-' . $random_id . '").css({"margin" : "0 auto", "display" : "block"});'; } elseif ($gmap_alignment == 'left') { $player_elements .= '$("#pb-gmap-' . $random_id . '").css({"float" : "left"});'; } $html_element .= '<script type="text/javascript">(function ($) { $( document ).ready( function () { ' . $player_elements . ' var map_' . $random_id . ' = ""; var marker_locations_' . $random_id . ' = []; var jsnpbPathRoot = "' . JURI::root() . '" function get_latlong(obj) { var myLatlng = new google.maps.LatLng( obj.gmi_lat, obj.gmi_long); return myLatlng; } function get_infobox(obj) { var infowindow = ""; var contentString = "<div class=\\"pb-gmi-info\\" style=\\"width:250px\\" >"; contentString += "<div class=\\"pb-gmi-thumb\\">"; if ( obj.gmi_image != "" && obj.gmi_image != "http://" ) { if ((/\\.(gif|jpg|jpeg|tiff|png)$/i).test(obj.gmi_image) && !/\\b(http|https)/.test(obj.gmi_image)) { contentString += "<img src=\\"" + jsnpbPathRoot + obj.gmi_image + "\\" />"; } else { contentString += "<img src=\\"" + obj.gmi_image + "\\" />"; } } contentString += "</div>"; contentString += "<span class=\\"pb-gmi-title\\"><b>" + obj.gmi_title + "</b></span>"; if ( obj.gmi_desc_content ) contentString += "<p>" + obj.gmi_desc_content + "</p>"; if ( obj.gmi_url != "" && obj.gmi_url != "http://" ) contentString += "<a href=\\"" + obj.gmi_url + "\\" target=\\"_blank\\">more...></a>"; contentString += "</div>"; infowindow = new google.maps.InfoWindow({ content: contentString }); infowindow.setOptions({maxWidth:300}); return infowindow; } function markerAtPoint(latlng) { for (var i = 0; i < marker_locations_' . $random_id . '.length; ++i) { if (marker_locations_' . $random_id . '[i].equals(latlng)) return true; } return false; } function initialize_' . $random_id . '() { var gmap_zoom = parseInt("' . $gmap_zoom . '"); var gmap_lat = ""; var gmap_long = ""; var gmap_type = google.maps.MapTypeId.' . $gmap_type . '; var directionsService_' . $random_id . ' = new google.maps.DirectionsService(); var has_direction = false; var mapOptions_' . $random_id . ' = { zoom: gmap_zoom, center: new google.maps.LatLng(0,0), mapTypeId: gmap_type, ' . $str_scripts . ' }; map_' . $random_id . ' = new google.maps.Map(document.getElementById(\'pb-gmap-' . $random_id . '\'), mapOptions_' . $random_id . '); var rendererOptions_' . $random_id . ' = { map: map_' . $random_id . ', suppressMarkers: true } var directionsDisplay_' . $random_id . ' = new google.maps.DirectionsRenderer(rendererOptions_' . $random_id . '); directionsDisplay_' . $random_id . '.setMap(map_' . $random_id . '); // Check has directions $( "#pb-gmap-wrapper-' . $random_id . ' .pb-gmi-lat-long" ).each(function (index) { var obj = JSON.parse($(this).val()); if ( obj.gmi_lat != "" && obj.gmi_long != "" && obj.gmi_destination != "" ) { has_direction = true; } }); // Add markers if ( has_direction == false ) { $( "#pb-gmap-wrapper-' . $random_id . ' .pb-gmi-lat-long" ).each(function (index) { var obj = JSON.parse($(this).val()); if ( obj.gmi_lat != "" && obj.gmi_long != "" ) { var myLatlng = get_latlong(obj); var infowindow = get_infobox(obj); if ( map_' . $random_id . ' ) { var marker = new google.maps.Marker({ position: myLatlng, map: map_' . $random_id . ', title: obj.gmi_title }); marker_locations_' . $random_id . '.push(myLatlng); map_' . $random_id . '.setCenter(marker.getPosition()); google.maps.event.addListener(marker, \'click\', function() { infowindow.open(map_' . $random_id . ',marker); }); } } }); } else { $( "#pb-gmap-wrapper-' . $random_id . ' .pb-gmi-lat-long" ).each(function (i) { var obj = JSON.parse($(this).val()); $( "#pb-gmap-wrapper-' . $random_id . ' .pb-gmi-lat-long" ).each(function (j) { var sub_obj = JSON.parse($(this).val()); if ( sub_obj.gmi_title == obj.gmi_destination && sub_obj.gmi_lat != "" && sub_obj.gmi_long != "" ) { var start = get_latlong(obj); var end = get_latlong(sub_obj); var infowindow = get_infobox(obj); if ( map_' . $random_id . ' ) { var marker = new google.maps.Marker({ position: start, map: map_' . $random_id . ', title: obj.gmi_title }); marker_locations_' . $random_id . '.push(start); google.maps.event.addListener(marker, \'click\', function() { infowindow.open(map_' . $random_id . ',marker); }); } var sub_infowindow = get_infobox(sub_obj); if ( map_' . $random_id . ' ) { var sub_marker = new google.maps.Marker({ position: end, map: map_' . $random_id . ', title: sub_obj.gmi_title }); marker_locations_' . $random_id . '.push(end); google.maps.event.addListener(sub_marker, \'click\', function() { sub_infowindow.open(map_' . $random_id . ',sub_marker); }); } var request = { origin:start, destination:end, travelMode: google.maps.DirectionsTravelMode.DRIVING }; directionsService_' . $random_id . '.route(request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay_' . $random_id . '.setDirections(response); } }); } if ( markerAtPoint(new google.maps.LatLng( obj.gmi_lat, obj.gmi_long) ) == false ) { var myLatlng = get_latlong(obj); var infowindow = get_infobox(obj); if ( map_' . $random_id . ' ) { var marker = new google.maps.Marker({ position: myLatlng, map: map_' . $random_id . ', title: obj.gmi_title }); marker_locations_' . $random_id . '.push(myLatlng); map_' . $random_id . '.setCenter(marker.getPosition()); google.maps.event.addListener(marker, \'click\', function() { infowindow.open(map_' . $random_id . ',marker); }); } } }); }); } } google.maps.event.addDomListener(window, \'load\', initialize_' . $random_id . '); }); })(jQuery)</script>'; $class = 'pb-googlemap'; if ($gmap_container_style == 'img-thumbnail') { $class .= ' img-thumbnail'; } if ($gmap_margin_top) { $gmap_styles[] = "margin-top:{$gmap_margin_top}px !important"; } if ($gmap_margin_bottom) { $gmap_styles[] = "margin-bottom:{$gmap_margin_bottom}px !important"; } if ($gmap_margin_right) { $gmap_styles[] = "margin-right:{$gmap_margin_right}px !important"; } if ($gmap_margin_left) { $gmap_styles[] = "margin-left:{$gmap_margin_left}px !important"; } if ($gmap_dimension_height) { $gmap_styles[] = "height:{$gmap_dimension_height}px !important"; } if ($gmap_dimension_width) { $gmap_styles[] = "width:{$gmap_dimension_width}{$gmap_dimension_width_unit} !important"; } $styles = count($gmap_styles) ? ' style="' . implode(';', $gmap_styles) . '"' : ''; $html_element .= '<div id="pb-gmap-wrapper-' . $random_id . '">'; $html_element .= '<div id="pb-gmap-' . $random_id . '" ' . $styles . ' class="' . $class . '"></div>'; $sub_shortcode = empty($content) ? JSNPagebuilderHelpersShortcode::removeAutop($content) : JSNPagebuilderHelpersBuilder::generateShortCode($content, false, 'frontend', true); $items = explode('<!--seperate-->', $sub_shortcode); $items = array_filter($items); $initial_open = !isset($initial_open) || $initial_open > count($items) ? 1 : $initial_open; foreach ($items as $idx => $item) { $open = $idx + 1 == $initial_open ? 'in' : ''; $items[$idx] = $item; } if (!empty($sub_shortcode)) { $sub_html = $sub_shortcode; $html_element .= $sub_html; $html_element .= '</div>'; } $document = JFactory::getDocument(); $document->addScript('https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false'); $document->addStyleSheet(JSNPB_ELEMENT_URL . '/googlemap/assets/css/googlemap.css', 'text/css'); return $this->element_wrapper($html_element, $arr_params); }
/** * DEFINE setting options of shortcode in frontend */ public function frontend_element_items() { $this->items = array('Notab' => array(array('id' => 'prtbl_item_attr_id', 'type' => 'text_field', 'std' => 'attr_' . JSNPagebuilderHelpersShortcode::generateRandomString(), 'input-type' => 'hidden', 'container_class' => 'hidden'), array('name' => JText::_('JSN_PAGEBUILDER_DEFAULT_ELEMENT_TITLE'), 'id' => 'prtbl_item_attr_title', 'type' => 'text_field', 'class' => 'jsn-input-xxlarge-fluid', 'role' => 'title', 'std' => JText::_('JSN_PAGEBUILDER_ELEMENT_PRICINGTABLE_ITEM_ATTRIBUTE_STD'), 'tooltip' => JText::_('JSN_PAGEBUILDER_DEFAULT_ELEMENT_TITLE')), array('name' => JText::_('JSN_PAGEBUILDER_ELEMENT_PRICINGTABLE_DESCRIPTION'), 'id' => 'prtbl_item_attr_desc', 'type' => 'text_area', 'class' => 'jsn-input-xxlarge-fluid', 'std' => '', 'tooltip' => JText::_('JSN_PAGEBUILDER_ELEMENT_PRICINGTABLE_DESCRIPTION'), 'exclude_quote' => '1'), array('name' => JText::_('JSN_PAGEBUILDER_ELEMENT_PRICINGTABLE_ITEM_TYPE'), 'id' => 'prtbl_item_attr_type', 'type' => 'select', 'class' => 'input-sm', 'std' => '', 'options' => JSNPagebuilderHelpersType::getSubItemPricingType(), 'tooltip' => JText::_('JSN_PAGEBUILDER_ELEMENT_PRICINGTABLE_ITEM_TYPE')))); }