Wordpress/wp-includes/js/media-editor.min.js

1 line
6.3 KiB
JavaScript
Raw Normal View History

(function(b){var a={};wp.media.string={props:function(e,h){var g,c,d,f;e=e?_.clone(e):{};if(h&&h.type){e.type=h.type}if("image"===e.type){e=_.defaults(e||{},{align:getUserSetting("align","none"),size:getUserSetting("imgsize","medium"),url:"",classes:[]})}if(!h){return e}g=e.link||getUserSetting("urlbutton","post");if("file"===g){c=h.url}else{if("post"===g){c=h.link}else{if("custom"===g){c=e.linkUrl}}}e.linkUrl=c||"";if("image"===h.type){e.classes.push("wp-image-"+h.id);f=h.sizes;d=f&&f[e.size]?f[e.size]:h;_.extend(e,_.pick(h,"align","caption"),{width:d.width,height:d.height,src:d.url,captionId:"attachment_"+h.id})}else{_.extend(e,{title:h.title||h.filename,rel:"attachment wp-att-"+h.id})}return e},link:function(d,e){var c;d=wp.media.string.props(d,e);c={tag:"a",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,"width","height","alt"));if(g.align&&!g.caption){f.push("align"+g.align)}if(g.size){f.push("size-"+g.size)}c["class"]=_.compact(f).join(" ");d={tag:"img",attrs:c,single:true};if(g.linkUrl){d={tag:"a",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="align"+g.align}e=wp.shortcode.string({tag:"caption",attrs:h,content:e+" "+g.caption})}return e}};wp.media.gallery=(function(){var c={};return{defaults:{order:"ASC",id:wp.media.view.settings.postId,itemtag:"dl",icontag:"dt",captiontag:"dd",columns:3,size:"thumbnail"},attachments:function(h){var j=h.string(),d=c[j],f,e,i,g;delete c[j];if(d){return d}f=h.attrs.named;e=_.pick(f,"orderby","order");e.type="image";e.perPage=-1;if(f.ids){e.post__in=f.ids.split(",");e.orderby="post__in"}else{if(f.include){e.post__in=f.include.split(",")}}if(f.exclude){e.post__not_in=f.exclude.split(",")}if(!e.post__in){e.parent=f.id}g={};_.filter(f,function(l,k){if(_.isUndefined(e[k])){g[k]=l}});i=media.query(e);i.gallery=new Backbone.Model(g);return i},shortcode:function(d){var f=d.props.toJSON(),e=_.pick(f,"include","exclude","orderby","order"),g,h;if(d.gallery){_.extend(e,d.gallery.toJSON())}e.ids=d.pluck("id");if(e.ids&&"post__in"===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:"gallery",attrs:e,type:"single"});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("gallery",g),h=wp.media.gallery.defaults.id,d,e;if(!f||f.content!==g){return}f=f.shortcode;if(_.isUndefined(f.get("id"))&&!_.isUndefined(h)){f.set("id",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("orderby")});return wp.media({frame:"post",state:"gallery-edit",title:wp.media.view.l10n.editGalleryTitle,editing:true,multiple:true,selection:e})}}}());wp.media.editor={insert:function(g){var d=typeof(tinymce)!="undefined",j=typeof(QTags)!="undefined",c=window.wpActiveEditor,f;if(window.send_to_editor){return window.send_to_editor.apply(this,arguments)}if(!c){if(d&&tinymce.activeEditor){f=tinymce.activeEditor;c=window.wpActiveEditor=f.id}else{if(!j){return false}}}else{if(d){if(tinymce.activeEditor&&(tinymce.activeEditor.id=="mce_fullscreen"||tinymce.activeEditor.id=="wp_mce_fullscreen")){f=tinymce.activeEditor}else{f=tinymce.get(c)}}}if(f&&!f.isHidden()){if(tinymce.isIE&&f.windowManager.insertimagebookmark){f.selection.moveToBookmark(f.windowManager.insertimagebookmark)}if(g.indexOf("[caption")===0){if(f.wpSetImgCaption){g=f.wpSetImgCaption(g)}}else{if(g.indexOf("[gallery")===0){if(f.plugins.wpgallery){g=f.plugins.wpgallery._do_gallery(g)}}else{if(g.indexOf("[embed")===0){if(f.plugins.wordpress){g=f.plugins.wordpress._setEmbed(g)}}}}f.execCommand("mceInsertContent",false,g)}else{if(j){QTags.insertContent(g)}else{document.getElementById(c).value+=