wp/wp-includes/js/wp-backbone.js
author ymh <ymh.work@gmail.com>
Mon, 08 Sep 2025 19:44:41 +0200
changeset 23 417f20492bf7
parent 21 48c4eec2b7e6
permissions -rw-r--r--
Update Docker configuration and plugin versions - Upgrade MariaDB from 10.6 to 11 with auto-upgrade support - Add WordPress debug environment variable to FPM container - Update PHP-FPM Dockerfile base image - Update Include Mastodon Feed plugin with bug fixes and improvements - Update Portfolio plugin (v2.58) with latest translations and demo data enhancements - Remove old README.md from Mastodon Feed plugin 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     1
/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     2
 * @output wp-includes/js/wp-backbone.js
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     3
 */
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
     4
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
     5
/** @namespace wp */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
window.wp = window.wp || {};
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
(function ($) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
     9
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    10
	 * Create the WordPress Backbone namespace.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    11
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    12
	 * @namespace wp.Backbone
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    13
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
	wp.Backbone = {};
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    16
	/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    17
	 * A backbone subview manager.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    18
	 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    19
	 * @since 3.5.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    20
	 * @since 3.6.0 Moved wp.media.Views to wp.Backbone.Subviews.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    21
	 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    22
	 * @memberOf wp.Backbone
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    23
	 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    24
	 * @class
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    25
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    26
	 * @param {wp.Backbone.View} view  The main view.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    27
	 * @param {Array|Object}     views The subviews for the main view.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    28
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
	wp.Backbone.Subviews = function( view, views ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
		this.view = view;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
		this._views = _.isArray( views ) ? { '': views } : views || {};
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
	};
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
	wp.Backbone.Subviews.extend = Backbone.Model.extend;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
	_.extend( wp.Backbone.Subviews.prototype, {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    37
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    38
		 * Fetches all of the subviews.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    39
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    40
		 * @since 3.5.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    41
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    42
		 * @return {Array} All the subviews.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    43
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
		all: function() {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    45
			return _.flatten( _.values( this._views ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    48
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    49
		 * Fetches all subviews that match a given `selector`.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    50
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    51
		 * If no `selector` is provided, it will grab all subviews attached
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    52
		 * to the view's root.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    53
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    54
		 * @since 3.5.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    55
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    56
		 * @param {string} selector A jQuery selector.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    57
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    58
		 * @return {Array} All the subviews that match the selector.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    59
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
		get: function( selector ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
			selector = selector || '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
			return this._views[ selector ];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    65
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    66
		 * Fetches the first subview that matches a given `selector`.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    67
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    68
		 * If no `selector` is provided, it will grab the first subview attached to the
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    69
		 * view's root.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    70
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    71
		 * Useful when a selector only has one subview at a time.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    72
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    73
		 * @since 3.5.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    74
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    75
		 * @param {string} selector A jQuery selector.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    76
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    77
		 * @return {Backbone.View} The view.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    78
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
		first: function( selector ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
			var views = this.get( selector );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
			return views && views.length ? views[0] : null;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    84
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    85
		 * Registers subview(s).
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    86
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    87
		 * Registers any number of `views` to a `selector`.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    88
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    89
		 * When no `selector` is provided, the root selector (the empty string)
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    90
		 * is used. `views` accepts a `Backbone.View` instance or an array of
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    91
		 * `Backbone.View` instances.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    92
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    93
		 * ---
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    94
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    95
		 * Accepts an `options` object, which has a significant effect on the
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    96
		 * resulting behavior.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    97
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    98
		 * `options.silent` - *boolean, `false`*
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    99
		 * If `options.silent` is true, no DOM modifications will be made.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   100
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   101
		 * `options.add` - *boolean, `false`*
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   102
		 * Use `Views.add()` as a shortcut for setting `options.add` to true.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   103
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   104
		 * By default, the provided `views` will replace any existing views
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   105
		 * associated with the selector. If `options.add` is true, the provided
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   106
		 * `views` will be added to the existing views.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   107
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   108
		 * `options.at` - *integer, `undefined`*
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   109
		 * When adding, to insert `views` at a specific index, use `options.at`.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   110
		 * By default, `views` are added to the end of the array.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   111
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   112
		 * @since 3.5.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   113
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   114
		 * @param {string}       selector A jQuery selector.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   115
		 * @param {Array|Object} views    The subviews for the main view.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   116
		 * @param {Object}       options  Options for call. If `options.silent` is true,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   117
		 *                                no DOM  modifications will be made. Use
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   118
		 *                                `Views.add()` as a shortcut for setting
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   119
		 *                                `options.add` to true. If `options.add` is
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   120
		 *                                true, the provided `views` will be added to
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   121
		 *                                the existing views. When adding, to insert
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   122
		 *                                `views` at a specific index, use `options.at`.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   123
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   124
		 * @return {wp.Backbone.Subviews} The current Subviews instance.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   125
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
		set: function( selector, views, options ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
			var existing, next;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
			if ( ! _.isString( selector ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
				options  = views;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
				views    = selector;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
				selector = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
			options  = options || {};
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   136
			views    = _.isArray( views ) ? views : [ views ];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
			existing = this.get( selector );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
			next     = views;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   139
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
			if ( existing ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
				if ( options.add ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
					if ( _.isUndefined( options.at ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
						next = existing.concat( views );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   144
					} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
						next = existing;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
						next.splice.apply( next, [ options.at, 0 ].concat( views ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
					}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
				} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   149
					_.each( next, function( view ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   150
						view.__detach = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   151
					});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   152
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   153
					_.each( existing, function( view ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   154
						if ( view.__detach )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   155
							view.$el.detach();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
						else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   157
							view.remove();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
					});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   160
					_.each( next, function( view ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   161
						delete view.__detach;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   162
					});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
			this._views[ selector ] = next;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
			_.each( views, function( subview ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
				var constructor = subview.Views || wp.Backbone.Subviews,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
					subviews = subview.views = subview.views || new constructor( subview );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
				subviews.parent   = this.view;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
				subviews.selector = selector;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
			}, this );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
			if ( ! options.silent )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
				this._attach( selector, views, _.extend({ ready: this._isReady() }, options ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   178
			return this;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   181
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   182
		 * Add subview(s) to existing subviews.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   183
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   184
		 * An alias to `Views.set()`, which defaults `options.add` to true.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   185
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   186
		 * Adds any number of `views` to a `selector`.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   187
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   188
		 * When no `selector` is provided, the root selector (the empty string)
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   189
		 * is used. `views` accepts a `Backbone.View` instance or an array of
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   190
		 * `Backbone.View` instances.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   191
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   192
		 * Uses `Views.set()` when setting `options.add` to `false`.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   193
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   194
		 * Accepts an `options` object. By default, provided `views` will be
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   195
		 * inserted at the end of the array of existing views. To insert
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   196
		 * `views` at a specific index, use `options.at`. If `options.silent`
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   197
		 * is true, no DOM modifications will be made.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   198
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   199
		 * For more information on the `options` object, see `Views.set()`.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   200
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   201
		 * @since 3.5.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   202
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   203
		 * @param {string}       selector A jQuery selector.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   204
		 * @param {Array|Object} views    The subviews for the main view.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   205
		 * @param {Object}       options  Options for call.  To insert `views` at a
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   206
		 *                                specific index, use `options.at`. If
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   207
		 *                                `options.silent` is true, no DOM modifications
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   208
		 *                                will be made.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   209
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   210
		 * @return {wp.Backbone.Subviews} The current subviews instance.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   211
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   212
		add: function( selector, views, options ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   213
			if ( ! _.isString( selector ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   214
				options  = views;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
				views    = selector;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
				selector = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
			return this.set( selector, views, _.extend({ add: true }, options ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   220
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   222
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   223
		 * Removes an added subview.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   224
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   225
		 * Stops tracking `views` registered to a `selector`. If no `views` are
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   226
		 * set, then all of the `selector`'s subviews will be unregistered and
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   227
		 * removed.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   228
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   229
		 * Accepts an `options` object. If `options.silent` is set, `remove`
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   230
		 * will *not* be triggered on the unregistered views.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   231
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   232
		 * @since 3.5.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   233
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   234
		 * @param {string}       selector A jQuery selector.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   235
		 * @param {Array|Object} views    The subviews for the main view.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   236
		 * @param {Object}       options  Options for call. If `options.silent` is set,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   237
		 *                                `remove` will *not* be triggered on the
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   238
		 *                                unregistered views.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   239
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   240
		 * @return {wp.Backbone.Subviews} The current Subviews instance.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   241
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   242
		unset: function( selector, views, options ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   243
			var existing;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   244
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   245
			if ( ! _.isString( selector ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   246
				options = views;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   247
				views = selector;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   248
				selector = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   249
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   250
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   251
			views = views || [];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   252
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   253
			if ( existing = this.get( selector ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   254
				views = _.isArray( views ) ? views : [ views ];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   255
				this._views[ selector ] = views.length ? _.difference( existing, views ) : [];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   256
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   257
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   258
			if ( ! options || ! options.silent )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   259
				_.invoke( views, 'remove' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   260
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   261
			return this;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   262
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   263
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   264
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   265
		 * Detaches all subviews.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   266
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   267
		 * Helps to preserve all subview events when re-rendering the master
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   268
		 * view. Used in conjunction with `Views.render()`.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   269
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   270
		 * @since 3.5.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   271
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   272
		 * @return {wp.Backbone.Subviews} The current Subviews instance.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   273
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
		detach: function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
			$( _.pluck( this.all(), 'el' ) ).detach();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   276
			return this;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   279
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   280
		 * Renders all subviews.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   281
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   282
		 * Used in conjunction with `Views.detach()`.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   283
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   284
		 * @since 3.5.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   285
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   286
		 * @return {wp.Backbone.Subviews} The current Subviews instance.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   287
		*/
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   288
		render: function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   289
			var options = {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   290
					ready: this._isReady()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   291
				};
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   292
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   293
			_.each( this._views, function( views, selector ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   294
				this._attach( selector, views, options );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   295
			}, this );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   296
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   297
			this.rendered = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   298
			return this;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   299
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   300
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   301
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   302
		 * Removes all subviews.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   303
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   304
		 * Triggers the `remove()` method on all subviews. Detaches the master
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   305
		 * view from its parent. Resets the internals of the views manager.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   306
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   307
		 * Accepts an `options` object. If `options.silent` is set, `unset`
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   308
		 * will *not* be triggered on the master view's parent.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   309
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   310
		 * @since 3.6.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   311
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   312
		 * @param {Object}  options        Options for call.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   313
		 * @param {boolean} options.silent If true, `unset` will *not* be triggered on
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   314
		 *                                 the master views' parent.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   315
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   316
		 * @return {wp.Backbone.Subviews} The current Subviews instance.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   317
		*/
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   318
		remove: function( options ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   319
			if ( ! options || ! options.silent ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   320
				if ( this.parent && this.parent.views )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   321
					this.parent.views.unset( this.selector, this.view, { silent: true });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   322
				delete this.parent;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   323
				delete this.selector;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   324
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   325
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   326
			_.invoke( this.all(), 'remove' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   327
			this._views = [];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   328
			return this;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   329
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   330
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   331
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   332
		 * Replaces a selector's subviews
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   333
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   334
		 * By default, sets the `$target` selector's html to the subview `els`.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   335
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   336
		 * Can be overridden in subclasses.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   337
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   338
		 * @since 3.5.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   339
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   340
		 * @param {string} $target Selector where to put the elements.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   341
		 * @param {*} els HTML or elements to put into the selector's HTML.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   342
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   343
		 * @return {wp.Backbone.Subviews} The current Subviews instance.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   344
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   345
		replace: function( $target, els ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   346
			$target.html( els );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   347
			return this;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   348
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   349
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   350
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   351
		 * Insert subviews into a selector.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   352
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   353
		 * By default, appends the subview `els` to the end of the `$target`
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   354
		 * selector. If `options.at` is set, inserts the subview `els` at the
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   355
		 * provided index.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   356
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   357
		 * Can be overridden in subclasses.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   358
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   359
		 * @since 3.5.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   360
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   361
		 * @param {string}  $target    Selector where to put the elements.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   362
		 * @param {*}       els        HTML or elements to put at the end of the
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   363
		 *                             $target.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   364
		 * @param {?Object} options    Options for call.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   365
		 * @param {?number} options.at At which index to put the elements.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   366
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   367
		 * @return {wp.Backbone.Subviews} The current Subviews instance.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   368
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   369
		insert: function( $target, els, options ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   370
			var at = options && options.at,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   371
				$children;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   372
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   373
			if ( _.isNumber( at ) && ($children = $target.children()).length > at )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   374
				$children.eq( at ).before( els );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   375
			else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   376
				$target.append( els );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   377
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   378
			return this;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   379
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   380
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   381
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   382
		 * Triggers the ready event.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   383
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   384
		 * Only use this method if you know what you're doing. For performance reasons,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   385
		 * this method does not check if the view is actually attached to the DOM. It's
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   386
		 * taking your word for it.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   387
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   388
		 * Fires the ready event on the current view and all attached subviews.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   389
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   390
		 * @since 3.5.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   391
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   392
		ready: function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   393
			this.view.trigger('ready');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   394
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   395
			// Find all attached subviews, and call ready on them.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   396
			_.chain( this.all() ).map( function( view ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   397
				return view.views;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   398
			}).flatten().where({ attached: true }).invoke('ready');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   399
		},
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   400
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   401
		 * Attaches a series of views to a selector. Internal.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   402
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   403
		 * Checks to see if a matching selector exists, renders the views,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   404
		 * performs the proper DOM operation, and then checks if the view is
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   405
		 * attached to the document.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   406
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   407
		 * @since 3.5.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   408
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   409
		 * @private
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   410
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   411
		 * @param {string}       selector    A jQuery selector.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   412
		 * @param {Array|Object} views       The subviews for the main view.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   413
		 * @param {Object}       options     Options for call.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   414
		 * @param {boolean}      options.add If true the provided views will be added.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   415
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   416
		 * @return {wp.Backbone.Subviews} The current Subviews instance.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   417
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   418
		_attach: function( selector, views, options ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   419
			var $selector = selector ? this.view.$( selector ) : this.view.$el,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   420
				managers;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   421
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   422
			// Check if we found a location to attach the views.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   423
			if ( ! $selector.length )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   424
				return this;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   425
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   426
			managers = _.chain( views ).pluck('views').flatten().value();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   427
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   428
			// Render the views if necessary.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   429
			_.each( managers, function( manager ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   430
				if ( manager.rendered )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   431
					return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   432
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   433
				manager.view.render();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   434
				manager.rendered = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   435
			}, this );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   436
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   437
			// Insert or replace the views.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   438
			this[ options.add ? 'insert' : 'replace' ]( $selector, _.pluck( views, 'el' ), options );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   439
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   440
			/*
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   441
			 * Set attached and trigger ready if the current view is already
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   442
			 * attached to the DOM.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   443
			 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   444
			_.each( managers, function( manager ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   445
				manager.attached = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   446
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   447
				if ( options.ready )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   448
					manager.ready();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   449
			}, this );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   450
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   451
			return this;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   452
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   453
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   454
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   455
		 * Determines whether or not the current view is in the DOM.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   456
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   457
		 * @since 3.5.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   458
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   459
		 * @private
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   460
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   461
		 * @return {boolean} Whether or not the current view is in the DOM.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   462
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   463
		_isReady: function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   464
			var node = this.view.el;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   465
			while ( node ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   466
				if ( node === document.body )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   467
					return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   468
				node = node.parentNode;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   469
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   470
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   471
			return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   472
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   473
	});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   474
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   475
	wp.Backbone.View = Backbone.View.extend({
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   476
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   477
		// The constructor for the `Views` manager.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   478
		Subviews: wp.Backbone.Subviews,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   479
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   480
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   481
		 * The base view class.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   482
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   483
		 * This extends the backbone view to have a build-in way to use subviews. This
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   484
		 * makes it easier to have nested views.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   485
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   486
		 * @since 3.5.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   487
		 * @since 3.6.0 Moved wp.media.View to wp.Backbone.View
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   488
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   489
		 * @constructs
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   490
		 * @augments Backbone.View
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   491
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   492
		 * @memberOf wp.Backbone
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   493
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   494
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   495
		 * @param {Object} options The options for this view.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   496
		 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   497
		constructor: function( options ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   498
			this.views = new this.Subviews( this, this.views );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   499
			this.on( 'ready', this.ready, this );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   500
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   501
			this.options = options || {};
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   502
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   503
			Backbone.View.apply( this, arguments );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   504
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   505
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   506
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   507
		 * Removes this view and all subviews.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   508
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   509
		 * @since 3.5.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   510
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   511
		 * @return {wp.Backbone.Subviews} The current Subviews instance.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   512
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   513
		remove: function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   514
			var result = Backbone.View.prototype.remove.apply( this, arguments );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   515
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   516
			// Recursively remove child views.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   517
			if ( this.views )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   518
				this.views.remove();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   519
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   520
			return result;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   521
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   522
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   523
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   524
		 * Renders this view and all subviews.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   525
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   526
		 * @since 3.5.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   527
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   528
		 * @return {wp.Backbone.View} The current instance of the view.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   529
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   530
		render: function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   531
			var options;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   532
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   533
			if ( this.prepare )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   534
				options = this.prepare();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   535
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   536
			this.views.detach();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   537
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   538
			if ( this.template ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   539
				options = options || {};
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   540
				this.trigger( 'prepare', options );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   541
				this.$el.html( this.template( options ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   542
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   543
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   544
			this.views.render();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   545
			return this;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   546
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   547
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   548
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   549
		 * Returns the options for this view.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   550
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   551
		 * @since 3.5.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   552
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   553
		 * @return {Object} The options for this view.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   554
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   555
		prepare: function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   556
			return this.options;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   557
		},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   558
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   559
		/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   560
		 * Method that is called when the ready event is triggered.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   561
		 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   562
		 * @since 3.5.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   563
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   564
		ready: function() {}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   565
	});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   566
}(jQuery));