Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / quickedit / js / editors / plainTextEditor.js
1 /**
2 * DO NOT EDIT THIS FILE.
3 * See the following change record for more information,
4 * https://www.drupal.org/node/2815083
5 * @preserve
6 **/
7
8 (function ($, _, Drupal) {
9   Drupal.quickedit.editors.plain_text = Drupal.quickedit.EditorView.extend({
10     $textElement: null,
11
12     initialize: function initialize(options) {
13       Drupal.quickedit.EditorView.prototype.initialize.call(this, options);
14
15       var editorModel = this.model;
16       var fieldModel = this.fieldModel;
17
18       var $textElement = void 0;
19       var $fieldItems = this.$el.find('.quickedit-field');
20       if ($fieldItems.length) {
21         $textElement = this.$textElement = $fieldItems.eq(0);
22       } else {
23         $textElement = this.$textElement = this.$el;
24       }
25       editorModel.set('originalValue', $.trim(this.$textElement.text()));
26
27       var previousText = editorModel.get('originalValue');
28       $textElement.on('keyup paste', function (event) {
29         var currentText = $.trim($textElement.text());
30         if (previousText !== currentText) {
31           previousText = currentText;
32           editorModel.set('currentValue', currentText);
33           fieldModel.set('state', 'changed');
34         }
35       });
36     },
37     getEditedElement: function getEditedElement() {
38       return this.$textElement;
39     },
40     stateChange: function stateChange(fieldModel, state, options) {
41       var from = fieldModel.previous('state');
42       var to = state;
43       switch (to) {
44         case 'inactive':
45           break;
46
47         case 'candidate':
48           if (from !== 'inactive') {
49             this.$textElement.removeAttr('contenteditable');
50           }
51           if (from === 'invalid') {
52             this.removeValidationErrors();
53           }
54           break;
55
56         case 'highlighted':
57           break;
58
59         case 'activating':
60           _.defer(function () {
61             fieldModel.set('state', 'active');
62           });
63           break;
64
65         case 'active':
66           this.$textElement.attr('contenteditable', 'true');
67           break;
68
69         case 'changed':
70           break;
71
72         case 'saving':
73           if (from === 'invalid') {
74             this.removeValidationErrors();
75           }
76           this.save(options);
77           break;
78
79         case 'saved':
80           break;
81
82         case 'invalid':
83           this.showValidationErrors();
84           break;
85       }
86     },
87     getQuickEditUISettings: function getQuickEditUISettings() {
88       return { padding: true, unifiedToolbar: false, fullWidthToolbar: false, popup: false };
89     },
90     revert: function revert() {
91       this.$textElement.html(this.model.get('originalValue'));
92     }
93   });
94 })(jQuery, _, Drupal);