WordPress/wp-admin/js/media-upload.min.js
Bot (Assets) fa3497237b Compress scripts/styles: 3.5-beta3-22678.
git-svn-id: http://core.svn.wordpress.org/trunk@22678 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-11-19 08:58:31 +00:00

1 line
5.9 KiB
JavaScript

var wpActiveEditor;function send_to_editor(c){var b,a=typeof(tinymce)!="undefined",f=typeof(QTags)!="undefined";if(!wpActiveEditor){if(a&&tinymce.activeEditor){b=tinymce.activeEditor;wpActiveEditor=b.id}else{if(!f){return false}}}else{if(a){if(tinymce.activeEditor&&(tinymce.activeEditor.id=="mce_fullscreen"||tinymce.activeEditor.id=="wp_mce_fullscreen")){b=tinymce.activeEditor}else{b=tinymce.get(wpActiveEditor)}}}if(b&&!b.isHidden()){if(tinymce.isIE&&b.windowManager.insertimagebookmark){b.selection.moveToBookmark(b.windowManager.insertimagebookmark)}if(c.indexOf("[caption")===0){if(b.wpSetImgCaption){c=b.wpSetImgCaption(c)}}else{if(c.indexOf("[gallery")===0){if(b.plugins.wpgallery){c=b.plugins.wpgallery._do_gallery(c)}}else{if(c.indexOf("[embed")===0){if(b.plugins.wordpress){c=b.plugins.wordpress._setEmbed(c)}}}}b.execCommand("mceInsertContent",false,c)}else{if(f){QTags.insertContent(c)}else{document.getElementById(wpActiveEditor).value+=c}}try{tb_remove()}catch(d){}}var tb_position;(function(a){tb_position=function(){var f=a("#TB_window"),e=a(window).width(),d=a(window).height(),c=(720<e)?720:e,b=0;if(a("body.admin-bar").length){b=28}if(f.size()){f.width(c-50).height(d-45-b);a("#TB_iframeContent").width(c-50).height(d-75-b);f.css({"margin-left":"-"+parseInt(((c-50)/2),10)+"px"});if(typeof document.body.style.maxWidth!="undefined"){f.css({top:20+b+"px","margin-top":"0"})}}return a("a.thickbox").each(function(){var g=a(this).attr("href");if(!g){return}g=g.replace(/&width=[0-9]+/g,"");g=g.replace(/&height=[0-9]+/g,"");a(this).attr("href",g+"&width="+(c-80)+"&height="+(d-85-b))})};a(window).resize(function(){tb_position()});a(document).ready(function(b){b("a.thickbox").click(function(){var c;if(typeof(tinymce)!="undefined"&&tinymce.isIE&&(c=tinymce.get(wpActiveEditor))&&!c.isHidden()){c.focus();c.windowManager.insertimagebookmark=c.selection.getBookmark()}})})})(jQuery);(function(b){var a={},c;c=function(g,e){var f=e.link,d;if("file"===f){d=g.get("url")}else{if("post"===f){d=g.get("link")}else{if("custom"===f){d=e.linkUrl}}}return d||""};wp.media.string={link:function(g,e){var f=getUserSetting("urlbutton","post"),d={tag:"a",content:g.get("title")||g.get("filename"),attrs:{rel:"attachment wp-att-"+g.id}};d.attrs.href=c(g,e);return wp.html.string(d)},image:function(k,i){var h,d,e,g,j,f;i=_.defaults(i||{},{img:{},align:getUserSetting("align","none"),size:getUserSetting("imgsize","medium"),link:getUserSetting("urlbutton","post")});i.linkUrl=c(k,i);k=k.toJSON();d=_.clone(i.img);h=d["class"]?d["class"].split(/\s+/):[];g=k.sizes?k.sizes[i.size]:{};if(!g){delete i.size;g=k}d.width=g.width;d.height=g.height;d.src=g.url;if(i.align&&!k.caption){h.push("align"+i.align)}if(i.size){h.push("size-"+i.size)}h.push("wp-image-"+k.id);d["class"]=_.compact(h).join(" ");e={tag:"img",attrs:d,single:true};if(i.linkUrl){i.anchor=i.anchor||{};i.anchor.href=i.linkUrl}if(i.anchor){e={tag:"a",attrs:i.anchor,content:e}}f=wp.html.string(e);if(k.caption){j={id:"attachment_"+k.id,width:d.width};if(i.align){j.align="align"+i.align}f=wp.shortcode.string({tag:"caption",attrs:j,content:f+" "+k.caption})}return f}};wp.media.gallery=(function(){var d={};return{defaults:{order:"ASC",orderby:"post__in",id:wp.media.view.settings.postId,itemtag:"dl",icontag:"dt",captiontag:"dd",columns:3,size:"thumbnail"},attachments:function(i){var k=i.string(),e=d[k],g,f,j,h;delete d[k];if(e){return e}g=i.attrs.named;f=_.pick(g,"orderby","order");f.type="image";f.perPage=-1;if(g.ids){f.post__in=g.ids.split(",");f.orderby="post__in"}else{if(g.include){f.post__in=g.include.split(",")}}if(g.exclude){f.post__not_in=g.exclude.split(",")}if(!f.post__in){f.parent=g.id}h={};_.filter(g,function(m,l){if(_.isUndefined(f[l])){h[l]=m}});j=media.query(f);j.gallery=new Backbone.Model(h);return j},shortcode:function(e){var g=e.props.toJSON(),f=_.pick(g,"include","exclude","orderby","order"),h,i;if(e.gallery){_.extend(f,e.gallery.toJSON())}f.ids=e.pluck("id");if(f.ids&&"post__in"===f.orderby){delete f.orderby}h=new wp.shortcode({tag:"gallery",attrs:f,type:"single"});i=new wp.media.model.Attachments(e.models,{props:g});i.gallery=e.gallery;d[h.string()]=i;return h},edit:function(h){var g=wp.shortcode.next("gallery",h),i=wp.media.gallery.defaults.postId,e,f;if(!g||g.content!==h){return}g=g.shortcode;if(_.isUndefined(g.get("id"))&&!_.isUndefined(i)){g.set("id",i)}e=wp.media.gallery.attachments(g);f=new wp.media.model.Selection(e.models,{props:e.props.toJSON(),multiple:true});f.gallery=e.gallery;return wp.media({frame:"post",state:"gallery-edit",title:wp.media.view.l10n.editGalleryTitle,editing:true,multiple:true,selection:f})}}}());wp.media.editor={insert:send_to_editor,add:function(f,d){var e=this.get(f);if(e){return e}e=a[f]=wp.media(_.defaults(d||{},{frame:"post",title:wp.media.view.l10n.insertMedia,multiple:true}));e.on("insert",function(h){var i=e.state(),g=i.get("details");h=h||i.get("selection");if(!h||!g){return}h.each(function(k){var j=g[k.cid];if(j){j=j.toJSON()}delete g[k.cid];if("image"===k.get("type")){this.insert(wp.media.string.image(k,j)+" ")}else{this.insert(wp.media.string.link(k,j)+" ")}},this)},this);e.get("gallery-edit").on("update",function(g){this.insert(wp.media.gallery.shortcode(g).string())},this);e.get("embed").on("select",function(){var h=e.state().toJSON(),g;if("link"===h.type){this.insert(wp.html.string({tag:"a",content:h.title||h.url,attrs:{href:h.url}}))}else{if("image"===h.type){_.defaults(h,{align:"none",url:"",alt:"",linkUrl:"",link:"none"});g={single:true,tag:"img",attrs:{"class":"align"+h.align,src:h.url,alt:h.alt}};if("custom"===h.link||"file"===h.link){g={tag:"a",content:g,attrs:{href:"custom"===h.link?h.linkUrl:h.url}}}this.insert(wp.html.string(g))}}},this);return e},get:function(d){return a[d]},remove:function(d){delete a[d]},init:function(){b("#wpbody").on("click",".insert-media",function(e){var f=b(this),d=f.data("editor"),g;e.preventDefault();f.blur();if(!d){return}g=wp.media.editor.get(d);if(g){g.open();return}wp.media.editor.add(d)})}};b(wp.media.editor.init)}(jQuery));