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