customs
1 year ago
holders
1 year ago
checkbox.php
1 year ago
color-and-opacity.php
1 year ago
color.php
1 year ago
datepicker-range.php
1 year ago
dropdown-and-colors.php
1 year ago
dropdown.php
1 year ago
font.php
1 year ago
google-font.php
1 year ago
gradient.php
1 year ago
hidden.php
1 year ago
index.php
3 years ago
integer.php
1 year ago
list.php
1 year ago
multiple-textbox.php
1 year ago
paddings-editor.php
1 year ago
pattern.php
1 year ago
radio-colors.php
1 year ago
radio.php
1 year ago
textarea.php
1 year ago
textbox.php
1 year ago
url.php
1 year ago
wp-editor.php
1 year ago
gradient.php
103 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Gradient picker Control |
| 5 | * |
| 6 | * Main options: |
| 7 | * name => a name of the control |
| 8 | * title => Заголовок |
| 9 | * colors => массив цветов для градиента |
| 10 | * Пример: array("#000 0% 0.5", "#e70303 100% 1") |
| 11 | * filldirection => Направление градиента(top, left) |
| 12 | * Пример: 90deg |
| 13 | * value => a value to show in the control |
| 14 | * default => a default value of the control if the "value" option is not specified |
| 15 | * |
| 16 | * @author Alex Kovalev <alex.kovalevv@gmail.com> |
| 17 | * @copyright (c) 2018, Webcraftic Ltd |
| 18 | * |
| 19 | * @package core |
| 20 | * @since 1.0.0 |
| 21 | */ |
| 22 | |
| 23 | // Exit if accessed directly |
| 24 | if( !defined('ABSPATH') ) { |
| 25 | exit; |
| 26 | } |
| 27 | |
| 28 | if( !class_exists('Wbcr_FactoryForms480_GradientControl') ) { |
| 29 | class Wbcr_FactoryForms480_GradientControl extends Wbcr_FactoryForms480_Control { |
| 30 | |
| 31 | public $type = 'gradient'; |
| 32 | |
| 33 | /** |
| 34 | * Shows the html markup of the control. |
| 35 | * |
| 36 | * @since 1.0.0 |
| 37 | * @return void |
| 38 | */ |
| 39 | public function html() |
| 40 | { |
| 41 | $name = $this->getNameOnForm(); |
| 42 | $value = esc_attr($this->getValue()); |
| 43 | |
| 44 | if( !empty($value) ) { |
| 45 | |
| 46 | $values = json_decode(stripcslashes(htmlspecialchars_decode($value))); |
| 47 | |
| 48 | $points = ''; |
| 49 | |
| 50 | foreach($values->color_points as $split_values) { |
| 51 | $points .= $split_values . ','; |
| 52 | } |
| 53 | |
| 54 | $points = rtrim($points, ','); |
| 55 | |
| 56 | $this->addHtmlData('points', $points); |
| 57 | $this->addHtmlData('directions', $values->filldirection); |
| 58 | } else { |
| 59 | $this->addHtmlData('directions', 'top'); |
| 60 | } |
| 61 | ?> |
| 62 | <script> |
| 63 | if( !window.factory ) { |
| 64 | window.factory = {}; |
| 65 | } |
| 66 | if( !window.factory.res ) { |
| 67 | window.factory.res = {}; |
| 68 | } |
| 69 | factory.res.resVertical = '<?php _e( 'vertical', 'wbcr_factory_forms_480' ) ?>'; |
| 70 | factory.res.resHorizontal = '<?php _e( 'horizontal', 'wbcr_factory_forms_480' ) ?>'; |
| 71 | </script> |
| 72 | <div <?php $this->attrs() ?>> |
| 73 | <div class="factory-gradient-picker"> |
| 74 | <ul class="gradientPicker-pallets"> |
| 75 | <li class="factory-preset-gradient factory-primary-gradient" data-primary="#1bbc9d" data-secondary="#16a086"></li> |
| 76 | <li class="factory-preset-gradient factory-primary-gradient" data-primary="#2fcc71" data-secondary="#27ae61"></li> |
| 77 | <li class="factory-preset-gradient factory-primary-gradient" data-primary="#3598dc" data-secondary="#2a80b9"></li> |
| 78 | <li class="factory-preset-gradient factory-primary-gradient" data-primary="#9c59b8" data-secondary="#8f44ad"></li> |
| 79 | <li class="factory-preset-gradient factory-primary-gradient" data-primary="#34495e" data-secondary="#2d3e50"></li> |
| 80 | <li class="factory-preset-gradient factory-primary-gradient" data-primary="#f1c40f" data-secondary="#f49c14"></li> |
| 81 | <li class="factory-preset-gradient factory-primary-gradient" data-primary="#e84c3d" data-secondary="#c1392b"></li> |
| 82 | <li class="factory-preset-gradient factory-primary-gradient" data-primary="#ecf0f1" data-secondary="#bec3c7"></li> |
| 83 | </ul> |
| 84 | <canvas class='gradientPicker-preview'></canvas> |
| 85 | <div class='factory-points'></div> |
| 86 | <div class='factory-color-picker-container'> |
| 87 | <div class="factory-slider-container"> |
| 88 | <div class="factory-slider"> |
| 89 | <input type="text" class="factory-input-text factory-color-hex"/> |
| 90 | |
| 91 | <div class="factory-bar"></div> |
| 92 | <div class="factory-visible-value">100%</div> |
| 93 | </div> |
| 94 | </div> |
| 95 | <div class="factory-color-picker"></div> |
| 96 | </div> |
| 97 | </div> |
| 98 | <input type="hidden" id="<?php echo esc_attr($name); ?>" class="factory-result" name="<?php echo esc_attr($name); ?>" value="<?php echo esc_attr($value); ?>"> |
| 99 | </div> |
| 100 | <?php |
| 101 | } |
| 102 | } |
| 103 | } |