1 line
6.1 KiB
JavaScript
1 line
6.1 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(e,g){var f=e.link||getUserSetting("urlbutton","post"),d;if("file"===f){d=g.url}else{if("post"===f){d=g.link}else{if("custom"===f){d=e.linkUrl}}}return d||""};wp.media.string={link:function(e,f){var d;e=_.defaults(e||{},{title:"",linkUrl:""});if(f){_.extend(e,{title:f.title||f.filename,linkUrl:c(e,f),rel:"attachment wp-att-"+f.id})}d={tag:"a",content:e.title,attrs:{href:e.linkUrl}};if(e.rel){d.attrs.rel=e.rel}return wp.html.string(d)},image:function(i,h){var d=[],f={},l,j,k,e,g;i=_.defaults(i||{},{align:getUserSetting("align","none"),size:getUserSetting("imgsize","medium"),url:""});if(h){d.push("wp-image-"+h.id);j=h.sizes;k=j&&j[i.size]?j[i.size]:h;_.extend(i,_.pick(h,"align","caption"),{width:k.width,height:k.height,src:k.url,linkUrl:c(i,h),captionId:"attachment_"+h.id})}f.src=i.url;_.extend(f,_.pick(i,"width","height","alt"));if(i.align&&!i.caption){d.push("align"+i.align)}if(i.size){d.push("size-"+i.size)}f["class"]=_.compact(d).join(" ");l={tag:"img",attrs:f,single:true};if(i.linkUrl){l={tag:"a",attrs:{href:i.linkUrl},content:l}}g=wp.html.string(l);if(i.caption){e={};if(f.width){e.width=f.width}if(i.captionId){e.id=i.captionId}if(i.align){e.align="align"+i.align}g=wp.shortcode.string({tag:"caption",attrs:e,content:g+" "+i.caption})}return g}};wp.media.gallery=(function(){var d={};return{defaults:{order:"ASC",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}_.each(wp.media.gallery.defaults,funct
|