/* Black Studio TinyMCE Widget */ !function(s){function a(t){var i=null;return"string"==typeof t?i=t:"object"==typeof t&&t instanceof jQuery&&(i=s("textarea[id^=widget-black-studio-tinymce]",t.closest(bstw_data.container_selectors)).attr("id")),{activate:function(){if(s("#"+i).addClass("mceEditor"),"object"==typeof tinymce&&"function"==typeof tinymce.execCommand){this.deactivate(),tinyMCEPreInit.mceInit[i]=tinyMCEPreInit.mceInit["black-studio-tinymce-widget"],tinyMCEPreInit.mceInit[i].selector="#"+i;try{tinymce.init(tinymce.extend({},tinyMCEPreInit.mceInit["black-studio-tinymce-widget"],tinyMCEPreInit.mceInit[i])),tinymce.execCommand("mceAddControl",!1,i)}catch(t){window.alert(t)}this.is_tinymce_active()&&"function"==typeof tinymce.get(i).on&&tinymce.get(i).on("keyup change",function(){var t=tinymce.get(i).getContent();s("#"+i).val(t).change()})}return this},deactivate:function(){var t;return"object"==typeof tinymce&&"function"==typeof tinymce.execCommand&&this.is_tinymce_active()&&(t=tinymce.get(i).getContent(),tinymce.get(i).remove(),s("#"+i).val(t)),this},activate_after_open:function(){return"visual"===this.get_mode()&&(0===s("div.widget:has(#"+i+") :animated").size()&&!this.is_tinymce_active()&&this.is_textearea_visible()||this.is_tinymce_active()?this.set_mode("visual"):setTimeout(function(){a(i).activate_after_open()},100)),this},activate_after_ajax:function(){return"visual"===this.get_mode()&&(0===s.active&&!this.is_tinymce_active()&&this.is_textearea_visible()?this.set_mode("visual"):this.is_widget_inside_visible()&&!this.is_tinymce_active()&&setTimeout(function(){a(i).activate_after_ajax()},100)),this},get_widget:function(){return s("#"+i).closest("div.widget")},get_widget_inside:function(){return s("#"+i).closest("div.widget-inside")},get_editor_wrap:function(){return s("#"+i).closest("div.wp-editor-wrap")},get_textarea:function(){return s("#"+i)},get_id:function(){return i},get_tinymce:function(){return tinymce.get(i)},get_mode:function(){return s("input[id^=widget-black-studio-tinymce][id$=type]",this.get_widget_inside()).val()},set_mode:function(t){return"visual"===t&&(this.get_editor_wrap().removeClass("html-active").addClass("tmce-active"),this.activate()),"html"===t&&(this.get_editor_wrap().removeClass("tmce-active").addClass("html-active"),this.deactivate()),s("input[id^=widget-black-studio-tinymce][id$=type]",this.get_widget_inside()).val(t),this},is_tinymce_active:function(){return"object"==typeof tinymce&&"object"==typeof tinymce.get(i)&&null!==tinymce.get(i)},is_textearea_visible:function(){return s("#"+i).is(":visible")},is_widget_inside_visible:function(){return s(" div.widget-inside:has(#"+i+")").is(":visible")},check_duplicates:function(){return 1'+bstw_data.error_duplicate_id+""),this},fix_css:function(){return this.get_widget().css("position","relative").css("z-index","100000"),s("#wpbody-content").css("overflow","visible"),this},set_media_target:function(){return s(".insert-media",this.get_widget()).data("editor",i),this}}}s(document).ready(function(){s(document).on("click","div.widget[id*=black-studio-tinymce] .widget-title, div.widget[id*=black-studio-tinymce] a.widget-action",function(){var t,i,e,n,c;a(s(this)).check_duplicates().fix_css().set_media_target().activate_after_open(),s("input[name=savewidget]",a(s(this)).get_widget()).on("click",function(){a(s(this)).is_tinymce_active()&&a(s(this)).deactivate(),s(this).unbind("ajaxSuccess").ajaxSuccess(function(){a(s(this)).activate_after_ajax()})}),s(this).parents("#available-widgets").length||(t=parseInt(s("input[name=widget-width]",a(s(this)).get_widget()).val(),10),i=s(window).width(),e=a(s(this)).get_widget().parent().width(),n=parseInt(s("#wpcontent").css("margin-left"),10),c=!("undefined"==typeof isRtl||!isRtl),i