<!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>[22770] trunk: Media: Move the new sections of media-upload.js to media-editor.js to allow the media modal to be used on the front end and prevent dependency conflicts with older themes and plugins.</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/22770">22770</a></dd>
<dt>Author</dt> <dd>koopersmith</dd>
<dt>Date</dt> <dd>2012-11-21 16:46:32 +0000 (Wed, 21 Nov 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Media: Move the new sections of media-upload.js to media-editor.js to allow the media modal to be used on the front end and prevent dependency conflicts with older themes and plugins. see <a href="http://core.trac.wordpress.org/ticket/21390">#21390</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminjsmediauploadjs">trunk/wp-admin/js/media-upload.js</a></li>
<li><a href="#trunkwpincludesjsmediamodelsjs">trunk/wp-includes/js/media-models.js</a></li>
<li><a href="#trunkwpincludesmediaphp">trunk/wp-includes/media.php</a></li>
<li><a href="#trunkwpincludesscriptloaderphp">trunk/wp-includes/script-loader.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkwpincludesjsmediaeditorjs">trunk/wp-includes/js/media-editor.js</a></li>
<li><a href="#trunkwpincludesjsmediaeditorminjs">trunk/wp-includes/js/media-editor.min.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminjsmediauploadjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/media-upload.js (22769 => 22770)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/media-upload.js        2012-11-21 16:34:57 UTC (rev 22769)
+++ trunk/wp-admin/js/media-upload.js        2012-11-21 16:46:32 UTC (rev 22770)
</span><span class="lines">@@ -86,478 +86,3 @@
</span><span class="cx">         });
</span><span class="cx"> 
</span><span class="cx"> })(jQuery);
</span><del>-
-// WordPress, TinyMCE, and Media
-// -----------------------------
-(function($){
-        // Stores the editors' `wp.media.controller.Frame` instances.
-        var workflows = {},
-                linkToUrl;
-
-        linkToUrl = function( props, attachment ) {
-                var link = props.link || getUserSetting( 'urlbutton', 'post' ),
-                        url;
-
-                if ( 'file' === link )
-                        url = attachment.url;
-                else if ( 'post' === link )
-                        url = attachment.link;
-                else if ( 'custom' === link )
-                        url = props.linkUrl;
-
-                return url || '';
-        };
-
-        wp.media.string = {
-                // Joins the `props` and `attachment` objects,
-                // outputting the proper object format based on the
-                // attachment's type.
-                props: function( props, attachment ) {
-                        var link, linkUrl, size, sizes;
-
-                        props = props ? _.clone( props ) : {};
-
-                        if ( attachment &amp;&amp; attachment.type )
-                                props.type = attachment.type;
-
-                        if ( 'image' === props.type ) {
-                                props = _.defaults( props || {}, {
-                                        align:   getUserSetting( 'align', 'none' ),
-                                        size:    getUserSetting( 'imgsize', 'medium' ),
-                                        url:     '',
-                                        classes: []
-                                });
-                        }
-
-                        // All attachment-specific settings follow.
-                        if ( ! attachment )
-                                return props;
-
-                        link = props.link || getUserSetting( 'urlbutton', 'post' );
-                        if ( 'file' === link )
-                                linkUrl = attachment.url;
-                        else if ( 'post' === link )
-                                linkUrl = attachment.link;
-                        else if ( 'custom' === link )
-                                linkUrl = props.linkUrl;
-                        props.linkUrl = linkUrl || '';
-
-                        // Format properties for images.
-                        if ( 'image' === attachment.type ) {
-                                props.classes.push( 'wp-image-' + attachment.id );
-
-                                sizes = attachment.sizes;
-                                size = sizes &amp;&amp; sizes[ props.size ] ? sizes[ props.size ] : attachment;
-
-                                _.extend( props, _.pick( attachment, 'align', 'caption' ), {
-                                        width:     size.width,
-                                        height:    size.height,
-                                        src:       size.url,
-                                        captionId: 'attachment_' + attachment.id
-                                });
-
-                        // Format properties for non-images.
-                        } else {
-                                _.extend( props, {
-                                        title:   attachment.title || attachment.filename,
-                                        rel:     'attachment wp-att-' + attachment.id
-                                });
-                        }
-
-                        return props;
-                },
-
-                link: function( props, attachment ) {
-                        var options;
-
-                        props = wp.media.string.props( props, attachment );
-
-                        options = {
-                                tag:     'a',
-                                content: props.title,
-                                attrs:   {
-                                        href: props.linkUrl
-                                }
-                        };
-
-                        if ( props.rel )
-                                options.attrs.rel = props.rel;
-
-                        return wp.html.string( options );
-                },
-
-                image: function( props, attachment ) {
-                        var img = {},
-                                options, classes, shortcode, html;
-
-                        props = wp.media.string.props( props, attachment );
-                        classes = props.classes || [];
-
-                        img.src = props.url;
-                        _.extend( img, _.pick( props, 'width', 'height', 'alt' ) );
-
-                        // Only assign the align class to the image if we're not printing
-                        // a caption, since the alignment is sent to the shortcode.
-                        if ( props.align &amp;&amp; ! props.caption )
-                                classes.push( 'align' + props.align );
-
-                        if ( props.size )
-                                classes.push( 'size-' + props.size );
-
-                        img['class'] = _.compact( classes ).join(' ');
-
-                        // Generate `img` tag options.
-                        options = {
-                                tag:    'img',
-                                attrs:  img,
-                                single: true
-                        };
-
-                        // Generate the `a` element options, if they exist.
-                        if ( props.linkUrl ) {
-                                options = {
-                                        tag:   'a',
-                                        attrs: {
-                                                href: props.linkUrl
-                                        },
-                                        content: options
-                                };
-                        }
-
-                        html = wp.html.string( options );
-
-                        // Generate the caption shortcode.
-                        if ( props.caption ) {
-                                shortcode = {};
-
-                                if ( img.width )
-                                        shortcode.width = img.width;
-
-                                if ( props.captionId )
-                                        shortcode.id = props.captionId;
-
-                                if ( props.align )
-                                        shortcode.align = 'align' + props.align;
-
-                                html = wp.shortcode.string({
-                                        tag:     'caption',
-                                        attrs:   shortcode,
-                                        content: html + ' ' + props.caption
-                                });
-                        }
-
-                        return html;
-                }
-        };
-
-        wp.media.gallery = (function() {
-                var galleries = {};
-
-                return {
-                        defaults: {
-                                order:      'ASC',
-                                id:         wp.media.view.settings.postId,
-                                itemtag:    'dl',
-                                icontag:    'dt',
-                                captiontag: 'dd',
-                                columns:    3,
-                                size:       'thumbnail'
-                        },
-
-                        attachments: function( shortcode ) {
-                                var shortcodeString = shortcode.string(),
-                                        result = galleries[ shortcodeString ],
-                                        attrs, args, query, others;
-
-                                delete galleries[ shortcodeString ];
-
-                                if ( result )
-                                        return result;
-
-                                attrs = shortcode.attrs.named;
-                                args  = _.pick( attrs, 'orderby', 'order' );
-
-                                args.type    = 'image';
-                                args.perPage = -1;
-
-                                // Map the `ids` param to the correct query args.
-                                if ( attrs.ids ) {
-                                        args.post__in = attrs.ids.split(',');
-                                        args.orderby  = 'post__in';
-                                } else if ( attrs.include ) {
-                                        args.post__in = attrs.include.split(',');
-                                }
-
-                                if ( attrs.exclude )
-                                        args.post__not_in = attrs.exclude.split(',');
-
-                                if ( ! args.post__in )
-                                        args.parent = attrs.id;
-
-                                // Collect the attributes that were not included in `args`.
-                                others = {};
-                                _.filter( attrs, function( value, key ) {
-                                        if ( _.isUndefined( args[ key ] ) )
-                                                others[ key ] = value;
-                                });
-
-                                query = media.query( args );
-                                query.gallery = new Backbone.Model( others );
-                                return query;
-                        },
-
-                        shortcode: function( attachments ) {
-                                var props = attachments.props.toJSON(),
-                                        attrs = _.pick( props, 'include', 'exclude', 'orderby', 'order' ),
-                                        shortcode, clone;
-
-                                if ( attachments.gallery )
-                                        _.extend( attrs, attachments.gallery.toJSON() );
-
-                                attrs.ids = attachments.pluck('id');
-
-                                // If the `ids` attribute is set and `orderby` attribute
-                                // is the default value, clear it for cleaner output.
-                                if ( attrs.ids &amp;&amp; 'post__in' === attrs.orderby )
-                                        delete attrs.orderby;
-
-                                // Remove default attributes from the shortcode.
-                                _.each( wp.media.gallery.defaults, function( value, key ) {
-                                        if ( value === attrs[ key ] )
-                                                delete attrs[ key ];
-                                });
-
-                                shortcode = new wp.shortcode({
-                                        tag:    'gallery',
-                                        attrs:  attrs,
-                                        type:   'single'
-                                });
-
-                                // Use a cloned version of the gallery.
-                                clone = new wp.media.model.Attachments( attachments.models, {
-                                        props: props
-                                });
-                                clone.gallery = attachments.gallery;
-                                galleries[ shortcode.string() ] = clone;
-
-                                return shortcode;
-                        },
-
-                        edit: function( content ) {
-                                var shortcode = wp.shortcode.next( 'gallery', content ),
-                                        defaultPostId = wp.media.gallery.defaults.id,
-                                        attachments, selection;
-
-                                // Bail if we didn't match the shortcode or all of the content.
-                                if ( ! shortcode || shortcode.content !== content )
-                                        return;
-
-                                // Ignore the rest of the match object.
-                                shortcode = shortcode.shortcode;
-
-                                if ( _.isUndefined( shortcode.get('id') ) &amp;&amp; ! _.isUndefined( defaultPostId ) )
-                                        shortcode.set( 'id', defaultPostId );
-
-                                attachments = wp.media.gallery.attachments( shortcode );
-
-                                selection = new wp.media.model.Selection( attachments.models, {
-                                        props:    attachments.props.toJSON(),
-                                        multiple: true
-                                });
-
-                                selection.gallery = attachments.gallery;
-
-                                // Fetch the query's attachments, and then break ties from the
-                                // query to allow for sorting.
-                                selection.more().done( function() {
-                                        // Break ties with the query.
-                                        selection.props.set({ query: false });
-                                        selection.unmirror();
-                                        selection.props.unset('orderby');
-                                });
-
-                                return wp.media({
-                                        frame:     'post',
-                                        state:     'gallery-edit',
-                                        title:     wp.media.view.l10n.editGalleryTitle,
-                                        editing:   true,
-                                        multiple:  true,
-                                        selection: selection
-                                });
-                        }
-                };
-        }());
-
-        wp.media.editor = {
-                insert: send_to_editor,
-
-                add: function( id, options ) {
-                        var workflow = this.get( id );
-
-                        if ( workflow )
-                                return workflow;
-
-                        workflow = workflows[ id ] = wp.media( _.defaults( options || {}, {
-                                frame:    'post',
-                                title:    wp.media.view.l10n.insertMedia,
-                                multiple: true
-                        } ) );
-
-                        workflow.on( 'insert', function( selection ) {
-                                var state = workflow.state(),
-                                        details = state.get('details');
-
-                                selection = selection || state.get('selection');
-
-                                if ( ! selection || ! details )
-                                        return;
-
-                                selection.each( function( attachment ) {
-                                        var detail = details[ attachment.cid ];
-
-                                        if ( detail )
-                                                detail = detail.toJSON();
-
-                                        // Reset the attachment details.
-                                        delete details[ attachment.cid ];
-
-                                        attachment = attachment.toJSON();
-
-                                        this.send.attachment( detail, attachment );
-                                }, this );
-                        }, this );
-
-                        workflow.get('gallery-edit').on( 'update', function( selection ) {
-                                this.insert( wp.media.gallery.shortcode( selection ).string() );
-                        }, this );
-
-                        workflow.get('embed').on( 'select', function() {
-                                var embed = workflow.state().toJSON();
-
-                                embed.url = embed.url || '';
-
-                                if ( 'link' === embed.type ) {
-                                        _.defaults( embed, {
-                                                title:   embed.url,
-                                                linkUrl: embed.url
-                                        });
-
-                                        this.send.link( embed );
-
-                                } else if ( 'image' === embed.type ) {
-                                        _.defaults( embed, {
-                                                title:   embed.url,
-                                                linkUrl: '',
-                                                align:   'none',
-                                                link:    'none'
-                                        });
-
-                                        if ( 'none' === embed.link )
-                                                embed.linkUrl = '';
-                                        else if ( 'file' === embed.link )
-                                                embed.linkUrl = embed.url;
-
-                                        this.insert( wp.media.string.image( embed ) );
-                                }
-                        }, this );
-
-                        return workflow;
-                },
-
-                get: function( id ) {
-                        return workflows[ id ];
-                },
-
-                remove: function( id ) {
-                        delete workflows[ id ];
-                },
-
-                send: {
-                        attachment: function( props, attachment ) {
-                                var caption = attachment.caption,
-                                        options, html;
-
-                                // If captions are disabled, clear the caption.
-                                if ( ! wp.media.view.settings.captions )
-                                        delete attachment.caption;
-
-                                props = wp.media.string.props( props, attachment );
-
-                                options = {
-                                        id: attachment.id
-                                };
-
-                                if ( 'image' === attachment.type ) {
-                                        html = wp.media.string.image( props );
-                                        options['caption'] = caption;
-
-                                        _.each({
-                                                align:   'image-align',
-                                                size:    'image-size',
-                                                alt:     'image-alt',
-                                                linkUrl: 'url'
-                                        }, function( option, prop ) {
-                                                if ( props[ prop ] )
-                                                        options[ option ] = props[ prop ];
-                                        });
-
-                                } else {
-                                        html = wp.media.string.link( props );
-                                        options.title = props.title;
-                                }
-
-                                return media.post( 'send-attachment-to-editor', {
-                                        nonce:      wp.media.view.settings.nonce.sendToEditor,
-                                        attachment: options,
-                                        html:       html
-                                }).done( function( resp ) {
-                                        wp.media.editor.insert( resp );
-                                });
-                        },
-
-                        link: function( embed ) {
-                                return media.post( 'send-link-to-editor', {
-                                        nonce: wp.media.view.settings.nonce.sendToEditor,
-                                        src:   embed.linkUrl,
-                                        title: embed.title,
-                                        html:  wp.media.string.link( embed )
-                                }).done( function( resp ) {
-                                        wp.media.editor.insert( resp );
-                                });
-                        }
-                },
-
-                init: function() {
-                        $(document.body).on('click', '.insert-media', function( event ) {
-                                var $this = $(this),
-                                        editor = $this.data('editor'),
-                                        workflow;
-
-                                event.preventDefault();
-
-                                // Remove focus from the `.insert-media` button.
-                                // Prevents Opera from showing the outline of the button
-                                // above the modal.
-                                //
-                                // 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.init );
-}(jQuery));
</del><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpincludesjsmediaeditorjsfromrev22768trunkwpadminjsmediauploadjs"></a>
<div class="copfile"><h4>Copied: trunk/wp-includes/js/media-editor.js (from rev 22768, trunk/wp-admin/js/media-upload.js) (0 => 22770)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/media-editor.js                                (rev 0)
+++ trunk/wp-includes/js/media-editor.js        2012-11-21 16:46:32 UTC (rev 22770)
</span><span class="lines">@@ -0,0 +1,563 @@
</span><ins>+// send html to the post editor
+
+var wpActiveEditor;
+
+function send_to_editor(h) {
+        var ed, mce = typeof(tinymce) != 'undefined', qt = typeof(QTags) != 'undefined';
+
+        if ( !wpActiveEditor ) {
+                if ( mce &amp;&amp; tinymce.activeEditor ) {
+                        ed = tinymce.activeEditor;
+                        wpActiveEditor = ed.id;
+                } else if ( !qt ) {
+                        return false;
+                }
+        } else if ( mce ) {
+                if ( tinymce.activeEditor &amp;&amp; (tinymce.activeEditor.id == 'mce_fullscreen' || tinymce.activeEditor.id == 'wp_mce_fullscreen') )
+                        ed = tinymce.activeEditor;
+                else
+                        ed = tinymce.get(wpActiveEditor);
+        }
+
+        if ( ed &amp;&amp; !ed.isHidden() ) {
+                // restore caret position on IE
+                if ( tinymce.isIE &amp;&amp; ed.windowManager.insertimagebookmark )
+                        ed.selection.moveToBookmark(ed.windowManager.insertimagebookmark);
+
+                if ( h.indexOf('[caption') === 0 ) {
+                        if ( ed.wpSetImgCaption )
+                                h = ed.wpSetImgCaption(h);
+                } else if ( h.indexOf('[gallery') === 0 ) {
+                        if ( ed.plugins.wpgallery )
+                                h = ed.plugins.wpgallery._do_gallery(h);
+                } else if ( h.indexOf('[embed') === 0 ) {
+                        if ( ed.plugins.wordpress )
+                                h = ed.plugins.wordpress._setEmbed(h);
+                }
+
+                ed.execCommand('mceInsertContent', false, h);
+        } else if ( qt ) {
+                QTags.insertContent(h);
+        } else {
+                document.getElementById(wpActiveEditor).value += h;
+        }
+
+        try{tb_remove();}catch(e){};
+}
+
+// thickbox settings
+var tb_position;
+(function($) {
+        tb_position = function() {
+                var tbWindow = $('#TB_window'), width = $(window).width(), H = $(window).height(), W = ( 720 &lt; width ) ? 720 : width, adminbar_height = 0;
+
+                if ( $('body.admin-bar').length )
+                        adminbar_height = 28;
+
+                if ( tbWindow.size() ) {
+                        tbWindow.width( W - 50 ).height( H - 45 - adminbar_height );
+                        $('#TB_iframeContent').width( W - 50 ).height( H - 75 - adminbar_height );
+                        tbWindow.css({'margin-left': '-' + parseInt((( W - 50 ) / 2),10) + 'px'});
+                        if ( typeof document.body.style.maxWidth != 'undefined' )
+                                tbWindow.css({'top': 20 + adminbar_height + 'px','margin-top':'0'});
+                };
+
+                return $('a.thickbox').each( function() {
+                        var href = $(this).attr('href');
+                        if ( ! href ) return;
+                        href = href.replace(/&amp;width=[0-9]+/g, '');
+                        href = href.replace(/&amp;height=[0-9]+/g, '');
+                        $(this).attr( 'href', href + '&amp;width=' + ( W - 80 ) + '&amp;height=' + ( H - 85 - adminbar_height ) );
+                });
+        };
+
+        $(window).resize(function(){ tb_position(); });
+
+        // store caret position in IE
+        $(document).ready(function($){
+                $('a.thickbox').click(function(){
+                        var ed;
+
+                        if ( typeof(tinymce) != 'undefined' &amp;&amp; tinymce.isIE &amp;&amp; ( ed = tinymce.get(wpActiveEditor) ) &amp;&amp; !ed.isHidden() ) {
+                                ed.focus();
+                                ed.windowManager.insertimagebookmark = ed.selection.getBookmark();
+                        }
+                });
+        });
+
+})(jQuery);
+
+// WordPress, TinyMCE, and Media
+// -----------------------------
+(function($){
+        // Stores the editors' `wp.media.controller.Frame` instances.
+        var workflows = {},
+                linkToUrl;
+
+        linkToUrl = function( props, attachment ) {
+                var link = props.link || getUserSetting( 'urlbutton', 'post' ),
+                        url;
+
+                if ( 'file' === link )
+                        url = attachment.url;
+                else if ( 'post' === link )
+                        url = attachment.link;
+                else if ( 'custom' === link )
+                        url = props.linkUrl;
+
+                return url || '';
+        };
+
+        wp.media.string = {
+                // Joins the `props` and `attachment` objects,
+                // outputting the proper object format based on the
+                // attachment's type.
+                props: function( props, attachment ) {
+                        var link, linkUrl, size, sizes;
+
+                        props = props ? _.clone( props ) : {};
+
+                        if ( attachment &amp;&amp; attachment.type )
+                                props.type = attachment.type;
+
+                        if ( 'image' === props.type ) {
+                                props = _.defaults( props || {}, {
+                                        align:   getUserSetting( 'align', 'none' ),
+                                        size:    getUserSetting( 'imgsize', 'medium' ),
+                                        url:     '',
+                                        classes: []
+                                });
+                        }
+
+                        // All attachment-specific settings follow.
+                        if ( ! attachment )
+                                return props;
+
+                        link = props.link || getUserSetting( 'urlbutton', 'post' );
+                        if ( 'file' === link )
+                                linkUrl = attachment.url;
+                        else if ( 'post' === link )
+                                linkUrl = attachment.link;
+                        else if ( 'custom' === link )
+                                linkUrl = props.linkUrl;
+                        props.linkUrl = linkUrl || '';
+
+                        // Format properties for images.
+                        if ( 'image' === attachment.type ) {
+                                props.classes.push( 'wp-image-' + attachment.id );
+
+                                sizes = attachment.sizes;
+                                size = sizes &amp;&amp; sizes[ props.size ] ? sizes[ props.size ] : attachment;
+
+                                _.extend( props, _.pick( attachment, 'align', 'caption' ), {
+                                        width:     size.width,
+                                        height:    size.height,
+                                        src:       size.url,
+                                        captionId: 'attachment_' + attachment.id
+                                });
+
+                        // Format properties for non-images.
+                        } else {
+                                _.extend( props, {
+                                        title:   attachment.title || attachment.filename,
+                                        rel:     'attachment wp-att-' + attachment.id
+                                });
+                        }
+
+                        return props;
+                },
+
+                link: function( props, attachment ) {
+                        var options;
+
+                        props = wp.media.string.props( props, attachment );
+
+                        options = {
+                                tag:     'a',
+                                content: props.title,
+                                attrs:   {
+                                        href: props.linkUrl
+                                }
+                        };
+
+                        if ( props.rel )
+                                options.attrs.rel = props.rel;
+
+                        return wp.html.string( options );
+                },
+
+                image: function( props, attachment ) {
+                        var img = {},
+                                options, classes, shortcode, html;
+
+                        props = wp.media.string.props( props, attachment );
+                        classes = props.classes || [];
+
+                        img.src = props.url;
+                        _.extend( img, _.pick( props, 'width', 'height', 'alt' ) );
+
+                        // Only assign the align class to the image if we're not printing
+                        // a caption, since the alignment is sent to the shortcode.
+                        if ( props.align &amp;&amp; ! props.caption )
+                                classes.push( 'align' + props.align );
+
+                        if ( props.size )
+                                classes.push( 'size-' + props.size );
+
+                        img['class'] = _.compact( classes ).join(' ');
+
+                        // Generate `img` tag options.
+                        options = {
+                                tag:    'img',
+                                attrs:  img,
+                                single: true
+                        };
+
+                        // Generate the `a` element options, if they exist.
+                        if ( props.linkUrl ) {
+                                options = {
+                                        tag:   'a',
+                                        attrs: {
+                                                href: props.linkUrl
+                                        },
+                                        content: options
+                                };
+                        }
+
+                        html = wp.html.string( options );
+
+                        // Generate the caption shortcode.
+                        if ( props.caption ) {
+                                shortcode = {};
+
+                                if ( img.width )
+                                        shortcode.width = img.width;
+
+                                if ( props.captionId )
+                                        shortcode.id = props.captionId;
+
+                                if ( props.align )
+                                        shortcode.align = 'align' + props.align;
+
+                                html = wp.shortcode.string({
+                                        tag:     'caption',
+                                        attrs:   shortcode,
+                                        content: html + ' ' + props.caption
+                                });
+                        }
+
+                        return html;
+                }
+        };
+
+        wp.media.gallery = (function() {
+                var galleries = {};
+
+                return {
+                        defaults: {
+                                order:      'ASC',
+                                id:         wp.media.view.settings.postId,
+                                itemtag:    'dl',
+                                icontag:    'dt',
+                                captiontag: 'dd',
+                                columns:    3,
+                                size:       'thumbnail'
+                        },
+
+                        attachments: function( shortcode ) {
+                                var shortcodeString = shortcode.string(),
+                                        result = galleries[ shortcodeString ],
+                                        attrs, args, query, others;
+
+                                delete galleries[ shortcodeString ];
+
+                                if ( result )
+                                        return result;
+
+                                attrs = shortcode.attrs.named;
+                                args  = _.pick( attrs, 'orderby', 'order' );
+
+                                args.type    = 'image';
+                                args.perPage = -1;
+
+                                // Map the `ids` param to the correct query args.
+                                if ( attrs.ids ) {
+                                        args.post__in = attrs.ids.split(',');
+                                        args.orderby  = 'post__in';
+                                } else if ( attrs.include ) {
+                                        args.post__in = attrs.include.split(',');
+                                }
+
+                                if ( attrs.exclude )
+                                        args.post__not_in = attrs.exclude.split(',');
+
+                                if ( ! args.post__in )
+                                        args.parent = attrs.id;
+
+                                // Collect the attributes that were not included in `args`.
+                                others = {};
+                                _.filter( attrs, function( value, key ) {
+                                        if ( _.isUndefined( args[ key ] ) )
+                                                others[ key ] = value;
+                                });
+
+                                query = media.query( args );
+                                query.gallery = new Backbone.Model( others );
+                                return query;
+                        },
+
+                        shortcode: function( attachments ) {
+                                var props = attachments.props.toJSON(),
+                                        attrs = _.pick( props, 'include', 'exclude', 'orderby', 'order' ),
+                                        shortcode, clone;
+
+                                if ( attachments.gallery )
+                                        _.extend( attrs, attachments.gallery.toJSON() );
+
+                                attrs.ids = attachments.pluck('id');
+
+                                // If the `ids` attribute is set and `orderby` attribute
+                                // is the default value, clear it for cleaner output.
+                                if ( attrs.ids &amp;&amp; 'post__in' === attrs.orderby )
+                                        delete attrs.orderby;
+
+                                // Remove default attributes from the shortcode.
+                                _.each( wp.media.gallery.defaults, function( value, key ) {
+                                        if ( value === attrs[ key ] )
+                                                delete attrs[ key ];
+                                });
+
+                                shortcode = new wp.shortcode({
+                                        tag:    'gallery',
+                                        attrs:  attrs,
+                                        type:   'single'
+                                });
+
+                                // Use a cloned version of the gallery.
+                                clone = new wp.media.model.Attachments( attachments.models, {
+                                        props: props
+                                });
+                                clone.gallery = attachments.gallery;
+                                galleries[ shortcode.string() ] = clone;
+
+                                return shortcode;
+                        },
+
+                        edit: function( content ) {
+                                var shortcode = wp.shortcode.next( 'gallery', content ),
+                                        defaultPostId = wp.media.gallery.defaults.id,
+                                        attachments, selection;
+
+                                // Bail if we didn't match the shortcode or all of the content.
+                                if ( ! shortcode || shortcode.content !== content )
+                                        return;
+
+                                // Ignore the rest of the match object.
+                                shortcode = shortcode.shortcode;
+
+                                if ( _.isUndefined( shortcode.get('id') ) &amp;&amp; ! _.isUndefined( defaultPostId ) )
+                                        shortcode.set( 'id', defaultPostId );
+
+                                attachments = wp.media.gallery.attachments( shortcode );
+
+                                selection = new wp.media.model.Selection( attachments.models, {
+                                        props:    attachments.props.toJSON(),
+                                        multiple: true
+                                });
+
+                                selection.gallery = attachments.gallery;
+
+                                // Fetch the query's attachments, and then break ties from the
+                                // query to allow for sorting.
+                                selection.more().done( function() {
+                                        // Break ties with the query.
+                                        selection.props.set({ query: false });
+                                        selection.unmirror();
+                                        selection.props.unset('orderby');
+                                });
+
+                                return wp.media({
+                                        frame:     'post',
+                                        state:     'gallery-edit',
+                                        title:     wp.media.view.l10n.editGalleryTitle,
+                                        editing:   true,
+                                        multiple:  true,
+                                        selection: selection
+                                });
+                        }
+                };
+        }());
+
+        wp.media.editor = {
+                insert: send_to_editor,
+
+                add: function( id, options ) {
+                        var workflow = this.get( id );
+
+                        if ( workflow )
+                                return workflow;
+
+                        workflow = workflows[ id ] = wp.media( _.defaults( options || {}, {
+                                frame:    'post',
+                                title:    wp.media.view.l10n.insertMedia,
+                                multiple: true
+                        } ) );
+
+                        workflow.on( 'insert', function( selection ) {
+                                var state = workflow.state(),
+                                        details = state.get('details');
+
+                                selection = selection || state.get('selection');
+
+                                if ( ! selection || ! details )
+                                        return;
+
+                                selection.each( function( attachment ) {
+                                        var detail = details[ attachment.cid ];
+
+                                        if ( detail )
+                                                detail = detail.toJSON();
+
+                                        // Reset the attachment details.
+                                        delete details[ attachment.cid ];
+
+                                        attachment = attachment.toJSON();
+
+                                        this.send.attachment( detail, attachment );
+                                }, this );
+                        }, this );
+
+                        workflow.get('gallery-edit').on( 'update', function( selection ) {
+                                this.insert( wp.media.gallery.shortcode( selection ).string() );
+                        }, this );
+
+                        workflow.get('embed').on( 'select', function() {
+                                var embed = workflow.state().toJSON();
+
+                                embed.url = embed.url || '';
+
+                                if ( 'link' === embed.type ) {
+                                        _.defaults( embed, {
+                                                title:   embed.url,
+                                                linkUrl: embed.url
+                                        });
+
+                                        this.send.link( embed );
+
+                                } else if ( 'image' === embed.type ) {
+                                        _.defaults( embed, {
+                                                title:   embed.url,
+                                                linkUrl: '',
+                                                align:   'none',
+                                                link:    'none'
+                                        });
+
+                                        if ( 'none' === embed.link )
+                                                embed.linkUrl = '';
+                                        else if ( 'file' === embed.link )
+                                                embed.linkUrl = embed.url;
+
+                                        this.insert( wp.media.string.image( embed ) );
+                                }
+                        }, this );
+
+                        return workflow;
+                },
+
+                get: function( id ) {
+                        return workflows[ id ];
+                },
+
+                remove: function( id ) {
+                        delete workflows[ id ];
+                },
+
+                send: {
+                        attachment: function( props, attachment ) {
+                                var caption = attachment.caption,
+                                        options, html;
+
+                                // If captions are disabled, clear the caption.
+                                if ( ! wp.media.view.settings.captions )
+                                        delete attachment.caption;
+
+                                props = wp.media.string.props( props, attachment );
+
+                                options = {
+                                        id: attachment.id
+                                };
+
+                                if ( 'image' === attachment.type ) {
+                                        html = wp.media.string.image( props );
+                                        options['caption'] = caption;
+
+                                        _.each({
+                                                align:   'image-align',
+                                                size:    'image-size',
+                                                alt:     'image-alt',
+                                                linkUrl: 'url'
+                                        }, function( option, prop ) {
+                                                if ( props[ prop ] )
+                                                        options[ option ] = props[ prop ];
+                                        });
+
+                                } else {
+                                        html = wp.media.string.link( props );
+                                        options.title = props.title;
+                                }
+
+                                return media.post( 'send-attachment-to-editor', {
+                                        nonce:      wp.media.view.settings.nonce.sendToEditor,
+                                        attachment: options,
+                                        html:       html
+                                }).done( function( resp ) {
+                                        wp.media.editor.insert( resp );
+                                });
+                        },
+
+                        link: function( embed ) {
+                                return media.post( 'send-link-to-editor', {
+                                        nonce: wp.media.view.settings.nonce.sendToEditor,
+                                        src:   embed.linkUrl,
+                                        title: embed.title,
+                                        html:  wp.media.string.link( embed )
+                                }).done( function( resp ) {
+                                        wp.media.editor.insert( resp );
+                                });
+                        }
+                },
+
+                init: function() {
+                        $(document.body).on('click', '.insert-media', function( event ) {
+                                var $this = $(this),
+                                        editor = $this.data('editor'),
+                                        workflow;
+
+                                event.preventDefault();
+
+                                // Remove focus from the `.insert-media` button.
+                                // Prevents Opera from showing the outline of the button
+                                // above the modal.
+                                //
+                                // 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.init );
+}(jQuery));
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpincludesjsmediaeditorminjsfromrev22768trunkwpadminjsmediauploadminjs"></a>
<div class="copfile"><h4>Copied: trunk/wp-includes/js/media-editor.min.js (from rev 22768, trunk/wp-admin/js/media-upload.min.js) (0 => 22770)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/media-editor.min.js                                (rev 0)
+++ trunk/wp-includes/js/media-editor.min.js        2012-11-21 16:46:32 UTC (rev 22770)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+var wpActiveEditor;function send_to_editor(c){var b,a=typeof(tinymce)!=&quot;undefined&quot;,f=typeof(QTags)!=&quot;undefined&quot;;if(!wpActiveEditor){if(a&amp;&amp;tinymce.activeEditor){b=tinymce.activeEditor;wpActiveEditor=b.id}else{if(!f){return false}}}else{if(a){if(tinymce.activeEditor&amp;&amp;(tinymce.activeEditor.id==&quot;mce_fullscreen&quot;||tinymce.activeEditor.id==&quot;wp_mce_fullscreen&quot;)){b=tinymce.activeEditor}else{b=tinymce.get(wpActiveEditor)}}}if(b&amp;&amp;!b.isHidden()){if(tinymce.isIE&amp;&amp;b.windowManager.insertimagebookmark){b.selection.moveToBookmark(b.windowManager.insertimagebookmark)}if(c.indexOf(&quot;[caption&quot;)===0){if(b.wpSetImgCaption){c=b.wpSetImgCaption(c)}}else{if(c.indexOf(&quot;[gallery&quot;)===0){if(b.plugins.wpgallery){c=b.plugins.wpgallery._do_gallery(c)}}else{if(c.indexOf(&quot;[embed&quot;)===0){if(b.plugins.wordpress){c=b.plugins.wordpress._setEmbed(c)}}}}b.execCommand(&quot;mceInsertContent&quot;,false,c)
 }else{if(f){QTags.insertContent(c)}else{document.getElementById(wpActiveEditor).value+=c}}try{tb_remove()}catch(d){}}var tb_position;(function(a){tb_position=function(){var f=a(&quot;#TB_window&quot;),e=a(window).width(),d=a(window).height(),c=(720&lt;e)?720:e,b=0;if(a(&quot;body.admin-bar&quot;).length){b=28}if(f.size()){f.width(c-50).height(d-45-b);a(&quot;#TB_iframeContent&quot;).width(c-50).height(d-75-b);f.css({&quot;margin-left&quot;:&quot;-&quot;+parseInt(((c-50)/2),10)+&quot;px&quot;});if(typeof document.body.style.maxWidth!=&quot;undefined&quot;){f.css({top:20+b+&quot;px&quot;,&quot;margin-top&quot;:&quot;0&quot;})}}return a(&quot;a.thickbox&quot;).each(function(){var g=a(this).attr(&quot;href&quot;);if(!g){return}g=g.replace(/&amp;width=[0-9]+/g,&quot;&quot;);g=g.replace(/&amp;height=[0-9]+/g,&quot;&quot;);a(this).attr(&quot;href&quot;,g+&quot;&amp;width=&quot;+(c-80)+&quot;&amp;height=&quot;+(d-85-b))})};a(window).resize(function(){tb_position()});a(document).read
 y(function(b){b(&quot;a.thickbox&quot;).click(function(){var c;if(typeof(tinymce)!=&quot;undefined&quot;&amp;&amp;tinymce.isIE&amp;&amp;(c=tinymce.get(wpActiveEditor))&amp;&amp;!c.isHidden()){c.focus();c.windowManager.insertimagebookmark=c.selection.getBookmark()}})})})(jQuery);(function(b){var a={},c;c=function(e,g){var f=e.link||getUserSetting(&quot;urlbutton&quot;,&quot;post&quot;),d;if(&quot;file&quot;===f){d=g.url}else{if(&quot;post&quot;===f){d=g.link}else{if(&quot;custom&quot;===f){d=e.linkUrl}}}return d||&quot;&quot;};wp.media.string={link:function(e,f){var d;e=_.defaults(e||{},{title:&quot;&quot;,linkUrl:&quot;&quot;});if(f){_.extend(e,{title:f.title||f.filename,linkUrl:c(e,f),rel:&quot;attachment wp-att-&quot;+f.id})}d={tag:&quot;a&quot;,content:e.title,attrs:{href:e.linkUrl}};if(e.rel){d.attrs.rel=e.rel}return wp.html.string(d)},image:function(i,h){var d=[],f={},l,j,k,e,g;i=_.defaults(i||{},{align:getUserSetting(&quot;align&quot;,&quot;none&quot;),size:getUserSett
 ing(&quot;imgsize&quot;,&quot;medium&quot;),url:&quot;&quot;});if(h){d.push(&quot;wp-image-&quot;+h.id);j=h.sizes;k=j&amp;&amp;j[i.size]?j[i.size]:h;_.extend(i,_.pick(h,&quot;align&quot;,&quot;caption&quot;),{width:k.width,height:k.height,src:k.url,linkUrl:c(i,h),captionId:&quot;attachment_&quot;+h.id})}f.src=i.url;_.extend(f,_.pick(i,&quot;width&quot;,&quot;height&quot;,&quot;alt&quot;));if(i.align&amp;&amp;!i.caption){d.push(&quot;align&quot;+i.align)}if(i.size){d.push(&quot;size-&quot;+i.size)}f[&quot;class&quot;]=_.compact(d).join(&quot; &quot;);l={tag:&quot;img&quot;,attrs:f,single:true};if(i.linkUrl){l={tag:&quot;a&quot;,attrs:{href:i.linkUrl},content:l}}g=wp.html.string(l);if(i.caption){e={};if(f.width){e.width=f.width}if(i.captionId){e.id=i.captionId}if(i.align){e.align=&quot;align&quot;+i.align}g=wp.shortcode.string({tag:&quot;caption&quot;,attrs:e,content:g+&quot; &quot;+i.caption})}return g}};wp.media.gallery=(function(){var d={};return{defaults:{order:&quot;ASC&q
 uot;,id:wp.media.view.settings.postId,itemtag:&quot;dl&quot;,icontag:&quot;dt&quot;,captiontag:&quot;dd&quot;,columns:3,size:&quot;thumbnail&quot;},attachments:function(i){var k=i.string(),e=d[k],g,f,j,h;delete d[k];if(e){return e}g=i.attrs.named;f=_.pick(g,&quot;orderby&quot;,&quot;order&quot;);f.type=&quot;image&quot;;f.perPage=-1;if(g.ids){f.post__in=g.ids.split(&quot;,&quot;);f.orderby=&quot;post__in&quot;}else{if(g.include){f.post__in=g.include.split(&quot;,&quot;)}}if(g.exclude){f.post__not_in=g.exclude.split(&quot;,&quot;)}if(!f.post__in){f.parent=g.id}h={};_.filter(g,function(m,l){if(_.isUndefined(f[l])){h[l]=m}});j=media.query(f);j.gallery=new Backbone.Model(h);return j},shortcode:function(e){var g=e.props.toJSON(),f=_.pick(g,&quot;include&quot;,&quot;exclude&quot;,&quot;orderby&quot;,&quot;order&quot;),h,i;if(e.gallery){_.extend(f,e.gallery.toJSON())}f.ids=e.pluck(&quot;id&quot;);if(f.ids&amp;&amp;&quot;post__in&quot;===f.orderby){delete f.orderby}_.each(wp.media.g
 allery.defaults,function(k,j){if(k===f[j]){delete f[j]}});h=new wp.shortcode({tag:&quot;gallery&quot;,attrs:f,type:&quot;single&quot;});i=new wp.media.model.Attachments(e.models,{props:g});i.gallery=e.gallery;d[h.string()]=i;return h},edit:function(h){var g=wp.shortcode.next(&quot;gallery&quot;,h),i=wp.media.gallery.defaults.id,e,f;if(!g||g.content!==h){return}g=g.shortcode;if(_.isUndefined(g.get(&quot;id&quot;))&amp;&amp;!_.isUndefined(i)){g.set(&quot;id&quot;,i)}e=wp.media.gallery.attachments(g);f=new wp.media.model.Selection(e.models,{props:e.props.toJSON(),multiple:true});f.gallery=e.gallery;f.more().done(function(){f.props.set({query:false});f.unmirror();f.props.unset(&quot;orderby&quot;)});return wp.media({frame:&quot;post&quot;,state:&quot;gallery-edit&quot;,title:wp.media.view.l10n.editGalleryTitle,editing:true,multiple:true,selection:f})}}}());wp.media.editor={insert:send_to_editor,add:function(f,d){var e=this.get(f);if(e){return e}e=a[f]=wp.media(_.defaults(d||{},{
 frame:&quot;post&quot;,title:wp.media.view.l10n.insertMedia,multiple:true}));e.on(&quot;insert&quot;,function(h){var i=e.state(),g=i.get(&quot;details&quot;);h=h||i.get(&quot;selection&quot;);if(!h||!g){return}h.each(function(k){var j=g[k.cid];if(j){j=j.toJSON()}delete g[k.cid];k=k.toJSON();if(!wp.media.view.settings.captions){delete k.caption}if(&quot;image&quot;===k.type){this.insert(wp.media.string.image(j,k)+&quot; &quot;)}else{this.insert(wp.media.string.link(j,k)+&quot; &quot;)}},this)},this);e.get(&quot;gallery-edit&quot;).on(&quot;update&quot;,function(g){this.insert(wp.media.gallery.shortcode(g).string())},this);e.get(&quot;embed&quot;).on(&quot;select&quot;,function(){var g=e.state().toJSON();g.url=g.url||&quot;&quot;;if(&quot;link&quot;===g.type){_.defaults(g,{title:g.url,linkUrl:g.url});this.insert(wp.media.string.link(g))}else{if(&quot;image&quot;===g.type){_.defaults(g,{title:g.url,linkUrl:&quot;&quot;,align:&quot;none&quot;,link:&quot;none&quot;});if(&quot;non
 e&quot;===g.link){g.linkUrl=&quot;&quot;}else{if(&quot;file&quot;===g.link){g.linkUrl=g.url}}this.insert(wp.media.string.image(g))}}},this);return e},get:function(d){return a[d]},remove:function(d){delete a[d]},init:function(){b(document.body).on(&quot;click&quot;,&quot;.insert-media&quot;,function(e){var f=b(this),d=f.data(&quot;editor&quot;),g;e.preventDefault();f.blur();if(!_.isString(d)){return}g=wp.media.editor.get(d);if(g){g.open();return}wp.media.editor.add(d)})}};b(wp.media.editor.init)}(jQuery));
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpincludesjsmediamodelsjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/media-models.js (22769 => 22770)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/media-models.js        2012-11-21 16:34:57 UTC (rev 22769)
+++ trunk/wp-includes/js/media-models.js        2012-11-21 16:46:32 UTC (rev 22770)
</span><span class="lines">@@ -41,6 +41,10 @@
</span><span class="cx">         // Link any localized strings.
</span><span class="cx">         l10n = media.model.l10n = typeof _wpMediaModelsL10n === 'undefined' ? {} : _wpMediaModelsL10n;
</span><span class="cx"> 
</span><ins>+        // Link any settings.
+        media.model.settings = l10n.settings || {};
+        delete l10n.settings;
+
</ins><span class="cx">         /**
</span><span class="cx">          * ========================================================================
</span><span class="cx">          * UTILITIES
</span><span class="lines">@@ -124,7 +128,7 @@
</span><span class="cx"> 
</span><span class="cx">                         options = _.defaults( options || {}, {
</span><span class="cx">                                 type:    'POST',
</span><del>-                                url:     ajaxurl,
</del><ins>+                                url:     media.model.settings.ajaxurl,
</ins><span class="cx">                                 context: this
</span><span class="cx">                         });
</span><span class="cx"> 
</span><span class="lines">@@ -221,7 +225,7 @@
</span><span class="cx">                                 options.data = _.extend( options.data || {}, {
</span><span class="cx">                                         action: 'save-attachment',
</span><span class="cx">                                         id:     this.id,
</span><del>-                                        nonce:  l10n.saveAttachmentNonce
</del><ins>+                                        nonce:  media.model.settings.saveAttachmentNonce
</ins><span class="cx">                                 });
</span><span class="cx"> 
</span><span class="cx">                                 // Record the values of the changed attributes.
</span></span></pre></div>
<a id="trunkwpincludesmediaphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/media.php (22769 => 22770)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/media.php        2012-11-21 16:34:57 UTC (rev 22769)
+++ trunk/wp-includes/media.php        2012-11-21 16:46:32 UTC (rev 22770)
</span><span class="lines">@@ -1387,7 +1387,7 @@
</span><span class="cx"> 
</span><span class="cx">         wp_localize_script( 'media-views', '_wpMediaViewsL10n', $strings );
</span><span class="cx"> 
</span><del>-        wp_enqueue_script( 'media-upload' );
</del><ins>+        wp_enqueue_script( 'media-editor' );
</ins><span class="cx">         wp_enqueue_style( 'media-views' );
</span><span class="cx">         wp_plupload_default_settings();
</span><span class="cx">         add_action( 'admin_footer', 'wp_print_media_templates' );
</span></span></pre></div>
<a id="trunkwpincludesscriptloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/script-loader.php (22769 => 22770)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/script-loader.php        2012-11-21 16:34:57 UTC (rev 22769)
+++ trunk/wp-includes/script-loader.php        2012-11-21 16:46:32 UTC (rev 22770)
</span><span class="lines">@@ -298,7 +298,7 @@
</span><span class="cx">                 'type' =&gt; 'characters' == _x( 'words', 'word count: words or characters?' ) ? 'c' : 'w',
</span><span class="cx">         ) );
</span><span class="cx"> 
</span><del>-        $scripts-&gt;add( 'media-upload', &quot;/wp-admin/js/media-upload$suffix.js&quot;, array( 'thickbox', 'shortcode', 'media-views' ), false, 1 );
</del><ins>+        $scripts-&gt;add( 'media-upload', &quot;/wp-admin/js/media-upload$suffix.js&quot;, array( 'thickbox', 'shortcode' ), false, 1 );
</ins><span class="cx"> 
</span><span class="cx">         $scripts-&gt;add( 'hoverIntent', &quot;/wp-includes/js/hoverIntent$suffix.js&quot;, array('jquery'), 'r6', 1 );
</span><span class="cx"> 
</span><span class="lines">@@ -318,13 +318,19 @@
</span><span class="cx">                 'allowedFiles' =&gt; __( 'Allowed Files' ),
</span><span class="cx">         ) );
</span><span class="cx"> 
</span><ins>+        $scripts-&gt;add( 'shortcode', &quot;/wp-includes/js/shortcode$suffix.js&quot;, array( 'underscore' ), false, 1 );
</ins><span class="cx">         $scripts-&gt;add( 'media-models', &quot;/wp-includes/js/media-models$suffix.js&quot;, array( 'backbone', 'jquery' ), false, 1 );
</span><span class="cx">         did_action( 'init' ) &amp;&amp; $scripts-&gt;localize( 'media-models', '_wpMediaModelsL10n', array(
</span><del>-                'saveAttachmentNonce' =&gt; wp_create_nonce( 'save-attachment' ),
</del><ins>+                'settings' =&gt; array(
+                        'saveAttachmentNonce' =&gt; wp_create_nonce( 'save-attachment' ),
+                        'ajaxurl' =&gt; admin_url( 'admin-ajax.php', 'relative' ),
+                ),
</ins><span class="cx">         ) );
</span><span class="cx"> 
</span><ins>+        // To enqueue media-views or media-editor, call wp_enqueue_media().
+        // Both rely on numerous settings, styles, and templates to operate correctly.
</ins><span class="cx">         $scripts-&gt;add( 'media-views',  &quot;/wp-includes/js/media-views$suffix.js&quot;,  array( 'media-models', 'wp-plupload' ), false, 1 );
</span><del>-        $scripts-&gt;add( 'shortcode', &quot;/wp-includes/js/shortcode$suffix.js&quot;, array( 'underscore' ), false, 1 );
</del><ins>+        $scripts-&gt;add( 'media-editor', &quot;/wp-includes/js/media-editor$suffix.js&quot;, array( 'shortcode', 'media-views' ), false, 1 );
</ins><span class="cx">         $scripts-&gt;add( 'mce-view', &quot;/wp-includes/js/mce-view$suffix.js&quot;, array( 'shortcode', 'media-models' ), false, 1 );
</span><span class="cx"> 
</span><span class="cx">         if ( is_admin() ) {
</span></span></pre>
</div>
</div>

</body>
</html>