3 * Attaches behaviors for the Contextual module's edit toolbar tab.
6 (function ($, Drupal, Backbone) {
11 tabbingReleased: Drupal.t('Tabbing is no longer constrained by the Contextual module.'),
12 tabbingConstrained: Drupal.t('Tabbing is constrained to a set of @contextualsCount and the edit mode toggle.'),
13 pressEsc: Drupal.t('Press the esc key to exit.')
17 * Initializes a contextual link: updates its DOM, sets up model and views.
19 * @param {HTMLElement} context
20 * A contextual links DOM element as rendered by the server.
22 function initContextualToolbar(context) {
23 if (!Drupal.contextual || !Drupal.contextual.collection) {
27 var contextualToolbar = Drupal.contextualToolbar;
28 var model = contextualToolbar.model = new contextualToolbar.StateModel({
29 // Checks whether localStorage indicates we should start in edit mode
30 // rather than view mode.
31 // @see Drupal.contextualToolbar.VisualView.persist
32 isViewing: localStorage.getItem('Drupal.contextualToolbar.isViewing') !== 'false'
34 contextualCollection: Drupal.contextual.collection
38 el: $('.toolbar .toolbar-bar .contextual-toolbar-tab'),
42 new contextualToolbar.VisualView(viewOptions);
43 new contextualToolbar.AuralView(viewOptions);
47 * Attaches contextual's edit toolbar tab behavior.
49 * @type {Drupal~behavior}
51 * @prop {Drupal~behaviorAttach} attach
52 * Attaches contextual toolbar behavior on a contextualToolbar-init event.
54 Drupal.behaviors.contextualToolbar = {
55 attach: function (context) {
56 if ($('body').once('contextualToolbar-init').length) {
57 initContextualToolbar(context);
63 * Namespace for the contextual toolbar.
67 Drupal.contextualToolbar = {
70 * The {@link Drupal.contextualToolbar.StateModel} instance.
72 * @type {?Drupal.contextualToolbar.StateModel}
77 })(jQuery, Drupal, Backbone);