3 * A Backbone Model for the toolbar.
6 (function (Backbone, Drupal) {
11 * Backbone model for the toolbar.
15 * @augments Backbone.Model
17 Drupal.toolbar.ToolbarModel = Backbone.Model.extend(/** @lends Drupal.toolbar.ToolbarModel# */{
26 * @prop areSubtreesLoaded
27 * @prop isViewportOverflowConstrained
30 * @prop isTrayToggleVisible
34 defaults: /** @lends Drupal.toolbar.ToolbarModel# */{
37 * The active toolbar tab. All other tabs should be inactive under
38 * normal circumstances. It will remain active across page loads. The
39 * active item is stored as an ID selector e.g. '#toolbar-item--1'.
46 * Represents whether a tray is open or not. Stored as an ID selector e.g.
47 * '#toolbar-item--1-tray'.
54 * Indicates whether the toolbar is displayed in an oriented fashion,
55 * either horizontal or vertical.
62 * Indicates whether the toolbar is positioned absolute (false) or fixed
70 * Menu subtrees are loaded through an AJAX request only when the Toolbar
71 * is set to a vertical orientation.
75 areSubtreesLoaded: false,
78 * If the viewport overflow becomes constrained, isFixed must be true so
79 * that elements in the trays aren't lost off-screen and impossible to
84 isViewportOverflowConstrained: false,
87 * The orientation of the active tray.
91 orientation: 'vertical',
94 * A tray is locked if a user toggled it to vertical. Otherwise a tray
95 * will switch between vertical and horizontal orientation based on the
96 * configured breakpoints. The locked state will be maintained across page
104 * Indicates whether the tray orientation toggle is visible.
108 isTrayToggleVisible: false,
111 * The height of the toolbar.
118 * The current viewport offsets determined by {@link Drupal.displace}. The
119 * offsets suggest how a module might position is components relative to
125 * @prop {number} right
126 * @prop {number} bottom
127 * @prop {number} left
140 * @param {object} attributes
141 * Attributes for the toolbar.
142 * @param {object} options
143 * Options for the toolbar.
145 * @return {string|undefined}
146 * Returns an error message if validation failed.
148 validate: function (attributes, options) {
149 // Prevent the orientation being set to horizontal if it is locked, unless
150 // override has not been passed as an option.
151 if (attributes.orientation === 'horizontal' && this.get('locked') && !options.override) {
152 return Drupal.t('The toolbar cannot be set to a horizontal orientation when it is locked.');
157 }(Backbone, Drupal));