tinymce-modal-min.js 1.89 KB
if(jQuery(document).ready((function($){$("body").on("click","#wpzinc-tinymce-modal div.mce-cancel button, .wpzinc-quicktags-modal .media-frame-toolbar .media-toolbar button.cancel",(function(t){"undefined"==typeof tinyMCE||!tinyMCE.activeEditor||tinyMCE.activeEditor.isHidden()?wpZincQuickTagsModal.close():tinymce.activeEditor.windowManager.close()})),$("body").on("click","#wpzinc-tinymce-modal div.mce-insert button, .wpzinc-quicktags-modal .media-frame-toolbar .media-toolbar button.insert",(function(t){t.preventDefault();var e=$("form.wpzinc-tinymce-popup"),i="["+$('input[name="shortcode"]',$(e)).val(),n="1"==$('input[name="close_shortcode"]',$(e)).val();switch($("input, select",$(e)).each((function(t){if(void 0===$(this).data("shortcode"))return!0;if(!$(this).val())return!0;if(0==$(this).val().length)return!0;var e=$(this).data("shortcode"),n="0"!=$(this).data("trim"),a=$(this).val();if(!e.length)return!0;e.search("}")>-1&&e.search("{")>-1&&(e=e.replace(/{|}/gi,(function(t){return""})),e=$(e,$(this).parent().parent()).val()),void 0!==$(this).data("shortcode-prepend")&&(e=$(this).data("shortcode-prepend")+e),Array.isArray(a)&&(a=a.join(",")),n&&(a=a.trim()),i+=" "+e.trim()+'="'+a+'"'})),i+="]",n&&(i+="[/"+$('input[name="shortcode"]',$(e)).val()+"]"),$('input[name="editor_type"]',$(e)).val()){case"tinymce":"undefined"!=typeof tinyMCE&&tinyMCE.activeEditor&&!tinyMCE.activeEditor.isHidden()&&(tinyMCE.activeEditor.execCommand("mceReplaceContent",!1,i),tinyMCE.activeEditor.windowManager.close());break;case"quicktags":QTags.insertContent(i),wpZincQuickTagsModal.close();break}}))})),"undefined"!=typeof wp&&void 0!==wp.media){var wpZincQuickTagsModal=new wp.media.view.Modal({controller:{trigger:function(){}},className:"wpzinc-quicktags-modal"}),wpZincQuickTagsModalContent=wp.Backbone.View.extend({template:wp.template("wpzinc-quicktags-modal")});wpZincQuickTagsModal.content(new wpZincQuickTagsModalContent)}