3 * Attaches behaviors for the Contextual module's edit toolbar tab.
6 (function ($, Drupal, Backbone) {
8 tabbingReleased: Drupal.t('Tabbing is no longer constrained by the Contextual module.'),
9 tabbingConstrained: Drupal.t('Tabbing is constrained to a set of @contextualsCount and the edit mode toggle.'),
10 pressEsc: Drupal.t('Press the esc key to exit.'),
14 * Initializes a contextual link: updates its DOM, sets up model and views.
16 * @param {HTMLElement} context
17 * A contextual links DOM element as rendered by the server.
19 function initContextualToolbar(context) {
20 if (!Drupal.contextual || !Drupal.contextual.collection) {
24 const contextualToolbar = Drupal.contextualToolbar;
25 const model = contextualToolbar.model = new contextualToolbar.StateModel({
26 // Checks whether localStorage indicates we should start in edit mode
27 // rather than view mode.
28 // @see Drupal.contextualToolbar.VisualView.persist
29 isViewing: localStorage.getItem('Drupal.contextualToolbar.isViewing') !== 'false',
31 contextualCollection: Drupal.contextual.collection,
35 el: $('.toolbar .toolbar-bar .contextual-toolbar-tab'),
39 new contextualToolbar.VisualView(viewOptions);
40 new contextualToolbar.AuralView(viewOptions);
44 * Attaches contextual's edit toolbar tab behavior.
46 * @type {Drupal~behavior}
48 * @prop {Drupal~behaviorAttach} attach
49 * Attaches contextual toolbar behavior on a contextualToolbar-init event.
51 Drupal.behaviors.contextualToolbar = {
53 if ($('body').once('contextualToolbar-init').length) {
54 initContextualToolbar(context);
60 * Namespace for the contextual toolbar.
64 Drupal.contextualToolbar = {
67 * The {@link Drupal.contextualToolbar.StateModel} instance.
69 * @type {?Drupal.contextualToolbar.StateModel}
73 }(jQuery, Drupal, Backbone));