Media: Introduce wp.media.editor.open(editor_id) and leverage it in distraction-free writing (fullscreen). props azaozz, koopersmith. fixes #22541.
git-svn-id: https://develop.svn.wordpress.org/trunk@22875 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
ae3472b2a2
commit
7f34c3e8ec
@ -482,14 +482,8 @@ PubSub.prototype.publish = function( topic, args ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
api.medialib = function() {
|
api.medialib = function() {
|
||||||
if ( s.has_tinymce && 'tinymce' === s.mode ) {
|
if ( typeof wp !== 'undefined' && wp.media && wp.media.editor )
|
||||||
tinyMCE.execCommand('WP_Medialib');
|
wp.media.editor.open(s.editor_id);
|
||||||
} else {
|
|
||||||
var href = $('#wp-' + s.editor_id + '-media-buttons a.thickbox').attr('href') || '';
|
|
||||||
|
|
||||||
if ( href )
|
|
||||||
tb_show('', href);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
api.refresh_buttons = function( fade ) {
|
api.refresh_buttons = function( fade ) {
|
||||||
|
@ -1148,7 +1148,7 @@ html[dir="rtl"] .wp-switch-editor {
|
|||||||
padding: 2px;
|
padding: 2px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
display: none;
|
display: none;
|
||||||
z-index: 999998;
|
z-index: 100000;
|
||||||
}
|
}
|
||||||
|
|
||||||
#wp_editimgbtn,
|
#wp_editimgbtn,
|
||||||
|
@ -68,7 +68,7 @@ input[type="search"] {
|
|||||||
left: 40px;
|
left: 40px;
|
||||||
right: 40px;
|
right: 40px;
|
||||||
bottom: 40px;
|
bottom: 40px;
|
||||||
z-index: 125000;
|
z-index: 160000;
|
||||||
}
|
}
|
||||||
|
|
||||||
.media-modal-backdrop {
|
.media-modal-backdrop {
|
||||||
@ -79,7 +79,7 @@ input[type="search"] {
|
|||||||
bottom: 0;
|
bottom: 0;
|
||||||
background: #000;
|
background: #000;
|
||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
z-index: 120000;
|
z-index: 159900;
|
||||||
}
|
}
|
||||||
|
|
||||||
.media-modal-backdrop div {
|
.media-modal-backdrop div {
|
||||||
|
@ -473,8 +473,7 @@
|
|||||||
init: function() {
|
init: function() {
|
||||||
$(document.body).on( 'click', '.insert-media', function( event ) {
|
$(document.body).on( 'click', '.insert-media', function( event ) {
|
||||||
var $this = $(this),
|
var $this = $(this),
|
||||||
editor = $this.data('editor'),
|
editor = $this.data('editor');
|
||||||
workflow;
|
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
@ -485,20 +484,33 @@
|
|||||||
// See: http://core.trac.wordpress.org/ticket/22445
|
// See: http://core.trac.wordpress.org/ticket/22445
|
||||||
$this.blur();
|
$this.blur();
|
||||||
|
|
||||||
if ( ! _.isString( editor ) )
|
wp.media.editor.open( editor );
|
||||||
return;
|
|
||||||
|
|
||||||
workflow = wp.media.editor.get( editor );
|
|
||||||
|
|
||||||
// If the workflow exists, just open it.
|
|
||||||
if ( workflow ) {
|
|
||||||
workflow.open();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize the editor's workflow if we haven't yet.
|
|
||||||
wp.media.editor.add( editor );
|
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
open: function( id ) {
|
||||||
|
var workflow;
|
||||||
|
|
||||||
|
// If an empty `id` is provided, default to `wpActiveEditor`.
|
||||||
|
id = id || wpActiveEditor;
|
||||||
|
|
||||||
|
// If that doesn't work, fall back to `tinymce.activeEditor`.
|
||||||
|
if ( ! id && typeof tinymce !== 'undefined' && tinymce.activeEditor )
|
||||||
|
id = id || tinymce.activeEditor.id;
|
||||||
|
|
||||||
|
// Last but not least, fall back to the empty string.
|
||||||
|
id = id || '';
|
||||||
|
|
||||||
|
workflow = wp.media.editor.get( id );
|
||||||
|
|
||||||
|
// If the workflow exists, open it.
|
||||||
|
// Initialize the editor's workflow if we haven't yet.
|
||||||
|
if ( workflow )
|
||||||
|
workflow.open();
|
||||||
|
else
|
||||||
|
workflow = wp.media.editor.add( id );
|
||||||
|
|
||||||
|
return workflow;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -63,15 +63,8 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
ed.addCommand('WP_Medialib', function() {
|
ed.addCommand('WP_Medialib', function() {
|
||||||
var id = ed.getParam('wp_fullscreen_editor_id') || ed.getParam('fullscreen_editor_id') || ed.id,
|
if ( typeof wp !== 'undefined' && wp.media && wp.media.editor )
|
||||||
link = tinymce.DOM.select('#wp-' + id + '-media-buttons a.thickbox');
|
wp.media.editor.open( ed.id );
|
||||||
|
|
||||||
if ( link && link[0] )
|
|
||||||
link = link[0];
|
|
||||||
else
|
|
||||||
return;
|
|
||||||
|
|
||||||
tb_show('', link.href);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Register buttons
|
// Register buttons
|
||||||
|
Loading…
x
Reference in New Issue
Block a user