Code Duplication    Length = 32-32 lines in 2 locations

src/Form/Field/File.php 1 location

@@ 192-223 (lines=32) @@
189
$("input{$this->getElementClassSelector()}").fileinput({$options});
190
EOT;
191
192
        if ($this->fileActionSettings['showRemove']) {
193
            $text = [
194
                'title'   => trans('admin.delete_confirm'),
195
                'confirm' => trans('admin.confirm'),
196
                'cancel'  => trans('admin.cancel'),
197
            ];
198
199
            $this->script .= <<<EOT
200
$("input{$this->getElementClassSelector()}").on('filebeforedelete', function() {
201
    
202
    return new Promise(function(resolve, reject) {
203
    
204
        var remove = resolve;
205
    
206
        swal({
207
            title: "{$text['title']}",
208
            type: "warning",
209
            showCancelButton: true,
210
            confirmButtonColor: "#DD6B55",
211
            confirmButtonText: "{$text['confirm']}",
212
            showLoaderOnConfirm: true,
213
            cancelButtonText: "{$text['cancel']}",
214
            preConfirm: function() {
215
                return new Promise(function(resolve) {
216
                    resolve(remove());
217
                });
218
            }
219
        });
220
    });
221
});
222
EOT;
223
        }
224
    }
225
226
    /**

src/Form/Field/MultipleFile.php 1 location

@@ 255-286 (lines=32) @@
252
$("input{$this->getElementClassSelector()}").fileinput({$options});
253
EOT;
254
255
        if ($this->fileActionSettings['showRemove']) {
256
            $text = [
257
                'title'   => trans('admin.delete_confirm'),
258
                'confirm' => trans('admin.confirm'),
259
                'cancel'  => trans('admin.cancel'),
260
            ];
261
262
            $this->script .= <<<EOT
263
$("input{$this->getElementClassSelector()}").on('filebeforedelete', function() {
264
265
    return new Promise(function(resolve, reject) {
266
267
        var remove = resolve;
268
269
        swal({
270
            title: "{$text['title']}",
271
            type: "warning",
272
            showCancelButton: true,
273
            confirmButtonColor: "#DD6B55",
274
            confirmButtonText: "{$text['confirm']}",
275
            showLoaderOnConfirm: true,
276
            cancelButtonText: "{$text['cancel']}",
277
            preConfirm: function() {
278
                return new Promise(function(resolve) {
279
                    resolve(remove());
280
                });
281
            }
282
        });
283
    });
284
});
285
EOT;
286
        }
287
288
        if ($this->fileActionSettings['showDrag']) {
289
            $this->addVariables([