<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[22875] trunk: Media: Introduce wp.media.editor.open(editor_id) and leverage it in distraction-free writing (fullscreen).</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/22875">22875</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2012-11-27 19:09:00 +0000 (Tue, 27 Nov 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Media: Introduce wp.media.editor.open(editor_id) and leverage it in distraction-free writing (fullscreen). props azaozz, koopersmith. fixes <a href="http://core.trac.wordpress.org/ticket/22541">#22541</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminjswpfullscreenjs">trunk/wp-admin/js/wp-fullscreen.js</a></li>
<li><a href="#trunkwpincludescsseditorcss">trunk/wp-includes/css/editor.css</a></li>
<li><a href="#trunkwpincludescssmediaviewscss">trunk/wp-includes/css/media-views.css</a></li>
<li><a href="#trunkwpincludesjsmediaeditorjs">trunk/wp-includes/js/media-editor.js</a></li>
<li><a href="#trunkwpincludesjstinymcepluginswordpresseditor_plugin_srcjs">trunk/wp-includes/js/tinymce/plugins/wordpress/editor_plugin_src.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminjswpfullscreenjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/wp-fullscreen.js (22874 => 22875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/wp-fullscreen.js        2012-11-27 18:58:07 UTC (rev 22874)
+++ trunk/wp-admin/js/wp-fullscreen.js        2012-11-27 19:09:00 UTC (rev 22875)
</span><span class="lines">@@ -482,14 +482,8 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         api.medialib = function() {
</span><del>-                if ( s.has_tinymce &amp;&amp; '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);
-                }
</del><ins>+                if ( typeof wp !== 'undefined' &amp;&amp; wp.media &amp;&amp; wp.media.editor )
+                        wp.media.editor.open(s.editor_id);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         api.refresh_buttons = function( fade ) {
</span></span></pre></div>
<a id="trunkwpincludescsseditorcss"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/css/editor.css (22874 => 22875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/css/editor.css        2012-11-27 18:58:07 UTC (rev 22874)
+++ trunk/wp-includes/css/editor.css        2012-11-27 19:09:00 UTC (rev 22875)
</span><span class="lines">@@ -1148,7 +1148,7 @@
</span><span class="cx">         padding: 2px;
</span><span class="cx">         position: absolute;
</span><span class="cx">         display: none;
</span><del>-        z-index: 999998;
</del><ins>+        z-index: 100000;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #wp_editimgbtn,
</span></span></pre></div>
<a id="trunkwpincludescssmediaviewscss"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/css/media-views.css (22874 => 22875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/css/media-views.css        2012-11-27 18:58:07 UTC (rev 22874)
+++ trunk/wp-includes/css/media-views.css        2012-11-27 19:09:00 UTC (rev 22875)
</span><span class="lines">@@ -68,7 +68,7 @@
</span><span class="cx">         left: 40px;
</span><span class="cx">         right: 40px;
</span><span class="cx">         bottom: 40px;
</span><del>-        z-index: 125000;
</del><ins>+        z-index: 160000;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> .media-modal-backdrop {
</span><span class="lines">@@ -79,7 +79,7 @@
</span><span class="cx">         bottom: 0;
</span><span class="cx">         background: #000;
</span><span class="cx">         opacity: 0.8;
</span><del>-        z-index: 120000;
</del><ins>+        z-index: 159900;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> .media-modal-backdrop div {
</span></span></pre></div>
<a id="trunkwpincludesjsmediaeditorjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/media-editor.js (22874 => 22875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/media-editor.js        2012-11-27 18:58:07 UTC (rev 22874)
+++ trunk/wp-includes/js/media-editor.js        2012-11-27 19:09:00 UTC (rev 22875)
</span><span class="lines">@@ -471,10 +471,9 @@
</span><span class="cx">                 },
</span><span class="cx"> 
</span><span class="cx">                 init: function() {
</span><del>-                        $(document.body).on('click', '.insert-media', function( event ) {
</del><ins>+                        $(document.body).on( 'click', '.insert-media', function( event ) {
</ins><span class="cx">                                 var $this = $(this),
</span><del>-                                        editor = $this.data('editor'),
-                                        workflow;
</del><ins>+                                        editor = $this.data('editor');
</ins><span class="cx"> 
</span><span class="cx">                                 event.preventDefault();
</span><span class="cx"> 
</span><span class="lines">@@ -485,22 +484,35 @@
</span><span class="cx">                                 // See: http://core.trac.wordpress.org/ticket/22445
</span><span class="cx">                                 $this.blur();
</span><span class="cx"> 
</span><del>-                                if ( ! _.isString( editor ) )
-                                        return;
</del><ins>+                                wp.media.editor.open( editor );
+                        });
+                },
</ins><span class="cx"> 
</span><del>-                                workflow = wp.media.editor.get( editor );
</del><ins>+                open: function( id ) {
+                        var workflow;
</ins><span class="cx"> 
</span><del>-                                // If the workflow exists, just open it.
-                                if ( workflow ) {
-                                        workflow.open();
-                                        return;
-                                }
</del><ins>+                        // If an empty `id` is provided, default to `wpActiveEditor`.
+                        id = id || wpActiveEditor;
</ins><span class="cx"> 
</span><del>-                                // Initialize the editor's workflow if we haven't yet.
-                                wp.media.editor.add( editor );
-                        });
</del><ins>+                        // If that doesn't work, fall back to `tinymce.activeEditor`.
+                        if ( ! id &amp;&amp; typeof tinymce !== 'undefined' &amp;&amp; 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;
</ins><span class="cx">                 }
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         $( wp.media.editor.init );
</span><del>-}(jQuery));
</del><span class="cx">\ No newline at end of file
</span><ins>+}(jQuery));
</ins></span></pre></div>
<a id="trunkwpincludesjstinymcepluginswordpresseditor_plugin_srcjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/tinymce/plugins/wordpress/editor_plugin_src.js (22874 => 22875)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/tinymce/plugins/wordpress/editor_plugin_src.js        2012-11-27 18:58:07 UTC (rev 22874)
+++ trunk/wp-includes/js/tinymce/plugins/wordpress/editor_plugin_src.js        2012-11-27 19:09:00 UTC (rev 22875)
</span><span class="lines">@@ -63,15 +63,8 @@
</span><span class="cx">                         });
</span><span class="cx"> 
</span><span class="cx">                         ed.addCommand('WP_Medialib', function() {
</span><del>-                                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 &amp;&amp; link[0] )
-                                        link = link[0];
-                                else
-                                        return;
-
-                                tb_show('', link.href);
</del><ins>+                                if ( typeof wp !== 'undefined' &amp;&amp; wp.media &amp;&amp; wp.media.editor )
+                                        wp.media.editor.open( ed.id );
</ins><span class="cx">                         });
</span><span class="cx"> 
</span><span class="cx">                         // Register buttons
</span></span></pre>
</div>
</div>

</body>
</html>