contextual.toolbar.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. (function ($, Drupal, Backbone) {
  8. var strings = {
  9. tabbingReleased: Drupal.t('Tabbing is no longer constrained by the Contextual module.'),
  10. tabbingConstrained: Drupal.t('Tabbing is constrained to a set of @contextualsCount and the edit mode toggle.'),
  11. pressEsc: Drupal.t('Press the esc key to exit.')
  12. };
  13. function initContextualToolbar(context) {
  14. if (!Drupal.contextual || !Drupal.contextual.collection) {
  15. return;
  16. }
  17. var contextualToolbar = Drupal.contextualToolbar;
  18. var model = contextualToolbar.model = new contextualToolbar.StateModel({
  19. isViewing: localStorage.getItem('Drupal.contextualToolbar.isViewing') !== 'false'
  20. }, {
  21. contextualCollection: Drupal.contextual.collection
  22. });
  23. var viewOptions = {
  24. el: $('.toolbar .toolbar-bar .contextual-toolbar-tab'),
  25. model: model,
  26. strings: strings
  27. };
  28. new contextualToolbar.VisualView(viewOptions);
  29. new contextualToolbar.AuralView(viewOptions);
  30. }
  31. Drupal.behaviors.contextualToolbar = {
  32. attach: function attach(context) {
  33. if ($('body').once('contextualToolbar-init').length) {
  34. initContextualToolbar(context);
  35. }
  36. }
  37. };
  38. Drupal.contextualToolbar = {
  39. model: null
  40. };
  41. })(jQuery, Drupal, Backbone);