Learn more  » Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

jsarnowski / jsarnowski/jet-engine   php

Repository URL to install this package:

/ components / blocks-views / block-types / dynamic-repeater.php

<?php
/**
 * Elementor views manager
 */

// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
	die;
}

if ( ! class_exists( 'Jet_Engine_Blocks_Views_Type_Dynamic_Repeater' ) ) {

	/**
	 * Define Jet_Engine_Blocks_Views_Type_Dynamic_Repeater class
	 */
	class Jet_Engine_Blocks_Views_Type_Dynamic_Repeater extends Jet_Engine_Blocks_Views_Type_Base {

		/**
		 * Returns block name
		 *
		 * @return [type] [description]
		 */
		public function get_name() {
			return 'dynamic-repeater';
		}

		/**
		 * Returns CSS selector for nested element
		 *
		 * @param  string|array $el
		 * @return string
		 */
		public function css_selector( $el = null ) {
			if ( ! is_array( $el ) ) {
				return sprintf( '{{WRAPPER}} .jet-listing-dynamic-repeater%s', $el );
			} else {

				$res = array();

				foreach ( $el as $selector ) {
					$res[] = sprintf( '{{WRAPPER}} .jet-listing-dynamic-repeater%s', $selector );
				}

				return implode( ', ', $res );
			}
		}

		/**
		 * Return attributes array
		 *
		 * @return array
		 */
		public function get_attributes() {
			return array(
				'dynamic_field_source' => array(
					'type' => 'string',
					'default' => '',
				),
				'dynamic_field_option' => array(
					'type' => 'string',
					'default' => '',
				),
				'dynamic_field_format' => array(
					'type' => 'string',
					'default' => '<span>%name%</span>',
				),
				'item_tag' => array(
					'type' => 'string',
					'default' => 'div',
				),
				'items_delimiter' => array(
					'type' => 'string',
					'default' => '',
				),
				'dynamic_field_before' => array(
					'type' => 'string',
					'default' => '',
				),
				'dynamic_field_after' => array(
					'type' => 'string',
					'default' => '',
				),
				'dynamic_field_counter' => array(
					'type' => 'boolean',
					'default' => false,
				),
				'dynamic_field_leading_zero' => array(
					'type' => 'boolean',
					'default' => false,
				),
				'dynamic_field_counter_after' => array(
					'type' => 'string',
					'default' => '',
				),
				'dynamic_field_counter_position' => array(
					'type' => 'string',
					'default' => 'at-left',
				),
				'hide_if_empty' => array(
					'type' => 'boolean',
					'default' => false,
				),
			);
		}

		/**
		 * Add style block options
		 *
		 * @return boolean
		 */
		public function add_style_manager_options() {
			$this->controls_manager->start_section(
				'style_controls',
				array(
					'id'           => 'section_general_style',
					'initial_open' => true,
					'title'        => esc_html__( 'General', 'jet-engine' )
				)
			);

			$this->controls_manager->add_responsive_control(
				array(
					'id'         => 'items_direction',
					'label'      => __( 'Direction', 'jet-engine' ),
					'type'       => 'choose',
					'attributes' => array(
						'default' => array(
							'value' => 'flex-start',
						),
					),
					'options' => array(
						'row'    => array(
							'label' => esc_html__( 'Horizontal', 'jet-engine' ),
							'icon'  => 'dashicons-arrow-right-alt',
						),
						'column' => array(
							'label' => esc_html__( 'Vertical', 'jet-engine' ),
							'icon'  => 'dashicons-arrow-down-alt',
						),
					),
					'css_selector' => array(
						$this->css_selector( '__items' ) => 'flex-direction: {{VALUE}};',
					),
				)
			);

			$this->controls_manager->add_responsive_control(
				array(
					'id'         => 'items_alignment',
					'label'      => __( 'Alignment', 'jet-engine' ),
					'type'       => 'choose',
					'attributes' => array(
						'default' => array(
							'value' => 'flex-start',
						),
					),
					'options' => array(
						'flex-start'   => array(
							'label' => esc_html__( 'Start', 'jet-engine' ),
							'icon'  => 'dashicons-editor-alignleft',
						),
						'center' => array(
							'label' => esc_html__( 'Center', 'jet-engine' ),
							'icon'  => 'dashicons-editor-aligncenter',
						),
						'flex-end'  => array(
							'label' => esc_html__( 'End', 'jet-engine' ),
							'icon'  => 'dashicons-editor-alignright',
						),
					),
					'css_selector' => array(
						$this->css_selector( '__items' )    => 'justify-content: {{VALUE}};',
						$this->css_selector( '__item > *' ) => 'justify-content: {{VALUE}};',
					),
				)
			);

			$this->controls_manager->add_control(
				array(
					'id'           => 'general_typography',
					'label'        => __( 'Typography', 'jet-engine' ),
					'type'         => 'typography',
					'separator'    => 'before',
					'css_selector' => array(
						$this->css_selector( '__item > *' ) => 'font-family: {{FAMILY}}; font-weight: {{WEIGHT}}; text-transform: {{TRANSFORM}}; font-style: {{STYLE}}; text-decoration: {{DECORATION}}; line-height: {{LINEHEIGHT}}{{LH_UNIT}}; letter-spacing: {{LETTERSPACING}}{{LS_UNIT}}; font-size: {{SIZE}}{{S_UNIT}};',
					),
				)
			);

			$this->controls_manager->end_section();

			$this->controls_manager->start_section(
				'style_controls',
				array(
					'id'           => 'section_items_style',
					'initial_open' => false,
					'title'        => esc_html__( 'Items', 'jet-engine' )
				)
			);

			// Not supported
			//
			// $this->controls_manager->add_control(
			// 	array(
			// 		'id'        => 'fixed_size',
			// 		'label'     => __( 'Fixed Item Size', 'jet-engine' ),
			// 		'type'      => 'choose',
			// 		'default'   => '',
			// 		'separator' => 'before',
			// 		'options'   => array(
			// 			'yes' => array(
			// 				'shortcut' => __( 'Yes', 'jet-engine' ),
			// 				'icon'     => 'dashicons-yes',
			// 			),
			// 			'' => array(
			// 				'shortcut' => __( 'No', 'jet-engine' ),
			// 				'icon'     => 'dashicons-no',
			// 			),
			// 		),
			// 	)
			// );

			// $this->controls_manager->add_responsive_control(
			// 	array(
			// 		'id'    => 'item_width',
			// 		'label' => __( 'Fixed Item Width', 'jet-engine' ),
			// 		'type'  => 'range',
			// 		'units' => array(
			// 			array(
			// 				'value'     => 'px',
			// 				'intervals' => array(
			// 					'step' => 1,
			// 					'min'  => 15,
			// 					'max'  => 150,
			// 				),
			// 			),
			// 		),
			// 		'css_selector' => array(
			// 			$this->css_selector( '__item > *' ) => 'display: flex; width: {{VALUE}}{{UNIT}}; justify-content: center;',
			// 		),
			// 		'condition' => array(
			// 			'fixed_size' => 'yes'
			// 		)
			// 	)
			// );

			// $this->controls_manager->add_responsive_control(
			// 	array(
			// 		'id'    => 'item_height',
			// 		'label' => __( 'Fixed Item Height', 'jet-engine' ),
			// 		'type'  => 'range',
			// 		'units' => array(
			// 			array(
			// 				'value'     => 'px',
			// 				'intervals' => array(
			// 					'step' => 1,
			// 					'min'  => 15,
			// 					'max'  => 150,
			// 				),
			// 			),
			// 		),
			// 		'css_selector' => array(
			// 			$this->css_selector( '__item > *' ) => 'height: {{VALUE}}{{UNIT}}; display: flex; align-items: center;',
			// 		),
			// 		'condition' => array(
			// 			'fixed_size' => 'yes'
			// 		)
			// 	)
			// );

			$this->controls_manager->start_tabs(
				'style_controls',
				array(
					'id'        => 'tabs_item_style',
					'separator' => 'after',
				)
			);

			$this->controls_manager->start_tab(
				'style_controls',
				array(
					'id'    => 'tabs_item_style_normal',
					'title' => esc_html__( 'Normal', 'jet-engine' ),
				)
			);

			$this->controls_manager->add_control(
				array(
					'id'           => 'item_color',
					'label'        => esc_html__( 'Color', 'jet-engine' ),
					'type'         => 'color-picker',
					'separator'    => 'before',
					'css_selector' => array(
						$this->css_selector( '__item > *' ) => 'color: {{VALUE}}',
					),
				)
			);

			$this->controls_manager->add_control(
				array(
					'id'           => 'item_background_color',
					'label'        => esc_html__( 'Background Color', 'jet-engine' ),
					'type'         => 'color-picker',
					'css_selector' => array(
						$this->css_selector( '__item > *' ) => 'background-color: {{VALUE}}',
					),
				)
			);

			$this->controls_manager->end_tab();

			$this->controls_manager->start_tab(
				'style_controls',
				array(
					'id'    => 'tabs_item_style_hover',
					'title' => esc_html__( 'Hover', 'jet-engine' ),
				)
			);

			$this->controls_manager->add_control(
				array(
					'id'           => 'item_color_hover',
					'label'        => esc_html__( 'Color', 'jet-engine' ),
					'type'         => 'color-picker',
					'separator'    => 'before',
					'css_selector' => array(
						$this->css_selector( '__item > *:hover' ) => 'color: {{VALUE}}',
					),
				)
			);

			$this->controls_manager->add_control(
				array(
					'id'           => 'item_background_color_hover',
					'label'        => esc_html__( 'Background Color', 'jet-engine' ),
					'type'         => 'color-picker',
					'css_selector' => array(
						$this->css_selector( '__item > *:hover' ) => 'background-color: {{VALUE}}',
					),
				)
			);

			$this->controls_manager->add_control(
				array(
					'id'           => 'item_border_color_hover',
Loading ...