[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Site 5 * @subpackage Layout 6 * 7 * @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 */ 10 11 use Joomla\CMS\Factory; 12 use Joomla\CMS\Language\Text; 13 14 // phpcs:disable PSR1.Files.SideEffects 15 \defined('_JEXEC') or die; 16 // phpcs:enable PSR1.Files.SideEffects 17 18 /** 19 * @var array $displayData Data for this field collected by ColorField 20 */ 21 extract($displayData); 22 23 /** 24 * Layout variables 25 * ----------------- 26 * @var string $autocomplete Autocomplete attribute for the field. 27 * @var boolean $autofocus Is autofocus enabled? 28 * @var string $class Classes for the input 29 * @var boolean $disabled Is this field disabled? 30 * @var string $display Which kind of slider should be displayed? 31 * @var string $default Default value for this field 32 * @var string $format Format of color value 33 * @var string $hint Text for inputs placeholder 34 * @var string $id ID of field and label 35 * @var string $name Name of the input field 36 * @var string $onchange Onchange attribute for the field 37 * @var string $onclick Onclick attribute for the field 38 * @var string $position Position of input 39 * @var boolean $preview Should the selected value be displayed separately? 40 * @var boolean $readonly Is this field read only? 41 * @var boolean $required Is this field required? 42 * @var string $saveFormat Format to save the color 43 * @var integer $size Size attribute of the input 44 * @var string $validate Validation rules to apply. 45 * @var string $dataAttribute Miscellaneous data attributes preprocessed for HTML output 46 * @var array $dataAttributes Miscellaneous data attributes for eg, data-*. 47 */ 48 49 if ($color === 'none' || is_null($color)) { 50 $color = ''; 51 } 52 53 $alpha = $format === 'hsla' || $format === 'rgba' || $format === 'alpha'; 54 $autocomplete = !empty($autocomplete) ? 'autocomplete="' . $autocomplete . '"' : ''; 55 $autofocus = $autofocus ? ' autofocus' : ''; 56 $color = ' data-color="' . $color . '"'; 57 $class = $class ? ' class="' . $class . '"' : ''; 58 $default = $default ? ' data-default="' . $default . '"' : ''; 59 $disabled = $disabled ? ' disabled' : ''; 60 $format = $format ? ' data-format="' . $format . '"' : ''; 61 $hint = strlen($hint) ? ' placeholder="' . $this->escape($hint) . '"' : ''; 62 $onchange = $onchange ? ' onchange="' . $onchange . '"' : ''; 63 $onclick = $onclick ? ' onclick="' . $onclick . '"' : ''; 64 $preview = $preview ? ' data-preview="' . $preview . '"' : ''; 65 $readonly = $readonly ? ' readonly' : ''; 66 $saveFormat = $saveFormat ? ' data-format="' . $saveFormat . '"' : ''; 67 $size = $size ? ' size="' . $size . '"' : ''; 68 $validate = $validate ? ' data-validate="' . $validate . '"' : ''; 69 70 $displayValues = explode(',', $display); 71 $allSliders = $display === 'full' || empty($display); 72 73 /** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ 74 $wa = Factory::getApplication()->getDocument()->getWebAssetManager(); 75 $wa->useScript('field.color-slider'); 76 77 Text::script('JFIELD_COLOR_ERROR_CONVERT_HSL'); 78 Text::script('JFIELD_COLOR_ERROR_CONVERT_HUE'); 79 Text::script('JFIELD_COLOR_ERROR_NO_COLOUR'); 80 Text::script('JFIELD_COLOR_ERROR_WRONG_FORMAT'); 81 ?> 82 83 <div class="color-slider-wrapper" 84 <?php echo 85 $class, 86 $color, 87 $default, 88 $preview, 89 $size, 90 $dataAttribute; 91 ?> 92 > 93 <!-- The data to save at the end (label created in form by Joomla) --> 94 <input type="text" class="form-control color-input" id="<?php echo $id; ?>" name="<?php echo $name; ?>" 95 <?php echo 96 $disabled, 97 $readonly, 98 $required, 99 $saveFormat, 100 $validate; 101 ?> 102 > 103 <!-- Shows value which is allowed to manipulate like 'hue' --> 104 <label for="slider-input" class="visually-hidden"><?php echo Text::_('JFIELD_COLOR_LABEL_SLIDER_INPUT'); ?></label> 105 <input type="text" class="form-control" id="slider-input" 106 <?php echo 107 $autocomplete, 108 $disabled, 109 $hint, 110 $onchange, 111 $onclick, 112 $position, 113 $readonly, 114 $required, 115 $format, 116 $validate; 117 ?> 118 > 119 <span class="form-control-feedback"></span> 120 121 <?php if ($allSliders || in_array('hue', $displayValues)) : ?> 122 <label for="hue-slider" class="visually-hidden"><?php echo Text::_('JFIELD_COLOR_LABEL_SLIDER_HUE'); ?></label> 123 <input type="range" min="0" max="360" class="form-control color-slider" id="hue-slider" data-type="hue" 124 <?php echo 125 $autofocus, 126 $disabled 127 ?> 128 > 129 <?php endif ?> 130 <?php if ($allSliders || in_array('saturation', $displayValues)) : ?> 131 <label for="saturation-slider" class="visually-hidden"><?php echo Text::_('JFIELD_COLOR_LABEL_SLIDER_SATURATION'); ?></label> 132 <input type="range" min="0" max="100" class="form-control color-slider" id="saturation-slider" data-type="saturation" 133 <?php echo 134 $autofocus, 135 $disabled 136 ?> 137 > 138 <?php endif ?> 139 <?php if ($allSliders || in_array('light', $displayValues)) : ?> 140 <label for="light-slider" class="visually-hidden"><?php echo Text::_('JFIELD_COLOR_LABEL_SLIDER_LIGHT'); ?></label> 141 <input type="range" min="0" max="100" class="form-control color-slider" id="light-slider" data-type="light" 142 <?php echo 143 $autofocus, 144 $disabled 145 ?> 146 > 147 <?php endif ?> 148 <?php if ($alpha && ($allSliders || in_array('alpha', $displayValues))) : ?> 149 <label for="alpha-slider" class="visually-hidden"><?php echo Text::_('JFIELD_COLOR_LABEL_SLIDER_ALPHA'); ?></label> 150 <input type="range" min="0" max="100" class="form-control color-slider" id="alpha-slider" data-type="alpha" 151 <?php echo 152 $autofocus, 153 $disabled 154 ?> 155 > 156 <?php endif ?> 157 </div>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |