balmet.com

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

base-units.php (2284B)


      1 <?php
      2 namespace Elementor;
      3 
      4 if ( ! defined( 'ABSPATH' ) ) {
      5 	exit; // Exit if accessed directly.
      6 }
      7 
      8 /**
      9  * Elementor control base units.
     10  *
     11  * An abstract class for creating new unit controls in the panel.
     12  *
     13  * @since 1.0.0
     14  * @abstract
     15  */
     16 abstract class Control_Base_Units extends Control_Base_Multiple {
     17 
     18 	/**
     19 	 * Get units control default value.
     20 	 *
     21 	 * Retrieve the default value of the units control. Used to return the default
     22 	 * values while initializing the units control.
     23 	 *
     24 	 * @since 1.0.0
     25 	 * @access public
     26 	 *
     27 	 * @return array Control default value.
     28 	 */
     29 	public function get_default_value() {
     30 		return [
     31 			'unit' => 'px',
     32 		];
     33 	}
     34 
     35 	/**
     36 	 * Get units control default settings.
     37 	 *
     38 	 * Retrieve the default settings of the units control. Used to return the default
     39 	 * settings while initializing the units control.
     40 	 *
     41 	 * @since 1.0.0
     42 	 * @access protected
     43 	 *
     44 	 * @return array Control default settings.
     45 	 */
     46 	protected function get_default_settings() {
     47 		return [
     48 			'size_units' => [ 'px' ],
     49 			'range' => [
     50 				'px' => [
     51 					'min' => 0,
     52 					'max' => 100,
     53 					'step' => 1,
     54 				],
     55 				'em' => [
     56 					'min' => 0.1,
     57 					'max' => 10,
     58 					'step' => 0.1,
     59 				],
     60 				'rem' => [
     61 					'min' => 0.1,
     62 					'max' => 10,
     63 					'step' => 0.1,
     64 				],
     65 				'%' => [
     66 					'min' => 0,
     67 					'max' => 100,
     68 					'step' => 1,
     69 				],
     70 				'deg' => [
     71 					'min' => 0,
     72 					'max' => 360,
     73 					'step' => 1,
     74 				],
     75 				'vh' => [
     76 					'min' => 0,
     77 					'max' => 100,
     78 					'step' => 1,
     79 				],
     80 				'vw' => [
     81 					'min' => 0,
     82 					'max' => 100,
     83 					'step' => 1,
     84 				],
     85 			],
     86 		];
     87 	}
     88 
     89 	/**
     90 	 * Print units control settings.
     91 	 *
     92 	 * Used to generate the units control template in the editor.
     93 	 *
     94 	 * @since 1.0.0
     95 	 * @access protected
     96 	 */
     97 	protected function print_units_template() {
     98 		?>
     99 		<# if ( data.size_units && data.size_units.length > 1 ) { #>
    100 		<div class="elementor-units-choices">
    101 			<# _.each( data.size_units, function( unit ) { #>
    102 			<input id="elementor-choose-{{ data._cid + data.name + unit }}" type="radio" name="elementor-choose-{{ data.name + data._cid }}" data-setting="unit" value="{{ unit }}">
    103 			<label class="elementor-units-choices-label" for="elementor-choose-{{ data._cid + data.name + unit }}">{{{ unit }}}</label>
    104 			<# } ); #>
    105 		</div>
    106 		<# } #>
    107 		<?php
    108 	}
    109 }