89ab29fedaf716cae8990bfafa298505201a1d96
[yaffs-website] / web / core / modules / ckeditor / js / ckeditor.drupalimage.admin.es6.js
1 /**
2  * @file
3  * CKEditor 'drupalimage' plugin admin behavior.
4  */
5
6 (function ($, Drupal, drupalSettings) {
7   /**
8    * Provides the summary for the "drupalimage" plugin settings vertical tab.
9    *
10    * @type {Drupal~behavior}
11    *
12    * @prop {Drupal~behaviorAttach} attach
13    *   Attaches summary behaviour to the "drupalimage" settings vertical tab.
14    */
15   Drupal.behaviors.ckeditorDrupalImageSettingsSummary = {
16     attach() {
17       $('[data-ckeditor-plugin-id="drupalimage"]').drupalSetSummary((context) => {
18         const root = 'input[name="editor[settings][plugins][drupalimage][image_upload]';
19         const $status = $(`${root}[status]"]`);
20         const $maxFileSize = $(`${root}[max_size]"]`);
21         const $maxWidth = $(`${root}[max_dimensions][width]"]`);
22         const $maxHeight = $(`${root}[max_dimensions][height]"]`);
23         const $scheme = $(`${root}[scheme]"]:checked`);
24
25         const maxFileSize = $maxFileSize.val() ? $maxFileSize.val() : $maxFileSize.attr('placeholder');
26         const maxDimensions = ($maxWidth.val() && $maxHeight.val()) ? `(${$maxWidth.val()}x${$maxHeight.val()})` : '';
27
28         if (!$status.is(':checked')) {
29           return Drupal.t('Uploads disabled');
30         }
31
32         let output = '';
33         output += Drupal.t('Uploads enabled, max size: @size @dimensions', { '@size': maxFileSize, '@dimensions': maxDimensions });
34         if ($scheme.length) {
35           output += `<br />${$scheme.attr('data-label')}`;
36         }
37         return output;
38       });
39     },
40   };
41 }(jQuery, Drupal, drupalSettings));