]> _ Git - fluidbook-toolbox.git/commitdiff
wait #5649 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 14 Dec 2022 16:27:45 +0000 (17:27 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 14 Dec 2022 16:27:45 +0000 (17:27 +0100)
app/SubForms/Link/Base.php
resources/linkeditor/js/linkeditor.form.js

index 71d4583e9df871fca78ada17902119d1bd44c0ea..8e38706f13e3547819917905748acbce8a5fc581 100644 (file)
@@ -259,16 +259,16 @@ class Base extends Form
         $this->addField('header_disposition', FormSection::class, __('Disposition'));
         $this->addField('group_disposition', FieldGroupStart::class);
         $this->addField('group_position', FieldGroupStart::class, __('Position'));
-        $this->addField('x', Text::class, 'X',['suffix'=>'px']);
-        $this->addField('y', Text::class, 'Y',['suffix'=>'px']);
+        $this->addField('x', Text::class, 'X', ['suffix' => 'px', 'class' => 'calculation']);
+        $this->addField('y', Text::class, 'Y', ['suffix' => 'px', 'class' => 'calculation']);
         $this->addField('group_position_end', FieldGroupEnd::class);
         $this->addField('group_dimensions', FieldGroupStart::class, __('Dimensions'));
-        $this->addField('w', Text::class, 'W',['suffix'=>'px']);
-        $this->addField('h', Text::class, 'H',['suffix'=>'px']);
+        $this->addField('w', Text::class, 'W', ['suffix' => 'px', 'class' => 'calculation']);
+        $this->addField('h', Text::class, 'H', ['suffix' => 'px', 'class' => 'calculation']);
         $this->addField('group_dimensions_end', FieldGroupEnd::class);
         if ($this->_displayedOnFluidbook) {
             $this->addField('group_transform', FieldGroupStart::class);
-            $this->addField('rot', Text::class, __('Rotation'), ['suffix' => '°']);
+            $this->addField('rot', Text::class, __('Rotation'), ['suffix' => '°', 'class' => 'calculation']);
             $this->addField('group_transform_end', FieldGroupEnd::class);
             $this->addField('zindex', Depth::class, __('Profondeur'));
         }
index bf882ce98f1e0deb27942db5101edf164daeb03d..ad8f8750db9d98993154f8a5d68eb9d243b7e47f 100644 (file)
@@ -9,6 +9,23 @@ LinkeditorForm.prototype = {
     init: function () {
         var $this = this;
 
+        $(document).on('change', '.calculation', function () {
+            var v = $(this).val();
+            console.log(v);
+            if (/[0-9\., \-\+\*\/]+/.test(v)) {
+                try {
+                    v = eval(v.replace(/,/g, '.'));
+                    console.log(v);
+                    if (isNaN(v)) {
+                        return;
+                    }
+                } catch (e) {
+                    return;
+                }
+            }
+            $(this).val(v);
+        });
+
         $(document).on('change', '#linkeditor-panel-form [name="type"]', function () {
             console.log('change type');
             if ($this._maskChangeEvent) {
@@ -18,6 +35,7 @@ LinkeditorForm.prototype = {
             $this.updateLinkForm();
         });
 
+
         $(document).on('change', "#linkeditor-panel-form input,#linkeditor-panel-form select,#linkeditor-panel-form textarea", function () {
             if ($this._maskChangeEvent) {
                 return;