!function(e){window.wysiwyg=e(window,document)}(function(e,t){"use strict";var n=function(e,t,n){var r;return function(){if(r){if(!n)return;clearTimeout(r)}var i=this,o=arguments;r=setTimeout(function(){r=null,e.apply(i,o)},t)}},r=function(t,n,r,i){t.addEventListener?t.addEventListener(n,r,i?!0:!1):t.attachEvent?t.attachEvent("on"+n,r):t!=e&&(t["on"+n]=r)},i=function(t,n,r,i){t.removeEventListener?t.removeEventListener(n,r,i?!0:!1):t.detachEvent?t.detachEvent("on"+n,r):t!=e&&(t["on"+n]=null)},o=function(e,n,r,i){if(t.createEvent){var o=t.createEvent("Event");o.initEvent(n,void 0!==r?r:!0,void 0!==i?i:!1),e.dispatchEvent(o)}else if(t.createEventObject){var o=t.createEventObject();e.fireEvent("on"+n,o)}else"function"==typeof e["on"+n]&&e["on"+n]()},a=function(e){return e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation?e.stopPropagation():e.cancelBubble=!0,!1},l="undefined"!=typeof Node?Node.ELEMENT_NODE:1,s="undefined"!=typeof Node?Node.TEXT_NODE:3,u=function(e,t){for(var n=t;n;){if(n===e)return!0;n=n.parentNode}return!1},c=function(e,t){if(e.firstChild)return e.firstChild;for(;e;){if(e==t)return null;if(e.nextSibling)return e.nextSibling;e=e.parentNode}return null},f=function(n){if(e.getSelection){var r=e.getSelection();if(r.rangeCount>0)return r.getRangeAt(0)}else if(t.selection){var r=t.selection;return r.createRange()}return null},p=function(n,r){if(r)if(e.getSelection){var i=e.getSelection();i.removeAllRanges(),i.addRange(r)}else t.selection&&r.select()},d=function(){if(e.getSelection){var n=e.getSelection();if(!n.rangeCount)return!1;var r=n.getRangeAt(0).cloneRange();if(r.getBoundingClientRect){var i=r.getBoundingClientRect();if(i&&i.left&&i.top&&i.right&&i.bottom)return{left:parseInt(i.left),top:parseInt(i.top),width:parseInt(i.right-i.left),height:parseInt(i.bottom-i.top)};for(var o=r.getClientRects?r.getClientRects():[],a=0;a=0&&a.compareBoundaryPoints(a.START_TO_END,d)<=0){p=!0;break}}}p&&i.push(s)}s=c(s,s==f?f:n)}return 0==i.length&&u(n,r.focusNode)&&r.focusNode!=n&&i.push(r.focusNode),i}if(t.selection){var r=t.selection;if("Text"==r.type){for(var i=[],g=r.createRangeCollection(),o=0;o=0&&d.compareEndPoints("StartToEnd",a)<=0){for(var v=!1,y=0;ya;++a)o.modify("extend","backward","character");for(var a=0;i>a;++a)o.modify("extend","forward","character")}else{var l=o.getRangeAt(0);l.setStart(l.startContainer,l.startOffset-r),l.setEnd(l.endContainer,l.endOffset+i),o.removeAllRanges(),o.addRange(l)}}else if(t.selection){var o=t.selection;if("Control"!=o.type){var l=o.createRange();l.collapse(!0),l.moveStart("character",-r),l.moveEnd("character",i),l.select()}}},w=function(n){if(g(n))return null;if(e.getSelection){var r=e.getSelection();if(r.rangeCount){for(var i=t.createElement("div"),o=r.rangeCount,a=0;o>a;++a){var l=r.getRangeAt(a).cloneContents();i.appendChild(l)}return i.innerHTML}}else if(t.selection){var r=t.selection;if("Text"==r.type){var s=r.createRange();return s.htmlText}}return null},m=function(n,r){if(e.getSelection){var i=e.getSelection();if(u(n,i.anchorNode)&&u(n,i.focusNode))return!0;if(!r)return!1;var o=t.createRange();o.selectNodeContents(n),o.collapse(!1),i.removeAllRanges(),i.addRange(o)}else if(t.selection){var i=t.selection;if("Control"==i.type){var o=i.createRange();if(0!=o.length&&u(n,o(0)))return!0}else{var a=t.body.createTextRange();a.moveToElementText(n);var o=i.createRange();if(a.inRange(o))return!0}if(!r)return!1;var o=t.body.createTextRange();o.moveToElementText(n),o.setEndPoint("StartToEnd",o),o.select()}return!0},b=function(n,r){if(e.getSelection){var i=e.getSelection();if(i.getRangeAt&&i.rangeCount){var o=i.getRangeAt(0),a=t.createElement("div");a.innerHTML=r;for(var l,s,c=t.createDocumentFragment();l=a.firstChild;)s=c.appendChild(l);u(n,o.commonAncestorContainer)?(o.deleteContents(),o.insertNode(c)):n.appendChild(c),s&&(o=o.cloneRange(),o.setStartAfter(s),o.collapse(!0),i.removeAllRanges(),i.addRange(o))}}else if(t.selection){var i=t.selection;if("Control"!=i.type){var f=i.createRange();f.collapse(!0);var o=i.createRange();if(u(n,o.parentElement()))o.pasteHTML(r);else{var p=t.body.createTextRange();p.moveToElementText(n),p.collapse(!1),p.select(),p.pasteHTML(r)}o=i.createRange(),o.setEndPoint("StartToEnd",f),o.select()}}},C=function(C){C=C||{};var T=C.element||null;"string"==typeof T&&(T=t.getElementById(T));var E=C.onKeyDown||null,S=C.onKeyPress||null,L=C.onKeyUp||null,R=C.onSelection||null,x=C.onPlaceholder||null,k=C.onOpenpopup||null,P=C.onClosepopup||null,I=C.hijackContextmenu||!1,M=C.readOnly||!1,A="TEXTAREA"==T.nodeName||"INPUT"==T.nodeName;if(A){var N="contentEditable"in t.body;if(N){var H=navigator.userAgent.match(/(?:iPad|iPhone|Android).* AppleWebKit\/([^ ]+)/);H&&420<=parseInt(H[1])&&parseInt(H[1])<534&&(N=!1)}if(!N){var O=T,D=function(e){return e.replace(/\n?/gi,"
\n")};O.value=D(O.value);var j=function(){return this},K=function(){return null};return{legacy:!0,getElement:function(){return O},getHTML:function(){return O.value},setHTML:function(e){return O.value=D(e),this},getSelectedHTML:K,sync:j,readOnly:function(e){return void 0===e?O.hasAttribute?O.hasAttribute("readonly"):!!O.getAttribute("readonly"):(e?O.setAttribute("readonly","readonly"):O.removeAttribute("readonly"),this)},collapseSelection:j,expandSelection:j,openPopup:K,closePopup:j,removeFormat:j,bold:j,italic:j,underline:j,strikethrough:j,forecolor:j,highlight:j,fontName:j,fontSize:j,subscript:j,superscript:j,align:j,format:j,indent:j,insertLink:j,insertImage:j,insertHTML:j,insertList:j}}}var O=null,B=null;if(A){O=T,O.style.display="none",B=t.createElement("DIV"),B.innerHTML=O.value;var F=O.parentNode,U=O.nextSibling;U?F.insertBefore(B,U):F.appendChild(B)}else B=T;M||B.setAttribute("contentEditable","true");var W=t.all&&!t.addEventListener?t:e,X=null;if(A){var Y=B.innerHTML;X=function(){var e=B.innerHTML;e!=Y&&(O.value=e,Y=e,o(O,"change",!1))}}var _;if(x){var V=!1;_=function(){for(var e=!0,t=B;t;)if(t=c(t,B)){if(t.nodeType==l){if("IMG"==t.nodeName){e=!1;break}}else if(t.nodeType==s){var n=t.nodeValue;if(n&&-1!=n.search(/[^\s]/)){e=!1;break}}}else;V!=e&&(x(e),V=e)},_()}var q=null,z=null,$=null;R&&(z=function(t,n,r){var i=g(B),o=h(B),a=null===t||null===n?null:{left:t,top:n,width:0,height:0},s=d();if(s&&(a=s),a){if(B.getBoundingClientRect){var u=B.getBoundingClientRect();a.left-=parseInt(u.left),a.top-=parseInt(u.top)}else{var c=B,f=0,p=0,v=!1;do f+=c.offsetLeft?parseInt(c.offsetLeft):0,p+=c.offsetTop?parseInt(c.offsetTop):0,"fixed"==c.style.position&&(v=!0);while(c=c.offsetParent);a.left-=f-(v?0:e.pageXOffset),a.top-=p-(v?0:e.pageYOffset)}a.left<0&&(a.left=0),a.top<0&&(a.top=0),a.width>B.offsetWidth&&(a.width=B.offsetWidth),a.height>B.offsetHeight&&(a.height=B.offsetHeight)}else if(o.length)for(var y=0;y"]/g,function(e){var t={"&":"&","<":"<",">":">",'"':"""};return t[e]||e})},o=function(o,a,l,s,u,c,f,p,d,g,h,v,y,w,m,b,C){var T=function(e,t){t&&(e.getSelectedHTML()?e.insertLink(t):e.insertHTML(''+i(t)+"")),e.closePopup().collapseSelection()},E=function(e,t){var r=n('').addClass("wysiwyg-input").keypress(function(n){(10==n.which||13==n.which)&&(t?(t.attr("href",r.val()),e.closePopup().collapseSelection()):T(e,r.val()))});p&&r.attr("placeholder",p);var i=n();c&&(i=k(c).click(function(n){return t?(t.attr("href",r.val()),e.closePopup().collapseSelection()):T(e,r.val()),n.stopPropagation(),n.preventDefault(),!1}));var o=n("
").addClass("wysiwyg-toolbar-form").attr("unselectable","on");return o.append(r).append(i),o},S=function(t){var r=function(e,r){var o='";t.insertHTML(o).closePopup().collapseSelection();var a=n("#wysiwyg-insert-image").removeAttr("id");g&&a.css({maxWidth:g[0]+"px",maxHeight:g[1]+"px"}).load(function(){a.css({maxWidth:"",maxHeight:""});var e=a.width(),t=a.height();(e>g[0]||t>g[1])&&(e/t>g[0]/g[1]?(t=parseInt(t/e*g[0]),e=g[0]):(e=parseInt(e/t*g[1]),t=g[1]),a.attr("width",e).attr("height",t))}),a.attr("src",e)},o=n("
").addClass("wysiwyg-toolbar-form").attr("unselectable","on"),a=null,l=n('').css({position:"absolute",left:0,top:0,width:"100%",height:"100%",opacity:0,cursor:"pointer"});if(!v&&e.File&&e.FileReader&&e.FileList){var s=function(e){if(e.type.match("image.*")){var t=new FileReader;t.onload=function(t){var n=t.target.result;r(n,e.name)},t.readAsDataURL(e)}};a=l.attr("draggable","true").change(function(e){for(var t=e.target.files,n=0;n").append(u)}a&&n("
").addClass("wysiwyg-browse").html(f).append(a).appendTo(o);var d=n('').addClass("wysiwyg-input").keypress(function(e){(10==e.which||13==e.which)&&r(d.val())});p&&d.attr("placeholder",p);var y=n();return c&&(y=k(c).click(function(e){return r(d.val()),e.stopPropagation(),e.preventDefault(),!1})),o.append(n("
").append(d).append(y)),o},L=function(e){var t=function(t,r){t=n.trim(t||""),r=n.trim(r||"");var o=!1;t.length&&!r.length?o=t:-1==r.indexOf("<")&&-1==r.indexOf(">")&&r.match(/^(?:https?:\/)?\/?(?:[^:\/\s]+)(?:(?:\/\w+)*\/)(?:[\w\-\.]+[^#?\s]+)(?:.*)?(?:#[\w\-]+)?$/)&&(o=r),o&&y&&(r=y(o)||""),!r.length&&o&&(r='