equal
deleted
inserted
replaced
19 |
19 |
20 /** |
20 /** |
21 * Create the default states. |
21 * Create the default states. |
22 * |
22 * |
23 * @since 4.9.0 |
23 * @since 4.9.0 |
24 * @returns {void} |
24 * @return {void} |
25 */ |
25 */ |
26 createStates: function createStates() { |
26 createStates: function createStates() { |
27 this.states.add([ |
27 this.states.add([ |
28 new wp.media.controller.Library({ |
28 new wp.media.controller.Library({ |
29 id: 'gallery', |
29 id: 'gallery', |
86 * @since 4.9.0 |
86 * @since 4.9.0 |
87 * @param {Object} options - Options. |
87 * @param {Object} options - Options. |
88 * @param {Backbone.Model} options.model - Model. |
88 * @param {Backbone.Model} options.model - Model. |
89 * @param {jQuery} options.el - Control field container element. |
89 * @param {jQuery} options.el - Control field container element. |
90 * @param {jQuery} options.syncContainer - Container element where fields are synced for the server. |
90 * @param {jQuery} options.syncContainer - Container element where fields are synced for the server. |
91 * @returns {void} |
91 * @return {void} |
92 */ |
92 */ |
93 initialize: function initialize( options ) { |
93 initialize: function initialize( options ) { |
94 var control = this; |
94 var control = this; |
95 |
95 |
96 component.MediaWidgetControl.prototype.initialize.call( control, options ); |
96 component.MediaWidgetControl.prototype.initialize.call( control, options ); |
120 |
120 |
121 /** |
121 /** |
122 * Update the selected attachments if necessary. |
122 * Update the selected attachments if necessary. |
123 * |
123 * |
124 * @since 4.9.0 |
124 * @since 4.9.0 |
125 * @returns {void} |
125 * @return {void} |
126 */ |
126 */ |
127 updateSelectedAttachments: function updateSelectedAttachments() { |
127 updateSelectedAttachments: function updateSelectedAttachments() { |
128 var control = this, newIds, oldIds, removedIds, addedIds, addedQuery; |
128 var control = this, newIds, oldIds, removedIds, addedIds, addedQuery; |
129 |
129 |
130 newIds = control.model.get( 'ids' ); |
130 newIds = control.model.get( 'ids' ); |
153 |
153 |
154 /** |
154 /** |
155 * Render preview. |
155 * Render preview. |
156 * |
156 * |
157 * @since 4.9.0 |
157 * @since 4.9.0 |
158 * @returns {void} |
158 * @return {void} |
159 */ |
159 */ |
160 renderPreview: function renderPreview() { |
160 renderPreview: function renderPreview() { |
161 var control = this, previewContainer, previewTemplate, data; |
161 var control = this, previewContainer, previewTemplate, data; |
162 |
162 |
163 previewContainer = control.$el.find( '.media-widget-preview' ); |
163 previewContainer = control.$el.find( '.media-widget-preview' ); |
174 |
174 |
175 /** |
175 /** |
176 * Determine whether there are selected attachments. |
176 * Determine whether there are selected attachments. |
177 * |
177 * |
178 * @since 4.9.0 |
178 * @since 4.9.0 |
179 * @returns {boolean} Selected. |
179 * @return {boolean} Selected. |
180 */ |
180 */ |
181 isSelected: function isSelected() { |
181 isSelected: function isSelected() { |
182 var control = this; |
182 var control = this; |
183 |
183 |
184 if ( control.model.get( 'error' ) ) { |
184 if ( control.model.get( 'error' ) ) { |
190 |
190 |
191 /** |
191 /** |
192 * Open the media select frame to edit images. |
192 * Open the media select frame to edit images. |
193 * |
193 * |
194 * @since 4.9.0 |
194 * @since 4.9.0 |
195 * @returns {void} |
195 * @return {void} |
196 */ |
196 */ |
197 editMedia: function editMedia() { |
197 editMedia: function editMedia() { |
198 var control = this, selection, mediaFrame, mediaFrameProps; |
198 var control = this, selection, mediaFrame, mediaFrameProps; |
199 |
199 |
200 selection = new wp.media.model.Selection( control.selectedAttachments.models, { |
200 selection = new wp.media.model.Selection( control.selectedAttachments.models, { |
253 |
253 |
254 /** |
254 /** |
255 * Open the media select frame to chose an item. |
255 * Open the media select frame to chose an item. |
256 * |
256 * |
257 * @since 4.9.0 |
257 * @since 4.9.0 |
258 * @returns {void} |
258 * @return {void} |
259 */ |
259 */ |
260 selectMedia: function selectMedia() { |
260 selectMedia: function selectMedia() { |
261 var control = this, selection, mediaFrame, mediaFrameProps; |
261 var control = this, selection, mediaFrame, mediaFrameProps; |
262 selection = new wp.media.model.Selection( control.selectedAttachments.models, { |
262 selection = new wp.media.model.Selection( control.selectedAttachments.models, { |
263 multiple: true |
263 multiple: true |
319 /** |
319 /** |
320 * Clear the selected attachment when it is deleted in the media select frame. |
320 * Clear the selected attachment when it is deleted in the media select frame. |
321 * |
321 * |
322 * @since 4.9.0 |
322 * @since 4.9.0 |
323 * @param {wp.media.models.Attachment} attachment - Attachment. |
323 * @param {wp.media.models.Attachment} attachment - Attachment. |
324 * @returns {void} |
324 * @return {void} |
325 */ |
325 */ |
326 handleAttachmentDestroy: function handleAttachmentDestroy( attachment ) { |
326 handleAttachmentDestroy: function handleAttachmentDestroy( attachment ) { |
327 var control = this; |
327 var control = this; |
328 control.model.set( { |
328 control.model.set( { |
329 ids: _.difference( |
329 ids: _.difference( |