mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
Media: Introduce wp.media.editor.open(editor_id) and leverage it in distraction-free writing (fullscreen). props azaozz, koopersmith. fixes #22541.
git-svn-id: http://core.svn.wordpress.org/trunk@22875 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
fe3ace4f05
commit
45ce9d2a96
@ -482,14 +482,8 @@ PubSub.prototype.publish = function( topic, args ) {
|
||||
}
|
||||
|
||||
api.medialib = function() {
|
||||
if ( s.has_tinymce && 'tinymce' === s.mode ) {
|
||||
tinyMCE.execCommand('WP_Medialib');
|
||||
} else {
|
||||
var href = $('#wp-' + s.editor_id + '-media-buttons a.thickbox').attr('href') || '';
|
||||
|
||||
if ( href )
|
||||
tb_show('', href);
|
||||
}
|
||||
if ( typeof wp !== 'undefined' && wp.media && wp.media.editor )
|
||||
wp.media.editor.open(s.editor_id);
|
||||
}
|
||||
|
||||
api.refresh_buttons = function( fade ) {
|
||||
|
@ -1148,7 +1148,7 @@ html[dir="rtl"] .wp-switch-editor {
|
||||
padding: 2px;
|
||||
position: absolute;
|
||||
display: none;
|
||||
z-index: 999998;
|
||||
z-index: 100000;
|
||||
}
|
||||
|
||||
#wp_editimgbtn,
|
||||
|
@ -68,7 +68,7 @@ input[type="search"] {
|
||||
left: 40px;
|
||||
right: 40px;
|
||||
bottom: 40px;
|
||||
z-index: 125000;
|
||||
z-index: 160000;
|
||||
}
|
||||
|
||||
.media-modal-backdrop {
|
||||
@ -79,7 +79,7 @@ input[type="search"] {
|
||||
bottom: 0;
|
||||
background: #000;
|
||||
opacity: 0.8;
|
||||
z-index: 120000;
|
||||
z-index: 159900;
|
||||
}
|
||||
|
||||
.media-modal-backdrop div {
|
||||
|
@ -473,8 +473,7 @@
|
||||
init: function() {
|
||||
$(document.body).on( 'click', '.insert-media', function( event ) {
|
||||
var $this = $(this),
|
||||
editor = $this.data('editor'),
|
||||
workflow;
|
||||
editor = $this.data('editor');
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
@ -485,20 +484,33 @@
|
||||
// See: http://core.trac.wordpress.org/ticket/22445
|
||||
$this.blur();
|
||||
|
||||
if ( ! _.isString( 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 );
|
||||
wp.media.editor.open( 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() {
|
||||
var id = ed.getParam('wp_fullscreen_editor_id') || ed.getParam('fullscreen_editor_id') || ed.id,
|
||||
link = tinymce.DOM.select('#wp-' + id + '-media-buttons a.thickbox');
|
||||
|
||||
if ( link && link[0] )
|
||||
link = link[0];
|
||||
else
|
||||
return;
|
||||
|
||||
tb_show('', link.href);
|
||||
if ( typeof wp !== 'undefined' && wp.media && wp.media.editor )
|
||||
wp.media.editor.open( ed.id );
|
||||
});
|
||||
|
||||
// Register buttons
|
||||
|
Loading…
Reference in New Issue
Block a user