]> _ Git - cubist_cms-back.git/commitdiff
wip #5637 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 9 Dec 2022 12:04:20 +0000 (13:04 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 9 Dec 2022 12:04:20 +0000 (13:04 +0100)
src/resources/views/fields/color.blade.php

index ee63c3ff004ea62b1ecc69ba8430be3a558af21c..27744f34130e818d43684e6cf1b0fd627a5d2b98 100644 (file)
@@ -4,7 +4,7 @@
 @include('crud::fields.inc.translatable_icon')
 <input
     type="text"
-    class="spectrum"
+    class="colorpicker"
     data-show-alpha="{{$field['allows_alpha']?'true':'false'}}"
     data-allow-empty="{{$field['allows_empty']?'true':'false'}}"
     name="{{ $field['name'] }}"
                 makeSpectrumColorPickers();
 
                 function makeSpectrumColorPickers() {
-                    $("input.spectrum:not(.spectrum-ok)").each(function () {
+                    $("input.colorpicker:not(.spectrum-ok)").each(function () {
                         if ($(this).closest('.sample').length > 0) {
                             return;
                         }
-                        $(this).spectrum({
+                        var e=$(this);
+                        var options={
                             preferredFormat: "hex3",
-                            showInput: true,
                             showInitial: true,
+                            showInput: true,
+                            allowEmpty: true,
                             showAlpha: $(this).attr('data-show-alpha') === 'true',
-                        }).addClass('spectrum-ok');
+                            move:function(color){
+                                e.val(color.toString());
+                                e.trigger('change');
+                            },
+                            dragend:function(color){
+                                e.val(color.toString());
+                                e.trigger('change');
+                            }
+                        };
+                        $(this).spectrum(options).addClass('spectrum-ok');
                     });
                 }