3 * A Backbone Model for the toolbar.
6 (function (Backbone, Drupal) {
8 * Backbone model for the toolbar.
12 * @augments Backbone.Model
14 Drupal.toolbar.ToolbarModel = Backbone.Model.extend(/** @lends Drupal.toolbar.ToolbarModel# */{
23 * @prop areSubtreesLoaded
24 * @prop isViewportOverflowConstrained
27 * @prop isTrayToggleVisible
31 defaults: /** @lends Drupal.toolbar.ToolbarModel# */{
34 * The active toolbar tab. All other tabs should be inactive under
35 * normal circumstances. It will remain active across page loads. The
36 * active item is stored as an ID selector e.g. '#toolbar-item--1'.
43 * Represents whether a tray is open or not. Stored as an ID selector e.g.
44 * '#toolbar-item--1-tray'.
51 * Indicates whether the toolbar is displayed in an oriented fashion,
52 * either horizontal or vertical.
59 * Indicates whether the toolbar is positioned absolute (false) or fixed
67 * Menu subtrees are loaded through an AJAX request only when the Toolbar
68 * is set to a vertical orientation.
72 areSubtreesLoaded: false,
75 * If the viewport overflow becomes constrained, isFixed must be true so
76 * that elements in the trays aren't lost off-screen and impossible to
81 isViewportOverflowConstrained: false,
84 * The orientation of the active tray.
88 orientation: 'horizontal',
91 * A tray is locked if a user toggled it to vertical. Otherwise a tray
92 * will switch between vertical and horizontal orientation based on the
93 * configured breakpoints. The locked state will be maintained across page
101 * Indicates whether the tray orientation toggle is visible.
105 isTrayToggleVisible: true,
108 * The height of the toolbar.
115 * The current viewport offsets determined by {@link Drupal.displace}. The
116 * offsets suggest how a module might position is components relative to
122 * @prop {number} right
123 * @prop {number} bottom
124 * @prop {number} left
137 * @param {object} attributes
138 * Attributes for the toolbar.
139 * @param {object} options
140 * Options for the toolbar.
142 * @return {string|undefined}
143 * Returns an error message if validation failed.
145 validate(attributes, options) {
146 // Prevent the orientation being set to horizontal if it is locked, unless
147 // override has not been passed as an option.
148 if (attributes.orientation === 'horizontal' && this.get('locked') && !options.override) {
149 return Drupal.t('The toolbar cannot be set to a horizontal orientation when it is locked.');
153 }(Backbone, Drupal));