Updated Drupal to 8.6. This goes with the following updates because it's possible...
[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 =
19           'input[name="editor[settings][plugins][drupalimage][image_upload]';
20         const $status = $(`${root}[status]"]`);
21         const $maxFileSize = $(`${root}[max_size]"]`);
22         const $maxWidth = $(`${root}[max_dimensions][width]"]`);
23         const $maxHeight = $(`${root}[max_dimensions][height]"]`);
24         const $scheme = $(`${root}[scheme]"]:checked`);
25
26         const maxFileSize = $maxFileSize.val()
27           ? $maxFileSize.val()
28           : $maxFileSize.attr('placeholder');
29         const maxDimensions =
30           $maxWidth.val() && $maxHeight.val()
31             ? `(${$maxWidth.val()}x${$maxHeight.val()})`
32             : '';
33
34         if (!$status.is(':checked')) {
35           return Drupal.t('Uploads disabled');
36         }
37
38         let output = '';
39         output += Drupal.t('Uploads enabled, max size: @size @dimensions', {
40           '@size': maxFileSize,
41           '@dimensions': maxDimensions,
42         });
43         if ($scheme.length) {
44           output += `<br />${$scheme.attr('data-label')}`;
45         }
46         return output;
47       });
48     },
49   };
50 })(jQuery, Drupal, drupalSettings);