Make WordPress Core

Changeset 33342


Ignore:
Timestamp:
07/21/2015 03:09:28 PM (10 years ago)
Author:
wonderboymusic
Message:

Revert [32466], I will pick this up in 4.4.

See #32466.

Location:
trunk/src/wp-includes/js
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/media-grid.js

    r33337 r33342  
    5050 */
    5151var Router = Backbone.Router.extend({
    52     initialize: function ( options ) {
    53         this.controller = options.controller;
    54         this.library = options.library;
    55         this.on( 'route', this.checkRoute );
    56     },
    57 
    5852    routes: {
    5953        'upload.php?item=:slug':    'showItem',
    60         'upload.php?search=:query': 'search',
    61         'upload.php':               'defaultRoute'
    62     },
    63 
    64     checkRoute: function ( event ) {
    65         if ( 'defaultRoute' !== event ) {
    66             this.modal = true;
    67         }
    68     },
    69 
    70     defaultRoute: function () {
    71         if ( this.modal ) {
    72             wp.media.frame.close();
    73             this.modal = false;
    74         }
     54        'upload.php?search=:query': 'search'
    7555    },
    7656
     
    8767    // Show the modal with a specific item
    8868    showItem: function( query ) {
    89         var frame = this.controller,
     69        var media = wp.media,
     70            library = media.frame.state().get('library'),
    9071            item;
    9172
    9273        // Trigger the media frame to open the correct item
    93         item = this.library.findWhere( { id: parseInt( query, 10 ) } );
     74        item = library.findWhere( { id: parseInt( query, 10 ) } );
    9475        if ( item ) {
    95             frame.trigger( 'edit:attachment', item );
     76            media.frame.trigger( 'edit:attachment', item );
    9677        } else {
    97             item = wp.media.attachment( query );
    98             frame.listenTo( item, 'change', function( model ) {
    99                 frame.stopListening( item );
    100                 frame.trigger( 'edit:attachment', model );
     78            item = media.attachment( query );
     79            media.frame.listenTo( item, 'change', function( model ) {
     80                media.frame.stopListening( item );
     81                media.frame.trigger( 'edit:attachment', model );
    10182            } );
    10283            item.fetch();
     
    665646            }).render();
    666647            this.uploader.ready();
    667             this.$body.append( this.uploader.el );
     648            $('body').append( this.uploader.el );
    668649
    669650            this.options.uploader = false;
    670651        }
     652
     653        this.gridRouter = new wp.media.view.MediaFrame.Manage.Router();
    671654
    672655        // Call 'initialize' directly on the parent class.
     
    676659        this.$el.appendTo( this.options.container );
    677660
    678         this.setLibrary( this.options );
    679         this.setRouter();
    680661        this.createStates();
    681662        this.bindRegionModeHandlers();
    682663        this.render();
    683664        this.bindSearchHandler();
    684     },
    685 
    686     setLibrary: function ( options ) {
    687         this.library = wp.media.query( options.library );
    688     },
    689 
    690     setRouter: function () {
    691         this.gridRouter = new wp.media.view.MediaFrame.Manage.Router({
    692             controller: this,
    693             library: this.library
    694         });
    695665    },
    696666
     
    713683        // Update the URL when entering search string (at most once per second)
    714684        search.on( 'input', _.bind( input, this ) );
    715         if ( currentSearch ) {
    716             searchView.val( currentSearch ).trigger( 'input' );
    717         }
     685        searchView.val( currentSearch ).trigger( 'input' );
    718686
    719687        this.gridRouter.on( 'route:search', function () {
     
    742710        this.states.add([
    743711            new Library({
    744                 library:            this.library,
     712                library:            wp.media.query( options.library ),
    745713                multiple:           options.multiple,
    746714                title:              options.title,
  • trunk/src/wp-includes/js/media/routers/manage.js

    r33337 r33342  
    88 */
    99var Router = Backbone.Router.extend({
    10     initialize: function ( options ) {
    11         this.controller = options.controller;
    12         this.library = options.library;
    13         this.on( 'route', this.checkRoute );
    14     },
    15 
    1610    routes: {
    1711        'upload.php?item=:slug':    'showItem',
    18         'upload.php?search=:query': 'search',
    19         'upload.php':               'defaultRoute'
    20     },
    21 
    22     checkRoute: function ( event ) {
    23         if ( 'defaultRoute' !== event ) {
    24             this.modal = true;
    25         }
    26     },
    27 
    28     defaultRoute: function () {
    29         if ( this.modal ) {
    30             wp.media.frame.close();
    31             this.modal = false;
    32         }
     12        'upload.php?search=:query': 'search'
    3313    },
    3414
     
    4525    // Show the modal with a specific item
    4626    showItem: function( query ) {
    47         var frame = this.controller,
     27        var media = wp.media,
     28            library = media.frame.state().get('library'),
    4829            item;
    4930
    5031        // Trigger the media frame to open the correct item
    51         item = this.library.findWhere( { id: parseInt( query, 10 ) } );
     32        item = library.findWhere( { id: parseInt( query, 10 ) } );
    5233        if ( item ) {
    53             frame.trigger( 'edit:attachment', item );
     34            media.frame.trigger( 'edit:attachment', item );
    5435        } else {
    55             item = wp.media.attachment( query );
    56             frame.listenTo( item, 'change', function( model ) {
    57                 frame.stopListening( item );
    58                 frame.trigger( 'edit:attachment', model );
     36            item = media.attachment( query );
     37            media.frame.listenTo( item, 'change', function( model ) {
     38                media.frame.stopListening( item );
     39                media.frame.trigger( 'edit:attachment', model );
    5940            } );
    6041            item.fetch();
  • trunk/src/wp-includes/js/media/views/frame/manage.js

    r33337 r33342  
    6161            }).render();
    6262            this.uploader.ready();
    63             this.$body.append( this.uploader.el );
     63            $('body').append( this.uploader.el );
    6464
    6565            this.options.uploader = false;
    6666        }
     67
     68        this.gridRouter = new wp.media.view.MediaFrame.Manage.Router();
    6769
    6870        // Call 'initialize' directly on the parent class.
     
    7274        this.$el.appendTo( this.options.container );
    7375
    74         this.setLibrary( this.options );
    75         this.setRouter();
    7676        this.createStates();
    7777        this.bindRegionModeHandlers();
    7878        this.render();
    7979        this.bindSearchHandler();
    80     },
    81 
    82     setLibrary: function ( options ) {
    83         this.library = wp.media.query( options.library );
    84     },
    85 
    86     setRouter: function () {
    87         this.gridRouter = new wp.media.view.MediaFrame.Manage.Router({
    88             controller: this,
    89             library: this.library
    90         });
    9180    },
    9281
     
    10998        // Update the URL when entering search string (at most once per second)
    11099        search.on( 'input', _.bind( input, this ) );
    111         if ( currentSearch ) {
    112             searchView.val( currentSearch ).trigger( 'input' );
    113         }
     100        searchView.val( currentSearch ).trigger( 'input' );
    114101
    115102        this.gridRouter.on( 'route:search', function () {
     
    138125        this.states.add([
    139126            new Library({
    140                 library:            this.library,
     127                library:            wp.media.query( options.library ),
    141128                multiple:           options.multiple,
    142129                title:              options.title,
Note: See TracChangeset for help on using the changeset viewer.