Media Grid: add disambiguation between generic frames and routers and the router specifically interacting with the grid's frame.

See #24716.

Built from https://develop.svn.wordpress.org/trunk@29074


git-svn-id: http://core.svn.wordpress.org/trunk@28860 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-07-10 18:43:14 +00:00
parent 7a438ad0dc
commit 41f71c7938
2 changed files with 7 additions and 14 deletions

View File

@ -153,7 +153,7 @@
}, },
createRouter: function() { createRouter: function() {
this.gridRouter = new media.view.Frame.Router( this ); this.gridRouter = new media.view.MediaFrame.Manage.Router();
// Verify pushState support and activate // Verify pushState support and activate
if ( window.history && window.history.pushState ) { if ( window.history && window.history.pushState ) {
@ -335,14 +335,7 @@
/** /**
* A router for handling the browser history and application state * A router for handling the browser history and application state
*/ */
media.view.Frame.Router = Backbone.Router.extend({ media.view.MediaFrame.Manage.Router = Backbone.Router.extend({
mediaFrame: '',
initialize: function( mediaFrame ){
this.mediaFrame = mediaFrame;
},
routes: { routes: {
'upload.php?item=:slug': 'showitem', 'upload.php?item=:slug': 'showitem',
'upload.php?search=:query': 'search', 'upload.php?search=:query': 'search',
@ -363,18 +356,18 @@
// Show the modal with a specific item // Show the modal with a specific item
showitem: function( query ) { showitem: function( query ) {
var library = this.mediaFrame.state().get('library'); var library = media.frame.state().get('library');
// Remove existing modal if present // Remove existing modal if present
this.closeModal(); this.closeModal();
// Trigger the media frame to open the correct item // Trigger the media frame to open the correct item
this.mediaFrame.trigger( 'edit:attachment', library.findWhere( { id: parseInt( query, 10 ) } ) ); media.frame.trigger( 'edit:attachment', library.findWhere( { id: parseInt( query, 10 ) } ) );
}, },
// Close the modal if set up // Close the modal if set up
closeModal: function() { closeModal: function() {
if ( 'undefined' !== typeof this.mediaFrame.editAttachmentFrame ) { if ( media.frame.modal ) {
this.mediaFrame.editAttachmentFrame.modal.close(); media.frame.modal.close();
} }
}, },

File diff suppressed because one or more lines are too long