db backup prior to drupal security update
[yaffs-website] / web / core / modules / toolbar / js / models / ToolbarModel.js
1 /**
2  * @file
3  * A Backbone Model for the toolbar.
4  */
5
6 (function (Backbone, Drupal) {
7
8   'use strict';
9
10   /**
11    * Backbone model for the toolbar.
12    *
13    * @constructor
14    *
15    * @augments Backbone.Model
16    */
17   Drupal.toolbar.ToolbarModel = Backbone.Model.extend(/** @lends Drupal.toolbar.ToolbarModel# */{
18
19     /**
20      * @type {object}
21      *
22      * @prop activeTab
23      * @prop activeTray
24      * @prop isOriented
25      * @prop isFixed
26      * @prop areSubtreesLoaded
27      * @prop isViewportOverflowConstrained
28      * @prop orientation
29      * @prop locked
30      * @prop isTrayToggleVisible
31      * @prop height
32      * @prop offsets
33      */
34     defaults: /** @lends Drupal.toolbar.ToolbarModel# */{
35
36       /**
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'.
40        *
41        * @type {string}
42        */
43       activeTab: null,
44
45       /**
46        * Represents whether a tray is open or not. Stored as an ID selector e.g.
47        * '#toolbar-item--1-tray'.
48        *
49        * @type {string}
50        */
51       activeTray: null,
52
53       /**
54        * Indicates whether the toolbar is displayed in an oriented fashion,
55        * either horizontal or vertical.
56        *
57        * @type {bool}
58        */
59       isOriented: false,
60
61       /**
62        * Indicates whether the toolbar is positioned absolute (false) or fixed
63        * (true).
64        *
65        * @type {bool}
66        */
67       isFixed: false,
68
69       /**
70        * Menu subtrees are loaded through an AJAX request only when the Toolbar
71        * is set to a vertical orientation.
72        *
73        * @type {bool}
74        */
75       areSubtreesLoaded: false,
76
77       /**
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
80        * get to.
81        *
82        * @type {bool}
83        */
84       isViewportOverflowConstrained: false,
85
86       /**
87        * The orientation of the active tray.
88        *
89        * @type {string}
90        */
91       orientation: 'vertical',
92
93       /**
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
97        * loads.
98        *
99        * @type {bool}
100        */
101       locked: false,
102
103       /**
104        * Indicates whether the tray orientation toggle is visible.
105        *
106        * @type {bool}
107        */
108       isTrayToggleVisible: false,
109
110       /**
111        * The height of the toolbar.
112        *
113        * @type {number}
114        */
115       height: null,
116
117       /**
118        * The current viewport offsets determined by {@link Drupal.displace}. The
119        * offsets suggest how a module might position is components relative to
120        * the viewport.
121        *
122        * @type {object}
123        *
124        * @prop {number} top
125        * @prop {number} right
126        * @prop {number} bottom
127        * @prop {number} left
128        */
129       offsets: {
130         top: 0,
131         right: 0,
132         bottom: 0,
133         left: 0
134       }
135     },
136
137     /**
138      * @inheritdoc
139      *
140      * @param {object} attributes
141      *   Attributes for the toolbar.
142      * @param {object} options
143      *   Options for the toolbar.
144      *
145      * @return {string|undefined}
146      *   Returns an error message if validation failed.
147      */
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.');
153       }
154     }
155   });
156
157 }(Backbone, Drupal));