comparison core/modules/quickedit/js/views/FieldToolbarView.js @ 0:c75dbcec494b

Initial commit from drush-created site
author Chris Cannam
date Thu, 05 Jul 2018 14:24:15 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:c75dbcec494b
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 ($, _, Backbone, Drupal) {
9 Drupal.quickedit.FieldToolbarView = Backbone.View.extend({
10 $editedElement: null,
11
12 editorView: null,
13
14 _id: null,
15
16 initialize: function initialize(options) {
17 this.$editedElement = options.$editedElement;
18 this.editorView = options.editorView;
19
20 this.$root = this.$el;
21
22 this._id = 'quickedit-toolbar-for-' + this.model.id.replace(/[/[\]]/g, '_');
23
24 this.listenTo(this.model, 'change:state', this.stateChange);
25 },
26 render: function render() {
27 this.setElement($(Drupal.theme('quickeditFieldToolbar', {
28 id: this._id
29 })));
30
31 this.$el.prependTo(this.$root);
32
33 return this;
34 },
35 stateChange: function stateChange(model, state) {
36 var from = model.previous('state');
37 var to = state;
38 switch (to) {
39 case 'inactive':
40 break;
41
42 case 'candidate':
43 if (from !== 'inactive' && from !== 'highlighted') {
44 this.$el.remove();
45 this.setElement();
46 }
47 break;
48
49 case 'highlighted':
50 break;
51
52 case 'activating':
53 this.render();
54
55 if (this.editorView.getQuickEditUISettings().fullWidthToolbar) {
56 this.$el.addClass('quickedit-toolbar-fullwidth');
57 }
58
59 if (this.editorView.getQuickEditUISettings().unifiedToolbar) {
60 this.insertWYSIWYGToolGroups();
61 }
62 break;
63
64 case 'active':
65 break;
66
67 case 'changed':
68 break;
69
70 case 'saving':
71 break;
72
73 case 'saved':
74 break;
75
76 case 'invalid':
77 break;
78 }
79 },
80 insertWYSIWYGToolGroups: function insertWYSIWYGToolGroups() {
81 this.$el.append(Drupal.theme('quickeditToolgroup', {
82 id: this.getFloatedWysiwygToolgroupId(),
83 classes: ['wysiwyg-floated', 'quickedit-animate-slow', 'quickedit-animate-invisible', 'quickedit-animate-delay-veryfast'],
84 buttons: []
85 })).append(Drupal.theme('quickeditToolgroup', {
86 id: this.getMainWysiwygToolgroupId(),
87 classes: ['wysiwyg-main', 'quickedit-animate-slow', 'quickedit-animate-invisible', 'quickedit-animate-delay-veryfast'],
88 buttons: []
89 }));
90
91 this.show('wysiwyg-floated');
92 this.show('wysiwyg-main');
93 },
94 getId: function getId() {
95 return 'quickedit-toolbar-for-' + this._id;
96 },
97 getFloatedWysiwygToolgroupId: function getFloatedWysiwygToolgroupId() {
98 return 'quickedit-wysiwyg-floated-toolgroup-for-' + this._id;
99 },
100 getMainWysiwygToolgroupId: function getMainWysiwygToolgroupId() {
101 return 'quickedit-wysiwyg-main-toolgroup-for-' + this._id;
102 },
103 _find: function _find(toolgroup) {
104 return this.$el.find('.quickedit-toolgroup.' + toolgroup);
105 },
106 show: function show(toolgroup) {
107 var $group = this._find(toolgroup);
108
109 $group.on(Drupal.quickedit.util.constants.transitionEnd, function (event) {
110 $group.off(Drupal.quickedit.util.constants.transitionEnd);
111 });
112
113 window.setTimeout(function () {
114 $group.removeClass('quickedit-animate-invisible');
115 }, 0);
116 }
117 });
118 })(jQuery, _, Backbone, Drupal);