diff --git Gruntfile.js Gruntfile.js
index 80e2968..09993be 100644
|
|
|
module.exports = function(grunt) { |
| 687 | 687 | if ( ! this.args.length || this.args.indexOf( 'browserify' ) > -1 ) { |
| 688 | 688 | grunt.config( 'browserify.options', { |
| 689 | 689 | browserifyOptions: { |
| 690 | | debug: true |
| | 690 | debug: false |
| 691 | 691 | }, |
| 692 | 692 | watch: true |
| 693 | 693 | } ); |
diff --git src/wp-includes/js/media-grid.js src/wp-includes/js/media-grid.js
index edf429e..9e964e8 100644
|
|
|
media.view.DeleteSelectedPermanentlyButton = require( './views/button/delete-sel |
| 50 | 50 | */ |
| 51 | 51 | var Router = Backbone.Router.extend({ |
| 52 | 52 | routes: { |
| 53 | | 'upload.php?item=:slug': 'showItem', |
| 54 | | 'upload.php?search=:query': 'search' |
| | 53 | 'upload.php?item=:slug&mode=edit': 'editItem', |
| | 54 | 'upload.php?item=:slug': 'showItem', |
| | 55 | 'upload.php?search=:query': 'search', |
| | 56 | 'upload.php': 'reset' |
| 55 | 57 | }, |
| 56 | 58 | |
| 57 | 59 | // Map routes against the page URL |
| … |
… |
var Router = Backbone.Router.extend({ |
| 59 | 61 | return 'upload.php' + url; |
| 60 | 62 | }, |
| 61 | 63 | |
| | 64 | reset: function() { |
| | 65 | var frame = wp.media.frames.edit; |
| | 66 | |
| | 67 | if ( frame ) { |
| | 68 | frame.close(); |
| | 69 | } |
| | 70 | }, |
| | 71 | |
| 62 | 72 | // Respond to the search route by filling the search field and trigggering the input event |
| 63 | 73 | search: function( query ) { |
| 64 | 74 | jQuery( '#media-search-input' ).val( query ).trigger( 'input' ); |
| … |
… |
var Router = Backbone.Router.extend({ |
| 67 | 77 | // Show the modal with a specific item |
| 68 | 78 | showItem: function( query ) { |
| 69 | 79 | var media = wp.media, |
| 70 | | library = media.frame.state().get('library'), |
| | 80 | frame = media.frames.browse, |
| | 81 | library = frame.state().get('library'), |
| 71 | 82 | item; |
| 72 | 83 | |
| 73 | 84 | // Trigger the media frame to open the correct item |
| 74 | 85 | item = library.findWhere( { id: parseInt( query, 10 ) } ); |
| | 86 | item.set( 'skipHistory', true ); |
| | 87 | |
| 75 | 88 | if ( item ) { |
| 76 | | media.frame.trigger( 'edit:attachment', item ); |
| | 89 | frame.trigger( 'edit:attachment', item ); |
| 77 | 90 | } else { |
| 78 | 91 | item = media.attachment( query ); |
| 79 | | media.frame.listenTo( item, 'change', function( model ) { |
| 80 | | media.frame.stopListening( item ); |
| 81 | | media.frame.trigger( 'edit:attachment', model ); |
| | 92 | frame.listenTo( item, 'change', function( model ) { |
| | 93 | frame.stopListening( item ); |
| | 94 | frame.trigger( 'edit:attachment', model ); |
| 82 | 95 | } ); |
| 83 | 96 | item.fetch(); |
| 84 | 97 | } |
| | 98 | }, |
| | 99 | |
| | 100 | // Show the modal in edit mode with a specific item. |
| | 101 | editItem: function( query ) { |
| | 102 | this.showItem( query ); |
| | 103 | wp.media.frames.edit.content.mode( 'edit-details' ); |
| 85 | 104 | } |
| 86 | 105 | }); |
| 87 | 106 | |
| … |
… |
var Details = wp.media.view.Attachment.Details, |
| 107 | 126 | TwoColumn = Details.extend({ |
| 108 | 127 | template: wp.template( 'attachment-details-two-column' ), |
| 109 | 128 | |
| | 129 | initialize: function() { |
| | 130 | this.controller.on( 'content:activate:edit-details', _.bind( this.editAttachment, this ) ); |
| | 131 | |
| | 132 | Details.prototype.initialize.apply( this, arguments ); |
| | 133 | }, |
| | 134 | |
| 110 | 135 | editAttachment: function( event ) { |
| 111 | | event.preventDefault(); |
| | 136 | if ( event ) { |
| | 137 | event.preventDefault(); |
| | 138 | } |
| 112 | 139 | this.controller.content.mode( 'edit-image' ); |
| 113 | 140 | }, |
| 114 | 141 | |
| … |
… |
EditAttachments = MediaFrame.extend({ |
| 401 | 428 | // Bind default title creation. |
| 402 | 429 | this.on( 'title:create:default', this.createTitle, this ); |
| 403 | 430 | |
| 404 | | // Close the modal if the attachment is deleted. |
| 405 | | this.listenTo( this.model, 'change:status destroy', this.close, this ); |
| 406 | | |
| 407 | 431 | this.on( 'content:create:edit-metadata', this.editMetadataMode, this ); |
| 408 | 432 | this.on( 'content:create:edit-image', this.editImageMode, this ); |
| 409 | 433 | this.on( 'content:render:edit-image', this.editImageModeRender, this ); |
| | 434 | this.on( 'refresh', this.rerender, this ); |
| 410 | 435 | this.on( 'close', this.detach ); |
| | 436 | |
| | 437 | this.bindModelHandlers(); |
| | 438 | this.listenTo( this.gridRouter, 'route:search', this.close, this ); |
| | 439 | }, |
| | 440 | |
| | 441 | bindModelHandlers: function() { |
| | 442 | // Close the modal if the attachment is deleted. |
| | 443 | this.listenTo( this.model, 'change:status destroy', this.close, this ); |
| 411 | 444 | }, |
| 412 | 445 | |
| 413 | 446 | createModal: function() { |
| … |
… |
EditAttachments = MediaFrame.extend({ |
| 424 | 457 | |
| 425 | 458 | // Completely destroy the modal DOM element when closing it. |
| 426 | 459 | this.modal.on( 'close', _.bind( function() { |
| 427 | | this.modal.remove(); |
| 428 | 460 | $( 'body' ).off( 'keydown.media-modal' ); /* remove the keydown event */ |
| 429 | 461 | // Restore the original focus item if possible |
| 430 | 462 | $( 'li.attachment[data-id="' + this.model.get( 'id' ) +'"]' ).focus(); |
| … |
… |
EditAttachments = MediaFrame.extend({ |
| 442 | 474 | */ |
| 443 | 475 | createStates: function() { |
| 444 | 476 | this.states.add([ |
| 445 | | new wp.media.controller.EditAttachmentMetadata( { model: this.model } ) |
| | 477 | new wp.media.controller.EditAttachmentMetadata({ |
| | 478 | model: this.model, |
| | 479 | library: this.library |
| | 480 | }) |
| 446 | 481 | ]); |
| 447 | 482 | }, |
| 448 | 483 | |
| … |
… |
EditAttachments = MediaFrame.extend({ |
| 467 | 502 | model: this.model |
| 468 | 503 | }) ); |
| 469 | 504 | |
| 470 | | // Update browser url when navigating media details |
| 471 | | if ( this.model ) { |
| | 505 | // Update browser url when navigating media details, except on load. |
| | 506 | if ( this.model && ! this.model.get( 'skipHistory' ) ) { |
| 472 | 507 | this.gridRouter.navigate( this.gridRouter.baseUrl( '?item=' + this.model.id ) ); |
| 473 | 508 | } |
| 474 | 509 | }, |
| … |
… |
EditAttachments = MediaFrame.extend({ |
| 494 | 529 | frame: this, |
| 495 | 530 | controller: editImageController |
| 496 | 531 | } ); |
| | 532 | |
| | 533 | this.gridRouter.navigate( this.gridRouter.baseUrl( '?item=' + this.model.id + '&mode=edit' ) ); |
| | 534 | |
| 497 | 535 | }, |
| 498 | 536 | |
| 499 | 537 | editImageModeRender: function( view ) { |
| … |
… |
EditAttachments = MediaFrame.extend({ |
| 508 | 546 | /** |
| 509 | 547 | * Rerender the view. |
| 510 | 548 | */ |
| 511 | | rerender: function() { |
| | 549 | rerender: function( model ) { |
| | 550 | this.stopListening( this.model ); |
| | 551 | |
| | 552 | this.model = model; |
| | 553 | |
| | 554 | this.bindModelHandlers(); |
| | 555 | |
| 512 | 556 | // Only rerender the `content` region. |
| 513 | 557 | if ( this.content.mode() !== 'edit-metadata' ) { |
| 514 | 558 | this.content.mode( 'edit-metadata' ); |
| … |
… |
EditAttachments = MediaFrame.extend({ |
| 527 | 571 | this.$( '.left' ).blur(); |
| 528 | 572 | return; |
| 529 | 573 | } |
| 530 | | this.model = this.library.at( this.getCurrentIndex() - 1 ); |
| 531 | | this.rerender(); |
| | 574 | this.trigger( 'refresh', this.library.at( this.getCurrentIndex() - 1 ) ); |
| 532 | 575 | this.$( '.left' ).focus(); |
| 533 | 576 | }, |
| 534 | 577 | |
| … |
… |
EditAttachments = MediaFrame.extend({ |
| 540 | 583 | this.$( '.right' ).blur(); |
| 541 | 584 | return; |
| 542 | 585 | } |
| 543 | | this.model = this.library.at( this.getCurrentIndex() + 1 ); |
| 544 | | this.rerender(); |
| | 586 | this.trigger( 'refresh', this.library.at( this.getCurrentIndex() + 1 ) ); |
| 545 | 587 | this.$( '.right' ).focus(); |
| 546 | 588 | }, |
| 547 | 589 | |
| … |
… |
EditAttachments = MediaFrame.extend({ |
| 576 | 618 | }, |
| 577 | 619 | |
| 578 | 620 | resetRoute: function() { |
| 579 | | this.gridRouter.navigate( this.gridRouter.baseUrl( '' ) ); |
| | 621 | var searchTerm = this.controller.browserView.toolbar.get( 'search' ).$el.val(), |
| | 622 | url = '' !== searchTerm ? '?search=' + searchTerm : ''; |
| | 623 | |
| | 624 | this.gridRouter.navigate( this.gridRouter.baseUrl( url ) ); |
| 580 | 625 | } |
| 581 | 626 | }); |
| 582 | 627 | |
| … |
… |
Manage = MediaFrame.extend({ |
| 666 | 711 | this.bindRegionModeHandlers(); |
| 667 | 712 | this.render(); |
| 668 | 713 | this.bindSearchHandler(); |
| | 714 | |
| | 715 | wp.media.frames.browse = this; |
| 669 | 716 | }, |
| 670 | 717 | |
| 671 | 718 | bindSearchHandler: function() { |
| 672 | 719 | var search = this.$( '#media-search-input' ), |
| 673 | | currentSearch = this.options.container.data( 'search' ), |
| 674 | 720 | searchView = this.browserView.toolbar.get( 'search' ).$el, |
| 675 | 721 | listMode = this.$( '.view-list' ), |
| 676 | 722 | |
| … |
… |
Manage = MediaFrame.extend({ |
| 686 | 732 | |
| 687 | 733 | // Update the URL when entering search string (at most once per second) |
| 688 | 734 | search.on( 'input', _.bind( input, this ) ); |
| 689 | | searchView.val( currentSearch ).trigger( 'input' ); |
| 690 | | |
| 691 | | this.gridRouter.on( 'route:search', function () { |
| 692 | | var href = window.location.href; |
| 693 | | if ( href.indexOf( 'mode=' ) > -1 ) { |
| 694 | | href = href.replace( /mode=[^&]+/g, 'mode=list' ); |
| 695 | | } else { |
| 696 | | href += href.indexOf( '?' ) > -1 ? '&mode=list' : '?mode=list'; |
| 697 | | } |
| 698 | | href = href.replace( 'search=', 's=' ); |
| 699 | | listMode.prop( 'href', href ); |
| 700 | | } ); |
| | 735 | |
| | 736 | this.gridRouter |
| | 737 | .on( 'route:search', function () { |
| | 738 | var href = window.location.href; |
| | 739 | if ( href.indexOf( 'mode=' ) > -1 ) { |
| | 740 | href = href.replace( /mode=[^&]+/g, 'mode=list' ); |
| | 741 | } else { |
| | 742 | href += href.indexOf( '?' ) > -1 ? '&mode=list' : '?mode=list'; |
| | 743 | } |
| | 744 | href = href.replace( 'search=', 's=' ); |
| | 745 | listMode.prop( 'href', href ); |
| | 746 | }) |
| | 747 | .on( 'route:reset', function() { |
| | 748 | searchView.val( '' ).trigger( 'input' ); |
| | 749 | }); |
| 701 | 750 | }, |
| 702 | 751 | |
| 703 | 752 | /** |
| … |
… |
Manage = MediaFrame.extend({ |
| 789 | 838 | */ |
| 790 | 839 | openEditAttachmentModal: function( model ) { |
| 791 | 840 | // Create a new EditAttachment frame, passing along the library and the attachment model. |
| 792 | | wp.media( { |
| 793 | | frame: 'edit-attachments', |
| 794 | | controller: this, |
| 795 | | library: this.state().get('library'), |
| 796 | | model: model |
| 797 | | } ); |
| | 841 | if ( wp.media.frames.edit ) { |
| | 842 | wp.media.frames.edit.open().trigger( 'refresh', model ); |
| | 843 | } else { |
| | 844 | wp.media.frames.edit = wp.media( { |
| | 845 | frame: 'edit-attachments', |
| | 846 | controller: this, |
| | 847 | library: this.state().get('library'), |
| | 848 | model: model |
| | 849 | } ); |
| | 850 | } |
| 798 | 851 | }, |
| 799 | 852 | |
| 800 | 853 | /** |
diff --git src/wp-includes/js/media/routers/manage.js src/wp-includes/js/media/routers/manage.js
index 7395969..4b88aa3 100644
|
|
|
|
| 8 | 8 | */ |
| 9 | 9 | var Router = Backbone.Router.extend({ |
| 10 | 10 | routes: { |
| 11 | | 'upload.php?item=:slug': 'showItem', |
| 12 | | 'upload.php?search=:query': 'search' |
| | 11 | 'upload.php?item=:slug&mode=edit': 'editItem', |
| | 12 | 'upload.php?item=:slug': 'showItem', |
| | 13 | 'upload.php?search=:query': 'search', |
| | 14 | 'upload.php': 'reset' |
| 13 | 15 | }, |
| 14 | 16 | |
| 15 | 17 | // Map routes against the page URL |
| … |
… |
var Router = Backbone.Router.extend({ |
| 17 | 19 | return 'upload.php' + url; |
| 18 | 20 | }, |
| 19 | 21 | |
| | 22 | reset: function() { |
| | 23 | var frame = wp.media.frames.edit; |
| | 24 | |
| | 25 | if ( frame ) { |
| | 26 | frame.close(); |
| | 27 | } |
| | 28 | }, |
| | 29 | |
| 20 | 30 | // Respond to the search route by filling the search field and trigggering the input event |
| 21 | 31 | search: function( query ) { |
| 22 | 32 | jQuery( '#media-search-input' ).val( query ).trigger( 'input' ); |
| … |
… |
var Router = Backbone.Router.extend({ |
| 25 | 35 | // Show the modal with a specific item |
| 26 | 36 | showItem: function( query ) { |
| 27 | 37 | var media = wp.media, |
| 28 | | library = media.frame.state().get('library'), |
| | 38 | frame = media.frames.browse, |
| | 39 | library = frame.state().get('library'), |
| 29 | 40 | item; |
| 30 | 41 | |
| 31 | 42 | // Trigger the media frame to open the correct item |
| 32 | 43 | item = library.findWhere( { id: parseInt( query, 10 ) } ); |
| | 44 | item.set( 'skipHistory', true ); |
| | 45 | |
| 33 | 46 | if ( item ) { |
| 34 | | media.frame.trigger( 'edit:attachment', item ); |
| | 47 | frame.trigger( 'edit:attachment', item ); |
| 35 | 48 | } else { |
| 36 | 49 | item = media.attachment( query ); |
| 37 | | media.frame.listenTo( item, 'change', function( model ) { |
| 38 | | media.frame.stopListening( item ); |
| 39 | | media.frame.trigger( 'edit:attachment', model ); |
| | 50 | frame.listenTo( item, 'change', function( model ) { |
| | 51 | frame.stopListening( item ); |
| | 52 | frame.trigger( 'edit:attachment', model ); |
| 40 | 53 | } ); |
| 41 | 54 | item.fetch(); |
| 42 | 55 | } |
| | 56 | }, |
| | 57 | |
| | 58 | // Show the modal in edit mode with a specific item. |
| | 59 | editItem: function( query ) { |
| | 60 | this.showItem( query ); |
| | 61 | wp.media.frames.edit.content.mode( 'edit-details' ); |
| 43 | 62 | } |
| 44 | 63 | }); |
| 45 | 64 | |
diff --git src/wp-includes/js/media/views/attachment/details-two-column.js src/wp-includes/js/media/views/attachment/details-two-column.js
index 708287d..96a8fed 100644
|
|
|
var Details = wp.media.view.Attachment.Details, |
| 17 | 17 | TwoColumn = Details.extend({ |
| 18 | 18 | template: wp.template( 'attachment-details-two-column' ), |
| 19 | 19 | |
| | 20 | initialize: function() { |
| | 21 | this.controller.on( 'content:activate:edit-details', _.bind( this.editAttachment, this ) ); |
| | 22 | |
| | 23 | Details.prototype.initialize.apply( this, arguments ); |
| | 24 | }, |
| | 25 | |
| 20 | 26 | editAttachment: function( event ) { |
| 21 | | event.preventDefault(); |
| | 27 | if ( event ) { |
| | 28 | event.preventDefault(); |
| | 29 | } |
| 22 | 30 | this.controller.content.mode( 'edit-image' ); |
| 23 | 31 | }, |
| 24 | 32 | |
diff --git src/wp-includes/js/media/views/frame/edit-attachments.js src/wp-includes/js/media/views/frame/edit-attachments.js
index 3d29ff5..39ecef3 100644
|
|
|
EditAttachments = MediaFrame.extend({ |
| 59 | 59 | // Bind default title creation. |
| 60 | 60 | this.on( 'title:create:default', this.createTitle, this ); |
| 61 | 61 | |
| 62 | | // Close the modal if the attachment is deleted. |
| 63 | | this.listenTo( this.model, 'change:status destroy', this.close, this ); |
| 64 | | |
| 65 | 62 | this.on( 'content:create:edit-metadata', this.editMetadataMode, this ); |
| 66 | 63 | this.on( 'content:create:edit-image', this.editImageMode, this ); |
| 67 | 64 | this.on( 'content:render:edit-image', this.editImageModeRender, this ); |
| | 65 | this.on( 'refresh', this.rerender, this ); |
| 68 | 66 | this.on( 'close', this.detach ); |
| | 67 | |
| | 68 | this.bindModelHandlers(); |
| | 69 | this.listenTo( this.gridRouter, 'route:search', this.close, this ); |
| | 70 | }, |
| | 71 | |
| | 72 | bindModelHandlers: function() { |
| | 73 | // Close the modal if the attachment is deleted. |
| | 74 | this.listenTo( this.model, 'change:status destroy', this.close, this ); |
| 69 | 75 | }, |
| 70 | 76 | |
| 71 | 77 | createModal: function() { |
| … |
… |
EditAttachments = MediaFrame.extend({ |
| 82 | 88 | |
| 83 | 89 | // Completely destroy the modal DOM element when closing it. |
| 84 | 90 | this.modal.on( 'close', _.bind( function() { |
| 85 | | this.modal.remove(); |
| 86 | 91 | $( 'body' ).off( 'keydown.media-modal' ); /* remove the keydown event */ |
| 87 | 92 | // Restore the original focus item if possible |
| 88 | 93 | $( 'li.attachment[data-id="' + this.model.get( 'id' ) +'"]' ).focus(); |
| … |
… |
EditAttachments = MediaFrame.extend({ |
| 100 | 105 | */ |
| 101 | 106 | createStates: function() { |
| 102 | 107 | this.states.add([ |
| 103 | | new wp.media.controller.EditAttachmentMetadata( { model: this.model } ) |
| | 108 | new wp.media.controller.EditAttachmentMetadata({ |
| | 109 | model: this.model, |
| | 110 | library: this.library |
| | 111 | }) |
| 104 | 112 | ]); |
| 105 | 113 | }, |
| 106 | 114 | |
| … |
… |
EditAttachments = MediaFrame.extend({ |
| 125 | 133 | model: this.model |
| 126 | 134 | }) ); |
| 127 | 135 | |
| 128 | | // Update browser url when navigating media details |
| 129 | | if ( this.model ) { |
| | 136 | // Update browser url when navigating media details, except on load. |
| | 137 | if ( this.model && ! this.model.get( 'skipHistory' ) ) { |
| 130 | 138 | this.gridRouter.navigate( this.gridRouter.baseUrl( '?item=' + this.model.id ) ); |
| 131 | 139 | } |
| 132 | 140 | }, |
| … |
… |
EditAttachments = MediaFrame.extend({ |
| 152 | 160 | frame: this, |
| 153 | 161 | controller: editImageController |
| 154 | 162 | } ); |
| | 163 | |
| | 164 | this.gridRouter.navigate( this.gridRouter.baseUrl( '?item=' + this.model.id + '&mode=edit' ) ); |
| | 165 | |
| 155 | 166 | }, |
| 156 | 167 | |
| 157 | 168 | editImageModeRender: function( view ) { |
| … |
… |
EditAttachments = MediaFrame.extend({ |
| 166 | 177 | /** |
| 167 | 178 | * Rerender the view. |
| 168 | 179 | */ |
| 169 | | rerender: function() { |
| | 180 | rerender: function( model ) { |
| | 181 | this.stopListening( this.model ); |
| | 182 | |
| | 183 | this.model = model; |
| | 184 | |
| | 185 | this.bindModelHandlers(); |
| | 186 | |
| 170 | 187 | // Only rerender the `content` region. |
| 171 | 188 | if ( this.content.mode() !== 'edit-metadata' ) { |
| 172 | 189 | this.content.mode( 'edit-metadata' ); |
| … |
… |
EditAttachments = MediaFrame.extend({ |
| 185 | 202 | this.$( '.left' ).blur(); |
| 186 | 203 | return; |
| 187 | 204 | } |
| 188 | | this.model = this.library.at( this.getCurrentIndex() - 1 ); |
| 189 | | this.rerender(); |
| | 205 | this.trigger( 'refresh', this.library.at( this.getCurrentIndex() - 1 ) ); |
| 190 | 206 | this.$( '.left' ).focus(); |
| 191 | 207 | }, |
| 192 | 208 | |
| … |
… |
EditAttachments = MediaFrame.extend({ |
| 198 | 214 | this.$( '.right' ).blur(); |
| 199 | 215 | return; |
| 200 | 216 | } |
| 201 | | this.model = this.library.at( this.getCurrentIndex() + 1 ); |
| 202 | | this.rerender(); |
| | 217 | this.trigger( 'refresh', this.library.at( this.getCurrentIndex() + 1 ) ); |
| 203 | 218 | this.$( '.right' ).focus(); |
| 204 | 219 | }, |
| 205 | 220 | |
| … |
… |
EditAttachments = MediaFrame.extend({ |
| 234 | 249 | }, |
| 235 | 250 | |
| 236 | 251 | resetRoute: function() { |
| 237 | | this.gridRouter.navigate( this.gridRouter.baseUrl( '' ) ); |
| | 252 | var searchTerm = this.controller.browserView.toolbar.get( 'search' ).$el.val(), |
| | 253 | url = '' !== searchTerm ? '?search=' + searchTerm : ''; |
| | 254 | |
| | 255 | this.gridRouter.navigate( this.gridRouter.baseUrl( url ) ); |
| 238 | 256 | } |
| 239 | 257 | }); |
| 240 | 258 | |
diff --git src/wp-includes/js/media/views/frame/manage.js src/wp-includes/js/media/views/frame/manage.js
index a033d7b..38cb302 100644
|
|
|
Manage = MediaFrame.extend({ |
| 81 | 81 | this.bindRegionModeHandlers(); |
| 82 | 82 | this.render(); |
| 83 | 83 | this.bindSearchHandler(); |
| | 84 | |
| | 85 | wp.media.frames.browse = this; |
| 84 | 86 | }, |
| 85 | 87 | |
| 86 | 88 | bindSearchHandler: function() { |
| 87 | 89 | var search = this.$( '#media-search-input' ), |
| 88 | | currentSearch = this.options.container.data( 'search' ), |
| 89 | 90 | searchView = this.browserView.toolbar.get( 'search' ).$el, |
| 90 | 91 | listMode = this.$( '.view-list' ), |
| 91 | 92 | |
| … |
… |
Manage = MediaFrame.extend({ |
| 101 | 102 | |
| 102 | 103 | // Update the URL when entering search string (at most once per second) |
| 103 | 104 | search.on( 'input', _.bind( input, this ) ); |
| 104 | | searchView.val( currentSearch ).trigger( 'input' ); |
| 105 | | |
| 106 | | this.gridRouter.on( 'route:search', function () { |
| 107 | | var href = window.location.href; |
| 108 | | if ( href.indexOf( 'mode=' ) > -1 ) { |
| 109 | | href = href.replace( /mode=[^&]+/g, 'mode=list' ); |
| 110 | | } else { |
| 111 | | href += href.indexOf( '?' ) > -1 ? '&mode=list' : '?mode=list'; |
| 112 | | } |
| 113 | | href = href.replace( 'search=', 's=' ); |
| 114 | | listMode.prop( 'href', href ); |
| 115 | | } ); |
| | 105 | |
| | 106 | this.gridRouter |
| | 107 | .on( 'route:search', function () { |
| | 108 | var href = window.location.href; |
| | 109 | if ( href.indexOf( 'mode=' ) > -1 ) { |
| | 110 | href = href.replace( /mode=[^&]+/g, 'mode=list' ); |
| | 111 | } else { |
| | 112 | href += href.indexOf( '?' ) > -1 ? '&mode=list' : '?mode=list'; |
| | 113 | } |
| | 114 | href = href.replace( 'search=', 's=' ); |
| | 115 | listMode.prop( 'href', href ); |
| | 116 | }) |
| | 117 | .on( 'route:reset', function() { |
| | 118 | searchView.val( '' ).trigger( 'input' ); |
| | 119 | }); |
| 116 | 120 | }, |
| 117 | 121 | |
| 118 | 122 | /** |
| … |
… |
Manage = MediaFrame.extend({ |
| 204 | 208 | */ |
| 205 | 209 | openEditAttachmentModal: function( model ) { |
| 206 | 210 | // Create a new EditAttachment frame, passing along the library and the attachment model. |
| 207 | | wp.media( { |
| 208 | | frame: 'edit-attachments', |
| 209 | | controller: this, |
| 210 | | library: this.state().get('library'), |
| 211 | | model: model |
| 212 | | } ); |
| | 211 | if ( wp.media.frames.edit ) { |
| | 212 | wp.media.frames.edit.open().trigger( 'refresh', model ); |
| | 213 | } else { |
| | 214 | wp.media.frames.edit = wp.media( { |
| | 215 | frame: 'edit-attachments', |
| | 216 | controller: this, |
| | 217 | library: this.state().get('library'), |
| | 218 | model: model |
| | 219 | } ); |
| | 220 | } |
| 213 | 221 | }, |
| 214 | 222 | |
| 215 | 223 | /** |