<!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>[22995] trunk/wp-includes: Compress scripts/styles: 3.5-RC2-22995.</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/22995">22995</a></dd>
<dt>Author</dt> <dd>bumpbot</dd>
<dt>Date</dt> <dd>2012-12-03 08:09:10 +0000 (Mon, 03 Dec 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Compress scripts/styles: 3.5-RC2-22995.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludesjsmediaeditorminjs">trunk/wp-includes/js/media-editor.min.js</a></li>
<li><a href="#trunkwpincludesjsmediamodelsminjs">trunk/wp-includes/js/media-models.min.js</a></li>
<li><a href="#trunkwpincludesjsmediaviewsminjs">trunk/wp-includes/js/media-views.min.js</a></li>
<li><a href="#trunkwpincludesjspluploadwppluploadminjs">trunk/wp-includes/js/plupload/wp-plupload.min.js</a></li>
<li><a href="#trunkwpincludesversionphp">trunk/wp-includes/version.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludesjsmediaeditorminjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/media-editor.min.js (22994 => 22995)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/media-editor.min.js        2012-12-03 07:17:10 UTC (rev 22994)
+++ trunk/wp-includes/js/media-editor.min.js        2012-12-03 08:09:10 UTC (rev 22995)
</span><span class="lines">@@ -1 +1 @@
</span><del>-(function(b){var a={};wp.media.string={props:function(f,i){var h,c,e,g,d;d=function(j){if(&quot;image&quot;===j.type&amp;&amp;!j.alt){j.alt=j.caption||j.title||&quot;&quot;;j.alt=j.alt.replace(/&lt;\/?[^&gt;]+&gt;/g,&quot;&quot;)}return j};f=f?_.clone(f):{};if(i&amp;&amp;i.type){f.type=i.type}if(&quot;image&quot;===f.type){f=_.defaults(f||{},{align:getUserSetting(&quot;align&quot;,&quot;none&quot;),size:getUserSetting(&quot;imgsize&quot;,&quot;medium&quot;),url:&quot;&quot;,classes:[]})}if(!i){return d(f)}f.title=f.title||i.title;h=f.link||getUserSetting(&quot;urlbutton&quot;,&quot;post&quot;);if(&quot;file&quot;===h){c=i.url}else{if(&quot;post&quot;===h){c=i.link}else{if(&quot;custom&quot;===h){c=f.linkUrl}}}f.linkUrl=c||&quot;&quot;;if(&quot;image&quot;===i.type){f.classes.push(&quot;wp-image-&quot;+i.id);g=i.sizes;e=g&amp;&amp;g[f.size]?g[f.size]:i;_.extend(f,_.pick(i,&quot;align&quot;,&quot;caption&quot;,&quot;alt&quot;),{width:e.width,height:e.height,src:e.u
 rl,captionId:&quot;attachment_&quot;+i.id})}else{f.title=f.title||i.filename;f.rel=f.rel||&quot;attachment wp-att-&quot;+i.id}return d(f)},link:function(d,e){var c;d=wp.media.string.props(d,e);c={tag:&quot;a&quot;,content:d.title,attrs:{href:d.linkUrl}};if(d.rel){c.attrs.rel=d.rel}return wp.html.string(c)},image:function(g,i){var c={},d,f,h,e;g=wp.media.string.props(g,i);f=g.classes||[];c.src=g.url;_.extend(c,_.pick(g,&quot;width&quot;,&quot;height&quot;,&quot;alt&quot;));if(g.align&amp;&amp;!g.caption){f.push(&quot;align&quot;+g.align)}if(g.size){f.push(&quot;size-&quot;+g.size)}c[&quot;class&quot;]=_.compact(f).join(&quot; &quot;);d={tag:&quot;img&quot;,attrs:c,single:true};if(g.linkUrl){d={tag:&quot;a&quot;,attrs:{href:g.linkUrl},content:d}}e=wp.html.string(d);if(g.caption){h={};if(c.width){h.width=c.width}if(g.captionId){h.id=g.captionId}if(g.align){h.align=&quot;align&quot;+g.align}e=wp.shortcode.string({tag:&quot;caption&quot;,attrs:h,content:e+&quot; &quot;+g.caption}
 )}return e}};wp.media.gallery=(function(){var c={};return{defaults:{order:&quot;ASC&quot;,id:wp.media.view.settings.postId,itemtag:&quot;dl&quot;,icontag:&quot;dt&quot;,captiontag:&quot;dd&quot;,columns:3,size:&quot;thumbnail&quot;,orderby:&quot;menu_order ID&quot;},attachments:function(h){var j=h.string(),d=c[j],f,e,i,g;delete c[j];if(d){return d}f=_.defaults(h.attrs.named,wp.media.gallery.defaults);e=_.pick(f,&quot;orderby&quot;,&quot;order&quot;);e.type=&quot;image&quot;;e.perPage=-1;if(&quot;rand&quot;===f.orderby){f._orderbyRandom=true}if(!f.orderby||/^menu_order(?: ID)?$/i.test(f.orderby)){e.orderby=&quot;menuOrder&quot;}if(f.ids){e.post__in=f.ids.split(&quot;,&quot;);e.orderby=&quot;post__in&quot;}else{if(f.include){e.post__in=f.include.split(&quot;,&quot;)}}if(f.exclude){e.post__not_in=f.exclude.split(&quot;,&quot;)}if(!e.post__in){e.uploadedTo=f.id}g=_.omit(f,&quot;id&quot;,&quot;ids&quot;,&quot;include&quot;,&quot;exclude&quot;,&quot;orderby&quot;,&quot;order&quot;
 );i=wp.media.query(e);i.gallery=new Backbone.Model(g);return i},shortcode:function(d){var f=d.props.toJSON(),e=_.pick(f,&quot;orderby&quot;,&quot;order&quot;),g,h;if(d.gallery){_.extend(e,d.gallery.toJSON())}e.ids=d.pluck(&quot;id&quot;);if(f.uploadedTo){e.id=f.uploadedTo}if(e._orderbyRandom){e.orderby=&quot;rand&quot;}delete e._orderbyRandom;if(e.ids&amp;&amp;&quot;post__in&quot;===e.orderby){delete e.orderby}_.each(wp.media.gallery.defaults,function(j,i){if(j===e[i]){delete e[i]}});g=new wp.shortcode({tag:&quot;gallery&quot;,attrs:e,type:&quot;single&quot;});h=new wp.media.model.Attachments(d.models,{props:f});h.gallery=d.gallery;c[g.string()]=h;return g},edit:function(g){var f=wp.shortcode.next(&quot;gallery&quot;,g),h=wp.media.gallery.defaults.id,d,e;if(!f||f.content!==g){return}f=f.shortcode;if(_.isUndefined(f.get(&quot;id&quot;))&amp;&amp;!_.isUndefined(h)){f.set(&quot;id&quot;,h)}d=wp.media.gallery.attachments(f);e=new wp.media.model.Selection(d.models,{props:d.props.
 toJSON(),multiple:true});e.gallery=d.gallery;e.more().done(function(){e.props.set({query:false});e.unmirror();e.props.unset(&quot;orderby&quot;)});if(this.frame){this.frame.dispose()}this.frame=wp.media({frame:&quot;post&quot;,state:&quot;gallery-edit&quot;,title:wp.media.view.l10n.editGalleryTitle,editing:true,multiple:true,selection:e}).open();return this.frame}}}());wp.media.editor={insert:function(g){var d=typeof(tinymce)!=&quot;undefined&quot;,j=typeof(QTags)!=&quot;undefined&quot;,c=window.wpActiveEditor,f;if(window.send_to_editor){return window.send_to_editor.apply(this,arguments)}if(!c){if(d&amp;&amp;tinymce.activeEditor){f=tinymce.activeEditor;c=window.wpActiveEditor=f.id}else{if(!j){return false}}}else{if(d){if(tinymce.activeEditor&amp;&amp;(tinymce.activeEditor.id==&quot;mce_fullscreen&quot;||tinymce.activeEditor.id==&quot;wp_mce_fullscreen&quot;)){f=tinymce.activeEditor}else{f=tinymce.get(c)}}}if(f&amp;&amp;!f.isHidden()){if(tinymce.isIE&amp;&amp;f.windowManager.
 insertimagebookmark){f.selection.moveToBookmark(f.windowManager.insertimagebookmark)}if(g.indexOf(&quot;[caption&quot;)===0){if(f.wpSetImgCaption){g=f.wpSetImgCaption(g)}}else{if(g.indexOf(&quot;[gallery&quot;)===0){if(f.plugins.wpgallery){g=f.plugins.wpgallery._do_gallery(g)}}else{if(g.indexOf(&quot;[embed&quot;)===0){if(f.plugins.wordpress){g=f.plugins.wordpress._setEmbed(g)}}}}f.execCommand(&quot;mceInsertContent&quot;,false,g)}else{if(j){QTags.insertContent(g)}else{document.getElementById(c).value+=g}}if(window.tb_remove){try{window.tb_remove()}catch(i){}}},add:function(e,c){var d=this.get(e);if(d){return d}d=a[e]=wp.media(_.defaults(c||{},{frame:&quot;post&quot;,state:&quot;upload&quot;,title:wp.media.view.l10n.addMedia,multiple:true}));d.on(&quot;insert&quot;,function(f){var g=d.state();f=f||g.get(&quot;selection&quot;);if(!f){return}f.each(function(i){var h=g.display(i).toJSON();this.send.attachment(h,i.toJSON())},this)},this);d.state(&quot;gallery-edit&quot;).on(&quo
 t;update&quot;,function(f){this.insert(wp.media.gallery.shortcode(f).string())},this);d.state(&quot;embed&quot;).on(&quot;select&quot;,function(){var f=d.state().toJSON();f.url=f.url||&quot;&quot;;if(&quot;link&quot;===f.type){_.defaults(f,{title:f.url,linkUrl:f.url});this.send.link(f)}else{if(&quot;image&quot;===f.type){_.defaults(f,{title:f.url,linkUrl:&quot;&quot;,align:&quot;none&quot;,link:&quot;none&quot;});if(&quot;none&quot;===f.link){f.linkUrl=&quot;&quot;}else{if(&quot;file&quot;===f.link){f.linkUrl=f.url}}this.insert(wp.media.string.image(f))}}},this);d.state(&quot;featured-image&quot;).on(&quot;select&quot;,function(){var h=wp.media.view.settings,f=h.featuredImage,g=this.get(&quot;selection&quot;).single();if(!f){return}f.id=g?g.id:-1;wp.media.post(&quot;set-post-thumbnail&quot;,{json:true,post_id:h.postId,thumbnail_id:f.id,_wpnonce:f.nonce}).done(function(i){b(&quot;.inside&quot;,&quot;#postimagediv&quot;).html(i)})});d.setState(d.options.state);return d},id:fun
 ction(c){if(c){return c}c=wpActiveEditor;if(!c&amp;&amp;typeof tinymce!==&quot;undefined&quot;&amp;&amp;tinymce.activeEditor){c=tinymce.activeEditor.id}c=c||&quot;&quot;;return c},get:function(c){c=this.id(c);return a[c]},remove:function(c){c=this.id(c);delete a[c]},send:{attachment:function(f,g){var c=g.caption,d,e;if(!wp.media.view.settings.captions){delete g.caption}f=wp.media.string.props(f,g);d={id:g.id};if(f.linkUrl){d.url=f.linkUrl}if(&quot;image&quot;===g.type){e=wp.media.string.image(f);d.post_excerpt=c;_.each({align:&quot;align&quot;,size:&quot;image-size&quot;,alt:&quot;image_alt&quot;},function(h,i){if(f[i]){d[h]=f[i]}})}else{e=wp.media.string.link(f);d.post_title=f.title}return wp.media.post(&quot;send-attachment-to-editor&quot;,{nonce:wp.media.view.settings.nonce.sendToEditor,attachment:d,html:e,post_id:wp.media.view.settings.postId}).done(function(h){wp.media.editor.insert(h)})},link:function(c){return wp.media.post(&quot;send-link-to-editor&quot;,{nonce:wp.me
 dia.view.settings.nonce.sendToEditor,src:c.linkUrl,title:c.title,html:wp.media.string.link(c),post_id:wp.media.view.settings.postId}).done(function(d){wp.media.editor.insert(d)})}},open:function(e){var d,c;e=this.id(e);if(typeof tinymce!==&quot;undefined&quot;){c=tinymce.get(e);if(tinymce.isIE&amp;&amp;c&amp;&amp;!c.isHidden()){c.focus();c.windowManager.insertimagebookmark=c.selection.getBookmark()}}d=this.get(e);if(!d){d=this.add(e)}return d.open()},init:function(){b(document.body).on(&quot;click&quot;,&quot;.insert-media&quot;,function(d){var e=b(this),c=e.data(&quot;editor&quot;);d.preventDefault();e.blur();wp.media.editor.open(c)});b(&quot;#postimagediv&quot;).on(&quot;click&quot;,&quot;#set-post-thumbnail&quot;,function(e){e.preventDefault();e.stopPropagation();var f=wp.media.editor.add(&quot;content&quot;),c=f.state().id,d;d=function(){this.off(&quot;escape&quot;,d);if(&quot;featured-image&quot;===this.state().id){this.setState(c)}};f.on(&quot;escape&quot;,d,f);f.setSt
 ate(&quot;featured-image&quot;).open()}).on(&quot;click&quot;,&quot;#remove-post-thumbnail&quot;,function(){wp.media.view.settings.featuredImage.id=-1})}};_.bindAll(wp.media.editor,&quot;open&quot;);b(wp.media.editor.init)}(jQuery));
</del><span class="cx">\ No newline at end of file
</span><ins>+(function(b){var a={};wp.media.string={props:function(f,i){var h,c,e,g,d;d=function(j){if(&quot;image&quot;===j.type&amp;&amp;!j.alt){j.alt=j.caption||j.title||&quot;&quot;;j.alt=j.alt.replace(/&lt;\/?[^&gt;]+&gt;/g,&quot;&quot;)}return j};f=f?_.clone(f):{};if(i&amp;&amp;i.type){f.type=i.type}if(&quot;image&quot;===f.type){f=_.defaults(f||{},{align:getUserSetting(&quot;align&quot;,&quot;none&quot;),size:getUserSetting(&quot;imgsize&quot;,&quot;medium&quot;),url:&quot;&quot;,classes:[]})}if(!i){return d(f)}f.title=f.title||i.title;h=f.link||getUserSetting(&quot;urlbutton&quot;,&quot;post&quot;);if(&quot;file&quot;===h){c=i.url}else{if(&quot;post&quot;===h){c=i.link}else{if(&quot;custom&quot;===h){c=f.linkUrl}}}f.linkUrl=c||&quot;&quot;;if(&quot;image&quot;===i.type){f.classes.push(&quot;wp-image-&quot;+i.id);g=i.sizes;e=g&amp;&amp;g[f.size]?g[f.size]:i;_.extend(f,_.pick(i,&quot;align&quot;,&quot;caption&quot;,&quot;alt&quot;),{width:e.width,height:e.height,src:e.u
 rl,captionId:&quot;attachment_&quot;+i.id})}else{f.title=f.title||i.filename;f.rel=f.rel||&quot;attachment wp-att-&quot;+i.id}return d(f)},link:function(d,e){var c;d=wp.media.string.props(d,e);c={tag:&quot;a&quot;,content:d.title,attrs:{href:d.linkUrl}};if(d.rel){c.attrs.rel=d.rel}return wp.html.string(c)},image:function(g,i){var c={},d,f,h,e;g=wp.media.string.props(g,i);f=g.classes||[];c.src=g.url;_.extend(c,_.pick(g,&quot;width&quot;,&quot;height&quot;,&quot;alt&quot;));if(g.align&amp;&amp;!g.caption){f.push(&quot;align&quot;+g.align)}if(g.size){f.push(&quot;size-&quot;+g.size)}c[&quot;class&quot;]=_.compact(f).join(&quot; &quot;);d={tag:&quot;img&quot;,attrs:c,single:true};if(g.linkUrl){d={tag:&quot;a&quot;,attrs:{href:g.linkUrl},content:d}}e=wp.html.string(d);if(g.caption){h={};if(c.width){h.width=c.width}if(g.captionId){h.id=g.captionId}if(g.align){h.align=&quot;align&quot;+g.align}e=wp.shortcode.string({tag:&quot;caption&quot;,attrs:h,content:e+&quot; &quot;+g.caption}
 )}return e}};wp.media.gallery=(function(){var c={};return{defaults:{order:&quot;ASC&quot;,id:wp.media.view.settings.post.id,itemtag:&quot;dl&quot;,icontag:&quot;dt&quot;,captiontag:&quot;dd&quot;,columns:3,size:&quot;thumbnail&quot;,orderby:&quot;menu_order ID&quot;},attachments:function(h){var j=h.string(),d=c[j],f,e,i,g;delete c[j];if(d){return d}f=_.defaults(h.attrs.named,wp.media.gallery.defaults);e=_.pick(f,&quot;orderby&quot;,&quot;order&quot;);e.type=&quot;image&quot;;e.perPage=-1;if(&quot;rand&quot;===f.orderby){f._orderbyRandom=true}if(!f.orderby||/^menu_order(?: ID)?$/i.test(f.orderby)){e.orderby=&quot;menuOrder&quot;}if(f.ids){e.post__in=f.ids.split(&quot;,&quot;);e.orderby=&quot;post__in&quot;}else{if(f.include){e.post__in=f.include.split(&quot;,&quot;)}}if(f.exclude){e.post__not_in=f.exclude.split(&quot;,&quot;)}if(!e.post__in){e.uploadedTo=f.id}g=_.omit(f,&quot;id&quot;,&quot;ids&quot;,&quot;include&quot;,&quot;exclude&quot;,&quot;orderby&quot;,&quot;order&quot
 ;);i=wp.media.query(e);i.gallery=new Backbone.Model(g);return i},shortcode:function(d){var f=d.props.toJSON(),e=_.pick(f,&quot;orderby&quot;,&quot;order&quot;),g,h;if(d.gallery){_.extend(e,d.gallery.toJSON())}e.ids=d.pluck(&quot;id&quot;);if(f.uploadedTo){e.id=f.uploadedTo}if(e._orderbyRandom){e.orderby=&quot;rand&quot;}delete e._orderbyRandom;if(e.ids&amp;&amp;&quot;post__in&quot;===e.orderby){delete e.orderby}_.each(wp.media.gallery.defaults,function(j,i){if(j===e[i]){delete e[i]}});g=new wp.shortcode({tag:&quot;gallery&quot;,attrs:e,type:&quot;single&quot;});h=new wp.media.model.Attachments(d.models,{props:f});h.gallery=d.gallery;c[g.string()]=h;return g},edit:function(g){var f=wp.shortcode.next(&quot;gallery&quot;,g),h=wp.media.gallery.defaults.id,d,e;if(!f||f.content!==g){return}f=f.shortcode;if(_.isUndefined(f.get(&quot;id&quot;))&amp;&amp;!_.isUndefined(h)){f.set(&quot;id&quot;,h)}d=wp.media.gallery.attachments(f);e=new wp.media.model.Selection(d.models,{props:d.props
 .toJSON(),multiple:true});e.gallery=d.gallery;e.more().done(function(){e.props.set({query:false});e.unmirror();e.props.unset(&quot;orderby&quot;)});if(this.frame){this.frame.dispose()}this.frame=wp.media({frame:&quot;post&quot;,state:&quot;gallery-edit&quot;,title:wp.media.view.l10n.editGalleryTitle,editing:true,multiple:true,selection:e}).open();return this.frame}}}());wp.media.editor={insert:function(g){var d=typeof(tinymce)!=&quot;undefined&quot;,j=typeof(QTags)!=&quot;undefined&quot;,c=window.wpActiveEditor,f;if(window.send_to_editor){return window.send_to_editor.apply(this,arguments)}if(!c){if(d&amp;&amp;tinymce.activeEditor){f=tinymce.activeEditor;c=window.wpActiveEditor=f.id}else{if(!j){return false}}}else{if(d){if(tinymce.activeEditor&amp;&amp;(tinymce.activeEditor.id==&quot;mce_fullscreen&quot;||tinymce.activeEditor.id==&quot;wp_mce_fullscreen&quot;)){f=tinymce.activeEditor}else{f=tinymce.get(c)}}}if(f&amp;&amp;!f.isHidden()){if(tinymce.isIE&amp;&amp;f.windowManager
 .insertimagebookmark){f.selection.moveToBookmark(f.windowManager.insertimagebookmark)}if(g.indexOf(&quot;[caption&quot;)===0){if(f.wpSetImgCaption){g=f.wpSetImgCaption(g)}}else{if(g.indexOf(&quot;[gallery&quot;)===0){if(f.plugins.wpgallery){g=f.plugins.wpgallery._do_gallery(g)}}else{if(g.indexOf(&quot;[embed&quot;)===0){if(f.plugins.wordpress){g=f.plugins.wordpress._setEmbed(g)}}}}f.execCommand(&quot;mceInsertContent&quot;,false,g)}else{if(j){QTags.insertContent(g)}else{document.getElementById(c).value+=g}}if(window.tb_remove){try{window.tb_remove()}catch(i){}}},add:function(e,c){var d=this.get(e);if(d){return d}d=a[e]=wp.media(_.defaults(c||{},{frame:&quot;post&quot;,state:&quot;upload&quot;,title:wp.media.view.l10n.addMedia,multiple:true}));d.on(&quot;insert&quot;,function(f){var g=d.state();f=f||g.get(&quot;selection&quot;);if(!f){return}f.each(function(i){var h=g.display(i).toJSON();this.send.attachment(h,i.toJSON())},this)},this);d.state(&quot;gallery-edit&quot;).on(&qu
 ot;update&quot;,function(f){this.insert(wp.media.gallery.shortcode(f).string())},this);d.state(&quot;embed&quot;).on(&quot;select&quot;,function(){var f=d.state().toJSON();f.url=f.url||&quot;&quot;;if(&quot;link&quot;===f.type){_.defaults(f,{title:f.url,linkUrl:f.url});this.send.link(f)}else{if(&quot;image&quot;===f.type){_.defaults(f,{title:f.url,linkUrl:&quot;&quot;,align:&quot;none&quot;,link:&quot;none&quot;});if(&quot;none&quot;===f.link){f.linkUrl=&quot;&quot;}else{if(&quot;file&quot;===f.link){f.linkUrl=f.url}}this.insert(wp.media.string.image(f))}}},this);d.state(&quot;featured-image&quot;).on(&quot;select&quot;,function(){var g=wp.media.view.settings,f=this.get(&quot;selection&quot;).single();if(!g.post.featuredImageId){return}g.post.featuredImageId=f?f.id:-1;wp.media.post(&quot;set-post-thumbnail&quot;,{json:true,post_id:g.post.id,thumbnail_id:g.post.featuredImageId,_wpnonce:g.post.nonce}).done(function(h){b(&quot;.inside&quot;,&quot;#postimagediv&quot;).html(h)})}
 );d.setState(d.options.state);return d},id:function(c){if(c){return c}c=wpActiveEditor;if(!c&amp;&amp;typeof tinymce!==&quot;undefined&quot;&amp;&amp;tinymce.activeEditor){c=tinymce.activeEditor.id}c=c||&quot;&quot;;return c},get:function(c){c=this.id(c);return a[c]},remove:function(c){c=this.id(c);delete a[c]},send:{attachment:function(f,g){var c=g.caption,d,e;if(!wp.media.view.settings.captions){delete g.caption}f=wp.media.string.props(f,g);d={id:g.id};if(f.linkUrl){d.url=f.linkUrl}if(&quot;image&quot;===g.type){e=wp.media.string.image(f);d.post_excerpt=c;_.each({align:&quot;align&quot;,size:&quot;image-size&quot;,alt:&quot;image_alt&quot;},function(h,i){if(f[i]){d[h]=f[i]}})}else{e=wp.media.string.link(f);d.post_title=f.title}return wp.media.post(&quot;send-attachment-to-editor&quot;,{nonce:wp.media.view.settings.nonce.sendToEditor,attachment:d,html:e,post_id:wp.media.view.settings.post.id}).done(function(h){wp.media.editor.insert(h)})},link:function(c){return wp.media.po
 st(&quot;send-link-to-editor&quot;,{nonce:wp.media.view.settings.nonce.sendToEditor,src:c.linkUrl,title:c.title,html:wp.media.string.link(c),post_id:wp.media.view.settings.post.id}).done(function(d){wp.media.editor.insert(d)})}},open:function(e){var d,c;e=this.id(e);if(typeof tinymce!==&quot;undefined&quot;){c=tinymce.get(e);if(tinymce.isIE&amp;&amp;c&amp;&amp;!c.isHidden()){c.focus();c.windowManager.insertimagebookmark=c.selection.getBookmark()}}d=this.get(e);if(!d){d=this.add(e)}return d.open()},init:function(){b(document.body).on(&quot;click&quot;,&quot;.insert-media&quot;,function(d){var e=b(this),c=e.data(&quot;editor&quot;);d.preventDefault();e.blur();wp.media.editor.open(c)});b(&quot;#postimagediv&quot;).on(&quot;click&quot;,&quot;#set-post-thumbnail&quot;,function(e){e.preventDefault();e.stopPropagation();var f=wp.media.editor.add(&quot;content&quot;),c=f.state().id,d;d=function(){this.off(&quot;escape&quot;,d);if(&quot;featured-image&quot;===this.state().id){this.se
 tState(c)}};f.on(&quot;escape&quot;,d,f);f.setState(&quot;featured-image&quot;).open()}).on(&quot;click&quot;,&quot;#remove-post-thumbnail&quot;,function(){wp.media.view.settings.post.featuredImageId=-1})}};_.bindAll(wp.media.editor,&quot;open&quot;);b(wp.media.editor.init)}(jQuery));
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpincludesjsmediamodelsminjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/media-models.min.js (22994 => 22995)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/media-models.min.js        2012-12-03 07:17:10 UTC (rev 22994)
+++ trunk/wp-includes/js/media-models.min.js        2012-12-03 08:09:10 UTC (rev 22995)
</span><span class="lines">@@ -1 +1 @@
</span><del>-window.wp=window.wp||{};(function(f){var d,c,a,e,b,g;g=wp.media=function(h){var i=g.view.MediaFrame,j;if(!i){return}h=_.defaults(h||{},{frame:&quot;select&quot;});if(&quot;select&quot;===h.frame&amp;&amp;i.Select){j=new i.Select(h)}else{if(&quot;post&quot;===h.frame&amp;&amp;i.Post){j=new i.Post(h)}}delete h.frame;return j};_.extend(g,{model:{},view:{},controller:{}});b=g.model.l10n=typeof _wpMediaModelsL10n===&quot;undefined&quot;?{}:_wpMediaModelsL10n;g.model.settings=b.settings||{};delete b.settings;e=function(i,h,j,k){if(_.isEqual(i,h)){return j===k?0:(j&gt;k?-1:1)}else{return i&gt;h?-1:1}};_.extend(g,{template:_.memoize(function(j){var i,h={evaluate:/&lt;#([\s\S]+?)#&gt;/g,interpolate:/\{\{\{([\s\S]+?)\}\}\}/g,escape:/\{\{([^\}]+?)\}\}(?!\})/g,variable:&quot;data&quot;};return function(k){i=i||_.template(f(&quot;#tmpl-&quot;+j).html(),null,h);return i(k)}}),post:function(i,h){return g.ajax({data:_.isObject(i)?i:_.extend(h||{},{action:i})})},ajax:function(i,h
 ){if(_.isObject(i)){h=i}else{h=h||{};h.data=_.extend(h.data||{},{action:i})}h=_.defaults(h||{},{type:&quot;POST&quot;,url:g.model.settings.ajaxurl,context:this});return f.Deferred(function(j){if(h.success){j.done(h.success)}if(h.error){j.fail(h.error)}delete h.success;delete h.error;f.ajax(h).done(function(k){if(_.isObject(k)&amp;&amp;!_.isUndefined(k.success)){j[k.success?&quot;resolveWith&quot;:&quot;rejectWith&quot;](this,[k.data])}else{j.rejectWith(this,[k])}}).fail(function(){j.rejectWith(this,arguments)})}).promise()},fit:function(l){var i=l.width,h=l.height,k=l.maxWidth,j=l.maxHeight,m;if(!_.isUndefined(k)&amp;&amp;!_.isUndefined(j)){m=(i/h&gt;k/j)?&quot;width&quot;:&quot;height&quot;}else{if(_.isUndefined(j)){m=&quot;width&quot;}else{if(_.isUndefined(k)&amp;&amp;h&gt;j){m=&quot;height&quot;}}}if(&quot;width&quot;===m&amp;&amp;i&gt;k){return{width:k,height:Math.round(k*h/i)}}else{if(&quot;height&quot;===m&amp;&amp;h&gt;j){return{width:Math.round(j*i/h),height:j}}else{
 return{width:i,height:h}}}},truncate:function(h,j,i){j=j||30;i=i||&quot;&amp;hellip;&quot;;if(h.length&lt;=j){return h}return h.substr(0,j/2)+i+h.substr(-1*j/2)}});d=g.model.Attachment=Backbone.Model.extend({sync:function(j,i,h){if(_.isUndefined(this.id)){return f.Deferred().reject().promise()}if(&quot;read&quot;===j){h=h||{};h.context=this;h.data=_.extend(h.data||{},{action:&quot;get-attachment&quot;,id:this.id});return g.ajax(h)}else{if(&quot;update&quot;===j){if(!this.get(&quot;nonces&quot;)){return f.Deferred().resolveWith(this).promise()}h=h||{};h.context=this;h.data=_.extend(h.data||{},{action:&quot;save-attachment&quot;,id:this.id,nonce:this.get(&quot;nonces&quot;).update,post_id:g.model.settings.postId});if(h.changes){_.each(h.changes,function(l,k){h.changes[k]=this.get(k)},this);h.data.changes=h.changes;delete h.changes}return g.ajax(h)}else{if(&quot;delete&quot;===j){h=h||{};h.context=this;h.data=_.extend(h.data||{},{action:&quot;delete-post&quot;,id:this.id,_wpnon
 ce:this.get(&quot;nonces&quot;)[&quot;delete&quot;]});return g.ajax(h)}}}},parse:function(i,h){if(!i){return i}i.date=new Date(i.date);i.modified=new Date(i.modified);return i},saveCompat:function(j,i){var h=this;return g.post(&quot;save-attachment-compat&quot;,_.defaults({id:this.id,nonce:this.get(&quot;nonces&quot;).update,post_id:g.model.settings.postId},j)).done(function(m,k,l){h.set(h.parse(m,l),i)})}},{create:function(h){return c.all.push(h)},get:_.memoize(function(i,h){return c.all.push(h||{id:i})})});c=g.model.Attachments=Backbone.Collection.extend({model:d,initialize:function(i,h){h=h||{};this.props=new Backbone.Model();this.filters=h.filters||{};this.props.on(&quot;change&quot;,this._changeFilteredProps,this);this.props.on(&quot;change:order&quot;,this._changeOrder,this);this.props.on(&quot;change:orderby&quot;,this._changeOrderby,this);this.props.on(&quot;change:query&quot;,this._changeQuery,this);this.props.set(_.defaults(h.props||{}));if(h.observe){this.observe(
 h.observe)}},_changeOrder:function(i,h){if(this.comparator){this.sort()}},_changeOrderby:function(h,i){if(this.comparator&amp;&amp;this.comparator!==c.comparator){return}if(i&amp;&amp;&quot;post__in&quot;!==i){this.comparator=c.comparator}else{delete this.comparator}},_changeQuery:function(h,i){if(i){this.props.on(&quot;change&quot;,this._requery,this);this._requery()}else{this.props.off(&quot;change&quot;,this._requery,this)}},_changeFilteredProps:function(i,h){if(this.props.get(&quot;query&quot;)){return}var j=_.chain(h.changes).map(function(l,n){var m=c.filters[n],k=i.get(n);if(!m){return}if(k&amp;&amp;!this.filters[n]){this.filters[n]=m}else{if(!k&amp;&amp;this.filters[n]===m){delete this.filters[n]}else{return}}return true},this).any().value();if(!j){return}if(!this._source){this._source=new c(this.models)}this.reset(this._source.filter(this.validator,this))},validator:function(h){return _.all(this.filters,function(j,i){return !!j.call(this,h)},this)},validate:function(
 k,i){var j=this.validator(k),h=!!this.getByCid(k.cid);if(!j&amp;&amp;h){this.remove(k,i)}else{if(j&amp;&amp;!h){this.add(k,i)}}return this},validateAll:function(h,i){i=i||{};_.each(h.models,function(j){this.validate(j,{silent:true})},this);if(!i.silent){this.trigger(&quot;reset&quot;,this,i)}return this},observe:function(h){this.observers=this.observers||[];this.observers.push(h);h.on(&quot;add change remove&quot;,this._validateHandler,this);h.on(&quot;reset&quot;,this._validateAllHandler,this);this.validateAll(h);return this},unobserve:function(h){if(h){h.off(null,null,this);this.observers=_.without(this.observers,h)}else{_.each(this.observers,function(i){i.off(null,null,this)},this);delete this.observers}return this},_validateHandler:function(j,h,i){i=h===this.mirroring?i:{silent:i&amp;&amp;i.silent};return this.validate(j,i)},_validateAllHandler:function(h,i){return this.validateAll(h,i)},mirror:function(h){if(this.mirroring&amp;&amp;this.mirroring===h){return this}this.u
 nmirror();this.mirroring=h;this.reset([],{silent:true});this.observe(h);return this},unmirror:function(){if(!this.mirroring){return}this.unobserve(this.mirroring);delete this.mirroring},more:function(j){var i=f.Deferred(),k=this.mirroring,h=this;if(!k||!k.more){return i.resolveWith(this).promise()}k.more(j).done(function(){if(this===h.mirroring){i.resolveWith(this)}});return i.promise()},hasMore:function(){return this.mirroring?this.mirroring.hasMore():false},parse:function(i,h){return _.map(i,function(j){var k=d.get(j.id);return k.set(k.parse(j,h))})},_requery:function(){if(this.props.get(&quot;query&quot;)){this.mirror(a.get(this.props.toJSON()))}},saveMenuOrder:function(){if(&quot;menuOrder&quot;!==this.props.get(&quot;orderby&quot;)){return}var h=this.chain().filter(function(i){return !_.isUndefined(i.id)}).map(function(j,i){i=i+1;j.set(&quot;menuOrder&quot;,i);return[j.id,i]}).object().value();if(_.isEmpty(h)){return}return g.post(&quot;save-attachment-order&quot;,{nonc
 e:g.model.settings.updatePostNonce,post_id:g.model.settings.postId,attachments:h})}},{comparator:function(j,i,k){var l=this.props.get(&quot;orderby&quot;),h=this.props.get(&quot;order&quot;)||&quot;DESC&quot;,m=j.cid,n=i.cid;j=j.get(l);i=i.get(l);if(&quot;date&quot;===l||&quot;modified&quot;===l){j=j||new Date();i=i||new Date()}if(k&amp;&amp;k.ties){m=n=null}return(&quot;DESC&quot;===h)?e(j,i,m,n):e(i,j,n,m)},filters:{search:function(h){if(!this.props.get(&quot;search&quot;)){return true}return _.any([&quot;title&quot;,&quot;filename&quot;,&quot;description&quot;,&quot;caption&quot;,&quot;name&quot;],function(i){var j=h.get(i);return j&amp;&amp;-1!==j.search(this.props.get(&quot;search&quot;))},this)},type:function(i){var h=this.props.get(&quot;type&quot;);return !h||-1!==h.indexOf(i.get(&quot;type&quot;))},uploadedTo:function(i){var h=this.props.get(&quot;uploadedTo&quot;);if(_.isUndefined(h)){return true}return h===i.get(&quot;uploadedTo&quot;)}}});c.all=new c();g.query=fu
 nction(h){return new c(null,{props:_.extend(_.defaults(h||{},{orderby:&quot;date&quot;}),{query:true})})};a=g.model.Query=c.extend({initialize:function(j,h){var i;h=h||{};c.prototype.initialize.apply(this,arguments);this.args=h.args;this._hasMore=true;this.created=new Date();this.filters.order=function(m){var l=this.props.get(&quot;orderby&quot;),k=this.props.get(&quot;order&quot;);if(!this.comparator){return true}if(this.length){return 1!==this.comparator(m,this.last(),{ties:true})}else{if(&quot;DESC&quot;===k&amp;&amp;(&quot;date&quot;===l||&quot;modified&quot;===l)){return m.get(l)&gt;=this.created}else{if(&quot;ASC&quot;===k&amp;&amp;&quot;menuOrder&quot;===l){return m.get(l)===0}}}return false};i=[&quot;s&quot;,&quot;order&quot;,&quot;orderby&quot;,&quot;posts_per_page&quot;,&quot;post_mime_type&quot;,&quot;post_parent&quot;];if(wp.Uploader&amp;&amp;_(this.args).chain().keys().difference(i).isEmpty().value()){this.observe(wp.Uploader.queue)}},hasMore:function(){return t
 his._hasMore},more:function(h){var i=this;if(this._more&amp;&amp;&quot;pending&quot;===this._more.state()){return this._more}if(!this.hasMore()){return f.Deferred().resolveWith(this).promise()}h=h||{};h.add=true;return this._more=this.fetch(h).done(function(j){if(_.isEmpty(j)||-1===this.args.posts_per_page||j.length&lt;this.args.posts_per_page){i._hasMore=false}})},sync:function(k,i,h){var j;if(&quot;read&quot;===k){h=h||{};h.context=this;h.data=_.extend(h.data||{},{action:&quot;query-attachments&quot;,post_id:g.model.settings.postId});args=_.clone(this.args);if(-1!==args.posts_per_page){args.paged=Math.floor(this.length/args.posts_per_page)+1}h.data.query=args;return g.ajax(h)}else{j=c.prototype.sync?c.prototype:Backbone;return j.sync.apply(this,arguments)}}},{defaultProps:{orderby:&quot;date&quot;,order:&quot;DESC&quot;},defaultArgs:{posts_per_page:40},orderby:{allowed:[&quot;name&quot;,&quot;author&quot;,&quot;date&quot;,&quot;title&quot;,&quot;modified&quot;,&quot;upload
 edTo&quot;,&quot;id&quot;,&quot;post__in&quot;,&quot;menuOrder&quot;],valuemap:{id:&quot;ID&quot;,uploadedTo:&quot;parent&quot;,menuOrder:&quot;menu_order ID&quot;}},propmap:{search:&quot;s&quot;,type:&quot;post_mime_type&quot;,perPage:&quot;posts_per_page&quot;,menuOrder:&quot;menu_order&quot;,uploadedTo:&quot;post_parent&quot;},get:(function(){var h=[];return function(k,j){var i={},m=a.orderby,n=a.defaultProps,l;delete k.query;_.defaults(k,n);k.order=k.order.toUpperCase();if(&quot;DESC&quot;!==k.order&amp;&amp;&quot;ASC&quot;!==k.order){k.order=n.order.toUpperCase()}if(!_.contains(m.allowed,k.orderby)){k.orderby=n.orderby}_.each(k,function(o,p){if(_.isNull(o)){return}i[a.propmap[p]||p]=o});_.defaults(i,a.defaultArgs);i.orderby=m.valuemap[k.orderby]||k.orderby;l=_.find(h,function(o){return _.isEqual(o.args,i)});if(!l){l=new a([],_.extend(j||{},{props:k,args:i}));h.push(l)}return l}}())});g.model.Selection=c.extend({initialize:function(i,h){c.prototype.initialize.apply(this,
 arguments);this.multiple=h&amp;&amp;h.multiple;this.on(&quot;add remove reset&quot;,_.bind(this.single,this,false))},add:function(i,h){if(!this.multiple){this.remove(this.models)}return c.prototype.add.call(this,i,h)},single:function(h){var i=this._single;if(h){this._single=h}if(this._single&amp;&amp;!this.getByCid(this._single.cid)){delete this._single}this._single=this._single||this.last();if(this._single!==i){if(i){i.trigger(&quot;selection:unsingle&quot;,i,this)}if(this._single){this._single.trigger(&quot;selection:single&quot;,this._single,this)}}return this._single}});f(window).on(&quot;unload&quot;,function(){window.wp=null})}(jQuery));
</del><span class="cx">\ No newline at end of file
</span><ins>+window.wp=window.wp||{};(function(f){var d,c,a,e,b,g;g=wp.media=function(h){var i=g.view.MediaFrame,j;if(!i){return}h=_.defaults(h||{},{frame:&quot;select&quot;});if(&quot;select&quot;===h.frame&amp;&amp;i.Select){j=new i.Select(h)}else{if(&quot;post&quot;===h.frame&amp;&amp;i.Post){j=new i.Post(h)}}delete h.frame;return j};_.extend(g,{model:{},view:{},controller:{}});b=g.model.l10n=typeof _wpMediaModelsL10n===&quot;undefined&quot;?{}:_wpMediaModelsL10n;g.model.settings=b.settings||{};delete b.settings;e=function(i,h,j,k){if(_.isEqual(i,h)){return j===k?0:(j&gt;k?-1:1)}else{return i&gt;h?-1:1}};_.extend(g,{template:_.memoize(function(j){var i,h={evaluate:/&lt;#([\s\S]+?)#&gt;/g,interpolate:/\{\{\{([\s\S]+?)\}\}\}/g,escape:/\{\{([^\}]+?)\}\}(?!\})/g,variable:&quot;data&quot;};return function(k){i=i||_.template(f(&quot;#tmpl-&quot;+j).html(),null,h);return i(k)}}),post:function(i,h){return g.ajax({data:_.isObject(i)?i:_.extend(h||{},{action:i})})},ajax:function(i,h
 ){if(_.isObject(i)){h=i}else{h=h||{};h.data=_.extend(h.data||{},{action:i})}h=_.defaults(h||{},{type:&quot;POST&quot;,url:g.model.settings.ajaxurl,context:this});return f.Deferred(function(j){if(h.success){j.done(h.success)}if(h.error){j.fail(h.error)}delete h.success;delete h.error;f.ajax(h).done(function(k){if(_.isObject(k)&amp;&amp;!_.isUndefined(k.success)){j[k.success?&quot;resolveWith&quot;:&quot;rejectWith&quot;](this,[k.data])}else{j.rejectWith(this,[k])}}).fail(function(){j.rejectWith(this,arguments)})}).promise()},fit:function(l){var i=l.width,h=l.height,k=l.maxWidth,j=l.maxHeight,m;if(!_.isUndefined(k)&amp;&amp;!_.isUndefined(j)){m=(i/h&gt;k/j)?&quot;width&quot;:&quot;height&quot;}else{if(_.isUndefined(j)){m=&quot;width&quot;}else{if(_.isUndefined(k)&amp;&amp;h&gt;j){m=&quot;height&quot;}}}if(&quot;width&quot;===m&amp;&amp;i&gt;k){return{width:k,height:Math.round(k*h/i)}}else{if(&quot;height&quot;===m&amp;&amp;h&gt;j){return{width:Math.round(j*i/h),height:j}}else{
 return{width:i,height:h}}}},truncate:function(h,j,i){j=j||30;i=i||&quot;&amp;hellip;&quot;;if(h.length&lt;=j){return h}return h.substr(0,j/2)+i+h.substr(-1*j/2)}});d=g.model.Attachment=Backbone.Model.extend({sync:function(j,i,h){if(_.isUndefined(this.id)){return f.Deferred().reject().promise()}if(&quot;read&quot;===j){h=h||{};h.context=this;h.data=_.extend(h.data||{},{action:&quot;get-attachment&quot;,id:this.id});return g.ajax(h)}else{if(&quot;update&quot;===j){if(!this.get(&quot;nonces&quot;)){return f.Deferred().resolveWith(this).promise()}h=h||{};h.context=this;h.data=_.extend(h.data||{},{action:&quot;save-attachment&quot;,id:this.id,nonce:this.get(&quot;nonces&quot;).update,post_id:g.model.settings.post.id});if(h.changes){_.each(h.changes,function(l,k){h.changes[k]=this.get(k)},this);h.data.changes=h.changes;delete h.changes}return g.ajax(h)}else{if(&quot;delete&quot;===j){h=h||{};h.context=this;h.data=_.extend(h.data||{},{action:&quot;delete-post&quot;,id:this.id,_wpno
 nce:this.get(&quot;nonces&quot;)[&quot;delete&quot;]});return g.ajax(h)}}}},parse:function(i,h){if(!i){return i}i.date=new Date(i.date);i.modified=new Date(i.modified);return i},saveCompat:function(j,i){var h=this;return g.post(&quot;save-attachment-compat&quot;,_.defaults({id:this.id,nonce:this.get(&quot;nonces&quot;).update,post_id:g.model.settings.post.id},j)).done(function(m,k,l){h.set(h.parse(m,l),i)})}},{create:function(h){return c.all.push(h)},get:_.memoize(function(i,h){return c.all.push(h||{id:i})})});c=g.model.Attachments=Backbone.Collection.extend({model:d,initialize:function(i,h){h=h||{};this.props=new Backbone.Model();this.filters=h.filters||{};this.props.on(&quot;change&quot;,this._changeFilteredProps,this);this.props.on(&quot;change:order&quot;,this._changeOrder,this);this.props.on(&quot;change:orderby&quot;,this._changeOrderby,this);this.props.on(&quot;change:query&quot;,this._changeQuery,this);this.props.set(_.defaults(h.props||{}));if(h.observe){this.observ
 e(h.observe)}},_changeOrder:function(i,h){if(this.comparator){this.sort()}},_changeOrderby:function(h,i){if(this.comparator&amp;&amp;this.comparator!==c.comparator){return}if(i&amp;&amp;&quot;post__in&quot;!==i){this.comparator=c.comparator}else{delete this.comparator}},_changeQuery:function(h,i){if(i){this.props.on(&quot;change&quot;,this._requery,this);this._requery()}else{this.props.off(&quot;change&quot;,this._requery,this)}},_changeFilteredProps:function(i,h){if(this.props.get(&quot;query&quot;)){return}var j=_.chain(h.changes).map(function(l,n){var m=c.filters[n],k=i.get(n);if(!m){return}if(k&amp;&amp;!this.filters[n]){this.filters[n]=m}else{if(!k&amp;&amp;this.filters[n]===m){delete this.filters[n]}else{return}}return true},this).any().value();if(!j){return}if(!this._source){this._source=new c(this.models)}this.reset(this._source.filter(this.validator,this))},validator:function(h){return _.all(this.filters,function(j,i){return !!j.call(this,h)},this)},validate:functio
 n(k,i){var j=this.validator(k),h=!!this.getByCid(k.cid);if(!j&amp;&amp;h){this.remove(k,i)}else{if(j&amp;&amp;!h){this.add(k,i)}}return this},validateAll:function(h,i){i=i||{};_.each(h.models,function(j){this.validate(j,{silent:true})},this);if(!i.silent){this.trigger(&quot;reset&quot;,this,i)}return this},observe:function(h){this.observers=this.observers||[];this.observers.push(h);h.on(&quot;add change remove&quot;,this._validateHandler,this);h.on(&quot;reset&quot;,this._validateAllHandler,this);this.validateAll(h);return this},unobserve:function(h){if(h){h.off(null,null,this);this.observers=_.without(this.observers,h)}else{_.each(this.observers,function(i){i.off(null,null,this)},this);delete this.observers}return this},_validateHandler:function(j,h,i){i=h===this.mirroring?i:{silent:i&amp;&amp;i.silent};return this.validate(j,i)},_validateAllHandler:function(h,i){return this.validateAll(h,i)},mirror:function(h){if(this.mirroring&amp;&amp;this.mirroring===h){return this}this
 .unmirror();this.mirroring=h;this.reset([],{silent:true});this.observe(h);return this},unmirror:function(){if(!this.mirroring){return}this.unobserve(this.mirroring);delete this.mirroring},more:function(j){var i=f.Deferred(),k=this.mirroring,h=this;if(!k||!k.more){return i.resolveWith(this).promise()}k.more(j).done(function(){if(this===h.mirroring){i.resolveWith(this)}});return i.promise()},hasMore:function(){return this.mirroring?this.mirroring.hasMore():false},parse:function(i,h){return _.map(i,function(j){var k=d.get(j.id);return k.set(k.parse(j,h))})},_requery:function(){if(this.props.get(&quot;query&quot;)){this.mirror(a.get(this.props.toJSON()))}},saveMenuOrder:function(){if(&quot;menuOrder&quot;!==this.props.get(&quot;orderby&quot;)){return}var h=this.chain().filter(function(i){return !_.isUndefined(i.id)}).map(function(j,i){i=i+1;j.set(&quot;menuOrder&quot;,i);return[j.id,i]}).object().value();if(_.isEmpty(h)){return}return g.post(&quot;save-attachment-order&quot;,{no
 nce:g.model.settings.post.nonce,post_id:g.model.settings.post.id,attachments:h})}},{comparator:function(j,i,k){var l=this.props.get(&quot;orderby&quot;),h=this.props.get(&quot;order&quot;)||&quot;DESC&quot;,m=j.cid,n=i.cid;j=j.get(l);i=i.get(l);if(&quot;date&quot;===l||&quot;modified&quot;===l){j=j||new Date();i=i||new Date()}if(k&amp;&amp;k.ties){m=n=null}return(&quot;DESC&quot;===h)?e(j,i,m,n):e(i,j,n,m)},filters:{search:function(h){if(!this.props.get(&quot;search&quot;)){return true}return _.any([&quot;title&quot;,&quot;filename&quot;,&quot;description&quot;,&quot;caption&quot;,&quot;name&quot;],function(i){var j=h.get(i);return j&amp;&amp;-1!==j.search(this.props.get(&quot;search&quot;))},this)},type:function(i){var h=this.props.get(&quot;type&quot;);return !h||-1!==h.indexOf(i.get(&quot;type&quot;))},uploadedTo:function(i){var h=this.props.get(&quot;uploadedTo&quot;);if(_.isUndefined(h)){return true}return h===i.get(&quot;uploadedTo&quot;)}}});c.all=new c();g.query=func
 tion(h){return new c(null,{props:_.extend(_.defaults(h||{},{orderby:&quot;date&quot;}),{query:true})})};a=g.model.Query=c.extend({initialize:function(j,h){var i;h=h||{};c.prototype.initialize.apply(this,arguments);this.args=h.args;this._hasMore=true;this.created=new Date();this.filters.order=function(m){var l=this.props.get(&quot;orderby&quot;),k=this.props.get(&quot;order&quot;);if(!this.comparator){return true}if(this.length){return 1!==this.comparator(m,this.last(),{ties:true})}else{if(&quot;DESC&quot;===k&amp;&amp;(&quot;date&quot;===l||&quot;modified&quot;===l)){return m.get(l)&gt;=this.created}else{if(&quot;ASC&quot;===k&amp;&amp;&quot;menuOrder&quot;===l){return m.get(l)===0}}}return false};i=[&quot;s&quot;,&quot;order&quot;,&quot;orderby&quot;,&quot;posts_per_page&quot;,&quot;post_mime_type&quot;,&quot;post_parent&quot;];if(wp.Uploader&amp;&amp;_(this.args).chain().keys().difference(i).isEmpty().value()){this.observe(wp.Uploader.queue)}},hasMore:function(){return thi
 s._hasMore},more:function(h){var i=this;if(this._more&amp;&amp;&quot;pending&quot;===this._more.state()){return this._more}if(!this.hasMore()){return f.Deferred().resolveWith(this).promise()}h=h||{};h.add=true;return this._more=this.fetch(h).done(function(j){if(_.isEmpty(j)||-1===this.args.posts_per_page||j.length&lt;this.args.posts_per_page){i._hasMore=false}})},sync:function(k,i,h){var j;if(&quot;read&quot;===k){h=h||{};h.context=this;h.data=_.extend(h.data||{},{action:&quot;query-attachments&quot;,post_id:g.model.settings.post.id});args=_.clone(this.args);if(-1!==args.posts_per_page){args.paged=Math.floor(this.length/args.posts_per_page)+1}h.data.query=args;return g.ajax(h)}else{j=c.prototype.sync?c.prototype:Backbone;return j.sync.apply(this,arguments)}}},{defaultProps:{orderby:&quot;date&quot;,order:&quot;DESC&quot;},defaultArgs:{posts_per_page:40},orderby:{allowed:[&quot;name&quot;,&quot;author&quot;,&quot;date&quot;,&quot;title&quot;,&quot;modified&quot;,&quot;uploade
 dTo&quot;,&quot;id&quot;,&quot;post__in&quot;,&quot;menuOrder&quot;],valuemap:{id:&quot;ID&quot;,uploadedTo:&quot;parent&quot;,menuOrder:&quot;menu_order ID&quot;}},propmap:{search:&quot;s&quot;,type:&quot;post_mime_type&quot;,perPage:&quot;posts_per_page&quot;,menuOrder:&quot;menu_order&quot;,uploadedTo:&quot;post_parent&quot;},get:(function(){var h=[];return function(k,j){var i={},m=a.orderby,n=a.defaultProps,l;delete k.query;_.defaults(k,n);k.order=k.order.toUpperCase();if(&quot;DESC&quot;!==k.order&amp;&amp;&quot;ASC&quot;!==k.order){k.order=n.order.toUpperCase()}if(!_.contains(m.allowed,k.orderby)){k.orderby=n.orderby}_.each(k,function(o,p){if(_.isNull(o)){return}i[a.propmap[p]||p]=o});_.defaults(i,a.defaultArgs);i.orderby=m.valuemap[k.orderby]||k.orderby;l=_.find(h,function(o){return _.isEqual(o.args,i)});if(!l){l=new a([],_.extend(j||{},{props:k,args:i}));h.push(l)}return l}}())});g.model.Selection=c.extend({initialize:function(i,h){c.prototype.initialize.apply(this,a
 rguments);this.multiple=h&amp;&amp;h.multiple;this.on(&quot;add remove reset&quot;,_.bind(this.single,this,false))},add:function(i,h){if(!this.multiple){this.remove(this.models)}return c.prototype.add.call(this,i,h)},single:function(h){var i=this._single;if(h){this._single=h}if(this._single&amp;&amp;!this.getByCid(this._single.cid)){delete this._single}this._single=this._single||this.last();if(this._single!==i){if(i){i.trigger(&quot;selection:unsingle&quot;,i,this)}if(this._single){this._single.trigger(&quot;selection:single&quot;,this._single,this)}}return this._single}});f(window).on(&quot;unload&quot;,function(){window.wp=null})}(jQuery));
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpincludesjsmediaviewsminjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/media-views.min.js (22994 => 22995)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/media-views.min.js        2012-12-03 07:17:10 UTC (rev 22994)
+++ trunk/wp-includes/js/media-views.min.js        2012-12-03 08:09:10 UTC (rev 22995)
</span><span class="lines">@@ -1 +1 @@
</span><del>-(function(e){var f=wp.media,d=f.model.Attachment,c=f.model.Attachments,a=f.model.Query,b;b=f.view.l10n=typeof _wpMediaViewsL10n===&quot;undefined&quot;?{}:_wpMediaViewsL10n;f.view.settings=b.settings||{};delete b.settings;f.model.settings.postId=f.view.settings.postId;f.model.settings.updatePostNonce=f.view.settings.nonce.updatePost;e.support.transition=(function(){var g=document.documentElement.style,h={WebkitTransition:&quot;webkitTransitionEnd&quot;,MozTransition:&quot;transitionend&quot;,OTransition:&quot;oTransitionEnd otransitionend&quot;,transition:&quot;transitionend&quot;},i;i=_.find(_.keys(h),function(j){return !_.isUndefined(g[j])});return i&amp;&amp;{end:h[i]}}());f.transition=function(g,h){var i=e.Deferred();h=h||2000;if(e.support.transition){if(!(g instanceof e)){g=e(g)}g.first().one(e.support.transition.end,i.resolve);_.delay(i.resolve,h)}else{i.resolve()}return i.promise()};f.controller.Region=function(g){_.extend(this,_.pick(g||{},&quot;id&quot;,
 &quot;controller&quot;,&quot;selector&quot;));this.on(&quot;activate:empty&quot;,this.empty,this);this.mode(&quot;empty&quot;)};f.controller.Region.extend=Backbone.Model.extend;_.extend(f.controller.Region.prototype,Backbone.Events,{trigger:(function(){var g=/\s+/,h=Backbone.Events.trigger;return function(i){var j=&quot;:&quot;+this._mode,k=i.split(g).join(j)+j;h.apply(this,arguments);h.apply(this,[k].concat(_.rest(arguments)));return this}}()),mode:function(g){if(g){this.trigger(&quot;deactivate&quot;,this);this._mode=g;return this.trigger(&quot;activate&quot;,this)}return this._mode},view:function(g){var h=this._view,i=this._mode,j=this.id;if(!g){return h}if(g===h){return}if(j){g.$el.addClass(&quot;region-&quot;+j)}if(i){g.$el.addClass(&quot;mode-&quot;+i)}this.controller.views.set(this.selector,g);this._view=g},empty:function(){this.view(new f.View())}});f.controller.StateMachine=function(g){this.states=new Backbone.Collection(g)};f.controller.StateMachine.extend=Backbone
 .Model.extend;_.extend(f.controller.StateMachine.prototype,Backbone.Events,{state:function(g){this.states=this.states||new Backbone.Collection();g=g||this._state;if(g&amp;&amp;!this.states.get(g)){this.states.add({id:g})}return this.states.get(g)},setState:function(h){var g=this.state();if((g&amp;&amp;h===g.id)||!this.states||!this.states.get(h)){return this}if(g){g.trigger(&quot;deactivate&quot;);this._lastState=g.id}this._state=h;this.state().trigger(&quot;activate&quot;);return this},lastState:function(){if(this._lastState){return this.state(this._lastState)}}});_.each([&quot;on&quot;,&quot;off&quot;,&quot;trigger&quot;],function(g){f.controller.StateMachine.prototype[g]=function(){this.states=this.states||new Backbone.Collection();this.states[g].apply(this.states,arguments);return this}});f.controller.State=Backbone.Model.extend({initialize:function(){this.on(&quot;activate&quot;,this._activate,this);this.on(&quot;activate&quot;,this.activate,this);this.on(&quot;deactiva
 te&quot;,this._deactivate,this);this.on(&quot;deactivate&quot;,this.deactivate,this);this.on(&quot;reset&quot;,this.reset,this)},activate:function(){},_activate:function(){this.active=true;this.menu();this.toolbar();this.content()},deactivate:function(){},_deactivate:function(){this.active=false},reset:function(){},menu:function(){var i=this.frame.menu,h=this.get(&quot;menu&quot;),g;if(!h){return}if(i.mode()!==h){i.mode(h)}g=i.view();if(g.select){g.select(this.id)}}});_.each([&quot;toolbar&quot;,&quot;content&quot;],function(g){f.controller.State.prototype[g]=function(){var h=this.get(g);if(h){this.frame[g].mode(h)}}});f.controller.Library=f.controller.State.extend({defaults:{id:&quot;library&quot;,multiple:false,describe:false,toolbar:&quot;main-attachments&quot;,sidebar:&quot;settings&quot;,content:&quot;browse&quot;,searchable:true,filterable:false,uploads:true,sortable:true},initialize:function(){if(!this.get(&quot;selection&quot;)){this.set(&quot;selection&quot;,new f.m
 odel.Selection(null,{multiple:this.get(&quot;multiple&quot;)}))}if(!this.get(&quot;library&quot;)){this.set(&quot;library&quot;,f.query())}if(!this.get(&quot;edge&quot;)){this.set(&quot;edge&quot;,120)}if(!this.get(&quot;gutter&quot;)){this.set(&quot;gutter&quot;,8)}this.resetDisplays();f.controller.State.prototype.initialize.apply(this,arguments)},activate:function(){var g=this.get(&quot;library&quot;),h=this.get(&quot;selection&quot;);this._excludeStateLibrary();this.buildComposite();this.on(&quot;change:library change:exclude&quot;,this.buildComposite,this);this.on(&quot;change:excludeState&quot;,this._excludeState,this);if(this.get(&quot;multiple&quot;)){wp.Uploader.queue.on(&quot;add&quot;,this.selectUpload,this)}h.on(&quot;add remove reset&quot;,this.refreshSelection,this);this.refresh();this.on(&quot;insert&quot;,this._insertDisplaySettings,this)},deactivate:function(){this.get(&quot;selection&quot;).off(null,null,this);wp.Uploader.queue.off(null,null,this);this.off(&
 quot;change:excludeState&quot;,this._excludeState,this);this.off(&quot;change:library change:exclude&quot;,this.buildComposite,this);this.destroyComposite()},reset:function(){this.get(&quot;selection&quot;).reset();this.resetDisplays()},refresh:function(){this.content();this.refreshSelection()},resetDisplays:function(){this._displays=[];this._defaultDisplaySettings={align:getUserSetting(&quot;align&quot;,&quot;none&quot;),size:getUserSetting(&quot;imgsize&quot;,&quot;medium&quot;),link:getUserSetting(&quot;urlbutton&quot;,&quot;post&quot;)}},display:function(h){var g=this._displays;if(!g[h.cid]){g[h.cid]=new Backbone.Model(this._defaultDisplaySettings)}return g[h.cid]},_insertDisplaySettings:function(){var g=this.get(&quot;selection&quot;),h;if(g.length!==1){return}h=this.display(g.first()).toJSON();setUserSetting(&quot;align&quot;,h.align);setUserSetting(&quot;imgsize&quot;,h.size);setUserSetting(&quot;urlbutton&quot;,h.link)},refreshSelection:function(){var g=this.get(&quo
 t;selection&quot;),h=this.frame.content.mode();this.frame.toolbar.view().refresh();this.trigger(&quot;refresh:selection&quot;,this,g);if(!g.length&amp;&amp;&quot;browse&quot;!==h&amp;&amp;&quot;upload&quot;!==h){this.content()}},selectUpload:function(g){this.get(&quot;selection&quot;).add(g)},buildComposite:function(){var h=this.get(&quot;_library&quot;),g=this.get(&quot;exclude&quot;),i;this.destroyComposite();if(!this.get(&quot;exclude&quot;)){return}if(!h){this.set(&quot;_library&quot;,h=this.get(&quot;library&quot;))}i=new f.model.Attachments(null,{props:_.pick(h.props.toJSON(),&quot;order&quot;,&quot;orderby&quot;)});i.validator=function(j){return !!h.getByCid(j.cid)&amp;&amp;!g.getByCid(j.cid)};i.mirror(h).observe(g);this.set(&quot;library&quot;,i)},destroyComposite:function(){var h=this.get(&quot;library&quot;),g=this.get(&quot;_library&quot;);if(!g){return}h.unobserve();this.set(&quot;library&quot;,g);this.unset(&quot;_library&quot;)},_excludeState:function(){var h=t
 his.get(&quot;excludeState&quot;),g=this.previous(&quot;excludeState&quot;);if(g){this.frame.state(g).off(&quot;change:library&quot;,this._excludeStateLibrary,this)}if(h){this.frame.state(h).on(&quot;change:library&quot;,this._excludeStateLibrary,this)}},_excludeStateLibrary:function(){var g=this.get(&quot;excludeState&quot;);if(!g){return}this.set(&quot;exclude&quot;,this.frame.state(g).get(&quot;library&quot;))}});f.controller.Upload=f.controller.State.extend({defaults:_.defaults({id:&quot;upload&quot;,content:&quot;upload&quot;,toolbar:&quot;empty&quot;,uploads:true,libraryState:&quot;library&quot;},f.controller.State.prototype.defaults),initialize:function(){f.controller.State.prototype.initialize.apply(this,arguments)},activate:function(){wp.Uploader.queue.on(&quot;add&quot;,this.uploading,this);f.controller.State.prototype.activate.apply(this,arguments)},deactivate:function(){wp.Uploader.queue.off(null,null,this);f.controller.State.prototype.deactivate.apply(this,argum
 ents)},uploading:function(h){var g=this.get(&quot;libraryState&quot;);this.frame.state(g).get(&quot;selection&quot;).add(h);this.frame.setState(g)}});f.controller.Gallery=f.controller.Library.extend({defaults:{id:&quot;gallery-edit&quot;,multiple:false,describe:true,edge:199,editing:false,sortable:true,searchable:false,toolbar:&quot;gallery-edit&quot;,content:&quot;browse&quot;},initialize:function(){if(!this.get(&quot;library&quot;)){this.set(&quot;library&quot;,new f.model.Selection())}if(!this.get(&quot;AttachmentView&quot;)){this.set(&quot;AttachmentView&quot;,f.view.Attachment.EditLibrary)}f.controller.Library.prototype.initialize.apply(this,arguments)},activate:function(){var g=this.get(&quot;library&quot;);g.props.set(&quot;type&quot;,&quot;image&quot;);this.get(&quot;library&quot;).observe(wp.Uploader.queue);this.frame.content.on(&quot;activate:browse&quot;,this.gallerySettings,this);f.controller.Library.prototype.activate.apply(this,arguments)},deactivate:function()
 {this.get(&quot;library&quot;).unobserve(wp.Uploader.queue);this.frame.content.off(null,null,this);f.controller.Library.prototype.deactivate.apply(this,arguments)},gallerySettings:function(){var g=this.get(&quot;library&quot;),h;if(!g){return}g.gallery=g.gallery||new Backbone.Model();h=this.frame.content.view();h.sidebar.set({gallery:new f.view.Settings.Gallery({controller:this,model:g.gallery,priority:40})});h.toolbar.set(&quot;reverse&quot;,{text:b.reverseOrder,priority:80,click:function(){g.reset(g.toArray().reverse())}})}});f.controller.FeaturedImage=f.controller.Library.extend({defaults:_.defaults({id:&quot;featured-image&quot;,filterable:&quot;uploaded&quot;,multiple:false,menu:&quot;main&quot;,toolbar:&quot;featured-image&quot;},f.controller.Library.prototype.defaults),initialize:function(){if(!this.get(&quot;library&quot;)){this.set(&quot;library&quot;,f.query({type:&quot;image&quot;}))}f.controller.Library.prototype.initialize.apply(this,arguments)},activate:functio
 n(){var g=this.get(&quot;selection&quot;),i=f.view.settings.featuredImage.id,h;if(&quot;&quot;!==i&amp;&amp;-1!==i){h=d.get(i);h.fetch()}g.reset(h?[h]:[]);f.controller.Library.prototype.activate.apply(this,arguments)}});f.controller.Embed=f.controller.State.extend({defaults:{id:&quot;embed&quot;,url:&quot;&quot;,menu:&quot;main&quot;,content:&quot;embed&quot;,toolbar:&quot;main-embed&quot;,type:&quot;link&quot;},sensitivity:200,initialize:function(){this.debouncedScan=_.debounce(_.bind(this.scan,this),this.sensitivity);this.on(&quot;change:url&quot;,this.debouncedScan,this);this.on(&quot;scan&quot;,this.scanImage,this);f.controller.State.prototype.initialize.apply(this,arguments)},scan:function(){var g={type:&quot;link&quot;};this.trigger(&quot;scan&quot;,g);this.set(g)},scanImage:function(g){var k=this.frame,i=this,h=this.get(&quot;url&quot;),j=new Image();j.onload=function(){if(i!==k.state()||h!==i.get(&quot;url&quot;)){return}i.set({type:&quot;image&quot;,width:j.width,he
 ight:j.height})};j.src=h},reset:function(){_.each(_.difference(_.keys(this.attributes),_.keys(this.defaults)),function(g){this.unset(g)},this);this.set(&quot;url&quot;,&quot;&quot;);if(this.id===this.frame.state().id){this.frame.toolbar.view().refresh()}}});f.Views=function(h,g){this.view=h;this._views=_.isArray(g)?{&quot;&quot;:g}:g||{}};f.Views.extend=Backbone.Model.extend;_.extend(f.Views.prototype,{all:function(){return _.flatten(this._views)},get:function(g){g=g||&quot;&quot;;return this._views[g]},first:function(g){var h=this.get(g);return h&amp;&amp;h.length?h[0]:null},set:function(g,h,i){var k,j;if(!_.isString(g)){i=h;h=g;g=&quot;&quot;}i=i||{};h=_.isArray(h)?h:[h];k=this.get(g);j=h;if(k){if(i.add){if(_.isUndefined(i.at)){j=k.concat(h)}else{j=k;j.splice.apply(j,[i.at,0].concat(h))}}else{_.each(j,function(l){l.__detach=true});_.each(k,function(l){if(l.__detach){l.$el.detach()}else{l.dispose()}});_.each(j,function(l){delete l.__detach})}}this._views[g]=j;_.each(h,funct
 ion(n){var l=n.Views||f.Views,m=n.views=n.views||new l(n);m.parent=this.view;m.selector=g},this);if(!i.silent){this._attach(g,h,_.extend({ready:this._isReady()},i))}return this},add:function(g,h,i){if(!_.isString(g)){i=h;h=g;g=&quot;&quot;}return this.set(g,h,_.extend({add:true},i))},unset:function(g,h,i){var j;if(!_.isString(g)){i=h;h=g;g=&quot;&quot;}h=h||[];if(j=this.get(g)){h=_.isArray(h)?h:[h];this._views[g]=h.length?_.difference(j,h):[]}if(!i||!i.silent){_.invoke(h,&quot;dispose&quot;)}return this},detach:function(){e(_.pluck(this.all(),&quot;el&quot;)).detach();return this},render:function(){var g={ready:this._isReady()};_.each(this._views,function(i,h){this._attach(h,i,g)},this);this.rendered=true;return this},dispose:function(g){if(!g||!g.silent){if(this.parent&amp;&amp;this.parent.views){this.parent.views.unset(this.selector,this.view,{silent:true})}delete this.parent;delete this.selector}_.invoke(this.all(),&quot;dispose&quot;);this._views=[];return this},replace:
 function(g,h){g.html(h);return this},insert:function(h,k,j){var g=j&amp;&amp;j.at,i;if(_.isNumber(g)&amp;&amp;(i=h.children()).length&gt;g){i.eq(g).before(k)}else{h.append(k)}return this},ready:function(){this.view.trigger(&quot;ready&quot;);_.chain(this.all()).map(function(g){return g.views}).flatten().where({attached:true}).invoke(&quot;ready&quot;)},_attach:function(g,h,i){var k=g?this.view.$(g):this.view.$el,j;if(!k.length){return this}j=_.chain(h).pluck(&quot;views&quot;).flatten().value();_.each(j,function(l){if(l.rendered){return}l.view.render();l.rendered=true},this);this[i.add?&quot;insert&quot;:&quot;replace&quot;](k,_.pluck(h,&quot;el&quot;),i);_.each(j,function(l){l.attached=true;if(i.ready){l.ready()}},this);return this},_isReady:function(){var g=this.view.el;while(g){if(g===document.body){return true}g=g.parentNode}return false}});f.View=Backbone.View.extend({Views:f.Views,constructor:function(){this.views=new this.Views(this,this.views);this.on(&quot;ready&quo
 t;,this.ready,this);Backbone.View.apply(this,arguments)},dispose:function(){this.undelegateEvents();if(this.model&amp;&amp;this.model.off){this.model.off(null,null,this)}if(this.collection&amp;&amp;this.collection.off){this.collection.off(null,null,this)}if(this.controller&amp;&amp;this.controller.off){this.controller.off(null,null,this)}if(this.views){this.views.dispose()}return this},remove:function(){this.dispose();return Backbone.View.prototype.remove.apply(this,arguments)},render:function(){var g;if(this.prepare){g=this.prepare()}this.views.detach();if(this.template){g=g||{};this.trigger(&quot;prepare&quot;,g);this.$el.html(this.template(g))}this.views.render();return this},prepare:function(){return this.options},ready:function(){}});f.view.Frame=f.View.extend({initialize:function(){this._createRegions();this._createStates()},_createRegions:function(){this.regions=this.regions?this.regions.slice():[];_.each(this.regions,function(g){this[g]=new f.controller.Region({contr
 oller:this,id:g,selector:&quot;.media-frame-&quot;+g})},this)},_createStates:function(){this.states=new Backbone.Collection(null,{model:f.controller.State});this.states.on(&quot;add&quot;,function(g){g.frame=this},this)},reset:function(){this.states.invoke(&quot;trigger&quot;,&quot;reset&quot;);return this}});_.extend(f.view.Frame.prototype,f.controller.StateMachine.prototype);f.view.MediaFrame=f.view.Frame.extend({className:&quot;media-frame&quot;,template:f.template(&quot;media-frame&quot;),regions:[&quot;menu&quot;,&quot;content&quot;,&quot;toolbar&quot;],initialize:function(){f.view.Frame.prototype.initialize.apply(this,arguments);_.defaults(this.options,{title:&quot;&quot;,modal:true,uploader:true});this.$el.addClass(&quot;wp-core-ui&quot;);if(this.options.modal){this.modal=new f.view.Modal({controller:this,title:this.options.title});this.modal.content(this)}if(wp.Uploader.limitExceeded||!wp.Uploader.browser.supported){this.options.uploader=false}if(this.options.uploade
 r){this.uploader=new f.view.UploaderWindow({controller:this,uploader:{dropzone:this.modal?this.modal.$el:this.$el,container:this.$el}});this.views.set(&quot;.media-frame-uploader&quot;,this.uploader)}this.on(&quot;attach&quot;,_.bind(this.views.ready,this.views),this)},render:function(){if(!this.state()&amp;&amp;this.options.state){this.setState(this.options.state)}return f.view.Frame.prototype.render.apply(this,arguments)},createIframeStates:function(g){var j=f.view.settings,i=j.tabs,k=j.tabUrl,h;if(!i||!k){return}h=e(&quot;#post_ID&quot;);if(h.length){k+=&quot;&amp;post_id=&quot;+h.val()}_.each(i,function(m,n){var l=this.state(&quot;iframe:&quot;+n).set(_.defaults({tab:n,src:k+&quot;&amp;tab=&quot;+n,title:m,content:&quot;iframe&quot;,menu:&quot;main&quot;},g))},this);this.content.on(&quot;activate:iframe&quot;,this.iframeContent,this);this.menu.on(&quot;activate:main&quot;,this.iframeMenu,this);this.on(&quot;open&quot;,this.hijackThickbox,this);this.on(&quot;close&quot;,t
 his.restoreThickbox,this)},iframeContent:function(){this.$el.addClass(&quot;hide-toolbar&quot;);this.content.view(new f.view.Iframe({controller:this}).render())},iframeMenu:function(){var g={};_.each(f.view.settings.tabs,function(h,i){g[&quot;iframe:&quot;+i]={text:this.state(&quot;iframe:&quot;+i).get(&quot;title&quot;),priority:200}},this);this.menu.view().set(g)},hijackThickbox:function(){var g=this;if(!window.tb_remove||this._tb_remove){return}this._tb_remove=window.tb_remove;window.tb_remove=function(){g.close();g.reset();g.setState(g.options.state);g._tb_remove.call(window)}},restoreThickbox:function(){if(!this._tb_remove){return}window.tb_remove=this._tb_remove;delete this._tb_remove}});_.each([&quot;open&quot;,&quot;close&quot;,&quot;attach&quot;,&quot;detach&quot;,&quot;escape&quot;],function(g){f.view.MediaFrame.prototype[g]=function(h){if(this.modal){this.modal[g].apply(this.modal,arguments)}return this}});f.view.MediaFrame.Select=f.view.MediaFrame.extend({initial
 ize:function(){f.view.MediaFrame.prototype.initialize.apply(this,arguments);_.defaults(this.options,{selection:[],library:{},multiple:false});this.createSelection();this.createStates();this.bindHandlers()},createSelection:function(){var g=this,h=this.options.selection;if(!(h instanceof f.model.Selection)){this.options.selection=new f.model.Selection(h,{multiple:this.options.multiple})}},createStates:function(){var g=this.options;this.states.add([new f.controller.Library({selection:g.selection,library:f.query(g.library),multiple:this.options.multiple,menu:&quot;main&quot;,toolbar:&quot;select&quot;}),new f.controller.Upload({menu:&quot;main&quot;})])},bindHandlers:function(){this.menu.on(&quot;activate:main&quot;,this.mainMenu,this);this.content.on(&quot;activate:browse&quot;,this.browseContent,this);this.content.on(&quot;activate:upload&quot;,this.uploadContent,this);this.toolbar.on(&quot;activate:select&quot;,this.selectToolbar,this);this.on(&quot;refresh:selection&quot;,th
 is.refreshSelectToolbar,this)},mainMenu:function(g){this.menu.view(new f.view.Menu({controller:this,silent:g&amp;&amp;g.silent,views:{upload:{text:b.uploadFilesTitle,priority:20},library:{text:b.mediaLibraryTitle,priority:40}}}))},browseContent:function(){var g=this.state();this.$el.removeClass(&quot;hide-toolbar&quot;);this.content.view(new f.view.AttachmentsBrowser({controller:this,collection:g.get(&quot;library&quot;),selection:g.get(&quot;selection&quot;),model:g,sortable:g.get(&quot;sortable&quot;),search:g.get(&quot;searchable&quot;),uploads:g.get(&quot;uploads&quot;),filters:g.get(&quot;filterable&quot;),display:g.get(&quot;displaySettings&quot;),AttachmentView:g.get(&quot;AttachmentView&quot;)}))},uploadContent:function(){this.$el.addClass(&quot;hide-toolbar&quot;);this.content.view(new f.view.UploaderInline({controller:this}))},selectToolbar:function(g){g=_.defaults(g||{},{event:&quot;select&quot;,silent:false,state:false});this.toolbar.view(new f.view.Toolbar({cont
 roller:this,silent:g.silent,items:{select:{style:&quot;primary&quot;,text:b.select,priority:80,click:function(){var h=this.controller;h.close();h.state().trigger(g.event);h.reset();if(g.state){h.setState(g.state)}}}}}))},refreshSelectToolbar:function(){var g=this.state().get(&quot;selection&quot;);if(!g||&quot;select&quot;!==this.toolbar.mode()){return}this.toolbar.view().get(&quot;select&quot;).model.set(&quot;disabled&quot;,!g.length)}});f.view.MediaFrame.Post=f.view.MediaFrame.Select.extend({initialize:function(){_.defaults(this.options,{multiple:true,editing:false});f.view.MediaFrame.Select.prototype.initialize.apply(this,arguments);this.createIframeStates()},createStates:function(){var g=this.options;this.states.add([new f.controller.Library({selection:g.selection,library:f.query(g.library),editable:true,filterable:&quot;all&quot;,multiple:this.options.multiple,menu:&quot;main&quot;,displaySettings:true,displayUserSettings:true}),new f.controller.Upload({menu:&quot;main
 &quot;}),new f.controller.Embed(),new f.controller.Gallery({library:g.selection,editing:g.editing,menu:&quot;gallery&quot;}),new f.controller.Library({id:&quot;gallery-library&quot;,library:f.query({type:&quot;image&quot;}),filterable:&quot;uploaded&quot;,multiple:true,menu:&quot;gallery&quot;,toolbar:&quot;gallery-add&quot;,excludeState:&quot;gallery-edit&quot;}),new f.controller.Upload({id:&quot;gallery-upload&quot;,menu:&quot;gallery&quot;,libraryState:&quot;gallery-edit&quot;})]);if(f.view.settings.featuredImage){this.states.add(new f.controller.FeaturedImage({controller:this,menu:&quot;main&quot;}))}},bindHandlers:function(){f.view.MediaFrame.Select.prototype.bindHandlers.apply(this,arguments);var g={menu:{gallery:&quot;galleryMenu&quot;},content:{embed:&quot;embedContent&quot;,&quot;edit-selection&quot;:&quot;editSelectionContent&quot;},toolbar:{&quot;main-attachments&quot;:&quot;mainAttachmentsToolbar&quot;,&quot;main-embed&quot;:&quot;mainEmbedToolbar&quot;,&quot;fea
 tured-image&quot;:&quot;featuredImageToolbar&quot;,&quot;gallery-edit&quot;:&quot;galleryEditToolbar&quot;,&quot;gallery-add&quot;:&quot;galleryAddToolbar&quot;}};_.each(g,function(i,h){_.each(i,function(k,j){this[h].on(&quot;activate:&quot;+j,this[k],this)},this)},this)},mainMenu:function(){f.view.MediaFrame.Select.prototype.mainMenu.call(this,{silent:true});this.menu.view().set({&quot;library-separator&quot;:new f.View({className:&quot;separator&quot;,priority:60}),embed:{text:b.fromUrlTitle,priority:80}});if(f.view.settings.featuredImage){this.menu.view().set(&quot;featured-image&quot;,{text:b.featuredImageTitle,priority:100})}},galleryMenu:function(){var g=this.lastState(),h=g&amp;&amp;g.id,i=this;this.menu.view(new f.view.Menu({controller:this,views:{cancel:{text:b.cancelGalleryTitle,priority:20,click:function(){if(h){i.setState(h)}else{i.close()}}},separateCancel:new f.View({className:&quot;separator&quot;,priority:40}),&quot;gallery-edit&quot;:{text:b.editGalleryTitle
 ,priority:60},&quot;gallery-upload&quot;:{text:b.uploadImagesTitle,priority:80},&quot;gallery-library&quot;:{text:b.mediaLibraryTitle,priority:100}}}))},embedContent:function(){var g=new f.view.Embed({controller:this,model:this.state()}).render();this.content.view(g);g.url.focus()},editSelectionContent:function(){var i=this.state(),h=i.get(&quot;selection&quot;),g;g=new f.view.AttachmentsBrowser({controller:this,collection:h,selection:h,model:i,sortable:true,search:false,AttachmentView:f.view.Attachment.EditSelection}).render();g.toolbar.set(&quot;backToLibrary&quot;,{text:b.returnToLibrary,priority:-100,click:function(){this.controller.content.mode(&quot;browse&quot;)}});this.content.view(g)},onSidebarGallerySettings:function(h){var g=this.state().get(&quot;library&quot;);if(!g){return}g.gallery=g.gallery||new Backbone.Model();this.sidebar.view().set({gallery:new f.view.Settings.Gallery({controller:this,model:g.gallery,priority:40}).render()},h)},mainAttachmentsToolbar:func
 tion(){this.toolbar.view(new f.view.Toolbar.Insert({controller:this,editable:this.state().get(&quot;editable&quot;)}))},featuredImageToolbar:function(){this.toolbar.view(new f.view.Toolbar.Select({controller:this,text:b.setFeaturedImage,state:this.options.state||&quot;upload&quot;}))},mainEmbedToolbar:function(){this.toolbar.view(new f.view.Toolbar.Embed({controller:this}));this.$el.removeClass(&quot;hide-toolbar&quot;)},galleryEditToolbar:function(){var g=this.state().get(&quot;editing&quot;);this.toolbar.view(new f.view.Toolbar({controller:this,items:{insert:{style:&quot;primary&quot;,text:g?b.updateGallery:b.insertGallery,priority:80,click:function(){var h=this.controller,i=h.state();h.close();i.trigger(&quot;update&quot;,i.get(&quot;library&quot;));h.reset();h.setState(&quot;upload&quot;)}}}}))},galleryAddToolbar:function(){this.toolbar.view(new f.view.Toolbar({controller:this,items:{insert:{style:&quot;primary&quot;,text:b.addToGallery,priority:80,click:function(){var g
 =this.controller,i=g.state(),h=g.state(&quot;gallery-edit&quot;);h.get(&quot;library&quot;).add(i.get(&quot;selection&quot;).models);i.trigger(&quot;reset&quot;);g.state(&quot;gallery-edit&quot;)}}}}))}});f.view.Modal=f.View.extend({tagName:&quot;div&quot;,template:f.template(&quot;media-modal&quot;),attributes:{tabindex:0},events:{&quot;click .media-modal-backdrop, .media-modal-close&quot;:&quot;escapeHandler&quot;,keydown:&quot;keydown&quot;},initialize:function(){this.controller=this.options.controller;_.defaults(this.options,{container:document.body,title:&quot;&quot;,propagate:true})},prepare:function(){return{title:this.options.title}},attach:function(){if(this.views.attached){return this}if(!this.views.rendered){this.render()}this.$el.appendTo(this.options.container);this.views.attached=true;this.views.ready();return this.propagate(&quot;attach&quot;)},detach:function(){if(this.$el.is(&quot;:visible&quot;)){this.close()}this.$el.detach();this.views.attached=false;retu
 rn this.propagate(&quot;detach&quot;)},open:function(){if(this.$el.is(&quot;:visible&quot;)){return this}if(!this.views.attached){this.attach()}this.$el.show().focus();return this.propagate(&quot;open&quot;)},close:function(g){if(!this.views.attached||!this.$el.is(&quot;:visible&quot;)){return this}this.$el.hide();this.propagate(&quot;close&quot;);if(g&amp;&amp;g.escape){this.propagate(&quot;escape&quot;)}return this},escape:function(){return this.close({escape:true})},escapeHandler:function(g){g.preventDefault();this.escape()},content:function(g){this.views.set(&quot;.media-modal-content&quot;,g);return this},propagate:function(g){this.trigger(g);if(this.options.propagate){this.controller.trigger(g)}return this},keydown:function(g){if(27===g.which){g.preventDefault();this.escape();return}}});f.view.UploaderWindow=f.View.extend({tagName:&quot;div&quot;,className:&quot;uploader-window&quot;,template:f.template(&quot;uploader-window&quot;),initialize:function(){var g;this.cont
 roller=this.options.controller;this.$browser=e('&lt;a href=&quot;#&quot; class=&quot;browser&quot; /&gt;').hide().appendTo(&quot;body&quot;);g=this.options.uploader=_.defaults(this.options.uploader||{},{dropzone:this.$el,browser:this.$browser,params:{}});if(g.dropzone&amp;&amp;!(g.dropzone instanceof e)){g.dropzone=e(g.dropzone)}this.controller.on(&quot;activate&quot;,this.refresh,this)},refresh:function(){if(this.uploader){this.uploader.refresh()}},ready:function(){var h=f.view.settings.postId,g;if(this.uploader){return}if(h){this.options.uploader.params.post_id=h}this.uploader=new wp.Uploader(this.options.uploader);g=this.uploader.dropzone;g.on(&quot;dropzone:enter&quot;,_.bind(this.show,this));g.on(&quot;dropzone:leave&quot;,_.bind(this.hide,this))},show:function(){var g=this.$el.show();_.defer(function(){g.css({opacity:1})})},hide:function(){var g=this.$el.css({opacity:0});f.transition(g).done(function(){if(&quot;0&quot;===g.css(&quot;opacity&quot;)){g.hide()}})}});f.vie
 w.UploaderInline=f.View.extend({tagName:&quot;div&quot;,className:&quot;uploader-inline&quot;,template:f.template(&quot;uploader-inline&quot;),initialize:function(){this.controller=this.options.controller;if(!this.options.$browser&amp;&amp;this.controller.uploader){this.options.$browser=this.controller.uploader.$browser}if(_.isUndefined(this.options.postId)){this.options.postId=f.view.settings.postId}this.views.set(&quot;.upload-inline-status&quot;,new f.view.UploaderStatus({controller:this.controller}))},ready:function(){var g=this.options.$browser,h;if(this.controller.uploader){h=this.$(&quot;.browser&quot;);if(h[0]===g[0]){return}g.detach().text(h.text());g[0].className=h[0].className;h.replaceWith(g.show())}return this}});f.view.UploaderStatus=f.View.extend({className:&quot;media-uploader-status&quot;,template:f.template(&quot;uploader-status&quot;),events:{&quot;click .upload-dismiss-errors&quot;:&quot;dismiss&quot;},initialize:function(){this.controller=this.options.co
 ntroller;this.queue=wp.Uploader.queue;this.queue.on(&quot;add remove reset&quot;,this.visibility,this);this.queue.on(&quot;add remove reset change:percent&quot;,this.progress,this);this.queue.on(&quot;add remove reset change:uploading&quot;,this.info,this);this.errors=wp.Uploader.errors;this.errors.reset();this.errors.on(&quot;add remove reset&quot;,this.visibility,this);this.errors.on(&quot;add&quot;,this.error,this)},dispose:function(){wp.Uploader.queue.off(null,null,this);f.View.prototype.dispose.apply(this,arguments);return this},visibility:function(){this.$el.toggleClass(&quot;uploading&quot;,!!this.queue.length);this.$el.toggleClass(&quot;errors&quot;,!!this.errors.length);this.$el.toggle(!!this.queue.length||!!this.errors.length)},ready:function(){_.each({&quot;$bar&quot;:&quot;.media-progress-bar div&quot;,&quot;$index&quot;:&quot;.upload-index&quot;,&quot;$total&quot;:&quot;.upload-total&quot;,&quot;$filename&quot;:&quot;.upload-filename&quot;},function(g,h){this[h]
 =this.$(g)},this);this.visibility();this.progress();this.info()},progress:function(){var g=this.queue,i=this.$bar,h=0;if(!i||!g.length){return}i.width((g.reduce(function(j,l){if(!l.get(&quot;uploading&quot;)){return j+100}var k=l.get(&quot;percent&quot;);return j+(_.isNumber(k)?k:100)},0)/g.length)+&quot;%&quot;)},info:function(){var g=this.queue,h=0,i;if(!g.length){return}i=this.queue.find(function(k,j){h=j;return k.get(&quot;uploading&quot;)});this.$index.text(h+1);this.$total.text(g.length);this.$filename.html(i?this.filename(i.get(&quot;filename&quot;)):&quot;&quot;)},filename:function(g){return f.truncate(_.escape(g),24)},error:function(g){this.views.add(&quot;.upload-errors&quot;,new f.view.UploaderStatusError({filename:this.filename(g.get(&quot;file&quot;).name),message:g.get(&quot;message&quot;)}),{at:0})},dismiss:function(g){var h=this.views.get(&quot;.upload-errors&quot;);g.preventDefault();if(h){_.invoke(h,&quot;remove&quot;)}wp.Uploader.errors.reset()}});f.view.U
 ploaderStatusError=f.View.extend({className:&quot;upload-error&quot;,template:f.template(&quot;uploader-status-error&quot;)});f.view.Toolbar=f.View.extend({tagName:&quot;div&quot;,className:&quot;media-toolbar&quot;,initialize:function(){this.controller=this.options.controller;this._views={};this.$primary=e('&lt;div class=&quot;media-toolbar-primary&quot; /&gt;').prependTo(this.$el);this.$secondary=e('&lt;div class=&quot;media-toolbar-secondary&quot; /&gt;').prependTo(this.$el);if(this.options.items){this.set(this.options.items,{silent:true})}if(!this.options.silent){this.render()}},destroy:function(){this.remove();if(this.model){this.model.off(null,null,this)}if(this.collection){this.collection.off(null,null,this)}this.controller.off(null,null,this);_.each(this._views,function(g){if(g.destroy){g.destroy()}})},render:function(){var g=_.chain(this._views).sortBy(function(h){return h.options.priority||10}).groupBy(function(h){return(h.options.priority||10)&gt;0?&quot;primary&q
 uot;:&quot;secondary&quot;}).value();e(_.pluck(this._views,&quot;el&quot;)).detach();this.$primary.html(_.pluck(g.primary||[],&quot;el&quot;));this.$secondary.html(_.pluck(g.secondary||[],&quot;el&quot;));this.refresh();return this},set:function(i,g,h){h=h||{};if(_.isObject(i)){_.each(i,function(j,k){this.set(k,j,{silent:true})},this)}else{if(!(g instanceof Backbone.View)){g.classes=[&quot;media-button-&quot;+i].concat(g.classes||[]);g=new f.view.Button(g).render()}g.controller=g.controller||this.controller;this._views[i]=g}if(!h.silent){this.render()}return this},get:function(g){return this._views[g]},unset:function(h,g){delete this._views[h];if(!g||!g.silent){this.render()}return this},refresh:function(){}});f.view.Toolbar.Select=f.view.Toolbar.extend({initialize:function(){var h=this.options,g=h.controller,i=g.state().get(&quot;selection&quot;);_.bindAll(this,&quot;clickSelect&quot;);_.defaults(h,{event:&quot;select&quot;,state:false,reset:true,close:true,text:b.select});
 h.items=_.defaults(h.items||{},{select:{style:&quot;primary&quot;,text:h.text,priority:80,click:this.clickSelect}});f.view.Toolbar.prototype.initialize.apply(this,arguments)},clickSelect:function(){var h=this.options,g=this.controller;if(h.close){g.close()}if(h.event){g.state().trigger(h.event)}if(h.reset){g.reset()}if(h.state){g.setState(h.state)}}});f.view.Toolbar.Embed=f.view.Toolbar.Select.extend({initialize:function(){var g=this.options.controller;_.defaults(this.options,{text:b.insertIntoPost});f.view.Toolbar.Select.prototype.initialize.apply(this,arguments);g.on(&quot;change:url&quot;,this.refresh,this)},refresh:function(){var g=this.controller.state().get(&quot;url&quot;);this.get(&quot;select&quot;).model.set(&quot;disabled&quot;,!g||/^https?:\/\/$/.test(g))}});f.view.Toolbar.Insert=f.view.Toolbar.extend({initialize:function(){var g=this.options.controller,i=g.state().get(&quot;selection&quot;),h;h=function(k,j){return function(){var l=this.controller,m=l.state().ge
 t(&quot;selection&quot;),n=l.state(k),o=j?j(m):m.models;n.set(&quot;library&quot;,new f.model.Selection(o,{props:m.props.toJSON(),multiple:true}));this.controller.setState(k)}};this.options.items=_.defaults(this.options.items||{},{selection:new f.view.Selection({controller:g,collection:i,priority:-40,editable:this.options.editable&amp;&amp;function(){this.controller.content.mode(&quot;edit-selection&quot;)}}).render(),insert:{style:&quot;primary&quot;,priority:80,text:b.insertIntoPost,click:function(){g.close();g.state().trigger(&quot;insert&quot;,i).reset()}},gallery:{text:b.createNewGallery,priority:40,click:h(&quot;gallery-edit&quot;,function(j){return j.where({type:&quot;image&quot;})})}});f.view.Toolbar.prototype.initialize.apply(this,arguments)},refresh:function(){var g=this.controller.state().get(&quot;selection&quot;),h=g.length;this.get(&quot;insert&quot;).model.set(&quot;disabled&quot;,!g.length);this.get(&quot;gallery&quot;).$el.toggle(h&gt;1&amp;&amp;g.any(functi
 on(i){return&quot;image&quot;===i.get(&quot;type&quot;)}))}});f.view.Button=f.View.extend({tagName:&quot;a&quot;,className:&quot;media-button&quot;,attributes:{href:&quot;#&quot;},events:{click:&quot;click&quot;},defaults:{text:&quot;&quot;,style:&quot;&quot;,size:&quot;large&quot;,disabled:false},initialize:function(){this.model=new Backbone.Model(this.defaults);_.each(this.defaults,function(i,g){var h=this.options[g];if(_.isUndefined(h)){return}this.model.set(g,h);delete this.options[g]},this);this.model.on(&quot;change&quot;,this.render,this)},render:function(){var h=[&quot;button&quot;,this.className],g=this.model.toJSON();if(g.style){h.push(&quot;button-&quot;+g.style)}if(g.size){h.push(&quot;button-&quot;+g.size)}h=_.uniq(h.concat(this.options.classes));this.el.className=h.join(&quot; &quot;);this.$el.attr(&quot;disabled&quot;,g.disabled);this.$el.text(this.model.get(&quot;text&quot;));return this},click:function(g){if(&quot;#&quot;===this.attributes.href){g.preventDef
 ault()}if(this.options.click&amp;&amp;!this.model.get(&quot;disabled&quot;)){this.options.click.apply(this,arguments)}}});f.view.ButtonGroup=f.View.extend({tagName:&quot;div&quot;,className:&quot;button-group button-large media-button-group&quot;,initialize:function(){this.buttons=_.map(this.options.buttons||[],function(g){if(g instanceof Backbone.View){return g}else{return new f.view.Button(g).render()}});delete this.options.buttons;if(this.options.classes){this.$el.addClass(this.options.classes)}},render:function(){this.$el.html(e(_.pluck(this.buttons,&quot;el&quot;)).detach());return this}});f.view.PriorityList=f.View.extend({tagName:&quot;div&quot;,initialize:function(){this.controller=this.options.controller;this._views={};this.set(_.extend({},this._views,this.options.views),{silent:true});delete this.options.views;if(!this.options.silent){this.render()}},destroy:this.dispose,set:function(l,h,j){var k,g,i;j=j||{};if(_.isObject(l)){_.each(l,function(m,n){this.set(n,m)},t
 his);return this}if(!(h instanceof Backbone.View)){h=this.toView(h,l,j)}h.controller=h.controller||this.controller;this.unset(l);k=h.options.priority||10;g=this.views.get()||[];_.find(g,function(n,m){if(n.options.priority&gt;k){i=m;return true}});this._views[l]=h;this.views.add(h,{at:_.isNumber(i)?i:g.length||0});return this},get:function(g){return this._views[g]},unset:function(h){var g=this.get(h);if(g){g.remove()}delete this._views[h];return this},toView:function(g){return new f.View(g)}});f.view.Menu=f.view.PriorityList.extend({tagName:&quot;ul&quot;,className:&quot;media-menu&quot;,toView:function(g,h){g=g||{};g.state=g.state||h;return new f.view.MenuItem(g).render()},select:function(h){var g=this.get(h);if(!g){return}this.deselect();g.$el.addClass(&quot;active&quot;)},deselect:function(){this.$el.children().removeClass(&quot;active&quot;)}});f.view.MenuItem=f.View.extend({tagName:&quot;li&quot;,className:&quot;media-menu-item&quot;,events:{click:&quot;click&quot;},clic
 k:function(){var g=this.options;if(g.click){g.click.call(this)}else{if(g.state){this.controller.setState(g.state)}}},render:function(){var g=this.options;if(g.text){this.$el.text(g.text)}else{if(g.html){this.$el.html(g.html)}}return this}});f.view.Sidebar=f.view.PriorityList.extend({className:&quot;media-sidebar&quot;});f.view.Attachment=f.View.extend({tagName:&quot;li&quot;,className:&quot;attachment&quot;,template:f.template(&quot;attachment&quot;),events:{&quot;click .attachment-preview&quot;:&quot;toggleSelection&quot;,&quot;change [data-setting]&quot;:&quot;updateSetting&quot;,&quot;change [data-setting] input&quot;:&quot;updateSetting&quot;,&quot;change [data-setting] select&quot;:&quot;updateSetting&quot;,&quot;change [data-setting] textarea&quot;:&quot;updateSetting&quot;,&quot;click .close&quot;:&quot;removeFromLibrary&quot;,&quot;click .check&quot;:&quot;removeFromSelection&quot;,&quot;click a&quot;:&quot;preventDefault&quot;},buttons:{},initialize:function(){var g
 =this.options.selection;this.controller=this.options.controller;this.model.on(&quot;change:sizes change:uploading change:caption change:title&quot;,this.render,this);this.model.on(&quot;change:percent&quot;,this.progress,this);this.model.on(&quot;add&quot;,this.select,this);this.model.on(&quot;remove&quot;,this.deselect,this);if(g){g.on(&quot;reset&quot;,this.updateSelect,this)}this.model.on(&quot;selection:single selection:unsingle&quot;,this.details,this);this.details(this.model,this.controller.state().get(&quot;selection&quot;))},dispose:function(){var g=this.options.selection;this.updateAll();if(g){g.off(null,null,this)}f.View.prototype.dispose.apply(this,arguments);return this},render:function(){var h=this.model.toJSON(),g=_.defaults(this.model.toJSON(),{orientation:&quot;landscape&quot;,uploading:false,type:&quot;&quot;,subtype:&quot;&quot;,icon:&quot;&quot;,filename:&quot;&quot;,caption:&quot;&quot;,title:&quot;&quot;,dateFormatted:&quot;&quot;,width:&quot;&quot;,heig
 ht:&quot;&quot;,compat:false,alt:&quot;&quot;});g.buttons=this.buttons;g.describe=this.controller.state().get(&quot;describe&quot;);if(&quot;image&quot;===g.type){g.size=this.imageSize()}this.views.detach();this.$el.html(this.template(g));this.$el.toggleClass(&quot;uploading&quot;,g.uploading);if(g.uploading){this.$bar=this.$(&quot;.media-progress-bar div&quot;)}else{delete this.$bar}this.updateSelect();this.updateSave();this.views.render();return this},progress:function(){if(this.$bar&amp;&amp;this.$bar.length){this.$bar.width(this.model.get(&quot;percent&quot;)+&quot;%&quot;)}},toggleSelection:function(i){var h=this.options.selection,g=this.model;if(!h){return}if(this.selected()){h[h.single()===g?&quot;remove&quot;:&quot;single&quot;](g)}else{h.add(g).single(g)}},updateSelect:function(){this[this.selected()?&quot;select&quot;:&quot;deselect&quot;]()},selected:function(){var g=this.options.selection;if(g){return !!g.getByCid(this.model.cid)}},select:function(g,i){var h=this
 .options.selection;if(!h||(i&amp;&amp;i!==h)){return}this.$el.addClass(&quot;selected&quot;)},deselect:function(g,i){var h=this.options.selection;if(!h||(i&amp;&amp;i!==h)){return}this.$el.removeClass(&quot;selected&quot;)},details:function(g,j){var i=this.options.selection,h;if(i!==j){return}h=i.single();this.$el.toggleClass(&quot;details&quot;,h===this.model)},preventDefault:function(g){g.preventDefault()},imageSize:function(g){var h=this.model.get(&quot;sizes&quot;);g=g||&quot;medium&quot;;if(h&amp;&amp;h[g]){return _.clone(h[g])}else{return{url:this.model.get(&quot;url&quot;),width:this.model.get(&quot;width&quot;),height:this.model.get(&quot;height&quot;),orientation:this.model.get(&quot;orientation&quot;)}}},updateSetting:function(i){var g=e(i.target).closest(&quot;[data-setting]&quot;),h,j;if(!g.length){return}h=g.data(&quot;setting&quot;);j=i.target.value;if(this.model.get(h)!==j){this.save(h,j)}},save:function(){var g=this,i=this._save=this._save||{status:&quot;read
 y&quot;},h=this.model.save.apply(this.model,arguments),j=i.requests?e.when(h,i.requests):h;if(i.savedTimer){clearTimeout(i.savedTimer)}this.updateSave(&quot;waiting&quot;);i.requests=j;j.done(function(){if(i.requests!==j){return}g.updateSave(&quot;complete&quot;);i.savedTimer=setTimeout(function(){g.updateSave(&quot;ready&quot;);delete i.savedTimer},2000)})},updateSave:function(g){var h=this._save=this._save||{status:&quot;ready&quot;};if(g&amp;&amp;g!==h.status){this.$el.removeClass(&quot;save-&quot;+h.status);h.status=g}this.$el.addClass(&quot;save-&quot;+h.status);return this},updateAll:function(){var h=this.$(&quot;[data-setting]&quot;),g=this.model,i;i=_.chain(h).map(function(k){var m=e(&quot;input, textarea, select, [value]&quot;,k),j,l;if(!m.length){return}j=e(k).data(&quot;setting&quot;);l=m.val();if(g.get(j)!==l){return[j,l]}}).compact().object().value();if(!_.isEmpty(i)){g.save(i)}},removeFromLibrary:function(g){g.stopPropagation();this.collection.remove(this.model
 )},removeFromSelection:function(h){var g=this.options.selection;if(!g){return}h.stopPropagation();g.remove(this.model)}});f.view.Attachment.Library=f.view.Attachment.extend({buttons:{check:true}});f.view.Attachment.EditLibrary=f.view.Attachment.extend({buttons:{close:true}});f.view.Attachments=f.View.extend({tagName:&quot;ul&quot;,className:&quot;attachments&quot;,cssTemplate:f.template(&quot;attachments-css&quot;),events:{scroll:&quot;scroll&quot;},initialize:function(){this.controller=this.options.controller;this.el.id=_.uniqueId(&quot;__attachments-view-&quot;);_.defaults(this.options,{refreshSensitivity:200,refreshThreshold:3,AttachmentView:f.view.Attachment,sortable:false});this._viewsByCid={};this.collection.on(&quot;add&quot;,function(i,g,h){this.views.add(this.createAttachmentView(i),{at:h.index})},this);this.collection.on(&quot;remove&quot;,function(j,g,i){var h=this._viewsByCid[j.cid];delete this._viewsByCid[j.cid];if(h){h.remove()}},this);this.collection.on(&quot;
 reset&quot;,this.render,this);this.scroll=_.chain(this.scroll).bind(this).throttle(this.options.refreshSensitivity).value();this.initSortable();_.bindAll(this,&quot;css&quot;);this.model.on(&quot;change:edge change:gutter&quot;,this.css,this);this._resizeCss=_.debounce(_.bind(this.css,this),this.refreshSensitivity);e(window).on(&quot;resize.attachments&quot;,this._resizeCss);this.css()},dispose:function(){this.collection.props.off(null,null,this);e(window).off(&quot;resize.attachments&quot;,this._resizeCss);f.View.prototype.dispose.apply(this,arguments)},css:function(){var g=e(&quot;#&quot;+this.el.id+&quot;-css&quot;);if(g.length){g.remove()}f.view.Attachments.$head().append(this.cssTemplate({id:this.el.id,edge:this.edge(),gutter:this.model.get(&quot;gutter&quot;)}))},edge:function(){var i=this.model.get(&quot;edge&quot;),j,h,g;if(!this.$el.is(&quot;:visible&quot;)){return i}j=this.model.get(&quot;gutter&quot;)*2;h=this.$el.width()-j;g=Math.ceil(h/(i+j));i=Math.floor((h-(g*
 j))/g);return i},initSortable:function(){var g=this.collection,h;if(!this.options.sortable||!e.fn.sortable){return}this.$el.sortable({disabled:!!g.comparator,containment:this.$el,tolerance:&quot;pointer&quot;,start:function(i,j){h=j.item.index()},update:function(k,l){var j=g.at(h),i=g.comparator;delete g.comparator;g.remove(j,{silent:true}).add(j,{at:l.item.index(),silent:true});g.comparator=i;g.saveMenuOrder()}});g.props.on(&quot;change:orderby&quot;,function(){this.$el.sortable(&quot;option&quot;,&quot;disabled&quot;,!!g.comparator)},this);this.collection.props.on(&quot;change:orderby&quot;,this.refreshSortable,this);this.refreshSortable()},refreshSortable:function(){if(!this.options.sortable||!e.fn.sortable){return}var i=this.collection,h=i.props.get(&quot;orderby&quot;),g=&quot;menuOrder&quot;===h||!i.comparator;this.$el.sortable(&quot;option&quot;,&quot;disabled&quot;,!g)},createAttachmentView:function(h){var g=new this.options.AttachmentView({controller:this.controller
 ,model:h,collection:this.collection,selection:this.options.selection});return this._viewsByCid[h.cid]=g},prepare:function(){if(this.collection.length){this.views.set(this.collection.map(this.createAttachmentView,this))}else{this.views.unset();this.collection.more().done(this.scroll)}},ready:function(){this.scroll()},scroll:function(g){if(!this.$el.is(&quot;:visible&quot;)){return}if(this.collection.hasMore()&amp;&amp;this.el.scrollHeight&lt;this.el.scrollTop+(this.el.clientHeight*this.options.refreshThreshold)){this.collection.more().done(this.scroll)}}},{$head:(function(){var g;return function(){return g=g||e(&quot;head&quot;)}}())});f.view.Search=f.View.extend({tagName:&quot;input&quot;,className:&quot;search&quot;,attributes:{type:&quot;search&quot;,placeholder:b.search},events:{input:&quot;search&quot;,keyup:&quot;search&quot;,change:&quot;search&quot;,search:&quot;search&quot;},render:function(){this.el.value=this.model.escape(&quot;search&quot;);return this},search:fun
 ction(g){if(g.target.value){this.model.set(&quot;search&quot;,g.target.value)}else{this.model.unset(&quot;search&quot;)}}});f.view.AttachmentFilters=f.View.extend({tagName:&quot;select&quot;,className:&quot;attachment-filters&quot;,events:{change:&quot;change&quot;},filters:{},keys:[],initialize:function(){this.$el.html(_.chain(this.filters).map(function(g,h){return{el:this.make(&quot;option&quot;,{value:h},g.text),priority:g.priority||50}},this).sortBy(&quot;priority&quot;).pluck(&quot;el&quot;).value());this.model.on(&quot;change&quot;,this.select,this);this.select()},change:function(h){var g=this.filters[this.el.value];if(g){this.model.set(g.props)}},select:function(){var g=this.model,i=&quot;all&quot;,h=g.toJSON();_.find(this.filters,function(k,l){var j=_.all(k.props,function(n,m){return n===(_.isUndefined(h[m])?null:h[m])});if(j){return i=l}});this.$el.val(i)}});f.view.AttachmentFilters.Uploaded=f.view.AttachmentFilters.extend({filters:{all:{text:b.allMediaItems,props:{
 uploadedTo:null,orderby:&quot;date&quot;,order:&quot;DESC&quot;},priority:10},uploaded:{text:b.uploadedToThisPost,props:{uploadedTo:f.view.settings.postId,orderby:&quot;menuOrder&quot;,order:&quot;ASC&quot;},priority:20}}});f.view.AttachmentFilters.All=f.view.AttachmentFilters.extend({filters:(function(){var g={};_.each(f.view.settings.mimeTypes||{},function(i,h){g[h]={text:i,props:{type:h,uploadedTo:null,orderby:&quot;date&quot;,order:&quot;DESC&quot;}}});g.all={text:b.allMediaItems,props:{type:null,uploadedTo:null,orderby:&quot;date&quot;,order:&quot;DESC&quot;},priority:10};g.uploaded={text:b.uploadedToThisPost,props:{type:null,uploadedTo:f.view.settings.postId,orderby:&quot;menuOrder&quot;,order:&quot;ASC&quot;},priority:20};return g}())});f.view.AttachmentsBrowser=f.View.extend({tagName:&quot;div&quot;,className:&quot;attachments-browser&quot;,initialize:function(){this.controller=this.options.controller;_.defaults(this.options,{filters:false,search:true,uploads:false,d
 isplay:false,AttachmentView:f.view.Attachment.Library});this.createToolbar();this.updateContent();this.createSidebar();this.collection.on(&quot;add remove reset&quot;,this.updateContent,this)},dispose:function(){this.options.selection.off(null,null,this);f.View.prototype.dispose.apply(this,arguments);return this},createToolbar:function(){var h,g;this.toolbar=new f.view.Toolbar({controller:this.controller});this.views.add(this.toolbar);h=this.options.filters;if(&quot;uploaded&quot;===h){g=f.view.AttachmentFilters.Uploaded}else{if(&quot;all&quot;===h){g=f.view.AttachmentFilters.All}}if(g){this.toolbar.set(&quot;filters&quot;,new g({controller:this.controller,model:this.collection.props,priority:-80}).render())}if(this.options.search){this.toolbar.set(&quot;search&quot;,new f.view.Search({controller:this.controller,model:this.collection.props,priority:60}).render())}if(this.options.sortable&amp;&amp;!this.options.filters){this.toolbar.set(&quot;dragInfo&quot;,new f.View({el:e('
 &lt;div class=&quot;instructions&quot;&gt;'+b.dragInfo+&quot;&lt;/div&gt;&quot;)[0],priority:-40}))}},updateContent:function(){var g=this;if(!this.attachments){this.createAttachments()}if(!this.collection.length){this.collection.more().done(function(){if(!g.collection.length){g.createUploader()}})}},removeContent:function(){_.each([&quot;attachments&quot;,&quot;uploader&quot;],function(g){if(this[g]){this[g].remove();delete this[g]}},this)},createUploader:function(){this.removeContent();this.uploader=new f.view.UploaderInline({controller:this.controller});this.views.add(this.uploader)},createAttachments:function(){this.removeContent();this.attachments=new f.view.Attachments({controller:this.controller,collection:this.collection,selection:this.options.selection,model:this.model,sortable:this.options.sortable,AttachmentView:this.options.AttachmentView});this.views.add(this.attachments)},createSidebar:function(){var g=this.options,h=g.selection,i=this.sidebar=new f.view.Sidebar
 ({controller:this.controller});this.views.add(i);if(g.uploads&amp;&amp;this.controller.uploader){i.set(&quot;uploads&quot;,new f.view.UploaderStatus({controller:this.controller,priority:40}))}h.on(&quot;selection:single&quot;,this.createSingle,this);h.on(&quot;selection:unsingle&quot;,this.disposeSingle,this);if(h.single()){this.createSingle()}},createSingle:function(){var h=this.sidebar,i=this.options.selection.single(),g={};h.set(&quot;details&quot;,new f.view.Attachment.Details({controller:this.controller,model:i,priority:80}));h.set(&quot;compat&quot;,new f.view.AttachmentCompat({controller:this.controller,model:i,priority:120}));if(this.options.display){h.set(&quot;display&quot;,new f.view.Settings.AttachmentDisplay({controller:this.controller,model:this.model.display(i),attachment:i,priority:160,userSettings:this.model.get(&quot;displayUserSettings&quot;)}))}},disposeSingle:function(){var g=this.sidebar;g.unset(&quot;details&quot;);g.unset(&quot;compat&quot;);g.unset(&
 quot;display&quot;)}});f.view.SelectionPreview=f.View.extend({tagName:&quot;div&quot;,className:&quot;selection-preview&quot;,template:f.template(&quot;media-selection-preview&quot;),events:{&quot;click .clear-selection&quot;:&quot;clear&quot;},initialize:function(){_.defaults(this.options,{clearable:true});this.controller=this.options.controller;this.collection.on(&quot;add change:url remove&quot;,this.render,this);this.render()},render:function(){var g=_.clone(this.options),j,i,h;if(!this.collection.length){this.$el.empty();return this}g.count=this.collection.length;j=this.collection.last();i=j.get(&quot;sizes&quot;);if(&quot;image&quot;===j.get(&quot;type&quot;)){g.thumbnail=(i&amp;&amp;i.thumbnail)?i.thumbnail.url:j.get(&quot;url&quot;)}else{g.thumbnail=j.get(&quot;icon&quot;)}this.$el.html(this.template(g));return this},clear:function(g){g.preventDefault();this.collection.reset()}});f.view.Selection=f.View.extend({tagName:&quot;div&quot;,className:&quot;media-selection&
 quot;,template:f.template(&quot;media-selection&quot;),events:{&quot;click .edit-selection&quot;:&quot;edit&quot;,&quot;click .clear-selection&quot;:&quot;clear&quot;},initialize:function(){_.defaults(this.options,{editable:false,clearable:true});this.controller=this.options.controller;this.attachments=new f.view.Attachments({controller:this.controller,collection:this.collection,selection:this.collection,sortable:true,model:new Backbone.Model({edge:40,gutter:5}),AttachmentView:f.view.Attachment.Selection});this.collection.on(&quot;add remove reset&quot;,this.refresh,this)},destroy:function(){this.remove();this.collection.off(&quot;add remove reset&quot;,this.refresh,this);this.attachments.destroy()},render:function(){this.attachments.$el.detach();this.attachments.render();this.$el.html(this.template(this.options));this.$(&quot;.selection-view&quot;).replaceWith(this.attachments.$el);this.refresh();return this},refresh:function(){if(!this.$el.children().length){return}this.$e
 l.toggleClass(&quot;empty&quot;,!this.collection.length);this.$(&quot;.count&quot;).text(this.collection.length+&quot; &quot;+b.selected)},edit:function(g){g.preventDefault();if(this.options.editable){this.options.editable.call(this,this.collection)}},clear:function(g){g.preventDefault();this.collection.reset()}});f.view.Attachment.Selection=f.view.Attachment.extend({className:&quot;attachment selection&quot;,toggleSelection:function(){this.options.selection.single(this.model)}});f.view.Attachment.EditSelection=f.view.Attachment.Selection.extend({buttons:{close:true}});f.view.Settings=f.View.extend({events:{&quot;click button&quot;:&quot;updateHandler&quot;,&quot;change input&quot;:&quot;updateHandler&quot;,&quot;change select&quot;:&quot;updateHandler&quot;,&quot;change textarea&quot;:&quot;updateHandler&quot;},initialize:function(){this.model=this.model||new Backbone.Model();this.model.on(&quot;change&quot;,this.updateChanges,this)},destroy:function(){this.model.off(null,n
 ull,this)},render:function(){this.$el.html(this.template(_.defaults({model:this.model.toJSON()},this.options)));_(this.model.attributes).chain().keys().each(this.update,this);return this},update:function(i){var j=this.model.get(i),h=this.$('[data-setting=&quot;'+i+'&quot;]'),g;if(!h.length){return}if(h.is(&quot;select&quot;)){h.find('[value=&quot;'+j+'&quot;]').attr(&quot;selected&quot;,true)}else{if(h.hasClass(&quot;button-group&quot;)){g=h.find(&quot;button&quot;).removeClass(&quot;active&quot;);g.filter('[value=&quot;'+j+'&quot;]').addClass(&quot;active&quot;)}else{if(h.is('input[type=&quot;text&quot;], textarea')){if(!h.is(&quot;:focus&quot;)){h.val(j)}}else{if(h.is('input[type=&quot;checkbox&quot;]')){h.attr(&quot;checked&quot;,!!j)}}}}},updateHandler:function(i){var h=e(i.target).closest(&quot;[data-setting]&quot;),j=i.target.value,g;i.preventDefault();if(!h.length){return}if(h.is('input[type=&quot;checkbox&quot;]')){j=h[0].checked}this.model.set(h.data(&quot;setting&q
 uot;),j);if(g=h.data(&quot;userSetting&quot;)){setUserSetting(g,j)}},updateChanges:function(h,g){if(g.changes){_(g.changes).chain().keys().each(this.update,this)}}});f.view.Settings.AttachmentDisplay=f.view.Settings.extend({className:&quot;attachment-display-settings&quot;,template:f.template(&quot;attachment-display-settings&quot;),initialize:function(){var g=this.options.attachment;_.defaults(this.options,{userSettings:false});f.view.Settings.prototype.initialize.apply(this,arguments);this.model.on(&quot;change:link&quot;,this.updateLinkTo,this);if(g){g.on(&quot;change:uploading&quot;,this.render,this)}},dispose:function(){var g=this.options.attachment;if(g){g.off(null,null,this)}f.view.Settings.prototype.dispose.apply(this,arguments)},render:function(){var g=this.options.attachment;if(g){_.extend(this.options,{sizes:g.get(&quot;sizes&quot;),type:g.get(&quot;type&quot;)})}f.view.Settings.prototype.render.call(this);this.updateLinkTo();return this},updateLinkTo:function(){v
 ar h=this.model.get(&quot;link&quot;),i=this.$(&quot;.link-to-custom&quot;),g=this.options.attachment;if(&quot;none&quot;===h){i.hide();return}i.show();if(&quot;post&quot;===h){i.val(g.get(&quot;link&quot;))}else{if(&quot;file&quot;===h){i.val(g.get(&quot;url&quot;))}else{if(!this.model.get(&quot;linkUrl&quot;)){i.val(&quot;http://&quot;)}}}i.prop(&quot;readonly&quot;,&quot;custom&quot;!==h);if(i.is(&quot;:visible&quot;)){i.focus()[0].select()}}});f.view.Settings.Gallery=f.view.Settings.extend({className:&quot;gallery-settings&quot;,template:f.template(&quot;gallery-settings&quot;)});f.view.Attachment.Details=f.view.Attachment.extend({tagName:&quot;div&quot;,className:&quot;attachment-details&quot;,template:f.template(&quot;attachment-details&quot;),events:{&quot;change [data-setting]&quot;:&quot;updateSetting&quot;,&quot;change [data-setting] input&quot;:&quot;updateSetting&quot;,&quot;change [data-setting] select&quot;:&quot;updateSetting&quot;,&quot;change [data-setting] 
 textarea&quot;:&quot;updateSetting&quot;,&quot;click .delete-attachment&quot;:&quot;deleteAttachment&quot;},deleteAttachment:function(g){g.preventDefault();if(confirm(b.warnDelete)){this.model.destroy()}}});f.view.AttachmentCompat=f.View.extend({tagName:&quot;form&quot;,className:&quot;compat-item&quot;,events:{submit:&quot;preventDefault&quot;,&quot;change input&quot;:&quot;save&quot;,&quot;change select&quot;:&quot;save&quot;,&quot;change textarea&quot;:&quot;save&quot;},initialize:function(){this.model.on(&quot;change:compat&quot;,this.render,this)},destroy:function(){this.model.off(null,null,this)},render:function(){var g=this.model.get(&quot;compat&quot;);if(!g||!g.item){return}this.$el.html(g.item);return this},preventDefault:function(g){g.preventDefault()},save:function(g){var h={};g.preventDefault();_.each(this.$el.serializeArray(),function(i){h[i.name]=i.value});this.model.saveCompat(h)}});f.view.Iframe=f.View.extend({className:&quot;media-iframe&quot;,initialize:fu
 nction(){this.controller=this.options.controller},render:function(){this.$el.html('&lt;iframe src=&quot;'+this.controller.state().get(&quot;src&quot;)+'&quot; /&gt;');return this}});f.view.Embed=f.View.extend({className:&quot;media-embed&quot;,initialize:function(){this.controller=this.options.controller;this.url=new f.view.EmbedUrl({controller:this.controller,model:this.model}).render();this._settings=new f.View();this.refresh();this.model.on(&quot;change:type&quot;,this.refresh,this)},render:function(){this.$el.html([this.url.el,this._settings.el]);this.url.focus();this.views.render();return this},settings:function(g){g.render();this._settings.$el.replaceWith(g.$el);if(this._settings.destroy){this._settings.destroy()}this._settings.remove();this._settings=g},refresh:function(){var h=this.model.get(&quot;type&quot;),g;if(&quot;image&quot;===h){g=f.view.EmbedImage}else{if(&quot;link&quot;===h){g=f.view.EmbedLink}else{return}}this.settings(new g({controller:this.controller,mo
 del:this.model,priority:40}))}});f.view.EmbedUrl=f.View.extend({tagName:&quot;label&quot;,className:&quot;embed-url&quot;,events:{input:&quot;url&quot;,keyup:&quot;url&quot;,change:&quot;url&quot;},initialize:function(){this.label=this.make(&quot;span&quot;,null,this.options.label||b.url);this.input=this.make(&quot;input&quot;,{type:&quot;text&quot;,value:this.model.get(&quot;url&quot;)||&quot;&quot;});this.$label=e(this.label);this.$input=e(this.input);this.$el.append([this.label,this.input]);this.model.on(&quot;change:url&quot;,this.render,this)},destroy:function(){this.model.off(null,null,this)},render:function(){var g=this.$input;if(g.is(&quot;:focus&quot;)){return}this.input.value=this.model.get(&quot;url&quot;)||&quot;http://&quot;;return this},url:function(g){this.model.set(&quot;url&quot;,g.target.value)},focus:function(){var g=this.$input;if(g.is(&quot;:visible&quot;)){g.focus()[0].select()}}});f.view.EmbedLink=f.view.Settings.extend({className:&quot;embed-link-sett
 ings&quot;,template:f.template(&quot;embed-link-settings&quot;)});f.view.EmbedImage=f.view.Settings.AttachmentDisplay.extend({className:&quot;embed-image-settings&quot;,template:f.template(&quot;embed-image-settings&quot;),initialize:function(){f.view.Settings.AttachmentDisplay.prototype.initialize.apply(this,arguments);this.model.on(&quot;change:url&quot;,this.updateImage,this)},destroy:function(){this.model.off(null,null,this);f.view.Settings.AttachmentDisplay.prototype.destroy.apply(this,arguments)},updateImage:function(){this.$(&quot;img&quot;).attr(&quot;src&quot;,this.model.get(&quot;url&quot;))}})}(jQuery));
</del><span class="cx">\ No newline at end of file
</span><ins>+(function(e){var f=wp.media,d=f.model.Attachment,c=f.model.Attachments,a=f.model.Query,b;b=f.view.l10n=typeof _wpMediaViewsL10n===&quot;undefined&quot;?{}:_wpMediaViewsL10n;f.view.settings=b.settings||{};delete b.settings;f.model.settings.post=f.view.settings.post;e.support.transition=(function(){var g=document.documentElement.style,h={WebkitTransition:&quot;webkitTransitionEnd&quot;,MozTransition:&quot;transitionend&quot;,OTransition:&quot;oTransitionEnd otransitionend&quot;,transition:&quot;transitionend&quot;},i;i=_.find(_.keys(h),function(j){return !_.isUndefined(g[j])});return i&amp;&amp;{end:h[i]}}());f.transition=function(g,h){var i=e.Deferred();h=h||2000;if(e.support.transition){if(!(g instanceof e)){g=e(g)}g.first().one(e.support.transition.end,i.resolve);_.delay(i.resolve,h)}else{i.resolve()}return i.promise()};f.controller.Region=function(g){_.extend(this,_.pick(g||{},&quot;id&quot;,&quot;controller&quot;,&quot;selector&quot;));this.on(&quot;activate:e
 mpty&quot;,this.empty,this);this.mode(&quot;empty&quot;)};f.controller.Region.extend=Backbone.Model.extend;_.extend(f.controller.Region.prototype,Backbone.Events,{trigger:(function(){var g=/\s+/,h=Backbone.Events.trigger;return function(i){var j=&quot;:&quot;+this._mode,k=i.split(g).join(j)+j;h.apply(this,arguments);h.apply(this,[k].concat(_.rest(arguments)));return this}}()),mode:function(g){if(g){this.trigger(&quot;deactivate&quot;,this);this._mode=g;return this.trigger(&quot;activate&quot;,this)}return this._mode},view:function(g){var h=this._view,i=this._mode,j=this.id;if(!g){return h}if(g===h){return}if(j){g.$el.addClass(&quot;region-&quot;+j)}if(i){g.$el.addClass(&quot;mode-&quot;+i)}this.controller.views.set(this.selector,g);this._view=g},empty:function(){this.view(new f.View())}});f.controller.StateMachine=function(g){this.states=new Backbone.Collection(g)};f.controller.StateMachine.extend=Backbone.Model.extend;_.extend(f.controller.StateMachine.prototype,Backbone.Ev
 ents,{state:function(g){this.states=this.states||new Backbone.Collection();g=g||this._state;if(g&amp;&amp;!this.states.get(g)){this.states.add({id:g})}return this.states.get(g)},setState:function(h){var g=this.state();if((g&amp;&amp;h===g.id)||!this.states||!this.states.get(h)){return this}if(g){g.trigger(&quot;deactivate&quot;);this._lastState=g.id}this._state=h;this.state().trigger(&quot;activate&quot;);return this},lastState:function(){if(this._lastState){return this.state(this._lastState)}}});_.each([&quot;on&quot;,&quot;off&quot;,&quot;trigger&quot;],function(g){f.controller.StateMachine.prototype[g]=function(){this.states=this.states||new Backbone.Collection();this.states[g].apply(this.states,arguments);return this}});f.controller.State=Backbone.Model.extend({initialize:function(){this.on(&quot;activate&quot;,this._activate,this);this.on(&quot;activate&quot;,this.activate,this);this.on(&quot;deactivate&quot;,this._deactivate,this);this.on(&quot;deactivate&quot;,this.de
 activate,this);this.on(&quot;reset&quot;,this.reset,this)},activate:function(){},_activate:function(){this.active=true;this.menu();this.toolbar();this.content()},deactivate:function(){},_deactivate:function(){this.active=false},reset:function(){},menu:function(){var i=this.frame.menu,h=this.get(&quot;menu&quot;),g;if(!h){return}if(i.mode()!==h){i.mode(h)}g=i.view();if(g.select){g.select(this.id)}}});_.each([&quot;toolbar&quot;,&quot;content&quot;],function(g){f.controller.State.prototype[g]=function(){var h=this.get(g);if(h){this.frame[g].mode(h)}}});f.controller.Library=f.controller.State.extend({defaults:{id:&quot;library&quot;,multiple:false,describe:false,toolbar:&quot;main-attachments&quot;,sidebar:&quot;settings&quot;,content:&quot;browse&quot;,searchable:true,filterable:false,uploads:true,sortable:true},initialize:function(){if(!this.get(&quot;selection&quot;)){this.set(&quot;selection&quot;,new f.model.Selection(null,{multiple:this.get(&quot;multiple&quot;)}))}if(!th
 is.get(&quot;library&quot;)){this.set(&quot;library&quot;,f.query())}if(!this.get(&quot;edge&quot;)){this.set(&quot;edge&quot;,120)}if(!this.get(&quot;gutter&quot;)){this.set(&quot;gutter&quot;,8)}this.resetDisplays();f.controller.State.prototype.initialize.apply(this,arguments)},activate:function(){var g=this.get(&quot;library&quot;),h=this.get(&quot;selection&quot;);this._excludeStateLibrary();this.buildComposite();this.on(&quot;change:library change:exclude&quot;,this.buildComposite,this);this.on(&quot;change:excludeState&quot;,this._excludeState,this);if(this.get(&quot;multiple&quot;)){wp.Uploader.queue.on(&quot;add&quot;,this.selectUpload,this)}h.on(&quot;add remove reset&quot;,this.refreshSelection,this);this.refresh();this.on(&quot;insert&quot;,this._insertDisplaySettings,this)},deactivate:function(){this.get(&quot;selection&quot;).off(null,null,this);wp.Uploader.queue.off(null,null,this);this.off(&quot;change:excludeState&quot;,this._excludeState,this);this.off(&quot
 ;change:library change:exclude&quot;,this.buildComposite,this);this.destroyComposite()},reset:function(){this.get(&quot;selection&quot;).reset();this.resetDisplays()},refresh:function(){this.content();this.refreshSelection()},resetDisplays:function(){this._displays=[];this._defaultDisplaySettings={align:getUserSetting(&quot;align&quot;,&quot;none&quot;),size:getUserSetting(&quot;imgsize&quot;,&quot;medium&quot;),link:getUserSetting(&quot;urlbutton&quot;,&quot;post&quot;)}},display:function(h){var g=this._displays;if(!g[h.cid]){g[h.cid]=new Backbone.Model(this._defaultDisplaySettings)}return g[h.cid]},_insertDisplaySettings:function(){var g=this.get(&quot;selection&quot;),h;if(g.length!==1){return}h=this.display(g.first()).toJSON();setUserSetting(&quot;align&quot;,h.align);setUserSetting(&quot;imgsize&quot;,h.size);setUserSetting(&quot;urlbutton&quot;,h.link)},refreshSelection:function(){var g=this.get(&quot;selection&quot;),h=this.frame.content.mode();this.frame.toolbar.view
 ().refresh();this.trigger(&quot;refresh:selection&quot;,this,g);if(!g.length&amp;&amp;&quot;browse&quot;!==h&amp;&amp;&quot;upload&quot;!==h){this.content()}},selectUpload:function(g){this.get(&quot;selection&quot;).add(g)},buildComposite:function(){var h=this.get(&quot;_library&quot;),g=this.get(&quot;exclude&quot;),i;this.destroyComposite();if(!this.get(&quot;exclude&quot;)){return}if(!h){this.set(&quot;_library&quot;,h=this.get(&quot;library&quot;))}i=new f.model.Attachments(null,{props:_.pick(h.props.toJSON(),&quot;order&quot;,&quot;orderby&quot;)});i.validator=function(j){return !!h.getByCid(j.cid)&amp;&amp;!g.getByCid(j.cid)};i.mirror(h).observe(g);this.set(&quot;library&quot;,i)},destroyComposite:function(){var h=this.get(&quot;library&quot;),g=this.get(&quot;_library&quot;);if(!g){return}h.unobserve();this.set(&quot;library&quot;,g);this.unset(&quot;_library&quot;)},_excludeState:function(){var h=this.get(&quot;excludeState&quot;),g=this.previous(&quot;excludeState&q
 uot;);if(g){this.frame.state(g).off(&quot;change:library&quot;,this._excludeStateLibrary,this)}if(h){this.frame.state(h).on(&quot;change:library&quot;,this._excludeStateLibrary,this)}},_excludeStateLibrary:function(){var g=this.get(&quot;excludeState&quot;);if(!g){return}this.set(&quot;exclude&quot;,this.frame.state(g).get(&quot;library&quot;))}});f.controller.Upload=f.controller.State.extend({defaults:_.defaults({id:&quot;upload&quot;,content:&quot;upload&quot;,toolbar:&quot;empty&quot;,uploads:true,libraryState:&quot;library&quot;},f.controller.State.prototype.defaults),initialize:function(){f.controller.State.prototype.initialize.apply(this,arguments)},activate:function(){wp.Uploader.queue.on(&quot;add&quot;,this.uploading,this);f.controller.State.prototype.activate.apply(this,arguments)},deactivate:function(){wp.Uploader.queue.off(null,null,this);f.controller.State.prototype.deactivate.apply(this,arguments)},uploading:function(h){var g=this.get(&quot;libraryState&quot;);
 this.frame.state(g).get(&quot;selection&quot;).add(h);this.frame.setState(g)}});f.controller.Gallery=f.controller.Library.extend({defaults:{id:&quot;gallery-edit&quot;,multiple:false,describe:true,edge:199,editing:false,sortable:true,searchable:false,toolbar:&quot;gallery-edit&quot;,content:&quot;browse&quot;},initialize:function(){if(!this.get(&quot;library&quot;)){this.set(&quot;library&quot;,new f.model.Selection())}if(!this.get(&quot;AttachmentView&quot;)){this.set(&quot;AttachmentView&quot;,f.view.Attachment.EditLibrary)}f.controller.Library.prototype.initialize.apply(this,arguments)},activate:function(){var g=this.get(&quot;library&quot;);g.props.set(&quot;type&quot;,&quot;image&quot;);this.get(&quot;library&quot;).observe(wp.Uploader.queue);this.frame.content.on(&quot;activate:browse&quot;,this.gallerySettings,this);f.controller.Library.prototype.activate.apply(this,arguments)},deactivate:function(){this.get(&quot;library&quot;).unobserve(wp.Uploader.queue);this.frame
 .content.off(null,null,this);f.controller.Library.prototype.deactivate.apply(this,arguments)},gallerySettings:function(){var g=this.get(&quot;library&quot;),h;if(!g){return}g.gallery=g.gallery||new Backbone.Model();h=this.frame.content.view();h.sidebar.set({gallery:new f.view.Settings.Gallery({controller:this,model:g.gallery,priority:40})});h.toolbar.set(&quot;reverse&quot;,{text:b.reverseOrder,priority:80,click:function(){g.reset(g.toArray().reverse())}})}});f.controller.FeaturedImage=f.controller.Library.extend({defaults:_.defaults({id:&quot;featured-image&quot;,filterable:&quot;uploaded&quot;,multiple:false,menu:&quot;main&quot;,toolbar:&quot;featured-image&quot;},f.controller.Library.prototype.defaults),initialize:function(){var h,g;if(!this.get(&quot;library&quot;)){this.set(&quot;library&quot;,f.query({type:&quot;image&quot;}))}f.controller.Library.prototype.initialize.apply(this,arguments);h=this.get(&quot;library&quot;);g=h.comparator;h.comparator=function(j,i){var l
 =!!this.mirroring.getByCid(j.cid),k=!!this.mirroring.getByCid(i.cid);if(!l&amp;&amp;k){return -1}else{if(l&amp;&amp;!k){return 1}else{return g.apply(this,arguments)}}};h.observe(this.get(&quot;selection&quot;))},activate:function(){var g=this.get(&quot;selection&quot;),i=f.view.settings.post.featuredImageId,h;if(&quot;&quot;!==i&amp;&amp;-1!==i){h=d.get(i);h.fetch()}g.reset(h?[h]:[]);f.controller.Library.prototype.activate.apply(this,arguments)}});f.controller.Embed=f.controller.State.extend({defaults:{id:&quot;embed&quot;,url:&quot;&quot;,menu:&quot;main&quot;,content:&quot;embed&quot;,toolbar:&quot;main-embed&quot;,type:&quot;link&quot;},sensitivity:200,initialize:function(){this.debouncedScan=_.debounce(_.bind(this.scan,this),this.sensitivity);this.on(&quot;change:url&quot;,this.debouncedScan,this);this.on(&quot;scan&quot;,this.scanImage,this);f.controller.State.prototype.initialize.apply(this,arguments)},scan:function(){var g={type:&quot;link&quot;};this.trigger(&quot;sc
 an&quot;,g);this.set(g)},scanImage:function(g){var k=this.frame,i=this,h=this.get(&quot;url&quot;),j=new Image();j.onload=function(){if(i!==k.state()||h!==i.get(&quot;url&quot;)){return}i.set({type:&quot;image&quot;,width:j.width,height:j.height})};j.src=h},reset:function(){_.each(_.difference(_.keys(this.attributes),_.keys(this.defaults)),function(g){this.unset(g)},this);this.set(&quot;url&quot;,&quot;&quot;);if(this.id===this.frame.state().id){this.frame.toolbar.view().refresh()}}});f.Views=function(h,g){this.view=h;this._views=_.isArray(g)?{&quot;&quot;:g}:g||{}};f.Views.extend=Backbone.Model.extend;_.extend(f.Views.prototype,{all:function(){return _.flatten(this._views)},get:function(g){g=g||&quot;&quot;;return this._views[g]},first:function(g){var h=this.get(g);return h&amp;&amp;h.length?h[0]:null},set:function(g,h,i){var k,j;if(!_.isString(g)){i=h;h=g;g=&quot;&quot;}i=i||{};h=_.isArray(h)?h:[h];k=this.get(g);j=h;if(k){if(i.add){if(_.isUndefined(i.at)){j=k.concat(h)}els
 e{j=k;j.splice.apply(j,[i.at,0].concat(h))}}else{_.each(j,function(l){l.__detach=true});_.each(k,function(l){if(l.__detach){l.$el.detach()}else{l.dispose()}});_.each(j,function(l){delete l.__detach})}}this._views[g]=j;_.each(h,function(n){var l=n.Views||f.Views,m=n.views=n.views||new l(n);m.parent=this.view;m.selector=g},this);if(!i.silent){this._attach(g,h,_.extend({ready:this._isReady()},i))}return this},add:function(g,h,i){if(!_.isString(g)){i=h;h=g;g=&quot;&quot;}return this.set(g,h,_.extend({add:true},i))},unset:function(g,h,i){var j;if(!_.isString(g)){i=h;h=g;g=&quot;&quot;}h=h||[];if(j=this.get(g)){h=_.isArray(h)?h:[h];this._views[g]=h.length?_.difference(j,h):[]}if(!i||!i.silent){_.invoke(h,&quot;dispose&quot;)}return this},detach:function(){e(_.pluck(this.all(),&quot;el&quot;)).detach();return this},render:function(){var g={ready:this._isReady()};_.each(this._views,function(i,h){this._attach(h,i,g)},this);this.rendered=true;return this},dispose:function(g){if(!g||!g
 .silent){if(this.parent&amp;&amp;this.parent.views){this.parent.views.unset(this.selector,this.view,{silent:true})}delete this.parent;delete this.selector}_.invoke(this.all(),&quot;dispose&quot;);this._views=[];return this},replace:function(g,h){g.html(h);return this},insert:function(h,k,j){var g=j&amp;&amp;j.at,i;if(_.isNumber(g)&amp;&amp;(i=h.children()).length&gt;g){i.eq(g).before(k)}else{h.append(k)}return this},ready:function(){this.view.trigger(&quot;ready&quot;);_.chain(this.all()).map(function(g){return g.views}).flatten().where({attached:true}).invoke(&quot;ready&quot;)},_attach:function(g,h,i){var k=g?this.view.$(g):this.view.$el,j;if(!k.length){return this}j=_.chain(h).pluck(&quot;views&quot;).flatten().value();_.each(j,function(l){if(l.rendered){return}l.view.render();l.rendered=true},this);this[i.add?&quot;insert&quot;:&quot;replace&quot;](k,_.pluck(h,&quot;el&quot;),i);_.each(j,function(l){l.attached=true;if(i.ready){l.ready()}},this);return this},_isReady:func
 tion(){var g=this.view.el;while(g){if(g===document.body){return true}g=g.parentNode}return false}});f.View=Backbone.View.extend({Views:f.Views,constructor:function(){this.views=new this.Views(this,this.views);this.on(&quot;ready&quot;,this.ready,this);Backbone.View.apply(this,arguments)},dispose:function(){this.undelegateEvents();if(this.model&amp;&amp;this.model.off){this.model.off(null,null,this)}if(this.collection&amp;&amp;this.collection.off){this.collection.off(null,null,this)}if(this.controller&amp;&amp;this.controller.off){this.controller.off(null,null,this)}if(this.views){this.views.dispose()}return this},remove:function(){this.dispose();return Backbone.View.prototype.remove.apply(this,arguments)},render:function(){var g;if(this.prepare){g=this.prepare()}this.views.detach();if(this.template){g=g||{};this.trigger(&quot;prepare&quot;,g);this.$el.html(this.template(g))}this.views.render();return this},prepare:function(){return this.options},ready:function(){}});f.view.F
 rame=f.View.extend({initialize:function(){this._createRegions();this._createStates()},_createRegions:function(){this.regions=this.regions?this.regions.slice():[];_.each(this.regions,function(g){this[g]=new f.controller.Region({controller:this,id:g,selector:&quot;.media-frame-&quot;+g})},this)},_createStates:function(){this.states=new Backbone.Collection(null,{model:f.controller.State});this.states.on(&quot;add&quot;,function(g){g.frame=this},this)},reset:function(){this.states.invoke(&quot;trigger&quot;,&quot;reset&quot;);return this}});_.extend(f.view.Frame.prototype,f.controller.StateMachine.prototype);f.view.MediaFrame=f.view.Frame.extend({className:&quot;media-frame&quot;,template:f.template(&quot;media-frame&quot;),regions:[&quot;menu&quot;,&quot;content&quot;,&quot;toolbar&quot;],initialize:function(){f.view.Frame.prototype.initialize.apply(this,arguments);_.defaults(this.options,{title:&quot;&quot;,modal:true,uploader:true});this.$el.addClass(&quot;wp-core-ui&quot;);i
 f(this.options.modal){this.modal=new f.view.Modal({controller:this,title:this.options.title});this.modal.content(this)}if(wp.Uploader.limitExceeded||!wp.Uploader.browser.supported){this.options.uploader=false}if(this.options.uploader){this.uploader=new f.view.UploaderWindow({controller:this,uploader:{dropzone:this.modal?this.modal.$el:this.$el,container:this.$el}});this.views.set(&quot;.media-frame-uploader&quot;,this.uploader)}this.on(&quot;attach&quot;,_.bind(this.views.ready,this.views),this)},render:function(){if(!this.state()&amp;&amp;this.options.state){this.setState(this.options.state)}return f.view.Frame.prototype.render.apply(this,arguments)},createIframeStates:function(g){var j=f.view.settings,i=j.tabs,k=j.tabUrl,h;if(!i||!k){return}h=e(&quot;#post_ID&quot;);if(h.length){k+=&quot;&amp;post_id=&quot;+h.val()}_.each(i,function(m,n){var l=this.state(&quot;iframe:&quot;+n).set(_.defaults({tab:n,src:k+&quot;&amp;tab=&quot;+n,title:m,content:&quot;iframe&quot;,menu:&quot
 ;main&quot;},g))},this);this.content.on(&quot;activate:iframe&quot;,this.iframeContent,this);this.menu.on(&quot;activate:main&quot;,this.iframeMenu,this);this.on(&quot;open&quot;,this.hijackThickbox,this);this.on(&quot;close&quot;,this.restoreThickbox,this)},iframeContent:function(){this.$el.addClass(&quot;hide-toolbar&quot;);this.content.view(new f.view.Iframe({controller:this}).render())},iframeMenu:function(){var g={};_.each(f.view.settings.tabs,function(h,i){g[&quot;iframe:&quot;+i]={text:this.state(&quot;iframe:&quot;+i).get(&quot;title&quot;),priority:200}},this);this.menu.view().set(g)},hijackThickbox:function(){var g=this;if(!window.tb_remove||this._tb_remove){return}this._tb_remove=window.tb_remove;window.tb_remove=function(){g.close();g.reset();g.setState(g.options.state);g._tb_remove.call(window)}},restoreThickbox:function(){if(!this._tb_remove){return}window.tb_remove=this._tb_remove;delete this._tb_remove}});_.each([&quot;open&quot;,&quot;close&quot;,&quot;attac
 h&quot;,&quot;detach&quot;,&quot;escape&quot;],function(g){f.view.MediaFrame.prototype[g]=function(h){if(this.modal){this.modal[g].apply(this.modal,arguments)}return this}});f.view.MediaFrame.Select=f.view.MediaFrame.extend({initialize:function(){f.view.MediaFrame.prototype.initialize.apply(this,arguments);_.defaults(this.options,{selection:[],library:{},multiple:false});this.createSelection();this.createStates();this.bindHandlers()},createSelection:function(){var g=this,h=this.options.selection;if(!(h instanceof f.model.Selection)){this.options.selection=new f.model.Selection(h,{multiple:this.options.multiple})}},createStates:function(){var g=this.options;this.states.add([new f.controller.Library({selection:g.selection,library:f.query(g.library),multiple:this.options.multiple,menu:&quot;main&quot;,toolbar:&quot;select&quot;}),new f.controller.Upload({menu:&quot;main&quot;})])},bindHandlers:function(){this.menu.on(&quot;activate:main&quot;,this.mainMenu,this);this.content.on
 (&quot;activate:browse&quot;,this.browseContent,this);this.content.on(&quot;activate:upload&quot;,this.uploadContent,this);this.toolbar.on(&quot;activate:select&quot;,this.selectToolbar,this);this.on(&quot;refresh:selection&quot;,this.refreshSelectToolbar,this)},mainMenu:function(g){this.menu.view(new f.view.Menu({controller:this,silent:g&amp;&amp;g.silent,views:{upload:{text:b.uploadFilesTitle,priority:20},library:{text:b.mediaLibraryTitle,priority:40}}}))},browseContent:function(){var g=this.state();this.$el.removeClass(&quot;hide-toolbar&quot;);this.content.view(new f.view.AttachmentsBrowser({controller:this,collection:g.get(&quot;library&quot;),selection:g.get(&quot;selection&quot;),model:g,sortable:g.get(&quot;sortable&quot;),search:g.get(&quot;searchable&quot;),uploads:g.get(&quot;uploads&quot;),filters:g.get(&quot;filterable&quot;),display:g.get(&quot;displaySettings&quot;),AttachmentView:g.get(&quot;AttachmentView&quot;)}))},uploadContent:function(){this.$el.addClass
 (&quot;hide-toolbar&quot;);this.content.view(new f.view.UploaderInline({controller:this}))},selectToolbar:function(g){g=_.defaults(g||{},{event:&quot;select&quot;,silent:false,state:false});this.toolbar.view(new f.view.Toolbar({controller:this,silent:g.silent,items:{select:{style:&quot;primary&quot;,text:b.select,priority:80,click:function(){var h=this.controller;h.close();h.state().trigger(g.event);h.reset();if(g.state){h.setState(g.state)}}}}}))},refreshSelectToolbar:function(){var g=this.state().get(&quot;selection&quot;);if(!g||&quot;select&quot;!==this.toolbar.mode()){return}this.toolbar.view().get(&quot;select&quot;).model.set(&quot;disabled&quot;,!g.length)}});f.view.MediaFrame.Post=f.view.MediaFrame.Select.extend({initialize:function(){_.defaults(this.options,{multiple:true,editing:false});f.view.MediaFrame.Select.prototype.initialize.apply(this,arguments);this.createIframeStates()},createStates:function(){var g=this.options;this.states.add([new f.controller.Library(
 {selection:g.selection,library:f.query(g.library),editable:true,filterable:&quot;all&quot;,multiple:this.options.multiple,menu:&quot;main&quot;,displaySettings:true,displayUserSettings:true}),new f.controller.Upload({menu:&quot;main&quot;}),new f.controller.Embed(),new f.controller.Gallery({library:g.selection,editing:g.editing,menu:&quot;gallery&quot;}),new f.controller.Library({id:&quot;gallery-library&quot;,library:f.query({type:&quot;image&quot;}),filterable:&quot;uploaded&quot;,multiple:true,menu:&quot;gallery&quot;,toolbar:&quot;gallery-add&quot;,excludeState:&quot;gallery-edit&quot;}),new f.controller.Upload({id:&quot;gallery-upload&quot;,menu:&quot;gallery&quot;,libraryState:&quot;gallery-edit&quot;})]);if(f.view.settings.post.featuredImageId){this.states.add(new f.controller.FeaturedImage({controller:this,menu:&quot;main&quot;}))}},bindHandlers:function(){f.view.MediaFrame.Select.prototype.bindHandlers.apply(this,arguments);var g={menu:{gallery:&quot;galleryMenu&quo
 t;},content:{embed:&quot;embedContent&quot;,&quot;edit-selection&quot;:&quot;editSelectionContent&quot;},toolbar:{&quot;main-attachments&quot;:&quot;mainAttachmentsToolbar&quot;,&quot;main-embed&quot;:&quot;mainEmbedToolbar&quot;,&quot;featured-image&quot;:&quot;featuredImageToolbar&quot;,&quot;gallery-edit&quot;:&quot;galleryEditToolbar&quot;,&quot;gallery-add&quot;:&quot;galleryAddToolbar&quot;}};_.each(g,function(i,h){_.each(i,function(k,j){this[h].on(&quot;activate:&quot;+j,this[k],this)},this)},this)},mainMenu:function(){f.view.MediaFrame.Select.prototype.mainMenu.call(this,{silent:true});this.menu.view().set({&quot;library-separator&quot;:new f.View({className:&quot;separator&quot;,priority:60}),embed:{text:b.fromUrlTitle,priority:80}});if(f.view.settings.post.featuredImageId){this.menu.view().set(&quot;featured-image&quot;,{text:b.featuredImageTitle,priority:100})}},galleryMenu:function(){var g=this.lastState(),h=g&amp;&amp;g.id,i=this;this.menu.view(new f.view.Menu({
 controller:this,views:{cancel:{text:b.cancelGalleryTitle,priority:20,click:function(){if(h){i.setState(h)}else{i.close()}}},separateCancel:new f.View({className:&quot;separator&quot;,priority:40}),&quot;gallery-edit&quot;:{text:b.editGalleryTitle,priority:60},&quot;gallery-upload&quot;:{text:b.uploadImagesTitle,priority:80},&quot;gallery-library&quot;:{text:b.mediaLibraryTitle,priority:100}}}))},embedContent:function(){var g=new f.view.Embed({controller:this,model:this.state()}).render();this.content.view(g);g.url.focus()},editSelectionContent:function(){var i=this.state(),h=i.get(&quot;selection&quot;),g;g=new f.view.AttachmentsBrowser({controller:this,collection:h,selection:h,model:i,sortable:true,search:false,AttachmentView:f.view.Attachment.EditSelection}).render();g.toolbar.set(&quot;backToLibrary&quot;,{text:b.returnToLibrary,priority:-100,click:function(){this.controller.content.mode(&quot;browse&quot;)}});this.content.view(g)},onSidebarGallerySettings:function(h){var
  g=this.state().get(&quot;library&quot;);if(!g){return}g.gallery=g.gallery||new Backbone.Model();this.sidebar.view().set({gallery:new f.view.Settings.Gallery({controller:this,model:g.gallery,priority:40}).render()},h)},mainAttachmentsToolbar:function(){this.toolbar.view(new f.view.Toolbar.Insert({controller:this,editable:this.state().get(&quot;editable&quot;)}))},featuredImageToolbar:function(){this.toolbar.view(new f.view.Toolbar.Select({controller:this,text:b.setFeaturedImage,state:this.options.state||&quot;upload&quot;}))},mainEmbedToolbar:function(){this.toolbar.view(new f.view.Toolbar.Embed({controller:this}));this.$el.removeClass(&quot;hide-toolbar&quot;)},galleryEditToolbar:function(){var g=this.state().get(&quot;editing&quot;);this.toolbar.view(new f.view.Toolbar({controller:this,items:{insert:{style:&quot;primary&quot;,text:g?b.updateGallery:b.insertGallery,priority:80,click:function(){var h=this.controller,i=h.state();h.close();i.trigger(&quot;update&quot;,i.get(&q
 uot;library&quot;));h.reset();h.setState(&quot;upload&quot;)}}}}))},galleryAddToolbar:function(){this.toolbar.view(new f.view.Toolbar({controller:this,items:{insert:{style:&quot;primary&quot;,text:b.addToGallery,priority:80,click:function(){var g=this.controller,i=g.state(),h=g.state(&quot;gallery-edit&quot;);h.get(&quot;library&quot;).add(i.get(&quot;selection&quot;).models);i.trigger(&quot;reset&quot;);g.state(&quot;gallery-edit&quot;)}}}}))}});f.view.Modal=f.View.extend({tagName:&quot;div&quot;,template:f.template(&quot;media-modal&quot;),attributes:{tabindex:0},events:{&quot;click .media-modal-backdrop, .media-modal-close&quot;:&quot;escapeHandler&quot;,keydown:&quot;keydown&quot;},initialize:function(){this.controller=this.options.controller;_.defaults(this.options,{container:document.body,title:&quot;&quot;,propagate:true})},prepare:function(){return{title:this.options.title}},attach:function(){if(this.views.attached){return this}if(!this.views.rendered){this.render()}
 this.$el.appendTo(this.options.container);this.views.attached=true;this.views.ready();return this.propagate(&quot;attach&quot;)},detach:function(){if(this.$el.is(&quot;:visible&quot;)){this.close()}this.$el.detach();this.views.attached=false;return this.propagate(&quot;detach&quot;)},open:function(){if(this.$el.is(&quot;:visible&quot;)){return this}if(!this.views.attached){this.attach()}this.$el.show().focus();return this.propagate(&quot;open&quot;)},close:function(g){if(!this.views.attached||!this.$el.is(&quot;:visible&quot;)){return this}this.$el.hide();this.propagate(&quot;close&quot;);if(g&amp;&amp;g.escape){this.propagate(&quot;escape&quot;)}return this},escape:function(){return this.close({escape:true})},escapeHandler:function(g){g.preventDefault();this.escape()},content:function(g){this.views.set(&quot;.media-modal-content&quot;,g);return this},propagate:function(g){this.trigger(g);if(this.options.propagate){this.controller.trigger(g)}return this},keydown:function(g){
 if(27===g.which){g.preventDefault();this.escape();return}}});f.view.UploaderWindow=f.View.extend({tagName:&quot;div&quot;,className:&quot;uploader-window&quot;,template:f.template(&quot;uploader-window&quot;),initialize:function(){var g;this.controller=this.options.controller;this.$browser=e('&lt;a href=&quot;#&quot; class=&quot;browser&quot; /&gt;').hide().appendTo(&quot;body&quot;);g=this.options.uploader=_.defaults(this.options.uploader||{},{dropzone:this.$el,browser:this.$browser,params:{}});if(g.dropzone&amp;&amp;!(g.dropzone instanceof e)){g.dropzone=e(g.dropzone)}this.controller.on(&quot;activate&quot;,this.refresh,this)},refresh:function(){if(this.uploader){this.uploader.refresh()}},ready:function(){var h=f.view.settings.post.id,g;if(this.uploader){return}if(h){this.options.uploader.params.post_id=h}this.uploader=new wp.Uploader(this.options.uploader);g=this.uploader.dropzone;g.on(&quot;dropzone:enter&quot;,_.bind(this.show,this));g.on(&quot;dropzone:leave&quot;,_.bi
 nd(this.hide,this))},show:function(){var g=this.$el.show();_.defer(function(){g.css({opacity:1})})},hide:function(){var g=this.$el.css({opacity:0});f.transition(g).done(function(){if(&quot;0&quot;===g.css(&quot;opacity&quot;)){g.hide()}})}});f.view.UploaderInline=f.View.extend({tagName:&quot;div&quot;,className:&quot;uploader-inline&quot;,template:f.template(&quot;uploader-inline&quot;),initialize:function(){this.controller=this.options.controller;if(!this.options.$browser&amp;&amp;this.controller.uploader){this.options.$browser=this.controller.uploader.$browser}if(_.isUndefined(this.options.postId)){this.options.postId=f.view.settings.post.id}this.views.set(&quot;.upload-inline-status&quot;,new f.view.UploaderStatus({controller:this.controller}))},ready:function(){var g=this.options.$browser,h;if(this.controller.uploader){h=this.$(&quot;.browser&quot;);if(h[0]===g[0]){return}g.detach().text(h.text());g[0].className=h[0].className;h.replaceWith(g.show())}return this}});f.vie
 w.UploaderStatus=f.View.extend({className:&quot;media-uploader-status&quot;,template:f.template(&quot;uploader-status&quot;),events:{&quot;click .upload-dismiss-errors&quot;:&quot;dismiss&quot;},initialize:function(){this.controller=this.options.controller;this.queue=wp.Uploader.queue;this.queue.on(&quot;add remove reset&quot;,this.visibility,this);this.queue.on(&quot;add remove reset change:percent&quot;,this.progress,this);this.queue.on(&quot;add remove reset change:uploading&quot;,this.info,this);this.errors=wp.Uploader.errors;this.errors.reset();this.errors.on(&quot;add remove reset&quot;,this.visibility,this);this.errors.on(&quot;add&quot;,this.error,this)},dispose:function(){wp.Uploader.queue.off(null,null,this);f.View.prototype.dispose.apply(this,arguments);return this},visibility:function(){this.$el.toggleClass(&quot;uploading&quot;,!!this.queue.length);this.$el.toggleClass(&quot;errors&quot;,!!this.errors.length);this.$el.toggle(!!this.queue.length||!!this.errors.le
 ngth)},ready:function(){_.each({&quot;$bar&quot;:&quot;.media-progress-bar div&quot;,&quot;$index&quot;:&quot;.upload-index&quot;,&quot;$total&quot;:&quot;.upload-total&quot;,&quot;$filename&quot;:&quot;.upload-filename&quot;},function(g,h){this[h]=this.$(g)},this);this.visibility();this.progress();this.info()},progress:function(){var g=this.queue,i=this.$bar,h=0;if(!i||!g.length){return}i.width((g.reduce(function(j,l){if(!l.get(&quot;uploading&quot;)){return j+100}var k=l.get(&quot;percent&quot;);return j+(_.isNumber(k)?k:100)},0)/g.length)+&quot;%&quot;)},info:function(){var g=this.queue,h=0,i;if(!g.length){return}i=this.queue.find(function(k,j){h=j;return k.get(&quot;uploading&quot;)});this.$index.text(h+1);this.$total.text(g.length);this.$filename.html(i?this.filename(i.get(&quot;filename&quot;)):&quot;&quot;)},filename:function(g){return f.truncate(_.escape(g),24)},error:function(g){this.views.add(&quot;.upload-errors&quot;,new f.view.UploaderStatusError({filename:this.
 filename(g.get(&quot;file&quot;).name),message:g.get(&quot;message&quot;)}),{at:0})},dismiss:function(g){var h=this.views.get(&quot;.upload-errors&quot;);g.preventDefault();if(h){_.invoke(h,&quot;remove&quot;)}wp.Uploader.errors.reset()}});f.view.UploaderStatusError=f.View.extend({className:&quot;upload-error&quot;,template:f.template(&quot;uploader-status-error&quot;)});f.view.Toolbar=f.View.extend({tagName:&quot;div&quot;,className:&quot;media-toolbar&quot;,initialize:function(){this.controller=this.options.controller;this._views={};this.$primary=e('&lt;div class=&quot;media-toolbar-primary&quot; /&gt;').prependTo(this.$el);this.$secondary=e('&lt;div class=&quot;media-toolbar-secondary&quot; /&gt;').prependTo(this.$el);if(this.options.items){this.set(this.options.items,{silent:true})}if(!this.options.silent){this.render()}},destroy:function(){this.remove();if(this.model){this.model.off(null,null,this)}if(this.collection){this.collection.off(null,null,this)}this.controller.
 off(null,null,this);_.each(this._views,function(g){if(g.destroy){g.destroy()}})},render:function(){var g=_.chain(this._views).sortBy(function(h){return h.options.priority||10}).groupBy(function(h){return(h.options.priority||10)&gt;0?&quot;primary&quot;:&quot;secondary&quot;}).value();e(_.pluck(this._views,&quot;el&quot;)).detach();this.$primary.html(_.pluck(g.primary||[],&quot;el&quot;));this.$secondary.html(_.pluck(g.secondary||[],&quot;el&quot;));this.refresh();return this},set:function(i,g,h){h=h||{};if(_.isObject(i)){_.each(i,function(j,k){this.set(k,j,{silent:true})},this)}else{if(!(g instanceof Backbone.View)){g.classes=[&quot;media-button-&quot;+i].concat(g.classes||[]);g=new f.view.Button(g).render()}g.controller=g.controller||this.controller;this._views[i]=g}if(!h.silent){this.render()}return this},get:function(g){return this._views[g]},unset:function(h,g){delete this._views[h];if(!g||!g.silent){this.render()}return this},refresh:function(){}});f.view.Toolbar.Select
 =f.view.Toolbar.extend({initialize:function(){var h=this.options,g=h.controller,i=g.state().get(&quot;selection&quot;);_.bindAll(this,&quot;clickSelect&quot;);_.defaults(h,{event:&quot;select&quot;,state:false,reset:true,close:true,text:b.select});h.items=_.defaults(h.items||{},{select:{style:&quot;primary&quot;,text:h.text,priority:80,click:this.clickSelect}});f.view.Toolbar.prototype.initialize.apply(this,arguments)},clickSelect:function(){var h=this.options,g=this.controller;if(h.close){g.close()}if(h.event){g.state().trigger(h.event)}if(h.reset){g.reset()}if(h.state){g.setState(h.state)}}});f.view.Toolbar.Embed=f.view.Toolbar.Select.extend({initialize:function(){var g=this.options.controller;_.defaults(this.options,{text:b.insertIntoPost});f.view.Toolbar.Select.prototype.initialize.apply(this,arguments);g.on(&quot;change:url&quot;,this.refresh,this)},refresh:function(){var g=this.controller.state().get(&quot;url&quot;);this.get(&quot;select&quot;).model.set(&quot;disable
 d&quot;,!g||/^https?:\/\/$/.test(g))}});f.view.Toolbar.Insert=f.view.Toolbar.extend({initialize:function(){var g=this.options.controller,i=g.state().get(&quot;selection&quot;),h;h=function(k,j){return function(){var l=this.controller,m=l.state().get(&quot;selection&quot;),n=l.state(k),o=j?j(m):m.models;n.set(&quot;library&quot;,new f.model.Selection(o,{props:m.props.toJSON(),multiple:true}));this.controller.setState(k)}};this.options.items=_.defaults(this.options.items||{},{selection:new f.view.Selection({controller:g,collection:i,priority:-40,editable:this.options.editable&amp;&amp;function(){this.controller.content.mode(&quot;edit-selection&quot;)}}).render(),insert:{style:&quot;primary&quot;,priority:80,text:b.insertIntoPost,click:function(){g.close();g.state().trigger(&quot;insert&quot;,i).reset()}},gallery:{text:b.createNewGallery,priority:40,click:h(&quot;gallery-edit&quot;,function(j){return j.where({type:&quot;image&quot;})})}});f.view.Toolbar.prototype.initialize.ap
 ply(this,arguments)},refresh:function(){var g=this.controller.state().get(&quot;selection&quot;),h=g.length;this.get(&quot;insert&quot;).model.set(&quot;disabled&quot;,!g.length);this.get(&quot;gallery&quot;).$el.toggle(h&gt;1&amp;&amp;g.any(function(i){return&quot;image&quot;===i.get(&quot;type&quot;)}))}});f.view.Button=f.View.extend({tagName:&quot;a&quot;,className:&quot;media-button&quot;,attributes:{href:&quot;#&quot;},events:{click:&quot;click&quot;},defaults:{text:&quot;&quot;,style:&quot;&quot;,size:&quot;large&quot;,disabled:false},initialize:function(){this.model=new Backbone.Model(this.defaults);_.each(this.defaults,function(i,g){var h=this.options[g];if(_.isUndefined(h)){return}this.model.set(g,h);delete this.options[g]},this);this.model.on(&quot;change&quot;,this.render,this)},render:function(){var h=[&quot;button&quot;,this.className],g=this.model.toJSON();if(g.style){h.push(&quot;button-&quot;+g.style)}if(g.size){h.push(&quot;button-&quot;+g.size)}h=_.uniq(h.c
 oncat(this.options.classes));this.el.className=h.join(&quot; &quot;);this.$el.attr(&quot;disabled&quot;,g.disabled);this.$el.text(this.model.get(&quot;text&quot;));return this},click:function(g){if(&quot;#&quot;===this.attributes.href){g.preventDefault()}if(this.options.click&amp;&amp;!this.model.get(&quot;disabled&quot;)){this.options.click.apply(this,arguments)}}});f.view.ButtonGroup=f.View.extend({tagName:&quot;div&quot;,className:&quot;button-group button-large media-button-group&quot;,initialize:function(){this.buttons=_.map(this.options.buttons||[],function(g){if(g instanceof Backbone.View){return g}else{return new f.view.Button(g).render()}});delete this.options.buttons;if(this.options.classes){this.$el.addClass(this.options.classes)}},render:function(){this.$el.html(e(_.pluck(this.buttons,&quot;el&quot;)).detach());return this}});f.view.PriorityList=f.View.extend({tagName:&quot;div&quot;,initialize:function(){this.controller=this.options.controller;this._views={};thi
 s.set(_.extend({},this._views,this.options.views),{silent:true});delete this.options.views;if(!this.options.silent){this.render()}},destroy:this.dispose,set:function(l,h,j){var k,g,i;j=j||{};if(_.isObject(l)){_.each(l,function(m,n){this.set(n,m)},this);return this}if(!(h instanceof Backbone.View)){h=this.toView(h,l,j)}h.controller=h.controller||this.controller;this.unset(l);k=h.options.priority||10;g=this.views.get()||[];_.find(g,function(n,m){if(n.options.priority&gt;k){i=m;return true}});this._views[l]=h;this.views.add(h,{at:_.isNumber(i)?i:g.length||0});return this},get:function(g){return this._views[g]},unset:function(h){var g=this.get(h);if(g){g.remove()}delete this._views[h];return this},toView:function(g){return new f.View(g)}});f.view.Menu=f.view.PriorityList.extend({tagName:&quot;ul&quot;,className:&quot;media-menu&quot;,toView:function(g,h){g=g||{};g.state=g.state||h;return new f.view.MenuItem(g).render()},select:function(h){var g=this.get(h);if(!g){return}this.des
 elect();g.$el.addClass(&quot;active&quot;)},deselect:function(){this.$el.children().removeClass(&quot;active&quot;)}});f.view.MenuItem=f.View.extend({tagName:&quot;li&quot;,className:&quot;media-menu-item&quot;,events:{click:&quot;click&quot;},click:function(){var g=this.options;if(g.click){g.click.call(this)}else{if(g.state){this.controller.setState(g.state)}}},render:function(){var g=this.options;if(g.text){this.$el.text(g.text)}else{if(g.html){this.$el.html(g.html)}}return this}});f.view.Sidebar=f.view.PriorityList.extend({className:&quot;media-sidebar&quot;});f.view.Attachment=f.View.extend({tagName:&quot;li&quot;,className:&quot;attachment&quot;,template:f.template(&quot;attachment&quot;),events:{&quot;click .attachment-preview&quot;:&quot;toggleSelection&quot;,&quot;change [data-setting]&quot;:&quot;updateSetting&quot;,&quot;change [data-setting] input&quot;:&quot;updateSetting&quot;,&quot;change [data-setting] select&quot;:&quot;updateSetting&quot;,&quot;change [data-
 setting] textarea&quot;:&quot;updateSetting&quot;,&quot;click .close&quot;:&quot;removeFromLibrary&quot;,&quot;click .check&quot;:&quot;removeFromSelection&quot;,&quot;click a&quot;:&quot;preventDefault&quot;},buttons:{},initialize:function(){var g=this.options.selection;this.controller=this.options.controller;this.model.on(&quot;change:sizes change:uploading change:caption change:title&quot;,this.render,this);this.model.on(&quot;change:percent&quot;,this.progress,this);this.model.on(&quot;add&quot;,this.select,this);this.model.on(&quot;remove&quot;,this.deselect,this);if(g){g.on(&quot;reset&quot;,this.updateSelect,this)}this.model.on(&quot;selection:single selection:unsingle&quot;,this.details,this);this.details(this.model,this.controller.state().get(&quot;selection&quot;))},dispose:function(){var g=this.options.selection;this.updateAll();if(g){g.off(null,null,this)}f.View.prototype.dispose.apply(this,arguments);return this},render:function(){var h=this.model.toJSON(),g=_.d
 efaults(this.model.toJSON(),{orientation:&quot;landscape&quot;,uploading:false,type:&quot;&quot;,subtype:&quot;&quot;,icon:&quot;&quot;,filename:&quot;&quot;,caption:&quot;&quot;,title:&quot;&quot;,dateFormatted:&quot;&quot;,width:&quot;&quot;,height:&quot;&quot;,compat:false,alt:&quot;&quot;});g.buttons=this.buttons;g.describe=this.controller.state().get(&quot;describe&quot;);if(&quot;image&quot;===g.type){g.size=this.imageSize()}this.views.detach();this.$el.html(this.template(g));this.$el.toggleClass(&quot;uploading&quot;,g.uploading);if(g.uploading){this.$bar=this.$(&quot;.media-progress-bar div&quot;)}else{delete this.$bar}this.updateSelect();this.updateSave();this.views.render();return this},progress:function(){if(this.$bar&amp;&amp;this.$bar.length){this.$bar.width(this.model.get(&quot;percent&quot;)+&quot;%&quot;)}},toggleSelection:function(i){var h=this.options.selection,g=this.model;if(!h){return}if(this.selected()){h[h.single()===g?&quot;remove&quot;:&quot;single&q
 uot;](g)}else{h.add(g).single(g)}},updateSelect:function(){this[this.selected()?&quot;select&quot;:&quot;deselect&quot;]()},selected:function(){var g=this.options.selection;if(g){return !!g.getByCid(this.model.cid)}},select:function(g,i){var h=this.options.selection;if(!h||(i&amp;&amp;i!==h)){return}this.$el.addClass(&quot;selected&quot;)},deselect:function(g,i){var h=this.options.selection;if(!h||(i&amp;&amp;i!==h)){return}this.$el.removeClass(&quot;selected&quot;)},details:function(g,j){var i=this.options.selection,h;if(i!==j){return}h=i.single();this.$el.toggleClass(&quot;details&quot;,h===this.model)},preventDefault:function(g){g.preventDefault()},imageSize:function(g){var h=this.model.get(&quot;sizes&quot;);g=g||&quot;medium&quot;;if(h&amp;&amp;h[g]){return _.clone(h[g])}else{return{url:this.model.get(&quot;url&quot;),width:this.model.get(&quot;width&quot;),height:this.model.get(&quot;height&quot;),orientation:this.model.get(&quot;orientation&quot;)}}},updateSetting:fun
 ction(i){var g=e(i.target).closest(&quot;[data-setting]&quot;),h,j;if(!g.length){return}h=g.data(&quot;setting&quot;);j=i.target.value;if(this.model.get(h)!==j){this.save(h,j)}},save:function(){var g=this,i=this._save=this._save||{status:&quot;ready&quot;},h=this.model.save.apply(this.model,arguments),j=i.requests?e.when(h,i.requests):h;if(i.savedTimer){clearTimeout(i.savedTimer)}this.updateSave(&quot;waiting&quot;);i.requests=j;j.done(function(){if(i.requests!==j){return}g.updateSave(&quot;complete&quot;);i.savedTimer=setTimeout(function(){g.updateSave(&quot;ready&quot;);delete i.savedTimer},2000)})},updateSave:function(g){var h=this._save=this._save||{status:&quot;ready&quot;};if(g&amp;&amp;g!==h.status){this.$el.removeClass(&quot;save-&quot;+h.status);h.status=g}this.$el.addClass(&quot;save-&quot;+h.status);return this},updateAll:function(){var h=this.$(&quot;[data-setting]&quot;),g=this.model,i;i=_.chain(h).map(function(k){var m=e(&quot;input, textarea, select, [value]&q
 uot;,k),j,l;if(!m.length){return}j=e(k).data(&quot;setting&quot;);l=m.val();if(g.get(j)!==l){return[j,l]}}).compact().object().value();if(!_.isEmpty(i)){g.save(i)}},removeFromLibrary:function(g){g.stopPropagation();this.collection.remove(this.model)},removeFromSelection:function(h){var g=this.options.selection;if(!g){return}h.stopPropagation();g.remove(this.model)}});f.view.Attachment.Library=f.view.Attachment.extend({buttons:{check:true}});f.view.Attachment.EditLibrary=f.view.Attachment.extend({buttons:{close:true}});f.view.Attachments=f.View.extend({tagName:&quot;ul&quot;,className:&quot;attachments&quot;,cssTemplate:f.template(&quot;attachments-css&quot;),events:{scroll:&quot;scroll&quot;},initialize:function(){this.controller=this.options.controller;this.el.id=_.uniqueId(&quot;__attachments-view-&quot;);_.defaults(this.options,{refreshSensitivity:200,refreshThreshold:3,AttachmentView:f.view.Attachment,sortable:false});this._viewsByCid={};this.collection.on(&quot;add&quot
 ;,function(i,g,h){this.views.add(this.createAttachmentView(i),{at:h.index})},this);this.collection.on(&quot;remove&quot;,function(j,g,i){var h=this._viewsByCid[j.cid];delete this._viewsByCid[j.cid];if(h){h.remove()}},this);this.collection.on(&quot;reset&quot;,this.render,this);this.scroll=_.chain(this.scroll).bind(this).throttle(this.options.refreshSensitivity).value();this.initSortable();_.bindAll(this,&quot;css&quot;);this.model.on(&quot;change:edge change:gutter&quot;,this.css,this);this._resizeCss=_.debounce(_.bind(this.css,this),this.refreshSensitivity);e(window).on(&quot;resize.attachments&quot;,this._resizeCss);this.css()},dispose:function(){this.collection.props.off(null,null,this);e(window).off(&quot;resize.attachments&quot;,this._resizeCss);f.View.prototype.dispose.apply(this,arguments)},css:function(){var g=e(&quot;#&quot;+this.el.id+&quot;-css&quot;);if(g.length){g.remove()}f.view.Attachments.$head().append(this.cssTemplate({id:this.el.id,edge:this.edge(),gutter:
 this.model.get(&quot;gutter&quot;)}))},edge:function(){var i=this.model.get(&quot;edge&quot;),j,h,g;if(!this.$el.is(&quot;:visible&quot;)){return i}j=this.model.get(&quot;gutter&quot;)*2;h=this.$el.width()-j;g=Math.ceil(h/(i+j));i=Math.floor((h-(g*j))/g);return i},initSortable:function(){var g=this.collection,h;if(!this.options.sortable||!e.fn.sortable){return}this.$el.sortable({disabled:!!g.comparator,containment:this.$el,tolerance:&quot;pointer&quot;,start:function(i,j){h=j.item.index()},update:function(k,l){var j=g.at(h),i=g.comparator;delete g.comparator;g.remove(j,{silent:true}).add(j,{at:l.item.index(),silent:true});g.comparator=i;g.saveMenuOrder()}});g.props.on(&quot;change:orderby&quot;,function(){this.$el.sortable(&quot;option&quot;,&quot;disabled&quot;,!!g.comparator)},this);this.collection.props.on(&quot;change:orderby&quot;,this.refreshSortable,this);this.refreshSortable()},refreshSortable:function(){if(!this.options.sortable||!e.fn.sortable){return}var i=this.co
 llection,h=i.props.get(&quot;orderby&quot;),g=&quot;menuOrder&quot;===h||!i.comparator;this.$el.sortable(&quot;option&quot;,&quot;disabled&quot;,!g)},createAttachmentView:function(h){var g=new this.options.AttachmentView({controller:this.controller,model:h,collection:this.collection,selection:this.options.selection});return this._viewsByCid[h.cid]=g},prepare:function(){if(this.collection.length){this.views.set(this.collection.map(this.createAttachmentView,this))}else{this.views.unset();this.collection.more().done(this.scroll)}},ready:function(){this.scroll()},scroll:function(g){if(!this.$el.is(&quot;:visible&quot;)){return}if(this.collection.hasMore()&amp;&amp;this.el.scrollHeight&lt;this.el.scrollTop+(this.el.clientHeight*this.options.refreshThreshold)){this.collection.more().done(this.scroll)}}},{$head:(function(){var g;return function(){return g=g||e(&quot;head&quot;)}}())});f.view.Search=f.View.extend({tagName:&quot;input&quot;,className:&quot;search&quot;,attributes:{ty
 pe:&quot;search&quot;,placeholder:b.search},events:{input:&quot;search&quot;,keyup:&quot;search&quot;,change:&quot;search&quot;,search:&quot;search&quot;},render:function(){this.el.value=this.model.escape(&quot;search&quot;);return this},search:function(g){if(g.target.value){this.model.set(&quot;search&quot;,g.target.value)}else{this.model.unset(&quot;search&quot;)}}});f.view.AttachmentFilters=f.View.extend({tagName:&quot;select&quot;,className:&quot;attachment-filters&quot;,events:{change:&quot;change&quot;},keys:[],initialize:function(){this.createFilters();this.$el.html(_.chain(this.filters).map(function(g,h){return{el:this.make(&quot;option&quot;,{value:h},g.text),priority:g.priority||50}},this).sortBy(&quot;priority&quot;).pluck(&quot;el&quot;).value());this.model.on(&quot;change&quot;,this.select,this);this.select()},createFilters:function(){this.filters={}},change:function(h){var g=this.filters[this.el.value];if(g){this.model.set(g.props)}},select:function(){var g=thi
 s.model,i=&quot;all&quot;,h=g.toJSON();_.find(this.filters,function(k,l){var j=_.all(k.props,function(n,m){return n===(_.isUndefined(h[m])?null:h[m])});if(j){return i=l}});this.$el.val(i)}});f.view.AttachmentFilters.Uploaded=f.view.AttachmentFilters.extend({createFilters:function(){this.filters={all:{text:b.allMediaItems,props:{uploadedTo:null,orderby:&quot;date&quot;,order:&quot;DESC&quot;},priority:10},uploaded:{text:b.uploadedToThisPost,props:{uploadedTo:f.view.settings.post.id,orderby:&quot;menuOrder&quot;,order:&quot;ASC&quot;},priority:20}}}});f.view.AttachmentFilters.All=f.view.AttachmentFilters.extend({createFilters:function(){var g={};_.each(f.view.settings.mimeTypes||{},function(i,h){g[h]={text:i,props:{type:h,uploadedTo:null,orderby:&quot;date&quot;,order:&quot;DESC&quot;}}});g.all={text:b.allMediaItems,props:{type:null,uploadedTo:null,orderby:&quot;date&quot;,order:&quot;DESC&quot;},priority:10};g.uploaded={text:b.uploadedToThisPost,props:{type:null,uploadedTo:f.
 view.settings.post.id,orderby:&quot;menuOrder&quot;,order:&quot;ASC&quot;},priority:20};this.filters=g}});f.view.AttachmentsBrowser=f.View.extend({tagName:&quot;div&quot;,className:&quot;attachments-browser&quot;,initialize:function(){this.controller=this.options.controller;_.defaults(this.options,{filters:false,search:true,uploads:false,display:false,AttachmentView:f.view.Attachment.Library});this.createToolbar();this.updateContent();this.createSidebar();this.collection.on(&quot;add remove reset&quot;,this.updateContent,this)},dispose:function(){this.options.selection.off(null,null,this);f.View.prototype.dispose.apply(this,arguments);return this},createToolbar:function(){var h,g;this.toolbar=new f.view.Toolbar({controller:this.controller});this.views.add(this.toolbar);h=this.options.filters;if(&quot;uploaded&quot;===h){g=f.view.AttachmentFilters.Uploaded}else{if(&quot;all&quot;===h){g=f.view.AttachmentFilters.All}}if(g){this.toolbar.set(&quot;filters&quot;,new g({controller
 :this.controller,model:this.collection.props,priority:-80}).render())}if(this.options.search){this.toolbar.set(&quot;search&quot;,new f.view.Search({controller:this.controller,model:this.collection.props,priority:60}).render())}if(this.options.sortable&amp;&amp;!this.options.filters){this.toolbar.set(&quot;dragInfo&quot;,new f.View({el:e('&lt;div class=&quot;instructions&quot;&gt;'+b.dragInfo+&quot;&lt;/div&gt;&quot;)[0],priority:-40}))}},updateContent:function(){var g=this;if(!this.attachments){this.createAttachments()}if(!this.collection.length){this.collection.more().done(function(){if(!g.collection.length){g.createUploader()}})}},removeContent:function(){_.each([&quot;attachments&quot;,&quot;uploader&quot;],function(g){if(this[g]){this[g].remove();delete this[g]}},this)},createUploader:function(){this.removeContent();this.uploader=new f.view.UploaderInline({controller:this.controller});this.views.add(this.uploader)},createAttachments:function(){this.removeContent();this.
 attachments=new f.view.Attachments({controller:this.controller,collection:this.collection,selection:this.options.selection,model:this.model,sortable:this.options.sortable,AttachmentView:this.options.AttachmentView});this.views.add(this.attachments)},createSidebar:function(){var g=this.options,h=g.selection,i=this.sidebar=new f.view.Sidebar({controller:this.controller});this.views.add(i);if(g.uploads&amp;&amp;this.controller.uploader){i.set(&quot;uploads&quot;,new f.view.UploaderStatus({controller:this.controller,priority:40}))}h.on(&quot;selection:single&quot;,this.createSingle,this);h.on(&quot;selection:unsingle&quot;,this.disposeSingle,this);if(h.single()){this.createSingle()}},createSingle:function(){var h=this.sidebar,i=this.options.selection.single(),g={};h.set(&quot;details&quot;,new f.view.Attachment.Details({controller:this.controller,model:i,priority:80}));h.set(&quot;compat&quot;,new f.view.AttachmentCompat({controller:this.controller,model:i,priority:120}));if(thi
 s.options.display){h.set(&quot;display&quot;,new f.view.Settings.AttachmentDisplay({controller:this.controller,model:this.model.display(i),attachment:i,priority:160,userSettings:this.model.get(&quot;displayUserSettings&quot;)}))}},disposeSingle:function(){var g=this.sidebar;g.unset(&quot;details&quot;);g.unset(&quot;compat&quot;);g.unset(&quot;display&quot;)}});f.view.SelectionPreview=f.View.extend({tagName:&quot;div&quot;,className:&quot;selection-preview&quot;,template:f.template(&quot;media-selection-preview&quot;),events:{&quot;click .clear-selection&quot;:&quot;clear&quot;},initialize:function(){_.defaults(this.options,{clearable:true});this.controller=this.options.controller;this.collection.on(&quot;add change:url remove&quot;,this.render,this);this.render()},render:function(){var g=_.clone(this.options),j,i,h;if(!this.collection.length){this.$el.empty();return this}g.count=this.collection.length;j=this.collection.last();i=j.get(&quot;sizes&quot;);if(&quot;image&quot;=
 ==j.get(&quot;type&quot;)){g.thumbnail=(i&amp;&amp;i.thumbnail)?i.thumbnail.url:j.get(&quot;url&quot;)}else{g.thumbnail=j.get(&quot;icon&quot;)}this.$el.html(this.template(g));return this},clear:function(g){g.preventDefault();this.collection.reset()}});f.view.Selection=f.View.extend({tagName:&quot;div&quot;,className:&quot;media-selection&quot;,template:f.template(&quot;media-selection&quot;),events:{&quot;click .edit-selection&quot;:&quot;edit&quot;,&quot;click .clear-selection&quot;:&quot;clear&quot;},initialize:function(){_.defaults(this.options,{editable:false,clearable:true});this.controller=this.options.controller;this.attachments=new f.view.Attachments({controller:this.controller,collection:this.collection,selection:this.collection,sortable:true,model:new Backbone.Model({edge:40,gutter:5}),AttachmentView:f.view.Attachment.Selection});this.collection.on(&quot;add remove reset&quot;,this.refresh,this)},destroy:function(){this.remove();this.collection.off(&quot;add remov
 e reset&quot;,this.refresh,this);this.attachments.destroy()},render:function(){this.attachments.$el.detach();this.attachments.render();this.$el.html(this.template(this.options));this.$(&quot;.selection-view&quot;).replaceWith(this.attachments.$el);this.refresh();return this},refresh:function(){if(!this.$el.children().length){return}this.$el.toggleClass(&quot;empty&quot;,!this.collection.length);this.$(&quot;.count&quot;).text(this.collection.length+&quot; &quot;+b.selected)},edit:function(g){g.preventDefault();if(this.options.editable){this.options.editable.call(this,this.collection)}},clear:function(g){g.preventDefault();this.collection.reset()}});f.view.Attachment.Selection=f.view.Attachment.extend({className:&quot;attachment selection&quot;,toggleSelection:function(){this.options.selection.single(this.model)}});f.view.Attachment.EditSelection=f.view.Attachment.Selection.extend({buttons:{close:true}});f.view.Settings=f.View.extend({events:{&quot;click button&quot;:&quot;up
 dateHandler&quot;,&quot;change input&quot;:&quot;updateHandler&quot;,&quot;change select&quot;:&quot;updateHandler&quot;,&quot;change textarea&quot;:&quot;updateHandler&quot;},initialize:function(){this.model=this.model||new Backbone.Model();this.model.on(&quot;change&quot;,this.updateChanges,this)},destroy:function(){this.model.off(null,null,this)},render:function(){this.$el.html(this.template(_.defaults({model:this.model.toJSON()},this.options)));_(this.model.attributes).chain().keys().each(this.update,this);return this},update:function(i){var j=this.model.get(i),h=this.$('[data-setting=&quot;'+i+'&quot;]'),g;if(!h.length){return}if(h.is(&quot;select&quot;)){h.find('[value=&quot;'+j+'&quot;]').attr(&quot;selected&quot;,true)}else{if(h.hasClass(&quot;button-group&quot;)){g=h.find(&quot;button&quot;).removeClass(&quot;active&quot;);g.filter('[value=&quot;'+j+'&quot;]').addClass(&quot;active&quot;)}else{if(h.is('input[type=&quot;text&quot;], textarea')){if(!h.is(&quot;:focus&
 quot;)){h.val(j)}}else{if(h.is('input[type=&quot;checkbox&quot;]')){h.attr(&quot;checked&quot;,!!j)}}}}},updateHandler:function(i){var h=e(i.target).closest(&quot;[data-setting]&quot;),j=i.target.value,g;i.preventDefault();if(!h.length){return}if(h.is('input[type=&quot;checkbox&quot;]')){j=h[0].checked}this.model.set(h.data(&quot;setting&quot;),j);if(g=h.data(&quot;userSetting&quot;)){setUserSetting(g,j)}},updateChanges:function(h,g){if(g.changes){_(g.changes).chain().keys().each(this.update,this)}}});f.view.Settings.AttachmentDisplay=f.view.Settings.extend({className:&quot;attachment-display-settings&quot;,template:f.template(&quot;attachment-display-settings&quot;),initialize:function(){var g=this.options.attachment;_.defaults(this.options,{userSettings:false});f.view.Settings.prototype.initialize.apply(this,arguments);this.model.on(&quot;change:link&quot;,this.updateLinkTo,this);if(g){g.on(&quot;change:uploading&quot;,this.render,this)}},dispose:function(){var g=this.opti
 ons.attachment;if(g){g.off(null,null,this)}f.view.Settings.prototype.dispose.apply(this,arguments)},render:function(){var g=this.options.attachment;if(g){_.extend(this.options,{sizes:g.get(&quot;sizes&quot;),type:g.get(&quot;type&quot;)})}f.view.Settings.prototype.render.call(this);this.updateLinkTo();return this},updateLinkTo:function(){var h=this.model.get(&quot;link&quot;),i=this.$(&quot;.link-to-custom&quot;),g=this.options.attachment;if(&quot;none&quot;===h){i.hide();return}i.show();if(&quot;post&quot;===h){i.val(g.get(&quot;link&quot;))}else{if(&quot;file&quot;===h){i.val(g.get(&quot;url&quot;))}else{if(!this.model.get(&quot;linkUrl&quot;)){i.val(&quot;http://&quot;)}}}i.prop(&quot;readonly&quot;,&quot;custom&quot;!==h);if(i.is(&quot;:visible&quot;)){i.focus()[0].select()}}});f.view.Settings.Gallery=f.view.Settings.extend({className:&quot;gallery-settings&quot;,template:f.template(&quot;gallery-settings&quot;)});f.view.Attachment.Details=f.view.Attachment.extend({tagNa
 me:&quot;div&quot;,className:&quot;attachment-details&quot;,template:f.template(&quot;attachment-details&quot;),events:{&quot;change [data-setting]&quot;:&quot;updateSetting&quot;,&quot;change [data-setting] input&quot;:&quot;updateSetting&quot;,&quot;change [data-setting] select&quot;:&quot;updateSetting&quot;,&quot;change [data-setting] textarea&quot;:&quot;updateSetting&quot;,&quot;click .delete-attachment&quot;:&quot;deleteAttachment&quot;},deleteAttachment:function(g){g.preventDefault();if(confirm(b.warnDelete)){this.model.destroy()}}});f.view.AttachmentCompat=f.View.extend({tagName:&quot;form&quot;,className:&quot;compat-item&quot;,events:{submit:&quot;preventDefault&quot;,&quot;change input&quot;:&quot;save&quot;,&quot;change select&quot;:&quot;save&quot;,&quot;change textarea&quot;:&quot;save&quot;},initialize:function(){this.model.on(&quot;change:compat&quot;,this.render,this)},destroy:function(){this.model.off(null,null,this)},render:function(){var g=this.model.get
 (&quot;compat&quot;);if(!g||!g.item){return}this.$el.html(g.item);return this},preventDefault:function(g){g.preventDefault()},save:function(g){var h={};g.preventDefault();_.each(this.$el.serializeArray(),function(i){h[i.name]=i.value});this.model.saveCompat(h)}});f.view.Iframe=f.View.extend({className:&quot;media-iframe&quot;,initialize:function(){this.controller=this.options.controller},render:function(){this.$el.html('&lt;iframe src=&quot;'+this.controller.state().get(&quot;src&quot;)+'&quot; /&gt;');return this}});f.view.Embed=f.View.extend({className:&quot;media-embed&quot;,initialize:function(){this.controller=this.options.controller;this.url=new f.view.EmbedUrl({controller:this.controller,model:this.model}).render();this._settings=new f.View();this.refresh();this.model.on(&quot;change:type&quot;,this.refresh,this)},render:function(){this.$el.html([this.url.el,this._settings.el]);this.url.focus();this.views.render();return this},settings:function(g){g.render();this._set
 tings.$el.replaceWith(g.$el);if(this._settings.destroy){this._settings.destroy()}this._settings.remove();this._settings=g},refresh:function(){var h=this.model.get(&quot;type&quot;),g;if(&quot;image&quot;===h){g=f.view.EmbedImage}else{if(&quot;link&quot;===h){g=f.view.EmbedLink}else{return}}this.settings(new g({controller:this.controller,model:this.model,priority:40}))}});f.view.EmbedUrl=f.View.extend({tagName:&quot;label&quot;,className:&quot;embed-url&quot;,events:{input:&quot;url&quot;,keyup:&quot;url&quot;,change:&quot;url&quot;},initialize:function(){this.label=this.make(&quot;span&quot;,null,this.options.label||b.url);this.input=this.make(&quot;input&quot;,{type:&quot;text&quot;,value:this.model.get(&quot;url&quot;)||&quot;&quot;});this.$label=e(this.label);this.$input=e(this.input);this.$el.append([this.label,this.input]);this.model.on(&quot;change:url&quot;,this.render,this)},destroy:function(){this.model.off(null,null,this)},render:function(){var g=this.$input;if(g.i
 s(&quot;:focus&quot;)){return}this.input.value=this.model.get(&quot;url&quot;)||&quot;http://&quot;;return this},url:function(g){this.model.set(&quot;url&quot;,g.target.value)},focus:function(){var g=this.$input;if(g.is(&quot;:visible&quot;)){g.focus()[0].select()}}});f.view.EmbedLink=f.view.Settings.extend({className:&quot;embed-link-settings&quot;,template:f.template(&quot;embed-link-settings&quot;)});f.view.EmbedImage=f.view.Settings.AttachmentDisplay.extend({className:&quot;embed-image-settings&quot;,template:f.template(&quot;embed-image-settings&quot;),initialize:function(){f.view.Settings.AttachmentDisplay.prototype.initialize.apply(this,arguments);this.model.on(&quot;change:url&quot;,this.updateImage,this)},destroy:function(){this.model.off(null,null,this);f.view.Settings.AttachmentDisplay.prototype.destroy.apply(this,arguments)},updateImage:function(){this.$(&quot;img&quot;).attr(&quot;src&quot;,this.model.get(&quot;url&quot;))}})}(jQuery));
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpincludesjspluploadwppluploadminjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/plupload/wp-plupload.min.js (22994 => 22995)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/plupload/wp-plupload.min.js        2012-12-03 07:17:10 UTC (rev 22994)
+++ trunk/wp-includes/js/plupload/wp-plupload.min.js        2012-12-03 08:09:10 UTC (rev 22995)
</span><span class="lines">@@ -1 +1 @@
</span><del>-window.wp=window.wp||{};(function(a,b){var c;if(typeof _wpPluploadSettings===&quot;undefined&quot;){return}c=function(f){var d=this,h={container:&quot;container&quot;,browser:&quot;browse_button&quot;,dropzone:&quot;drop_element&quot;},g,e;this.supports={upload:c.browser.supported};this.supported=this.supports.upload;if(!this.supported){return}this.plupload=b.extend(true,{multipart_params:{}},c.defaults);this.container=document.body;b.extend(true,this,f);for(g in this){if(b.isFunction(this[g])){this[g]=b.proxy(this[g],this)}}for(g in h){if(!this[g]){continue}this[g]=b(this[g]).first();if(!this[g].length){delete this[g];continue}if(!this[g].prop(&quot;id&quot;)){this[g].prop(&quot;id&quot;,&quot;__wp-uploader-id-&quot;+c.uuid++)}this.plupload[h[g]]=this[g].prop(&quot;id&quot;)}if(!(this.browser&amp;&amp;this.browser.length)&amp;&amp;!(this.dropzone&amp;&amp;this.dropzone.length)){return}this.uploader=new plupload.Uploader(this.plupload);delete this.plupload;this.p
 aram(this.params||{});delete this.params;e=function(j,k,i){if(i.attachment){i.attachment.destroy()}c.errors.unshift({message:j||pluploadL10n.default_error,data:k,file:i});d.error(j,k,i)};this.uploader.init();this.supports.dragdrop=this.uploader.features.dragdrop&amp;&amp;!c.browser.mobile;(function(j,i){var l,k;if(!j){return}j.toggleClass(&quot;supports-drag-drop&quot;,!!i);if(!i){return j.unbind(&quot;.wp-uploader&quot;)}j.bind(&quot;dragover.wp-uploader&quot;,function(){if(l){clearTimeout(l)}if(k){return}j.trigger(&quot;dropzone:enter&quot;).addClass(&quot;drag-over&quot;);k=true});j.bind(&quot;dragleave.wp-uploader, drop.wp-uploader&quot;,function(){l=setTimeout(function(){k=false;j.trigger(&quot;dropzone:leave&quot;).removeClass(&quot;drag-over&quot;)},0)})}(this.dropzone,this.supports.dragdrop));if(this.browser){this.browser.on(&quot;mouseenter&quot;,this.refresh)}else{this.uploader.disableBrowse(true);b(&quot;#&quot;+this.uploader.id+&quot;_html5_container&quot;).hide(
 )}this.uploader.bind(&quot;FilesAdded&quot;,function(i,j){_.each(j,function(l){var k,m;k=_.extend({file:l,uploading:true,date:new Date(),filename:l.name,menuOrder:0,uploadedTo:wp.media.model.settings.postId},_.pick(l,&quot;loaded&quot;,&quot;size&quot;,&quot;percent&quot;));m=/(?:jpe?g|png|gif)$/i.exec(l.name);if(m){k.type=&quot;image&quot;;k.subtype=(&quot;jpg&quot;===m[0])?&quot;jpeg&quot;:m[0]}l.attachment=wp.media.model.Attachment.create(k);c.queue.add(l.attachment);d.added(l.attachment)});i.refresh();i.start()});this.uploader.bind(&quot;UploadProgress&quot;,function(i,j){j.attachment.set(_.pick(j,&quot;loaded&quot;,&quot;percent&quot;));d.progress(j.attachment)});this.uploader.bind(&quot;FileUploaded&quot;,function(i,l,k){var j;try{k=JSON.parse(k.response)}catch(m){return e(pluploadL10n.default_error,m,l)}if(!_.isObject(k)||_.isUndefined(k.success)){return e(pluploadL10n.default_error,null,l)}else{if(!k.success){return e(k.data&amp;&amp;k.data.message,k.data,l)}}_.each(
 [&quot;file&quot;,&quot;loaded&quot;,&quot;size&quot;,&quot;percent&quot;],function(n){l.attachment.unset(n)});l.attachment.set(_.extend(k.data,{uploading:false}));wp.media.model.Attachment.get(k.data.id,l.attachment);j=c.queue.all(function(n){return !n.get(&quot;uploading&quot;)});if(j){c.queue.reset()}d.success(l.attachment)});this.uploader.bind(&quot;Error&quot;,function(i,l){var k=pluploadL10n.default_error,j;for(j in c.errorMap){if(l.code===plupload[j]){k=c.errorMap[j];if(_.isFunction(k)){k=k(l.file,l)}break}}e(k,l,l.file);i.refresh()});this.init()};b.extend(c,_wpPluploadSettings);c.uuid=0;c.errorMap={FAILED:pluploadL10n.upload_failed,FILE_EXTENSION_ERROR:pluploadL10n.invalid_filetype,IMAGE_FORMAT_ERROR:pluploadL10n.not_an_image,IMAGE_MEMORY_ERROR:pluploadL10n.image_memory_exceeded,IMAGE_DIMENSIONS_ERROR:pluploadL10n.image_dimensions_exceeded,GENERIC_ERROR:pluploadL10n.upload_failed,IO_ERROR:pluploadL10n.io_error,HTTP_ERROR:pluploadL10n.http_error,SECURITY_ERROR:pluploa
 dL10n.security_error,FILE_SIZE_ERROR:function(d){return pluploadL10n.file_exceeds_size_limit.replace(&quot;%s&quot;,d.name)}};b.extend(c.prototype,{param:function(d,e){if(arguments.length===1&amp;&amp;typeof d===&quot;string&quot;){return this.uploader.settings.multipart_params[d]}if(arguments.length&gt;1){this.uploader.settings.multipart_params[d]=e}else{b.extend(this.uploader.settings.multipart_params,d)}},init:function(){},error:function(){},success:function(){},added:function(){},progress:function(){},complete:function(){},refresh:function(){this.uploader.refresh()}});c.queue=new wp.media.model.Attachments([],{query:false});c.errors=new Backbone.Collection();a.Uploader=c})(wp,jQuery);
</del><span class="cx">\ No newline at end of file
</span><ins>+window.wp=window.wp||{};(function(a,b){var c;if(typeof _wpPluploadSettings===&quot;undefined&quot;){return}c=function(f){var d=this,h={container:&quot;container&quot;,browser:&quot;browse_button&quot;,dropzone:&quot;drop_element&quot;},g,e;this.supports={upload:c.browser.supported};this.supported=this.supports.upload;if(!this.supported){return}this.plupload=b.extend(true,{multipart_params:{}},c.defaults);this.container=document.body;b.extend(true,this,f);for(g in this){if(b.isFunction(this[g])){this[g]=b.proxy(this[g],this)}}for(g in h){if(!this[g]){continue}this[g]=b(this[g]).first();if(!this[g].length){delete this[g];continue}if(!this[g].prop(&quot;id&quot;)){this[g].prop(&quot;id&quot;,&quot;__wp-uploader-id-&quot;+c.uuid++)}this.plupload[h[g]]=this[g].prop(&quot;id&quot;)}if(!(this.browser&amp;&amp;this.browser.length)&amp;&amp;!(this.dropzone&amp;&amp;this.dropzone.length)){return}this.uploader=new plupload.Uploader(this.plupload);delete this.plupload;this.p
 aram(this.params||{});delete this.params;e=function(j,k,i){if(i.attachment){i.attachment.destroy()}c.errors.unshift({message:j||pluploadL10n.default_error,data:k,file:i});d.error(j,k,i)};this.uploader.init();this.supports.dragdrop=this.uploader.features.dragdrop&amp;&amp;!c.browser.mobile;(function(j,i){var l,k;if(!j){return}j.toggleClass(&quot;supports-drag-drop&quot;,!!i);if(!i){return j.unbind(&quot;.wp-uploader&quot;)}j.bind(&quot;dragover.wp-uploader&quot;,function(){if(l){clearTimeout(l)}if(k){return}j.trigger(&quot;dropzone:enter&quot;).addClass(&quot;drag-over&quot;);k=true});j.bind(&quot;dragleave.wp-uploader, drop.wp-uploader&quot;,function(){l=setTimeout(function(){k=false;j.trigger(&quot;dropzone:leave&quot;).removeClass(&quot;drag-over&quot;)},0)})}(this.dropzone,this.supports.dragdrop));if(this.browser){this.browser.on(&quot;mouseenter&quot;,this.refresh)}else{this.uploader.disableBrowse(true);b(&quot;#&quot;+this.uploader.id+&quot;_html5_container&quot;).hide(
 )}this.uploader.bind(&quot;FilesAdded&quot;,function(i,j){_.each(j,function(l){var k,m;k=_.extend({file:l,uploading:true,date:new Date(),filename:l.name,menuOrder:0,uploadedTo:wp.media.model.settings.post.id},_.pick(l,&quot;loaded&quot;,&quot;size&quot;,&quot;percent&quot;));m=/(?:jpe?g|png|gif)$/i.exec(l.name);if(m){k.type=&quot;image&quot;;k.subtype=(&quot;jpg&quot;===m[0])?&quot;jpeg&quot;:m[0]}l.attachment=wp.media.model.Attachment.create(k);c.queue.add(l.attachment);d.added(l.attachment)});i.refresh();i.start()});this.uploader.bind(&quot;UploadProgress&quot;,function(i,j){j.attachment.set(_.pick(j,&quot;loaded&quot;,&quot;percent&quot;));d.progress(j.attachment)});this.uploader.bind(&quot;FileUploaded&quot;,function(i,l,k){var j;try{k=JSON.parse(k.response)}catch(m){return e(pluploadL10n.default_error,m,l)}if(!_.isObject(k)||_.isUndefined(k.success)){return e(pluploadL10n.default_error,null,l)}else{if(!k.success){return e(k.data&amp;&amp;k.data.message,k.data,l)}}_.each
 ([&quot;file&quot;,&quot;loaded&quot;,&quot;size&quot;,&quot;percent&quot;],function(n){l.attachment.unset(n)});l.attachment.set(_.extend(k.data,{uploading:false}));wp.media.model.Attachment.get(k.data.id,l.attachment);j=c.queue.all(function(n){return !n.get(&quot;uploading&quot;)});if(j){c.queue.reset()}d.success(l.attachment)});this.uploader.bind(&quot;Error&quot;,function(i,l){var k=pluploadL10n.default_error,j;for(j in c.errorMap){if(l.code===plupload[j]){k=c.errorMap[j];if(_.isFunction(k)){k=k(l.file,l)}break}}e(k,l,l.file);i.refresh()});this.init()};b.extend(c,_wpPluploadSettings);c.uuid=0;c.errorMap={FAILED:pluploadL10n.upload_failed,FILE_EXTENSION_ERROR:pluploadL10n.invalid_filetype,IMAGE_FORMAT_ERROR:pluploadL10n.not_an_image,IMAGE_MEMORY_ERROR:pluploadL10n.image_memory_exceeded,IMAGE_DIMENSIONS_ERROR:pluploadL10n.image_dimensions_exceeded,GENERIC_ERROR:pluploadL10n.upload_failed,IO_ERROR:pluploadL10n.io_error,HTTP_ERROR:pluploadL10n.http_error,SECURITY_ERROR:pluplo
 adL10n.security_error,FILE_SIZE_ERROR:function(d){return pluploadL10n.file_exceeds_size_limit.replace(&quot;%s&quot;,d.name)}};b.extend(c.prototype,{param:function(d,e){if(arguments.length===1&amp;&amp;typeof d===&quot;string&quot;){return this.uploader.settings.multipart_params[d]}if(arguments.length&gt;1){this.uploader.settings.multipart_params[d]=e}else{b.extend(this.uploader.settings.multipart_params,d)}},init:function(){},error:function(){},success:function(){},added:function(){},progress:function(){},complete:function(){},refresh:function(){this.uploader.refresh()}});c.queue=new wp.media.model.Attachments([],{query:false});c.errors=new Backbone.Collection();a.Uploader=c})(wp,jQuery);
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpincludesversionphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/version.php (22994 => 22995)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/version.php        2012-12-03 07:17:10 UTC (rev 22994)
+++ trunk/wp-includes/version.php        2012-12-03 08:09:10 UTC (rev 22995)
</span><span class="lines">@@ -4,7 +4,7 @@
</span><span class="cx">  *
</span><span class="cx">  * @global string $wp_version
</span><span class="cx">  */
</span><del>-$wp_version = '3.5-RC2-22992';
</del><ins>+$wp_version = '3.5-RC2-22995';
</ins><span class="cx"> 
</span><span class="cx"> /**
</span><span class="cx">  * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
</span></span></pre>
</div>
</div>

</body>
</html>