43 | | // ### Get a selector's first subview |
44 | | // |
45 | | // Fetches the first subview that matches a given `selector`. |
46 | | // |
47 | | // If no `selector` is provided, it will grab the first subview |
48 | | // attached to the view's root. |
49 | | // |
50 | | // Useful when a selector only has one subview at a time. |
| 62 | /** |
| 63 | * Fetches the first subview that matches a given `selector`. |
| 64 | * |
| 65 | * If no `selector` is provided, it will grab the first subview attached to the |
| 66 | * view's root. |
| 67 | * |
| 68 | * Useful when a selector only has one subview at a time. |
| 69 | * |
| 70 | * @since 3.5.0 |
| 71 | * |
| 72 | * @param {string} selector A jQuery selector. |
| 73 | * |
| 74 | * @return {Backbone.View} The view. |
| 75 | */ |
56 | | // ### Register subview(s) |
57 | | // |
58 | | // Registers any number of `views` to a `selector`. |
59 | | // |
60 | | // When no `selector` is provided, the root selector (the empty string) |
61 | | // is used. `views` accepts a `Backbone.View` instance or an array of |
62 | | // `Backbone.View` instances. |
63 | | // |
64 | | // --- |
65 | | // |
66 | | // Accepts an `options` object, which has a significant effect on the |
67 | | // resulting behavior. |
68 | | // |
69 | | // `options.silent` – *boolean, `false`* |
70 | | // > If `options.silent` is true, no DOM modifications will be made. |
71 | | // |
72 | | // `options.add` – *boolean, `false`* |
73 | | // > Use `Views.add()` as a shortcut for setting `options.add` to true. |
74 | | // |
75 | | // > By default, the provided `views` will replace |
76 | | // any existing views associated with the selector. If `options.add` |
77 | | // is true, the provided `views` will be added to the existing views. |
78 | | // |
79 | | // `options.at` – *integer, `undefined`* |
80 | | // > When adding, to insert `views` at a specific index, use |
81 | | // `options.at`. By default, `views` are added to the end of the array. |
| 81 | /** |
| 82 | * Registers subview(s). |
| 83 | * |
| 84 | * Registers any number of `views` to a `selector`. |
| 85 | * |
| 86 | * When no `selector` is provided, the root selector (the empty string) |
| 87 | * is used. `views` accepts a `Backbone.View` instance or an array of |
| 88 | * `Backbone.View` instances. |
| 89 | * |
| 90 | * --- |
| 91 | * |
| 92 | * Accepts an `options` object, which has a significant effect on the |
| 93 | * resulting behavior. |
| 94 | * |
| 95 | * `options.silent` – *boolean, `false`* |
| 96 | * > If `options.silent` is true, no DOM modifications will be made. |
| 97 | * |
| 98 | * `options.add` – *boolean, `false`* |
| 99 | * > Use `Views.add()` as a shortcut for setting `options.add` to true. |
| 100 | * |
| 101 | * > By default, the provided `views` will replace |
| 102 | * any existing views associated with the selector. If `options.add` |
| 103 | * is true, the provided `views` will be added to the existing views. |
| 104 | * |
| 105 | * `options.at` – *integer, `undefined`* |
| 106 | * > When adding, to insert `views` at a specific index, use |
| 107 | * `options.at`. By default, `views` are added to the end of the array. |
| 108 | * |
| 109 | * @since 3.5.0 |
| 110 | * |
| 111 | * @param {string} selector A jQuery selector. |
| 112 | * @param {array|Object} views The subviews for the main view. |
| 113 | * @param {Object} options Options for call. If `options.silent` is true, |
| 114 | * no DOM modifications will be made. Use |
| 115 | * `Views.add()` as a shortcut for setting |
| 116 | * `options.add` to true. If `options.add` is |
| 117 | * true, the provided `views` will be added to |
| 118 | * the existing views. When adding, to insert |
| 119 | * `views` at a specific index, use `options.at`. |
| 120 | * |
| 121 | * @return wp.Backbone.Subviews |
| 122 | */ |
137 | | // ### Add subview(s) to existing subviews |
138 | | // |
139 | | // An alias to `Views.set()`, which defaults `options.add` to true. |
140 | | // |
141 | | // Adds any number of `views` to a `selector`. |
142 | | // |
143 | | // When no `selector` is provided, the root selector (the empty string) |
144 | | // is used. `views` accepts a `Backbone.View` instance or an array of |
145 | | // `Backbone.View` instances. |
146 | | // |
147 | | // Use `Views.set()` when setting `options.add` to `false`. |
148 | | // |
149 | | // Accepts an `options` object. By default, provided `views` will be |
150 | | // inserted at the end of the array of existing views. To insert |
151 | | // `views` at a specific index, use `options.at`. If `options.silent` |
152 | | // is true, no DOM modifications will be made. |
153 | | // |
154 | | // For more information on the `options` object, see `Views.set()`. |
| 178 | /** |
| 179 | * Add subview(s) to existing subviews. |
| 180 | * |
| 181 | * An alias to `Views.set()`, which defaults `options.add` to true. |
| 182 | * |
| 183 | * Adds any number of `views` to a `selector`. |
| 184 | * |
| 185 | * When no `selector` is provided, the root selector (the empty string) |
| 186 | * is used. `views` accepts a `Backbone.View` instance or an array of |
| 187 | * `Backbone.View` instances. |
| 188 | * |
| 189 | * Uses `Views.set()` when setting `options.add` to `false`. |
| 190 | * |
| 191 | * Accepts an `options` object. By default, provided `views` will be |
| 192 | * inserted at the end of the array of existing views. To insert |
| 193 | * `views` at a specific index, use `options.at`. If `options.silent` |
| 194 | * is true, no DOM modifications will be made. |
| 195 | * |
| 196 | * For more information on the `options` object, see `Views.set()`. |
| 197 | * |
| 198 | * @since 3.5.0 |
| 199 | * |
| 200 | * @param {string} selector A jQuery selector. |
| 201 | * @param {array|object} views The subviews for the main view. |
| 202 | * @param {Object} options Options for call. To insert `views` at a |
| 203 | * specific index, use `options.at`. If |
| 204 | * `options.silent` is true, no DOM modifications |
| 205 | * will be made. |
| 206 | * |
| 207 | * @return wp.Backbone.Subviews |
| 208 | */ |
165 | | // ### Stop tracking subviews |
166 | | // |
167 | | // Stops tracking `views` registered to a `selector`. If no `views` are |
168 | | // set, then all of the `selector`'s subviews will be unregistered and |
169 | | // removed. |
170 | | // |
171 | | // Accepts an `options` object. If `options.silent` is set, `remove` |
172 | | // will *not* be triggered on the unregistered views. |
| 219 | /** |
| 220 | * Removes an added subview. |
| 221 | * |
| 222 | * Stops tracking `views` registered to a `selector`. If no `views` are |
| 223 | * set, then all of the `selector`'s subviews will be unregistered and |
| 224 | * removed. |
| 225 | * |
| 226 | * Accepts an `options` object. If `options.silent` is set, `remove` |
| 227 | * will *not* be triggered on the unregistered views. |
| 228 | * |
| 229 | * @since 3.5.0 |
| 230 | * |
| 231 | * @param {string} selector A jQuery selector. |
| 232 | * @param {array|object} views The subviews for the main view. |
| 233 | * @param {Object} options Options for call. If `options.silent` is set, |
| 234 | * `remove` will *not* be triggered on the |
| 235 | * unregistered views. |
| 236 | * |
| 237 | * @return {wp.Backbone.Subviews} The current Subviews instance. |
| 238 | */ |
222 | | // ### Remove all subviews |
223 | | // |
224 | | // Triggers the `remove()` method on all subviews. Detaches the master |
225 | | // view from its parent. Resets the internals of the views manager. |
226 | | // |
227 | | // Accepts an `options` object. If `options.silent` is set, `unset` |
228 | | // will *not* be triggered on the master view's parent. |
| 298 | /** |
| 299 | * Removes all subviews |
| 300 | * |
| 301 | * Triggers the `remove()` method on all subviews. Detaches the master |
| 302 | * view from its parent. Resets the internals of the views manager. |
| 303 | * |
| 304 | * Accepts an `options` object. If `options.silent` is set, `unset` |
| 305 | * will *not* be triggered on the master view's parent. |
| 306 | * |
| 307 | * @since 3.6.0 |
| 308 | * |
| 309 | * @param {Object} options Options for call. |
| 310 | * @param {boolean} options.silent If true, `unset` wil *not* be triggered on |
| 311 | * the master views' parent. |
| 312 | * |
| 313 | * @return {wp.Backbone.Subviews} The current Subviews instance. |
| 314 | */ |
252 | | // ### Insert subviews into a selector |
253 | | // |
254 | | // By default, appends the subview `els` to the end of the `$target` |
255 | | // selector. If `options.at` is set, inserts the subview `els` at the |
256 | | // provided index. |
257 | | // |
258 | | // Can be overridden in subclasses. |
| 347 | /** |
| 348 | * Insert subviews into a selector |
| 349 | * |
| 350 | * By default, appends the subview `els` to the end of the `$target` |
| 351 | * selector. If `options.at` is set, inserts the subview `els` at the |
| 352 | * provided index. |
| 353 | * |
| 354 | * Can be overridden in subclasses. |
| 355 | * |
| 356 | * @since 3.5.0 |
| 357 | * |
| 358 | * @param {string} $target Selector where to put the elements. |
| 359 | * @param {*} els HTML or elements to put at the end of the |
| 360 | * $target. |
| 361 | * @param {?Object} options Options for call. |
| 362 | * @param {?number} options.at At which index to put the elements. |
| 363 | * |
| 364 | * @return {wp.Backbone.Subviews} The current Subviews instance. |
| 365 | */ |
271 | | // ### Trigger the ready event |
272 | | // |
273 | | // **Only use this method if you know what you're doing.** |
274 | | // For performance reasons, this method does not check if the view is |
275 | | // actually attached to the DOM. It's taking your word for it. |
276 | | // |
277 | | // Fires the ready event on the current view and all attached subviews. |
| 378 | /** |
| 379 | * Triggers the ready event. |
| 380 | * |
| 381 | * Only use this method if you know what you're doing. For performance reasons, |
| 382 | * this method does not check if the view is actually attached to the DOM. It's |
| 383 | * taking your word for it. |
| 384 | * |
| 385 | * Fires the ready event on the current view and all attached subviews. |
| 386 | * |
| 387 | * @since 3.5.0 |
| 388 | */ |
286 | | |
287 | | // #### Internal. Attaches a series of views to a selector. |
288 | | // |
289 | | // Checks to see if a matching selector exists, renders the views, |
290 | | // performs the proper DOM operation, and then checks if the view is |
291 | | // attached to the document. |
| 397 | /** |
| 398 | * Attaches a series of views to a selector. Internal. |
| 399 | * |
| 400 | * Checks to see if a matching selector exists, renders the views, |
| 401 | * performs the proper DOM operation, and then checks if the view is |
| 402 | * attached to the document. |
| 403 | * |
| 404 | * @since 3.5.0 |
| 405 | * |
| 406 | * @private |
| 407 | * |
| 408 | * @param {string} selector A jQuery selector. |
| 409 | * @param {array|object} views The subviews for the main view. |
| 410 | * @param {Object} options Options for call. |
| 411 | * @param {boolean} options.add If true the provided views will be added. |
| 412 | * |
| 413 | * @return {wp.Backbone.Subviews} The current Subviews instance. |
| 414 | */ |