Changeset 28688
- Timestamp:
- 06/06/2014 02:12:03 PM (11 years ago)
- Location:
- trunk/src/wp-includes/js
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/js/media-models.js
r28682 r28688 6 6 7 7 /** 8 * wp.media( attributes )8 * Create and return a media frame. 9 9 * 10 10 * Handles the default media experience. Automatically creates … … 32 32 frame = new MediaFrame.Post( attributes ); 33 33 } else if ( 'manage' === attributes.frame && MediaFrame.Manage ) { 34 frame = new MediaFrame.Manage( attributes ); 34 frame = new MediaFrame.Manage( attributes ); 35 35 } else if ( 'image' === attributes.frame && MediaFrame.ImageDetails ) { 36 36 frame = new MediaFrame.ImageDetails( attributes ); -
trunk/src/wp-includes/js/media-views.js
r28682 r28688 93 93 _.extend( media.controller.Region.prototype, { 94 94 /** 95 * Switch modes95 * 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 ) { … … 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 ); … … 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 ) { … … 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() { … … 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={}] … … 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 ) { … … 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 ); … … 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 /** … … 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() { … … 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 … … 539 573 540 574 /** 541 * wp.media.controller.Library575 * A state for choosing an attachment from the media library. 542 576 * 543 577 * @constructor … … 748 782 749 783 /** 750 * wp.media.controller.ImageDetails784 * A state for editing the settings of an image within a content editor. 751 785 * 752 786 * @constructor … … 779 813 780 814 /** 781 * wp.media.controller.GalleryEdit815 * A state for editing a gallery's images and settings. 782 816 * 783 817 * @constructor … … 878 912 879 913 /** 880 * wp.media.controller.GalleryAdd914 * A state for adding an image to a gallery. 881 915 * 882 916 * @constructor … … 1112 1146 1113 1147 /** 1114 * wp.media.controller.FeaturedImage1148 * A state for selecting a featured image for a post. 1115 1149 * 1116 1150 * @constructor … … 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 … … 1267 1299 1268 1300 /** 1269 * wp.media.controller.EditImage1301 * A state for editing (cropping, etc.) an image. 1270 1302 * 1271 1303 * @constructor … … 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;
Note: See TracChangeset
for help on using the changeset viewer.