balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

hover-animation.php (4335B)


      1 <?php
      2 namespace Elementor;
      3 
      4 if ( ! defined( 'ABSPATH' ) ) {
      5 	exit; // Exit if accessed directly.
      6 }
      7 
      8 /**
      9  * Elementor hover animation control.
     10  *
     11  * A base control for creating hover animation control. Displays a select box
     12  * with the available hover animation effects @see Control_Hover_Animation::get_animations()
     13  *
     14  * @since 1.0.0
     15  */
     16 class Control_Hover_Animation extends Base_Data_Control {
     17 
     18 	/**
     19 	 * Animations.
     20 	 *
     21 	 * Holds all the available hover animation effects of the control.
     22 	 *
     23 	 * @access private
     24 	 * @static
     25 	 *
     26 	 * @var array
     27 	 */
     28 	private static $_animations;
     29 
     30 	/**
     31 	 * Get hover animation control type.
     32 	 *
     33 	 * Retrieve the control type, in this case `hover_animation`.
     34 	 *
     35 	 * @since 1.0.0
     36 	 * @access public
     37 	 *
     38 	 * @return string Control type.
     39 	 */
     40 	public function get_type() {
     41 		return 'hover_animation';
     42 	}
     43 
     44 	/**
     45 	 * Get animations.
     46 	 *
     47 	 * Retrieve the available hover animation effects.
     48 	 *
     49 	 * @since 1.0.0
     50 	 * @access public
     51 	 * @static
     52 	 *
     53 	 * @return array Available hover animation.
     54 	 */
     55 	public static function get_animations() {
     56 		if ( is_null( self::$_animations ) ) {
     57 			self::$_animations = [
     58 				'grow' => 'Grow',
     59 				'shrink' => 'Shrink',
     60 				'pulse' => 'Pulse',
     61 				'pulse-grow' => 'Pulse Grow',
     62 				'pulse-shrink' => 'Pulse Shrink',
     63 				'push' => 'Push',
     64 				'pop' => 'Pop',
     65 				'bounce-in' => 'Bounce In',
     66 				'bounce-out' => 'Bounce Out',
     67 				'rotate' => 'Rotate',
     68 				'grow-rotate' => 'Grow Rotate',
     69 				'float' => 'Float',
     70 				'sink' => 'Sink',
     71 				'bob' => 'Bob',
     72 				'hang' => 'Hang',
     73 				'skew' => 'Skew',
     74 				'skew-forward' => 'Skew Forward',
     75 				'skew-backward' => 'Skew Backward',
     76 				'wobble-vertical' => 'Wobble Vertical',
     77 				'wobble-horizontal' => 'Wobble Horizontal',
     78 				'wobble-to-bottom-right' => 'Wobble To Bottom Right',
     79 				'wobble-to-top-right' => 'Wobble To Top Right',
     80 				'wobble-top' => 'Wobble Top',
     81 				'wobble-bottom' => 'Wobble Bottom',
     82 				'wobble-skew' => 'Wobble Skew',
     83 				'buzz' => 'Buzz',
     84 				'buzz-out' => 'Buzz Out',
     85 			];
     86 
     87 			$additional_animations = [];
     88 
     89 			/**
     90 			 * Hover animations.
     91 			 *
     92 			 * Filters the animations list displayed in the hover animations control.
     93 			 *
     94 			 * This hook can be used to register new animations in addition to the
     95 			 * basic Elementor hover animations.
     96 			 *
     97 			 * @since 2.4.0
     98 			 *
     99 			 * @param array $additional_animations Additional animations array.
    100 			 */
    101 			$additional_animations = apply_filters( 'elementor/controls/hover_animations/additional_animations', $additional_animations );
    102 
    103 			self::$_animations = array_merge( self::$_animations, $additional_animations );
    104 		}
    105 
    106 		return self::$_animations;
    107 	}
    108 
    109 	/**
    110 	 * Render hover animation control output in the editor.
    111 	 *
    112 	 * Used to generate the control HTML in the editor using Underscore JS
    113 	 * template. The variables for the class are available using `data` JS
    114 	 * object.
    115 	 *
    116 	 * @since 1.0.0
    117 	 * @access public
    118 	 */
    119 	public function content_template() {
    120 		?>
    121 		<div class="elementor-control-field">
    122 			<label for="<?php $this->print_control_uid(); ?>" class="elementor-control-title">{{{ data.label }}}</label>
    123 			<div class="elementor-control-input-wrapper">
    124 				<select id="<?php $this->print_control_uid(); ?>" data-setting="{{ data.name }}">
    125 					<option value=""><?php echo esc_html__( 'None', 'elementor' ); ?></option>
    126 					<?php foreach ( self::get_animations() as $animation_name => $animation_title ) : ?>
    127 						<option value="<?php Utils::print_unescaped_internal_string( $animation_name ); ?>"><?php Utils::print_unescaped_internal_string( $animation_title ); ?></option>
    128 					<?php endforeach; ?>
    129 				</select>
    130 			</div>
    131 		</div>
    132 		<# if ( data.description ) { #>
    133 		<div class="elementor-control-field-description">{{{ data.description }}}</div>
    134 		<# } #>
    135 		<?php
    136 	}
    137 
    138 	/**
    139 	 * Get hover animation control default settings.
    140 	 *
    141 	 * Retrieve the default settings of the hover animation control. Used to return
    142 	 * the default settings while initializing the hover animation control.
    143 	 *
    144 	 * @since 1.0.0
    145 	 * @access protected
    146 	 *
    147 	 * @return array Control default settings.
    148 	 */
    149 	protected function get_default_settings() {
    150 		return [
    151 			'label_block' => true,
    152 		];
    153 	}
    154 
    155 	public static function get_assets( $setting ) {
    156 		if ( ! $setting || 'none' === $setting ) {
    157 			return [];
    158 		}
    159 
    160 		return [
    161 			'styles' => [ 'e-animations' ],
    162 		];
    163 	}
    164 }