Ticket #22652: 22652.diff
| File 22652.diff, 9.3 KB (added by koopersmith, 6 months ago) |
|---|
-
wp-admin/includes/meta-boxes.php
1020 1020 $thumbnailId.val( thumbnailId ); 1021 1021 1022 1022 if ( frame ) { 1023 selection = frame. get('library').get('selection');1023 selection = frame.state('library').get('selection'); 1024 1024 1025 1025 if ( -1 === thumbnailId ) 1026 1026 selection.clear(); … … 1055 1055 1056 1056 frame = wp.media( options ); 1057 1057 1058 frame. get('library').set( 'filterable', 'uploaded' );1058 frame.state('library').set( 'filterable', 'uploaded' ); 1059 1059 1060 1060 frame.toolbar.on( 'activate:select', function() { 1061 1061 frame.toolbar.view().set({ -
wp-admin/js/custom-background.js
57 57 }); 58 58 }); 59 59 60 frame.s tate('library');60 frame.setState('library'); 61 61 }); 62 62 }); 63 63 })(jQuery); 64 No newline at end of file -
wp-admin/js/custom-header.js
40 40 }); 41 41 }); 42 42 43 frame.s tate('library');43 frame.setState('library'); 44 44 }); 45 45 }); 46 46 }(jQuery)); -
wp-includes/js/media-editor.js
393 393 }, this ); 394 394 }, this ); 395 395 396 workflow. get('gallery-edit').on( 'update', function( selection ) {396 workflow.state('gallery-edit').on( 'update', function( selection ) { 397 397 this.insert( wp.media.gallery.shortcode( selection ).string() ); 398 398 }, this ); 399 399 400 workflow. get('embed').on( 'select', function() {400 workflow.state('embed').on( 'select', function() { 401 401 var embed = workflow.state().toJSON(); 402 402 403 403 embed.url = embed.url || ''; -
wp-includes/js/media-models.js
31 31 32 32 delete attributes.frame; 33 33 // Set the default state. 34 frame.s tate( frame.options.state );34 frame.setState( frame.options.state ); 35 35 // Render, attach, and open the frame. 36 36 return frame.render().attach().open(); 37 37 }; -
wp-includes/js/media-views.js
143 143 // Add events to the `StateMachine`. 144 144 _.extend( media.controller.StateMachine.prototype, Backbone.Events, { 145 145 146 // Fetch a state model.146 // Fetch a state. 147 147 // 148 // If no `id` is provided, returns the active state. 149 // 148 150 // Implicitly creates states. 149 get: function( id ) {151 state: function( id ) { 150 152 // Ensure that the `states` collection exists so the `StateMachine` 151 153 // can be used as a mixin. 152 154 this.states = this.states || new Backbone.Collection(); 153 155 154 if ( ! this.states.get( id ) ) 156 // Default to the active state. 157 id = id || this._state; 158 159 if ( id && ! this.states.get( id ) ) 155 160 this.states.add({ id: id }); 156 161 return this.states.get( id ); 157 162 }, 158 163 159 // Selects or returns the active state. 160 // 161 // If a `id` is provided, sets that as the current state. 162 // If no parameters are provided, returns the current state object. 163 state: function( id ) { 164 var previous; 164 // Sets the active state. 165 setState: function( id ) { 166 var previous = this.state(); 165 167 166 if ( ! id )167 return this._state ? this.get( this._state ) : null;168 169 previous = this.state();170 171 168 // Bail if we're trying to select the current state, if we haven't 172 169 // created the `states` collection, or are trying to select a state 173 170 // that does not exist. … … 176 173 177 174 if ( previous ) { 178 175 previous.trigger('deactivate'); 179 this._ previous= previous.id;176 this._lastState = previous.id; 180 177 } 181 178 182 179 this._state = id; 183 180 this.state().trigger('activate'); 184 181 }, 185 182 186 previous: function() { 187 return this._previous; 183 // Returns the previous active state. 184 // 185 // Call the `state()` method with no parameters to retrieve the current 186 // active state. 187 lastState: function() { 188 if ( this._lastState ) 189 return this.state( this._lastState ); 188 190 } 189 191 }); 190 192 … … 427 429 previous = this.previous('excludeState'); 428 430 429 431 if ( previous ) 430 this.frame. get( previous ).off( 'change:library', this._excludeStateLibrary, this );432 this.frame.state( previous ).off( 'change:library', this._excludeStateLibrary, this ); 431 433 432 434 if ( current ) 433 this.frame. get( current ).on( 'change:library', this._excludeStateLibrary, this );435 this.frame.state( current ).on( 'change:library', this._excludeStateLibrary, this ); 434 436 }, 435 437 436 438 _excludeStateLibrary: function() { … … 439 441 if ( ! current ) 440 442 return; 441 443 442 this.set( 'exclude', this.frame. get( current ).get('library') );444 this.set( 'exclude', this.frame.state( current ).get('library') ); 443 445 } 444 446 }); 445 447 … … 474 476 uploading: function( attachment ) { 475 477 var library = this.get('libraryState'); 476 478 477 this.frame. get( library ).get('selection').add( attachment );478 this.frame.s tate( library );479 this.frame.state( library ).get('selection').add( attachment ); 480 this.frame.setState( library ); 479 481 } 480 482 }); 481 483 … … 1119 1121 1120 1122 // Generate the tab states. 1121 1123 _.each( tabs, function( title, id ) { 1122 var frame = this. get( 'iframe:' + id ).set( _.defaults({1124 var frame = this.state( 'iframe:' + id ).set( _.defaults({ 1123 1125 tab: id, 1124 1126 src: tabUrl + '&tab=' + id, 1125 1127 title: title, … … 1146 1148 1147 1149 _.each( media.view.settings.tabs, function( title, id ) { 1148 1150 views[ 'iframe:' + id ] = { 1149 text: this. get( 'iframe:' + id ).get('title'),1151 text: this.state( 'iframe:' + id ).get('title'), 1150 1152 priority: 200 1151 1153 }; 1152 1154 }, this ); … … 1164 1166 window.tb_remove = function() { 1165 1167 frame.close(); 1166 1168 frame.reset(); 1167 frame.s tate( frame.options.state );1169 frame.setState( frame.options.state ); 1168 1170 frame._tb_remove.call( window ); 1169 1171 }; 1170 1172 }, … … 1319 1321 controller.state().trigger( options.event ); 1320 1322 controller.reset(); 1321 1323 if ( options.state ) 1322 controller.s tate( options.state );1324 controller.setState( options.state ); 1323 1325 } 1324 1326 } 1325 1327 } … … 1449 1451 }, 1450 1452 1451 1453 galleryMenu: function() { 1452 var previous = this.previous(), 1454 var lastState = this.lastState(), 1455 previous = lastState && lastState.id, 1453 1456 frame = this; 1454 1457 1455 1458 this.menu.view( new media.view.Menu({ … … 1460 1463 priority: 20, 1461 1464 click: function() { 1462 1465 if ( previous ) 1463 frame.s tate( previous );1466 frame.setState( previous ); 1464 1467 else 1465 1468 frame.close(); 1466 1469 } … … 1578 1581 1579 1582 controller.reset(); 1580 1583 // @todo: Make the state activated dynamic (instead of hardcoded). 1581 controller.s tate('upload');1584 controller.setState('upload'); 1582 1585 } 1583 1586 } 1584 1587 } … … 1597 1600 click: function() { 1598 1601 var controller = this.controller, 1599 1602 state = controller.state(), 1600 edit = controller. get('gallery-edit');1603 edit = controller.state('gallery-edit'); 1601 1604 1602 1605 edit.get('library').add( state.get('selection').models ); 1603 1606 state.trigger('reset'); … … 2066 2069 controller.reset(); 2067 2070 2068 2071 if ( options.state ) 2069 controller.s tate( options.state );2072 controller.setState( options.state ); 2070 2073 } 2071 2074 }); 2072 2075 … … 2102 2105 return function() { 2103 2106 var controller = this.controller, 2104 2107 selection = controller.state().get('selection'), 2105 edit = controller. get( state ),2108 edit = controller.state( state ), 2106 2109 models = filter ? filter( selection ) : selection.models; 2107 2110 2108 2111 edit.set( 'library', new media.model.Selection( models, { … … 2110 2113 multiple: true 2111 2114 }) ); 2112 2115 2113 this.controller.s tate( state );2116 this.controller.setState( state ); 2114 2117 }; 2115 2118 }; 2116 2119 … … 2375 2378 if ( options.click ) 2376 2379 options.click.call( this ); 2377 2380 else if ( options.state ) 2378 this.controller.s tate( options.state );2381 this.controller.setState( options.state ); 2379 2382 }, 2380 2383 2381 2384 render: function() { -
wp-includes/js/tinymce/plugins/wpgallery/editor_plugin_src.js
28 28 29 29 frame = gallery.edit( '[' + ed.dom.getAttrib( el, 'title' ) + ']' ); 30 30 31 frame. get('gallery-edit').on( 'update', function( selection ) {31 frame.state('gallery-edit').on( 'update', function( selection ) { 32 32 var shortcode = gallery.shortcode( selection ).string().slice( 1, -1 ); 33 33 ed.dom.setAttrib( el, 'title', shortcode ); 34 34 }); … … 49 49 }); 50 50 } 51 51 }); 52 52 53 53 ed.onMouseDown.add(function(ed, e) { 54 54 if ( e.target.nodeName == 'IMG' && ed.dom.hasClass(e.target, 'wpGallery') ) { 55 55 ed.plugins.wordpress._hideButtons();
