1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of FacturaScripts |
4
|
|
|
* Copyright (C) 2023 Carlos Garcia Gomez <[email protected]> |
5
|
|
|
* |
6
|
|
|
* This program is free software: you can redistribute it and/or modify |
7
|
|
|
* it under the terms of the GNU Lesser General Public License as |
8
|
|
|
* published by the Free Software Foundation, either version 3 of the |
9
|
|
|
* License, or (at your option) any later version. |
10
|
|
|
* |
11
|
|
|
* This program is distributed in the hope that it will be useful, |
12
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14
|
|
|
* GNU Lesser General Public License for more details. |
15
|
|
|
* |
16
|
|
|
* You should have received a copy of the GNU Lesser General Public License |
17
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
namespace FacturaScripts\Core\UI\Widget; |
21
|
|
|
|
22
|
|
|
use FacturaScripts\Core\Template\UI\Widget; |
23
|
|
|
use FacturaScripts\Dinamic\Lib\AssetManager; |
24
|
|
|
|
25
|
|
|
class WidgetColor extends Widget |
26
|
|
|
{ |
27
|
|
|
public function __construct(string $name, ?string $field = null, ?string $label = null) |
28
|
|
|
{ |
29
|
|
|
parent::__construct($name, $field, $label); |
30
|
|
|
|
31
|
|
|
AssetManager::add('js', 'https://cdnjs.cloudflare.com/ajax/libs/jscolor/2.5.1/jscolor.min.js'); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function render(string $context = ''): string |
35
|
|
|
{ |
36
|
|
|
return '<div class="form-group">' |
37
|
|
|
. '<label for="' . $this->id() . '">' . $this->label(true) . '</label>' |
38
|
|
|
. '<input type="text" name="' . $this->field . '" value="' . $this->value . '" id="' |
39
|
|
|
. $this->id() . '" class="form-control" data-jscolor=""/>' |
40
|
|
|
. '</div>'; |
41
|
|
|
} |
42
|
|
|
} |