diff --git a/src/wp-includes/js/media-models.js b/src/wp-includes/js/media-models.js
index 176b424..d2dd7df 100644
|
a
|
b
|
window.wp = window.wp || {}; |
| 5 | 5 | var Attachment, Attachments, Query, PostImage, compare, l10n, media; |
| 6 | 6 | |
| 7 | 7 | /** |
| 8 | | * wp.media( attributes ) |
| | 8 | * Create and return a media frame. |
| 9 | 9 | * |
| 10 | | * Handles the default media experience. Automatically creates |
| 11 | | * and opens a media frame, and returns the result. |
| 12 | | * Does nothing if the controllers do not exist. |
| | 10 | * Employs the facade design pattern. |
| 13 | 11 | * |
| 14 | | * @param {object} attributes The properties passed to the main media controller. |
| 15 | | * @return {wp.media.view.MediaFrame} A media workflow. |
| | 12 | * @param {object} attributes The properties passed to the media frame. |
| | 13 | * @return {wp.media.view.MediaFrame.*} A media workflow. |
| 16 | 14 | */ |
| 17 | 15 | media = wp.media = function( attributes ) { |
| 18 | 16 | var MediaFrame = media.view.MediaFrame, |
| … |
… |
window.wp = window.wp || {}; |
| 31 | 29 | } else if ( 'post' === attributes.frame && MediaFrame.Post ) { |
| 32 | 30 | frame = new MediaFrame.Post( attributes ); |
| 33 | 31 | } else if ( 'manage' === attributes.frame && MediaFrame.Manage ) { |
| 34 | | frame = new MediaFrame.Manage( attributes ); |
| | 32 | frame = new MediaFrame.Manage( attributes ); |
| 35 | 33 | } else if ( 'image' === attributes.frame && MediaFrame.ImageDetails ) { |
| 36 | 34 | frame = new MediaFrame.ImageDetails( attributes ); |
| 37 | 35 | } else if ( 'audio' === attributes.frame && MediaFrame.AudioDetails ) { |
diff --git a/src/wp-includes/js/media-views.js b/src/wp-includes/js/media-views.js
index 6775746..8b8ef52 100644
|
a
|
b
|
|
| 92 | 92 | |
| 93 | 93 | _.extend( media.controller.Region.prototype, { |
| 94 | 94 | /** |
| 95 | | * Switch modes |
| | 95 | * Activate a mode. |
| 96 | 96 | * |
| 97 | 97 | * @param {string} mode |
| 98 | 98 | * |
| 99 | | * @fires wp.media.controller.Region#{id}:activate:{mode} |
| 100 | | * @fires wp.media.controller.Region#{id}:deactivate:{mode} |
| | 99 | * @fires this.view#{this.id}:activate:{this._mode} |
| | 100 | * @fires this.view#{this.id}:activate |
| | 101 | * @fires this.view#{this.id}:deactivate:{this._mode} |
| | 102 | * @fires this.view#{this.id}:deactivate |
| 101 | 103 | * |
| 102 | | * @returns {wp.media.controller.Region} Returns itself to allow chaining |
| | 104 | * @returns {wp.media.controller.Region} Returns itself to allow chaining. |
| 103 | 105 | */ |
| 104 | 106 | mode: function( mode ) { |
| 105 | 107 | if ( ! mode ) { |
| … |
… |
|
| 110 | 112 | return this; |
| 111 | 113 | } |
| 112 | 114 | |
| | 115 | /** |
| | 116 | * Region mode deactivation event. |
| | 117 | * |
| | 118 | * @event this.view#{this.id}:deactivate:{this._mode} |
| | 119 | * @event this.view#{this.id}:deactivate |
| | 120 | */ |
| 113 | 121 | this.trigger('deactivate'); |
| | 122 | |
| 114 | 123 | this._mode = mode; |
| 115 | 124 | this.render( mode ); |
| | 125 | |
| | 126 | /** |
| | 127 | * Region mode activation event. |
| | 128 | * |
| | 129 | * @event this.view#{this.id}:activate:{this._mode} |
| | 130 | * @event this.view#{this.id}:activate |
| | 131 | */ |
| 116 | 132 | this.trigger('activate'); |
| 117 | 133 | return this; |
| 118 | 134 | }, |
| 119 | 135 | /** |
| 120 | | * Render a new mode, the view is set in the `create` callback method |
| 121 | | * of the extending class |
| 122 | | * |
| 123 | | * If no mode is provided, just re-render the current mode. |
| 124 | | * If the provided mode isn't active, perform a full switch. |
| | 136 | * Render a mode. |
| 125 | 137 | * |
| 126 | 138 | * @param {string} mode |
| 127 | 139 | * |
| 128 | | * @fires wp.media.controller.Region#{id}:create:{mode} |
| 129 | | * @fires wp.media.controller.Region#{id}:render:{mode} |
| | 140 | * @fires this.view#{this.id}:create:{this._mode} |
| | 141 | * @fires this.view#{this.id}:create |
| | 142 | * @fires this.view#{this.id}:render:{this._mode} |
| | 143 | * @fires this.view#{this.id}:render |
| 130 | 144 | * |
| 131 | 145 | * @returns {wp.media.controller.Region} Returns itself to allow chaining |
| 132 | 146 | */ |
| 133 | 147 | render: function( mode ) { |
| | 148 | // If the mode isn't active, activate it. |
| 134 | 149 | if ( mode && mode !== this._mode ) { |
| 135 | 150 | return this.mode( mode ); |
| 136 | 151 | } |
| … |
… |
|
| 138 | 153 | var set = { view: null }, |
| 139 | 154 | view; |
| 140 | 155 | |
| | 156 | /** |
| | 157 | * Create region view event. |
| | 158 | * |
| | 159 | * Region view creation takes place in an event callback on the frame. |
| | 160 | * |
| | 161 | * @event this.view#{this.id}:create:{this._mode} |
| | 162 | * @event this.view#{this.id}:create |
| | 163 | */ |
| 141 | 164 | this.trigger( 'create', set ); |
| 142 | 165 | view = set.view; |
| | 166 | |
| | 167 | /** |
| | 168 | * Render region view event. |
| | 169 | * |
| | 170 | * Region view creation takes place in an event callback on the frame. |
| | 171 | * |
| | 172 | * @event this.view#{this.id}:create:{this._mode} |
| | 173 | * @event this.view#{this.id}:create |
| | 174 | */ |
| 143 | 175 | this.trigger( 'render', view ); |
| 144 | 176 | if ( view ) { |
| 145 | 177 | this.set( view ); |
| … |
… |
|
| 148 | 180 | }, |
| 149 | 181 | |
| 150 | 182 | /** |
| 151 | | * @returns {wp.media.View} Returns the selector's first subview |
| | 183 | * Get the region's view. |
| | 184 | * |
| | 185 | * @returns {wp.media.View} |
| 152 | 186 | */ |
| 153 | 187 | get: function() { |
| 154 | 188 | return this.view.views.first( this.selector ); |
| 155 | 189 | }, |
| 156 | 190 | |
| 157 | 191 | /** |
| | 192 | * Set the region's view as a subview of the frame. |
| | 193 | * |
| 158 | 194 | * @param {Array|Object} views |
| 159 | 195 | * @param {Object} [options={}] |
| 160 | 196 | * @returns {wp.Backbone.Subviews} Subviews is returned to allow chaining |
| … |
… |
|
| 167 | 203 | }, |
| 168 | 204 | |
| 169 | 205 | /** |
| 170 | | * Helper function to trigger view events based on {id}:{event}:{mode} |
| | 206 | * Trigger regional view events on the frame. |
| 171 | 207 | * |
| 172 | 208 | * @param {string} event |
| 173 | | * @returns {undefined|wp.media.controller.Region} Returns itself to allow chaining |
| | 209 | * @returns {undefined|wp.media.controller.Region} Returns itself to allow chaining. |
| 174 | 210 | */ |
| 175 | 211 | trigger: function( event ) { |
| 176 | 212 | var base, args; |
| … |
… |
|
| 182 | 218 | args = _.toArray( arguments ); |
| 183 | 219 | base = this.id + ':' + event; |
| 184 | 220 | |
| 185 | | // Trigger `region:action:mode` event. |
| | 221 | // Trigger `{this.id}:{event}:{this._mode}` event on the frame. |
| 186 | 222 | args[0] = base + ':' + this._mode; |
| 187 | 223 | this.view.trigger.apply( this.view, args ); |
| 188 | 224 | |
| 189 | | // Trigger `region:action` event. |
| | 225 | // Trigger `{this.id}:{event}` event on the frame. |
| 190 | 226 | args[0] = base; |
| 191 | 227 | this.view.trigger.apply( this.view, args ); |
| 192 | 228 | return this; |
| … |
… |
|
| 210 | 246 | // Use Backbone's self-propagating `extend` inheritance method. |
| 211 | 247 | media.controller.StateMachine.extend = Backbone.Model.extend; |
| 212 | 248 | |
| 213 | | // Add events to the `StateMachine`. |
| 214 | 249 | _.extend( media.controller.StateMachine.prototype, Backbone.Events, { |
| 215 | 250 | /** |
| 216 | 251 | * Fetch a state. |
| … |
… |
|
| 286 | 321 | } |
| 287 | 322 | }); |
| 288 | 323 | |
| 289 | | // Map methods from the `states` collection to the `StateMachine` itself. |
| | 324 | // Map all event binding and triggering on a StateMachine to its `states` collection. |
| 290 | 325 | _.each([ 'on', 'off', 'trigger' ], function( method ) { |
| 291 | 326 | /** |
| 292 | | * @returns {wp.media.controller.StateMachine} Returns itself to allow chaining |
| | 327 | * @returns {wp.media.controller.StateMachine} Returns itself to allow chaining. |
| 293 | 328 | */ |
| 294 | 329 | media.controller.StateMachine.prototype[ method ] = function() { |
| 295 | 330 | // Ensure that the `states` collection exists so the `StateMachine` |
| … |
… |
|
| 304 | 339 | /** |
| 305 | 340 | * wp.media.controller.State |
| 306 | 341 | * |
| 307 | | * A state is a step in a workflow that when set will trigger |
| 308 | | * the controllers for the regions to be updated as specified. This |
| 309 | | * class is the base class that the various states used in the media |
| 310 | | * modals extend. |
| | 342 | * A state is a step in a workflow that when set will trigger the controllers |
| | 343 | * for the regions to be updated as specified in the frame. This is the base |
| | 344 | * class that the various states used in wp.media extend. |
| 311 | 345 | * |
| 312 | 346 | * @constructor |
| 313 | 347 | * @augments Backbone.Model |
| … |
… |
|
| 538 | 572 | }; |
| 539 | 573 | |
| 540 | 574 | /** |
| 541 | | * wp.media.controller.Library |
| | 575 | * A state for choosing an attachment from the media library. |
| 542 | 576 | * |
| 543 | 577 | * @constructor |
| 544 | 578 | * @augments wp.media.controller.State |
| … |
… |
|
| 747 | 781 | _.extend( media.controller.Library.prototype, media.selectionSync ); |
| 748 | 782 | |
| 749 | 783 | /** |
| 750 | | * wp.media.controller.ImageDetails |
| | 784 | * A state for editing the settings of an image within a content editor. |
| 751 | 785 | * |
| 752 | 786 | * @constructor |
| 753 | 787 | * @augments wp.media.controller.State |
| … |
… |
|
| 778 | 812 | }); |
| 779 | 813 | |
| 780 | 814 | /** |
| 781 | | * wp.media.controller.GalleryEdit |
| | 815 | * A state for editing a gallery's images and settings. |
| 782 | 816 | * |
| 783 | 817 | * @constructor |
| 784 | 818 | * @augments wp.media.controller.Library |
| … |
… |
|
| 877 | 911 | }); |
| 878 | 912 | |
| 879 | 913 | /** |
| 880 | | * wp.media.controller.GalleryAdd |
| | 914 | * A state for adding an image to a gallery. |
| 881 | 915 | * |
| 882 | 916 | * @constructor |
| 883 | 917 | * @augments wp.media.controller.Library |
| … |
… |
|
| 1111 | 1145 | }); |
| 1112 | 1146 | |
| 1113 | 1147 | /** |
| 1114 | | * wp.media.controller.FeaturedImage |
| | 1148 | * A state for selecting a featured image for a post. |
| 1115 | 1149 | * |
| 1116 | 1150 | * @constructor |
| 1117 | 1151 | * @augments wp.media.controller.Library |
| … |
… |
|
| 1194 | 1228 | }); |
| 1195 | 1229 | |
| 1196 | 1230 | /** |
| 1197 | | * wp.media.controller.ReplaceImage |
| 1198 | | * |
| 1199 | | * Replace a selected single image |
| | 1231 | * A state for replacing an image. |
| 1200 | 1232 | * |
| 1201 | 1233 | * @constructor |
| 1202 | 1234 | * @augments wp.media.controller.Library |
| … |
… |
|
| 1266 | 1298 | }); |
| 1267 | 1299 | |
| 1268 | 1300 | /** |
| 1269 | | * wp.media.controller.EditImage |
| | 1301 | * A state for editing (cropping, etc.) an image. |
| 1270 | 1302 | * |
| 1271 | 1303 | * @constructor |
| 1272 | 1304 | * @augments wp.media.controller.State |
| … |
… |
|
| 4530 | 4562 | * @augments Backbone.View |
| 4531 | 4563 | */ |
| 4532 | 4564 | media.view.RouterItem = media.view.MenuItem.extend({ |
| | 4565 | /** |
| | 4566 | * On click handler to activate the content region's corresponding mode. |
| | 4567 | */ |
| 4533 | 4568 | click: function() { |
| 4534 | 4569 | var contentMode = this.options.contentMode; |
| 4535 | 4570 | if ( contentMode ) { |