/** * List of other option types ( checkbox, select... ) * @param type $element * @return type */ static function render($element) { $element = parent::get_extra_info($element); $label = parent::get_label($element); $options_type = isset($element['options_type']) ? $element['options_type'] : ''; $ul_wrap = isset($element['ul_wrap']) ? $element['ul_wrap'] : true; $output = ''; $element_clone = $element; $element_clone['wrapper_item_start'] = "<li class='jsn-item jsn-iconbar-trigger'>"; $element_clone['wrapper_item_end'] = '</li>'; $element_clone['blank_output'] = '1'; $element['class'] = str_replace('form-control', '', $element['class']); $element_clone['class'] = (isset($element['class']) ? $element['class'] : '') . ' ' . $options_type; // re-arrange $element['options'] array by the order of value in $element['std'] $element_clone['std'] = str_replace(',', '__#__', $element_clone['std']); if (!isset($element_clone['no_order'])) { $std_val = explode('__#__', $element_clone['std']); $std = array(); foreach ($std_val as $value) { if (trim($value) != '' && isset($element_clone['options'][$value])) { $std[$value] = $element_clone['options'][$value]; } } // other option value which is not defined in std foreach ($element_clone['options'] as $key => $value) { if (!in_array($key, $std_val)) { $std[$key] = $value; } } $element_clone['options'] = $std; } $output = IG_Pb_Helper_Shortcode::render_parameter($options_type, $element_clone); $output = $ul_wrap ? "<ul class='jsn-items-list ui-sortable'>{$output}</ul>" : $output; return parent::final_element($element, $output, $label); }
/** * Dimension type, which defines Width, Height of element * @param type $element * @param type $input_params * @return type */ static function render($element, $input_params) { $element = parent::get_extra_info($element); $label = parent::get_label($element); $element['dimension_elements'] = isset($element['dimension_elements']) ? explode(',', str_replace(' ', '', $element['dimension_elements'])) : array('w', 'h'); $_no_prefix_id = str_replace('param-', '', $element['id']); $output = ''; if (in_array('w', $element['dimension_elements'])) { $_idx_width = $_no_prefix_id . '_width'; $_idx_width_unit = $_no_prefix_id . '_width_unit'; $element['width_std'] = isset($element[$_idx_width]) ? $element[$_idx_width]['std'] : ''; $element['width_std'] = isset($input_params[$_idx_width]) ? $input_params[$_idx_width] : $element['width_std']; // Width and Width unit $_width = array('id' => $element['id'] . '_width', 'type' => 'text_append', 'input_type' => 'number', 'class' => 'jsn-input-number input-mini input-sm', 'parent_class' => 'input-group-inline', 'std' => $element['width_std'], 'append_before' => 'W', 'validate' => 'number', 'bound' => '0'); if (isset($element[$_idx_width_unit])) { $element['width_unit_std'] = isset($element[$_idx_width_unit]) ? $element[$_idx_width_unit]['std'] : ''; $element['width_unit_std'] = isset($input_params[$_idx_width_unit]) ? $input_params[$_idx_width_unit] : $element['width_unit_std']; $_w_unit = array('id' => $element['id'] . '_width_unit', 'type' => 'select', 'class' => 'input-mini input-sm', 'bound' => '0'); $_w_unit = array_merge($_w_unit, $element[$_idx_width_unit]); $_w_unit['std'] = $element['width_unit_std']; $_append = ''; } else { $_width = array_merge($_width, array('append' => 'px')); } $output .= IG_Pb_Helper_Shortcode::render_parameter('text_append', $_width); $output .= isset($element[$_idx_width_unit]) ? IG_Pb_Helper_Shortcode::render_parameter('select', $_w_unit) : ''; } // Height and Height Unit if (in_array('h', $element['dimension_elements'])) { $_idx_height = $_no_prefix_id . '_height'; $_idx_height_unit = $_no_prefix_id . '_height_unit'; $element['height_std'] = isset($element[$_idx_height]) ? $element[$_idx_height]['std'] : ''; $element['height_std'] = isset($input_params[$_idx_height]) ? $input_params[$_idx_height] : $element['height_std']; $_append = 'px'; $_height = array('id' => $element['id'] . '_height', 'input_type' => 'number', 'class' => 'jsn-input-number input-mini input-sm', 'parent_class' => 'input-group-inline', 'std' => $element['height_std'], 'append_before' => 'H', 'validate' => 'number', 'bound' => '0'); if (isset($element[$_idx_height_unit])) { $element['height_unit_std'] = isset($element[$_idx_width_unit]) ? $element[$_idx_width_unit]['std'] : ''; $element['height_unit_std'] = isset($input_params[$_idx_width_unit]) ? $input_params[$_idx_width_unit] : $element['width_unit_std']; $_h_unit = array('id' => $element['id'] . '_height_unit', 'type' => 'select', 'class' => 'input-mini input-sm', 'bound' => '0'); $_h_unit = array_merge($_h_unit, $element[$_idx_height_unit]); $_h_unit['std'] = $element['height_unit_std']; $_append = ''; } else { $_height = array_merge($_height, array('append' => 'px')); } $output .= IG_Pb_Helper_Shortcode::render_parameter('text_append', $_height); $output .= isset($element[$_idx_height_unit]) ? IG_Pb_Helper_Shortcode::render_parameter('select', $_h_unit) : ''; } return parent::final_element($element, $output, $label); }
/** * Option to Define top/right/bottom/left margin for element * @param type $element * @param type $input_params * @return type */ static function render($element, $input_params) { $element = parent::get_extra_info($element); $label = parent::get_label($element); $_no_prefix_id = str_replace('param-', '', $element['id']); // Set default margin element // t: top // r: right // b: bottom // l: left $element['margin_elements'] = isset($element['margin_elements']) ? explode(',', str_replace(' ', '', $element['margin_elements'])) : array('t', 'r', 'b', 'l'); $output = ''; $_br = false; if (in_array('t', $element['margin_elements'])) { $_idx_top = $_no_prefix_id . '_top'; $_br = true; $element['top_std'] = isset($element[$_idx_top]) ? $element[$_idx_top]['std'] : ''; $element['top_std'] = isset($input_params[$_idx_top]) ? $input_params[$_idx_top] : $element['top_std']; $_top = array('id' => $element['id'] . '_top', 'type' => 'text_append', 'input_type' => 'number', 'class' => 'jsn-input-number input-mini', 'parent_class' => 'input-group-inline', 'std' => $element['top_std'], 'append_before' => '<i class="icon-arrow-up"></i>', 'append' => 'px', 'validate' => 'number', 'bound' => '0'); $output .= IG_Pb_Helper_Shortcode::render_parameter('text_append', $_top); } if (in_array('r', $element['margin_elements'])) { $_idx_right = $_no_prefix_id . '_right'; $_br = true; $element['right_std'] = isset($element[$_idx_right]) ? $element[$_idx_right]['std'] : ''; $element['right_std'] = isset($input_params[$_idx_right]) ? $input_params[$_idx_right] : $element['right_std']; $_right = array('id' => $element['id'] . '_right', 'input_type' => 'number', 'class' => 'jsn-input-number input-mini', 'parent_class' => 'input-group-inline', 'std' => $element['right_std'], 'append_before' => '<i class="icon-arrow-right"></i>', 'append' => 'px', 'validate' => 'number', 'bound' => '0'); $output .= IG_Pb_Helper_Shortcode::render_parameter('text_append', $_right); } $output .= $_br ? '<div class="clearbreak"></div>' : ''; if (in_array('b', $element['margin_elements'])) { $_idx_bottom = $_no_prefix_id . '_bottom'; $element['bottom_std'] = isset($element[$_idx_bottom]) ? $element[$_idx_bottom]['std'] : ''; $element['bottom_std'] = isset($input_params[$_idx_bottom]) ? $input_params[$_idx_bottom] : $element['bottom_std']; $_bottom = array('id' => $element['id'] . '_bottom', 'input_type' => 'number', 'class' => 'jsn-input-number input-mini', 'parent_class' => 'input-group-inline', 'std' => $element['bottom_std'], 'append_before' => '<i class="icon-arrow-down"></i>', 'append' => 'px', 'validate' => 'number', 'bound' => '0'); $output .= IG_Pb_Helper_Shortcode::render_parameter('text_append', $_bottom); } if (in_array('l', $element['margin_elements'])) { $_idx_left = $_no_prefix_id . '_left'; $element['left_std'] = isset($element[$_idx_left]) ? $element[$_idx_left]['std'] : ''; $element['left_std'] = isset($input_params[$_idx_left]) ? $input_params[$_idx_left] : $element['left_std']; $_left = array('id' => $element['id'] . '_left', 'input_type' => 'number', 'class' => 'jsn-input-number input-mini', 'parent_class' => 'input-group-inline', 'std' => $element['left_std'], 'append_before' => '<i class="icon-arrow-left"></i>', 'append' => 'px', 'validate' => 'number', 'bound' => '0'); $output .= IG_Pb_Helper_Shortcode::render_parameter('text_append', $_left); } return parent::final_element($element, $output, $label); }
/** * List of "items_list" * @param type $element * @return type */ static function render($element) { $element = parent::get_extra_info($element); $label = parent::get_label($element); $output = ''; $items = isset($element['items']) ? $element['items'] : ''; if (is_array($items)) { foreach ($items as $element_) { $element_func = $element_['type']; $element_['wrap'] = '0'; $element_['wrap_class'] = ''; $element_['std'] = $element['std']; $element_['id'] = $element['id']; $output .= IG_Pb_Helper_Shortcode::render_parameter($element_func, $element_); } } return parent::final_element($element, $output, $label); }
/** * Radio * @param type $element * @return string */ static function render($element) { $element['class'] = isset($element['class']) ? $element['class'] : 'radio-inline'; $element['input_type'] = 'radio'; return IG_Pb_Helper_Shortcode::render_parameter('checkbox', $element); }
$exp = preg_quote($widget->get_field_id('____')); $exp = str_replace('____', '(.*? )', $exp); $form = preg_replace('/' . $exp . '/', '$1', $form); // tab and content generate $tabs = array(); foreach (array('content', 'styling') as $i => $tab) { $active = $i++ == 0 ? 'active' : ''; $data_['href'] = "#{$tab}"; $data_['data-toggle'] = 'tab'; $content_ = ucfirst($tab); $tabs[] = "<li class='{$active}'>" . IG_Pb_Objects_Modal::tab_settings('a', $data_, $content_) . '</li>'; } // content $contents = array(); $contents[] = "<div class='tab-pane active' id='content'><form id='ig-widget-form'>{$form}</form></div>"; $contents[] = "<div class='tab-pane' id='styling'>" . IG_Pb_Helper_Shortcode::render_parameter('preview') . '</div>'; $output = IG_Pb_Objects_Modal::setting_tab_html($shortcode, $tabs, $contents, array(), '', array()); echo balanceTags($output); } } ?> <div id="modalAction" class="ig-pb-setting-tab"></div> </div> <textarea class="hidden" id="shortcode_content"><?php echo esc_attr($params); ?> </textarea> <textarea class="hidden" id="ig_share_data"></textarea> <textarea class="hidden" id="ig_merge_data"></textarea> <textarea class="hidden" id="ig_extract_data"></textarea> <input type="hidden" id="ig_previewing" value="0" />
/** * Generate HTML code from shortcode content. * * @param array $atts Shortcode attributes. * @param string $content Current content. * * @return string */ public function element_shortcode_full($atts = null, $content = null) { $arr_params = shortcode_atts($this->config['params'], $atts); $initial_open = intval($arr_params['initial_open']); $multi_open = $arr_params['multi_open']; $filter = $arr_params['filter']; $random_id = IG_Pb_Utils_Common::random_string(); $script = ''; if ($multi_open == 'yes') { $script .= "<script type='text/javascript'>( function (\$) {\n\t\t\t\t\$( document ).ready( function ()\n\t\t\t\t{\n\t\t\t\t\t\$( '#accordion_{$random_id} .panel-title a' ).click( function(e ){\n\t\t\t\t\t\tvar collapse_item = \$( '#accordion_{$random_id} '+this.hash )\n\t\t\t\t\t\tcollapse_item.collapse( 'toggle' )\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t} )( jQuery )</script>"; } else { // some case the collapse doesn't work, need this code $script .= "<script type='text/javascript'>( function (\$) {\n\t\t\t\t\$( document ).ready( function ()\n\t\t\t\t{\n\t\t\t\t\t\$( '#accordion_{$random_id} .panel-collapse' ).click( function(e ){\n\t\t\t\t\t\tvar collapse_item = \$( '#accordion_{$random_id} '+this.hash )\n\t\t\t\t\t\t\$( '#accordion_{$random_id} .panel-body' ).each(function(){\n\t\t\t\t\t\t\t\$( this ).addClass( 'panel-collapse' );\n\t\t\t\t\t\t});\n\t\t\t\t\t\tcollapse_item.removeClass( 'panel-collapse' );\n\t\t\t\t\t\tcollapse_item.attr( 'style', '' );\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t} )( jQuery )</script>"; } $sub_shortcode = IG_Pb_Helper_Shortcode::remove_autop($content); $items = explode('<!--seperate-->', $sub_shortcode); // remove empty element $items = array_filter($items); // update id, class for each item $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 = IG_Pb_Helper_Shortcode::extract_sub_shortcode($content); $sub_sc_data = reset($sub_sc_data); // tags to filter item $tags = array('all'); foreach ($sub_sc_data as $shortcode) { $extract_params = shortcode_parse_atts($shortcode); $tags[] = $extract_params['tag']; } $tags = array_filter($tags); if (count($tags) > 1) { $tags = implode(',', $tags); $tags = explode(',', $tags); $tags = array_unique($tags); $filter_html = IG_Pb_Helper_Shortcode::render_parameter('filter_list', $tags, $random_id); // remove "All" tag array_shift($tags); $inner_tags = implode(',', $tags); $script .= "<script type='text/javascript'>( function (\$) {\n\t\t\t\t\$( document ).ready( function ()\n\t\t\t\t{\n\t\t\t\t\twindow.parent.jQuery.noConflict()( '#jsn_view_modal').contents().find( '#ig_share_data' ).text( '{$inner_tags}')\n\t\t\t\t\tvar parent_criteria = '#filter_{$random_id}'\n\t\t\t\t\tvar clientsClone = \$( '#accordion_{$random_id}' );\n\t\t\t\t\tvar tag_to_filter = 'div';\n\t\t\t\t\tvar class_to_filter = '.panel-default';\n\n\t\t\t\t\t\$( parent_criteria + ' a' ).click( function(e ) {\n\t\t\t\t\t\t// stop running filter\n\t\t\t\t\t\t\$( class_to_filter ).each(function(){\n\t\t\t\t\t\t\t\$( this ).stop( true )\n\t\t\t\t\t\t})\n\t\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\t\t//active clicked criteria\n\t\t\t\t\t\t\$( parent_criteria + ' li' ).removeClass( 'active' );\n\t\t\t\t\t\t\$( this ).parent().addClass( 'active' );\n\n\t\t\t\t\t\tvar filterData = \$( this ).attr( 'class' );\n\t\t\t\t\t\tvar filters;\n\t\t\t\t\t\tif( filterData == 'all' ){\n\t\t\t\t\t\t\tfilters = clientsClone.find( tag_to_filter );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tfilters = clientsClone.find( tag_to_filter + '[data-tag~='+ filterData +']' );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclientsClone.find( class_to_filter ).each(function(){\n\t\t\t\t\t\t\t\$( this ).fadeOut()\n\t\t\t\t\t\t});\n\t\t\t\t\t\tfilters.each(function(){\n\t\t\t\t\t\t\t\$( this ).fadeIn()\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t} )( jQuery )</script>"; } } $html = '<div class="panel-group" id="accordion_{ID}">' . $sub_shortcode . '</div>'; $html = str_replace('{ID}', $random_id, $html); return $this->element_wrapper($filter_html . $html . $script, $arr_params); }
/** * get HTML of Modal Settings Box of Shortcode * * @param array $options * * @return string */ static function get_shortcode_modal_settings($settings, $shortcode = '', $input_params = null, $raw_shortcode = null) { $i = 0; $tabs = $contents = $actions = $general_actions = array(); foreach ((array) $settings as $tab => $options) { $options = self::ignore_settings($options); if ($tab == 'action') { foreach ($options as $option) { $actions[] = IG_Pb_Helper_Shortcode::render_parameter($option['type'], $option); } } else { if ($tab == 'generalaction') { foreach ($options as $option) { $option['id'] = isset($option['id']) ? 'param-' . $option['id'] : ''; $general_actions[] = IG_Pb_Helper_Shortcode::render_parameter($option['type'], $option); } } else { $active = $i++ == 0 ? 'active' : ''; if (strtolower($tab) != 'notab') { $data_ = isset($settings[$tab]['settings']) ? $settings[$tab]['settings'] : array(); $data_['href'] = "#{$tab}"; $data_['data-toggle'] = 'tab'; $content_ = ucfirst($tab); $tabs[] = "<li class='{$active}'>" . self::tab_settings('a', $data_, $content_) . '</li>'; } $has_margin = 0; $param_html = array(); foreach ($options as $idx => $option) { // check if this element has Margin param (1) if (isset($option['name']) && $option['name'] == __('Margin', IGPBL) && $option['id'] != 'div_margin') { $has_margin = 1; } // if (1), don't use the 'auto extended margin ( top, bottom ) option' if ($has_margin && isset($option['id']) && $option['id'] == 'div_margin') { continue; } $type = $option['type']; $option['id'] = isset($option['id']) ? 'param-' . $option['id'] : "{$idx}"; if (!is_array($type)) { $param_html[$option['id']] = IG_Pb_Helper_Shortcode::render_parameter($type, $option, $input_params); } else { $output_inner = ''; foreach ($type as $sub_options) { $sub_options['id'] = isset($sub_options['id']) ? 'param-' . $sub_options['id'] : ''; /* for sub option, auto assign bound = 0 {not wrapped by <div class='controls'></div> } */ $sub_options['bound'] = '0'; /* for sub option, auto assign 'input-small' class */ $sub_options['class'] = isset($sub_options['class']) ? $sub_options['class'] : ''; $type = $sub_options['type']; $output_inner .= IG_Pb_Helper_Shortcode::render_parameter($type, $sub_options); } $option = IG_Pb_Helper_Html::get_extra_info($option); $label = IG_Pb_Helper_Html::get_label($option); $param_html[$option['id']] = IG_Pb_Helper_Html::final_element($option, $output_inner, $label); } } if (!empty($param_html['param-copy_style_from'])) { array_pop($param_html); // move "auto extended margin ( top, bottom ) option" to top of output $style_copy = array_shift($param_html); // Shift Preview frame from the array $preview = array_shift($param_html); if (!empty($param_html['param-div_margin'])) { $margin = $param_html['param-div_margin']; $param_html = array_merge(array($preview, $style_copy, $margin), $param_html); } else { $param_html = array_merge(array($preview, $style_copy), $param_html); } } $param_html = implode('', $param_html); $content_tab = "<div class='tab-pane {$active} ig-pb-setting-tab' id='{$tab}'>{$param_html}</div>"; $contents[] = $content_tab; } } } // Auto-append `Shortcode Content` tab if ($shortcode != 'ig_row') { self::shortcode_content_tab($tabs, $contents, $raw_shortcode); } return self::setting_tab_html($shortcode, $tabs, $contents, $general_actions, $settings, $actions); }