text: !function(e){e.fn.richText=function(t){function a(e,t){"undefined"==typeof t&&(t=null),h(),"heading"===e&&r()?f("<"+t+">"+r()+"</"+t+">"):document.execCommand(e,!1,t)}function n(){var t=e("#"+te),a=t.html();b.useSingleQuotes===!0&&(a=u(a)),t.siblings(".richText-initial").val(a)}function i(){var t=e("#"+te),a=t.siblings(".richText-initial").val();t.html(a)}function o(t,a){if(9!==a.keyCode)return!1;var n;if(t.getSelection&&(n=t.getSelection(),n.rangeCount>0)){var i=null,r=null;if(a.shiftKey?(r="previous",i="TD"===n.focusNode.nodeName?null!=n.focusNode.previousSibling?n.focusNode.previousSibling:null!=n.focusNode.parentNode.previousSibling?n.focusNode.parentNode.previousSibling.childNodes[n.focusNode.parentNode.previousSibling.childNodes.length-1]:null:null!=n.focusNode.parentNode.previousSibling?n.focusNode.parentNode.previousSibling:null!=n.focusNode.parentNode.parentNode.previousSibling?n.focusNode.parentNode.parentNode.previousSibling.childNodes[n.focusNode.parentNode.parentNode.previousSibling.childNodes.length-1]:null):(r="next",i="TD"===n.focusNode.nodeName?null!=n.focusNode.nextSibling?n.focusNode.nextSibling:null!=n.focusNode.parentNode.nextSibling?n.focusNode.parentNode.nextSibling.childNodes[0]:null:null!=n.focusNode.parentNode.nextSibling?n.focusNode.parentNode.nextSibling:null!=n.focusNode.parentNode.parentNode.nextSibling?n.focusNode.parentNode.parentNode.nextSibling.childNodes[0]:null),null!=i)return n.collapse(i,Math.min(i.length,n.focusOffset+1)),null!=i.textContent&&n.selectAllChildren(i),a.preventDefault(),!0;if(null===i&&"next"===r&&"TD"===n.focusNode.nodeName){for(var l=e(n.focusNode).parents("table"),d=l.find("tr").first().children("td").length,s=e("<tr />"),c=e("<td />"),p=1;d>=p;p++)s.append(c.clone());l.append(s),o(window,{keyCode:9,shiftKey:!1,preventDefault:function(){}})}}return!1}function r(){var e;return window.getSelection?(e=window.getSelection(),e.toString()):document.selection.createRange?(e=document.selection.createRange(),e.text):!1}function l(){d(w.find("textarea").val()),N=y()}function d(e){ne.length-1>ie&&(ne.length=ie+1),ne[ne.length-1]!==e&&ne.push(e),ie=ne.length-1,s()}function s(){0>=ie?w.find(".richText-undo").addClass("is-disabled"):w.find(".richText-undo").removeClass("is-disabled"),ie>=ne.length-1||0===ne.length?w.find(".richText-redo").addClass("is-disabled"):w.find(".richText-redo").removeClass("is-disabled")}function c(){ie--;var e=ne[ie];w.find("textarea").val(e),w.find(".richText-editor").html(e),s()}function p(){ie++;var e=ne[ie];w.find("textarea").val(e),w.find(".richText-editor").html(e),s()}function h(){N&&C()}function f(e){var t,a;if(window.getSelection){if(t=window.getSelection(),t.getRangeAt&&t.rangeCount){a=t.getRangeAt(0),a.deleteContents();var n=document.createElement("div");n.innerHTML=e;for(var i,o,r=document.createDocumentFragment();i=n.firstChild;)o=r.appendChild(i);a.insertNode(r),o&&(a=a.cloneRange(),a.setStartAfter(o),a.collapse(!0),t.removeAllRanges(),t.addRange(a))}}else document.selection&&"Control"!==document.selection.type&&document.selection.createRange().pasteHTML(e)}function u(e){if(!e)return"";var t,a;return b.useSingleQuotes===!0?(t=/\s+(\w+\s*=\s*(["][^"]*["])|(['][^']*[']))+/g,a=e.replace(t,function(e,t,a){return a?e.replace(a,a.replace(/\"/g,"'")):e})):(t=/\s+(\w+\s*=\s*(['][^']*['])|(["][^"]*["]))+/g,a=e.replace(t,function(e,t,a){return a?e.replace(a,a.replace(/'/g,'"')):e})),a}function m(e){var t=[],a="";t["#FFFFFF"]="White",t["#000000"]="Black",t["#7F6000"]="Brown",t["#938953"]="Beige",t["#1F497D"]="Dark Blue",t.blue="Blue",t["#4F81BD"]="Light blue",t["#953734"]="Dark red",t.red="Red",t["#4F6128"]="Dark green",t.green="Green",t["#3F3151"]="Purple",t["#31859B"]="Dark Turquois",t["#4BACC6"]="Turquois",t["#E36C09"]="Dark orange",t["#F79646"]="Orange",t["#FFFF00"]="Yellow",b.colors&&b.colors.length>0&&(t=b.colors);for(var n in t)a+='<li class="inline"><a data-command="'+e+'" data-option="'+n+'" style="text-align:left;" title="'+t[n]+'"><span class="box-color" style="background-color:'+n+'"></span></a></li>';return a}function g(){w.find(".richText-editor").is(":visible")?(w.find(".richText-initial").show(),w.find(".richText-editor").hide(),e(".richText-toolbar").find(".richText-btn").each(function(){e(this).hasClass("fa-code")||e(this).parent("li").attr("data-disable","true")})):(w.find(".richText-initial").hide(),w.find(".richText-editor").show(),e(".richText-toolbar").find("li").removeAttr("data-disable"))}function v(e,t){var a=x(e),n=!1,i=!1;if(!a)return!1;t?"responsive"!==t?t=t.split("x"):(n=!0,t="640x360",t=t.split("x")):(t="640x360",t=t.split("x"));var o="<br><br>";n===!0&&(o+='<div style="position:relative;height:0;padding-bottom:56.25%">');var r="webkitallowfullscreen mozallowfullscreen allowfullscreen";return"YouTube"===a.platform?(o+='<iframe src="https://www.youtube.com/embed/'+a.id+'?ecver=2" width="'+t[0]+'" height="'+t[1]+'" frameborder="0"'+(n===!0?' style="position:absolute;width:100%;height:100%;left:0"':"")+" "+r+"></iframe>",i=!0):"Vimeo"===a.platform?(o+='<iframe src="https://player.vimeo.com/video/'+a.id+'" width="'+t[0]+'" height="'+t[1]+'" frameborder="0"'+(n===!0?' style="position:absolute;width:100%;height:100%;left:0"':"")+" "+r+"></iframe>",i=!0):"Facebook"===a.platform?(o+='<iframe src="https://www.facebook.com/plugins/video.php?href='+encodeURI(e)+"&show_text=0&width="+t[0]+'" width="'+t[0]+'" height="'+t[1]+'" style="'+(n===!0?'position:absolute;width:100%;height:100%;left:0;border:none;overflow:hidden"':"border:none;overflow:hidden")+'" scrolling="no" frameborder="0" allowTransparency="true" '+r+"></iframe>",i=!0):"Dailymotion"===a.platform&&(o+='<iframe frameborder="0" width="'+t[0]+'" height="'+t[1]+'" src="//www.dailymotion.com/embed/video/'+a.id+'"'+(n===!0?' style="position:absolute;width:100%;height:100%;left:0"':"")+" "+r+"></iframe>",i=!0),n===!0&&(o+="</div>"),o+="<br><br>",i?o:!1}function x(e){var t=/(?:http?s?:\/\/)?(?:www\.)?(?:vimeo\.com)\/?(.+)/,a=/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/,n=/(?:http?s?:\/\/)?(?:www\.)?(?:facebook\.com)\/.*\/videos\/[0-9]+/,i=/(?:http?s?:\/\/)?(?:www\.)?(?:dailymotion\.com)\/video\/([a-zA-Z0-9]+)/,o=e.match(a),r=e.match(t),l=e.match(n),d=e.match(i);return o&&11===o[2].length?{platform:"YouTube",id:o[2]}:r&&r[1]?{platform:"Vimeo",id:r[1]}:l&&l[0]?{platform:"Facebook",id:l[0]}:d&&d[1]?{platform:"Dailymotion",id:d[1]}:!1}var b=e.extend({bold:!0,italic:!0,underline:!0,leftAlign:!0,centerAlign:!0,rightAlign:!0,ol:!0,ul:!0,heading:!0,fonts:!0,fontList:["Arial","Arial Black","Comic Sans MS","Courier New","Geneva","Georgia","Helvetica","Impact","Lucida Console","Tahoma","Times New Roman","Verdana"],fontColor:!0,imageUpload:!0,fileUpload:!0,videoEmbed:!0,urls:!0,table:!0,removeStyles:!0,code:!0,colors:[],fileHTML:"",imageHTML:"",useSingleQuotes:!1,height:0,heightPercentage:0,id:"","class":""},t),T=e(this);T.addClass("richText-initial");var w,y,C,N,R=e("<ul />"),S=e("<li />"),L=e("<a />",{"class":"richText-btn fa fa-bold","data-command":"bold"}),k=e("<a />",{"class":"richText-btn fa fa-italic","data-command":"italic"}),U=e("<a />",{"class":"richText-btn fa fa-underline","data-command":"underline"}),D=e("<a />",{"class":"richText-btn fa fa-align-left","data-command":"justifyLeft"}),A=e("<a />",{"class":"richText-btn fa fa-align-center","data-command":"justifyCenter"}),F=e("<a />",{"class":"richText-btn fa fa-align-right","data-command":"justifyRight"}),H=e("<a />",{"class":"richText-btn fa fa-list-ol","data-command":"insertOrderedList"}),E=e("<a />",{"class":"richText-btn fa fa-list","data-command":"insertUnorderedList"}),B=e("<a />",{"class":"richText-btn fa fa-header"}),I=e("<a />",{"class":"richText-btn fa fa-font"}),M=e("<a />",{"class":"richText-btn fa fa-paint-brush"}),W=e("<a />",{"class":"richText-btn fa fa-image"}),X=e("<a />",{"class":"richText-btn fa fa-video-camera"}),P=e("<a />",{"class":"richText-btn fa fa-file-text-o"}),Y=e("<a />",{"class":"richText-btn fa fa-link"}),Q=e("<a />",{"class":"richText-btn fa fa-table"}),z=e("<a />",{"class":"richText-btn fa fa-recycle","data-command":"removeFormat"}),_=e("<a />",{"class":"richText-btn fa fa-code","data-command":"toggleCode"}),V=e("<div />",{"class":"richText-dropdown-outer"}),G=e("<span />",{"class":"richText-dropdown-close",html:'<span class="fa fa-times"></span>'}),O=e("<ul />",{"class":"richText-dropdown"}),j=e("<div />",{"class":"richText-dropdown"}),q=e("<div />",{"class":"richText-form"}),K=e("<div />",{"class":"richText-form-item"}),Z=e("<label />"),$=e("<input />",{type:"text"}),J=(e("<input />",{type:"file"}),e("<select />")),ee=e("<button />",{text:"Einfügen","class":"btn"}),te="richText-"+Math.random().toString(36).substring(7),ae=null,ne=[],ie=0,oe=O.clone();oe.append(e("<li />",{html:'<a data-command="formatBlock" data-option="h1">Title #1</a>'})),oe.append(e("<li />",{html:'<a data-command="formatBlock" data-option="h2">Title #2</a>'})),oe.append(e("<li />",{html:'<a data-command="formatBlock" data-option="h3">Title #3</a>'})),oe.append(e("<li />",{html:'<a data-command="formatBlock" data-option="h4">Title #4</a>'})),B.append(V.clone().append(oe.prepend(G.clone())));for(var re=b.fontList,le=O.clone(),de=0;de<re.length;de++)le.append(e("<li />",{html:'<a style="font-family:'+re[de]+';" data-command="fontName" data-option="'+re[de]+'">'+re[de]+"</a>"}));I.append(V.clone().append(le.prepend(G.clone())));var se=O.clone();se.html(m("forecolor")),M.append(V.clone().append(se.prepend(G.clone())));var ce=j.clone(),pe=q.clone().attr("id","richText-URL").attr("data-editor",te);pe.append(K.clone().append(Z.clone().text("URL").attr("for","url")).append($.clone().attr("id","url"))),pe.append(K.clone().append(Z.clone().text("Text").attr("for","urlText")).append($.clone().attr("id","urlText"))),pe.append(K.clone().append(Z.clone().text("Open in").attr("for","openIn")).append(J.clone().attr("id","openIn").append(e("<option />",{value:"_self",text:"Same tab"})).append(e("<option />",{value:"_blank",text:"New tab"})))),pe.append(K.clone().append(ee.clone())),ce.append(pe),Y.append(V.clone().append(ce.prepend(G.clone())));var he=j.clone(),fe=q.clone().attr("id","richText-Video").attr("data-editor",te);fe.append(K.clone().append(Z.clone().text("URL").attr("for","videoURL")).append($.clone().attr("id","videoURL"))),fe.append(K.clone().append(Z.clone().text("Size").attr("for","size")).append(J.clone().attr("id","size").append(e("<option />",{value:"responsive",text:"Responsive"})).append(e("<option />",{value:"640x360",text:"640x360"})).append(e("<option />",{value:"560x315",text:"560x315"})).append(e("<option />",{value:"480x270",text:"480x270"})).append(e("<option />",{value:"320x180",text:"320x180"})))),fe.append(K.clone().append(ee.clone())),he.append(fe),X.append(V.clone().append(he.prepend(G.clone())));var ue=j.clone(),me=q.clone().attr("id","richText-Image").attr("data-editor",te);b.imageHTML&&(e(b.imageHTML).find("#imageURL").length>0||"imageURL"===e(b.imageHTML).attr("id"))?me.html(b.imageHTML):(me.append(K.clone().append(Z.clone().text("Image URL").attr("for","imageURL")).append($.clone().attr("id","imageURL"))),me.append(K.clone().append(Z.clone().text("Align").attr("for","align")).append(J.clone().attr("id","align").append(e("<option />",{value:"left",text:"Left"})).append(e("<option />",{value:"center",text:"Center"})).append(e("<option />",{value:"right",text:"Right"}))))),me.append(K.clone().append(ee.clone())),ue.append(me),W.append(V.clone().append(ue.prepend(G.clone())));var ge=j.clone(),ve=q.clone().attr("id","richText-File").attr("data-editor",te);b.fileHTML&&(e(b.fileHTML).find("#fileURL").length>0||"fileURL"===e(b.fileHTML).attr("id"))?ve.html(b.fileHTML):(ve.append(K.clone().append(Z.clone().text("File URL").attr("for","fileURL")).append($.clone().attr("id","fileURL"))),ve.append(K.clone().append(Z.clone().text("Link text").attr("for","fileText")).append($.clone().attr("id","fileText")))),ve.append(K.clone().append(ee.clone())),ge.append(ve),P.append(V.clone().append(ge.prepend(G.clone())));var xe=j.clone(),be=q.clone().attr("id","richText-Table").attr("data-editor",te);be.append(K.clone().append(Z.clone().text("Rows").attr("for","tableRows")).append($.clone().attr("id","tableRows").attr("type","number"))),be.append(K.clone().append(Z.clone().text("Columns").attr("for","tableColumns")).append($.clone().attr("id","tableColumns").attr("type","number"))),be.append(K.clone().append(ee.clone())),xe.append(be),Q.append(V.clone().append(xe.prepend(G.clone())));var Te=function(){var t,a,n="";"TEXTAREA"===T.prop("tagName")||(T.val()?(t=T.val(),a=T.prop("attributes"),e.each(a,function(){this.name&&(n+=" "+this.name+'="'+this.value+'"')}),T.replaceWith(e("<textarea"+n+' data-richtext="init">'+t+"</textarea>")),T=e('[data-richtext="init"]'),T.removeAttr("data-richtext")):T.html()?(t=T.html(),a=T.prop("attributes"),e.each(a,function(){this.name&&(n+=" "+this.name+'="'+this.value+'"')}),T.replaceWith(e("<textarea"+n+' data-richtext="init">'+t+"</textarea>")),T=e('[data-richtext="init"]'),T.removeAttr("data-richtext")):(a=T.prop("attributes"),e.each(a,function(){this.name&&(n+=" "+this.name+'="'+this.value+'"')}),T.replaceWith(e("<textarea"+n+' data-richtext="init"></textarea>')),T=e('[data-richtext="init"]'),T.removeAttr("data-richtext"))),w=e("<div />",{"class":"richText"});var i=e("<div />",{"class":"richText-toolbar"}),o=e("<div />",{"class":"richText-editor",id:te,contenteditable:!0});if(i.append(R),b.bold===!0&&R.append(S.clone().append(L)),b.italic===!0&&R.append(S.clone().append(k)),b.underline===!0&&R.append(S.clone().append(U)),b.leftAlign===!0&&R.append(S.clone().append(D)),b.centerAlign===!0&&R.append(S.clone().append(A)),b.rightAlign===!0&&R.append(S.clone().append(F)),b.ol===!0&&R.append(S.clone().append(H)),b.ul===!0&&R.append(S.clone().append(E)),b.fonts===!0&&b.fontList.length>0&&R.append(S.clone().append(I)),b.heading===!0&&R.append(S.clone().append(B)),b.fontColor===!0&&R.append(S.clone().append(M)),b.imageUpload===!0&&R.append(S.clone().append(W)),b.fileUpload===!0&&R.append(S.clone().append(P)),b.videoEmbed===!0&&R.append(S.clone().append(X)),b.urls===!0&&R.append(S.clone().append(Y)),b.table===!0&&R.append(S.clone().append(Q)),b.removeStyles===!0&&R.append(S.clone().append(z)),b.code===!0&&R.append(S.clone().append(_)),o.html(T.val()),w.append(i),w.append(o),w.append(T.clone().hide()),T.replaceWith(w),w.append(e("<div />",{"class":"richText-toolbar"}).append(e("<a />",{"class":"richText-undo is-disabled",html:'<span class="fa fa-undo"></span>'})).append(e("<a />",{"class":"richText-redo is-disabled",html:'<span class="fa fa-repeat"></span>'})).append(e("<a />",{"class":"richText-help",html:'<span class="fa fa-question-circle"></span>'}))),b.height&&b.height>0)w.children(".richText-editor, .richText-initial").css({"min-height":b.height+"px",height:b.height+"px"});else if(b.heightPercentage&&b.heightPercentage>0){var r=w.parent().innerHeight(),l=b.heightPercentage/100*r;l-=2*i.outerHeight(),l-=parseInt(w.css("margin-top")),l-=parseInt(w.css("margin-bottom")),l-=parseInt(w.find(".richText-editor").css("padding-top")),l-=parseInt(w.find(".richText-editor").css("padding-bottom")),w.children(".richText-editor, .richText-initial").css({"min-height":l+"px",height:l+"px"})}b["class"]&&w.addClass(b["class"]),b.id&&w.attr("id",b.id),ne.push(w.find("textarea").val())};return Te(),w.find(".richText-help").on("click",function(){var t=e(this).parents(".richText");if(t){var a=e("<div />",{"class":"richText-help-popup",style:"position:absolute;top:0;right:0;bottom:0;left:0;background-color: rgba(0,0,0,0.3);"}),n=e("<div />",{style:"position:relative;margin:60px auto;padding:20px;background-color:#FAFAFA;width:70%;font-family:Calibri,Verdana,Helvetica,sans-serif;font-size:small;"}),i=e("<div />",{html:'<span id="closeHelp" style="display:block;position:absolute;top:0;right:0;padding:10px;cursor:pointer;" class="fa fa-times" title="Close"></span>'});i.append("<h3>RichText</h3>"),i.append('<hr>Powered by <a href="https://github.com/webfashionist/RichText" target="_blank">webfashionist/RichText</a> (Github) <br>License: <a href="https://github.com/webfashionist/RichText/blob/master/LICENSE" target="_blank">AGPL-3.0</a>'),a.append(n.append(i)),t.append(a),a.on("click","#closeHelp",function(){e(this).parents(".richText-help-popup").remove()})}}),e(document).on("click",".richText-undo, .richText-redo",function(t){var a=e(this);a.hasClass("richText-undo")&&!a.hasClass("is-disabled")?c():a.hasClass("richText-redo")&&!a.hasClass("is-disabled")&&p()}),e(document).on("input change blur keydown",".richText-editor",function(e){return 9!==e.keyCode&&"9"!==e.keyCode||"keydown"!==e.type?(n(),void l()):(e.preventDefault(),o(window,e),!1)}),e(document).on("input change blur",".richText-initial",function(){b.useSingleQuotes===!0&&e(this).val(u(e(this).val())),i(),l()}),e(document).on("dblclick mouseup",".richText-editor",function(){l()}),e(document).on("click","#richText-Video button.btn",function(t){t.preventDefault();var a=e(this),i=a.parent(".richText-form-item").parent(".richText-form");if(i.attr("data-editor")===te){var o=i.find("input#videoURL").val(),r=i.find("select#size").val();if(o){var l="";l=v(o,r),l?(b.useSingleQuotes===!0,C(),f(l),n(),i.find("input#videoURL").val(""),e(".richText-toolbar li.is-selected").removeClass("is-selected")):(i.prepend(e("<div />",{style:"color:red;display:none;","class":"form-item is-error",text:"Video URL not supported"})),i.children(".form-item.is-error").slideDown(),setTimeout(function(){i.children(".form-item.is-error").slideUp(function(){e(this).remove()})},5e3))}else i.prepend(e("<div />",{style:"color:red;display:none;","class":"form-item is-error",text:"Please enter an URL"})),i.children(".form-item.is-error").slideDown(),setTimeout(function(){i.children(".form-item.is-error").slideUp(function(){e(this).remove()})},5e3)}}),e(document).on("mousedown",function(t){var a=e(t.target);if("IMG"===a.prop("tagName")&&a.parents("#"+te)){startX=t.pageX,startY=t.pageY,startW=a.innerWidth(),startH=a.innerHeight();var n=(a.offset().left,a.offset().left+a.innerWidth()),i=a.offset().top+a.innerHeight(),o=(a.offset().top,!1);a.css({cursor:"default"}),startY<=i&&startY>=i-20&&startX>=n-20&&startX<=n&&(ae=a,ae.css({cursor:"nwse-resize"}),o=!0),o!==!0&&!ae||ae.data("width")?o===!0||ae?t.preventDefault():ae=null:(ae.data("width",a.parents("#"+te).innerWidth()),ae.data("height",3*a.parents("#"+te).innerHeight()),t.preventDefault())}}),e(document).mouseup(function(){ae&&ae.css({cursor:"default"}),ae=null}).mousemove(function(e){if(null!==ae){var t=ae.data("width"),a=ae.width(),i=ae.data("height"),o=ae.height();startW+e.pageX-startX<=t&&startH+e.pageY-startY<=i?(ae.innerWidth(startW+e.pageX-startX),n()):startW+e.pageX-startX<=a&&startH+e.pageY-startY<=o&&(ae.innerWidth(startW+e.pageX-startX),n())}}),e(document).on("click","#richText-URL button.btn",function(t){t.preventDefault();var a=e(this),n=a.parent(".richText-form-item").parent(".richText-form");if(n.attr("data-editor")===te){var i=n.find("input#url").val(),o=n.find("input#urlText").val(),r=n.find("#openIn").val();if(r||(r="_self"),o||(o=i),i){var l="";l=b.useSingleQuotes===!0?"<a href='"+i+"' target='"+r+"'>"+o+"</a>":'<a href="'+i+'" target="'+r+'">'+o+"</a>",C(),f(l),n.find("input#url").val(""),n.find("input#urlText").val(""),e(".richText-toolbar li.is-selected").removeClass("is-selected")}else n.prepend(e("<div />",{style:"color:red;display:none;","class":"form-item is-error",text:"Please enter an URL"})),n.children(".form-item.is-error").slideDown(),setTimeout(function(){n.children(".form-item.is-error").slideUp(function(){e(this).remove()})},5e3)}}),e(document).on("click","#richText-Image button.btn",function(t){t.preventDefault();var a=e(this),n=a.parent(".richText-form-item").parent(".richText-form");if(n.attr("data-editor")===te){var i=n.find("#imageURL").val(),o=n.find("select#align").val();if(o||(o="center"),i){var r="";r=b.useSingleQuotes===!0?"center"===o?"<div style='text-align:center;'><img src='"+i+"'></div>":"<img src='"+i+"' align='"+o+"'>":"center"===o?'<div style="text-align:center;"><img src="'+i+'"></div>':'<img src="'+i+'" align="'+o+'">',C(),f(r),n.find("input#imageURL").val(""),e(".richText-toolbar li.is-selected").removeClass("is-selected")}else n.prepend(e("<div />",{style:"color:red;display:none;","class":"form-item is-error",text:"Please select an image."})),n.children(".form-item.is-error").slideDown(),setTimeout(function(){n.children(".form-item.is-error").slideUp(function(){e(this).remove()})},5e3)}}),e(document).on("click","#richText-File button.btn",function(t){t.preventDefault();var a=e(this),n=a.parent(".richText-form-item").parent(".richText-form");if(n.attr("data-editor")===te){var i=n.find("#fileURL").val(),o=n.find("#fileText").val();if(o||(o=i),i){var r="";r=b.useSingleQuotes===!0?"<a href='"+i+"' target='_blank'>"+o+"</a>":'<a href="'+i+'" target="_blank">'+o+"</a>",C(),f(r),n.find("input#fileURL").val(""),n.find("input#fileText").val(""),e(".richText-toolbar li.is-selected").removeClass("is-selected")}else n.prepend(e("<div />",{style:"color:red;display:none;","class":"form-item is-error",text:"Please select a file."})),n.children(".form-item.is-error").slideDown(),setTimeout(function(){n.children(".form-item.is-error").slideUp(function(){e(this).remove()})},5e3)}}),e(document).on("click","#richText-Table button.btn",function(t){t.preventDefault();var a=e(this),n=a.parent(".richText-form-item").parent(".richText-form");if(n.attr("data-editor")===te){var i=n.find("input#tableRows").val(),o=n.find("input#tableColumns").val();(!i||0>=i)&&(i=2),(!o||0>=o)&&(o=2);var r="";r=b.useSingleQuotes===!0?"<table class='table-1'><tbody>":'<table class="table-1"><tbody>';for(var l=1;i>=l;l++){r+="<tr>";for(var d=1;o>=d;d++)r+="<td> </td>";r+="</tr>"}r+="</tbod></table>",C(),f(r),n.find("input#tableColumns").val(""),n.find("input#tableRows").val(""),e(".richText-toolbar li.is-selected").removeClass("is-selected")}}),e(document).on("click",function(t){var a=e(t.target);if(0===a.parents(".richText-toolbar").length);else if(a.hasClass("richText-dropdown-outer"))a.parent("a").parent("li").removeClass("is-selected");else if(a.find(".richText").length>0)e(".richText-toolbar li").removeClass("is-selected");else if(a.parent().hasClass("richText-dropdown-close"))e(".richText-toolbar li").removeClass("is-selected");else if(a.hasClass("richText-btn")&&e(t.target).children(".richText-dropdown-outer").length>0)if(a.parent("li").addClass("is-selected"),a.hasClass("fa-link")){C();var n=r();a.find("input#urlText").val(""),a.find("input#url").val(""),n&&a.find("input#urlText").val(n)}else a.hasClass("fa-image")}),e(document).on("click",".richText-toolbar a[data-command]",function(t){var n=e(this),i=n.closest(".richText-toolbar");if(i.siblings("#"+te).length>0&&(!n.parent("li").attr("data-disable")||"false"===n.parent("li").attr("data-disable"))){t.preventDefault();var o=e(this).data("command");if("toggleCode"===o)g();else{var r=null;e(this).data("option")&&(r=e(this).data("option"),r.match(/^h[1-6]$/)&&(o="heading")),a(o,r),"removeFormat"===o&&a("formatBlock","div")}}n.parents("li.is-selected").removeClass("is-selected")}),window.getSelection&&document.createRange?(y=function(){var e=document.getElementById(te),t=window.getSelection&&window.getSelection();if(t&&t.rangeCount>0){var a=window.getSelection().getRangeAt(0),n=a.cloneRange();n.selectNodeContents(e),n.setEnd(a.startContainer,a.startOffset);var i=n.toString().length;return{start:i,end:i+a.toString().length}}return N?N:{start:0,end:0}},C=function(){var e=document.getElementById(te),t=N,a=0,n=document.createRange();n.setStart(e,0),n.collapse(!0);for(var i,o=[e],r=!1,l=!1;!l&&(i=o.pop());)if(3===i.nodeType){var d=a+i.length;!r&&t.start>=a&&t.start<=d&&(n.setStart(i,t.start-a),r=!0),r&&t.end>=a&&t.end<=d&&(n.setEnd(i,t.end-a),l=!0),a=d}else for(var s=i.childNodes.length;s--;)o.push(i.childNodes[s]);var c=window.getSelection();c.removeAllRanges(),c.addRange(n)}):document.selection&&document.body.createTextRange&&(y=function(){var e=document.getElementById(te),t=document.selection.createRange(),a=document.body.createTextRange();a.moveToElementText(e),a.setEndPoint("EndToStart",t);var n=a.text.length;return{start:n,end:n+t.text.length}},C=function(){var e=document.getElementById(te),t=N,a=document.body.createTextRange();a.moveToElementText(e),a.collapse(!0),a.moveEnd("character",t.end),a.moveStart("character",t.start),a.select()}),e(this)}}(jQuery);