"use strict";tinymce.PluginManager.requireLangPack("bootstrap"),tinymce.PluginManager.add("bootstrap",function(e,t){function a(a,i,l,c){var d=o(),p="";jQuery(d).hasClass("active")&&(jQuery(d).hasClass("btn")?p=r(d,"bsBtn"):jQuery(d).hasClass("glyphicon")?p=r(d,"bsIcon"):jQuery(d).is("img")?p=r(d,"bsImage"):jQuery(d).hasClass("table")?p=r(d,"bsTable"):jQuery(d).hasClass("breadcrumb")?p=r(d,"bsBreadcrumb"):jQuery(d).hasClass("pagination")?p=r(d,"bsPagination"):jQuery(d).hasClass("pager")?p=r(d,"bsPager"):jQuery(d).hasClass("label")?p=r(d,"bsLabel"):jQuery(d).hasClass("badge")?p=r(d,"bsBadge"):jQuery(d).hasClass("alert")?p=r(d,"bsAlert"):jQuery(d).hasClass("panel")&&(p=r(d,"bsPanel")));var u=function(){var e="",n=tinymce.activeEditor.getParam("language");n||(n="en_EN"),e+='<input type="hidden" name="bs-code" id="bs-code" />';var o="?";return a.match(/\?/)&&(o="&"),e+='<iframe src="'+t+"/"+a+o+"language="+n+"&images_path="+f+"&bootstrap_css_path="+y+"&"+p+"&"+(new Date).getTime()+'"></iframe>'},b=v;jQuery(window).width()<885&&(b=.9*jQuery(window).width()),jQuery(window).height()>l&&(l=.9*jQuery(window).height()-90);e.windowManager.open({title:i,width:b,height:l,html:u(),buttons:[{text:"OK",subtype:"primary",onclick:function(e){s(e,c),this.parent().parent().close()}},{text:"Cancel",onclick:function(){this.parent().parent().close()}}]});jQuery(".mce-floatpanel").find(".mce-widget.mce-abs-layout-item.mce-first").css({left:"auto",right:"82px"}),jQuery(".mce-floatpanel").find(".mce-widget.mce-last.mce-abs-layout-item").css({left:"auto",right:"10px"}),jQuery(window).on("resize",function(){n()})}function n(){var e=v;e=jQuery(window).width()>v?v:.9*jQuery(window).width(),jQuery(".mce-floatpanel").width(e).css("left",(jQuery(window).width()-e)/2),jQuery(".mce-floatpanel").find(".mce-container-body, .mce-foot, .mce-abs-layout").width(e),768>e?jQuery(".mce-edit-area iframe").contents().find(".container").addClass("container-xs"):jQuery(".mce-edit-area iframe").contents().find(".container").removeClass("container-xs")}function o(){var t=e.selection.getNode();if(!jQuery(t).hasClass("active")||jQuery(t).closest("ol.breadcrumb").length>0||jQuery(t).closest("ul.pagination").length>0||jQuery(t).closest("ul.pager").length>0||jQuery(t).closest("div.alert").length>0)for(var a=[".table",".breadcrumb",".pagination",".pager",".alert",".panel"],n=!1,o=0;o<a.length;o++)jQuery(t).closest(a[o]).length>0&&n===!1&&(t=jQuery(t).closest(a[o]),n=!0);return t}function s(t,a){var n=i(document.getElementById("bs-code").value),s=o();if(jQuery(s).hasClass("active")){jQuery(s).after(n);var r={bsBtn:"btn",bsIcon:"glyphicon",bsImage:"img",bsTable:"table",bsBreadcrumb:"breadcrumb",bsPagination:"pagination",bsPager:"pager",bsLabel:"label",bsBadge:"badge",bsAlert:"alert",bsPanel:"panel"};for(var l in r){var c=r[l];a==l&&("bsImage"==a&&jQuery(s).is("img")?e.dom.remove(s):jQuery(s).hasClass(c)&&e.dom.remove(s))}}else e.insertContent(n);tinymce.activeEditor.dom.remove(tinymce.activeEditor.dom.select('li > br[data-mce-bogus="1"]'))}function r(e,t){var a="";if("bsBtn"==t){var n,o=jQuery(e)[0].outerHTML.replace(" active",""),s="";jQuery(e).find("span")[0]&&(s=jQuery(e).find("span").attr("class").split(" ")[1]);var r=new Array("default","btn-primary","btn-success","btn-info","btn-warning","btn-danger"),i="";for(n=r.length-1;n>=0;n--)jQuery(e).hasClass(r[n])&&(i=r[n]);var l=new Array("btn-xs","btn-sm","btn-lg"),c="";for(n=l.length-1;n>=0;n--)jQuery(e).hasClass(l[n])&&(c=l[n]);var d=jQuery(e).prop("tagName").toLowerCase(),p="";"a"==d&&(p=jQuery(e).attr("href"));var u="";("button"==d||"input"==d)&&(u=jQuery(e).attr("type"));var b;b="button"==d||"a"==d?jQuery(e).remove("i").text():jQuery(e).val();var m="prepend";if(jQuery(e).find("span")[0]){var g=new RegExp("/^"+b+"/");g.test(jQuery(e).html())===!0&&(m="append")}o=encodeURIComponent(o),s=encodeURIComponent(s),i=encodeURIComponent(i),c=encodeURIComponent(c),d=encodeURIComponent(d),p=encodeURIComponent(p),u=encodeURIComponent(u),b=encodeURIComponent(b),m=encodeURIComponent(m),a="btnCode="+o+"&btnIcon="+s+"&btnStyle="+i+"&btnSize="+c+"&btnTag="+d+"&btnHref="+p+"&btnType="+u+"&btnText="+b+"&iconPos="+m}else if("bsImage"==t){var y=jQuery(e).attr("src"),h="",f="",v="",j="",Q="false";jQuery(e).hasClass("img-rounded")?j="img-rounded":jQuery(e).hasClass("img-circle")?j="img-circle":jQuery(e).hasClass("img-thumbnail")&&(j="img-thumbnail"),jQuery(e).hasClass("img-responsive")&&(Q="true"),jQuery(e).attr("alt")&&(h=jQuery(e).attr("alt")),jQuery(e).attr("width")&&(f=jQuery(e).attr("width")),jQuery(e).attr("height")&&(v=jQuery(e).attr("height")),y=encodeURIComponent(y),h=encodeURIComponent(h),f=encodeURIComponent(f),v=encodeURIComponent(v),j=encodeURIComponent(j),a="imgSrc="+y+"&imgAlt="+h+"&imgWidth="+f+"&imgHeight="+v+"&imgStyle="+j+"&imgResponsive="+Q}else if("bsIcon"==t){var C=jQuery(e).attr("class").split(" ")[1],B=jQuery(e).css("font-size"),w=jQuery(e).css("color");C=encodeURIComponent(C),B=encodeURIComponent(B),w=encodeURIComponent(w),a="glyphicon="+C+"&iconSize="+B+"&iconColor="+w}else if("bsTable"==t){e=jQuery(e).closest(".table");var I="false",k="false",E="false",P="false",x="false";jQuery(e).hasClass("table-striped")&&(I="true"),jQuery(e).hasClass("table-bordered")&&(k="true"),jQuery(e).hasClass("table-hover")&&(E="true"),jQuery(e).hasClass("table-condensed")&&(P="true"),jQuery(e).hasClass("table-responsive")&&(x="true"),a="tableStriped="+I+"&tableBordered="+k+"&tableHover="+E+"&tableCondensed="+P+"&tableResponsive="+x}else("bsBreadcrumb"==t||"bsPagination"==t||"bsPager"==t||"bsLabel"==t||"bsBadge"==t||"bsAlert"==t|"bsPanel"==t)&&(a="edit=true");return a}function i(e){var t=document.createElement("div");return t.innerHTML=e,0===t.childNodes.length?"":t.childNodes[0].nodeValue}function l(){tinymce.activeEditor.hasVisual?tinymce.activeEditor.dom.addClass(tinymce.activeEditor.dom.select(".mce-content-body "),"hasVisual"):tinymce.activeEditor.dom.removeClass(tinymce.activeEditor.dom.select(".mce-content-body "),"hasVisual")}function c(){l(),tinymce.activeEditor.on("ExecCommand",function(e){"mceToggleVisualAid"==e.command,l()}),l(),tinymce.activeEditor.on("click keyup",function(e){var t="",a="";jQuery(e.target).is("img")?(t="img",a="insertImageBtn"):jQuery(e.target).attr("class")?jQuery(e.target).attr("class").match(/btn/)?(t=".btn",a="insertBtnBtn"):jQuery(e.target).attr("class").match(/glyphicon/)?(t=".glyphicon",a="insertIconBtn"):jQuery(e.target).attr("class").match(/label/)?(t=".label",a="insertLabelBtn"):jQuery(e.target).attr("class").match(/badge/)?(t=".badge",a="insertBadgeBtn"):jQuery(e.target).attr("class").match(/alert/)&&(t=".alert",a="insertAlertBtn"):jQuery(e.target).closest(".table").attr("class")?(t=".table",a="insertTableBtn"):jQuery(e.target).closest(".breadcrumb").attr("class")?(t=".breadcrumb",a="insertBreadcrumbBtn"):jQuery(e.target).closest(".pagination").attr("class")?(t=".pagination",a="insertPaginationBtn"):jQuery(e.target).closest(".pager").attr("class")?(t=".pager",a="insertPagerBtn"):jQuery(e.target).closest(".alert").attr("class")?(t=".alert",a="insertAlertBtn"):jQuery(e.target).closest(".panel").attr("class")&&(t=".panel",a="insertPanelBtn"),p(),""!==t&&d(e.target,t,a)}),p()}function d(t,a,n){".glyphicon"==a?e.selection.setCursorLocation(t):".btn"==a&&jQuery(t).is("input")!==!0&&e.selection.setCursorLocation(t,!0),".table"==a?(jQuery(t).closest(".table").addClass("active"),u(n,"on")):".breadcrumb"==a?(jQuery(t).closest(".breadcrumb").addClass("active"),u(n,"on")):".pagination"==a?(jQuery(t).closest(".pagination").addClass("active"),u(n,"on")):".pager"==a?(jQuery(t).closest(".pager").addClass("active"),u(n,"on")):".alert"==a?(jQuery(t).closest(".alert").addClass("active"),u(n,"on")):".panel"==a?(jQuery(t).closest(".panel").addClass("active"),u(n,"on")):(jQuery(t).addClass("active"),u(n,"on"))}function p(){for(var t=new Array(".btn",".glyphicon","img",".table",".breadcrumb",".pagination",".pager",".label",".badge",".alert",".panel"),a=0;a<t.length;a++)jQuery(e.dom.select(t[a])).removeClass("active");for(var n=e.buttons.bootstrap.items,o=n.length-1;o>=0;o--)n[o].active(!1)}function u(t,a){for(var n=e.buttons.bootstrap.items,o=n.length-1;o>=0;o--)("allBtns"==t||n[o]._name==t)&&"on"==a&&n[o].active(!0)}function b(){var e="@[accesskey|draggable|style|class|hidden|tabindex|contenteditable|id|title|contextmenu|lang|dir<ltr?rtl|spellcheck|onabort|onerror|onmousewheel|onblur|onfocus|onpause|oncanplay|onformchange|onplay|oncanplaythrough|onforminput|onplaying|onchange|oninput|onprogress|onclick|oninvalid|onratechange|oncontextmenu|onkeydown|onreadystatechange|ondblclick|onkeypress|onscroll|ondrag|onkeyup|onseeked|ondragend|onload|onseeking|ondragenter|onloadeddata|onselect|ondragleave|onloadedmetadata|onshow|ondragover|onloadstart|onstalled|ondragstart|onmousedown|onsubmit|ondrop|onmousemove|onsuspend|ondurationmouseout|ontimeupdate|onemptied|onmouseover|onvolumechange|onended|onmouseup|onwaiting],a[target<_blank?_self?_top?_parent|ping|media|href|hreflang|type|rel<alternate?archives?author?bookmark?external?feed?first?help?index?last?license?next?nofollow?noreferrer?prev?search?sidebar?tag?up],abbr,address,area[alt|coords|shape|href|target<_blank?_self?_top?_parent|ping|media|hreflang|type|shape<circle?default?poly?rect|rel<alternate?archives?author?bookmark?external?feed?first?help?index?last?license?next?nofollow?noreferrer?prev?search?sidebar?tag?up],article,aside,audio[src|preload<none?metadata?auto|autoplay<autoplay|loop<loop|controls<controls|mediagroup],blockquote[cite],body,br,button[autofocus<autofocus|disabled<disabled|form|formaction|formenctype|formmethod<get?put?post?delete|formnovalidate?novalidate|formtarget<_blank?_self?_top?_parent|name|type<reset?submit?button|value],canvas[width,height],caption,cite,code,col[span],colgroup[span],command[type<command?checkbox?radio|label|icon|disabled<disabled|checked<checked|radiogroup|default<default],datalist[data],dd,del[cite|datetime],details[open<open],dfn,div,dl,dt,em/i,embed[src|type|width|height],eventsource[src],fieldset[disabled<disabled|form|name],figcaption,figure,footer,form[accept-charset|action|enctype|method<get?post?put?delete|name|novalidate<novalidate|target<_blank?_self?_top?_parent],h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe[name|src|srcdoc|seamless<seamless|width|height|sandbox],img[alt=|src|ismap|usemap|width|height],input[accept|alt|autocomplete<on?off|autofocus<autofocus|checked<checked|disabled<disabled|form|formaction|formenctype|formmethod<get?put?post?delete|formnovalidate?novalidate|formtarget<_blank?_self?_top?_parent|height|list|max|maxlength|min|multiple<multiple|name|pattern|placeholder|readonly<readonly|required<required|size|src|step|type<hidden?text?search?tel?url?email?password?datetime?date?month?week?time?datetime-local?number?range?color?checkbox?radio?file?submit?image?reset?button|value|width],ins[cite|datetime],kbd,keygen[autofocus<autofocus|challenge|disabled<disabled|form|name],label[for|form],legend,li[value],mark,map[name],menu[type<context?toolbar?list|label],meter[value|min|low|high|max|optimum],nav,noscript,object[data|type|name|usemap|form|width|height],ol[reversed|start],optgroup[disabled<disabled|label],option[disabled<disabled|label|selected<selected|value],output[for|form|name],p,param[name,value],-pre,progress[value,max],q[cite],ruby,rp,rt,samp,script[src|async<async|defer<defer|type|charset],section,select[autofocus<autofocus|disabled<disabled|form|multiple<multiple|name|size],small,source[src|type|media],span,-strong/b,-sub,summary,-sup,table,tbody,td[colspan|rowspan|headers],textarea[autofocus<autofocus|disabled<disabled|form|maxlength|name|placeholder|readonly<readonly|required<required|rows|cols|wrap<soft|hard],tfoot,th[colspan|rowspan|headers|scope],thead,time[datetime],tr,ul,var,video[preload<none?metadata?auto|src|crossorigin|poster|autoplay<autoplay|mediagroup|loop<loop|muted<muted|controls<controls|width|height],wbr";return e}var m,g,y,h,f,v=885;"undefined"==typeof e.settings.bootstrapConfig&&(e.settings.bootstrapConfig=[]),"undefined"==typeof e.settings.bootstrapConfig.bootstrapElements&&(e.settings.bootstrapConfig.bootstrapElements={btn:!0,icon:!0,image:!0,table:!0,template:!0,breadcrumb:!0,pagination:!0,pager:!0,label:!0,badge:!0,alert:!0,panel:!0,snippet:!0}),m=e.settings.bootstrapConfig.bootstrapElements,e.settings.verify_html===!1&&"*[*]"===e.settings.valid_elements||e.settings.bootstrapConfig.overwriteValidElements===!1||(e.settings.valid_elements=b()),"undefined"==typeof e.settings.bootstrapConfig.bootstrapCssPath&&(g=t+"/css/bootstrap.min.css",e.settings.bootstrapConfig.bootstrapCssPath=g),y=e.settings.bootstrapConfig.bootstrapCssPath,"undefined"==typeof e.settings.bootstrapConfig.imagesPath&&(h=t+"/",e.settings.bootstrapConfig.imagesPath={imagesPath:h}),f=e.settings.bootstrapConfig.imagesPath,"undefined"==typeof(e.settings.bootstrapConfig.bootstrapElements.snippet===!0&&e.settings.bootstrapConfig.allowSnippetManagement)&&(e.settings.bootstrapConfig.allowSnippetManagement=!0);var j=e.settings.content_css;j="undefined"==typeof j?y+","+t+"/css/editor-content.min.css":y+","+j+","+t+"/css/editor-content.min.css",e.settings.content_css=j,e.on("init",function(){var a=t+"/css/editor.min.css";if(document.createStyleSheet)document.createStyleSheet(a);else{var n=e.dom.create("link",{rel:"stylesheet",href:a});document.getElementsByTagName("head")[0].appendChild(n)}var o=e.settings.bootstrapConfig.tinymceBackgroundColor;""!==o&&e.dom.addStyle(".mce-content-body {background-color: "+o+" !important}"),c()});var Q=[],C=tinymce.ui.Factory.create({type:"button",text:"",classes:"widget btn bs-icon-btn",icon:"bootstrap-icon",tooltip:"Bootstrap Elements"});if(Q.push(C),m.btn){var B=tinymce.ui.Factory.create({type:"button",classes:"widget btn bs-icon-btn",icon:"icon-btn",name:"insertBtnBtn",tooltip:"Insert/Edit Bootstrap Button",onclick:function(){a("bootstrap-btn.php","Insert/Edit Bootstrap Button",580,"bsBtn")}});Q.push(B)}if(m.image){var w=tinymce.ui.Factory.create({type:"button",classes:"widget btn bs-icon-btn",icon:"icon-image",name:"insertImageBtn",tooltip:"Insert/Edit Bootstrap Image",onclick:function(){a("bootstrap-image.php","Insert/Edit Bootstrap Image",580,"bsImage")}});Q.push(w)}if(m.icon){var I=tinymce.ui.Factory.create({type:"button",classes:"widget btn bs-icon-btn",icon:"icon-icon",name:"insertIconBtn",tooltip:"Insert/Edit Bootstrap Icon",onclick:function(){a("bootstrap-icon.php","Insert/Edit Bootstrap Icon",450,"bsIcon")}});Q.push(I)}if(m.table){var k=tinymce.ui.Factory.create({type:"button",classes:"widget btn bs-icon-btn",icon:"icon-table",name:"insertTableBtn",tooltip:"Insert/Edit Bootstrap Table",onclick:function(){a("bootstrap-table.php","Insert/Edit Bootstrap Table",620,"bsTable")}});Q.push(k)}if(m.template){var E=tinymce.ui.Factory.create({type:"button",classes:"widget btn bs-icon-btn",icon:"icon-template",name:"insertTemplateBtn",tooltip:"Insert Bootstrap Template",onclick:function(){a("bootstrap-template.php","Insert Bootstrap Template",580,"bsTemplate")}});Q.push(E)}if(m.breadcrumb){var P=tinymce.ui.Factory.create({type:"button",classes:"widget btn bs-icon-btn",icon:"icon-breadcrumb",name:"insertBreadcrumbBtn",tooltip:"Insert/Edit Bootstrap Breadcrumb",onclick:function(){a("bootstrap-breadcrumb.php","Insert/Edit Bootstrap Breadcrumb",580,"bsBreadcrumb")}});Q.push(P)}if(m.pagination){var x=tinymce.ui.Factory.create({type:"button",classes:"widget btn bs-icon-btn",icon:"icon-pagination",name:"insertPaginationBtn",tooltip:"Insert/Edit Bootstrap Pagination",onclick:function(){a("bootstrap-pagination.php","Insert/Edit Bootstrap Pagination",650,"bsPagination")}});Q.push(x)}if(m.pager){var _=tinymce.ui.Factory.create({type:"button",classes:"widget btn bs-icon-btn",icon:"icon-pager",name:"insertPagerBtn",tooltip:"Insert/Edit Bootstrap Pager",onclick:function(){a("bootstrap-pager.php","Insert/Edit Bootstrap Pager",450,"bsPager")}});Q.push(_)}if(m.label){var R=tinymce.ui.Factory.create({type:"button",classes:"widget btn bs-icon-btn",icon:"icon-label",name:"insertLabelBtn",tooltip:"Insert/Edit Bootstrap Label",onclick:function(){a("bootstrap-label.php","Insert/Edit Bootstrap Label",350,"bsLabel")}});Q.push(R)}if(m.badge){var T=tinymce.ui.Factory.create({type:"button",classes:"widget btn bs-icon-btn",icon:"icon-badge",name:"insertBadgeBtn",tooltip:"Insert/Edit Bootstrap Badge",onclick:function(){a("bootstrap-badge.php","Insert/Edit Bootstrap Badge",350,"bsBadge")}});Q.push(T)}if(m.alert){var S=tinymce.ui.Factory.create({type:"button",classes:"widget btn bs-icon-btn",icon:"icon-alert",name:"insertAlertBtn",tooltip:"Insert/Edit Bootstrap Alert",onclick:function(){a("bootstrap-alert.php","Insert/Edit Bootstrap Alert",580,"bsAlert")}});Q.push(S)}if(m.panel){var U=tinymce.ui.Factory.create({type:"button",classes:"widget btn bs-icon-btn",icon:"icon-panel",name:"insertPanelBtn",tooltip:"Insert/Edit Bootstrap Panel",onclick:function(){a("bootstrap-panel.php","Insert/Edit Bootstrap Panel",650,"bsPanel")}});Q.push(U)}if(m.snippet){var A=tinymce.ui.Factory.create({type:"button",classes:"widget btn bs-icon-btn",icon:"icon-snippet",name:"insertSnippetBtn",tooltip:"Insert/Edit Snippet",onclick:function(){a("bootstrap-snippet.php?allowEdit="+e.settings.bootstrapConfig.allowSnippetManagement,"Insert Snippet",650,"bsSnippet")}});Q.push(A)}e.addButton("bootstrap",{type:"buttongroup",classes:"bs-btn",items:Q})});
