2012-11-12 23:58:31 +01:00
|
|
|
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={};wp.mce.media={insert:send_to_editor,add:function(e,c){var d=this.get(e);if(d){return d}d=a[e]=wp.media(_.defaults(c||{},{frame:"post",title:wp.media.view.l10n.insertMedia,multiple:true}));d.on("insert",function(g){var h=d.state(),f=h.get("details");g=g||h.get("selection");if(!g||!f){return}this.insert(g.map(function(j){var i=f[j.cid];if(i){i=i.toJSON()}delete f[j.cid];if("image"===j.get("type")){return wp.media.string.image(j,i)+" "}else{return wp.media.string.link(j,i)+" "}}).join(""))},this);d.get("gallery-edit").on("update",function(g){var f=wp.mce.view.get("gallery"),h;if(!f){return}h=f.gallery.shortcode(g);this.insert(h.string())},this);d.get("embed").on("select",function(){var g=d.state().toJSON(),f;if("link"===g.type){this.insert(wp.html.string({tag:"a",content:g.title||g.url,attrs:{href:g.url}}))}else{if("image"===g.type){_.defaults(g,{align:"none",url:"",alt:"",linkUrl:"",link:"none"});f={single:true,tag:"img",attrs:{"class":"align"+g.align,src:g.url,alt:g.alt}};if("custom"===g.link||"file"===g.link){f={tag:"a",content:f,attrs:{href:"custom"===g.link?g.linkUrl:g.url}}}this.insert(wp.html.string(f))}}},this);return d},get:function(c){return a[c]},remove:function(c){delete a[c]},init:function(){b("#wpbody").on("click",".insert-media",function(d){var c=b(this).data("editor"),e;d.preventDefault();if(!c){return}e=wp.mce.media.get(c);if(e){e.open();return}wp.mce.media.add(c)})}};b(wp.mce.media.init)}(jQuery));
|