diff --git a/js/froala_editor.min.js b/js/froala_editor.min.js index 812d0bba8..40106e4dc 100644 --- a/js/froala_editor.min.js +++ b/js/froala_editor.min.js @@ -2,6 +2,6 @@ * froala_editor v1.1.1 (http://editor.froala.com) * Copyright 2014-2014 Froala */ -if("undefined"==typeof jQuery)throw new Error("Froala requires jQuery");!function(a){"use strict";var b=function(c,d){this.options=a.extend({},b.DEFAULTS,a(c).data(),"object"==typeof d&&d),this.browser=b.browser(),this.disabledList=[],this._id=++b.count,this.init(c)};b.count=0,b.VALID_NODES=["P","PRE","BLOCKQUOTE","H1","H2","H3","H4","H5","H6","DIV"],b.COLORS=["#000000","#444444","#666666","#999999","#CCCCCC","#EEEEEE","#F3F3F3","#FFFFFF","#FF0000","#FF9900","#FFFF00","#00FF00","#00FFFF","#0000FF","#9900FF","#FF00FF","#F4CCCC","#FCE5CD","#FFF2CC","#D9EAD3","#D0E0E3","#CFE2F3","#D9D2E9","#EAD1DC","#EA9999","#F9CB9C","#FFE599","#B6D7A8","#A2C4C9","#9FC5E8","#B4A7D6","#D5A6BD","#E06666","#F6B26B","#FFD966","#93C47D","#76A5AF","#6FA8DC","#8E7CC3","#C27BA0","#CC0000","#E69138","#F1C232","#6AA84F","#45818E","#3D85C6","#674EA7","#A64D79","#990000","#B45F06","#BF9000","#38771D","#134F5C","#0B5394","#351C75","#741B47","#660000","#783F04","#7F6000","#274E13","#0C343D","#073763","#201211","#4C1130"],b.commands={bold:{title:"Bold",icon:"fa fa-bold",shortcut:"(Ctrl + B)"},italic:{title:"Italic",icon:"fa fa-italic",shortcut:"(Ctrl + I)"},underline:{cmd:"underline",title:"Underline",icon:"fa fa-underline",shortcut:"(Ctrl + U)"},strikeThrough:{title:"Strikethrough",icon:"fa fa-strikethrough"},fontSize:{title:"Font Size",icon:"fa fa-text-height",seed:[{min:11,max:52}]},color:{icon:"fa fa-font",title:"Color",seed:[{cmd:"backColor",value:b.COLORS,title:"Background Color"},{cmd:"foreColor",value:b.COLORS,title:"Text Color"}]},formatBlock:{title:"Format Block",icon_alt:"¶",seed:[{value:"n",title:"Normal"},{value:"p",title:"Paragraph"},{value:"pre",title:"Code"},{value:"blockquote",title:"Quote"},{value:"h1",title:"Heading 1"},{value:"h2",title:"Heading 2"},{value:"h3",title:"Heading 3"},{value:"h4",title:"Heading 4"},{value:"h5",title:"Heading 5"},{value:"h6",title:"Heading 6"}]},align:{title:"Alignment",icon:"fa fa-align-center",seed:[{cmd:"justifyLeft",title:"Align Left",icon:"fa fa-align-left"},{cmd:"justifyCenter",title:"Align Center",icon:"fa fa-align-center"},{cmd:"justifyRight",title:"Align Right",icon:"fa fa-align-right"},{cmd:"justifyFull",title:"Justify",icon:"fa fa-align-justify"}]},insertOrderedList:{title:"Numbered List",icon:"fa fa-list-ol"},insertUnorderedList:{title:"Bulleted List",icon:"fa fa-list-ul"},outdent:{title:"Indent Less",icon:"fa fa-dedent",activeless:!0,shortcut:"(Ctrl + <)"},indent:{title:"Indent More",icon:"fa fa-indent",activeless:!0,shortcut:"(Ctrl + >)"},selectAll:{title:"Select All",icon:"fa fa-file-text",shortcut:"(Ctrl + A)"},createLink:{title:"Insert Link",icon:"fa fa-link",shortcut:"(Ctrl + K)"},insertImage:{title:"Insert Image",icon:"fa fa-picture-o",activeless:!0,shortcut:"(Ctrl + P)"},undo:{title:"Undo",icon:"fa fa-undo",activeless:!0,shortcut:"(Ctrl+Z)"},redo:{title:"Redo",icon:"fa fa-repeat",activeless:!0,shortcut:"(Shift+Ctrl+Z)"},html:{title:"Show HTML",icon:"fa fa-code"},save:{title:"Save",icon:"fa fa-floppy-o"},insertVideo:{title:"Insert Video",icon:"fa fa-video-camera"}},b.LANGS=[],b.DEFAULTS={autosave:!1,autosaveInterval:1e3,saveURL:null,saveParams:{},blockTags:["n","p","blockquote","pre","h1","h2","h3","h4","h5","h6"],borderColor:"#252528",buttons:["bold","italic","underline","strikeThrough","fontSize","color","sep","formatBlock","align","insertOrderedList","insertUnorderedList","outdent","indent","sep","createLink","insertImage","insertVideo","undo","redo","html"],crossDomain:!1,direction:"ltr",editorClass:"",enableScript:!1,height:"auto",imageMargin:20,imageParams:{},imageErrorCallback:!1,imageMove:!0,imageUploadParam:"file",imageUploadURL:"http://uploads.im/api",inverseSkin:!1,inlineMode:!0,paragraphy:!0,placeholder:"Type something",shortcuts:!0,customText:!1,spellcheck:!1,toolbarFixed:!0,typingTimer:250,width:"auto",language:"en_us",customButtons:[]},b.hexToRGB=function(a){var b=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;a=a.replace(b,function(a,b,c,d){return b+b+c+c+d+d});var c=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a);return c?{r:parseInt(c[1],16),g:parseInt(c[2],16),b:parseInt(c[3],16)}:null},b.hexToRGBString=function(a){var b=this.hexToRGB(a);return"rgb("+b.r+", "+b.g+", "+b.b+")"},b.getIEversion=function(){var a,b,c=-1;return"Microsoft Internet Explorer"==navigator.appName?(a=navigator.userAgent,b=new RegExp("MSIE ([0-9]{1,}[\\.0-9]{0,})"),null!==b.exec(a)&&(c=parseFloat(RegExp.$1))):"Netscape"==navigator.appName&&(a=navigator.userAgent,b=new RegExp("Trident/.*rv:([0-9]{1,}[\\.0-9]{0,})"),null!==b.exec(a)&&(c=parseFloat(RegExp.$1))),c},b.browser=function(){var a={};if(b.getIEversion()>0)a.msie=!0;else{var c=navigator.userAgent.toLowerCase(),d=/(chrome)[ \/]([\w.]+)/.exec(c)||/(webkit)[ \/]([\w.]+)/.exec(c)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(c)||/(msie) ([\w.]+)/.exec(c)||c.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(c)||[],e={browser:d[1]||"",version:d[2]||"0"};d[1]&&(a[e.browser]=!0),parseInt(e.version,10)<9&&a.msie&&(a.oldMsie=!0),a.chrome?a.webkit=!0:a.webkit&&(a.safari=!0)}return a},b.prototype.text=function(){var a="";return window.getSelection?a=window.getSelection():document.getSelection?a=document.getSelection():document.selection&&(a=document.selection.createRange().text),a.toString()},b.prototype.selectionInEditor=function(){var b=this.getSelectionParent(),c=!1;return b==this.$element.get(0)?!0:(a(b).parents().each(a.proxy(function(a,b){b==this.$element.get(0)&&(c=!0)},this)),c)},b.prototype.getSelection=function(){var a="";return a=window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange()},b.prototype.getRange=function(){if(window.getSelection){var a=window.getSelection();if(a.getRangeAt&&a.rangeCount)return a.getRangeAt(0)}return document.createRange()},b.prototype.clearSelection=function(){if(window.getSelection){var a=window.getSelection();a.removeAllRanges()}else document.selection.createRange&&(document.selection.createRange(),document.selection.empty())},b.prototype.getSelectionElement=function(){var a=this.getSelection();if(a.rangeCount){var b=a.getRangeAt(0).startContainer;return 1!=b.nodeType?b.parentNode:b}return this.$element.get(0)},b.prototype.getSelectionParent=function(){var a,b=null;return window.getSelection?(a=window.getSelection(),a.rangeCount&&(b=a.getRangeAt(0).commonAncestorContainer,1!=b.nodeType&&(b=b.parentNode))):(a=document.selection)&&"Control"!=a.type&&(b=a.createRange().parentElement()),b},b.prototype.nodeInRange=function(a,b){var c;if(a.intersectsNode)return a.intersectsNode(b);c=b.ownerDocument.createRange();try{c.selectNode(b)}catch(d){c.selectNodeContents(b)}return-1==a.compareBoundaryPoints(Range.END_TO_START,c)&&1==a.compareBoundaryPoints(Range.START_TO_END,c)},b.prototype.getElementFromNode=function(c){for(1!=c.nodeType&&(c=c.parentNode);null!==c&&b.VALID_NODES.indexOf(c.tagName)<0;)c=c.parentNode;return a.makeArray(a(c).parents()).indexOf(this.$element.get(0))>=0?c:null},b.prototype.nextNode=function(a){if(a.hasChildNodes())return a.firstChild;for(;a&&!a.nextSibling;)a=a.parentNode;return a?a.nextSibling:null},b.prototype.getRangeSelectedNodes=function(a){var b=a.startContainer,c=a.endContainer;if(b==c)return[b];for(var d=[];b&&b!=c;)d.push(b=this.nextNode(b));for(b=a.startContainer;b&&b!=a.commonAncestorContainer;)d.unshift(b),b=b.parentNode;return d},b.prototype.getSelectedNodes=function(){if(window.getSelection){var a=window.getSelection();if(!a.isCollapsed)return this.getRangeSelectedNodes(a.getRangeAt(0));if(this.selectionInEditor()){var b=a.getRangeAt(0).startContainer;return 3==b.nodeType?[b.parentNode]:[b]}}return[]},b.prototype.getSelectionElements=function(){var b=this.getSelectedNodes(),c=[];return a.each(b,a.proxy(function(a,b){if(null!==b){var d=this.getElementFromNode(b);c.indexOf(d)<0&&d!=this.$element.get(0)&&null!==d&&c.push(d)}},this)),0===c.length&&c.push(this.$element.get(0)),c},b.prototype.getSelectionLink=function(){var a,b;return window.getSelection?(b=window.getSelection(),a=b.anchorNode.parentNode.href):(b=document.selection)&&"Control"!=b.type&&(a=b.createRange().parentElement().href),a},b.prototype.saveSelection=function(){var a,b,c,d=this.getSelection();if(d.getRangeAt&&d.rangeCount){for(c=[],a=0,b=d.rangeCount;b>a;a+=1)c.push(d.getRangeAt(a));this.savedRanges=c}else this.savedRanges=null},b.prototype.restoreSelection=function(){var a,b,c=this.getSelection();if(this.savedRanges)for(c.removeAllRanges(),a=0,b=this.savedRanges.length;b>a;a+=1)c.addRange(this.savedRanges[a])},b.prototype.saveSelectionByMarkers=function(){var a=this.getRange();this.placeMarker(a,!0),this.placeMarker(a,!1)},b.prototype.restoreSelectionByMarkers=function(){var a=this.$element.find("#marker-true"),b=this.$element.find("#marker-false");return a.length&&b.length?(this.$element.removeAttr("contentEditable"),this.$element.focus(),this.setSelection(a[0],0,b[0],0),this.removeMarkers(),void this.$element.attr("contentEditable",!0)):!1},b.prototype.setSelection=function(a,b,c,d){try{null===c&&(c=a),null===d&&(d=b);var e=this.getSelection();if(!e)return;var f=this.getRange();f.setStart(a,b),f.setEnd(c,d),e.removeAllRanges(),e.addRange(f)}catch(g){}},b.prototype.placeMarker=function(b,c){var d=b.cloneRange();d.collapse(c),d.insertNode(a('',document)[0]),d.detach()},b.prototype.removeMarkers=function(){this.$element.find("#marker-true, #marker-false").removeAttr("id")},b.prototype.getBoundingRect=function(){var a=this.getRange().getBoundingClientRect();return a},b.prototype.repositionEditor=function(b){var c,d,e;(this.options.inlineMode||b)&&(c=this.getBoundingRect(),void 0!==c.left&&void 0!==c.top&&void 0!==c.right&&void 0!==c.bottom?(d=c.left+c.width/2+a(window).scrollLeft(),e=c.top+c.height+a(window).scrollTop(),this.isTouch()&&(d=c.left+c.width/2,e=c.top+c.height),this.showByCoordinates(d,e)):(document.execCommand("selectAll"),c=this.getRange().getBoundingClientRect(),d=c.left+a(window).scrollLeft(),e=c.top+c.height+a(window).scrollTop(),this.isTouch()&&(d=c.left,e=c.top+c.height),this.showByCoordinates(d,e-20),this.getRange().collapse(!1)))},b.prototype.destroy=function(){this.sync(),this.$editor.remove(),this.$popup_editor&&this.$popup_editor.remove(),this.$element.replaceWith(this.getHTML()),this.$box.removeClass("froala-box"),this.$box.find(".html-switch").remove(),this.$box.removeData("fa.editable"),clearTimeout(this.typingTimer),clearTimeout(this.ajaxInterval),this.$element.off("mousedown mouseup click keydown keyup keypress touchstart touchend touch drop","**"),void 0!==this.$upload_frame&&this.$upload_frame.remove(),this.$textarea&&(this.$box.remove(),this.$textarea.removeData("fa.editable"),this.$textarea.show())},b.prototype.callback=function(b,c){var d=b+"Callback";this.options[d]&&a.isFunction(this.options[d])&&(c?this.options[d].apply(this,c):this.options[d].call(this)),this.sync()},b.prototype.sync=function(){for(""!==this.text()&&this.saveSelectionByMarkers(),this.$element.find("b").each(function(b,c){a(c).replaceWith(""+a(c).html()+"")}),this.$element.find("i").each(function(b,c){a(c).replaceWith(""+a(c).html()+"")}),this.restoreSelectionByMarkers(),this.$textarea&&this.$textarea.val(this.getHTML());this.$element.find("span:empty").length;)this.$element.find("span:empty").remove();this.$element.find("*").each(a.proxy(function(b,c){this.emptyElement(c)&&"SPAN"==c.tagName&&a(c).remove()},this)),this.disableImageResize(),this.$element.trigger("placeholderCheck")},b.prototype.emptyElement=function(b){if("IMG"==b.tagName||a(b).find("img").length>0)return!1;for(var c=a(b).text(),d=0;d'),a(this).append(''),b.restoreSelectionByMarkers(),b.exec("createLink"),b.$link_wrapper.find('input[type="text"]').val(a(this).attr("href")),b.$link_wrapper.find('input[type="checkbox"]').prop("checked","_blank"==a(this).attr("target")),b.repositionEditor(!0),b.$popup_editor.show()})},b.prototype.imageHandle=function(){var b=this,c=a("").addClass("f-img-handle").on({movestart:function(c){b.hide(),b.$element.addClass("f-non-selectable").removeAttr("contenteditable"),b.isResizing=!0,a(this).attr("data-start-x",c.startX),a(this).attr("data-start-y",c.startY)},move:function(b){var c=a(this),d=b.pageX-parseInt(c.attr("data-start-x"),10);c.attr("data-start-x",b.pageX),c.attr("data-start-y",b.pageY);var e=c.prevAll("img");e.width(c.hasClass("f-h-ne")||c.hasClass("f-h-se")?e.width()+d:e.width()-d)},moveend:function(){if(b.isResizing=!1,a(this).removeAttr("data-start-x"),a(this).removeAttr("data-start-y"),b.$element.removeClass("f-non-selectable").attr("contenteditable",!0),b.browser.mozilla)try{document.execCommand("enableObjectResizing",!1,!1),document.execCommand("enableInlineTableEditing",!1,!1)}catch(c){}}});return c},b.prototype.disableImageResize=function(){if(this.browser.mozilla)try{document.execCommand("enableObjectResizing",!1,!1),document.execCommand("enableInlineTableEditing",!1,!1)}catch(a){}},b.prototype.initImageResizer=function(){this.disableImageResize();var b=this;this.$element.on("mousedown","img",function(){!b.options.imageMove||b.browser.msie?b.$element.attr("contenteditable",!1):a(this).parent().hasClass("f-img-editor")&&(b.closeImageMode(),b.hide())}),this.$element.find("img").each(function(a,b){b.oncontrolselect=function(){return!1}}),this.$element.on("mouseup","img",function(){b.options.imageMove||b.$element.attr("contenteditable",!0)}),this.$element.on("click touchend","img",function(c){c.preventDefault(),c.stopPropagation(),b.$element.blur(),b.$image_editor.find("button").removeClass("active");var d=a(this).css("float");b.$image_editor.find('button[data-cmd="floatImage'+d.charAt(0).toUpperCase()+d.slice(1)+'"]').addClass("active"),b.$image_editor.find('.f-image-alt input[type="text"]').val(a(this).attr("alt")||a(this).attr("title")),b.showImageEditor(),b.showByCoordinates(a(this).offset().left+a(this).width()/2,a(this).offset().top+a(this).height()),a(this).parent().hasClass("f-img-editor")&&"SPAN"==a(this).parent().get(0).tagName||(a(this).wrap(''),a(this).css("margin-left","auto"),a(this).css("margin-right","auto"),a(this).css("margin-bottom","auto"));var e=b.imageHandle();a(this).parent().append(e.clone(!0).addClass("f-h-ne")),a(this).parent().append(e.clone(!0).addClass("f-h-se")),a(this).parent().append(e.clone(!0).addClass("f-h-sw")),a(this).parent().append(e.clone(!0).addClass("f-h-nw")),b.clearSelection(),b.imageMode=!0}),this.$element.find("img").each(function(a,b){b.oncontrolselect=function(){return!1}})},b.prototype.initImagePopup=function(){var b=a("").addClass("fr-bttn").attr("data-cmd","floatImageLeft").attr("title","Float Left").html(''),c=a("").addClass("fr-bttn").attr("data-cmd","floatImageNone").attr("title","Float None").html(''),d=a("").addClass("fr-bttn").attr("data-cmd","floatImageRight").attr("title","Float Right").html(''),e=a("").addClass("fr-bttn").attr("data-cmd","linkImage").attr("title","Insert Link").html(''),f=a("").addClass("fr-bttn").attr("data-cmd","replaceImage").attr("title","Replace Image").html(''),g=a("").addClass("fr-bttn").attr("data-cmd","removeImage").attr("title","Remove Image").html(''),h=a('').append('Title: ').append(a('').on("mouseup touchend keydown",function(a){a.stopPropagation()})).append(a('').attr("data-cmd","setImageAlt").attr("title","OK").html("OK"));this.$image_editor=a("").addClass("bttn-wrapper f-image-editor").append(b).append(c).append(d).append(e).append(f).append(g).append("").append(h);var i=this;this.$image_editor.find("button").click(function(b){b.stopPropagation(),i[a(this).attr("data-cmd")](i.$element.find("span.f-img-editor"))}),this.$popup_editor.append(this.$image_editor)},b.prototype.floatImageLeft=function(a){a.css("margin-left","auto"),a.css("margin-right",this.options.imageMargin),a.css("margin-bottom",this.options.imageMargin),a.css("float","left"),a.find("img").css("float","left"),this.saveUndoStep(),this.callback("floatImageLeft"),a.find("img").click()},b.prototype.floatImageNone=function(a){a.css("margin-left","auto"),a.css("margin-right","auto"),a.css("margin-bottom","auto"),a.css("float","none"),a.find("img").css("float","none"),a.parent().get(0)==this.$element.get(0)?a.wrap(''):a.parent().css("text-align","center"),this.saveUndoStep(),this.callback("floatImageNone"),a.find("img").click()},b.prototype.floatImageRight=function(a){a.css("margin-right","auto"),a.css("margin-left",this.options.imageMargin),a.css("margin-bottom",this.options.imageMargin),a.css("float","right"),a.find("img").css("float","right"),this.saveUndoStep(),this.callback("floatImageRight"),a.find("img").click()},b.prototype.linkImage=function(a){this.showInsertLink(),this.imageMode=!0,"A"==a.parent().get(0).tagName?(this.$link_wrapper.find('input[type="text"]').val(a.parent().attr("href")),"_blank"==a.parent().attr("target")?this.$link_wrapper.find('input[type="checkbox"]').prop("checked",!0):this.$link_wrapper.find('input[type="checkbox"]').prop("checked",!1)):this.$link_wrapper.find('input[type="text"]').val("http://")},b.prototype.replaceImage=function(a){this.showInsertImage(),this.imageMode=!0,this.$image_wrapper.find('input[type="text"]').val(a.find("img").attr("src"))},b.prototype.removeImage=function(a){this.callback("beforeRemoveImage");var c="Are you sure? Image will be deleted.";b.LANGS[this.options.language]&&(c=b.LANGS[this.options.language].translation[c]),confirm(c)?(a.remove(),this.hide(),this.saveUndoStep(),this.callback("afterRemoveImage")):a.find("img").click()},b.prototype.setImageAlt=function(a){a.find("img").attr("alt",this.$image_editor.find('.f-image-alt input[type="text"]').val()),a.find("img").attr("title",this.$image_editor.find('.f-image-alt input[type="text"]').val()),this.saveUndoStep(),this.hide(),this.closeImageMode(),this.callback("setImageAlt")},b.prototype.initElement=function(b){"TEXTAREA"==b.tagName?(this.$textarea=a(b),void 0!==this.$textarea.attr("placeholder")&&"Type something"==this.options.placeholder&&(this.options.placeholder=this.$textarea.attr("placeholder")),this.$element=a("").html(this.$textarea.val()),this.$textarea.before(this.$element).hide()):("DIV"!=b.tagName&&this.options.buttons.indexOf("formatBlock")>=0&&this.disabledList.push("formatBlock"),this.$element=a(b)),this.$box=this.$element,this.$element=a(""),this.setHTML(this.$box.html()),this.$box.empty(),this.$box.html(this.$element).addClass("froala-box"),this.sync(),this.$element.on("drop",function(){setTimeout(function(){a("html").click()},1)})},b.prototype.trim=function(a){return String(a).replace(/^\s+|\s+$/g,"")},b.prototype.wrapText=function(){var b=[],c=["SPAN","A","B","I","EM","U","S","STRONG","STRIKE","FONT"],d=this;this.$element.contents().filter(function(){if(this.nodeType==Node.TEXT_NODE&&a(this).text().trim().length>0||c.indexOf(this.tagName)>=0)b.push(this);else{var e;e=a(d.options.paragraphy===!0?"":"");for(var f in b)e.append(a(b[f]).clone()),f==b.length-1?a(b[f]).replaceWith(e):a(b[f]).remove();b=[]}});var e;e=a(this.options.paragraphy===!0?"":"");for(var f in b)e.append(a(b[f]).clone()),f==b.length-1?a(b[f]).replaceWith(e):a(b[f]).remove();this.$element.find("div:empty, > br").remove()},b.prototype.setHTML=function(b){this.$element.html(a.htmlClean(b,{format:!0})),this.wrapText()},b.prototype.initElementStyle=function(){this.$element.attr("contentEditable",!0),this.$element.addClass("froala-element").addClass(this.options.editorClass),this.$element.css("outline",0)},b.prototype.initUndoRedo=function(){(this.isEnabled("undo")||this.isEnabled("redo"))&&(this.undoStack=[],this.undoIndex=0,this.saveUndoStep()),this.disableBrowserUndo()},b.prototype.enableTyping=function(){this.typingTimer=null,this.$element.on("keydown",a.proxy(function(){clearTimeout(this.typingTimer),this.ajaxSave=!1,this.oldHtml=this.$element.html(),this.typingTimer=setTimeout(a.proxy(function(){this.$element.html()!=this.oldHtml&&((this.isEnabled("undo")||this.isEnabled("redo"))&&this.$element.html()!=this.undoStack[this.undoIndex-1]&&this.saveUndoStep(),this.sync())},this),Math.max(this.options.typingTimer,200))},this))},b.prototype.getHTML=function(){var b=this.$element.clone();return b.find(".f-img-editor > img").each(function(b,c){a(c).css("margin-left",a(c).parent().css("margin-left")),a(c).css("margin-right",a(c).parent().css("margin-right")),a(c).css("margin-bottom",a(c).parent().css("margin-bottom")),a(c).siblings("span.f-img-handle").remove().end().unwrap()}),a.htmlClean(b.html())},b.prototype.initAjaxSaver=function(){this.ajaxHTML=this.getHTML(),this.ajaxSave=!0,this.ajaxInterval=setInterval(a.proxy(function(){this.ajaxHTML!=this.getHTML()&&this.ajaxSave&&(this.options.autosave&&this.save(),this.ajaxHTML=this.getHTML(),this.callback("contentChanged")),this.ajaxSave=!0},this),Math.max(this.options.autosaveInterval,1e3))},b.prototype.disableBrowserUndo=function(){a("body").keydown(function(a){var b=a.which,c=a.ctrlKey||a.metaKey;if(!this.isHTM&&c){if(75==b)return a.preventDefault(),!1;if(90==b&&a.shiftKey)return a.preventDefault(),!1;if(90==b)return a.preventDefault(),!1}})},b.prototype.saveUndoStep=function(){if(this.isEnabled("undo")||this.isEnabled("redo")){for(;this.undoStack.length>this.undoIndex;)this.undoStack.pop();this.undoStack.push(this.getHTML()),this.undoIndex++,this.refreshUndoRedo()}this.sync()},b.prototype.initShortcuts=function(){this.options.shortcuts&&this.$element.on("keydown",a.proxy(function(a){var b=a.which,c=a.ctrlKey||a.metaKey;if(!this.isHTML&&c){if(70==b)return this.show(null),!1;if(66==b)return this.execDefaultShortcut("bold");if(73==b)return this.execDefaultShortcut("italic");if(85==b)return this.execDefaultShortcut("underline");if(75==b)return this.execDefaultShortcut("createLink");if(80==b)return this.repositionEditor(),this.execDefaultShortcut("insertImage");if(65==b)return this.execDefaultShortcut("selectAll");if(190==b)return this.execDefaultShortcut("indent");if(188==b)return this.execDefaultShortcut("outdent");if(72==b)return this.execDefaultShortcut("html");if(48==b)return this.execDefaultShortcut("formatBlock","n");if(49==b)return this.execDefaultShortcut("formatBlock","h1");if(50==b)return this.execDefaultShortcut("formatBlock","h2");if(51==b)return this.execDefaultShortcut("formatBlock","h3");if(52==b)return this.execDefaultShortcut("formatBlock","h4");if(53==b)return this.execDefaultShortcut("formatBlock","h5");if(54==b)return this.execDefaultShortcut("formatBlock","h6");if(90==b&&a.shiftKey)return this.redo(),a.stopPropagation(),!1;if(90==b)return this.undo(),a.stopPropagation(),!1}9!=b||a.shiftKey?9==b&&a.shiftKey&&a.preventDefault():(a.preventDefault(),this.insertHTML(" ",!1))},this))},b.prototype.insertHTML=function(a,b){var c,d;if(window.getSelection){if(c=window.getSelection(),c.getRangeAt&&c.rangeCount){d=c.getRangeAt(0),d.deleteContents();var e=document.createElement("div");e.innerHTML=a;for(var f,g,h=document.createDocumentFragment();f=e.firstChild;)g=h.appendChild(f);var i=h.firstChild;d.insertNode(h),g&&(d=d.cloneRange(),d.setStartAfter(g),b?d.setStartBefore(i):d.collapse(!0),c.removeAllRanges(),c.addRange(d))}}else if((c=document.selection)&&"Control"!=c.type){var j=c.createRange();j.collapse(!0),c.createRange().pasteHTML(a),b&&(d=c.createRange(),d.setEndPoint("StartToStart",j),d.select())}},b.prototype.execDefaultShortcut=function(a,b){return this.isEnabled(a)?(this.exec(a,b),!1):!0},b.prototype.initEditor=function(){this.$editor=a(""),this.$editor.addClass("froala-editor").hide(),a("body").append(this.$editor),this.options.inlineMode?this.initInlineEditor():this.initBasicEditor()},b.prototype.toolbarTop=function(){a(window).on("scroll resize",a.proxy(function(){this.options.toolbarFixed||this.options.inlineMode||(a(window).scrollTop()>this.$box.offset().top&&a(window).scrollTop() img").each(function(b,c){a(c).css("margin-left",a(c).parent().css("margin-left")),a(c).css("margin-right",a(c).parent().css("margin-right")),a(c).css("margin-bottom",a(c).parent().css("margin-bottom")),a(c).siblings("span.f-img-handle").remove().end().unwrap()}),this.$element.find("span.f-img-editor").length&&this.$element.find("span.f-img-editor").remove(),this.$element.removeClass("f-non-selectable").attr("contenteditable",!0),this.$image_editor.hide()},b.prototype.isTouch=function(){return Modernizr.touch&&void 0!==window.Touch},b.prototype.initEditorSelection=function(){this.$element.on("mousedown touchstart",a.proxy(function(){this.$element.attr("data-resize")||(this.closeImageMode(),this.hide())},this)),this.$element.on("mouseup touchend",a.proxy(function(a){var b=this.text();""===b||this.isTouch()?this.options.inlineMode||this.refreshButtons():(a.stopPropagation(),this.show(a)),this.imageMode=!1},this)),this.$element.on("mousedown touchstart","img, a",a.proxy(function(a){this.isResizing||a.stopPropagation()},this)),this.$element.on("mousedown touchstart",".f-img-handle",a.proxy(function(){this.$element.attr("data-resize",!0)},this)),this.$element.on("mouseup touchend",".f-img-handle",a.proxy(function(){this.$element.removeAttr("data-resize")},this)),this.$editor.on("mouseup touchend",a.proxy(function(a){a.stopPropagation(),this.options.inlineMode===!1&&this.hide()},this)),this.$popup_editor.on("mouseup touchend",a.proxy(function(a){a.stopPropagation()},this)),this.$link_wrapper&&this.$link_wrapper.on("mouseup touchend",a.proxy(function(a){a.stopPropagation()})),this.$image_wrapper&&this.$image_wrapper.on("mouseup touchend",a.proxy(function(a){a.stopPropagation()})),this.$video_wrapper&&this.$video_wrapper.on("mouseup touchend",a.proxy(function(a){a.stopPropagation()})),a(window).on("mouseup touchend",a.proxy(function(){this.selectionInEditor()&&""!==this.text()&&!this.isTouch()?this.show(null):(this.hide(),this.closeImageMode())},this)),a(document).on("selectionchange",a.proxy(function(a){if(this.options.inlineMode&&this.selectionInEditor()&&this.link!==!0&&this.isTouch()){var b=this.text();""!==b?(Modernizr.mq("(max-device-width: 320px) and (-webkit-min-device-pixel-ratio: 2)")||this.show(null),a.stopPropagation()):this.hide()}},this)),a(window).keydown(a.proxy(function(a){a.ctrlKey||(this.hide(),this.closeImageMode())},this))},b.prototype.setPlaceholder=function(a){a&&(this.options.placeholder=a),this.$textarea&&this.$textarea.attr("placeholder",this.options.placeholder),this.$element.attr("data-placeholder",this.options.placeholder)},b.prototype.isEmpty=function(){var a=this.$element.text().replace(/(\r\n|\n|\r|\t)/gm,"");return(""===a||1==a.length&&"8203"==a.charCodeAt(0))&&0===this.$element.find("img").length&&0==this.$element.find("p > br").length},b.prototype.setPlaceholderEvents=function(){this.$element.on("keyup keydown focus placeholderCheck",a.proxy(function(){if(this.isEmpty()&&!this.isHTML){if(this.options.paragraphy){var b=a("");this.$element.html(b),this.setSelection(b.get(0),0,null,0)}this.$element.addClass("f-placeholder")}else this.$element.find("p").length?this.isEmpty()===!1&&this.$element.removeClass("f-placeholder"):this.options.paragraphy&&(this.wrapText(),this.setSelection(this.$element.find("p")[0],1,null,1))},this)),this.$element.trigger("placeholderCheck")},b.prototype.setDimensions=function(a,b){a&&(this.options.height=a),b&&(this.options.width=b),"auto"!=this.options.height&&this.$element.css("height",this.options.height),"auto"!=this.options.width&&this.$box.css("width",this.options.width)},b.prototype.setDirection=function(a){a&&(this.options.direction=a),"ltr"!=this.options.direction&&"rtl"!=this.options.direction&&(this.options.direction="ltr"),"rtl"==this.options.direction?(this.$element.addClass("f-rtl"),this.$editor.addClass("f-rtl"),this.$popup_editor.addClass("f-rtl")):(this.$element.removeClass("f-rtl"),this.$editor.removeClass("f-rtl"),this.$popup_editor.removeClass("f-rtl"))},b.prototype.setBorderColor=function(a){a&&(this.options.borderColor=a);var c=b.hexToRGB(this.options.borderColor);null!==c&&(this.$editor.css("border-color",this.options.borderColor),this.$editor.attr("data-border-color",this.options.borderColor))},b.prototype.setSpellcheck=function(a){void 0!==a&&(this.options.spellcheck=a),this.$element.attr("spellcheck",this.options.spellcheck)},b.prototype.setInverseSkin=function(a){void 0!==a&&(this.options.inverseSkin=a),this.options.inverseSkin?(this.$editor.addClass("f-inverse"),this.$popup_editor.addClass("f-inverse")):(this.$editor.removeClass("f-inverse"),this.$popup_editor.removeClass("f-inverse"))},b.prototype.customizeText=function(b){b&&(this.$editor.find("[title]").add(this.$popup_editor.find("[title]")).each(a.proxy(function(c,d){for(var e in b)a(d).attr("title").toLowerCase()==e.toLowerCase()&&a(d).attr("title",b[e])},this)),this.$editor.find('[data-text="true"]').add(this.$popup_editor.find('[data-text="true"]')).each(a.proxy(function(c,d){for(var e in b)a(d).text().toLowerCase()==e.toLowerCase()&&a(d).text(b[e])},this)))},b.prototype.setLanguage=function(b){void 0!==b&&(this.options.language=b),a.Editable.LANGS[this.options.language]&&(this.customizeText(a.Editable.LANGS[this.options.language].translation),a.Editable.LANGS[this.options.language].direction&&this.setDirection(a.Editable.LANGS[this.options.language].direction),a.Editable.LANGS[this.options.language].translation[this.options.placeholder]&&this.setPlaceholder(a.Editable.LANGS[this.options.language].translation[this.options.placeholder]))},b.prototype.setCustomText=function(a){a&&(this.options.customText=a),this.options.customText&&this.customizeText(this.options.customText)},b.prototype.execHTML=function(){this.html() -},b.prototype.initHTMLArea=function(){this.$html_area=a('').keydown(function(b){var c=b.keyCode||b.which;if(9==c){b.preventDefault();var d=a(this).get(0).selectionStart,e=a(this).get(0).selectionEnd;a(this).val(a(this).val().substring(0,d)+" "+a(this).val().substring(e)),a(this).get(0).selectionStart=a(this).get(0).selectionEnd=d+1}})},b.prototype.setButtons=function(c){c&&(this.options.buttons=c),this.$bttn_wrapper=a("").addClass("bttn-wrapper"),this.$editor.append(this.$bttn_wrapper);for(var d in this.options.buttons){var e,f;"sep"==this.options.buttons[d]&&this.$bttn_wrapper.append(this.options.inlineMode?'':'');var g=b.commands[this.options.buttons[d]];if(void 0!==g)switch(g.cmd=this.options.buttons[d],g.cmd){case"color":e=this.buildDropdownColor(g),f=this.buildDropdownButton(g,"fr-color-picker").append(e),this.$bttn_wrapper.append(f);break;case"align":e=this.buildDropdownAlign(g),f=this.buildDropdownButton(g,"fr-selector").append(e),this.$bttn_wrapper.append(f);break;case"fontSize":e=this.buildDropdownFontsize(g),f=this.buildDropdownButton(g).append(e),this.$bttn_wrapper.append(f);break;case"formatBlock":e=this.buildDropdownFormatblock(g),f=this.buildDropdownButton(g).append(e),this.$bttn_wrapper.append(f);break;case"createLink":f=this.buildDefaultButton(g),this.$bttn_wrapper.append(f);break;case"insertImage":f=this.buildDefaultButton(g),this.$bttn_wrapper.append(f);break;case"insertVideo":f=this.buildDefaultButton(g),this.$bttn_wrapper.append(f),this.buildInsertVideo();break;case"undo":case"redo":f=this.buildDefaultButton(g),this.$bttn_wrapper.append(f),f.prop("disabled",!0);break;case"html":f=this.buildDefaultButton(g),this.$bttn_wrapper.append(f),this.options.inlineMode&&this.$box.append(f.clone(!0).addClass("html-switch").attr("title","Hide HTML").click(a.proxy(this.execHTML,this))),this.initHTMLArea();break;default:f=this.buildDefaultButton(g),this.$bttn_wrapper.append(f)}else{if(g=this.options.customButtons[this.options.buttons[d]],void 0===g)continue;f=this.buildCustomButton(g),this.$bttn_wrapper.append(f)}}this.buildCreateLink(),this.buildInsertImage(),this.bindButtonEvents()},b.prototype.buildDefaultButton=function(b){var c=a("").addClass("fr-bttn").attr("title",b.title).attr("data-cmd",b.cmd).attr("data-activeless",b.activeless);return this.addButtonIcon(c,b),c},b.prototype.addButtonIcon=function(b,c){b.append(c.icon?a("").addClass(c.icon):c.icon_alt?a("").addClass("for-text").html(c.icon_alt):c.icon_img?a('').attr("alt",c.title):c.icon_txt?a("").html(c.icon_txt):c.title)},b.prototype.buildCustomButton=function(b){var c=a("").addClass("fr-bttn").attr("title",b.title);return"fa"==b.icon.type?this.addButtonIcon(c,{icon:"fa "+b.icon.value}):"img"==b.icon.type?this.addButtonIcon(c,{icon_img:b.icon.value,title:b.title}):"txt"==b.icon.type&&this.addButtonIcon(c,{icon_txt:b.icon.value}),c.on("click touchend",a.proxy(function(a){a.stopPropagation(),a.preventDefault(),b.callback(this)},this)),c},b.prototype.buildDropdownButton=function(b,c){c=c||"";var d=a("").addClass("fr-bttn fr-dropdown").addClass(c),e=a("").addClass("fr-trigger").attr("title",b.title);return this.addButtonIcon(e,b),d.append(e),d},b.prototype.buildDropdownColor=function(b){var c=a("").addClass("fr-dropdown-menu");for(var d in b.seed){var e=b.seed[d],f=a("").append(a('').html(e.title));for(var g in e.value){var h=e.value[g];f.append(a("").addClass("fr-color-bttn").attr("data-cmd",e.cmd).attr("data-val",h).attr("data-activeless",b.activeless).css("background-color",h).html(" ")),g%8==7&&g>0&&(f.append(""),(7==g||15==g)&&f.append(a("").addClass("separator")))}c.append(f)}return c},b.prototype.buildDropdownAlign=function(b){var c=a("").addClass("fr-dropdown-menu");for(var d in b.seed){var e=b.seed[d],f=a("").append(a("").addClass("fr-bttn").attr("data-cmd",e.cmd).attr("title",e.title).attr("data-activeless",b.activeless).append(a("").addClass(e.icon)));c.append(f)}return c},b.prototype.buildDropdownFontsize=function(b){var c=a("").addClass("fr-dropdown-menu f-font-sizes");for(var d in b.seed)for(var e=b.seed[d],f=e.min;f<=e.max;f++){var g=a("").attr("data-cmd",b.cmd).attr("data-val",f+"px").attr("data-activeless",b.activeless).append(a('').append(a("").text(f+"px")));c.append(g)}return c},b.prototype.buildDropdownFormatblock=function(b){var c=a("").addClass("fr-dropdown-menu");for(var d in b.seed){var e=b.seed[d];if(-1!=a.inArray(e.value,this.options.blockTags)){var f=a("").append(a("").attr("data-cmd",b.cmd).attr("data-val",e.value).attr("data-activeless",b.activeless).append(a('').addClass("format_"+e.value).attr("title",e.title).text(e.title)));c.append(f)}}return c},b.prototype.buildInsertImage=function(){this.$image_wrapper=a("").addClass("image-wrapper"),this.$popup_editor.append(this.$image_wrapper);var b=this;this.$progress_bar=a('').append("");var c=a('').append('Drop Image(or click)').append(a('').append(a('')));this.browser.msie&&(this.$upload_frame=a(''),a("body").append(this.$upload_frame),this.$upload_frame.bind("load",function(){var c=a(this).contents().text();b.parseImageResponse(c)})),this.$image_wrapper.on("change",'input[type="file"]',function(){if(void 0!==this.files)b.uploadFile(this.files);else{var c=a(this).parents("form");c.find('input[type="hidden"]').remove();for(var d in b.options.imageParams)c.append('');c.append(''),c.submit()}}),this.buildDragUpload(c);var d=a('').on("mouseup touchend keydown",a.proxy(function(a){a.stopPropagation()},this));this.$image_list=a("").append(a('').append(c)).append(a('').append('Enter URL: ').append(d).append(a('OK').click(a.proxy(function(){this.writeImage(d.val())},this)))),this.$image_wrapper.append(a("").append('Insert image').append(a('').click(a.proxy(function(){this.$bttn_wrapper.show(),this.hideImageWrapper(!0),this.restoreSelection(),this.options.inlineMode||this.imageMode?this.imageMode&&this.showImageEditor():this.hide()},this)))).append(this.$image_list).append(this.$progress_bar).click(function(a){a.stopPropagation()}).find("*").click(function(a){a.stopPropagation()}).end().hide()},b.prototype.buildInsertVideo=function(){this.$video_wrapper=a("").addClass("video-wrapper"),this.$popup_editor.append(this.$video_wrapper);var b=a('').on("mouseup touchend keydown",a.proxy(function(a){a.stopPropagation()},this)),c=a("").append(a('OK').click(a.proxy(function(){this.restoreSelection(),a(this.getSelectionElements()[0]).after(this.options.paragraphy?''+b.val()+"":''+b.val()+""),this.saveUndoStep(),this.$bttn_wrapper.show(),this.hideVideoWrapper(),this.hide(),this.callback("insertVideo",[b.val()])},this)));this.$video_wrapper.append(a("").append('Insert video').append(a('').click(a.proxy(function(){this.$bttn_wrapper.show(),this.hideVideoWrapper(),this.restoreSelection(),this.options.inlineMode||this.hide()},this)))).append(b).append(c).click(function(a){a.stopPropagation()}).find("*").click(function(a){a.stopPropagation()}).end().hide()},b.prototype.buildCreateLink=function(){this.$link_wrapper=a("").addClass("link-wrapper"),this.$popup_editor.append(this.$link_wrapper);var b=a('').attr("placeholder","http://www.example.com").on("mouseup touchend keydown",function(a){a.stopPropagation()}),c=a('').click(function(a){a.stopPropagation()}),d=a('').text("OK").on("touchend",function(a){a.stopPropagation()}).click(a.proxy(function(){this.writeLink(b.val(),c.prop("checked"))},this)),e=a('').text("UNLINK").on("click touch",a.proxy(function(){this.link=!0,this.writeLink("",c.prop("checked"))},this));this.$link_wrapper.append(a("").append('Insert link').append(a('').click(a.proxy(function(){this.$bttn_wrapper.show(),this.hideLinkWrapper(),this.options.inlineMode||this.imageMode?this.imageMode&&this.showImageEditor():this.hide(),this.restoreSelection()},this)))).append(b).append(a("").append(c).append(' Open in new tab').append(d).append(e)).end().hide()},b.prototype.buildDragUpload=function(b){var c=this;b.on({dragover:function(){return a(this).addClass("f-hover"),!1},dragend:function(){return a(this).removeClass("f-hover"),!1},drop:function(b){a(this).removeClass("f-hover"),b.preventDefault(),c.uploadFile(b.originalEvent.dataTransfer.files)}})},b.prototype.hideImageLoader=function(){this.$progress_bar.hide(),this.$progress_bar.find("span").css("width","0%").text(""),this.$image_list.show()},b.prototype.writeImage=function(b){var c=new Image;if(c.onerror=a.proxy(function(){this.hideImageLoader(),this.throwImageError(1)},this),this.imageMode)return c.onload=a.proxy(function(){this.$element.find(".f-img-editor > img").attr("src",b),this.hide(),this.hideImageLoader(),this.$image_editor.show(),this.saveUndoStep(),this.callback("replaceImage",[b])},this),c.src=b,!1;var d=this.getSelectionElements()[0];c.onload=a.proxy(function(){a(d).prepend(''),a(d).find("img:first").get(0).oncontrolselect=function(){return!1},this.hide(),this.hideImageLoader(),this.saveUndoStep(),this.callback("insertImage",[b])},this),c.src=b},b.prototype.throwImageError=function(b){var c="Unknown image upload error.";1==b?c="Bad link.":2==b?c="No link in upload response.":3==b?c="Error during file upload.":4==b&&(c="Parsing response failed."),this.options.imageErrorCallback&&a.isFunction(this.options.imageErrorCallback)&&this.options.imageErrorCallback({errorCode:b,errorStatus:c})},b.prototype.uploadFile=function(b){if(void 0!==b&&b.length>0){var c;if(this.drag_support.formdata&&(c=this.drag_support.formdata?new FormData:null),c&&c.append(this.options.imageUploadParam,b[0]),c){var d;this.options.crossDomain?d=this.createCORSRequest("POST",this.options.imageUploadURL):(d=new XMLHttpRequest,d.open("POST",this.options.imageUploadURL)),d.onload=a.proxy(function(){this.$progress_bar.find("span").css("width","100%").text("Please wait!");try{200==d.status?this.parseImageResponse(d.responseText):this.throwImageError(3)}catch(a){this.throwImageError(4)}this.hideImageLoader()},this),d.onerror=a.proxy(function(){this.throwImageError(3),this.hideImageLoader()},this),d.upload.onprogress=a.proxy(function(a){if(a.lengthComputable){var b=a.loaded/a.total*100|0;this.$progress_bar.find("span").css("width",b+"%")}},this);for(var e in this.options.imageParams)c.append(e,this.options.imageParams[e]);d.send(c),this.$image_list.hide(),this.$progress_bar.show()}}},b.prototype.parseImageResponse=function(b){try{var c=a.parseJSON(b);"http://uploads.im/api"==this.options.imageUploadURL?this.writeImage(c.data.img_url):c.link?this.writeImage(c.link):this.throwImageError(2)}catch(d){this.throwImageError(4)}},b.prototype.createCORSRequest=function(a,b){var c=new XMLHttpRequest;return"withCredentials"in c?c.open(a,b,!0):"undefined"!=typeof XDomainRequest?(c=new XDomainRequest,c.open(a,b)):c=null,c},b.prototype.writeLink=function(b,c){if(this.imageMode)return""!==b?("A"!=this.$element.find(".f-img-editor").parent().get(0).tagName?this.$element.find(".f-img-editor").wrap(c===!0?'':''):c===!0?this.$element.find(".f-img-editor").parent().attr("target","_blank"):(this.$element.find(".f-img-editor").parent().removeAttr("target"),this.$element.find(".f-img-editor").parent().attr("href",b)),this.callback("insertImageLink",[b])):("A"==this.$element.find(".f-img-editor").parent().get(0).tagName&&a(this.$element.find(".f-img-editor").get(0)).unwrap(),this.callback("removeImageLink")),this.saveUndoStep(),this.showImageEditor(),this.$element.find(".f-img-editor").find("img").click(),this.link=!1,!1;if(this.restoreSelection(),document.execCommand("unlink",!1,b),this.saveSelectionByMarkers(),this.$element.find("span.f-link").each(function(b,c){a(c).replaceWith(a(c).html())}),this.restoreSelectionByMarkers(),""!==b){document.execCommand("createLink",!1,b);for(var d=this.getSelectionLinks(),e=0;e-1&&e.push(c[h])}d.detach()}}else if(document.selection&&"Control"!=document.selection.type)if(a=document.selection.createRange(),b=a.parentElement(),"a"==b.nodeName.toLowerCase())e.push(b);else{c=b.getElementsByTagName("a"),d=document.body.createTextRange();for(var i=0;i-1&&d.compareEndPoints("EndToStart",a)<1&&e.push(c[i])}return e},b.prototype.isEnabled=function(b){return a.inArray(b,this.options.buttons)>=0},b.prototype.show=function(b){if(void 0!==b){if(this.options.inlineMode)if(null!==b&&"touchend"!==b.type){var c=b.pageX,d=b.pageY;20>c&&(c=20),0>d&&(d=0),c+this.$editor.width()>a(window).width()-50?(this.$editor.addClass("right-side"),c=a(window).width()-(c+30),this.$editor.css("top",d+20),this.$editor.css("right",c),this.$editor.css("left","auto")):(this.$editor.removeClass("right-side"),this.$editor.css("top",d+20),this.$editor.css("left",c-20),this.$editor.css("right","auto")),a(".froala-editor:not(.f-basic)").hide(),this.$editor.show()}else a(".froala-editor:not(.f-basic)").hide(),this.$editor.show(),this.repositionEditor();this.hideLinkWrapper(),this.hideVideoWrapper(),this.hideImageWrapper(),this.$bttn_wrapper.show(),this.$bttn_wrapper.find(".fr-dropdown").removeClass("active"),this.refreshButtons(),this.imageMode=!1}},b.prototype.showByCoordinates=function(b,c){b-=20,c+=15,b+this.$popup_editor.width()>a(window).width()-50?(this.$popup_editor.addClass("right-side"),b=a(window).width()-(b+40),this.$popup_editor.css("top",c),this.$popup_editor.css("right",b),this.$popup_editor.css("left","auto")):(this.$popup_editor.removeClass("right-side"),this.$popup_editor.css("top",c),this.$popup_editor.css("left",b),this.$popup_editor.css("right","auto")),this.$popup_editor.show()},b.prototype.showLinkWrapper=function(){this.$link_wrapper&&this.$link_wrapper.show()},b.prototype.hideLinkWrapper=function(){this.$link_wrapper&&this.$link_wrapper.hide()},b.prototype.showImageWrapper=function(){this.$image_wrapper&&this.$image_wrapper.show()},b.prototype.showVideoWrapper=function(){this.$video_wrapper&&this.$video_wrapper.show()},b.prototype.hideImageWrapper=function(a){this.$image_wrapper&&(this.$element.attr("data-resize")||a||this.closeImageMode(),this.$image_wrapper.hide())},b.prototype.hideVideoWrapper=function(){this.$video_wrapper&&this.$video_wrapper.hide()},b.prototype.showInsertLink=function(){this.options.inlineMode&&this.$bttn_wrapper.hide(),this.showLinkWrapper(),this.hideImageWrapper(!0),this.hideVideoWrapper(),this.$image_editor.hide(),this.link=!0},b.prototype.showInsertImage=function(){this.options.inlineMode&&this.$bttn_wrapper.hide(),this.hideLinkWrapper(),this.hideVideoWrapper(),this.showImageWrapper(),this.$image_editor.hide()},b.prototype.showInsertVideo=function(){this.options.inlineMode&&this.$bttn_wrapper.hide(),this.hideLinkWrapper(),this.hideImageWrapper(),this.showVideoWrapper(),this.$image_editor.hide()},b.prototype.showImageEditor=function(){this.options.inlineMode&&this.$bttn_wrapper.hide(),this.hideLinkWrapper(),this.hideImageWrapper(!0),this.hideVideoWrapper(),this.$image_editor.show(),this.options.imageMove||this.$element.attr("contenteditable",!1)},b.prototype.hide=function(){this.$popup_editor.hide(),this.hideLinkWrapper(),this.hideImageWrapper(),this.hideVideoWrapper(),this.$image_editor.hide(),this.link=!1},b.prototype.positionPopup=function(b){a(this.$editor.find('button.fr-bttn[data-cmd="'+b+'"]')).length&&(this.$popup_editor.css("top",this.$editor.find('button.fr-bttn[data-cmd="'+b+'"]').offset().top+30),this.$popup_editor.css("left",this.$editor.find('button.fr-bttn[data-cmd="'+b+'"]').offset().left),this.$popup_editor.show())},b.prototype.bindButtonEvents=function(){this.bindDropdownEvents(),this.bindCommandEvents()},b.prototype.bindDropdownEvents=function(){var b=this;this.$bttn_wrapper.find(".fr-dropdown").on("click touchend",function(c){return c.stopPropagation(),c.preventDefault(),0==b.options.inlineMode&&b.hide(),a(this).attr("data-disabled")?!1:(a(".fr-dropdown").not(this).removeClass("active"),void a(this).toggleClass("active"))}),a(window).on("click touchend",a.proxy(function(){this.$editor.find(".fr-dropdown").removeClass("active")},this)),this.$element.on("click touchend","img, a",a.proxy(function(){this.$editor.find(".fr-dropdown").removeClass("active")},this));var c=this.$bttn_wrapper.find(".fr-selector button.fr-bttn");c.bind("select",function(){a(this).parents(".fr-selector").find(" > button > i").attr("class",a(this).find("i").attr("class"))}).on("click touch",function(){a(this).parents("ul").find("button").removeClass("active"),a(this).parents(".fr-selector").removeClass("active").trigger("mouseout"),a(this).trigger("select")})},b.prototype.bindCommandEvents=function(){this.$bttn_wrapper.find("[data-cmd]").on("click touchend",a.proxy(function(b){b.stopPropagation(),b.preventDefault();var c=b.currentTarget,d=a(c).data("cmd"),e=a(c).data("val");a(c).parents(".fr-dropdown").removeClass("active"),this.exec(d,e),this.$bttn_wrapper.find(".fr-dropdown").removeClass("active")},this))},b.prototype.exec=function(a,b){if(!this.selectionInEditor()&&"html"!==a&&"undo"!==a&&"redo"!==a&&"selectAll"!==a&&"save"!=a&&"insertImage"!==a&&"insertVideo"!==a)return!1;if(this.selectionInEditor()&&""===this.text()&&"fontSize"!==a&&"formatBlock"!==a&&"indent"!==a&&"outdent"!==a&&"justifyLeft"!==a&&"justifyRight"!==a&&"justifyFull"!==a&&"justifyCenter"!==a&&"html"!==a&&"undo"!==a&&"redo"!==a&&"selectAll"!==a&&"save"!==a&&"insertImage"!==a&&"insertVideo"!==a&&"insertOrderedList"!==a&&"insertUnorderedList"!==a)return!1;switch(a){case"fontSize":this.fontSize(b);break;case"backColor":this.backColor(b);break;case"foreColor":this.foreColor(b);break;case"formatBlock":this.formatBlock(b);break;case"createLink":this.insertLink();break;case"insertImage":this.insertImage();break;case"indent":this.indent();break;case"outdent":this.outdent(!0);break;case"justifyLeft":case"justifyRight":case"justifyCenter":case"justifyFull":this.align(a);break;case"insertOrderedList":case"insertUnorderedList":this.formatList(a);break;case"insertVideo":this.insertVideo();break;case"indent":case"outdent":this.execDefault(a,b),this.repositionEditor();break;case"undo":this.undo();break;case"redo":this.redo();break;case"html":this.html();break;case"save":this.save();break;case"selectAll":this.$element.focus(),this.execDefault(a,b);break;default:this.execDefault(a,b)}"undo"!=a&&"redo"!=a&&"selectAll"!=a&&"createLink"!=a&&"insertImage"!=a&&"html"!=a&&"insertVideo"!=a&&this.saveUndoStep(),"createLink"!=a&&"insertImage"!=a&&this.refreshButtons()},b.prototype.undo=function(){if(this.undoIndex>1){var a=this.getHTML();this.$element.html(this.undoStack[--this.undoIndex-1]),this.hide(),this.callback("undo",[this.$element.html(),a])}this.refreshUndoRedo()},b.prototype.redo=function(){if(this.undoIndex").attr("data-font",!0).css("font-size",b).html(a(e).html());0===a(e).parents("font").length&&c.push(f),a(e).replaceWith(f)});var d=function(b,c){a(c).css("font-size","")};for(var e in c){var f=c[e];a(f).find("*").each(d)}this.$element.find('span[data-font="true"] > span[data-font="true"]').each(function(b,c){a(c).attr("style")&&(a(c).before(''),a(c).after(''))});var g=this.$element.html();g=g.replace(new RegExp('',"g"),""),g=g.replace(new RegExp('data-open="true">',"g"),">"),this.$element.html(g);for(var h=!0,i=a.proxy(function(){this.$element.find('span[data-font="true"] + span[data-font="true"]').each(function(b,c){a(c).css("font-size")==a(c).prev().css("font-size")&&(a(c).prepend(a(c).prev().html()),a(c).prev().remove(),h=!0)}),this.$element.find('span[data-font="true"] + span#marker-true + span[data-font="true"], span[data-font="true"] + span#marker-true + span[data-font="true"]').each(function(b,c){a(c).css("font-size")==a(c).prev().prev().css("font-size")&&(a(c).prepend(a(c).prev().clone()),a(c).prepend(a(c).prev().prev().html()),a(c).prev().prev().remove(),a(c).prev().remove(),h=!0)})},this);h;)h=!1,i();this.$element.find('span[style=""]').each(function(b,c){a(c).replaceWith(a(c).html())}),this.$element.find("span[data-font]").each(function(b,c){a(c).css("font-size")==a(c).parent().css("font-size")&&a(c).replaceWith(a(c).html())}),this.restoreSelectionByMarkers(),this.repositionEditor(),this.callback("fontSize")},b.prototype.backColor=function(c){var d="backColor";this.browser.msie||(d="hiliteColor");var e=a(this.getSelectionElement()).css("background-color");document.execCommand(d,!1,c);var f=this.$editor.find('button.fr-color-bttn[data-cmd="backColor"][data-val="'+c+'"]');f.addClass("active"),f.siblings().removeClass("active"),this.callback("backColor",[b.hexToRGBString(c),e])},b.prototype.foreColor=function(c){var d=a(this.getSelectionElement()).css("color");document.execCommand("foreColor",!1,c),this.saveSelectionByMarkers(),this.$element.find("font[color]").each(function(b,d){a(d).replaceWith(a("").css("color",c).html(a(d).html()))}),this.restoreSelectionByMarkers();var e=this.$editor.find('button.fr-color-bttn[data-cmd="foreColor"][data-val="'+c+'"]');e.addClass("active"),e.siblings().removeClass("active"),this.callback("foreColor",[b.hexToRGBString(c),d])},b.prototype.formatBlock=function(b){if(this.disabledList.indexOf("formatBlock")>=0)return!1;this.saveSelectionByMarkers(),this.wrapText(),this.restoreSelectionByMarkers();var c,d=this.getSelectionElements();for(var e in d){var f=a(d[e]);if(c="n"==b?a("").html(f.html()):a("<"+b+">").html(f.html()),f.get(0)!=this.$element.get(0)&&"LI"!=f.get(0).tagName){var g=f.prop("attributes");if(c.attr)for(var h in g)c.attr(g[h].name,g[h].value);f.replaceWith(c)}else f.html(c)}this.clearSelection(),this.hide(),this.callback("formatBlock")},b.prototype.formatList=function(b){this.saveSelectionByMarkers();var c,d=this.getSelectionElements(),e=!0,f=!1;for(var g in d)c=a(d[g]),c.parents("li").length>0?(c.parents("ol").length>0?(c.parents("li").before(''),c.parents("li").after('')):c.parents("ul").length>0&&(c.parents("li").before(''),c.parents("li").after('')),c.parents("li").replaceWith(c.parents("li").contents()),f=!0):e=!1;if(f){var h=this.$element.html();h=h.replace(new RegExp('',"g"),""),h=h.replace(new RegExp('',"g"),""),h=h.replace(new RegExp('',"g"),""),h=h.replace(new RegExp('',"g"),""),this.$element.html(h),this.$element.find("ul:empty, ol:empty").remove()}if(this.clearSelection(),this.wrapText(),this.restoreSelectionByMarkers(),e===!1){d=this.getSelectionElements(),this.saveSelectionByMarkers();var i=a("");"insertUnorderedList"==b&&(i=a(""));for(var j in d)c=a(d[j]),c.get(0)!=this.$element.get(0)&&(i.append(a("").append(c.clone())),j!=d.length-1?c.remove():c.replaceWith(i));this.restoreSelectionByMarkers()}this.repositionEditor(),this.callback(b)},b.prototype.align=function(b){var c=this.getSelectionElements();this.saveSelection(),"justifyLeft"==b?b="left":"justifyRight"==b?b="right":"justifyCenter"==b?b="center":"justifyFull"==b&&(b="justify");for(var d in c)a(c[d]).css("text-align",b);this.restoreSelection(),this.repositionEditor(),this.callback("align")},b.prototype.indent=function(b){var c=20;b&&(c=-20),this.saveSelectionByMarkers(),this.wrapText(),this.restoreSelectionByMarkers();var d=this.getSelectionElements();this.saveSelectionByMarkers();for(var e in d){var f=a(d[e]);if(f.get(0)!=this.$element.get(0)){var g=parseInt(f.css("margin-left").replace(/px/,""),10),h=Math.max(0,g+c);f.css("marginLeft",h)}else{var i=a("").html(f.html());f.html(i),i.css("marginLeft",Math.max(0,c))}}this.restoreSelectionByMarkers(),this.repositionEditor(),b||this.callback("indent")},b.prototype.outdent=function(){this.indent(!0),this.callback("outdent")},b.prototype.insertLink=function(){this.showInsertLink(),this.options.inlineMode||this.positionPopup("createLink"),this.saveSelection();var b=this.getSelectionLink(),c=this.getSelectionLinks();c.length>0&&this.$link_wrapper.find('input[type="checkbox"]').prop("checked","_blank"==a(c[0]).attr("target")),this.$link_wrapper.find('input[type="text"]').val(b||"http://")},b.prototype.insertImage=function(){this.showInsertImage(),this.saveSelection(),this.options.inlineMode||this.positionPopup("insertImage"),this.$image_wrapper.find('input[type="text"]').val("")},b.prototype.insertVideo=function(){this.showInsertVideo(),this.saveSelection(),this.options.inlineMode||this.positionPopup("insertVideo"),this.$video_wrapper.find("textarea").val("")},b.prototype.execDefault=function(a,b){document.execCommand(a,!1,b),"insertOrderedList"==a?this.$bttn_wrapper.find('[data-cmd="insertUnorderedList"]').removeClass("active"):"insertUnorderedList"==a&&this.$bttn_wrapper.find('[data-cmd="insertOrderedList"]').removeClass("active"),this.callback(a)},b.prototype.refreshButtons=function(){return!this.selectionInEditor()||this.isHTML?!1:(this.refreshUndoRedo(),void this.$bttn_wrapper.find("[data-cmd]").each(a.proxy(function(b,c){switch(a(c).data("cmd")){case"fontSize":this.refreshFontSize(c);break;case"backColor":this.refreshBackColor(c);break;case"foreColor":this.refreshForeColor(c);break;case"formatBlock":this.refreshFormatBlock(c);break;case"createLink":case"insertImage":break;case"justifyLeft":case"justifyRight":case"justifyCenter":case"justifyFull":this.refreshAlign(c);break;case"html":this.isHTML?a(c).addClass("active"):a(c).removeClass("active");break;case"undo":case"redo":case"save":break;default:this.refreshDefault(c)}},this)))},b.prototype.refreshFormatBlock=function(b){this.disabledList.indexOf("formatBlock")>=0&&a(b).parents(".fr-dropdown").attr("data-disabled",!0)},b.prototype.refreshUndoRedo=function(){if(this.isEnabled("undo")||this.isEnabled("redo")){if(void 0===this.$editor)return;this.$bttn_wrapper.find('[data-cmd="undo"], [data-cmd="redo"]').prop("disabled",!1),(0===this.undoStack.length||this.undoIndex<=1||this.isHTML)&&this.$bttn_wrapper.find('[data-cmd="undo"]').prop("disabled",!0),(this.undoIndex==this.undoStack.length||this.isHTML)&&this.$bttn_wrapper.find('[data-cmd="redo"]').prop("disabled",!0)}},b.prototype.refreshDefault=function(b){a(b).removeClass("active");try{document.queryCommandState(a(b).data("cmd"))===!0&&a(b).addClass("active")}catch(c){}},b.prototype.refreshAlign=function(b){var c=a(b).data("cmd"),d=this.getSelectionElements();"justifyLeft"==c?c="left":"justifyRight"==c?c="right":"justifyCenter"==c?c="center":"justifyFull"==c&&(c="justify"),c==a(d[0]).css("text-align")&&(a(b).parents("ul").find(".fr-bttn").removeClass("active"),a(b).addClass("active"),a(b).parents(".fr-dropdown").find(".fr-trigger").html(a(b).html()))},b.prototype.refreshForeColor=function(b){a(b).removeClass("active"),document.queryCommandValue("foreColor")==b.style.backgroundColor&&a(b).addClass("active")},b.prototype.refreshBackColor=function(b){a(b).removeClass("active"),document.queryCommandValue("backColor")==b.style.backgroundColor&&a(b).addClass("active")},b.prototype.refreshFontSize=function(b){a(b).removeClass("active"),parseInt(document.queryCommandValue("fontSize"),10)==parseInt(a(b).data("val"),10)&&a(b).addClass("active") +if("undefined"==typeof jQuery)throw new Error("Froala requires jQuery");!function(a){"use strict";var b=function(c,d){this.options=a.extend({},b.DEFAULTS,a(c).data(),"object"==typeof d&&d),this.browser=b.browser(),this.disabledList=[],this._id=++b.count,this.init(c)};b.count=0,b.VALID_NODES=["P","PRE","BLOCKQUOTE","H1","H2","H3","H4","H5","H6","DIV"],b.COLORS=["#000000","#444444","#666666","#999999","#CCCCCC","#EEEEEE","#F3F3F3","#FFFFFF","#FF0000","#FF9900","#FFFF00","#00FF00","#00FFFF","#0000FF","#9900FF","#FF00FF","#F4CCCC","#FCE5CD","#FFF2CC","#D9EAD3","#D0E0E3","#CFE2F3","#D9D2E9","#EAD1DC","#EA9999","#F9CB9C","#FFE599","#B6D7A8","#A2C4C9","#9FC5E8","#B4A7D6","#D5A6BD","#E06666","#F6B26B","#FFD966","#93C47D","#76A5AF","#6FA8DC","#8E7CC3","#C27BA0","#CC0000","#E69138","#F1C232","#6AA84F","#45818E","#3D85C6","#674EA7","#A64D79","#990000","#B45F06","#BF9000","#38771D","#134F5C","#0B5394","#351C75","#741B47","#660000","#783F04","#7F6000","#274E13","#0C343D","#073763","#201211","#4C1130"],b.commands={bold:{title:"Bold",icon:"fa fa-bold",shortcut:"(Ctrl + B)"},italic:{title:"Italic",icon:"fa fa-italic",shortcut:"(Ctrl + I)"},underline:{cmd:"underline",title:"Underline",icon:"fa fa-underline",shortcut:"(Ctrl + U)"},strikeThrough:{title:"Strikethrough",icon:"fa fa-strikethrough"},fontSize:{title:"Font Size",icon:"fa fa-text-height",seed:[{min:11,max:52}]},color:{icon:"fa fa-font",title:"Color",seed:[{cmd:"backColor",value:b.COLORS,title:"Background Color"},{cmd:"foreColor",value:b.COLORS,title:"Text Color"}]},formatBlock:{title:"Format Block",icon_alt:"¶",seed:[{value:"n",title:"Normal"},{value:"p",title:"Paragraph"},{value:"pre",title:"Code"},{value:"blockquote",title:"Quote"},{value:"h1",title:"Heading 1"},{value:"h2",title:"Heading 2"},{value:"h3",title:"Heading 3"},{value:"h4",title:"Heading 4"},{value:"h5",title:"Heading 5"},{value:"h6",title:"Heading 6"}]},align:{title:"Alignment",icon:"fa fa-align-center",seed:[{cmd:"justifyLeft",title:"Align Left",icon:"fa fa-align-left"},{cmd:"justifyCenter",title:"Align Center",icon:"fa fa-align-center"},{cmd:"justifyRight",title:"Align Right",icon:"fa fa-align-right"},{cmd:"justifyFull",title:"Justify",icon:"fa fa-align-justify"}]},insertOrderedList:{title:"Numbered List",icon:"fa fa-list-ol"},insertUnorderedList:{title:"Bulleted List",icon:"fa fa-list-ul"},outdent:{title:"Indent Less",icon:"fa fa-dedent",activeless:!0,shortcut:"(Ctrl + <)"},indent:{title:"Indent More",icon:"fa fa-indent",activeless:!0,shortcut:"(Ctrl + >)"},selectAll:{title:"Select All",icon:"fa fa-file-text",shortcut:"(Ctrl + A)"},createLink:{title:"Insert Link",icon:"fa fa-link",shortcut:"(Ctrl + K)"},insertImage:{title:"Insert Image",icon:"fa fa-picture-o",activeless:!0,shortcut:"(Ctrl + P)"},undo:{title:"Undo",icon:"fa fa-undo",activeless:!0,shortcut:"(Ctrl+Z)"},redo:{title:"Redo",icon:"fa fa-repeat",activeless:!0,shortcut:"(Shift+Ctrl+Z)"},html:{title:"Show HTML",icon:"fa fa-code"},save:{title:"Save",icon:"fa fa-floppy-o"},insertVideo:{title:"Insert Video",icon:"fa fa-video-camera"}},b.LANGS=[],b.DEFAULTS={autosave:!1,autosaveInterval:1e3,saveURL:null,saveParams:{},blockTags:["n","p","blockquote","pre","h1","h2","h3","h4","h5","h6"],borderColor:"#252528",buttons:["bold","italic","underline","strikeThrough","fontSize","color","sep","formatBlock","align","insertOrderedList","insertUnorderedList","outdent","indent","sep","createLink","insertImage","insertVideo","undo","redo","html"],crossDomain:!1,direction:"ltr",editorClass:"",enableScript:!1,height:"auto",imageMargin:20,imageParams:{},imageErrorCallback:!1,imageMove:!0,imageUploadParam:"file",imageUploadURL:"http://uploads.im/api",inverseSkin:!1,inlineMode:!0,paragraphy:!0,placeholder:"Type something",shortcuts:!0,customText:!1,spellcheck:!1,toolbarFixed:!0,typingTimer:250,width:"auto",language:"en_us",customButtons:[]},b.hexToRGB=function(a){var b=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;a=a.replace(b,function(a,b,c,d){return b+b+c+c+d+d});var c=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a);return c?{r:parseInt(c[1],16),g:parseInt(c[2],16),b:parseInt(c[3],16)}:null},b.hexToRGBString=function(a){var b=this.hexToRGB(a);return"rgb("+b.r+", "+b.g+", "+b.b+")"},b.getIEversion=function(){var a,b,c=-1;return"Microsoft Internet Explorer"==navigator.appName?(a=navigator.userAgent,b=new RegExp("MSIE ([0-9]{1,}[\\.0-9]{0,})"),null!==b.exec(a)&&(c=parseFloat(RegExp.$1))):"Netscape"==navigator.appName&&(a=navigator.userAgent,b=new RegExp("Trident/.*rv:([0-9]{1,}[\\.0-9]{0,})"),null!==b.exec(a)&&(c=parseFloat(RegExp.$1))),c},b.browser=function(){var a={};if(b.getIEversion()>0)a.msie=!0;else{var c=navigator.userAgent.toLowerCase(),d=/(chrome)[ \/]([\w.]+)/.exec(c)||/(webkit)[ \/]([\w.]+)/.exec(c)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(c)||/(msie) ([\w.]+)/.exec(c)||c.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(c)||[],e={browser:d[1]||"",version:d[2]||"0"};d[1]&&(a[e.browser]=!0),parseInt(e.version,10)<9&&a.msie&&(a.oldMsie=!0),a.chrome?a.webkit=!0:a.webkit&&(a.safari=!0)}return a},b.prototype.text=function(){var a="";return window.getSelection?a=window.getSelection():document.getSelection?a=document.getSelection():document.selection&&(a=document.selection.createRange().text),a.toString()},b.prototype.selectionInEditor=function(){var b=this.getSelectionParent(),c=!1;return b==this.$element.get(0)?!0:(a(b).parents().each(a.proxy(function(a,b){b==this.$element.get(0)&&(c=!0)},this)),c)},b.prototype.getSelection=function(){var a="";return a=window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange()},b.prototype.getRange=function(){if(window.getSelection){var a=window.getSelection();if(a.getRangeAt&&a.rangeCount)return a.getRangeAt(0)}return document.createRange()},b.prototype.clearSelection=function(){if(window.getSelection){var a=window.getSelection();a.removeAllRanges()}else document.selection.createRange&&(document.selection.createRange(),document.selection.empty())},b.prototype.getSelectionElement=function(){var a=this.getSelection();if(a.rangeCount){var b=a.getRangeAt(0).startContainer;return 1!=b.nodeType?b.parentNode:b}return this.$element.get(0)},b.prototype.getSelectionParent=function(){var a,b=null;return window.getSelection?(a=window.getSelection(),a.rangeCount&&(b=a.getRangeAt(0).commonAncestorContainer,1!=b.nodeType&&(b=b.parentNode))):(a=document.selection)&&"Control"!=a.type&&(b=a.createRange().parentElement()),b},b.prototype.nodeInRange=function(a,b){var c;if(a.intersectsNode)return a.intersectsNode(b);c=b.ownerDocument.createRange();try{c.selectNode(b)}catch(d){c.selectNodeContents(b)}return-1==a.compareBoundaryPoints(Range.END_TO_START,c)&&1==a.compareBoundaryPoints(Range.START_TO_END,c)},b.prototype.getElementFromNode=function(c){for(1!=c.nodeType&&(c=c.parentNode);null!==c&&b.VALID_NODES.indexOf(c.tagName)<0;)c=c.parentNode;return a.makeArray(a(c).parents()).indexOf(this.$element.get(0))>=0?c:null},b.prototype.nextNode=function(a){if(a.hasChildNodes())return a.firstChild;for(;a&&!a.nextSibling;)a=a.parentNode;return a?a.nextSibling:null},b.prototype.getRangeSelectedNodes=function(a){var b=a.startContainer,c=a.endContainer;if(b==c)return[b];for(var d=[];b&&b!=c;)d.push(b=this.nextNode(b));for(b=a.startContainer;b&&b!=a.commonAncestorContainer;)d.unshift(b),b=b.parentNode;return d},b.prototype.getSelectedNodes=function(){if(window.getSelection){var a=window.getSelection();if(!a.isCollapsed)return this.getRangeSelectedNodes(a.getRangeAt(0));if(this.selectionInEditor()){var b=a.getRangeAt(0).startContainer;return 3==b.nodeType?[b.parentNode]:[b]}}return[]},b.prototype.getSelectionElements=function(){var b=this.getSelectedNodes(),c=[];return a.each(b,a.proxy(function(a,b){if(null!==b){var d=this.getElementFromNode(b);c.indexOf(d)<0&&d!=this.$element.get(0)&&null!==d&&c.push(d)}},this)),0===c.length&&c.push(this.$element.get(0)),c},b.prototype.getSelectionLink=function(){var a,b;return window.getSelection?(b=window.getSelection(),a=b.anchorNode.parentNode.href):(b=document.selection)&&"Control"!=b.type&&(a=b.createRange().parentElement().href),a},b.prototype.saveSelection=function(){var a,b,c,d=this.getSelection();if(d.getRangeAt&&d.rangeCount){for(c=[],a=0,b=d.rangeCount;b>a;a+=1)c.push(d.getRangeAt(a));this.savedRanges=c}else this.savedRanges=null},b.prototype.restoreSelection=function(){var a,b,c=this.getSelection();if(this.savedRanges)for(c.removeAllRanges(),a=0,b=this.savedRanges.length;b>a;a+=1)c.addRange(this.savedRanges[a])},b.prototype.saveSelectionByMarkers=function(){var a=this.getRange();this.placeMarker(a,!0),this.placeMarker(a,!1)},b.prototype.restoreSelectionByMarkers=function(){var a=this.$element.find("#marker-true"),b=this.$element.find("#marker-false");return a.length&&b.length?(this.$element.removeAttr("contentEditable"),this.$element.focus(),this.setSelection(a[0],0,b[0],0),this.removeMarkers(),void this.$element.attr("contentEditable",!0)):!1},b.prototype.setSelection=function(a,b,c,d){try{null===c&&(c=a),null===d&&(d=b);var e=this.getSelection();if(!e)return;var f=this.getRange();f.setStart(a,b),f.setEnd(c,d),e.removeAllRanges(),e.addRange(f)}catch(g){}},b.prototype.placeMarker=function(b,c){var d=b.cloneRange();d.collapse(c),d.insertNode(a('',document)[0]),d.detach()},b.prototype.removeMarkers=function(){this.$element.find("#marker-true, #marker-false").removeAttr("id")},b.prototype.getBoundingRect=function(){var a=this.getRange().getBoundingClientRect();return a},b.prototype.repositionEditor=function(b){var c,d,e;(this.options.inlineMode||b)&&(c=this.getBoundingRect(),void 0!==c.left&&void 0!==c.top&&void 0!==c.right&&void 0!==c.bottom?(d=c.left+c.width/2+a(window).scrollLeft(),e=c.top+c.height+a(window).scrollTop(),this.isTouch()&&(d=c.left+c.width/2,e=c.top+c.height),this.showByCoordinates(d,e)):(document.execCommand("selectAll"),c=this.getRange().getBoundingClientRect(),d=c.left+a(window).scrollLeft(),e=c.top+c.height+a(window).scrollTop(),this.isTouch()&&(d=c.left,e=c.top+c.height),this.showByCoordinates(d,e-20),this.getRange().collapse(!1)))},b.prototype.destroy=function(){this.sync(),this.$editor.remove(),this.$popup_editor&&this.$popup_editor.remove(),this.$element.replaceWith(this.getHTML()),this.$box.removeClass("froala-box"),this.$box.find(".html-switch").remove(),this.$box.removeData("fa.editable"),clearTimeout(this.typingTimer),clearTimeout(this.ajaxInterval),this.$element.off("mousedown mouseup click keydown keyup keypress touchstart touchend touch drop","**"),void 0!==this.$upload_frame&&this.$upload_frame.remove(),this.$textarea&&(this.$box.remove(),this.$textarea.removeData("fa.editable"),this.$textarea.show())},b.prototype.callback=function(b,c,d){var e=b+"Callback";this.options[e]&&a.isFunction(this.options[e])&&(c?this.options[e].apply(this,c):this.options[e].call(this)),void 0==d&&(console.log("sync"),this.sync())},b.prototype.sync=function(){for(""!==this.text()&&this.saveSelectionByMarkers(),this.$element.find("b").each(function(b,c){a(c).replaceWith(""+a(c).html()+"")}),this.$element.find("i").each(function(b,c){a(c).replaceWith(""+a(c).html()+"")}),this.restoreSelectionByMarkers(),this.$textarea&&this.$textarea.val(this.getHTML());this.$element.find("span:empty").length;)this.$element.find("span:empty").remove();this.$element.find("*").each(a.proxy(function(b,c){this.emptyElement(c)&&"SPAN"==c.tagName&&a(c).remove()},this)),this.disableImageResize(),this.$element.trigger("placeholderCheck")},b.prototype.emptyElement=function(b){if("IMG"==b.tagName||a(b).find("img").length>0)return!1;for(var c=a(b).text(),d=0;d'),a(this).append(''),b.restoreSelectionByMarkers(),b.exec("createLink"),b.$link_wrapper.find('input[type="text"]').val(a(this).attr("href")),b.$link_wrapper.find('input[type="checkbox"]').prop("checked","_blank"==a(this).attr("target")),b.repositionEditor(!0),b.$popup_editor.show()})},b.prototype.imageHandle=function(){var b=this,c=a("").addClass("f-img-handle").on({movestart:function(c){b.hide(),b.$element.addClass("f-non-selectable").removeAttr("contenteditable"),b.isResizing=!0,a(this).attr("data-start-x",c.startX),a(this).attr("data-start-y",c.startY)},move:function(b){var c=a(this),d=b.pageX-parseInt(c.attr("data-start-x"),10);c.attr("data-start-x",b.pageX),c.attr("data-start-y",b.pageY);var e=c.prevAll("img");e.width(c.hasClass("f-h-ne")||c.hasClass("f-h-se")?e.width()+d:e.width()-d)},moveend:function(){if(b.isResizing=!1,a(this).removeAttr("data-start-x"),a(this).removeAttr("data-start-y"),b.$element.removeClass("f-non-selectable").attr("contenteditable",!0),b.browser.mozilla)try{document.execCommand("enableObjectResizing",!1,!1),document.execCommand("enableInlineTableEditing",!1,!1)}catch(c){}}});return c},b.prototype.disableImageResize=function(){if(this.browser.mozilla)try{document.execCommand("enableObjectResizing",!1,!1),document.execCommand("enableInlineTableEditing",!1,!1)}catch(a){}},b.prototype.initImageResizer=function(){this.disableImageResize();var b=this;this.$element.on("mousedown","img",function(){!b.options.imageMove||b.browser.msie?b.$element.attr("contenteditable",!1):a(this).parent().hasClass("f-img-editor")&&(b.closeImageMode(),b.hide())}),this.$element.find("img").each(function(a,b){b.oncontrolselect=function(){return!1}}),this.$element.on("mouseup","img",function(){b.options.imageMove||b.$element.attr("contenteditable",!0)}),this.$element.on("click touchend","img",function(c){c.preventDefault(),c.stopPropagation(),b.$element.blur(),b.$image_editor.find("button").removeClass("active");var d=a(this).css("float");b.$image_editor.find('button[data-cmd="floatImage'+d.charAt(0).toUpperCase()+d.slice(1)+'"]').addClass("active"),b.$image_editor.find('.f-image-alt input[type="text"]').val(a(this).attr("alt")||a(this).attr("title")),b.showImageEditor(),b.showByCoordinates(a(this).offset().left+a(this).width()/2,a(this).offset().top+a(this).height()),a(this).parent().hasClass("f-img-editor")&&"SPAN"==a(this).parent().get(0).tagName||(a(this).wrap(''),a(this).css("margin-left","auto"),a(this).css("margin-right","auto"),a(this).css("margin-bottom","auto"));var e=b.imageHandle();a(this).parent().append(e.clone(!0).addClass("f-h-ne")),a(this).parent().append(e.clone(!0).addClass("f-h-se")),a(this).parent().append(e.clone(!0).addClass("f-h-sw")),a(this).parent().append(e.clone(!0).addClass("f-h-nw")),b.clearSelection(),b.imageMode=!0}),this.$element.find("img").each(function(a,b){b.oncontrolselect=function(){return!1}})},b.prototype.initImagePopup=function(){var b=a("").addClass("fr-bttn").attr("data-cmd","floatImageLeft").attr("title","Float Left").html(''),c=a("").addClass("fr-bttn").attr("data-cmd","floatImageNone").attr("title","Float None").html(''),d=a("").addClass("fr-bttn").attr("data-cmd","floatImageRight").attr("title","Float Right").html(''),e=a("").addClass("fr-bttn").attr("data-cmd","linkImage").attr("title","Insert Link").html(''),f=a("").addClass("fr-bttn").attr("data-cmd","replaceImage").attr("title","Replace Image").html(''),g=a("").addClass("fr-bttn").attr("data-cmd","removeImage").attr("title","Remove Image").html(''),h=a('').append('Title: ').append(a('').on("mouseup touchend keydown",function(a){a.stopPropagation()})).append(a('').attr("data-cmd","setImageAlt").attr("title","OK").html("OK"));this.$image_editor=a("").addClass("bttn-wrapper f-image-editor").append(b).append(c).append(d).append(e).append(f).append(g).append("").append(h);var i=this;this.$image_editor.find("button").click(function(b){b.stopPropagation(),i[a(this).attr("data-cmd")](i.$element.find("span.f-img-editor"))}),this.$popup_editor.append(this.$image_editor)},b.prototype.floatImageLeft=function(a){a.css("margin-left","auto"),a.css("margin-right",this.options.imageMargin),a.css("margin-bottom",this.options.imageMargin),a.css("float","left"),a.find("img").css("float","left"),this.saveUndoStep(),this.callback("floatImageLeft"),a.find("img").click()},b.prototype.floatImageNone=function(a){a.css("margin-left","auto"),a.css("margin-right","auto"),a.css("margin-bottom","auto"),a.css("float","none"),a.find("img").css("float","none"),a.parent().get(0)==this.$element.get(0)?a.wrap(''):a.parent().css("text-align","center"),this.saveUndoStep(),this.callback("floatImageNone"),a.find("img").click()},b.prototype.floatImageRight=function(a){a.css("margin-right","auto"),a.css("margin-left",this.options.imageMargin),a.css("margin-bottom",this.options.imageMargin),a.css("float","right"),a.find("img").css("float","right"),this.saveUndoStep(),this.callback("floatImageRight"),a.find("img").click()},b.prototype.linkImage=function(a){this.showInsertLink(),this.imageMode=!0,"A"==a.parent().get(0).tagName?(this.$link_wrapper.find('input[type="text"]').val(a.parent().attr("href")),"_blank"==a.parent().attr("target")?this.$link_wrapper.find('input[type="checkbox"]').prop("checked",!0):this.$link_wrapper.find('input[type="checkbox"]').prop("checked",!1)):this.$link_wrapper.find('input[type="text"]').val("http://")},b.prototype.replaceImage=function(a){this.showInsertImage(),this.imageMode=!0,this.$image_wrapper.find('input[type="text"]').val(a.find("img").attr("src"))},b.prototype.removeImage=function(a){this.callback("beforeRemoveImage");var c="Are you sure? Image will be deleted.";b.LANGS[this.options.language]&&(c=b.LANGS[this.options.language].translation[c]),confirm(c)?(a.remove(),this.hide(),this.saveUndoStep(),this.callback("afterRemoveImage")):a.find("img").click()},b.prototype.setImageAlt=function(a){a.find("img").attr("alt",this.$image_editor.find('.f-image-alt input[type="text"]').val()),a.find("img").attr("title",this.$image_editor.find('.f-image-alt input[type="text"]').val()),this.saveUndoStep(),this.hide(),this.closeImageMode(),this.callback("setImageAlt")},b.prototype.initElement=function(b){"TEXTAREA"==b.tagName?(this.$textarea=a(b),void 0!==this.$textarea.attr("placeholder")&&"Type something"==this.options.placeholder&&(this.options.placeholder=this.$textarea.attr("placeholder")),this.$element=a("").html(this.$textarea.val()),this.$textarea.before(this.$element).hide()):("DIV"!=b.tagName&&this.options.buttons.indexOf("formatBlock")>=0&&this.disabledList.push("formatBlock"),this.$element=a(b)),this.$box=this.$element,this.$element=a(""),this.setHTML(this.$box.html()),this.$box.empty(),this.$box.html(this.$element).addClass("froala-box"),this.sync(),this.$element.on("drop",function(){setTimeout(function(){a("html").click()},1)})},b.prototype.trim=function(a){return String(a).replace(/^\s+|\s+$/g,"")},b.prototype.wrapText=function(){var b=[],c=["SPAN","A","B","I","EM","U","S","STRONG","STRIKE","FONT"],d=this;this.$element.contents().filter(function(){if(this.nodeType==Node.TEXT_NODE&&a(this).text().trim().length>0||c.indexOf(this.tagName)>=0)b.push(this);else{var e;e=a(d.options.paragraphy===!0?"":"");for(var f in b)e.append(a(b[f]).clone()),f==b.length-1?a(b[f]).replaceWith(e):a(b[f]).remove();b=[]}});var e;e=a(this.options.paragraphy===!0?"":"");for(var f in b)e.append(a(b[f]).clone()),f==b.length-1?a(b[f]).replaceWith(e):a(b[f]).remove();this.$element.find("div:empty, > br").remove()},b.prototype.setHTML=function(b){this.$element.html(a.htmlClean(b,{format:!0})),this.wrapText()},b.prototype.initElementStyle=function(){this.$element.attr("contentEditable",!0),this.$element.addClass("froala-element").addClass(this.options.editorClass),this.$element.css("outline",0)},b.prototype.initUndoRedo=function(){(this.isEnabled("undo")||this.isEnabled("redo"))&&(this.undoStack=[],this.undoIndex=0,this.saveUndoStep()),this.disableBrowserUndo()},b.prototype.enableTyping=function(){this.typingTimer=null,this.$element.on("keydown",a.proxy(function(){clearTimeout(this.typingTimer),this.ajaxSave=!1,this.oldHtml=this.$element.html(),this.typingTimer=setTimeout(a.proxy(function(){this.$element.html()!=this.oldHtml&&((this.isEnabled("undo")||this.isEnabled("redo"))&&this.$element.html()!=this.undoStack[this.undoIndex-1]&&this.saveUndoStep(),this.sync())},this),Math.max(this.options.typingTimer,200))},this))},b.prototype.getHTML=function(){var b=this.$element.clone();return b.find(".f-img-editor > img").each(function(b,c){a(c).css("margin-left",a(c).parent().css("margin-left")),a(c).css("margin-right",a(c).parent().css("margin-right")),a(c).css("margin-bottom",a(c).parent().css("margin-bottom")),a(c).siblings("span.f-img-handle").remove().end().unwrap()}),a.htmlClean(b.html())},b.prototype.initAjaxSaver=function(){this.ajaxHTML=this.getHTML(),this.ajaxSave=!0,this.ajaxInterval=setInterval(a.proxy(function(){this.ajaxHTML!=this.getHTML()&&this.ajaxSave&&(this.options.autosave&&this.save(),this.ajaxHTML=this.getHTML(),this.callback("contentChanged",[],!1)),this.ajaxSave=!0},this),Math.max(this.options.autosaveInterval,1e3))},b.prototype.disableBrowserUndo=function(){a("body").keydown(function(a){var b=a.which,c=a.ctrlKey||a.metaKey;if(!this.isHTM&&c){if(75==b)return a.preventDefault(),!1;if(90==b&&a.shiftKey)return a.preventDefault(),!1;if(90==b)return a.preventDefault(),!1}})},b.prototype.saveUndoStep=function(){if(this.isEnabled("undo")||this.isEnabled("redo")){for(;this.undoStack.length>this.undoIndex;)this.undoStack.pop();this.undoStack.push(this.getHTML()),this.undoIndex++,this.refreshUndoRedo()}this.sync()},b.prototype.initShortcuts=function(){this.options.shortcuts&&this.$element.on("keydown",a.proxy(function(a){var b=a.which,c=a.ctrlKey||a.metaKey;if(!this.isHTML&&c){if(70==b)return this.show(null),!1;if(66==b)return this.execDefaultShortcut("bold");if(73==b)return this.execDefaultShortcut("italic");if(85==b)return this.execDefaultShortcut("underline");if(75==b)return this.execDefaultShortcut("createLink");if(80==b)return this.repositionEditor(),this.execDefaultShortcut("insertImage");if(65==b)return this.execDefaultShortcut("selectAll");if(190==b)return this.execDefaultShortcut("indent");if(188==b)return this.execDefaultShortcut("outdent");if(72==b)return this.execDefaultShortcut("html");if(48==b)return this.execDefaultShortcut("formatBlock","n");if(49==b)return this.execDefaultShortcut("formatBlock","h1");if(50==b)return this.execDefaultShortcut("formatBlock","h2");if(51==b)return this.execDefaultShortcut("formatBlock","h3");if(52==b)return this.execDefaultShortcut("formatBlock","h4");if(53==b)return this.execDefaultShortcut("formatBlock","h5");if(54==b)return this.execDefaultShortcut("formatBlock","h6");if(90==b&&a.shiftKey)return this.redo(),a.stopPropagation(),!1;if(90==b)return this.undo(),a.stopPropagation(),!1}9!=b||a.shiftKey?9==b&&a.shiftKey&&a.preventDefault():(a.preventDefault(),this.insertHTML(" ",!1))},this))},b.prototype.insertHTML=function(a,b){var c,d;if(window.getSelection){if(c=window.getSelection(),c.getRangeAt&&c.rangeCount){d=c.getRangeAt(0),d.deleteContents();var e=document.createElement("div");e.innerHTML=a;for(var f,g,h=document.createDocumentFragment();f=e.firstChild;)g=h.appendChild(f);var i=h.firstChild;d.insertNode(h),g&&(d=d.cloneRange(),d.setStartAfter(g),b?d.setStartBefore(i):d.collapse(!0),c.removeAllRanges(),c.addRange(d))}}else if((c=document.selection)&&"Control"!=c.type){var j=c.createRange();j.collapse(!0),c.createRange().pasteHTML(a),b&&(d=c.createRange(),d.setEndPoint("StartToStart",j),d.select())}},b.prototype.execDefaultShortcut=function(a,b){return this.isEnabled(a)?(this.exec(a,b),!1):!0},b.prototype.initEditor=function(){this.$editor=a(""),this.$editor.addClass("froala-editor").hide(),a("body").append(this.$editor),this.options.inlineMode?this.initInlineEditor():this.initBasicEditor()},b.prototype.toolbarTop=function(){a(window).on("scroll resize",a.proxy(function(){this.options.toolbarFixed||this.options.inlineMode||(a(window).scrollTop()>this.$box.offset().top&&a(window).scrollTop() img").each(function(b,c){a(c).css("margin-left",a(c).parent().css("margin-left")),a(c).css("margin-right",a(c).parent().css("margin-right")),a(c).css("margin-bottom",a(c).parent().css("margin-bottom")),a(c).siblings("span.f-img-handle").remove().end().unwrap()}),this.$element.find("span.f-img-editor").length&&this.$element.find("span.f-img-editor").remove(),this.$element.removeClass("f-non-selectable").attr("contenteditable",!0),this.$image_editor.hide()},b.prototype.isTouch=function(){return Modernizr.touch&&void 0!==window.Touch},b.prototype.initEditorSelection=function(){this.$element.on("mousedown touchstart",a.proxy(function(){this.$element.attr("data-resize")||(this.closeImageMode(),this.hide())},this)),this.$element.on("mouseup touchend",a.proxy(function(a){var b=this.text();""===b||this.isTouch()?this.options.inlineMode||this.refreshButtons():(a.stopPropagation(),this.show(a)),this.imageMode=!1},this)),this.$element.on("mousedown touchstart","img, a",a.proxy(function(a){this.isResizing||a.stopPropagation()},this)),this.$element.on("mousedown touchstart",".f-img-handle",a.proxy(function(){this.$element.attr("data-resize",!0)},this)),this.$element.on("mouseup touchend",".f-img-handle",a.proxy(function(){this.$element.removeAttr("data-resize")},this)),this.$editor.on("mouseup touchend",a.proxy(function(a){a.stopPropagation(),this.options.inlineMode===!1&&this.hide()},this)),this.$popup_editor.on("mouseup touchend",a.proxy(function(a){a.stopPropagation()},this)),this.$link_wrapper&&this.$link_wrapper.on("mouseup touchend",a.proxy(function(a){a.stopPropagation()})),this.$image_wrapper&&this.$image_wrapper.on("mouseup touchend",a.proxy(function(a){a.stopPropagation()})),this.$video_wrapper&&this.$video_wrapper.on("mouseup touchend",a.proxy(function(a){a.stopPropagation()})),a(window).on("mouseup touchend",a.proxy(function(){this.selectionInEditor()&&""!==this.text()&&!this.isTouch()?this.show(null):(this.hide(),this.closeImageMode())},this)),a(document).on("selectionchange",a.proxy(function(a){if(this.options.inlineMode&&this.selectionInEditor()&&this.link!==!0&&this.isTouch()){var b=this.text();""!==b?(Modernizr.mq("(max-device-width: 320px) and (-webkit-min-device-pixel-ratio: 2)")||this.show(null),a.stopPropagation()):this.hide()}},this)),a(window).keydown(a.proxy(function(a){a.ctrlKey||(this.hide(),this.closeImageMode())},this))},b.prototype.setPlaceholder=function(a){a&&(this.options.placeholder=a),this.$textarea&&this.$textarea.attr("placeholder",this.options.placeholder),this.$element.attr("data-placeholder",this.options.placeholder)},b.prototype.isEmpty=function(){var a=this.$element.text().replace(/(\r\n|\n|\r|\t)/gm,"");return(""===a||1==a.length&&"8203"==a.charCodeAt(0))&&0===this.$element.find("img").length&&0==this.$element.find("p > br").length},b.prototype.setPlaceholderEvents=function(){this.$element.on("keyup keydown focus placeholderCheck",a.proxy(function(){if(this.isEmpty()&&!this.isHTML){if(this.options.paragraphy){var b=a("");this.$element.html(b),this.setSelection(b.get(0),0,null,0)}this.$element.addClass("f-placeholder")}else this.$element.find("p").length?this.isEmpty()===!1&&this.$element.removeClass("f-placeholder"):this.options.paragraphy&&(this.wrapText(),this.setSelection(this.$element.find("p")[0],1,null,1))},this)),this.$element.trigger("placeholderCheck")},b.prototype.setDimensions=function(a,b){a&&(this.options.height=a),b&&(this.options.width=b),"auto"!=this.options.height&&this.$element.css("height",this.options.height),"auto"!=this.options.width&&this.$box.css("width",this.options.width)},b.prototype.setDirection=function(a){a&&(this.options.direction=a),"ltr"!=this.options.direction&&"rtl"!=this.options.direction&&(this.options.direction="ltr"),"rtl"==this.options.direction?(this.$element.addClass("f-rtl"),this.$editor.addClass("f-rtl"),this.$popup_editor.addClass("f-rtl")):(this.$element.removeClass("f-rtl"),this.$editor.removeClass("f-rtl"),this.$popup_editor.removeClass("f-rtl"))},b.prototype.setBorderColor=function(a){a&&(this.options.borderColor=a);var c=b.hexToRGB(this.options.borderColor);null!==c&&(this.$editor.css("border-color",this.options.borderColor),this.$editor.attr("data-border-color",this.options.borderColor))},b.prototype.setSpellcheck=function(a){void 0!==a&&(this.options.spellcheck=a),this.$element.attr("spellcheck",this.options.spellcheck)},b.prototype.setInverseSkin=function(a){void 0!==a&&(this.options.inverseSkin=a),this.options.inverseSkin?(this.$editor.addClass("f-inverse"),this.$popup_editor.addClass("f-inverse")):(this.$editor.removeClass("f-inverse"),this.$popup_editor.removeClass("f-inverse"))},b.prototype.customizeText=function(b){b&&(this.$editor.find("[title]").add(this.$popup_editor.find("[title]")).each(a.proxy(function(c,d){for(var e in b)a(d).attr("title").toLowerCase()==e.toLowerCase()&&a(d).attr("title",b[e])},this)),this.$editor.find('[data-text="true"]').add(this.$popup_editor.find('[data-text="true"]')).each(a.proxy(function(c,d){for(var e in b)a(d).text().toLowerCase()==e.toLowerCase()&&a(d).text(b[e])},this)))},b.prototype.setLanguage=function(b){void 0!==b&&(this.options.language=b),a.Editable.LANGS[this.options.language]&&(this.customizeText(a.Editable.LANGS[this.options.language].translation),a.Editable.LANGS[this.options.language].direction&&this.setDirection(a.Editable.LANGS[this.options.language].direction),a.Editable.LANGS[this.options.language].translation[this.options.placeholder]&&this.setPlaceholder(a.Editable.LANGS[this.options.language].translation[this.options.placeholder]))},b.prototype.setCustomText=function(a){a&&(this.options.customText=a),this.options.customText&&this.customizeText(this.options.customText) +},b.prototype.execHTML=function(){this.html()},b.prototype.initHTMLArea=function(){this.$html_area=a('').keydown(function(b){var c=b.keyCode||b.which;if(9==c){b.preventDefault();var d=a(this).get(0).selectionStart,e=a(this).get(0).selectionEnd;a(this).val(a(this).val().substring(0,d)+" "+a(this).val().substring(e)),a(this).get(0).selectionStart=a(this).get(0).selectionEnd=d+1}})},b.prototype.setButtons=function(c){c&&(this.options.buttons=c),this.$bttn_wrapper=a("").addClass("bttn-wrapper"),this.$editor.append(this.$bttn_wrapper);for(var d in this.options.buttons){var e,f;"sep"==this.options.buttons[d]&&this.$bttn_wrapper.append(this.options.inlineMode?'':'');var g=b.commands[this.options.buttons[d]];if(void 0!==g)switch(g.cmd=this.options.buttons[d],g.cmd){case"color":e=this.buildDropdownColor(g),f=this.buildDropdownButton(g,"fr-color-picker").append(e),this.$bttn_wrapper.append(f);break;case"align":e=this.buildDropdownAlign(g),f=this.buildDropdownButton(g,"fr-selector").append(e),this.$bttn_wrapper.append(f);break;case"fontSize":e=this.buildDropdownFontsize(g),f=this.buildDropdownButton(g).append(e),this.$bttn_wrapper.append(f);break;case"formatBlock":e=this.buildDropdownFormatblock(g),f=this.buildDropdownButton(g).append(e),this.$bttn_wrapper.append(f);break;case"createLink":f=this.buildDefaultButton(g),this.$bttn_wrapper.append(f);break;case"insertImage":f=this.buildDefaultButton(g),this.$bttn_wrapper.append(f);break;case"insertVideo":f=this.buildDefaultButton(g),this.$bttn_wrapper.append(f),this.buildInsertVideo();break;case"undo":case"redo":f=this.buildDefaultButton(g),this.$bttn_wrapper.append(f),f.prop("disabled",!0);break;case"html":f=this.buildDefaultButton(g),this.$bttn_wrapper.append(f),this.options.inlineMode&&this.$box.append(f.clone(!0).addClass("html-switch").attr("title","Hide HTML").click(a.proxy(this.execHTML,this))),this.initHTMLArea();break;default:f=this.buildDefaultButton(g),this.$bttn_wrapper.append(f)}else{if(g=this.options.customButtons[this.options.buttons[d]],void 0===g)continue;f=this.buildCustomButton(g),this.$bttn_wrapper.append(f)}}this.buildCreateLink(),this.buildInsertImage(),this.bindButtonEvents()},b.prototype.buildDefaultButton=function(b){var c=a("").addClass("fr-bttn").attr("title",b.title).attr("data-cmd",b.cmd).attr("data-activeless",b.activeless);return this.addButtonIcon(c,b),c},b.prototype.addButtonIcon=function(b,c){b.append(c.icon?a("").addClass(c.icon):c.icon_alt?a("").addClass("for-text").html(c.icon_alt):c.icon_img?a('').attr("alt",c.title):c.icon_txt?a("").html(c.icon_txt):c.title)},b.prototype.buildCustomButton=function(b){var c=a("").addClass("fr-bttn").attr("title",b.title);return"fa"==b.icon.type?this.addButtonIcon(c,{icon:"fa "+b.icon.value}):"img"==b.icon.type?this.addButtonIcon(c,{icon_img:b.icon.value,title:b.title}):"txt"==b.icon.type&&this.addButtonIcon(c,{icon_txt:b.icon.value}),c.on("click touchend",a.proxy(function(a){a.stopPropagation(),a.preventDefault(),b.callback(this)},this)),c},b.prototype.buildDropdownButton=function(b,c){c=c||"";var d=a("").addClass("fr-bttn fr-dropdown").addClass(c),e=a("").addClass("fr-trigger").attr("title",b.title);return this.addButtonIcon(e,b),d.append(e),d},b.prototype.buildDropdownColor=function(b){var c=a("").addClass("fr-dropdown-menu");for(var d in b.seed){var e=b.seed[d],f=a("").append(a('').html(e.title));for(var g in e.value){var h=e.value[g];f.append(a("").addClass("fr-color-bttn").attr("data-cmd",e.cmd).attr("data-val",h).attr("data-activeless",b.activeless).css("background-color",h).html(" ")),g%8==7&&g>0&&(f.append(""),(7==g||15==g)&&f.append(a("").addClass("separator")))}c.append(f)}return c},b.prototype.buildDropdownAlign=function(b){var c=a("").addClass("fr-dropdown-menu");for(var d in b.seed){var e=b.seed[d],f=a("").append(a("").addClass("fr-bttn").attr("data-cmd",e.cmd).attr("title",e.title).attr("data-activeless",b.activeless).append(a("").addClass(e.icon)));c.append(f)}return c},b.prototype.buildDropdownFontsize=function(b){var c=a("").addClass("fr-dropdown-menu f-font-sizes");for(var d in b.seed)for(var e=b.seed[d],f=e.min;f<=e.max;f++){var g=a("").attr("data-cmd",b.cmd).attr("data-val",f+"px").attr("data-activeless",b.activeless).append(a('').append(a("").text(f+"px")));c.append(g)}return c},b.prototype.buildDropdownFormatblock=function(b){var c=a("").addClass("fr-dropdown-menu");for(var d in b.seed){var e=b.seed[d];if(-1!=a.inArray(e.value,this.options.blockTags)){var f=a("").append(a("").attr("data-cmd",b.cmd).attr("data-val",e.value).attr("data-activeless",b.activeless).append(a('').addClass("format_"+e.value).attr("title",e.title).text(e.title)));c.append(f)}}return c},b.prototype.buildInsertImage=function(){this.$image_wrapper=a("").addClass("image-wrapper"),this.$popup_editor.append(this.$image_wrapper);var b=this;this.$progress_bar=a('').append("");var c=a('').append('Drop Image(or click)').append(a('').append(a('')));this.browser.msie&&(this.$upload_frame=a(''),a("body").append(this.$upload_frame),this.$upload_frame.bind("load",function(){var c=a(this).contents().text();b.parseImageResponse(c)})),this.$image_wrapper.on("change",'input[type="file"]',function(){if(void 0!==this.files)b.uploadFile(this.files);else{var c=a(this).parents("form");c.find('input[type="hidden"]').remove();for(var d in b.options.imageParams)c.append('');c.append(''),c.submit()}}),this.buildDragUpload(c);var d=a('').on("mouseup touchend keydown",a.proxy(function(a){a.stopPropagation()},this));this.$image_list=a("").append(a('').append(c)).append(a('').append('Enter URL: ').append(d).append(a('OK').click(a.proxy(function(){this.writeImage(d.val())},this)))),this.$image_wrapper.append(a("").append('Insert image').append(a('').click(a.proxy(function(){this.$bttn_wrapper.show(),this.hideImageWrapper(!0),this.restoreSelection(),this.options.inlineMode||this.imageMode?this.imageMode&&this.showImageEditor():this.hide()},this)))).append(this.$image_list).append(this.$progress_bar).click(function(a){a.stopPropagation()}).find("*").click(function(a){a.stopPropagation()}).end().hide()},b.prototype.buildInsertVideo=function(){this.$video_wrapper=a("").addClass("video-wrapper"),this.$popup_editor.append(this.$video_wrapper);var b=a('').on("mouseup touchend keydown",a.proxy(function(a){a.stopPropagation()},this)),c=a("").append(a('OK').click(a.proxy(function(){this.restoreSelection(),a(this.getSelectionElements()[0]).after(this.options.paragraphy?''+b.val()+"":''+b.val()+""),this.saveUndoStep(),this.$bttn_wrapper.show(),this.hideVideoWrapper(),this.hide(),this.callback("insertVideo",[b.val()])},this)));this.$video_wrapper.append(a("").append('Insert video').append(a('').click(a.proxy(function(){this.$bttn_wrapper.show(),this.hideVideoWrapper(),this.restoreSelection(),this.options.inlineMode||this.hide()},this)))).append(b).append(c).click(function(a){a.stopPropagation()}).find("*").click(function(a){a.stopPropagation()}).end().hide()},b.prototype.buildCreateLink=function(){this.$link_wrapper=a("").addClass("link-wrapper"),this.$popup_editor.append(this.$link_wrapper);var b=a('').attr("placeholder","http://www.example.com").on("mouseup touchend keydown",function(a){a.stopPropagation()}),c=a('').click(function(a){a.stopPropagation()}),d=a('').text("OK").on("touchend",function(a){a.stopPropagation()}).click(a.proxy(function(){this.writeLink(b.val(),c.prop("checked"))},this)),e=a('').text("UNLINK").on("click touch",a.proxy(function(){this.link=!0,this.writeLink("",c.prop("checked"))},this));this.$link_wrapper.append(a("").append('Insert link').append(a('').click(a.proxy(function(){this.$bttn_wrapper.show(),this.hideLinkWrapper(),this.options.inlineMode||this.imageMode?this.imageMode&&this.showImageEditor():this.hide(),this.restoreSelection()},this)))).append(b).append(a("").append(c).append(' Open in new tab').append(d).append(e)).end().hide()},b.prototype.buildDragUpload=function(b){var c=this;b.on({dragover:function(){return a(this).addClass("f-hover"),!1},dragend:function(){return a(this).removeClass("f-hover"),!1},drop:function(b){a(this).removeClass("f-hover"),b.preventDefault(),c.uploadFile(b.originalEvent.dataTransfer.files)}})},b.prototype.hideImageLoader=function(){this.$progress_bar.hide(),this.$progress_bar.find("span").css("width","0%").text(""),this.$image_list.show()},b.prototype.writeImage=function(b){var c=new Image;if(c.onerror=a.proxy(function(){this.hideImageLoader(),this.throwImageError(1)},this),this.imageMode)return c.onload=a.proxy(function(){this.$element.find(".f-img-editor > img").attr("src",b),this.hide(),this.hideImageLoader(),this.$image_editor.show(),this.saveUndoStep(),this.callback("replaceImage",[b])},this),c.src=b,!1;var d=this.getSelectionElements()[0];c.onload=a.proxy(function(){a(d).prepend(''),a(d).find("img:first").get(0).oncontrolselect=function(){return!1},this.hide(),this.hideImageLoader(),this.saveUndoStep(),this.callback("insertImage",[b])},this),c.src=b},b.prototype.throwImageError=function(b){var c="Unknown image upload error.";1==b?c="Bad link.":2==b?c="No link in upload response.":3==b?c="Error during file upload.":4==b&&(c="Parsing response failed."),this.options.imageErrorCallback&&a.isFunction(this.options.imageErrorCallback)&&this.options.imageErrorCallback({errorCode:b,errorStatus:c})},b.prototype.uploadFile=function(b){if(void 0!==b&&b.length>0){var c;if(this.drag_support.formdata&&(c=this.drag_support.formdata?new FormData:null),c&&c.append(this.options.imageUploadParam,b[0]),c){var d;this.options.crossDomain?d=this.createCORSRequest("POST",this.options.imageUploadURL):(d=new XMLHttpRequest,d.open("POST",this.options.imageUploadURL)),d.onload=a.proxy(function(){this.$progress_bar.find("span").css("width","100%").text("Please wait!");try{200==d.status?this.parseImageResponse(d.responseText):this.throwImageError(3)}catch(a){this.throwImageError(4)}this.hideImageLoader()},this),d.onerror=a.proxy(function(){this.throwImageError(3),this.hideImageLoader()},this),d.upload.onprogress=a.proxy(function(a){if(a.lengthComputable){var b=a.loaded/a.total*100|0;this.$progress_bar.find("span").css("width",b+"%")}},this);for(var e in this.options.imageParams)c.append(e,this.options.imageParams[e]);d.send(c),this.$image_list.hide(),this.$progress_bar.show()}}},b.prototype.parseImageResponse=function(b){try{var c=a.parseJSON(b);"http://uploads.im/api"==this.options.imageUploadURL?this.writeImage(c.data.img_url):c.link?this.writeImage(c.link):this.throwImageError(2)}catch(d){this.throwImageError(4)}},b.prototype.createCORSRequest=function(a,b){var c=new XMLHttpRequest;return"withCredentials"in c?c.open(a,b,!0):"undefined"!=typeof XDomainRequest?(c=new XDomainRequest,c.open(a,b)):c=null,c},b.prototype.writeLink=function(b,c){if(this.imageMode)return""!==b?("A"!=this.$element.find(".f-img-editor").parent().get(0).tagName?this.$element.find(".f-img-editor").wrap(c===!0?'':''):c===!0?this.$element.find(".f-img-editor").parent().attr("target","_blank"):(this.$element.find(".f-img-editor").parent().removeAttr("target"),this.$element.find(".f-img-editor").parent().attr("href",b)),this.callback("insertImageLink",[b])):("A"==this.$element.find(".f-img-editor").parent().get(0).tagName&&a(this.$element.find(".f-img-editor").get(0)).unwrap(),this.callback("removeImageLink")),this.saveUndoStep(),this.showImageEditor(),this.$element.find(".f-img-editor").find("img").click(),this.link=!1,!1;if(this.restoreSelection(),document.execCommand("unlink",!1,b),this.saveSelectionByMarkers(),this.$element.find("span.f-link").each(function(b,c){a(c).replaceWith(a(c).html())}),this.restoreSelectionByMarkers(),""!==b){document.execCommand("createLink",!1,b);for(var d=this.getSelectionLinks(),e=0;e-1&&e.push(c[h])}d.detach()}}else if(document.selection&&"Control"!=document.selection.type)if(a=document.selection.createRange(),b=a.parentElement(),"a"==b.nodeName.toLowerCase())e.push(b);else{c=b.getElementsByTagName("a"),d=document.body.createTextRange();for(var i=0;i-1&&d.compareEndPoints("EndToStart",a)<1&&e.push(c[i])}return e},b.prototype.isEnabled=function(b){return a.inArray(b,this.options.buttons)>=0},b.prototype.show=function(b){if(void 0!==b){if(this.options.inlineMode)if(null!==b&&"touchend"!==b.type){var c=b.pageX,d=b.pageY;20>c&&(c=20),0>d&&(d=0),c+this.$editor.width()>a(window).width()-50?(this.$editor.addClass("right-side"),c=a(window).width()-(c+30),this.$editor.css("top",d+20),this.$editor.css("right",c),this.$editor.css("left","auto")):(this.$editor.removeClass("right-side"),this.$editor.css("top",d+20),this.$editor.css("left",c-20),this.$editor.css("right","auto")),a(".froala-editor:not(.f-basic)").hide(),this.$editor.show()}else a(".froala-editor:not(.f-basic)").hide(),this.$editor.show(),this.repositionEditor();this.hideLinkWrapper(),this.hideVideoWrapper(),this.hideImageWrapper(),this.$bttn_wrapper.show(),this.$bttn_wrapper.find(".fr-dropdown").removeClass("active"),this.refreshButtons(),this.imageMode=!1}},b.prototype.showByCoordinates=function(b,c){b-=20,c+=15,b+this.$popup_editor.width()>a(window).width()-50?(this.$popup_editor.addClass("right-side"),b=a(window).width()-(b+40),this.$popup_editor.css("top",c),this.$popup_editor.css("right",b),this.$popup_editor.css("left","auto")):(this.$popup_editor.removeClass("right-side"),this.$popup_editor.css("top",c),this.$popup_editor.css("left",b),this.$popup_editor.css("right","auto")),this.$popup_editor.show()},b.prototype.showLinkWrapper=function(){this.$link_wrapper&&this.$link_wrapper.show()},b.prototype.hideLinkWrapper=function(){this.$link_wrapper&&this.$link_wrapper.hide()},b.prototype.showImageWrapper=function(){this.$image_wrapper&&this.$image_wrapper.show()},b.prototype.showVideoWrapper=function(){this.$video_wrapper&&this.$video_wrapper.show()},b.prototype.hideImageWrapper=function(a){this.$image_wrapper&&(this.$element.attr("data-resize")||a||this.closeImageMode(),this.$image_wrapper.hide())},b.prototype.hideVideoWrapper=function(){this.$video_wrapper&&this.$video_wrapper.hide()},b.prototype.showInsertLink=function(){this.options.inlineMode&&this.$bttn_wrapper.hide(),this.showLinkWrapper(),this.hideImageWrapper(!0),this.hideVideoWrapper(),this.$image_editor.hide(),this.link=!0},b.prototype.showInsertImage=function(){this.options.inlineMode&&this.$bttn_wrapper.hide(),this.hideLinkWrapper(),this.hideVideoWrapper(),this.showImageWrapper(),this.$image_editor.hide()},b.prototype.showInsertVideo=function(){this.options.inlineMode&&this.$bttn_wrapper.hide(),this.hideLinkWrapper(),this.hideImageWrapper(),this.showVideoWrapper(),this.$image_editor.hide()},b.prototype.showImageEditor=function(){this.options.inlineMode&&this.$bttn_wrapper.hide(),this.hideLinkWrapper(),this.hideImageWrapper(!0),this.hideVideoWrapper(),this.$image_editor.show(),this.options.imageMove||this.$element.attr("contenteditable",!1)},b.prototype.hide=function(){this.$popup_editor.hide(),this.hideLinkWrapper(),this.hideImageWrapper(),this.hideVideoWrapper(),this.$image_editor.hide(),this.link=!1},b.prototype.positionPopup=function(b){a(this.$editor.find('button.fr-bttn[data-cmd="'+b+'"]')).length&&(this.$popup_editor.css("top",this.$editor.find('button.fr-bttn[data-cmd="'+b+'"]').offset().top+30),this.$popup_editor.css("left",this.$editor.find('button.fr-bttn[data-cmd="'+b+'"]').offset().left),this.$popup_editor.show())},b.prototype.bindButtonEvents=function(){this.bindDropdownEvents(),this.bindCommandEvents()},b.prototype.bindDropdownEvents=function(){var b=this;this.$bttn_wrapper.find(".fr-dropdown").on("click touchend",function(c){return c.stopPropagation(),c.preventDefault(),0==b.options.inlineMode&&b.hide(),a(this).attr("data-disabled")?!1:(a(".fr-dropdown").not(this).removeClass("active"),void a(this).toggleClass("active"))}),a(window).on("click touchend",a.proxy(function(){this.$editor.find(".fr-dropdown").removeClass("active")},this)),this.$element.on("click touchend","img, a",a.proxy(function(){this.$editor.find(".fr-dropdown").removeClass("active")},this));var c=this.$bttn_wrapper.find(".fr-selector button.fr-bttn");c.bind("select",function(){a(this).parents(".fr-selector").find(" > button > i").attr("class",a(this).find("i").attr("class"))}).on("click touch",function(){a(this).parents("ul").find("button").removeClass("active"),a(this).parents(".fr-selector").removeClass("active").trigger("mouseout"),a(this).trigger("select")})},b.prototype.bindCommandEvents=function(){this.$bttn_wrapper.find("[data-cmd]").on("click touchend",a.proxy(function(b){b.stopPropagation(),b.preventDefault();var c=b.currentTarget,d=a(c).data("cmd"),e=a(c).data("val");a(c).parents(".fr-dropdown").removeClass("active"),this.exec(d,e),this.$bttn_wrapper.find(".fr-dropdown").removeClass("active")},this))},b.prototype.exec=function(a,b){if(!this.selectionInEditor()&&"html"!==a&&"undo"!==a&&"redo"!==a&&"selectAll"!==a&&"save"!=a&&"insertImage"!==a&&"insertVideo"!==a)return!1;if(this.selectionInEditor()&&""===this.text()&&"fontSize"!==a&&"formatBlock"!==a&&"indent"!==a&&"outdent"!==a&&"justifyLeft"!==a&&"justifyRight"!==a&&"justifyFull"!==a&&"justifyCenter"!==a&&"html"!==a&&"undo"!==a&&"redo"!==a&&"selectAll"!==a&&"save"!==a&&"insertImage"!==a&&"insertVideo"!==a&&"insertOrderedList"!==a&&"insertUnorderedList"!==a)return!1;switch(a){case"fontSize":this.fontSize(b);break;case"backColor":this.backColor(b);break;case"foreColor":this.foreColor(b);break;case"formatBlock":this.formatBlock(b);break;case"createLink":this.insertLink();break;case"insertImage":this.insertImage();break;case"indent":this.indent();break;case"outdent":this.outdent(!0);break;case"justifyLeft":case"justifyRight":case"justifyCenter":case"justifyFull":this.align(a);break;case"insertOrderedList":case"insertUnorderedList":this.formatList(a);break;case"insertVideo":this.insertVideo();break;case"indent":case"outdent":this.execDefault(a,b),this.repositionEditor();break;case"undo":this.undo();break;case"redo":this.redo();break;case"html":this.html();break;case"save":this.save();break;case"selectAll":this.$element.focus(),this.execDefault(a,b);break;default:this.execDefault(a,b)}"undo"!=a&&"redo"!=a&&"selectAll"!=a&&"createLink"!=a&&"insertImage"!=a&&"html"!=a&&"insertVideo"!=a&&this.saveUndoStep(),"createLink"!=a&&"insertImage"!=a&&this.refreshButtons()},b.prototype.undo=function(){if(this.undoIndex>1){var a=this.getHTML();this.$element.html(this.undoStack[--this.undoIndex-1]),this.hide(),this.callback("undo",[this.$element.html(),a])}this.refreshUndoRedo()},b.prototype.redo=function(){if(this.undoIndex").attr("data-font",!0).css("font-size",b).html(a(e).html());0===a(e).parents("font").length&&c.push(f),a(e).replaceWith(f)});var d=function(b,c){a(c).css("font-size","")};for(var e in c){var f=c[e];a(f).find("*").each(d)}this.$element.find('span[data-font="true"] > span[data-font="true"]').each(function(b,c){a(c).attr("style")&&(a(c).before(''),a(c).after(''))});var g=this.$element.html();g=g.replace(new RegExp('',"g"),""),g=g.replace(new RegExp('data-open="true">',"g"),">"),this.$element.html(g);for(var h=!0,i=a.proxy(function(){this.$element.find('span[data-font="true"] + span[data-font="true"]').each(function(b,c){a(c).css("font-size")==a(c).prev().css("font-size")&&(a(c).prepend(a(c).prev().html()),a(c).prev().remove(),h=!0)}),this.$element.find('span[data-font="true"] + span#marker-true + span[data-font="true"], span[data-font="true"] + span#marker-true + span[data-font="true"]').each(function(b,c){a(c).css("font-size")==a(c).prev().prev().css("font-size")&&(a(c).prepend(a(c).prev().clone()),a(c).prepend(a(c).prev().prev().html()),a(c).prev().prev().remove(),a(c).prev().remove(),h=!0)})},this);h;)h=!1,i();this.$element.find('span[style=""]').each(function(b,c){a(c).replaceWith(a(c).html())}),this.$element.find("span[data-font]").each(function(b,c){a(c).css("font-size")==a(c).parent().css("font-size")&&a(c).replaceWith(a(c).html())}),this.restoreSelectionByMarkers(),this.repositionEditor(),this.callback("fontSize")},b.prototype.backColor=function(c){var d="backColor";this.browser.msie||(d="hiliteColor");var e=a(this.getSelectionElement()).css("background-color");document.execCommand(d,!1,c);var f=this.$editor.find('button.fr-color-bttn[data-cmd="backColor"][data-val="'+c+'"]');f.addClass("active"),f.siblings().removeClass("active"),this.callback("backColor",[b.hexToRGBString(c),e])},b.prototype.foreColor=function(c){var d=a(this.getSelectionElement()).css("color");document.execCommand("foreColor",!1,c),this.saveSelectionByMarkers(),this.$element.find("font[color]").each(function(b,d){a(d).replaceWith(a("").css("color",c).html(a(d).html()))}),this.restoreSelectionByMarkers();var e=this.$editor.find('button.fr-color-bttn[data-cmd="foreColor"][data-val="'+c+'"]');e.addClass("active"),e.siblings().removeClass("active"),this.callback("foreColor",[b.hexToRGBString(c),d])},b.prototype.formatBlock=function(b){if(this.disabledList.indexOf("formatBlock")>=0)return!1;this.saveSelectionByMarkers(),this.wrapText(),this.restoreSelectionByMarkers();var c,d=this.getSelectionElements();for(var e in d){var f=a(d[e]);if(c="n"==b?a("").html(f.html()):a("<"+b+">").html(f.html()),f.get(0)!=this.$element.get(0)&&"LI"!=f.get(0).tagName){var g=f.prop("attributes");if(c.attr)for(var h in g)c.attr(g[h].name,g[h].value);f.replaceWith(c)}else f.html(c)}this.clearSelection(),this.hide(),this.callback("formatBlock")},b.prototype.formatList=function(b){this.saveSelectionByMarkers();var c,d=this.getSelectionElements(),e=!0,f=!1;for(var g in d)c=a(d[g]),c.parents("li").length>0?(c.parents("ol").length>0?(c.parents("li").before(''),c.parents("li").after('')):c.parents("ul").length>0&&(c.parents("li").before(''),c.parents("li").after('')),c.parents("li").replaceWith(c.parents("li").contents()),f=!0):e=!1;if(f){var h=this.$element.html();h=h.replace(new RegExp('',"g"),""),h=h.replace(new RegExp('',"g"),""),h=h.replace(new RegExp('',"g"),""),h=h.replace(new RegExp('',"g"),""),this.$element.html(h),this.$element.find("ul:empty, ol:empty").remove()}if(this.clearSelection(),this.wrapText(),this.restoreSelectionByMarkers(),e===!1){d=this.getSelectionElements(),this.saveSelectionByMarkers();var i=a("");"insertUnorderedList"==b&&(i=a(""));for(var j in d)c=a(d[j]),c.get(0)!=this.$element.get(0)&&(i.append(a("").append(c.clone())),j!=d.length-1?c.remove():c.replaceWith(i));this.restoreSelectionByMarkers()}this.repositionEditor(),this.callback(b)},b.prototype.align=function(b){var c=this.getSelectionElements();this.saveSelection(),"justifyLeft"==b?b="left":"justifyRight"==b?b="right":"justifyCenter"==b?b="center":"justifyFull"==b&&(b="justify");for(var d in c)a(c[d]).css("text-align",b);this.restoreSelection(),this.repositionEditor(),this.callback("align")},b.prototype.indent=function(b){var c=20;b&&(c=-20),this.saveSelectionByMarkers(),this.wrapText(),this.restoreSelectionByMarkers();var d=this.getSelectionElements();this.saveSelectionByMarkers();for(var e in d){var f=a(d[e]);if(f.get(0)!=this.$element.get(0)){var g=parseInt(f.css("margin-left").replace(/px/,""),10),h=Math.max(0,g+c);f.css("marginLeft",h)}else{var i=a("").html(f.html());f.html(i),i.css("marginLeft",Math.max(0,c))}}this.restoreSelectionByMarkers(),this.repositionEditor(),b||this.callback("indent")},b.prototype.outdent=function(){this.indent(!0),this.callback("outdent")},b.prototype.insertLink=function(){this.showInsertLink(),this.options.inlineMode||this.positionPopup("createLink"),this.saveSelection();var b=this.getSelectionLink(),c=this.getSelectionLinks();c.length>0&&this.$link_wrapper.find('input[type="checkbox"]').prop("checked","_blank"==a(c[0]).attr("target")),this.$link_wrapper.find('input[type="text"]').val(b||"http://")},b.prototype.insertImage=function(){this.showInsertImage(),this.saveSelection(),this.options.inlineMode||this.positionPopup("insertImage"),this.$image_wrapper.find('input[type="text"]').val("")},b.prototype.insertVideo=function(){this.showInsertVideo(),this.saveSelection(),this.options.inlineMode||this.positionPopup("insertVideo"),this.$video_wrapper.find("textarea").val("")},b.prototype.execDefault=function(a,b){document.execCommand(a,!1,b),"insertOrderedList"==a?this.$bttn_wrapper.find('[data-cmd="insertUnorderedList"]').removeClass("active"):"insertUnorderedList"==a&&this.$bttn_wrapper.find('[data-cmd="insertOrderedList"]').removeClass("active"),this.callback(a)},b.prototype.refreshButtons=function(){return!this.selectionInEditor()||this.isHTML?!1:(this.refreshUndoRedo(),void this.$bttn_wrapper.find("[data-cmd]").each(a.proxy(function(b,c){switch(a(c).data("cmd")){case"fontSize":this.refreshFontSize(c);break;case"backColor":this.refreshBackColor(c);break;case"foreColor":this.refreshForeColor(c);break;case"formatBlock":this.refreshFormatBlock(c);break;case"createLink":case"insertImage":break;case"justifyLeft":case"justifyRight":case"justifyCenter":case"justifyFull":this.refreshAlign(c);break;case"html":this.isHTML?a(c).addClass("active"):a(c).removeClass("active");break;case"undo":case"redo":case"save":break;default:this.refreshDefault(c)}},this)))},b.prototype.refreshFormatBlock=function(b){this.disabledList.indexOf("formatBlock")>=0&&a(b).parents(".fr-dropdown").attr("data-disabled",!0)},b.prototype.refreshUndoRedo=function(){if(this.isEnabled("undo")||this.isEnabled("redo")){if(void 0===this.$editor)return;this.$bttn_wrapper.find('[data-cmd="undo"], [data-cmd="redo"]').prop("disabled",!1),(0===this.undoStack.length||this.undoIndex<=1||this.isHTML)&&this.$bttn_wrapper.find('[data-cmd="undo"]').prop("disabled",!0),(this.undoIndex==this.undoStack.length||this.isHTML)&&this.$bttn_wrapper.find('[data-cmd="redo"]').prop("disabled",!0)}},b.prototype.refreshDefault=function(b){a(b).removeClass("active");try{document.queryCommandState(a(b).data("cmd"))===!0&&a(b).addClass("active")}catch(c){}},b.prototype.refreshAlign=function(b){var c=a(b).data("cmd"),d=this.getSelectionElements();"justifyLeft"==c?c="left":"justifyRight"==c?c="right":"justifyCenter"==c?c="center":"justifyFull"==c&&(c="justify"),c==a(d[0]).css("text-align")&&(a(b).parents("ul").find(".fr-bttn").removeClass("active"),a(b).addClass("active"),a(b).parents(".fr-dropdown").find(".fr-trigger").html(a(b).html()))},b.prototype.refreshForeColor=function(b){a(b).removeClass("active"),document.queryCommandValue("foreColor")==b.style.backgroundColor&&a(b).addClass("active")},b.prototype.refreshBackColor=function(b){a(b).removeClass("active"),document.queryCommandValue("backColor")==b.style.backgroundColor&&a(b).addClass("active")},b.prototype.refreshFontSize=function(b){a(b).removeClass("active"),parseInt(document.queryCommandValue("fontSize"),10)==parseInt(a(b).data("val"),10)&&a(b).addClass("active") },b.prototype.option=function(b,c){if(void 0===b)return this.options;if(b instanceof Object)this.options=a.extend({},this.options,b),this.initOptions(),this.setCustomText(),this.setLanguage();else{if(void 0===c)return this.options[b];switch(this.options[b]=c,b){case"borderColor":this.setBorderColor();break;case"direction":this.setDirection();break;case"height":case"width":this.setDimensions();break;case"spellcheck":this.setSpellcheck();break;case"placeholder":this.setPlaceholder();break;case"customText":this.setCustomText();break;case"inverseSkin":this.setInverseSkin();break;case"language":this.setLanguage()}}};var c=a.fn.editable;a.fn.editable=function(c){for(var d=[],e=0;ee*e+f*f||v(a,b,c,e,f,d)}function t(){return this._handled=d,!1}function u(a){try{a._handled()}catch(b){return!1}}function v(a,b,c,d,e,f){{var g,h;b.target}g=a.targetTouches,h=a.timeStamp-b.timeStamp,b.type="movestart",b.distX=d,b.distY=e,b.deltaX=d,b.deltaY=e,b.pageX=c.pageX,b.pageY=c.pageY,b.velocityX=d/h,b.velocityY=e/h,b.targetTouches=g,b.finger=g?g.length:1,b._handled=t,b._preventTouchmoveDefault=function(){a.preventDefault()},L(b.target,b),f(b.identifier)}function w(a){var b=a.data.timer;a.data.touch=a,a.data.timeStamp=a.timeStamp,b.kick()}function x(a){var b=a.data.event,c=a.data.timer;y(),D(b,c,function(){setTimeout(function(){K(b.target,"click",e)},0)})}function y(){K(document,O.move,w),K(document,O.end,x)}function z(a){var b=a.data.event,c=a.data.timer,d=j(a,b);d&&(a.preventDefault(),b.targetTouches=a.targetTouches,a.data.touch=d,a.data.timeStamp=a.timeStamp,c.kick())}function A(a){var b=a.data.event,c=a.data.timer,d=i(a.changedTouches,b.identifier);d&&(B(b),D(b,c))}function B(a){K(document,"."+a.identifier,z),K(document,"."+a.identifier,A)}function C(a,b,c){var d=c-a.timeStamp;a.type="move",a.distX=b.pageX-a.startX,a.distY=b.pageY-a.startY,a.deltaX=b.pageX-a.pageX,a.deltaY=b.pageY-a.pageY,a.velocityX=.3*a.velocityX+.7*a.deltaX/d,a.velocityY=.3*a.velocityY+.7*a.deltaY/d,a.pageX=b.pageX,a.pageY=b.pageY}function D(a,b,c){b.end(function(){return a.type="moveend",L(a.target,a),c&&c()})}function E(){return J(this,"movestart.move",u),!0}function F(){return K(this,"dragstart drag",f),K(this,"mousedown touchstart",g),K(this,"movestart",u),!0}function G(a){"move"!==a.namespace&&"moveend"!==a.namespace&&(J(this,"dragstart."+a.guid+" drag."+a.guid,f,b,a.selector),J(this,"mousedown."+a.guid,g,b,a.selector))}function H(a){"move"!==a.namespace&&"moveend"!==a.namespace&&(K(this,"dragstart."+a.guid+" drag."+a.guid),K(this,"mousedown."+a.guid))}var I=6,J=a.event.add,K=a.event.remove,L=function(b,c,d){a.event.trigger(c,d,b)},M=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){return window.setTimeout(function(){a()},25)}}(),N={textarea:!0,input:!0,select:!0,button:!0},O={move:"mousemove",cancel:"mouseup dragstart",end:"mouseup"},P={move:"touchmove",cancel:"touchend",end:"touchend"};a.event.special.movestart={setup:E,teardown:F,add:G,remove:H,_default:function(a){function d(){C(f,g.touch,g.timeStamp),L(a.target,f)}var f,g;a._handled()&&(f={target:a.target,startX:a.startX,startY:a.startY,pageX:a.pageX,pageY:a.pageY,distX:a.distX,distY:a.distY,deltaX:a.deltaX,deltaY:a.deltaY,velocityX:a.velocityX,velocityY:a.velocityY,timeStamp:a.timeStamp,identifier:a.identifier,targetTouches:a.targetTouches,finger:a.finger},g={event:f,timer:new c(d),touch:b,timeStamp:b},a.identifier===b?(J(a.target,"click",e),J(document,O.move,w,g),J(document,O.end,x,g)):(a._preventTouchmoveDefault(),J(document,P.move+"."+a.identifier,z,g),J(document,P.end+"."+a.identifier,A,g)))}},a.event.special.move={setup:function(){J(this,"movestart.move",a.noop)},teardown:function(){K(this,"movestart.move",a.noop)}},a.event.special.moveend={setup:function(){J(this,"movestart.moveend",a.noop)},teardown:function(){K(this,"movestart.moveend",a.noop)}},J(document,"mousedown.move",k),J(document,"touchstart.move",o),"function"==typeof Array.prototype.indexOf&&!function(a){for(var b=["changedTouches","targetTouches"],c=b.length;c--;)-1===a.event.props.indexOf(b[c])&&a.event.props.push(b[c])}(a)}),+function(a){function b(a,b,c,d){if(a.tag.format&&c.length>0){c.push("\n");for(var e=0;d>e;e++)c.push(" ")}}function c(d,e){var f=[],g=0==d.attributes.length,h=0;if(d.tag.isComment)e.allowComments&&(f.push("
":"
').html(e.title));for(var g in e.value){var h=e.value[g];f.append(a("").addClass("fr-color-bttn").attr("data-cmd",e.cmd).attr("data-val",h).attr("data-activeless",b.activeless).css("background-color",h).html(" ")),g%8==7&&g>0&&(f.append(""),(7==g||15==g)&&f.append(a("").addClass("separator")))}c.append(f)}return c},b.prototype.buildDropdownAlign=function(b){var c=a("").addClass("fr-dropdown-menu");for(var d in b.seed){var e=b.seed[d],f=a("").append(a("").addClass("fr-bttn").attr("data-cmd",e.cmd).attr("title",e.title).attr("data-activeless",b.activeless).append(a("").addClass(e.icon)));c.append(f)}return c},b.prototype.buildDropdownFontsize=function(b){var c=a("").addClass("fr-dropdown-menu f-font-sizes");for(var d in b.seed)for(var e=b.seed[d],f=e.min;f<=e.max;f++){var g=a("").attr("data-cmd",b.cmd).attr("data-val",f+"px").attr("data-activeless",b.activeless).append(a('').append(a("").text(f+"px")));c.append(g)}return c},b.prototype.buildDropdownFormatblock=function(b){var c=a("").addClass("fr-dropdown-menu");for(var d in b.seed){var e=b.seed[d];if(-1!=a.inArray(e.value,this.options.blockTags)){var f=a("").append(a("").attr("data-cmd",b.cmd).attr("data-val",e.value).attr("data-activeless",b.activeless).append(a('').addClass("format_"+e.value).attr("title",e.title).text(e.title)));c.append(f)}}return c},b.prototype.buildInsertImage=function(){this.$image_wrapper=a("").addClass("image-wrapper"),this.$popup_editor.append(this.$image_wrapper);var b=this;this.$progress_bar=a('').append("");var c=a('').append('Drop Image(or click)').append(a('').append(a('')));this.browser.msie&&(this.$upload_frame=a(''),a("body").append(this.$upload_frame),this.$upload_frame.bind("load",function(){var c=a(this).contents().text();b.parseImageResponse(c)})),this.$image_wrapper.on("change",'input[type="file"]',function(){if(void 0!==this.files)b.uploadFile(this.files);else{var c=a(this).parents("form");c.find('input[type="hidden"]').remove();for(var d in b.options.imageParams)c.append('');c.append(''),c.submit()}}),this.buildDragUpload(c);var d=a('').on("mouseup touchend keydown",a.proxy(function(a){a.stopPropagation()},this));this.$image_list=a("").append(a('').append(c)).append(a('').append('Enter URL: ').append(d).append(a('OK').click(a.proxy(function(){this.writeImage(d.val())},this)))),this.$image_wrapper.append(a("").append('Insert image').append(a('').click(a.proxy(function(){this.$bttn_wrapper.show(),this.hideImageWrapper(!0),this.restoreSelection(),this.options.inlineMode||this.imageMode?this.imageMode&&this.showImageEditor():this.hide()},this)))).append(this.$image_list).append(this.$progress_bar).click(function(a){a.stopPropagation()}).find("*").click(function(a){a.stopPropagation()}).end().hide()},b.prototype.buildInsertVideo=function(){this.$video_wrapper=a("").addClass("video-wrapper"),this.$popup_editor.append(this.$video_wrapper);var b=a('').on("mouseup touchend keydown",a.proxy(function(a){a.stopPropagation()},this)),c=a("").append(a('OK').click(a.proxy(function(){this.restoreSelection(),a(this.getSelectionElements()[0]).after(this.options.paragraphy?''+b.val()+"":''+b.val()+""),this.saveUndoStep(),this.$bttn_wrapper.show(),this.hideVideoWrapper(),this.hide(),this.callback("insertVideo",[b.val()])},this)));this.$video_wrapper.append(a("").append('Insert video').append(a('').click(a.proxy(function(){this.$bttn_wrapper.show(),this.hideVideoWrapper(),this.restoreSelection(),this.options.inlineMode||this.hide()},this)))).append(b).append(c).click(function(a){a.stopPropagation()}).find("*").click(function(a){a.stopPropagation()}).end().hide()},b.prototype.buildCreateLink=function(){this.$link_wrapper=a("").addClass("link-wrapper"),this.$popup_editor.append(this.$link_wrapper);var b=a('').attr("placeholder","http://www.example.com").on("mouseup touchend keydown",function(a){a.stopPropagation()}),c=a('').click(function(a){a.stopPropagation()}),d=a('').text("OK").on("touchend",function(a){a.stopPropagation()}).click(a.proxy(function(){this.writeLink(b.val(),c.prop("checked"))},this)),e=a('').text("UNLINK").on("click touch",a.proxy(function(){this.link=!0,this.writeLink("",c.prop("checked"))},this));this.$link_wrapper.append(a("").append('Insert link').append(a('').click(a.proxy(function(){this.$bttn_wrapper.show(),this.hideLinkWrapper(),this.options.inlineMode||this.imageMode?this.imageMode&&this.showImageEditor():this.hide(),this.restoreSelection()},this)))).append(b).append(a("").append(c).append(' Open in new tab').append(d).append(e)).end().hide()},b.prototype.buildDragUpload=function(b){var c=this;b.on({dragover:function(){return a(this).addClass("f-hover"),!1},dragend:function(){return a(this).removeClass("f-hover"),!1},drop:function(b){a(this).removeClass("f-hover"),b.preventDefault(),c.uploadFile(b.originalEvent.dataTransfer.files)}})},b.prototype.hideImageLoader=function(){this.$progress_bar.hide(),this.$progress_bar.find("span").css("width","0%").text(""),this.$image_list.show()},b.prototype.writeImage=function(b){var c=new Image;if(c.onerror=a.proxy(function(){this.hideImageLoader(),this.throwImageError(1)},this),this.imageMode)return c.onload=a.proxy(function(){this.$element.find(".f-img-editor > img").attr("src",b),this.hide(),this.hideImageLoader(),this.$image_editor.show(),this.saveUndoStep(),this.callback("replaceImage",[b])},this),c.src=b,!1;var d=this.getSelectionElements()[0];c.onload=a.proxy(function(){a(d).prepend(''),a(d).find("img:first").get(0).oncontrolselect=function(){return!1},this.hide(),this.hideImageLoader(),this.saveUndoStep(),this.callback("insertImage",[b])},this),c.src=b},b.prototype.throwImageError=function(b){var c="Unknown image upload error.";1==b?c="Bad link.":2==b?c="No link in upload response.":3==b?c="Error during file upload.":4==b&&(c="Parsing response failed."),this.options.imageErrorCallback&&a.isFunction(this.options.imageErrorCallback)&&this.options.imageErrorCallback({errorCode:b,errorStatus:c})},b.prototype.uploadFile=function(b){if(void 0!==b&&b.length>0){var c;if(this.drag_support.formdata&&(c=this.drag_support.formdata?new FormData:null),c&&c.append(this.options.imageUploadParam,b[0]),c){var d;this.options.crossDomain?d=this.createCORSRequest("POST",this.options.imageUploadURL):(d=new XMLHttpRequest,d.open("POST",this.options.imageUploadURL)),d.onload=a.proxy(function(){this.$progress_bar.find("span").css("width","100%").text("Please wait!");try{200==d.status?this.parseImageResponse(d.responseText):this.throwImageError(3)}catch(a){this.throwImageError(4)}this.hideImageLoader()},this),d.onerror=a.proxy(function(){this.throwImageError(3),this.hideImageLoader()},this),d.upload.onprogress=a.proxy(function(a){if(a.lengthComputable){var b=a.loaded/a.total*100|0;this.$progress_bar.find("span").css("width",b+"%")}},this);for(var e in this.options.imageParams)c.append(e,this.options.imageParams[e]);d.send(c),this.$image_list.hide(),this.$progress_bar.show()}}},b.prototype.parseImageResponse=function(b){try{var c=a.parseJSON(b);"http://uploads.im/api"==this.options.imageUploadURL?this.writeImage(c.data.img_url):c.link?this.writeImage(c.link):this.throwImageError(2)}catch(d){this.throwImageError(4)}},b.prototype.createCORSRequest=function(a,b){var c=new XMLHttpRequest;return"withCredentials"in c?c.open(a,b,!0):"undefined"!=typeof XDomainRequest?(c=new XDomainRequest,c.open(a,b)):c=null,c},b.prototype.writeLink=function(b,c){if(this.imageMode)return""!==b?("A"!=this.$element.find(".f-img-editor").parent().get(0).tagName?this.$element.find(".f-img-editor").wrap(c===!0?'':''):c===!0?this.$element.find(".f-img-editor").parent().attr("target","_blank"):(this.$element.find(".f-img-editor").parent().removeAttr("target"),this.$element.find(".f-img-editor").parent().attr("href",b)),this.callback("insertImageLink",[b])):("A"==this.$element.find(".f-img-editor").parent().get(0).tagName&&a(this.$element.find(".f-img-editor").get(0)).unwrap(),this.callback("removeImageLink")),this.saveUndoStep(),this.showImageEditor(),this.$element.find(".f-img-editor").find("img").click(),this.link=!1,!1;if(this.restoreSelection(),document.execCommand("unlink",!1,b),this.saveSelectionByMarkers(),this.$element.find("span.f-link").each(function(b,c){a(c).replaceWith(a(c).html())}),this.restoreSelectionByMarkers(),""!==b){document.execCommand("createLink",!1,b);for(var d=this.getSelectionLinks(),e=0;e-1&&e.push(c[h])}d.detach()}}else if(document.selection&&"Control"!=document.selection.type)if(a=document.selection.createRange(),b=a.parentElement(),"a"==b.nodeName.toLowerCase())e.push(b);else{c=b.getElementsByTagName("a"),d=document.body.createTextRange();for(var i=0;i-1&&d.compareEndPoints("EndToStart",a)<1&&e.push(c[i])}return e},b.prototype.isEnabled=function(b){return a.inArray(b,this.options.buttons)>=0},b.prototype.show=function(b){if(void 0!==b){if(this.options.inlineMode)if(null!==b&&"touchend"!==b.type){var c=b.pageX,d=b.pageY;20>c&&(c=20),0>d&&(d=0),c+this.$editor.width()>a(window).width()-50?(this.$editor.addClass("right-side"),c=a(window).width()-(c+30),this.$editor.css("top",d+20),this.$editor.css("right",c),this.$editor.css("left","auto")):(this.$editor.removeClass("right-side"),this.$editor.css("top",d+20),this.$editor.css("left",c-20),this.$editor.css("right","auto")),a(".froala-editor:not(.f-basic)").hide(),this.$editor.show()}else a(".froala-editor:not(.f-basic)").hide(),this.$editor.show(),this.repositionEditor();this.hideLinkWrapper(),this.hideVideoWrapper(),this.hideImageWrapper(),this.$bttn_wrapper.show(),this.$bttn_wrapper.find(".fr-dropdown").removeClass("active"),this.refreshButtons(),this.imageMode=!1}},b.prototype.showByCoordinates=function(b,c){b-=20,c+=15,b+this.$popup_editor.width()>a(window).width()-50?(this.$popup_editor.addClass("right-side"),b=a(window).width()-(b+40),this.$popup_editor.css("top",c),this.$popup_editor.css("right",b),this.$popup_editor.css("left","auto")):(this.$popup_editor.removeClass("right-side"),this.$popup_editor.css("top",c),this.$popup_editor.css("left",b),this.$popup_editor.css("right","auto")),this.$popup_editor.show()},b.prototype.showLinkWrapper=function(){this.$link_wrapper&&this.$link_wrapper.show()},b.prototype.hideLinkWrapper=function(){this.$link_wrapper&&this.$link_wrapper.hide()},b.prototype.showImageWrapper=function(){this.$image_wrapper&&this.$image_wrapper.show()},b.prototype.showVideoWrapper=function(){this.$video_wrapper&&this.$video_wrapper.show()},b.prototype.hideImageWrapper=function(a){this.$image_wrapper&&(this.$element.attr("data-resize")||a||this.closeImageMode(),this.$image_wrapper.hide())},b.prototype.hideVideoWrapper=function(){this.$video_wrapper&&this.$video_wrapper.hide()},b.prototype.showInsertLink=function(){this.options.inlineMode&&this.$bttn_wrapper.hide(),this.showLinkWrapper(),this.hideImageWrapper(!0),this.hideVideoWrapper(),this.$image_editor.hide(),this.link=!0},b.prototype.showInsertImage=function(){this.options.inlineMode&&this.$bttn_wrapper.hide(),this.hideLinkWrapper(),this.hideVideoWrapper(),this.showImageWrapper(),this.$image_editor.hide()},b.prototype.showInsertVideo=function(){this.options.inlineMode&&this.$bttn_wrapper.hide(),this.hideLinkWrapper(),this.hideImageWrapper(),this.showVideoWrapper(),this.$image_editor.hide()},b.prototype.showImageEditor=function(){this.options.inlineMode&&this.$bttn_wrapper.hide(),this.hideLinkWrapper(),this.hideImageWrapper(!0),this.hideVideoWrapper(),this.$image_editor.show(),this.options.imageMove||this.$element.attr("contenteditable",!1)},b.prototype.hide=function(){this.$popup_editor.hide(),this.hideLinkWrapper(),this.hideImageWrapper(),this.hideVideoWrapper(),this.$image_editor.hide(),this.link=!1},b.prototype.positionPopup=function(b){a(this.$editor.find('button.fr-bttn[data-cmd="'+b+'"]')).length&&(this.$popup_editor.css("top",this.$editor.find('button.fr-bttn[data-cmd="'+b+'"]').offset().top+30),this.$popup_editor.css("left",this.$editor.find('button.fr-bttn[data-cmd="'+b+'"]').offset().left),this.$popup_editor.show())},b.prototype.bindButtonEvents=function(){this.bindDropdownEvents(),this.bindCommandEvents()},b.prototype.bindDropdownEvents=function(){var b=this;this.$bttn_wrapper.find(".fr-dropdown").on("click touchend",function(c){return c.stopPropagation(),c.preventDefault(),0==b.options.inlineMode&&b.hide(),a(this).attr("data-disabled")?!1:(a(".fr-dropdown").not(this).removeClass("active"),void a(this).toggleClass("active"))}),a(window).on("click touchend",a.proxy(function(){this.$editor.find(".fr-dropdown").removeClass("active")},this)),this.$element.on("click touchend","img, a",a.proxy(function(){this.$editor.find(".fr-dropdown").removeClass("active")},this));var c=this.$bttn_wrapper.find(".fr-selector button.fr-bttn");c.bind("select",function(){a(this).parents(".fr-selector").find(" > button > i").attr("class",a(this).find("i").attr("class"))}).on("click touch",function(){a(this).parents("ul").find("button").removeClass("active"),a(this).parents(".fr-selector").removeClass("active").trigger("mouseout"),a(this).trigger("select")})},b.prototype.bindCommandEvents=function(){this.$bttn_wrapper.find("[data-cmd]").on("click touchend",a.proxy(function(b){b.stopPropagation(),b.preventDefault();var c=b.currentTarget,d=a(c).data("cmd"),e=a(c).data("val");a(c).parents(".fr-dropdown").removeClass("active"),this.exec(d,e),this.$bttn_wrapper.find(".fr-dropdown").removeClass("active")},this))},b.prototype.exec=function(a,b){if(!this.selectionInEditor()&&"html"!==a&&"undo"!==a&&"redo"!==a&&"selectAll"!==a&&"save"!=a&&"insertImage"!==a&&"insertVideo"!==a)return!1;if(this.selectionInEditor()&&""===this.text()&&"fontSize"!==a&&"formatBlock"!==a&&"indent"!==a&&"outdent"!==a&&"justifyLeft"!==a&&"justifyRight"!==a&&"justifyFull"!==a&&"justifyCenter"!==a&&"html"!==a&&"undo"!==a&&"redo"!==a&&"selectAll"!==a&&"save"!==a&&"insertImage"!==a&&"insertVideo"!==a&&"insertOrderedList"!==a&&"insertUnorderedList"!==a)return!1;switch(a){case"fontSize":this.fontSize(b);break;case"backColor":this.backColor(b);break;case"foreColor":this.foreColor(b);break;case"formatBlock":this.formatBlock(b);break;case"createLink":this.insertLink();break;case"insertImage":this.insertImage();break;case"indent":this.indent();break;case"outdent":this.outdent(!0);break;case"justifyLeft":case"justifyRight":case"justifyCenter":case"justifyFull":this.align(a);break;case"insertOrderedList":case"insertUnorderedList":this.formatList(a);break;case"insertVideo":this.insertVideo();break;case"indent":case"outdent":this.execDefault(a,b),this.repositionEditor();break;case"undo":this.undo();break;case"redo":this.redo();break;case"html":this.html();break;case"save":this.save();break;case"selectAll":this.$element.focus(),this.execDefault(a,b);break;default:this.execDefault(a,b)}"undo"!=a&&"redo"!=a&&"selectAll"!=a&&"createLink"!=a&&"insertImage"!=a&&"html"!=a&&"insertVideo"!=a&&this.saveUndoStep(),"createLink"!=a&&"insertImage"!=a&&this.refreshButtons()},b.prototype.undo=function(){if(this.undoIndex>1){var a=this.getHTML();this.$element.html(this.undoStack[--this.undoIndex-1]),this.hide(),this.callback("undo",[this.$element.html(),a])}this.refreshUndoRedo()},b.prototype.redo=function(){if(this.undoIndex").attr("data-font",!0).css("font-size",b).html(a(e).html());0===a(e).parents("font").length&&c.push(f),a(e).replaceWith(f)});var d=function(b,c){a(c).css("font-size","")};for(var e in c){var f=c[e];a(f).find("*").each(d)}this.$element.find('span[data-font="true"] > span[data-font="true"]').each(function(b,c){a(c).attr("style")&&(a(c).before(''),a(c).after(''))});var g=this.$element.html();g=g.replace(new RegExp('',"g"),""),g=g.replace(new RegExp('data-open="true">',"g"),">"),this.$element.html(g);for(var h=!0,i=a.proxy(function(){this.$element.find('span[data-font="true"] + span[data-font="true"]').each(function(b,c){a(c).css("font-size")==a(c).prev().css("font-size")&&(a(c).prepend(a(c).prev().html()),a(c).prev().remove(),h=!0)}),this.$element.find('span[data-font="true"] + span#marker-true + span[data-font="true"], span[data-font="true"] + span#marker-true + span[data-font="true"]').each(function(b,c){a(c).css("font-size")==a(c).prev().prev().css("font-size")&&(a(c).prepend(a(c).prev().clone()),a(c).prepend(a(c).prev().prev().html()),a(c).prev().prev().remove(),a(c).prev().remove(),h=!0)})},this);h;)h=!1,i();this.$element.find('span[style=""]').each(function(b,c){a(c).replaceWith(a(c).html())}),this.$element.find("span[data-font]").each(function(b,c){a(c).css("font-size")==a(c).parent().css("font-size")&&a(c).replaceWith(a(c).html())}),this.restoreSelectionByMarkers(),this.repositionEditor(),this.callback("fontSize")},b.prototype.backColor=function(c){var d="backColor";this.browser.msie||(d="hiliteColor");var e=a(this.getSelectionElement()).css("background-color");document.execCommand(d,!1,c);var f=this.$editor.find('button.fr-color-bttn[data-cmd="backColor"][data-val="'+c+'"]');f.addClass("active"),f.siblings().removeClass("active"),this.callback("backColor",[b.hexToRGBString(c),e])},b.prototype.foreColor=function(c){var d=a(this.getSelectionElement()).css("color");document.execCommand("foreColor",!1,c),this.saveSelectionByMarkers(),this.$element.find("font[color]").each(function(b,d){a(d).replaceWith(a("").css("color",c).html(a(d).html()))}),this.restoreSelectionByMarkers();var e=this.$editor.find('button.fr-color-bttn[data-cmd="foreColor"][data-val="'+c+'"]');e.addClass("active"),e.siblings().removeClass("active"),this.callback("foreColor",[b.hexToRGBString(c),d])},b.prototype.formatBlock=function(b){if(this.disabledList.indexOf("formatBlock")>=0)return!1;this.saveSelectionByMarkers(),this.wrapText(),this.restoreSelectionByMarkers();var c,d=this.getSelectionElements();for(var e in d){var f=a(d[e]);if(c="n"==b?a("").html(f.html()):a("<"+b+">").html(f.html()),f.get(0)!=this.$element.get(0)&&"LI"!=f.get(0).tagName){var g=f.prop("attributes");if(c.attr)for(var h in g)c.attr(g[h].name,g[h].value);f.replaceWith(c)}else f.html(c)}this.clearSelection(),this.hide(),this.callback("formatBlock")},b.prototype.formatList=function(b){this.saveSelectionByMarkers();var c,d=this.getSelectionElements(),e=!0,f=!1;for(var g in d)c=a(d[g]),c.parents("li").length>0?(c.parents("ol").length>0?(c.parents("li").before(''),c.parents("li").after('')):c.parents("ul").length>0&&(c.parents("li").before(''),c.parents("li").after('')),c.parents("li").replaceWith(c.parents("li").contents()),f=!0):e=!1;if(f){var h=this.$element.html();h=h.replace(new RegExp('',"g"),""),h=h.replace(new RegExp('',"g"),""),h=h.replace(new RegExp('',"g"),""),h=h.replace(new RegExp('',"g"),""),this.$element.html(h),this.$element.find("ul:empty, ol:empty").remove()}if(this.clearSelection(),this.wrapText(),this.restoreSelectionByMarkers(),e===!1){d=this.getSelectionElements(),this.saveSelectionByMarkers();var i=a("");"insertUnorderedList"==b&&(i=a(""));for(var j in d)c=a(d[j]),c.get(0)!=this.$element.get(0)&&(i.append(a("").append(c.clone())),j!=d.length-1?c.remove():c.replaceWith(i));this.restoreSelectionByMarkers()}this.repositionEditor(),this.callback(b)},b.prototype.align=function(b){var c=this.getSelectionElements();this.saveSelection(),"justifyLeft"==b?b="left":"justifyRight"==b?b="right":"justifyCenter"==b?b="center":"justifyFull"==b&&(b="justify");for(var d in c)a(c[d]).css("text-align",b);this.restoreSelection(),this.repositionEditor(),this.callback("align")},b.prototype.indent=function(b){var c=20;b&&(c=-20),this.saveSelectionByMarkers(),this.wrapText(),this.restoreSelectionByMarkers();var d=this.getSelectionElements();this.saveSelectionByMarkers();for(var e in d){var f=a(d[e]);if(f.get(0)!=this.$element.get(0)){var g=parseInt(f.css("margin-left").replace(/px/,""),10),h=Math.max(0,g+c);f.css("marginLeft",h)}else{var i=a("").html(f.html());f.html(i),i.css("marginLeft",Math.max(0,c))}}this.restoreSelectionByMarkers(),this.repositionEditor(),b||this.callback("indent")},b.prototype.outdent=function(){this.indent(!0),this.callback("outdent")},b.prototype.insertLink=function(){this.showInsertLink(),this.options.inlineMode||this.positionPopup("createLink"),this.saveSelection();var b=this.getSelectionLink(),c=this.getSelectionLinks();c.length>0&&this.$link_wrapper.find('input[type="checkbox"]').prop("checked","_blank"==a(c[0]).attr("target")),this.$link_wrapper.find('input[type="text"]').val(b||"http://")},b.prototype.insertImage=function(){this.showInsertImage(),this.saveSelection(),this.options.inlineMode||this.positionPopup("insertImage"),this.$image_wrapper.find('input[type="text"]').val("")},b.prototype.insertVideo=function(){this.showInsertVideo(),this.saveSelection(),this.options.inlineMode||this.positionPopup("insertVideo"),this.$video_wrapper.find("textarea").val("")},b.prototype.execDefault=function(a,b){document.execCommand(a,!1,b),"insertOrderedList"==a?this.$bttn_wrapper.find('[data-cmd="insertUnorderedList"]').removeClass("active"):"insertUnorderedList"==a&&this.$bttn_wrapper.find('[data-cmd="insertOrderedList"]').removeClass("active"),this.callback(a)},b.prototype.refreshButtons=function(){return!this.selectionInEditor()||this.isHTML?!1:(this.refreshUndoRedo(),void this.$bttn_wrapper.find("[data-cmd]").each(a.proxy(function(b,c){switch(a(c).data("cmd")){case"fontSize":this.refreshFontSize(c);break;case"backColor":this.refreshBackColor(c);break;case"foreColor":this.refreshForeColor(c);break;case"formatBlock":this.refreshFormatBlock(c);break;case"createLink":case"insertImage":break;case"justifyLeft":case"justifyRight":case"justifyCenter":case"justifyFull":this.refreshAlign(c);break;case"html":this.isHTML?a(c).addClass("active"):a(c).removeClass("active");break;case"undo":case"redo":case"save":break;default:this.refreshDefault(c)}},this)))},b.prototype.refreshFormatBlock=function(b){this.disabledList.indexOf("formatBlock")>=0&&a(b).parents(".fr-dropdown").attr("data-disabled",!0)},b.prototype.refreshUndoRedo=function(){if(this.isEnabled("undo")||this.isEnabled("redo")){if(void 0===this.$editor)return;this.$bttn_wrapper.find('[data-cmd="undo"], [data-cmd="redo"]').prop("disabled",!1),(0===this.undoStack.length||this.undoIndex<=1||this.isHTML)&&this.$bttn_wrapper.find('[data-cmd="undo"]').prop("disabled",!0),(this.undoIndex==this.undoStack.length||this.isHTML)&&this.$bttn_wrapper.find('[data-cmd="redo"]').prop("disabled",!0)}},b.prototype.refreshDefault=function(b){a(b).removeClass("active");try{document.queryCommandState(a(b).data("cmd"))===!0&&a(b).addClass("active")}catch(c){}},b.prototype.refreshAlign=function(b){var c=a(b).data("cmd"),d=this.getSelectionElements();"justifyLeft"==c?c="left":"justifyRight"==c?c="right":"justifyCenter"==c?c="center":"justifyFull"==c&&(c="justify"),c==a(d[0]).css("text-align")&&(a(b).parents("ul").find(".fr-bttn").removeClass("active"),a(b).addClass("active"),a(b).parents(".fr-dropdown").find(".fr-trigger").html(a(b).html()))},b.prototype.refreshForeColor=function(b){a(b).removeClass("active"),document.queryCommandValue("foreColor")==b.style.backgroundColor&&a(b).addClass("active")},b.prototype.refreshBackColor=function(b){a(b).removeClass("active"),document.queryCommandValue("backColor")==b.style.backgroundColor&&a(b).addClass("active")},b.prototype.refreshFontSize=function(b){a(b).removeClass("active"),parseInt(document.queryCommandValue("fontSize"),10)==parseInt(a(b).data("val"),10)&&a(b).addClass("active") +if("undefined"==typeof jQuery)throw new Error("Froala requires jQuery");!function(a){"use strict";var b=function(c,d){this.options=a.extend({},b.DEFAULTS,a(c).data(),"object"==typeof d&&d),this.browser=b.browser(),this.disabledList=[],this._id=++b.count,this.init(c)};b.count=0,b.VALID_NODES=["P","PRE","BLOCKQUOTE","H1","H2","H3","H4","H5","H6","DIV"],b.COLORS=["#000000","#444444","#666666","#999999","#CCCCCC","#EEEEEE","#F3F3F3","#FFFFFF","#FF0000","#FF9900","#FFFF00","#00FF00","#00FFFF","#0000FF","#9900FF","#FF00FF","#F4CCCC","#FCE5CD","#FFF2CC","#D9EAD3","#D0E0E3","#CFE2F3","#D9D2E9","#EAD1DC","#EA9999","#F9CB9C","#FFE599","#B6D7A8","#A2C4C9","#9FC5E8","#B4A7D6","#D5A6BD","#E06666","#F6B26B","#FFD966","#93C47D","#76A5AF","#6FA8DC","#8E7CC3","#C27BA0","#CC0000","#E69138","#F1C232","#6AA84F","#45818E","#3D85C6","#674EA7","#A64D79","#990000","#B45F06","#BF9000","#38771D","#134F5C","#0B5394","#351C75","#741B47","#660000","#783F04","#7F6000","#274E13","#0C343D","#073763","#201211","#4C1130"],b.commands={bold:{title:"Bold",icon:"fa fa-bold",shortcut:"(Ctrl + B)"},italic:{title:"Italic",icon:"fa fa-italic",shortcut:"(Ctrl + I)"},underline:{cmd:"underline",title:"Underline",icon:"fa fa-underline",shortcut:"(Ctrl + U)"},strikeThrough:{title:"Strikethrough",icon:"fa fa-strikethrough"},fontSize:{title:"Font Size",icon:"fa fa-text-height",seed:[{min:11,max:52}]},color:{icon:"fa fa-font",title:"Color",seed:[{cmd:"backColor",value:b.COLORS,title:"Background Color"},{cmd:"foreColor",value:b.COLORS,title:"Text Color"}]},formatBlock:{title:"Format Block",icon_alt:"¶",seed:[{value:"n",title:"Normal"},{value:"p",title:"Paragraph"},{value:"pre",title:"Code"},{value:"blockquote",title:"Quote"},{value:"h1",title:"Heading 1"},{value:"h2",title:"Heading 2"},{value:"h3",title:"Heading 3"},{value:"h4",title:"Heading 4"},{value:"h5",title:"Heading 5"},{value:"h6",title:"Heading 6"}]},align:{title:"Alignment",icon:"fa fa-align-center",seed:[{cmd:"justifyLeft",title:"Align Left",icon:"fa fa-align-left"},{cmd:"justifyCenter",title:"Align Center",icon:"fa fa-align-center"},{cmd:"justifyRight",title:"Align Right",icon:"fa fa-align-right"},{cmd:"justifyFull",title:"Justify",icon:"fa fa-align-justify"}]},insertOrderedList:{title:"Numbered List",icon:"fa fa-list-ol"},insertUnorderedList:{title:"Bulleted List",icon:"fa fa-list-ul"},outdent:{title:"Indent Less",icon:"fa fa-dedent",activeless:!0,shortcut:"(Ctrl + <)"},indent:{title:"Indent More",icon:"fa fa-indent",activeless:!0,shortcut:"(Ctrl + >)"},selectAll:{title:"Select All",icon:"fa fa-file-text",shortcut:"(Ctrl + A)"},createLink:{title:"Insert Link",icon:"fa fa-link",shortcut:"(Ctrl + K)"},insertImage:{title:"Insert Image",icon:"fa fa-picture-o",activeless:!0,shortcut:"(Ctrl + P)"},undo:{title:"Undo",icon:"fa fa-undo",activeless:!0,shortcut:"(Ctrl+Z)"},redo:{title:"Redo",icon:"fa fa-repeat",activeless:!0,shortcut:"(Shift+Ctrl+Z)"},html:{title:"Show HTML",icon:"fa fa-code"},save:{title:"Save",icon:"fa fa-floppy-o"},insertVideo:{title:"Insert Video",icon:"fa fa-video-camera"}},b.LANGS=[],b.DEFAULTS={autosave:!1,autosaveInterval:1e3,saveURL:null,saveParams:{},blockTags:["n","p","blockquote","pre","h1","h2","h3","h4","h5","h6"],borderColor:"#252528",buttons:["bold","italic","underline","strikeThrough","fontSize","color","sep","formatBlock","align","insertOrderedList","insertUnorderedList","outdent","indent","sep","createLink","insertImage","insertVideo","undo","redo","html"],crossDomain:!1,direction:"ltr",editorClass:"",enableScript:!1,height:"auto",imageMargin:20,imageParams:{},imageErrorCallback:!1,imageMove:!0,imageUploadParam:"file",imageUploadURL:"http://uploads.im/api",inverseSkin:!1,inlineMode:!0,paragraphy:!0,placeholder:"Type something",shortcuts:!0,customText:!1,spellcheck:!1,toolbarFixed:!0,typingTimer:250,width:"auto",language:"en_us",customButtons:[]},b.hexToRGB=function(a){var b=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;a=a.replace(b,function(a,b,c,d){return b+b+c+c+d+d});var c=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a);return c?{r:parseInt(c[1],16),g:parseInt(c[2],16),b:parseInt(c[3],16)}:null},b.hexToRGBString=function(a){var b=this.hexToRGB(a);return"rgb("+b.r+", "+b.g+", "+b.b+")"},b.getIEversion=function(){var a,b,c=-1;return"Microsoft Internet Explorer"==navigator.appName?(a=navigator.userAgent,b=new RegExp("MSIE ([0-9]{1,}[\\.0-9]{0,})"),null!==b.exec(a)&&(c=parseFloat(RegExp.$1))):"Netscape"==navigator.appName&&(a=navigator.userAgent,b=new RegExp("Trident/.*rv:([0-9]{1,}[\\.0-9]{0,})"),null!==b.exec(a)&&(c=parseFloat(RegExp.$1))),c},b.browser=function(){var a={};if(b.getIEversion()>0)a.msie=!0;else{var c=navigator.userAgent.toLowerCase(),d=/(chrome)[ \/]([\w.]+)/.exec(c)||/(webkit)[ \/]([\w.]+)/.exec(c)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(c)||/(msie) ([\w.]+)/.exec(c)||c.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(c)||[],e={browser:d[1]||"",version:d[2]||"0"};d[1]&&(a[e.browser]=!0),parseInt(e.version,10)<9&&a.msie&&(a.oldMsie=!0),a.chrome?a.webkit=!0:a.webkit&&(a.safari=!0)}return a},b.prototype.text=function(){var a="";return window.getSelection?a=window.getSelection():document.getSelection?a=document.getSelection():document.selection&&(a=document.selection.createRange().text),a.toString()},b.prototype.selectionInEditor=function(){var b=this.getSelectionParent(),c=!1;return b==this.$element.get(0)?!0:(a(b).parents().each(a.proxy(function(a,b){b==this.$element.get(0)&&(c=!0)},this)),c)},b.prototype.getSelection=function(){var a="";return a=window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange()},b.prototype.getRange=function(){if(window.getSelection){var a=window.getSelection();if(a.getRangeAt&&a.rangeCount)return a.getRangeAt(0)}return document.createRange()},b.prototype.clearSelection=function(){if(window.getSelection){var a=window.getSelection();a.removeAllRanges()}else document.selection.createRange&&(document.selection.createRange(),document.selection.empty())},b.prototype.getSelectionElement=function(){var a=this.getSelection();if(a.rangeCount){var b=a.getRangeAt(0).startContainer;return 1!=b.nodeType?b.parentNode:b}return this.$element.get(0)},b.prototype.getSelectionParent=function(){var a,b=null;return window.getSelection?(a=window.getSelection(),a.rangeCount&&(b=a.getRangeAt(0).commonAncestorContainer,1!=b.nodeType&&(b=b.parentNode))):(a=document.selection)&&"Control"!=a.type&&(b=a.createRange().parentElement()),b},b.prototype.nodeInRange=function(a,b){var c;if(a.intersectsNode)return a.intersectsNode(b);c=b.ownerDocument.createRange();try{c.selectNode(b)}catch(d){c.selectNodeContents(b)}return-1==a.compareBoundaryPoints(Range.END_TO_START,c)&&1==a.compareBoundaryPoints(Range.START_TO_END,c)},b.prototype.getElementFromNode=function(c){for(1!=c.nodeType&&(c=c.parentNode);null!==c&&b.VALID_NODES.indexOf(c.tagName)<0;)c=c.parentNode;return a.makeArray(a(c).parents()).indexOf(this.$element.get(0))>=0?c:null},b.prototype.nextNode=function(a){if(a.hasChildNodes())return a.firstChild;for(;a&&!a.nextSibling;)a=a.parentNode;return a?a.nextSibling:null},b.prototype.getRangeSelectedNodes=function(a){var b=a.startContainer,c=a.endContainer;if(b==c)return[b];for(var d=[];b&&b!=c;)d.push(b=this.nextNode(b));for(b=a.startContainer;b&&b!=a.commonAncestorContainer;)d.unshift(b),b=b.parentNode;return d},b.prototype.getSelectedNodes=function(){if(window.getSelection){var a=window.getSelection();if(!a.isCollapsed)return this.getRangeSelectedNodes(a.getRangeAt(0));if(this.selectionInEditor()){var b=a.getRangeAt(0).startContainer;return 3==b.nodeType?[b.parentNode]:[b]}}return[]},b.prototype.getSelectionElements=function(){var b=this.getSelectedNodes(),c=[];return a.each(b,a.proxy(function(a,b){if(null!==b){var d=this.getElementFromNode(b);c.indexOf(d)<0&&d!=this.$element.get(0)&&null!==d&&c.push(d)}},this)),0===c.length&&c.push(this.$element.get(0)),c},b.prototype.getSelectionLink=function(){var a,b;return window.getSelection?(b=window.getSelection(),a=b.anchorNode.parentNode.href):(b=document.selection)&&"Control"!=b.type&&(a=b.createRange().parentElement().href),a},b.prototype.saveSelection=function(){var a,b,c,d=this.getSelection();if(d.getRangeAt&&d.rangeCount){for(c=[],a=0,b=d.rangeCount;b>a;a+=1)c.push(d.getRangeAt(a));this.savedRanges=c}else this.savedRanges=null},b.prototype.restoreSelection=function(){var a,b,c=this.getSelection();if(this.savedRanges)for(c.removeAllRanges(),a=0,b=this.savedRanges.length;b>a;a+=1)c.addRange(this.savedRanges[a])},b.prototype.saveSelectionByMarkers=function(){var a=this.getRange();this.placeMarker(a,!0),this.placeMarker(a,!1)},b.prototype.restoreSelectionByMarkers=function(){var a=this.$element.find("#marker-true"),b=this.$element.find("#marker-false");return a.length&&b.length?(this.$element.removeAttr("contentEditable"),this.$element.focus(),this.setSelection(a[0],0,b[0],0),this.removeMarkers(),void this.$element.attr("contentEditable",!0)):!1},b.prototype.setSelection=function(a,b,c,d){try{null===c&&(c=a),null===d&&(d=b);var e=this.getSelection();if(!e)return;var f=this.getRange();f.setStart(a,b),f.setEnd(c,d),e.removeAllRanges(),e.addRange(f)}catch(g){}},b.prototype.placeMarker=function(b,c){var d=b.cloneRange();d.collapse(c),d.insertNode(a('',document)[0]),d.detach()},b.prototype.removeMarkers=function(){this.$element.find("#marker-true, #marker-false").removeAttr("id")},b.prototype.getBoundingRect=function(){var a=this.getRange().getBoundingClientRect();return a},b.prototype.repositionEditor=function(b){var c,d,e;(this.options.inlineMode||b)&&(c=this.getBoundingRect(),void 0!==c.left&&void 0!==c.top&&void 0!==c.right&&void 0!==c.bottom?(d=c.left+c.width/2+a(window).scrollLeft(),e=c.top+c.height+a(window).scrollTop(),this.isTouch()&&(d=c.left+c.width/2,e=c.top+c.height),this.showByCoordinates(d,e)):(document.execCommand("selectAll"),c=this.getRange().getBoundingClientRect(),d=c.left+a(window).scrollLeft(),e=c.top+c.height+a(window).scrollTop(),this.isTouch()&&(d=c.left,e=c.top+c.height),this.showByCoordinates(d,e-20),this.getRange().collapse(!1)))},b.prototype.destroy=function(){this.sync(),this.$editor.remove(),this.$popup_editor&&this.$popup_editor.remove(),this.$element.replaceWith(this.getHTML()),this.$box.removeClass("froala-box"),this.$box.find(".html-switch").remove(),this.$box.removeData("fa.editable"),clearTimeout(this.typingTimer),clearTimeout(this.ajaxInterval),this.$element.off("mousedown mouseup click keydown keyup keypress touchstart touchend touch drop","**"),void 0!==this.$upload_frame&&this.$upload_frame.remove(),this.$textarea&&(this.$box.remove(),this.$textarea.removeData("fa.editable"),this.$textarea.show())},b.prototype.callback=function(b,c,d){var e=b+"Callback";this.options[e]&&a.isFunction(this.options[e])&&(c?this.options[e].apply(this,c):this.options[e].call(this)),void 0==d&&(console.log("sync"),this.sync())},b.prototype.sync=function(){for(""!==this.text()&&this.saveSelectionByMarkers(),this.$element.find("b").each(function(b,c){a(c).replaceWith(""+a(c).html()+"")}),this.$element.find("i").each(function(b,c){a(c).replaceWith(""+a(c).html()+"")}),this.restoreSelectionByMarkers(),this.$textarea&&this.$textarea.val(this.getHTML());this.$element.find("span:empty").length;)this.$element.find("span:empty").remove();this.$element.find("*").each(a.proxy(function(b,c){this.emptyElement(c)&&"SPAN"==c.tagName&&a(c).remove()},this)),this.disableImageResize(),this.$element.trigger("placeholderCheck")},b.prototype.emptyElement=function(b){if("IMG"==b.tagName||a(b).find("img").length>0)return!1;for(var c=a(b).text(),d=0;d'),a(this).append(''),b.restoreSelectionByMarkers(),b.exec("createLink"),b.$link_wrapper.find('input[type="text"]').val(a(this).attr("href")),b.$link_wrapper.find('input[type="checkbox"]').prop("checked","_blank"==a(this).attr("target")),b.repositionEditor(!0),b.$popup_editor.show()})},b.prototype.imageHandle=function(){var b=this,c=a("").addClass("f-img-handle").on({movestart:function(c){b.hide(),b.$element.addClass("f-non-selectable").removeAttr("contenteditable"),b.isResizing=!0,a(this).attr("data-start-x",c.startX),a(this).attr("data-start-y",c.startY)},move:function(b){var c=a(this),d=b.pageX-parseInt(c.attr("data-start-x"),10);c.attr("data-start-x",b.pageX),c.attr("data-start-y",b.pageY);var e=c.prevAll("img");e.width(c.hasClass("f-h-ne")||c.hasClass("f-h-se")?e.width()+d:e.width()-d)},moveend:function(){if(b.isResizing=!1,a(this).removeAttr("data-start-x"),a(this).removeAttr("data-start-y"),b.$element.removeClass("f-non-selectable").attr("contenteditable",!0),b.browser.mozilla)try{document.execCommand("enableObjectResizing",!1,!1),document.execCommand("enableInlineTableEditing",!1,!1)}catch(c){}}});return c},b.prototype.disableImageResize=function(){if(this.browser.mozilla)try{document.execCommand("enableObjectResizing",!1,!1),document.execCommand("enableInlineTableEditing",!1,!1)}catch(a){}},b.prototype.initImageResizer=function(){this.disableImageResize();var b=this;this.$element.on("mousedown","img",function(){!b.options.imageMove||b.browser.msie?b.$element.attr("contenteditable",!1):a(this).parent().hasClass("f-img-editor")&&(b.closeImageMode(),b.hide())}),this.$element.find("img").each(function(a,b){b.oncontrolselect=function(){return!1}}),this.$element.on("mouseup","img",function(){b.options.imageMove||b.$element.attr("contenteditable",!0)}),this.$element.on("click touchend","img",function(c){c.preventDefault(),c.stopPropagation(),b.$element.blur(),b.$image_editor.find("button").removeClass("active");var d=a(this).css("float");b.$image_editor.find('button[data-cmd="floatImage'+d.charAt(0).toUpperCase()+d.slice(1)+'"]').addClass("active"),b.$image_editor.find('.f-image-alt input[type="text"]').val(a(this).attr("alt")||a(this).attr("title")),b.showImageEditor(),b.showByCoordinates(a(this).offset().left+a(this).width()/2,a(this).offset().top+a(this).height()),a(this).parent().hasClass("f-img-editor")&&"SPAN"==a(this).parent().get(0).tagName||(a(this).wrap(''),a(this).css("margin-left","auto"),a(this).css("margin-right","auto"),a(this).css("margin-bottom","auto"));var e=b.imageHandle();a(this).parent().append(e.clone(!0).addClass("f-h-ne")),a(this).parent().append(e.clone(!0).addClass("f-h-se")),a(this).parent().append(e.clone(!0).addClass("f-h-sw")),a(this).parent().append(e.clone(!0).addClass("f-h-nw")),b.clearSelection(),b.imageMode=!0}),this.$element.find("img").each(function(a,b){b.oncontrolselect=function(){return!1}})},b.prototype.initImagePopup=function(){var b=a("").addClass("fr-bttn").attr("data-cmd","floatImageLeft").attr("title","Float Left").html(''),c=a("").addClass("fr-bttn").attr("data-cmd","floatImageNone").attr("title","Float None").html(''),d=a("").addClass("fr-bttn").attr("data-cmd","floatImageRight").attr("title","Float Right").html(''),e=a("").addClass("fr-bttn").attr("data-cmd","linkImage").attr("title","Insert Link").html(''),f=a("").addClass("fr-bttn").attr("data-cmd","replaceImage").attr("title","Replace Image").html(''),g=a("").addClass("fr-bttn").attr("data-cmd","removeImage").attr("title","Remove Image").html(''),h=a('').append('Title: ').append(a('').on("mouseup touchend keydown",function(a){a.stopPropagation()})).append(a('').attr("data-cmd","setImageAlt").attr("title","OK").html("OK"));this.$image_editor=a("").addClass("bttn-wrapper f-image-editor").append(b).append(c).append(d).append(e).append(f).append(g).append("").append(h);var i=this;this.$image_editor.find("button").click(function(b){b.stopPropagation(),i[a(this).attr("data-cmd")](i.$element.find("span.f-img-editor"))}),this.$popup_editor.append(this.$image_editor)},b.prototype.floatImageLeft=function(a){a.css("margin-left","auto"),a.css("margin-right",this.options.imageMargin),a.css("margin-bottom",this.options.imageMargin),a.css("float","left"),a.find("img").css("float","left"),this.saveUndoStep(),this.callback("floatImageLeft"),a.find("img").click()},b.prototype.floatImageNone=function(a){a.css("margin-left","auto"),a.css("margin-right","auto"),a.css("margin-bottom","auto"),a.css("float","none"),a.find("img").css("float","none"),a.parent().get(0)==this.$element.get(0)?a.wrap(''):a.parent().css("text-align","center"),this.saveUndoStep(),this.callback("floatImageNone"),a.find("img").click()},b.prototype.floatImageRight=function(a){a.css("margin-right","auto"),a.css("margin-left",this.options.imageMargin),a.css("margin-bottom",this.options.imageMargin),a.css("float","right"),a.find("img").css("float","right"),this.saveUndoStep(),this.callback("floatImageRight"),a.find("img").click()},b.prototype.linkImage=function(a){this.showInsertLink(),this.imageMode=!0,"A"==a.parent().get(0).tagName?(this.$link_wrapper.find('input[type="text"]').val(a.parent().attr("href")),"_blank"==a.parent().attr("target")?this.$link_wrapper.find('input[type="checkbox"]').prop("checked",!0):this.$link_wrapper.find('input[type="checkbox"]').prop("checked",!1)):this.$link_wrapper.find('input[type="text"]').val("http://")},b.prototype.replaceImage=function(a){this.showInsertImage(),this.imageMode=!0,this.$image_wrapper.find('input[type="text"]').val(a.find("img").attr("src"))},b.prototype.removeImage=function(a){this.callback("beforeRemoveImage");var c="Are you sure? Image will be deleted.";b.LANGS[this.options.language]&&(c=b.LANGS[this.options.language].translation[c]),confirm(c)?(a.remove(),this.hide(),this.saveUndoStep(),this.callback("afterRemoveImage")):a.find("img").click()},b.prototype.setImageAlt=function(a){a.find("img").attr("alt",this.$image_editor.find('.f-image-alt input[type="text"]').val()),a.find("img").attr("title",this.$image_editor.find('.f-image-alt input[type="text"]').val()),this.saveUndoStep(),this.hide(),this.closeImageMode(),this.callback("setImageAlt")},b.prototype.initElement=function(b){"TEXTAREA"==b.tagName?(this.$textarea=a(b),void 0!==this.$textarea.attr("placeholder")&&"Type something"==this.options.placeholder&&(this.options.placeholder=this.$textarea.attr("placeholder")),this.$element=a("").html(this.$textarea.val()),this.$textarea.before(this.$element).hide()):("DIV"!=b.tagName&&this.options.buttons.indexOf("formatBlock")>=0&&this.disabledList.push("formatBlock"),this.$element=a(b)),this.$box=this.$element,this.$element=a(""),this.setHTML(this.$box.html()),this.$box.empty(),this.$box.html(this.$element).addClass("froala-box"),this.sync(),this.$element.on("drop",function(){setTimeout(function(){a("html").click()},1)})},b.prototype.trim=function(a){return String(a).replace(/^\s+|\s+$/g,"")},b.prototype.wrapText=function(){var b=[],c=["SPAN","A","B","I","EM","U","S","STRONG","STRIKE","FONT"],d=this;this.$element.contents().filter(function(){if(this.nodeType==Node.TEXT_NODE&&a(this).text().trim().length>0||c.indexOf(this.tagName)>=0)b.push(this);else{var e;e=a(d.options.paragraphy===!0?"":"");for(var f in b)e.append(a(b[f]).clone()),f==b.length-1?a(b[f]).replaceWith(e):a(b[f]).remove();b=[]}});var e;e=a(this.options.paragraphy===!0?"":"");for(var f in b)e.append(a(b[f]).clone()),f==b.length-1?a(b[f]).replaceWith(e):a(b[f]).remove();this.$element.find("div:empty, > br").remove()},b.prototype.setHTML=function(b){this.$element.html(a.htmlClean(b,{format:!0})),this.wrapText()},b.prototype.initElementStyle=function(){this.$element.attr("contentEditable",!0),this.$element.addClass("froala-element").addClass(this.options.editorClass),this.$element.css("outline",0)},b.prototype.initUndoRedo=function(){(this.isEnabled("undo")||this.isEnabled("redo"))&&(this.undoStack=[],this.undoIndex=0,this.saveUndoStep()),this.disableBrowserUndo()},b.prototype.enableTyping=function(){this.typingTimer=null,this.$element.on("keydown",a.proxy(function(){clearTimeout(this.typingTimer),this.ajaxSave=!1,this.oldHtml=this.$element.html(),this.typingTimer=setTimeout(a.proxy(function(){this.$element.html()!=this.oldHtml&&((this.isEnabled("undo")||this.isEnabled("redo"))&&this.$element.html()!=this.undoStack[this.undoIndex-1]&&this.saveUndoStep(),this.sync())},this),Math.max(this.options.typingTimer,200))},this))},b.prototype.getHTML=function(){var b=this.$element.clone();return b.find(".f-img-editor > img").each(function(b,c){a(c).css("margin-left",a(c).parent().css("margin-left")),a(c).css("margin-right",a(c).parent().css("margin-right")),a(c).css("margin-bottom",a(c).parent().css("margin-bottom")),a(c).siblings("span.f-img-handle").remove().end().unwrap()}),a.htmlClean(b.html())},b.prototype.initAjaxSaver=function(){this.ajaxHTML=this.getHTML(),this.ajaxSave=!0,this.ajaxInterval=setInterval(a.proxy(function(){this.ajaxHTML!=this.getHTML()&&this.ajaxSave&&(this.options.autosave&&this.save(),this.ajaxHTML=this.getHTML(),this.callback("contentChanged",[],!1)),this.ajaxSave=!0},this),Math.max(this.options.autosaveInterval,1e3))},b.prototype.disableBrowserUndo=function(){a("body").keydown(function(a){var b=a.which,c=a.ctrlKey||a.metaKey;if(!this.isHTM&&c){if(75==b)return a.preventDefault(),!1;if(90==b&&a.shiftKey)return a.preventDefault(),!1;if(90==b)return a.preventDefault(),!1}})},b.prototype.saveUndoStep=function(){if(this.isEnabled("undo")||this.isEnabled("redo")){for(;this.undoStack.length>this.undoIndex;)this.undoStack.pop();this.undoStack.push(this.getHTML()),this.undoIndex++,this.refreshUndoRedo()}this.sync()},b.prototype.initShortcuts=function(){this.options.shortcuts&&this.$element.on("keydown",a.proxy(function(a){var b=a.which,c=a.ctrlKey||a.metaKey;if(!this.isHTML&&c){if(70==b)return this.show(null),!1;if(66==b)return this.execDefaultShortcut("bold");if(73==b)return this.execDefaultShortcut("italic");if(85==b)return this.execDefaultShortcut("underline");if(75==b)return this.execDefaultShortcut("createLink");if(80==b)return this.repositionEditor(),this.execDefaultShortcut("insertImage");if(65==b)return this.execDefaultShortcut("selectAll");if(190==b)return this.execDefaultShortcut("indent");if(188==b)return this.execDefaultShortcut("outdent");if(72==b)return this.execDefaultShortcut("html");if(48==b)return this.execDefaultShortcut("formatBlock","n");if(49==b)return this.execDefaultShortcut("formatBlock","h1");if(50==b)return this.execDefaultShortcut("formatBlock","h2");if(51==b)return this.execDefaultShortcut("formatBlock","h3");if(52==b)return this.execDefaultShortcut("formatBlock","h4");if(53==b)return this.execDefaultShortcut("formatBlock","h5");if(54==b)return this.execDefaultShortcut("formatBlock","h6");if(90==b&&a.shiftKey)return this.redo(),a.stopPropagation(),!1;if(90==b)return this.undo(),a.stopPropagation(),!1}9!=b||a.shiftKey?9==b&&a.shiftKey&&a.preventDefault():(a.preventDefault(),this.insertHTML(" ",!1))},this))},b.prototype.insertHTML=function(a,b){var c,d;if(window.getSelection){if(c=window.getSelection(),c.getRangeAt&&c.rangeCount){d=c.getRangeAt(0),d.deleteContents();var e=document.createElement("div");e.innerHTML=a;for(var f,g,h=document.createDocumentFragment();f=e.firstChild;)g=h.appendChild(f);var i=h.firstChild;d.insertNode(h),g&&(d=d.cloneRange(),d.setStartAfter(g),b?d.setStartBefore(i):d.collapse(!0),c.removeAllRanges(),c.addRange(d))}}else if((c=document.selection)&&"Control"!=c.type){var j=c.createRange();j.collapse(!0),c.createRange().pasteHTML(a),b&&(d=c.createRange(),d.setEndPoint("StartToStart",j),d.select())}},b.prototype.execDefaultShortcut=function(a,b){return this.isEnabled(a)?(this.exec(a,b),!1):!0},b.prototype.initEditor=function(){this.$editor=a(""),this.$editor.addClass("froala-editor").hide(),a("body").append(this.$editor),this.options.inlineMode?this.initInlineEditor():this.initBasicEditor()},b.prototype.toolbarTop=function(){a(window).on("scroll resize",a.proxy(function(){this.options.toolbarFixed||this.options.inlineMode||(a(window).scrollTop()>this.$box.offset().top&&a(window).scrollTop() img").each(function(b,c){a(c).css("margin-left",a(c).parent().css("margin-left")),a(c).css("margin-right",a(c).parent().css("margin-right")),a(c).css("margin-bottom",a(c).parent().css("margin-bottom")),a(c).siblings("span.f-img-handle").remove().end().unwrap()}),this.$element.find("span.f-img-editor").length&&this.$element.find("span.f-img-editor").remove(),this.$element.removeClass("f-non-selectable").attr("contenteditable",!0),this.$image_editor.hide()},b.prototype.isTouch=function(){return Modernizr.touch&&void 0!==window.Touch},b.prototype.initEditorSelection=function(){this.$element.on("mousedown touchstart",a.proxy(function(){this.$element.attr("data-resize")||(this.closeImageMode(),this.hide())},this)),this.$element.on("mouseup touchend",a.proxy(function(a){var b=this.text();""===b||this.isTouch()?this.options.inlineMode||this.refreshButtons():(a.stopPropagation(),this.show(a)),this.imageMode=!1},this)),this.$element.on("mousedown touchstart","img, a",a.proxy(function(a){this.isResizing||a.stopPropagation()},this)),this.$element.on("mousedown touchstart",".f-img-handle",a.proxy(function(){this.$element.attr("data-resize",!0)},this)),this.$element.on("mouseup touchend",".f-img-handle",a.proxy(function(){this.$element.removeAttr("data-resize")},this)),this.$editor.on("mouseup touchend",a.proxy(function(a){a.stopPropagation(),this.options.inlineMode===!1&&this.hide()},this)),this.$popup_editor.on("mouseup touchend",a.proxy(function(a){a.stopPropagation()},this)),this.$link_wrapper&&this.$link_wrapper.on("mouseup touchend",a.proxy(function(a){a.stopPropagation()})),this.$image_wrapper&&this.$image_wrapper.on("mouseup touchend",a.proxy(function(a){a.stopPropagation()})),this.$video_wrapper&&this.$video_wrapper.on("mouseup touchend",a.proxy(function(a){a.stopPropagation()})),a(window).on("mouseup touchend",a.proxy(function(){this.selectionInEditor()&&""!==this.text()&&!this.isTouch()?this.show(null):(this.hide(),this.closeImageMode())},this)),a(document).on("selectionchange",a.proxy(function(a){if(this.options.inlineMode&&this.selectionInEditor()&&this.link!==!0&&this.isTouch()){var b=this.text();""!==b?(Modernizr.mq("(max-device-width: 320px) and (-webkit-min-device-pixel-ratio: 2)")||this.show(null),a.stopPropagation()):this.hide()}},this)),a(window).keydown(a.proxy(function(a){a.ctrlKey||(this.hide(),this.closeImageMode())},this))},b.prototype.setPlaceholder=function(a){a&&(this.options.placeholder=a),this.$textarea&&this.$textarea.attr("placeholder",this.options.placeholder),this.$element.attr("data-placeholder",this.options.placeholder)},b.prototype.isEmpty=function(){var a=this.$element.text().replace(/(\r\n|\n|\r|\t)/gm,"");return(""===a||1==a.length&&"8203"==a.charCodeAt(0))&&0===this.$element.find("img").length&&0==this.$element.find("p > br").length},b.prototype.setPlaceholderEvents=function(){this.$element.on("keyup keydown focus placeholderCheck",a.proxy(function(){if(this.isEmpty()&&!this.isHTML){if(this.options.paragraphy){var b=a("");this.$element.html(b),this.setSelection(b.get(0),0,null,0)}this.$element.addClass("f-placeholder")}else this.$element.find("p").length?this.isEmpty()===!1&&this.$element.removeClass("f-placeholder"):this.options.paragraphy&&(this.wrapText(),this.setSelection(this.$element.find("p")[0],1,null,1))},this)),this.$element.trigger("placeholderCheck")},b.prototype.setDimensions=function(a,b){a&&(this.options.height=a),b&&(this.options.width=b),"auto"!=this.options.height&&this.$element.css("height",this.options.height),"auto"!=this.options.width&&this.$box.css("width",this.options.width)},b.prototype.setDirection=function(a){a&&(this.options.direction=a),"ltr"!=this.options.direction&&"rtl"!=this.options.direction&&(this.options.direction="ltr"),"rtl"==this.options.direction?(this.$element.addClass("f-rtl"),this.$editor.addClass("f-rtl"),this.$popup_editor.addClass("f-rtl")):(this.$element.removeClass("f-rtl"),this.$editor.removeClass("f-rtl"),this.$popup_editor.removeClass("f-rtl"))},b.prototype.setBorderColor=function(a){a&&(this.options.borderColor=a);var c=b.hexToRGB(this.options.borderColor);null!==c&&(this.$editor.css("border-color",this.options.borderColor),this.$editor.attr("data-border-color",this.options.borderColor))},b.prototype.setSpellcheck=function(a){void 0!==a&&(this.options.spellcheck=a),this.$element.attr("spellcheck",this.options.spellcheck)},b.prototype.setInverseSkin=function(a){void 0!==a&&(this.options.inverseSkin=a),this.options.inverseSkin?(this.$editor.addClass("f-inverse"),this.$popup_editor.addClass("f-inverse")):(this.$editor.removeClass("f-inverse"),this.$popup_editor.removeClass("f-inverse"))},b.prototype.customizeText=function(b){b&&(this.$editor.find("[title]").add(this.$popup_editor.find("[title]")).each(a.proxy(function(c,d){for(var e in b)a(d).attr("title").toLowerCase()==e.toLowerCase()&&a(d).attr("title",b[e])},this)),this.$editor.find('[data-text="true"]').add(this.$popup_editor.find('[data-text="true"]')).each(a.proxy(function(c,d){for(var e in b)a(d).text().toLowerCase()==e.toLowerCase()&&a(d).text(b[e])},this)))},b.prototype.setLanguage=function(b){void 0!==b&&(this.options.language=b),a.Editable.LANGS[this.options.language]&&(this.customizeText(a.Editable.LANGS[this.options.language].translation),a.Editable.LANGS[this.options.language].direction&&this.setDirection(a.Editable.LANGS[this.options.language].direction),a.Editable.LANGS[this.options.language].translation[this.options.placeholder]&&this.setPlaceholder(a.Editable.LANGS[this.options.language].translation[this.options.placeholder]))},b.prototype.setCustomText=function(a){a&&(this.options.customText=a),this.options.customText&&this.customizeText(this.options.customText) +},b.prototype.execHTML=function(){this.html()},b.prototype.initHTMLArea=function(){this.$html_area=a('').keydown(function(b){var c=b.keyCode||b.which;if(9==c){b.preventDefault();var d=a(this).get(0).selectionStart,e=a(this).get(0).selectionEnd;a(this).val(a(this).val().substring(0,d)+" "+a(this).val().substring(e)),a(this).get(0).selectionStart=a(this).get(0).selectionEnd=d+1}})},b.prototype.setButtons=function(c){c&&(this.options.buttons=c),this.$bttn_wrapper=a("").addClass("bttn-wrapper"),this.$editor.append(this.$bttn_wrapper);for(var d in this.options.buttons){var e,f;"sep"==this.options.buttons[d]&&this.$bttn_wrapper.append(this.options.inlineMode?'':'');var g=b.commands[this.options.buttons[d]];if(void 0!==g)switch(g.cmd=this.options.buttons[d],g.cmd){case"color":e=this.buildDropdownColor(g),f=this.buildDropdownButton(g,"fr-color-picker").append(e),this.$bttn_wrapper.append(f);break;case"align":e=this.buildDropdownAlign(g),f=this.buildDropdownButton(g,"fr-selector").append(e),this.$bttn_wrapper.append(f);break;case"fontSize":e=this.buildDropdownFontsize(g),f=this.buildDropdownButton(g).append(e),this.$bttn_wrapper.append(f);break;case"formatBlock":e=this.buildDropdownFormatblock(g),f=this.buildDropdownButton(g).append(e),this.$bttn_wrapper.append(f);break;case"createLink":f=this.buildDefaultButton(g),this.$bttn_wrapper.append(f);break;case"insertImage":f=this.buildDefaultButton(g),this.$bttn_wrapper.append(f);break;case"insertVideo":f=this.buildDefaultButton(g),this.$bttn_wrapper.append(f),this.buildInsertVideo();break;case"undo":case"redo":f=this.buildDefaultButton(g),this.$bttn_wrapper.append(f),f.prop("disabled",!0);break;case"html":f=this.buildDefaultButton(g),this.$bttn_wrapper.append(f),this.options.inlineMode&&this.$box.append(f.clone(!0).addClass("html-switch").attr("title","Hide HTML").click(a.proxy(this.execHTML,this))),this.initHTMLArea();break;default:f=this.buildDefaultButton(g),this.$bttn_wrapper.append(f)}else{if(g=this.options.customButtons[this.options.buttons[d]],void 0===g)continue;f=this.buildCustomButton(g),this.$bttn_wrapper.append(f)}}this.buildCreateLink(),this.buildInsertImage(),this.bindButtonEvents()},b.prototype.buildDefaultButton=function(b){var c=a("").addClass("fr-bttn").attr("title",b.title).attr("data-cmd",b.cmd).attr("data-activeless",b.activeless);return this.addButtonIcon(c,b),c},b.prototype.addButtonIcon=function(b,c){b.append(c.icon?a("").addClass(c.icon):c.icon_alt?a("").addClass("for-text").html(c.icon_alt):c.icon_img?a('').attr("alt",c.title):c.icon_txt?a("").html(c.icon_txt):c.title)},b.prototype.buildCustomButton=function(b){var c=a("").addClass("fr-bttn").attr("title",b.title);return"fa"==b.icon.type?this.addButtonIcon(c,{icon:"fa "+b.icon.value}):"img"==b.icon.type?this.addButtonIcon(c,{icon_img:b.icon.value,title:b.title}):"txt"==b.icon.type&&this.addButtonIcon(c,{icon_txt:b.icon.value}),c.on("click touchend",a.proxy(function(a){a.stopPropagation(),a.preventDefault(),b.callback(this)},this)),c},b.prototype.buildDropdownButton=function(b,c){c=c||"";var d=a("").addClass("fr-bttn fr-dropdown").addClass(c),e=a("").addClass("fr-trigger").attr("title",b.title);return this.addButtonIcon(e,b),d.append(e),d},b.prototype.buildDropdownColor=function(b){var c=a("").addClass("fr-dropdown-menu");for(var d in b.seed){var e=b.seed[d],f=a("").append(a('').html(e.title));for(var g in e.value){var h=e.value[g];f.append(a("").addClass("fr-color-bttn").attr("data-cmd",e.cmd).attr("data-val",h).attr("data-activeless",b.activeless).css("background-color",h).html(" ")),g%8==7&&g>0&&(f.append(""),(7==g||15==g)&&f.append(a("").addClass("separator")))}c.append(f)}return c},b.prototype.buildDropdownAlign=function(b){var c=a("").addClass("fr-dropdown-menu");for(var d in b.seed){var e=b.seed[d],f=a("").append(a("").addClass("fr-bttn").attr("data-cmd",e.cmd).attr("title",e.title).attr("data-activeless",b.activeless).append(a("").addClass(e.icon)));c.append(f)}return c},b.prototype.buildDropdownFontsize=function(b){var c=a("").addClass("fr-dropdown-menu f-font-sizes");for(var d in b.seed)for(var e=b.seed[d],f=e.min;f<=e.max;f++){var g=a("").attr("data-cmd",b.cmd).attr("data-val",f+"px").attr("data-activeless",b.activeless).append(a('').append(a("").text(f+"px")));c.append(g)}return c},b.prototype.buildDropdownFormatblock=function(b){var c=a("").addClass("fr-dropdown-menu");for(var d in b.seed){var e=b.seed[d];if(-1!=a.inArray(e.value,this.options.blockTags)){var f=a("").append(a("").attr("data-cmd",b.cmd).attr("data-val",e.value).attr("data-activeless",b.activeless).append(a('').addClass("format_"+e.value).attr("title",e.title).text(e.title)));c.append(f)}}return c},b.prototype.buildInsertImage=function(){this.$image_wrapper=a("").addClass("image-wrapper"),this.$popup_editor.append(this.$image_wrapper);var b=this;this.$progress_bar=a('').append("");var c=a('').append('Drop Image(or click)').append(a('').append(a('')));this.browser.msie&&(this.$upload_frame=a(''),a("body").append(this.$upload_frame),this.$upload_frame.bind("load",function(){var c=a(this).contents().text();b.parseImageResponse(c)})),this.$image_wrapper.on("change",'input[type="file"]',function(){if(void 0!==this.files)b.uploadFile(this.files);else{var c=a(this).parents("form");c.find('input[type="hidden"]').remove();for(var d in b.options.imageParams)c.append('');c.append(''),c.submit()}}),this.buildDragUpload(c);var d=a('').on("mouseup touchend keydown",a.proxy(function(a){a.stopPropagation()},this));this.$image_list=a("").append(a('').append(c)).append(a('').append('Enter URL: ').append(d).append(a('OK').click(a.proxy(function(){this.writeImage(d.val())},this)))),this.$image_wrapper.append(a("").append('Insert image').append(a('').click(a.proxy(function(){this.$bttn_wrapper.show(),this.hideImageWrapper(!0),this.restoreSelection(),this.options.inlineMode||this.imageMode?this.imageMode&&this.showImageEditor():this.hide()},this)))).append(this.$image_list).append(this.$progress_bar).click(function(a){a.stopPropagation()}).find("*").click(function(a){a.stopPropagation()}).end().hide()},b.prototype.buildInsertVideo=function(){this.$video_wrapper=a("").addClass("video-wrapper"),this.$popup_editor.append(this.$video_wrapper);var b=a('').on("mouseup touchend keydown",a.proxy(function(a){a.stopPropagation()},this)),c=a("").append(a('OK').click(a.proxy(function(){this.restoreSelection(),a(this.getSelectionElements()[0]).after(this.options.paragraphy?''+b.val()+"":''+b.val()+""),this.saveUndoStep(),this.$bttn_wrapper.show(),this.hideVideoWrapper(),this.hide(),this.callback("insertVideo",[b.val()])},this)));this.$video_wrapper.append(a("").append('Insert video').append(a('').click(a.proxy(function(){this.$bttn_wrapper.show(),this.hideVideoWrapper(),this.restoreSelection(),this.options.inlineMode||this.hide()},this)))).append(b).append(c).click(function(a){a.stopPropagation()}).find("*").click(function(a){a.stopPropagation()}).end().hide()},b.prototype.buildCreateLink=function(){this.$link_wrapper=a("").addClass("link-wrapper"),this.$popup_editor.append(this.$link_wrapper);var b=a('').attr("placeholder","http://www.example.com").on("mouseup touchend keydown",function(a){a.stopPropagation()}),c=a('').click(function(a){a.stopPropagation()}),d=a('').text("OK").on("touchend",function(a){a.stopPropagation()}).click(a.proxy(function(){this.writeLink(b.val(),c.prop("checked"))},this)),e=a('').text("UNLINK").on("click touch",a.proxy(function(){this.link=!0,this.writeLink("",c.prop("checked"))},this));this.$link_wrapper.append(a("").append('Insert link').append(a('').click(a.proxy(function(){this.$bttn_wrapper.show(),this.hideLinkWrapper(),this.options.inlineMode||this.imageMode?this.imageMode&&this.showImageEditor():this.hide(),this.restoreSelection()},this)))).append(b).append(a("").append(c).append(' Open in new tab').append(d).append(e)).end().hide()},b.prototype.buildDragUpload=function(b){var c=this;b.on({dragover:function(){return a(this).addClass("f-hover"),!1},dragend:function(){return a(this).removeClass("f-hover"),!1},drop:function(b){a(this).removeClass("f-hover"),b.preventDefault(),c.uploadFile(b.originalEvent.dataTransfer.files)}})},b.prototype.hideImageLoader=function(){this.$progress_bar.hide(),this.$progress_bar.find("span").css("width","0%").text(""),this.$image_list.show()},b.prototype.writeImage=function(b){var c=new Image;if(c.onerror=a.proxy(function(){this.hideImageLoader(),this.throwImageError(1)},this),this.imageMode)return c.onload=a.proxy(function(){this.$element.find(".f-img-editor > img").attr("src",b),this.hide(),this.hideImageLoader(),this.$image_editor.show(),this.saveUndoStep(),this.callback("replaceImage",[b])},this),c.src=b,!1;var d=this.getSelectionElements()[0];c.onload=a.proxy(function(){a(d).prepend(''),a(d).find("img:first").get(0).oncontrolselect=function(){return!1},this.hide(),this.hideImageLoader(),this.saveUndoStep(),this.callback("insertImage",[b])},this),c.src=b},b.prototype.throwImageError=function(b){var c="Unknown image upload error.";1==b?c="Bad link.":2==b?c="No link in upload response.":3==b?c="Error during file upload.":4==b&&(c="Parsing response failed."),this.options.imageErrorCallback&&a.isFunction(this.options.imageErrorCallback)&&this.options.imageErrorCallback({errorCode:b,errorStatus:c})},b.prototype.uploadFile=function(b){if(void 0!==b&&b.length>0){var c;if(this.drag_support.formdata&&(c=this.drag_support.formdata?new FormData:null),c&&c.append(this.options.imageUploadParam,b[0]),c){var d;this.options.crossDomain?d=this.createCORSRequest("POST",this.options.imageUploadURL):(d=new XMLHttpRequest,d.open("POST",this.options.imageUploadURL)),d.onload=a.proxy(function(){this.$progress_bar.find("span").css("width","100%").text("Please wait!");try{200==d.status?this.parseImageResponse(d.responseText):this.throwImageError(3)}catch(a){this.throwImageError(4)}this.hideImageLoader()},this),d.onerror=a.proxy(function(){this.throwImageError(3),this.hideImageLoader()},this),d.upload.onprogress=a.proxy(function(a){if(a.lengthComputable){var b=a.loaded/a.total*100|0;this.$progress_bar.find("span").css("width",b+"%")}},this);for(var e in this.options.imageParams)c.append(e,this.options.imageParams[e]);d.send(c),this.$image_list.hide(),this.$progress_bar.show()}}},b.prototype.parseImageResponse=function(b){try{var c=a.parseJSON(b);"http://uploads.im/api"==this.options.imageUploadURL?this.writeImage(c.data.img_url):c.link?this.writeImage(c.link):this.throwImageError(2)}catch(d){this.throwImageError(4)}},b.prototype.createCORSRequest=function(a,b){var c=new XMLHttpRequest;return"withCredentials"in c?c.open(a,b,!0):"undefined"!=typeof XDomainRequest?(c=new XDomainRequest,c.open(a,b)):c=null,c},b.prototype.writeLink=function(b,c){if(this.imageMode)return""!==b?("A"!=this.$element.find(".f-img-editor").parent().get(0).tagName?this.$element.find(".f-img-editor").wrap(c===!0?'':''):c===!0?this.$element.find(".f-img-editor").parent().attr("target","_blank"):(this.$element.find(".f-img-editor").parent().removeAttr("target"),this.$element.find(".f-img-editor").parent().attr("href",b)),this.callback("insertImageLink",[b])):("A"==this.$element.find(".f-img-editor").parent().get(0).tagName&&a(this.$element.find(".f-img-editor").get(0)).unwrap(),this.callback("removeImageLink")),this.saveUndoStep(),this.showImageEditor(),this.$element.find(".f-img-editor").find("img").click(),this.link=!1,!1;if(this.restoreSelection(),document.execCommand("unlink",!1,b),this.saveSelectionByMarkers(),this.$element.find("span.f-link").each(function(b,c){a(c).replaceWith(a(c).html())}),this.restoreSelectionByMarkers(),""!==b){document.execCommand("createLink",!1,b);for(var d=this.getSelectionLinks(),e=0;e-1&&e.push(c[h])}d.detach()}}else if(document.selection&&"Control"!=document.selection.type)if(a=document.selection.createRange(),b=a.parentElement(),"a"==b.nodeName.toLowerCase())e.push(b);else{c=b.getElementsByTagName("a"),d=document.body.createTextRange();for(var i=0;i-1&&d.compareEndPoints("EndToStart",a)<1&&e.push(c[i])}return e},b.prototype.isEnabled=function(b){return a.inArray(b,this.options.buttons)>=0},b.prototype.show=function(b){if(void 0!==b){if(this.options.inlineMode)if(null!==b&&"touchend"!==b.type){var c=b.pageX,d=b.pageY;20>c&&(c=20),0>d&&(d=0),c+this.$editor.width()>a(window).width()-50?(this.$editor.addClass("right-side"),c=a(window).width()-(c+30),this.$editor.css("top",d+20),this.$editor.css("right",c),this.$editor.css("left","auto")):(this.$editor.removeClass("right-side"),this.$editor.css("top",d+20),this.$editor.css("left",c-20),this.$editor.css("right","auto")),a(".froala-editor:not(.f-basic)").hide(),this.$editor.show()}else a(".froala-editor:not(.f-basic)").hide(),this.$editor.show(),this.repositionEditor();this.hideLinkWrapper(),this.hideVideoWrapper(),this.hideImageWrapper(),this.$bttn_wrapper.show(),this.$bttn_wrapper.find(".fr-dropdown").removeClass("active"),this.refreshButtons(),this.imageMode=!1}},b.prototype.showByCoordinates=function(b,c){b-=20,c+=15,b+this.$popup_editor.width()>a(window).width()-50?(this.$popup_editor.addClass("right-side"),b=a(window).width()-(b+40),this.$popup_editor.css("top",c),this.$popup_editor.css("right",b),this.$popup_editor.css("left","auto")):(this.$popup_editor.removeClass("right-side"),this.$popup_editor.css("top",c),this.$popup_editor.css("left",b),this.$popup_editor.css("right","auto")),this.$popup_editor.show()},b.prototype.showLinkWrapper=function(){this.$link_wrapper&&this.$link_wrapper.show()},b.prototype.hideLinkWrapper=function(){this.$link_wrapper&&this.$link_wrapper.hide()},b.prototype.showImageWrapper=function(){this.$image_wrapper&&this.$image_wrapper.show()},b.prototype.showVideoWrapper=function(){this.$video_wrapper&&this.$video_wrapper.show()},b.prototype.hideImageWrapper=function(a){this.$image_wrapper&&(this.$element.attr("data-resize")||a||this.closeImageMode(),this.$image_wrapper.hide())},b.prototype.hideVideoWrapper=function(){this.$video_wrapper&&this.$video_wrapper.hide()},b.prototype.showInsertLink=function(){this.options.inlineMode&&this.$bttn_wrapper.hide(),this.showLinkWrapper(),this.hideImageWrapper(!0),this.hideVideoWrapper(),this.$image_editor.hide(),this.link=!0},b.prototype.showInsertImage=function(){this.options.inlineMode&&this.$bttn_wrapper.hide(),this.hideLinkWrapper(),this.hideVideoWrapper(),this.showImageWrapper(),this.$image_editor.hide()},b.prototype.showInsertVideo=function(){this.options.inlineMode&&this.$bttn_wrapper.hide(),this.hideLinkWrapper(),this.hideImageWrapper(),this.showVideoWrapper(),this.$image_editor.hide()},b.prototype.showImageEditor=function(){this.options.inlineMode&&this.$bttn_wrapper.hide(),this.hideLinkWrapper(),this.hideImageWrapper(!0),this.hideVideoWrapper(),this.$image_editor.show(),this.options.imageMove||this.$element.attr("contenteditable",!1)},b.prototype.hide=function(){this.$popup_editor.hide(),this.hideLinkWrapper(),this.hideImageWrapper(),this.hideVideoWrapper(),this.$image_editor.hide(),this.link=!1},b.prototype.positionPopup=function(b){a(this.$editor.find('button.fr-bttn[data-cmd="'+b+'"]')).length&&(this.$popup_editor.css("top",this.$editor.find('button.fr-bttn[data-cmd="'+b+'"]').offset().top+30),this.$popup_editor.css("left",this.$editor.find('button.fr-bttn[data-cmd="'+b+'"]').offset().left),this.$popup_editor.show())},b.prototype.bindButtonEvents=function(){this.bindDropdownEvents(),this.bindCommandEvents()},b.prototype.bindDropdownEvents=function(){var b=this;this.$bttn_wrapper.find(".fr-dropdown").on("click touchend",function(c){return c.stopPropagation(),c.preventDefault(),0==b.options.inlineMode&&b.hide(),a(this).attr("data-disabled")?!1:(a(".fr-dropdown").not(this).removeClass("active"),void a(this).toggleClass("active"))}),a(window).on("click touchend",a.proxy(function(){this.$editor.find(".fr-dropdown").removeClass("active")},this)),this.$element.on("click touchend","img, a",a.proxy(function(){this.$editor.find(".fr-dropdown").removeClass("active")},this));var c=this.$bttn_wrapper.find(".fr-selector button.fr-bttn");c.bind("select",function(){a(this).parents(".fr-selector").find(" > button > i").attr("class",a(this).find("i").attr("class"))}).on("click touch",function(){a(this).parents("ul").find("button").removeClass("active"),a(this).parents(".fr-selector").removeClass("active").trigger("mouseout"),a(this).trigger("select")})},b.prototype.bindCommandEvents=function(){this.$bttn_wrapper.find("[data-cmd]").on("click touchend",a.proxy(function(b){b.stopPropagation(),b.preventDefault();var c=b.currentTarget,d=a(c).data("cmd"),e=a(c).data("val");a(c).parents(".fr-dropdown").removeClass("active"),this.exec(d,e),this.$bttn_wrapper.find(".fr-dropdown").removeClass("active")},this))},b.prototype.exec=function(a,b){if(!this.selectionInEditor()&&"html"!==a&&"undo"!==a&&"redo"!==a&&"selectAll"!==a&&"save"!=a&&"insertImage"!==a&&"insertVideo"!==a)return!1;if(this.selectionInEditor()&&""===this.text()&&"fontSize"!==a&&"formatBlock"!==a&&"indent"!==a&&"outdent"!==a&&"justifyLeft"!==a&&"justifyRight"!==a&&"justifyFull"!==a&&"justifyCenter"!==a&&"html"!==a&&"undo"!==a&&"redo"!==a&&"selectAll"!==a&&"save"!==a&&"insertImage"!==a&&"insertVideo"!==a&&"insertOrderedList"!==a&&"insertUnorderedList"!==a)return!1;switch(a){case"fontSize":this.fontSize(b);break;case"backColor":this.backColor(b);break;case"foreColor":this.foreColor(b);break;case"formatBlock":this.formatBlock(b);break;case"createLink":this.insertLink();break;case"insertImage":this.insertImage();break;case"indent":this.indent();break;case"outdent":this.outdent(!0);break;case"justifyLeft":case"justifyRight":case"justifyCenter":case"justifyFull":this.align(a);break;case"insertOrderedList":case"insertUnorderedList":this.formatList(a);break;case"insertVideo":this.insertVideo();break;case"indent":case"outdent":this.execDefault(a,b),this.repositionEditor();break;case"undo":this.undo();break;case"redo":this.redo();break;case"html":this.html();break;case"save":this.save();break;case"selectAll":this.$element.focus(),this.execDefault(a,b);break;default:this.execDefault(a,b)}"undo"!=a&&"redo"!=a&&"selectAll"!=a&&"createLink"!=a&&"insertImage"!=a&&"html"!=a&&"insertVideo"!=a&&this.saveUndoStep(),"createLink"!=a&&"insertImage"!=a&&this.refreshButtons()},b.prototype.undo=function(){if(this.undoIndex>1){var a=this.getHTML();this.$element.html(this.undoStack[--this.undoIndex-1]),this.hide(),this.callback("undo",[this.$element.html(),a])}this.refreshUndoRedo()},b.prototype.redo=function(){if(this.undoIndex").attr("data-font",!0).css("font-size",b).html(a(e).html());0===a(e).parents("font").length&&c.push(f),a(e).replaceWith(f)});var d=function(b,c){a(c).css("font-size","")};for(var e in c){var f=c[e];a(f).find("*").each(d)}this.$element.find('span[data-font="true"] > span[data-font="true"]').each(function(b,c){a(c).attr("style")&&(a(c).before(''),a(c).after(''))});var g=this.$element.html();g=g.replace(new RegExp('',"g"),""),g=g.replace(new RegExp('data-open="true">',"g"),">"),this.$element.html(g);for(var h=!0,i=a.proxy(function(){this.$element.find('span[data-font="true"] + span[data-font="true"]').each(function(b,c){a(c).css("font-size")==a(c).prev().css("font-size")&&(a(c).prepend(a(c).prev().html()),a(c).prev().remove(),h=!0)}),this.$element.find('span[data-font="true"] + span#marker-true + span[data-font="true"], span[data-font="true"] + span#marker-true + span[data-font="true"]').each(function(b,c){a(c).css("font-size")==a(c).prev().prev().css("font-size")&&(a(c).prepend(a(c).prev().clone()),a(c).prepend(a(c).prev().prev().html()),a(c).prev().prev().remove(),a(c).prev().remove(),h=!0)})},this);h;)h=!1,i();this.$element.find('span[style=""]').each(function(b,c){a(c).replaceWith(a(c).html())}),this.$element.find("span[data-font]").each(function(b,c){a(c).css("font-size")==a(c).parent().css("font-size")&&a(c).replaceWith(a(c).html())}),this.restoreSelectionByMarkers(),this.repositionEditor(),this.callback("fontSize")},b.prototype.backColor=function(c){var d="backColor";this.browser.msie||(d="hiliteColor");var e=a(this.getSelectionElement()).css("background-color");document.execCommand(d,!1,c);var f=this.$editor.find('button.fr-color-bttn[data-cmd="backColor"][data-val="'+c+'"]');f.addClass("active"),f.siblings().removeClass("active"),this.callback("backColor",[b.hexToRGBString(c),e])},b.prototype.foreColor=function(c){var d=a(this.getSelectionElement()).css("color");document.execCommand("foreColor",!1,c),this.saveSelectionByMarkers(),this.$element.find("font[color]").each(function(b,d){a(d).replaceWith(a("").css("color",c).html(a(d).html()))}),this.restoreSelectionByMarkers();var e=this.$editor.find('button.fr-color-bttn[data-cmd="foreColor"][data-val="'+c+'"]');e.addClass("active"),e.siblings().removeClass("active"),this.callback("foreColor",[b.hexToRGBString(c),d])},b.prototype.formatBlock=function(b){if(this.disabledList.indexOf("formatBlock")>=0)return!1;this.saveSelectionByMarkers(),this.wrapText(),this.restoreSelectionByMarkers();var c,d=this.getSelectionElements();for(var e in d){var f=a(d[e]);if(c="n"==b?a("").html(f.html()):a("<"+b+">").html(f.html()),f.get(0)!=this.$element.get(0)&&"LI"!=f.get(0).tagName){var g=f.prop("attributes");if(c.attr)for(var h in g)c.attr(g[h].name,g[h].value);f.replaceWith(c)}else f.html(c)}this.clearSelection(),this.hide(),this.callback("formatBlock")},b.prototype.formatList=function(b){this.saveSelectionByMarkers();var c,d=this.getSelectionElements(),e=!0,f=!1;for(var g in d)c=a(d[g]),c.parents("li").length>0?(c.parents("ol").length>0?(c.parents("li").before(''),c.parents("li").after('')):c.parents("ul").length>0&&(c.parents("li").before(''),c.parents("li").after('')),c.parents("li").replaceWith(c.parents("li").contents()),f=!0):e=!1;if(f){var h=this.$element.html();h=h.replace(new RegExp('',"g"),""),h=h.replace(new RegExp('',"g"),""),h=h.replace(new RegExp('',"g"),""),h=h.replace(new RegExp('',"g"),""),this.$element.html(h),this.$element.find("ul:empty, ol:empty").remove()}if(this.clearSelection(),this.wrapText(),this.restoreSelectionByMarkers(),e===!1){d=this.getSelectionElements(),this.saveSelectionByMarkers();var i=a("");"insertUnorderedList"==b&&(i=a(""));for(var j in d)c=a(d[j]),c.get(0)!=this.$element.get(0)&&(i.append(a("").append(c.clone())),j!=d.length-1?c.remove():c.replaceWith(i));this.restoreSelectionByMarkers()}this.repositionEditor(),this.callback(b)},b.prototype.align=function(b){var c=this.getSelectionElements();this.saveSelection(),"justifyLeft"==b?b="left":"justifyRight"==b?b="right":"justifyCenter"==b?b="center":"justifyFull"==b&&(b="justify");for(var d in c)a(c[d]).css("text-align",b);this.restoreSelection(),this.repositionEditor(),this.callback("align")},b.prototype.indent=function(b){var c=20;b&&(c=-20),this.saveSelectionByMarkers(),this.wrapText(),this.restoreSelectionByMarkers();var d=this.getSelectionElements();this.saveSelectionByMarkers();for(var e in d){var f=a(d[e]);if(f.get(0)!=this.$element.get(0)){var g=parseInt(f.css("margin-left").replace(/px/,""),10),h=Math.max(0,g+c);f.css("marginLeft",h)}else{var i=a("").html(f.html());f.html(i),i.css("marginLeft",Math.max(0,c))}}this.restoreSelectionByMarkers(),this.repositionEditor(),b||this.callback("indent")},b.prototype.outdent=function(){this.indent(!0),this.callback("outdent")},b.prototype.insertLink=function(){this.showInsertLink(),this.options.inlineMode||this.positionPopup("createLink"),this.saveSelection();var b=this.getSelectionLink(),c=this.getSelectionLinks();c.length>0&&this.$link_wrapper.find('input[type="checkbox"]').prop("checked","_blank"==a(c[0]).attr("target")),this.$link_wrapper.find('input[type="text"]').val(b||"http://")},b.prototype.insertImage=function(){this.showInsertImage(),this.saveSelection(),this.options.inlineMode||this.positionPopup("insertImage"),this.$image_wrapper.find('input[type="text"]').val("")},b.prototype.insertVideo=function(){this.showInsertVideo(),this.saveSelection(),this.options.inlineMode||this.positionPopup("insertVideo"),this.$video_wrapper.find("textarea").val("")},b.prototype.execDefault=function(a,b){document.execCommand(a,!1,b),"insertOrderedList"==a?this.$bttn_wrapper.find('[data-cmd="insertUnorderedList"]').removeClass("active"):"insertUnorderedList"==a&&this.$bttn_wrapper.find('[data-cmd="insertOrderedList"]').removeClass("active"),this.callback(a)},b.prototype.refreshButtons=function(){return!this.selectionInEditor()||this.isHTML?!1:(this.refreshUndoRedo(),void this.$bttn_wrapper.find("[data-cmd]").each(a.proxy(function(b,c){switch(a(c).data("cmd")){case"fontSize":this.refreshFontSize(c);break;case"backColor":this.refreshBackColor(c);break;case"foreColor":this.refreshForeColor(c);break;case"formatBlock":this.refreshFormatBlock(c);break;case"createLink":case"insertImage":break;case"justifyLeft":case"justifyRight":case"justifyCenter":case"justifyFull":this.refreshAlign(c);break;case"html":this.isHTML?a(c).addClass("active"):a(c).removeClass("active");break;case"undo":case"redo":case"save":break;default:this.refreshDefault(c)}},this)))},b.prototype.refreshFormatBlock=function(b){this.disabledList.indexOf("formatBlock")>=0&&a(b).parents(".fr-dropdown").attr("data-disabled",!0)},b.prototype.refreshUndoRedo=function(){if(this.isEnabled("undo")||this.isEnabled("redo")){if(void 0===this.$editor)return;this.$bttn_wrapper.find('[data-cmd="undo"], [data-cmd="redo"]').prop("disabled",!1),(0===this.undoStack.length||this.undoIndex<=1||this.isHTML)&&this.$bttn_wrapper.find('[data-cmd="undo"]').prop("disabled",!0),(this.undoIndex==this.undoStack.length||this.isHTML)&&this.$bttn_wrapper.find('[data-cmd="redo"]').prop("disabled",!0)}},b.prototype.refreshDefault=function(b){a(b).removeClass("active");try{document.queryCommandState(a(b).data("cmd"))===!0&&a(b).addClass("active")}catch(c){}},b.prototype.refreshAlign=function(b){var c=a(b).data("cmd"),d=this.getSelectionElements();"justifyLeft"==c?c="left":"justifyRight"==c?c="right":"justifyCenter"==c?c="center":"justifyFull"==c&&(c="justify"),c==a(d[0]).css("text-align")&&(a(b).parents("ul").find(".fr-bttn").removeClass("active"),a(b).addClass("active"),a(b).parents(".fr-dropdown").find(".fr-trigger").html(a(b).html()))},b.prototype.refreshForeColor=function(b){a(b).removeClass("active"),document.queryCommandValue("foreColor")==b.style.backgroundColor&&a(b).addClass("active")},b.prototype.refreshBackColor=function(b){a(b).removeClass("active"),document.queryCommandValue("backColor")==b.style.backgroundColor&&a(b).addClass("active")},b.prototype.refreshFontSize=function(b){a(b).removeClass("active"),parseInt(document.queryCommandValue("fontSize"),10)==parseInt(a(b).data("val"),10)&&a(b).addClass("active") },b.prototype.option=function(b,c){if(void 0===b)return this.options;if(b instanceof Object)this.options=a.extend({},this.options,b),this.initOptions(),this.setCustomText(),this.setLanguage();else{if(void 0===c)return this.options[b];switch(this.options[b]=c,b){case"borderColor":this.setBorderColor();break;case"direction":this.setDirection();break;case"height":case"width":this.setDimensions();break;case"spellcheck":this.setSpellcheck();break;case"placeholder":this.setPlaceholder();break;case"customText":this.setCustomText();break;case"inverseSkin":this.setInverseSkin();break;case"language":this.setLanguage()}}};var c=a.fn.editable;a.fn.editable=function(c){for(var d=[],e=0;ee*e+f*f||v(a,b,c,e,f,d)}function t(){return this._handled=d,!1}function u(a){try{a._handled()}catch(b){return!1}}function v(a,b,c,d,e,f){{var g,h;b.target}g=a.targetTouches,h=a.timeStamp-b.timeStamp,b.type="movestart",b.distX=d,b.distY=e,b.deltaX=d,b.deltaY=e,b.pageX=c.pageX,b.pageY=c.pageY,b.velocityX=d/h,b.velocityY=e/h,b.targetTouches=g,b.finger=g?g.length:1,b._handled=t,b._preventTouchmoveDefault=function(){a.preventDefault()},L(b.target,b),f(b.identifier)}function w(a){var b=a.data.timer;a.data.touch=a,a.data.timeStamp=a.timeStamp,b.kick()}function x(a){var b=a.data.event,c=a.data.timer;y(),D(b,c,function(){setTimeout(function(){K(b.target,"click",e)},0)})}function y(){K(document,O.move,w),K(document,O.end,x)}function z(a){var b=a.data.event,c=a.data.timer,d=j(a,b);d&&(a.preventDefault(),b.targetTouches=a.targetTouches,a.data.touch=d,a.data.timeStamp=a.timeStamp,c.kick())}function A(a){var b=a.data.event,c=a.data.timer,d=i(a.changedTouches,b.identifier);d&&(B(b),D(b,c))}function B(a){K(document,"."+a.identifier,z),K(document,"."+a.identifier,A)}function C(a,b,c){var d=c-a.timeStamp;a.type="move",a.distX=b.pageX-a.startX,a.distY=b.pageY-a.startY,a.deltaX=b.pageX-a.pageX,a.deltaY=b.pageY-a.pageY,a.velocityX=.3*a.velocityX+.7*a.deltaX/d,a.velocityY=.3*a.velocityY+.7*a.deltaY/d,a.pageX=b.pageX,a.pageY=b.pageY}function D(a,b,c){b.end(function(){return a.type="moveend",L(a.target,a),c&&c()})}function E(){return J(this,"movestart.move",u),!0}function F(){return K(this,"dragstart drag",f),K(this,"mousedown touchstart",g),K(this,"movestart",u),!0}function G(a){"move"!==a.namespace&&"moveend"!==a.namespace&&(J(this,"dragstart."+a.guid+" drag."+a.guid,f,b,a.selector),J(this,"mousedown."+a.guid,g,b,a.selector))}function H(a){"move"!==a.namespace&&"moveend"!==a.namespace&&(K(this,"dragstart."+a.guid+" drag."+a.guid),K(this,"mousedown."+a.guid))}var I=6,J=a.event.add,K=a.event.remove,L=function(b,c,d){a.event.trigger(c,d,b)},M=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){return window.setTimeout(function(){a()},25)}}(),N={textarea:!0,input:!0,select:!0,button:!0},O={move:"mousemove",cancel:"mouseup dragstart",end:"mouseup"},P={move:"touchmove",cancel:"touchend",end:"touchend"};a.event.special.movestart={setup:E,teardown:F,add:G,remove:H,_default:function(a){function d(){C(f,g.touch,g.timeStamp),L(a.target,f)}var f,g;a._handled()&&(f={target:a.target,startX:a.startX,startY:a.startY,pageX:a.pageX,pageY:a.pageY,distX:a.distX,distY:a.distY,deltaX:a.deltaX,deltaY:a.deltaY,velocityX:a.velocityX,velocityY:a.velocityY,timeStamp:a.timeStamp,identifier:a.identifier,targetTouches:a.targetTouches,finger:a.finger},g={event:f,timer:new c(d),touch:b,timeStamp:b},a.identifier===b?(J(a.target,"click",e),J(document,O.move,w,g),J(document,O.end,x,g)):(a._preventTouchmoveDefault(),J(document,P.move+"."+a.identifier,z,g),J(document,P.end+"."+a.identifier,A,g)))}},a.event.special.move={setup:function(){J(this,"movestart.move",a.noop)},teardown:function(){K(this,"movestart.move",a.noop)}},a.event.special.moveend={setup:function(){J(this,"movestart.moveend",a.noop)},teardown:function(){K(this,"movestart.moveend",a.noop)}},J(document,"mousedown.move",k),J(document,"touchstart.move",o),"function"==typeof Array.prototype.indexOf&&!function(a){for(var b=["changedTouches","targetTouches"],c=b.length;c--;)-1===a.event.props.indexOf(b[c])&&a.event.props.push(b[c])}(a)}),+function(a){function b(a,b,c,d){if(a.tag.format&&c.length>0){c.push("\n");for(var e=0;d>e;e++)c.push(" ")}}function c(d,e){var f=[],g=0==d.attributes.length,h=0;if(d.tag.isComment)e.allowComments&&(f.push("
').append("");var c=a('
").append(a('OK').click(a.proxy(function(){this.restoreSelection(),a(this.getSelectionElements()[0]).after(this.options.paragraphy?'
'+b.val()+"
").append(c).append(' Open in new tab').append(d).append(e)).end().hide()},b.prototype.buildDragUpload=function(b){var c=this;b.on({dragover:function(){return a(this).addClass("f-hover"),!1},dragend:function(){return a(this).removeClass("f-hover"),!1},drop:function(b){a(this).removeClass("f-hover"),b.preventDefault(),c.uploadFile(b.originalEvent.dataTransfer.files)}})},b.prototype.hideImageLoader=function(){this.$progress_bar.hide(),this.$progress_bar.find("span").css("width","0%").text(""),this.$image_list.show()},b.prototype.writeImage=function(b){var c=new Image;if(c.onerror=a.proxy(function(){this.hideImageLoader(),this.throwImageError(1)},this),this.imageMode)return c.onload=a.proxy(function(){this.$element.find(".f-img-editor > img").attr("src",b),this.hide(),this.hideImageLoader(),this.$image_editor.show(),this.saveUndoStep(),this.callback("replaceImage",[b])},this),c.src=b,!1;var d=this.getSelectionElements()[0];c.onload=a.proxy(function(){a(d).prepend(''),a(d).find("img:first").get(0).oncontrolselect=function(){return!1},this.hide(),this.hideImageLoader(),this.saveUndoStep(),this.callback("insertImage",[b])},this),c.src=b},b.prototype.throwImageError=function(b){var c="Unknown image upload error.";1==b?c="Bad link.":2==b?c="No link in upload response.":3==b?c="Error during file upload.":4==b&&(c="Parsing response failed."),this.options.imageErrorCallback&&a.isFunction(this.options.imageErrorCallback)&&this.options.imageErrorCallback({errorCode:b,errorStatus:c})},b.prototype.uploadFile=function(b){if(void 0!==b&&b.length>0){var c;if(this.drag_support.formdata&&(c=this.drag_support.formdata?new FormData:null),c&&c.append(this.options.imageUploadParam,b[0]),c){var d;this.options.crossDomain?d=this.createCORSRequest("POST",this.options.imageUploadURL):(d=new XMLHttpRequest,d.open("POST",this.options.imageUploadURL)),d.onload=a.proxy(function(){this.$progress_bar.find("span").css("width","100%").text("Please wait!");try{200==d.status?this.parseImageResponse(d.responseText):this.throwImageError(3)}catch(a){this.throwImageError(4)}this.hideImageLoader()},this),d.onerror=a.proxy(function(){this.throwImageError(3),this.hideImageLoader()},this),d.upload.onprogress=a.proxy(function(a){if(a.lengthComputable){var b=a.loaded/a.total*100|0;this.$progress_bar.find("span").css("width",b+"%")}},this);for(var e in this.options.imageParams)c.append(e,this.options.imageParams[e]);d.send(c),this.$image_list.hide(),this.$progress_bar.show()}}},b.prototype.parseImageResponse=function(b){try{var c=a.parseJSON(b);"http://uploads.im/api"==this.options.imageUploadURL?this.writeImage(c.data.img_url):c.link?this.writeImage(c.link):this.throwImageError(2)}catch(d){this.throwImageError(4)}},b.prototype.createCORSRequest=function(a,b){var c=new XMLHttpRequest;return"withCredentials"in c?c.open(a,b,!0):"undefined"!=typeof XDomainRequest?(c=new XDomainRequest,c.open(a,b)):c=null,c},b.prototype.writeLink=function(b,c){if(this.imageMode)return""!==b?("A"!=this.$element.find(".f-img-editor").parent().get(0).tagName?this.$element.find(".f-img-editor").wrap(c===!0?'':''):c===!0?this.$element.find(".f-img-editor").parent().attr("target","_blank"):(this.$element.find(".f-img-editor").parent().removeAttr("target"),this.$element.find(".f-img-editor").parent().attr("href",b)),this.callback("insertImageLink",[b])):("A"==this.$element.find(".f-img-editor").parent().get(0).tagName&&a(this.$element.find(".f-img-editor").get(0)).unwrap(),this.callback("removeImageLink")),this.saveUndoStep(),this.showImageEditor(),this.$element.find(".f-img-editor").find("img").click(),this.link=!1,!1;if(this.restoreSelection(),document.execCommand("unlink",!1,b),this.saveSelectionByMarkers(),this.$element.find("span.f-link").each(function(b,c){a(c).replaceWith(a(c).html())}),this.restoreSelectionByMarkers(),""!==b){document.execCommand("createLink",!1,b);for(var d=this.getSelectionLinks(),e=0;e-1&&e.push(c[h])}d.detach()}}else if(document.selection&&"Control"!=document.selection.type)if(a=document.selection.createRange(),b=a.parentElement(),"a"==b.nodeName.toLowerCase())e.push(b);else{c=b.getElementsByTagName("a"),d=document.body.createTextRange();for(var i=0;i-1&&d.compareEndPoints("EndToStart",a)<1&&e.push(c[i])}return e},b.prototype.isEnabled=function(b){return a.inArray(b,this.options.buttons)>=0},b.prototype.show=function(b){if(void 0!==b){if(this.options.inlineMode)if(null!==b&&"touchend"!==b.type){var c=b.pageX,d=b.pageY;20>c&&(c=20),0>d&&(d=0),c+this.$editor.width()>a(window).width()-50?(this.$editor.addClass("right-side"),c=a(window).width()-(c+30),this.$editor.css("top",d+20),this.$editor.css("right",c),this.$editor.css("left","auto")):(this.$editor.removeClass("right-side"),this.$editor.css("top",d+20),this.$editor.css("left",c-20),this.$editor.css("right","auto")),a(".froala-editor:not(.f-basic)").hide(),this.$editor.show()}else a(".froala-editor:not(.f-basic)").hide(),this.$editor.show(),this.repositionEditor();this.hideLinkWrapper(),this.hideVideoWrapper(),this.hideImageWrapper(),this.$bttn_wrapper.show(),this.$bttn_wrapper.find(".fr-dropdown").removeClass("active"),this.refreshButtons(),this.imageMode=!1}},b.prototype.showByCoordinates=function(b,c){b-=20,c+=15,b+this.$popup_editor.width()>a(window).width()-50?(this.$popup_editor.addClass("right-side"),b=a(window).width()-(b+40),this.$popup_editor.css("top",c),this.$popup_editor.css("right",b),this.$popup_editor.css("left","auto")):(this.$popup_editor.removeClass("right-side"),this.$popup_editor.css("top",c),this.$popup_editor.css("left",b),this.$popup_editor.css("right","auto")),this.$popup_editor.show()},b.prototype.showLinkWrapper=function(){this.$link_wrapper&&this.$link_wrapper.show()},b.prototype.hideLinkWrapper=function(){this.$link_wrapper&&this.$link_wrapper.hide()},b.prototype.showImageWrapper=function(){this.$image_wrapper&&this.$image_wrapper.show()},b.prototype.showVideoWrapper=function(){this.$video_wrapper&&this.$video_wrapper.show()},b.prototype.hideImageWrapper=function(a){this.$image_wrapper&&(this.$element.attr("data-resize")||a||this.closeImageMode(),this.$image_wrapper.hide())},b.prototype.hideVideoWrapper=function(){this.$video_wrapper&&this.$video_wrapper.hide()},b.prototype.showInsertLink=function(){this.options.inlineMode&&this.$bttn_wrapper.hide(),this.showLinkWrapper(),this.hideImageWrapper(!0),this.hideVideoWrapper(),this.$image_editor.hide(),this.link=!0},b.prototype.showInsertImage=function(){this.options.inlineMode&&this.$bttn_wrapper.hide(),this.hideLinkWrapper(),this.hideVideoWrapper(),this.showImageWrapper(),this.$image_editor.hide()},b.prototype.showInsertVideo=function(){this.options.inlineMode&&this.$bttn_wrapper.hide(),this.hideLinkWrapper(),this.hideImageWrapper(),this.showVideoWrapper(),this.$image_editor.hide()},b.prototype.showImageEditor=function(){this.options.inlineMode&&this.$bttn_wrapper.hide(),this.hideLinkWrapper(),this.hideImageWrapper(!0),this.hideVideoWrapper(),this.$image_editor.show(),this.options.imageMove||this.$element.attr("contenteditable",!1)},b.prototype.hide=function(){this.$popup_editor.hide(),this.hideLinkWrapper(),this.hideImageWrapper(),this.hideVideoWrapper(),this.$image_editor.hide(),this.link=!1},b.prototype.positionPopup=function(b){a(this.$editor.find('button.fr-bttn[data-cmd="'+b+'"]')).length&&(this.$popup_editor.css("top",this.$editor.find('button.fr-bttn[data-cmd="'+b+'"]').offset().top+30),this.$popup_editor.css("left",this.$editor.find('button.fr-bttn[data-cmd="'+b+'"]').offset().left),this.$popup_editor.show())},b.prototype.bindButtonEvents=function(){this.bindDropdownEvents(),this.bindCommandEvents()},b.prototype.bindDropdownEvents=function(){var b=this;this.$bttn_wrapper.find(".fr-dropdown").on("click touchend",function(c){return c.stopPropagation(),c.preventDefault(),0==b.options.inlineMode&&b.hide(),a(this).attr("data-disabled")?!1:(a(".fr-dropdown").not(this).removeClass("active"),void a(this).toggleClass("active"))}),a(window).on("click touchend",a.proxy(function(){this.$editor.find(".fr-dropdown").removeClass("active")},this)),this.$element.on("click touchend","img, a",a.proxy(function(){this.$editor.find(".fr-dropdown").removeClass("active")},this));var c=this.$bttn_wrapper.find(".fr-selector button.fr-bttn");c.bind("select",function(){a(this).parents(".fr-selector").find(" > button > i").attr("class",a(this).find("i").attr("class"))}).on("click touch",function(){a(this).parents("ul").find("button").removeClass("active"),a(this).parents(".fr-selector").removeClass("active").trigger("mouseout"),a(this).trigger("select")})},b.prototype.bindCommandEvents=function(){this.$bttn_wrapper.find("[data-cmd]").on("click touchend",a.proxy(function(b){b.stopPropagation(),b.preventDefault();var c=b.currentTarget,d=a(c).data("cmd"),e=a(c).data("val");a(c).parents(".fr-dropdown").removeClass("active"),this.exec(d,e),this.$bttn_wrapper.find(".fr-dropdown").removeClass("active")},this))},b.prototype.exec=function(a,b){if(!this.selectionInEditor()&&"html"!==a&&"undo"!==a&&"redo"!==a&&"selectAll"!==a&&"save"!=a&&"insertImage"!==a&&"insertVideo"!==a)return!1;if(this.selectionInEditor()&&""===this.text()&&"fontSize"!==a&&"formatBlock"!==a&&"indent"!==a&&"outdent"!==a&&"justifyLeft"!==a&&"justifyRight"!==a&&"justifyFull"!==a&&"justifyCenter"!==a&&"html"!==a&&"undo"!==a&&"redo"!==a&&"selectAll"!==a&&"save"!==a&&"insertImage"!==a&&"insertVideo"!==a&&"insertOrderedList"!==a&&"insertUnorderedList"!==a)return!1;switch(a){case"fontSize":this.fontSize(b);break;case"backColor":this.backColor(b);break;case"foreColor":this.foreColor(b);break;case"formatBlock":this.formatBlock(b);break;case"createLink":this.insertLink();break;case"insertImage":this.insertImage();break;case"indent":this.indent();break;case"outdent":this.outdent(!0);break;case"justifyLeft":case"justifyRight":case"justifyCenter":case"justifyFull":this.align(a);break;case"insertOrderedList":case"insertUnorderedList":this.formatList(a);break;case"insertVideo":this.insertVideo();break;case"indent":case"outdent":this.execDefault(a,b),this.repositionEditor();break;case"undo":this.undo();break;case"redo":this.redo();break;case"html":this.html();break;case"save":this.save();break;case"selectAll":this.$element.focus(),this.execDefault(a,b);break;default:this.execDefault(a,b)}"undo"!=a&&"redo"!=a&&"selectAll"!=a&&"createLink"!=a&&"insertImage"!=a&&"html"!=a&&"insertVideo"!=a&&this.saveUndoStep(),"createLink"!=a&&"insertImage"!=a&&this.refreshButtons()},b.prototype.undo=function(){if(this.undoIndex>1){var a=this.getHTML();this.$element.html(this.undoStack[--this.undoIndex-1]),this.hide(),this.callback("undo",[this.$element.html(),a])}this.refreshUndoRedo()},b.prototype.redo=function(){if(this.undoIndex").attr("data-font",!0).css("font-size",b).html(a(e).html());0===a(e).parents("font").length&&c.push(f),a(e).replaceWith(f)});var d=function(b,c){a(c).css("font-size","")};for(var e in c){var f=c[e];a(f).find("*").each(d)}this.$element.find('span[data-font="true"] > span[data-font="true"]').each(function(b,c){a(c).attr("style")&&(a(c).before(''),a(c).after(''))});var g=this.$element.html();g=g.replace(new RegExp('',"g"),""),g=g.replace(new RegExp('data-open="true">',"g"),">"),this.$element.html(g);for(var h=!0,i=a.proxy(function(){this.$element.find('span[data-font="true"] + span[data-font="true"]').each(function(b,c){a(c).css("font-size")==a(c).prev().css("font-size")&&(a(c).prepend(a(c).prev().html()),a(c).prev().remove(),h=!0)}),this.$element.find('span[data-font="true"] + span#marker-true + span[data-font="true"], span[data-font="true"] + span#marker-true + span[data-font="true"]').each(function(b,c){a(c).css("font-size")==a(c).prev().prev().css("font-size")&&(a(c).prepend(a(c).prev().clone()),a(c).prepend(a(c).prev().prev().html()),a(c).prev().prev().remove(),a(c).prev().remove(),h=!0)})},this);h;)h=!1,i();this.$element.find('span[style=""]').each(function(b,c){a(c).replaceWith(a(c).html())}),this.$element.find("span[data-font]").each(function(b,c){a(c).css("font-size")==a(c).parent().css("font-size")&&a(c).replaceWith(a(c).html())}),this.restoreSelectionByMarkers(),this.repositionEditor(),this.callback("fontSize")},b.prototype.backColor=function(c){var d="backColor";this.browser.msie||(d="hiliteColor");var e=a(this.getSelectionElement()).css("background-color");document.execCommand(d,!1,c);var f=this.$editor.find('button.fr-color-bttn[data-cmd="backColor"][data-val="'+c+'"]');f.addClass("active"),f.siblings().removeClass("active"),this.callback("backColor",[b.hexToRGBString(c),e])},b.prototype.foreColor=function(c){var d=a(this.getSelectionElement()).css("color");document.execCommand("foreColor",!1,c),this.saveSelectionByMarkers(),this.$element.find("font[color]").each(function(b,d){a(d).replaceWith(a("").css("color",c).html(a(d).html()))}),this.restoreSelectionByMarkers();var e=this.$editor.find('button.fr-color-bttn[data-cmd="foreColor"][data-val="'+c+'"]');e.addClass("active"),e.siblings().removeClass("active"),this.callback("foreColor",[b.hexToRGBString(c),d])},b.prototype.formatBlock=function(b){if(this.disabledList.indexOf("formatBlock")>=0)return!1;this.saveSelectionByMarkers(),this.wrapText(),this.restoreSelectionByMarkers();var c,d=this.getSelectionElements();for(var e in d){var f=a(d[e]);if(c="n"==b?a("").html(f.html()):a("<"+b+">").html(f.html()),f.get(0)!=this.$element.get(0)&&"LI"!=f.get(0).tagName){var g=f.prop("attributes");if(c.attr)for(var h in g)c.attr(g[h].name,g[h].value);f.replaceWith(c)}else f.html(c)}this.clearSelection(),this.hide(),this.callback("formatBlock")},b.prototype.formatList=function(b){this.saveSelectionByMarkers();var c,d=this.getSelectionElements(),e=!0,f=!1;for(var g in d)c=a(d[g]),c.parents("li").length>0?(c.parents("ol").length>0?(c.parents("li").before(''),c.parents("li").after('')):c.parents("ul").length>0&&(c.parents("li").before(''),c.parents("li").after('')),c.parents("li").replaceWith(c.parents("li").contents()),f=!0):e=!1;if(f){var h=this.$element.html();h=h.replace(new RegExp('',"g"),""),h=h.replace(new RegExp('',"g"),""),h=h.replace(new RegExp('',"g"),""),h=h.replace(new RegExp('',"g"),""),this.$element.html(h),this.$element.find("ul:empty, ol:empty").remove()}if(this.clearSelection(),this.wrapText(),this.restoreSelectionByMarkers(),e===!1){d=this.getSelectionElements(),this.saveSelectionByMarkers();var i=a("");"insertUnorderedList"==b&&(i=a(""));for(var j in d)c=a(d[j]),c.get(0)!=this.$element.get(0)&&(i.append(a("").append(c.clone())),j!=d.length-1?c.remove():c.replaceWith(i));this.restoreSelectionByMarkers()}this.repositionEditor(),this.callback(b)},b.prototype.align=function(b){var c=this.getSelectionElements();this.saveSelection(),"justifyLeft"==b?b="left":"justifyRight"==b?b="right":"justifyCenter"==b?b="center":"justifyFull"==b&&(b="justify");for(var d in c)a(c[d]).css("text-align",b);this.restoreSelection(),this.repositionEditor(),this.callback("align")},b.prototype.indent=function(b){var c=20;b&&(c=-20),this.saveSelectionByMarkers(),this.wrapText(),this.restoreSelectionByMarkers();var d=this.getSelectionElements();this.saveSelectionByMarkers();for(var e in d){var f=a(d[e]);if(f.get(0)!=this.$element.get(0)){var g=parseInt(f.css("margin-left").replace(/px/,""),10),h=Math.max(0,g+c);f.css("marginLeft",h)}else{var i=a("").html(f.html());f.html(i),i.css("marginLeft",Math.max(0,c))}}this.restoreSelectionByMarkers(),this.repositionEditor(),b||this.callback("indent")},b.prototype.outdent=function(){this.indent(!0),this.callback("outdent")},b.prototype.insertLink=function(){this.showInsertLink(),this.options.inlineMode||this.positionPopup("createLink"),this.saveSelection();var b=this.getSelectionLink(),c=this.getSelectionLinks();c.length>0&&this.$link_wrapper.find('input[type="checkbox"]').prop("checked","_blank"==a(c[0]).attr("target")),this.$link_wrapper.find('input[type="text"]').val(b||"http://")},b.prototype.insertImage=function(){this.showInsertImage(),this.saveSelection(),this.options.inlineMode||this.positionPopup("insertImage"),this.$image_wrapper.find('input[type="text"]').val("")},b.prototype.insertVideo=function(){this.showInsertVideo(),this.saveSelection(),this.options.inlineMode||this.positionPopup("insertVideo"),this.$video_wrapper.find("textarea").val("")},b.prototype.execDefault=function(a,b){document.execCommand(a,!1,b),"insertOrderedList"==a?this.$bttn_wrapper.find('[data-cmd="insertUnorderedList"]').removeClass("active"):"insertUnorderedList"==a&&this.$bttn_wrapper.find('[data-cmd="insertOrderedList"]').removeClass("active"),this.callback(a)},b.prototype.refreshButtons=function(){return!this.selectionInEditor()||this.isHTML?!1:(this.refreshUndoRedo(),void this.$bttn_wrapper.find("[data-cmd]").each(a.proxy(function(b,c){switch(a(c).data("cmd")){case"fontSize":this.refreshFontSize(c);break;case"backColor":this.refreshBackColor(c);break;case"foreColor":this.refreshForeColor(c);break;case"formatBlock":this.refreshFormatBlock(c);break;case"createLink":case"insertImage":break;case"justifyLeft":case"justifyRight":case"justifyCenter":case"justifyFull":this.refreshAlign(c);break;case"html":this.isHTML?a(c).addClass("active"):a(c).removeClass("active");break;case"undo":case"redo":case"save":break;default:this.refreshDefault(c)}},this)))},b.prototype.refreshFormatBlock=function(b){this.disabledList.indexOf("formatBlock")>=0&&a(b).parents(".fr-dropdown").attr("data-disabled",!0)},b.prototype.refreshUndoRedo=function(){if(this.isEnabled("undo")||this.isEnabled("redo")){if(void 0===this.$editor)return;this.$bttn_wrapper.find('[data-cmd="undo"], [data-cmd="redo"]').prop("disabled",!1),(0===this.undoStack.length||this.undoIndex<=1||this.isHTML)&&this.$bttn_wrapper.find('[data-cmd="undo"]').prop("disabled",!0),(this.undoIndex==this.undoStack.length||this.isHTML)&&this.$bttn_wrapper.find('[data-cmd="redo"]').prop("disabled",!0)}},b.prototype.refreshDefault=function(b){a(b).removeClass("active");try{document.queryCommandState(a(b).data("cmd"))===!0&&a(b).addClass("active")}catch(c){}},b.prototype.refreshAlign=function(b){var c=a(b).data("cmd"),d=this.getSelectionElements();"justifyLeft"==c?c="left":"justifyRight"==c?c="right":"justifyCenter"==c?c="center":"justifyFull"==c&&(c="justify"),c==a(d[0]).css("text-align")&&(a(b).parents("ul").find(".fr-bttn").removeClass("active"),a(b).addClass("active"),a(b).parents(".fr-dropdown").find(".fr-trigger").html(a(b).html()))},b.prototype.refreshForeColor=function(b){a(b).removeClass("active"),document.queryCommandValue("foreColor")==b.style.backgroundColor&&a(b).addClass("active")},b.prototype.refreshBackColor=function(b){a(b).removeClass("active"),document.queryCommandValue("backColor")==b.style.backgroundColor&&a(b).addClass("active")},b.prototype.refreshFontSize=function(b){a(b).removeClass("active"),parseInt(document.queryCommandValue("fontSize"),10)==parseInt(a(b).data("val"),10)&&a(b).addClass("active") +if("undefined"==typeof jQuery)throw new Error("Froala requires jQuery");!function(a){"use strict";var b=function(c,d){this.options=a.extend({},b.DEFAULTS,a(c).data(),"object"==typeof d&&d),this.browser=b.browser(),this.disabledList=[],this._id=++b.count,this.init(c)};b.count=0,b.VALID_NODES=["P","PRE","BLOCKQUOTE","H1","H2","H3","H4","H5","H6","DIV"],b.COLORS=["#000000","#444444","#666666","#999999","#CCCCCC","#EEEEEE","#F3F3F3","#FFFFFF","#FF0000","#FF9900","#FFFF00","#00FF00","#00FFFF","#0000FF","#9900FF","#FF00FF","#F4CCCC","#FCE5CD","#FFF2CC","#D9EAD3","#D0E0E3","#CFE2F3","#D9D2E9","#EAD1DC","#EA9999","#F9CB9C","#FFE599","#B6D7A8","#A2C4C9","#9FC5E8","#B4A7D6","#D5A6BD","#E06666","#F6B26B","#FFD966","#93C47D","#76A5AF","#6FA8DC","#8E7CC3","#C27BA0","#CC0000","#E69138","#F1C232","#6AA84F","#45818E","#3D85C6","#674EA7","#A64D79","#990000","#B45F06","#BF9000","#38771D","#134F5C","#0B5394","#351C75","#741B47","#660000","#783F04","#7F6000","#274E13","#0C343D","#073763","#201211","#4C1130"],b.commands={bold:{title:"Bold",icon:"fa fa-bold",shortcut:"(Ctrl + B)"},italic:{title:"Italic",icon:"fa fa-italic",shortcut:"(Ctrl + I)"},underline:{cmd:"underline",title:"Underline",icon:"fa fa-underline",shortcut:"(Ctrl + U)"},strikeThrough:{title:"Strikethrough",icon:"fa fa-strikethrough"},fontSize:{title:"Font Size",icon:"fa fa-text-height",seed:[{min:11,max:52}]},color:{icon:"fa fa-font",title:"Color",seed:[{cmd:"backColor",value:b.COLORS,title:"Background Color"},{cmd:"foreColor",value:b.COLORS,title:"Text Color"}]},formatBlock:{title:"Format Block",icon_alt:"¶",seed:[{value:"n",title:"Normal"},{value:"p",title:"Paragraph"},{value:"pre",title:"Code"},{value:"blockquote",title:"Quote"},{value:"h1",title:"Heading 1"},{value:"h2",title:"Heading 2"},{value:"h3",title:"Heading 3"},{value:"h4",title:"Heading 4"},{value:"h5",title:"Heading 5"},{value:"h6",title:"Heading 6"}]},align:{title:"Alignment",icon:"fa fa-align-center",seed:[{cmd:"justifyLeft",title:"Align Left",icon:"fa fa-align-left"},{cmd:"justifyCenter",title:"Align Center",icon:"fa fa-align-center"},{cmd:"justifyRight",title:"Align Right",icon:"fa fa-align-right"},{cmd:"justifyFull",title:"Justify",icon:"fa fa-align-justify"}]},insertOrderedList:{title:"Numbered List",icon:"fa fa-list-ol"},insertUnorderedList:{title:"Bulleted List",icon:"fa fa-list-ul"},outdent:{title:"Indent Less",icon:"fa fa-dedent",activeless:!0,shortcut:"(Ctrl + <)"},indent:{title:"Indent More",icon:"fa fa-indent",activeless:!0,shortcut:"(Ctrl + >)"},selectAll:{title:"Select All",icon:"fa fa-file-text",shortcut:"(Ctrl + A)"},createLink:{title:"Insert Link",icon:"fa fa-link",shortcut:"(Ctrl + K)"},insertImage:{title:"Insert Image",icon:"fa fa-picture-o",activeless:!0,shortcut:"(Ctrl + P)"},undo:{title:"Undo",icon:"fa fa-undo",activeless:!0,shortcut:"(Ctrl+Z)"},redo:{title:"Redo",icon:"fa fa-repeat",activeless:!0,shortcut:"(Shift+Ctrl+Z)"},html:{title:"Show HTML",icon:"fa fa-code"},save:{title:"Save",icon:"fa fa-floppy-o"},insertVideo:{title:"Insert Video",icon:"fa fa-video-camera"}},b.LANGS=[],b.DEFAULTS={autosave:!1,autosaveInterval:1e3,saveURL:null,saveParams:{},blockTags:["n","p","blockquote","pre","h1","h2","h3","h4","h5","h6"],borderColor:"#252528",buttons:["bold","italic","underline","strikeThrough","fontSize","color","sep","formatBlock","align","insertOrderedList","insertUnorderedList","outdent","indent","sep","createLink","insertImage","insertVideo","undo","redo","html"],crossDomain:!1,direction:"ltr",editorClass:"",enableScript:!1,height:"auto",imageMargin:20,imageParams:{},imageErrorCallback:!1,imageMove:!0,imageUploadParam:"file",imageUploadURL:"http://uploads.im/api",inverseSkin:!1,inlineMode:!0,paragraphy:!0,placeholder:"Type something",shortcuts:!0,customText:!1,spellcheck:!1,toolbarFixed:!0,typingTimer:250,width:"auto",language:"en_us",customButtons:[]},b.hexToRGB=function(a){var b=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;a=a.replace(b,function(a,b,c,d){return b+b+c+c+d+d});var c=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a);return c?{r:parseInt(c[1],16),g:parseInt(c[2],16),b:parseInt(c[3],16)}:null},b.hexToRGBString=function(a){var b=this.hexToRGB(a);return"rgb("+b.r+", "+b.g+", "+b.b+")"},b.getIEversion=function(){var a,b,c=-1;return"Microsoft Internet Explorer"==navigator.appName?(a=navigator.userAgent,b=new RegExp("MSIE ([0-9]{1,}[\\.0-9]{0,})"),null!==b.exec(a)&&(c=parseFloat(RegExp.$1))):"Netscape"==navigator.appName&&(a=navigator.userAgent,b=new RegExp("Trident/.*rv:([0-9]{1,}[\\.0-9]{0,})"),null!==b.exec(a)&&(c=parseFloat(RegExp.$1))),c},b.browser=function(){var a={};if(b.getIEversion()>0)a.msie=!0;else{var c=navigator.userAgent.toLowerCase(),d=/(chrome)[ \/]([\w.]+)/.exec(c)||/(webkit)[ \/]([\w.]+)/.exec(c)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(c)||/(msie) ([\w.]+)/.exec(c)||c.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(c)||[],e={browser:d[1]||"",version:d[2]||"0"};d[1]&&(a[e.browser]=!0),parseInt(e.version,10)<9&&a.msie&&(a.oldMsie=!0),a.chrome?a.webkit=!0:a.webkit&&(a.safari=!0)}return a},b.prototype.text=function(){var a="";return window.getSelection?a=window.getSelection():document.getSelection?a=document.getSelection():document.selection&&(a=document.selection.createRange().text),a.toString()},b.prototype.selectionInEditor=function(){var b=this.getSelectionParent(),c=!1;return b==this.$element.get(0)?!0:(a(b).parents().each(a.proxy(function(a,b){b==this.$element.get(0)&&(c=!0)},this)),c)},b.prototype.getSelection=function(){var a="";return a=window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange()},b.prototype.getRange=function(){if(window.getSelection){var a=window.getSelection();if(a.getRangeAt&&a.rangeCount)return a.getRangeAt(0)}return document.createRange()},b.prototype.clearSelection=function(){if(window.getSelection){var a=window.getSelection();a.removeAllRanges()}else document.selection.createRange&&(document.selection.createRange(),document.selection.empty())},b.prototype.getSelectionElement=function(){var a=this.getSelection();if(a.rangeCount){var b=a.getRangeAt(0).startContainer;return 1!=b.nodeType?b.parentNode:b}return this.$element.get(0)},b.prototype.getSelectionParent=function(){var a,b=null;return window.getSelection?(a=window.getSelection(),a.rangeCount&&(b=a.getRangeAt(0).commonAncestorContainer,1!=b.nodeType&&(b=b.parentNode))):(a=document.selection)&&"Control"!=a.type&&(b=a.createRange().parentElement()),b},b.prototype.nodeInRange=function(a,b){var c;if(a.intersectsNode)return a.intersectsNode(b);c=b.ownerDocument.createRange();try{c.selectNode(b)}catch(d){c.selectNodeContents(b)}return-1==a.compareBoundaryPoints(Range.END_TO_START,c)&&1==a.compareBoundaryPoints(Range.START_TO_END,c)},b.prototype.getElementFromNode=function(c){for(1!=c.nodeType&&(c=c.parentNode);null!==c&&b.VALID_NODES.indexOf(c.tagName)<0;)c=c.parentNode;return a.makeArray(a(c).parents()).indexOf(this.$element.get(0))>=0?c:null},b.prototype.nextNode=function(a){if(a.hasChildNodes())return a.firstChild;for(;a&&!a.nextSibling;)a=a.parentNode;return a?a.nextSibling:null},b.prototype.getRangeSelectedNodes=function(a){var b=a.startContainer,c=a.endContainer;if(b==c)return[b];for(var d=[];b&&b!=c;)d.push(b=this.nextNode(b));for(b=a.startContainer;b&&b!=a.commonAncestorContainer;)d.unshift(b),b=b.parentNode;return d},b.prototype.getSelectedNodes=function(){if(window.getSelection){var a=window.getSelection();if(!a.isCollapsed)return this.getRangeSelectedNodes(a.getRangeAt(0));if(this.selectionInEditor()){var b=a.getRangeAt(0).startContainer;return 3==b.nodeType?[b.parentNode]:[b]}}return[]},b.prototype.getSelectionElements=function(){var b=this.getSelectedNodes(),c=[];return a.each(b,a.proxy(function(a,b){if(null!==b){var d=this.getElementFromNode(b);c.indexOf(d)<0&&d!=this.$element.get(0)&&null!==d&&c.push(d)}},this)),0===c.length&&c.push(this.$element.get(0)),c},b.prototype.getSelectionLink=function(){var a,b;return window.getSelection?(b=window.getSelection(),a=b.anchorNode.parentNode.href):(b=document.selection)&&"Control"!=b.type&&(a=b.createRange().parentElement().href),a},b.prototype.saveSelection=function(){var a,b,c,d=this.getSelection();if(d.getRangeAt&&d.rangeCount){for(c=[],a=0,b=d.rangeCount;b>a;a+=1)c.push(d.getRangeAt(a));this.savedRanges=c}else this.savedRanges=null},b.prototype.restoreSelection=function(){var a,b,c=this.getSelection();if(this.savedRanges)for(c.removeAllRanges(),a=0,b=this.savedRanges.length;b>a;a+=1)c.addRange(this.savedRanges[a])},b.prototype.saveSelectionByMarkers=function(){var a=this.getRange();this.placeMarker(a,!0),this.placeMarker(a,!1)},b.prototype.restoreSelectionByMarkers=function(){var a=this.$element.find("#marker-true"),b=this.$element.find("#marker-false");return a.length&&b.length?(this.$element.removeAttr("contentEditable"),this.$element.focus(),this.setSelection(a[0],0,b[0],0),this.removeMarkers(),void this.$element.attr("contentEditable",!0)):!1},b.prototype.setSelection=function(a,b,c,d){try{null===c&&(c=a),null===d&&(d=b);var e=this.getSelection();if(!e)return;var f=this.getRange();f.setStart(a,b),f.setEnd(c,d),e.removeAllRanges(),e.addRange(f)}catch(g){}},b.prototype.placeMarker=function(b,c){var d=b.cloneRange();d.collapse(c),d.insertNode(a('',document)[0]),d.detach()},b.prototype.removeMarkers=function(){this.$element.find("#marker-true, #marker-false").removeAttr("id")},b.prototype.getBoundingRect=function(){var a=this.getRange().getBoundingClientRect();return a},b.prototype.repositionEditor=function(b){var c,d,e;(this.options.inlineMode||b)&&(c=this.getBoundingRect(),void 0!==c.left&&void 0!==c.top&&void 0!==c.right&&void 0!==c.bottom?(d=c.left+c.width/2+a(window).scrollLeft(),e=c.top+c.height+a(window).scrollTop(),this.isTouch()&&(d=c.left+c.width/2,e=c.top+c.height),this.showByCoordinates(d,e)):(document.execCommand("selectAll"),c=this.getRange().getBoundingClientRect(),d=c.left+a(window).scrollLeft(),e=c.top+c.height+a(window).scrollTop(),this.isTouch()&&(d=c.left,e=c.top+c.height),this.showByCoordinates(d,e-20),this.getRange().collapse(!1)))},b.prototype.destroy=function(){this.sync(),this.$editor.remove(),this.$popup_editor&&this.$popup_editor.remove(),this.$element.replaceWith(this.getHTML()),this.$box.removeClass("froala-box"),this.$box.find(".html-switch").remove(),this.$box.removeData("fa.editable"),clearTimeout(this.typingTimer),clearTimeout(this.ajaxInterval),this.$element.off("mousedown mouseup click keydown keyup keypress touchstart touchend touch drop","**"),void 0!==this.$upload_frame&&this.$upload_frame.remove(),this.$textarea&&(this.$box.remove(),this.$textarea.removeData("fa.editable"),this.$textarea.show())},b.prototype.callback=function(b,c,d){var e=b+"Callback";this.options[e]&&a.isFunction(this.options[e])&&(c?this.options[e].apply(this,c):this.options[e].call(this)),void 0==d&&(console.log("sync"),this.sync())},b.prototype.sync=function(){for(""!==this.text()&&this.saveSelectionByMarkers(),this.$element.find("b").each(function(b,c){a(c).replaceWith(""+a(c).html()+"")}),this.$element.find("i").each(function(b,c){a(c).replaceWith(""+a(c).html()+"")}),this.restoreSelectionByMarkers(),this.$textarea&&this.$textarea.val(this.getHTML());this.$element.find("span:empty").length;)this.$element.find("span:empty").remove();this.$element.find("*").each(a.proxy(function(b,c){this.emptyElement(c)&&"SPAN"==c.tagName&&a(c).remove()},this)),this.disableImageResize(),this.$element.trigger("placeholderCheck")},b.prototype.emptyElement=function(b){if("IMG"==b.tagName||a(b).find("img").length>0)return!1;for(var c=a(b).text(),d=0;d'),a(this).append(''),b.restoreSelectionByMarkers(),b.exec("createLink"),b.$link_wrapper.find('input[type="text"]').val(a(this).attr("href")),b.$link_wrapper.find('input[type="checkbox"]').prop("checked","_blank"==a(this).attr("target")),b.repositionEditor(!0),b.$popup_editor.show()})},b.prototype.imageHandle=function(){var b=this,c=a("").addClass("f-img-handle").on({movestart:function(c){b.hide(),b.$element.addClass("f-non-selectable").removeAttr("contenteditable"),b.isResizing=!0,a(this).attr("data-start-x",c.startX),a(this).attr("data-start-y",c.startY)},move:function(b){var c=a(this),d=b.pageX-parseInt(c.attr("data-start-x"),10);c.attr("data-start-x",b.pageX),c.attr("data-start-y",b.pageY);var e=c.prevAll("img");e.width(c.hasClass("f-h-ne")||c.hasClass("f-h-se")?e.width()+d:e.width()-d)},moveend:function(){if(b.isResizing=!1,a(this).removeAttr("data-start-x"),a(this).removeAttr("data-start-y"),b.$element.removeClass("f-non-selectable").attr("contenteditable",!0),b.browser.mozilla)try{document.execCommand("enableObjectResizing",!1,!1),document.execCommand("enableInlineTableEditing",!1,!1)}catch(c){}}});return c},b.prototype.disableImageResize=function(){if(this.browser.mozilla)try{document.execCommand("enableObjectResizing",!1,!1),document.execCommand("enableInlineTableEditing",!1,!1)}catch(a){}},b.prototype.initImageResizer=function(){this.disableImageResize();var b=this;this.$element.on("mousedown","img",function(){!b.options.imageMove||b.browser.msie?b.$element.attr("contenteditable",!1):a(this).parent().hasClass("f-img-editor")&&(b.closeImageMode(),b.hide())}),this.$element.find("img").each(function(a,b){b.oncontrolselect=function(){return!1}}),this.$element.on("mouseup","img",function(){b.options.imageMove||b.$element.attr("contenteditable",!0)}),this.$element.on("click touchend","img",function(c){c.preventDefault(),c.stopPropagation(),b.$element.blur(),b.$image_editor.find("button").removeClass("active");var d=a(this).css("float");b.$image_editor.find('button[data-cmd="floatImage'+d.charAt(0).toUpperCase()+d.slice(1)+'"]').addClass("active"),b.$image_editor.find('.f-image-alt input[type="text"]').val(a(this).attr("alt")||a(this).attr("title")),b.showImageEditor(),b.showByCoordinates(a(this).offset().left+a(this).width()/2,a(this).offset().top+a(this).height()),a(this).parent().hasClass("f-img-editor")&&"SPAN"==a(this).parent().get(0).tagName||(a(this).wrap(''),a(this).css("margin-left","auto"),a(this).css("margin-right","auto"),a(this).css("margin-bottom","auto"));var e=b.imageHandle();a(this).parent().append(e.clone(!0).addClass("f-h-ne")),a(this).parent().append(e.clone(!0).addClass("f-h-se")),a(this).parent().append(e.clone(!0).addClass("f-h-sw")),a(this).parent().append(e.clone(!0).addClass("f-h-nw")),b.clearSelection(),b.imageMode=!0}),this.$element.find("img").each(function(a,b){b.oncontrolselect=function(){return!1}})},b.prototype.initImagePopup=function(){var b=a("").addClass("fr-bttn").attr("data-cmd","floatImageLeft").attr("title","Float Left").html(''),c=a("").addClass("fr-bttn").attr("data-cmd","floatImageNone").attr("title","Float None").html(''),d=a("").addClass("fr-bttn").attr("data-cmd","floatImageRight").attr("title","Float Right").html(''),e=a("").addClass("fr-bttn").attr("data-cmd","linkImage").attr("title","Insert Link").html(''),f=a("").addClass("fr-bttn").attr("data-cmd","replaceImage").attr("title","Replace Image").html(''),g=a("").addClass("fr-bttn").attr("data-cmd","removeImage").attr("title","Remove Image").html(''),h=a('').append('Title: ').append(a('').on("mouseup touchend keydown",function(a){a.stopPropagation()})).append(a('').attr("data-cmd","setImageAlt").attr("title","OK").html("OK"));this.$image_editor=a("").addClass("bttn-wrapper f-image-editor").append(b).append(c).append(d).append(e).append(f).append(g).append("").append(h);var i=this;this.$image_editor.find("button").click(function(b){b.stopPropagation(),i[a(this).attr("data-cmd")](i.$element.find("span.f-img-editor"))}),this.$popup_editor.append(this.$image_editor)},b.prototype.floatImageLeft=function(a){a.css("margin-left","auto"),a.css("margin-right",this.options.imageMargin),a.css("margin-bottom",this.options.imageMargin),a.css("float","left"),a.find("img").css("float","left"),this.saveUndoStep(),this.callback("floatImageLeft"),a.find("img").click()},b.prototype.floatImageNone=function(a){a.css("margin-left","auto"),a.css("margin-right","auto"),a.css("margin-bottom","auto"),a.css("float","none"),a.find("img").css("float","none"),a.parent().get(0)==this.$element.get(0)?a.wrap(''):a.parent().css("text-align","center"),this.saveUndoStep(),this.callback("floatImageNone"),a.find("img").click()},b.prototype.floatImageRight=function(a){a.css("margin-right","auto"),a.css("margin-left",this.options.imageMargin),a.css("margin-bottom",this.options.imageMargin),a.css("float","right"),a.find("img").css("float","right"),this.saveUndoStep(),this.callback("floatImageRight"),a.find("img").click()},b.prototype.linkImage=function(a){this.showInsertLink(),this.imageMode=!0,"A"==a.parent().get(0).tagName?(this.$link_wrapper.find('input[type="text"]').val(a.parent().attr("href")),"_blank"==a.parent().attr("target")?this.$link_wrapper.find('input[type="checkbox"]').prop("checked",!0):this.$link_wrapper.find('input[type="checkbox"]').prop("checked",!1)):this.$link_wrapper.find('input[type="text"]').val("http://")},b.prototype.replaceImage=function(a){this.showInsertImage(),this.imageMode=!0,this.$image_wrapper.find('input[type="text"]').val(a.find("img").attr("src"))},b.prototype.removeImage=function(a){this.callback("beforeRemoveImage");var c="Are you sure? Image will be deleted.";b.LANGS[this.options.language]&&(c=b.LANGS[this.options.language].translation[c]),confirm(c)?(a.remove(),this.hide(),this.saveUndoStep(),this.callback("afterRemoveImage")):a.find("img").click()},b.prototype.setImageAlt=function(a){a.find("img").attr("alt",this.$image_editor.find('.f-image-alt input[type="text"]').val()),a.find("img").attr("title",this.$image_editor.find('.f-image-alt input[type="text"]').val()),this.saveUndoStep(),this.hide(),this.closeImageMode(),this.callback("setImageAlt")},b.prototype.initElement=function(b){"TEXTAREA"==b.tagName?(this.$textarea=a(b),void 0!==this.$textarea.attr("placeholder")&&"Type something"==this.options.placeholder&&(this.options.placeholder=this.$textarea.attr("placeholder")),this.$element=a("").html(this.$textarea.val()),this.$textarea.before(this.$element).hide()):("DIV"!=b.tagName&&this.options.buttons.indexOf("formatBlock")>=0&&this.disabledList.push("formatBlock"),this.$element=a(b)),this.$box=this.$element,this.$element=a(""),this.setHTML(this.$box.html()),this.$box.empty(),this.$box.html(this.$element).addClass("froala-box"),this.sync(),this.$element.on("drop",function(){setTimeout(function(){a("html").click()},1)})},b.prototype.trim=function(a){return String(a).replace(/^\s+|\s+$/g,"")},b.prototype.wrapText=function(){var b=[],c=["SPAN","A","B","I","EM","U","S","STRONG","STRIKE","FONT"],d=this;this.$element.contents().filter(function(){if(this.nodeType==Node.TEXT_NODE&&a(this).text().trim().length>0||c.indexOf(this.tagName)>=0)b.push(this);else{var e;e=a(d.options.paragraphy===!0?"":"");for(var f in b)e.append(a(b[f]).clone()),f==b.length-1?a(b[f]).replaceWith(e):a(b[f]).remove();b=[]}});var e;e=a(this.options.paragraphy===!0?"":"");for(var f in b)e.append(a(b[f]).clone()),f==b.length-1?a(b[f]).replaceWith(e):a(b[f]).remove();this.$element.find("div:empty, > br").remove()},b.prototype.setHTML=function(b){this.$element.html(a.htmlClean(b,{format:!0})),this.wrapText()},b.prototype.initElementStyle=function(){this.$element.attr("contentEditable",!0),this.$element.addClass("froala-element").addClass(this.options.editorClass),this.$element.css("outline",0)},b.prototype.initUndoRedo=function(){(this.isEnabled("undo")||this.isEnabled("redo"))&&(this.undoStack=[],this.undoIndex=0,this.saveUndoStep()),this.disableBrowserUndo()},b.prototype.enableTyping=function(){this.typingTimer=null,this.$element.on("keydown",a.proxy(function(){clearTimeout(this.typingTimer),this.ajaxSave=!1,this.oldHtml=this.$element.html(),this.typingTimer=setTimeout(a.proxy(function(){this.$element.html()!=this.oldHtml&&((this.isEnabled("undo")||this.isEnabled("redo"))&&this.$element.html()!=this.undoStack[this.undoIndex-1]&&this.saveUndoStep(),this.sync())},this),Math.max(this.options.typingTimer,200))},this))},b.prototype.getHTML=function(){var b=this.$element.clone();return b.find(".f-img-editor > img").each(function(b,c){a(c).css("margin-left",a(c).parent().css("margin-left")),a(c).css("margin-right",a(c).parent().css("margin-right")),a(c).css("margin-bottom",a(c).parent().css("margin-bottom")),a(c).siblings("span.f-img-handle").remove().end().unwrap()}),a.htmlClean(b.html())},b.prototype.initAjaxSaver=function(){this.ajaxHTML=this.getHTML(),this.ajaxSave=!0,this.ajaxInterval=setInterval(a.proxy(function(){this.ajaxHTML!=this.getHTML()&&this.ajaxSave&&(this.options.autosave&&this.save(),this.ajaxHTML=this.getHTML(),this.callback("contentChanged",[],!1)),this.ajaxSave=!0},this),Math.max(this.options.autosaveInterval,1e3))},b.prototype.disableBrowserUndo=function(){a("body").keydown(function(a){var b=a.which,c=a.ctrlKey||a.metaKey;if(!this.isHTM&&c){if(75==b)return a.preventDefault(),!1;if(90==b&&a.shiftKey)return a.preventDefault(),!1;if(90==b)return a.preventDefault(),!1}})},b.prototype.saveUndoStep=function(){if(this.isEnabled("undo")||this.isEnabled("redo")){for(;this.undoStack.length>this.undoIndex;)this.undoStack.pop();this.undoStack.push(this.getHTML()),this.undoIndex++,this.refreshUndoRedo()}this.sync()},b.prototype.initShortcuts=function(){this.options.shortcuts&&this.$element.on("keydown",a.proxy(function(a){var b=a.which,c=a.ctrlKey||a.metaKey;if(!this.isHTML&&c){if(70==b)return this.show(null),!1;if(66==b)return this.execDefaultShortcut("bold");if(73==b)return this.execDefaultShortcut("italic");if(85==b)return this.execDefaultShortcut("underline");if(75==b)return this.execDefaultShortcut("createLink");if(80==b)return this.repositionEditor(),this.execDefaultShortcut("insertImage");if(65==b)return this.execDefaultShortcut("selectAll");if(190==b)return this.execDefaultShortcut("indent");if(188==b)return this.execDefaultShortcut("outdent");if(72==b)return this.execDefaultShortcut("html");if(48==b)return this.execDefaultShortcut("formatBlock","n");if(49==b)return this.execDefaultShortcut("formatBlock","h1");if(50==b)return this.execDefaultShortcut("formatBlock","h2");if(51==b)return this.execDefaultShortcut("formatBlock","h3");if(52==b)return this.execDefaultShortcut("formatBlock","h4");if(53==b)return this.execDefaultShortcut("formatBlock","h5");if(54==b)return this.execDefaultShortcut("formatBlock","h6");if(90==b&&a.shiftKey)return this.redo(),a.stopPropagation(),!1;if(90==b)return this.undo(),a.stopPropagation(),!1}9!=b||a.shiftKey?9==b&&a.shiftKey&&a.preventDefault():(a.preventDefault(),this.insertHTML(" ",!1))},this))},b.prototype.insertHTML=function(a,b){var c,d;if(window.getSelection){if(c=window.getSelection(),c.getRangeAt&&c.rangeCount){d=c.getRangeAt(0),d.deleteContents();var e=document.createElement("div");e.innerHTML=a;for(var f,g,h=document.createDocumentFragment();f=e.firstChild;)g=h.appendChild(f);var i=h.firstChild;d.insertNode(h),g&&(d=d.cloneRange(),d.setStartAfter(g),b?d.setStartBefore(i):d.collapse(!0),c.removeAllRanges(),c.addRange(d))}}else if((c=document.selection)&&"Control"!=c.type){var j=c.createRange();j.collapse(!0),c.createRange().pasteHTML(a),b&&(d=c.createRange(),d.setEndPoint("StartToStart",j),d.select())}},b.prototype.execDefaultShortcut=function(a,b){return this.isEnabled(a)?(this.exec(a,b),!1):!0},b.prototype.initEditor=function(){this.$editor=a(""),this.$editor.addClass("froala-editor").hide(),a("body").append(this.$editor),this.options.inlineMode?this.initInlineEditor():this.initBasicEditor()},b.prototype.toolbarTop=function(){a(window).on("scroll resize",a.proxy(function(){this.options.toolbarFixed||this.options.inlineMode||(a(window).scrollTop()>this.$box.offset().top&&a(window).scrollTop() img").each(function(b,c){a(c).css("margin-left",a(c).parent().css("margin-left")),a(c).css("margin-right",a(c).parent().css("margin-right")),a(c).css("margin-bottom",a(c).parent().css("margin-bottom")),a(c).siblings("span.f-img-handle").remove().end().unwrap()}),this.$element.find("span.f-img-editor").length&&this.$element.find("span.f-img-editor").remove(),this.$element.removeClass("f-non-selectable").attr("contenteditable",!0),this.$image_editor.hide()},b.prototype.isTouch=function(){return Modernizr.touch&&void 0!==window.Touch},b.prototype.initEditorSelection=function(){this.$element.on("mousedown touchstart",a.proxy(function(){this.$element.attr("data-resize")||(this.closeImageMode(),this.hide())},this)),this.$element.on("mouseup touchend",a.proxy(function(a){var b=this.text();""===b||this.isTouch()?this.options.inlineMode||this.refreshButtons():(a.stopPropagation(),this.show(a)),this.imageMode=!1},this)),this.$element.on("mousedown touchstart","img, a",a.proxy(function(a){this.isResizing||a.stopPropagation()},this)),this.$element.on("mousedown touchstart",".f-img-handle",a.proxy(function(){this.$element.attr("data-resize",!0)},this)),this.$element.on("mouseup touchend",".f-img-handle",a.proxy(function(){this.$element.removeAttr("data-resize")},this)),this.$editor.on("mouseup touchend",a.proxy(function(a){a.stopPropagation(),this.options.inlineMode===!1&&this.hide()},this)),this.$popup_editor.on("mouseup touchend",a.proxy(function(a){a.stopPropagation()},this)),this.$link_wrapper&&this.$link_wrapper.on("mouseup touchend",a.proxy(function(a){a.stopPropagation()})),this.$image_wrapper&&this.$image_wrapper.on("mouseup touchend",a.proxy(function(a){a.stopPropagation()})),this.$video_wrapper&&this.$video_wrapper.on("mouseup touchend",a.proxy(function(a){a.stopPropagation()})),a(window).on("mouseup touchend",a.proxy(function(){this.selectionInEditor()&&""!==this.text()&&!this.isTouch()?this.show(null):(this.hide(),this.closeImageMode())},this)),a(document).on("selectionchange",a.proxy(function(a){if(this.options.inlineMode&&this.selectionInEditor()&&this.link!==!0&&this.isTouch()){var b=this.text();""!==b?(Modernizr.mq("(max-device-width: 320px) and (-webkit-min-device-pixel-ratio: 2)")||this.show(null),a.stopPropagation()):this.hide()}},this)),a(window).keydown(a.proxy(function(a){a.ctrlKey||(this.hide(),this.closeImageMode())},this))},b.prototype.setPlaceholder=function(a){a&&(this.options.placeholder=a),this.$textarea&&this.$textarea.attr("placeholder",this.options.placeholder),this.$element.attr("data-placeholder",this.options.placeholder)},b.prototype.isEmpty=function(){var a=this.$element.text().replace(/(\r\n|\n|\r|\t)/gm,"");return(""===a||1==a.length&&"8203"==a.charCodeAt(0))&&0===this.$element.find("img").length&&0==this.$element.find("p > br").length},b.prototype.setPlaceholderEvents=function(){this.$element.on("keyup keydown focus placeholderCheck",a.proxy(function(){if(this.isEmpty()&&!this.isHTML){if(this.options.paragraphy){var b=a("");this.$element.html(b),this.setSelection(b.get(0),0,null,0)}this.$element.addClass("f-placeholder")}else this.$element.find("p").length?this.isEmpty()===!1&&this.$element.removeClass("f-placeholder"):this.options.paragraphy&&(this.wrapText(),this.setSelection(this.$element.find("p")[0],1,null,1))},this)),this.$element.trigger("placeholderCheck")},b.prototype.setDimensions=function(a,b){a&&(this.options.height=a),b&&(this.options.width=b),"auto"!=this.options.height&&this.$element.css("height",this.options.height),"auto"!=this.options.width&&this.$box.css("width",this.options.width)},b.prototype.setDirection=function(a){a&&(this.options.direction=a),"ltr"!=this.options.direction&&"rtl"!=this.options.direction&&(this.options.direction="ltr"),"rtl"==this.options.direction?(this.$element.addClass("f-rtl"),this.$editor.addClass("f-rtl"),this.$popup_editor.addClass("f-rtl")):(this.$element.removeClass("f-rtl"),this.$editor.removeClass("f-rtl"),this.$popup_editor.removeClass("f-rtl"))},b.prototype.setBorderColor=function(a){a&&(this.options.borderColor=a);var c=b.hexToRGB(this.options.borderColor);null!==c&&(this.$editor.css("border-color",this.options.borderColor),this.$editor.attr("data-border-color",this.options.borderColor))},b.prototype.setSpellcheck=function(a){void 0!==a&&(this.options.spellcheck=a),this.$element.attr("spellcheck",this.options.spellcheck)},b.prototype.setInverseSkin=function(a){void 0!==a&&(this.options.inverseSkin=a),this.options.inverseSkin?(this.$editor.addClass("f-inverse"),this.$popup_editor.addClass("f-inverse")):(this.$editor.removeClass("f-inverse"),this.$popup_editor.removeClass("f-inverse"))},b.prototype.customizeText=function(b){b&&(this.$editor.find("[title]").add(this.$popup_editor.find("[title]")).each(a.proxy(function(c,d){for(var e in b)a(d).attr("title").toLowerCase()==e.toLowerCase()&&a(d).attr("title",b[e])},this)),this.$editor.find('[data-text="true"]').add(this.$popup_editor.find('[data-text="true"]')).each(a.proxy(function(c,d){for(var e in b)a(d).text().toLowerCase()==e.toLowerCase()&&a(d).text(b[e])},this)))},b.prototype.setLanguage=function(b){void 0!==b&&(this.options.language=b),a.Editable.LANGS[this.options.language]&&(this.customizeText(a.Editable.LANGS[this.options.language].translation),a.Editable.LANGS[this.options.language].direction&&this.setDirection(a.Editable.LANGS[this.options.language].direction),a.Editable.LANGS[this.options.language].translation[this.options.placeholder]&&this.setPlaceholder(a.Editable.LANGS[this.options.language].translation[this.options.placeholder]))},b.prototype.setCustomText=function(a){a&&(this.options.customText=a),this.options.customText&&this.customizeText(this.options.customText) +},b.prototype.execHTML=function(){this.html()},b.prototype.initHTMLArea=function(){this.$html_area=a('').keydown(function(b){var c=b.keyCode||b.which;if(9==c){b.preventDefault();var d=a(this).get(0).selectionStart,e=a(this).get(0).selectionEnd;a(this).val(a(this).val().substring(0,d)+" "+a(this).val().substring(e)),a(this).get(0).selectionStart=a(this).get(0).selectionEnd=d+1}})},b.prototype.setButtons=function(c){c&&(this.options.buttons=c),this.$bttn_wrapper=a("").addClass("bttn-wrapper"),this.$editor.append(this.$bttn_wrapper);for(var d in this.options.buttons){var e,f;"sep"==this.options.buttons[d]&&this.$bttn_wrapper.append(this.options.inlineMode?'':'');var g=b.commands[this.options.buttons[d]];if(void 0!==g)switch(g.cmd=this.options.buttons[d],g.cmd){case"color":e=this.buildDropdownColor(g),f=this.buildDropdownButton(g,"fr-color-picker").append(e),this.$bttn_wrapper.append(f);break;case"align":e=this.buildDropdownAlign(g),f=this.buildDropdownButton(g,"fr-selector").append(e),this.$bttn_wrapper.append(f);break;case"fontSize":e=this.buildDropdownFontsize(g),f=this.buildDropdownButton(g).append(e),this.$bttn_wrapper.append(f);break;case"formatBlock":e=this.buildDropdownFormatblock(g),f=this.buildDropdownButton(g).append(e),this.$bttn_wrapper.append(f);break;case"createLink":f=this.buildDefaultButton(g),this.$bttn_wrapper.append(f);break;case"insertImage":f=this.buildDefaultButton(g),this.$bttn_wrapper.append(f);break;case"insertVideo":f=this.buildDefaultButton(g),this.$bttn_wrapper.append(f),this.buildInsertVideo();break;case"undo":case"redo":f=this.buildDefaultButton(g),this.$bttn_wrapper.append(f),f.prop("disabled",!0);break;case"html":f=this.buildDefaultButton(g),this.$bttn_wrapper.append(f),this.options.inlineMode&&this.$box.append(f.clone(!0).addClass("html-switch").attr("title","Hide HTML").click(a.proxy(this.execHTML,this))),this.initHTMLArea();break;default:f=this.buildDefaultButton(g),this.$bttn_wrapper.append(f)}else{if(g=this.options.customButtons[this.options.buttons[d]],void 0===g)continue;f=this.buildCustomButton(g),this.$bttn_wrapper.append(f)}}this.buildCreateLink(),this.buildInsertImage(),this.bindButtonEvents()},b.prototype.buildDefaultButton=function(b){var c=a("").addClass("fr-bttn").attr("title",b.title).attr("data-cmd",b.cmd).attr("data-activeless",b.activeless);return this.addButtonIcon(c,b),c},b.prototype.addButtonIcon=function(b,c){b.append(c.icon?a("").addClass(c.icon):c.icon_alt?a("").addClass("for-text").html(c.icon_alt):c.icon_img?a('').attr("alt",c.title):c.icon_txt?a("").html(c.icon_txt):c.title)},b.prototype.buildCustomButton=function(b){var c=a("").addClass("fr-bttn").attr("title",b.title);return"fa"==b.icon.type?this.addButtonIcon(c,{icon:"fa "+b.icon.value}):"img"==b.icon.type?this.addButtonIcon(c,{icon_img:b.icon.value,title:b.title}):"txt"==b.icon.type&&this.addButtonIcon(c,{icon_txt:b.icon.value}),c.on("click touchend",a.proxy(function(a){a.stopPropagation(),a.preventDefault(),b.callback(this)},this)),c},b.prototype.buildDropdownButton=function(b,c){c=c||"";var d=a("").addClass("fr-bttn fr-dropdown").addClass(c),e=a("").addClass("fr-trigger").attr("title",b.title);return this.addButtonIcon(e,b),d.append(e),d},b.prototype.buildDropdownColor=function(b){var c=a("").addClass("fr-dropdown-menu");for(var d in b.seed){var e=b.seed[d],f=a("").append(a('').html(e.title));for(var g in e.value){var h=e.value[g];f.append(a("").addClass("fr-color-bttn").attr("data-cmd",e.cmd).attr("data-val",h).attr("data-activeless",b.activeless).css("background-color",h).html(" ")),g%8==7&&g>0&&(f.append(""),(7==g||15==g)&&f.append(a("").addClass("separator")))}c.append(f)}return c},b.prototype.buildDropdownAlign=function(b){var c=a("").addClass("fr-dropdown-menu");for(var d in b.seed){var e=b.seed[d],f=a("").append(a("").addClass("fr-bttn").attr("data-cmd",e.cmd).attr("title",e.title).attr("data-activeless",b.activeless).append(a("").addClass(e.icon)));c.append(f)}return c},b.prototype.buildDropdownFontsize=function(b){var c=a("").addClass("fr-dropdown-menu f-font-sizes");for(var d in b.seed)for(var e=b.seed[d],f=e.min;f<=e.max;f++){var g=a("").attr("data-cmd",b.cmd).attr("data-val",f+"px").attr("data-activeless",b.activeless).append(a('').append(a("").text(f+"px")));c.append(g)}return c},b.prototype.buildDropdownFormatblock=function(b){var c=a("").addClass("fr-dropdown-menu");for(var d in b.seed){var e=b.seed[d];if(-1!=a.inArray(e.value,this.options.blockTags)){var f=a("").append(a("").attr("data-cmd",b.cmd).attr("data-val",e.value).attr("data-activeless",b.activeless).append(a('').addClass("format_"+e.value).attr("title",e.title).text(e.title)));c.append(f)}}return c},b.prototype.buildInsertImage=function(){this.$image_wrapper=a("").addClass("image-wrapper"),this.$popup_editor.append(this.$image_wrapper);var b=this;this.$progress_bar=a('').append("");var c=a('').append('Drop Image(or click)').append(a('').append(a('')));this.browser.msie&&(this.$upload_frame=a(''),a("body").append(this.$upload_frame),this.$upload_frame.bind("load",function(){var c=a(this).contents().text();b.parseImageResponse(c)})),this.$image_wrapper.on("change",'input[type="file"]',function(){if(void 0!==this.files)b.uploadFile(this.files);else{var c=a(this).parents("form");c.find('input[type="hidden"]').remove();for(var d in b.options.imageParams)c.append('');c.append(''),c.submit()}}),this.buildDragUpload(c);var d=a('').on("mouseup touchend keydown",a.proxy(function(a){a.stopPropagation()},this));this.$image_list=a("").append(a('').append(c)).append(a('').append('Enter URL: ').append(d).append(a('OK').click(a.proxy(function(){this.writeImage(d.val())},this)))),this.$image_wrapper.append(a("").append('Insert image').append(a('').click(a.proxy(function(){this.$bttn_wrapper.show(),this.hideImageWrapper(!0),this.restoreSelection(),this.options.inlineMode||this.imageMode?this.imageMode&&this.showImageEditor():this.hide()},this)))).append(this.$image_list).append(this.$progress_bar).click(function(a){a.stopPropagation()}).find("*").click(function(a){a.stopPropagation()}).end().hide()},b.prototype.buildInsertVideo=function(){this.$video_wrapper=a("").addClass("video-wrapper"),this.$popup_editor.append(this.$video_wrapper);var b=a('').on("mouseup touchend keydown",a.proxy(function(a){a.stopPropagation()},this)),c=a("").append(a('OK').click(a.proxy(function(){this.restoreSelection(),a(this.getSelectionElements()[0]).after(this.options.paragraphy?''+b.val()+"":''+b.val()+""),this.saveUndoStep(),this.$bttn_wrapper.show(),this.hideVideoWrapper(),this.hide(),this.callback("insertVideo",[b.val()])},this)));this.$video_wrapper.append(a("").append('Insert video').append(a('').click(a.proxy(function(){this.$bttn_wrapper.show(),this.hideVideoWrapper(),this.restoreSelection(),this.options.inlineMode||this.hide()},this)))).append(b).append(c).click(function(a){a.stopPropagation()}).find("*").click(function(a){a.stopPropagation()}).end().hide()},b.prototype.buildCreateLink=function(){this.$link_wrapper=a("").addClass("link-wrapper"),this.$popup_editor.append(this.$link_wrapper);var b=a('').attr("placeholder","http://www.example.com").on("mouseup touchend keydown",function(a){a.stopPropagation()}),c=a('').click(function(a){a.stopPropagation()}),d=a('').text("OK").on("touchend",function(a){a.stopPropagation()}).click(a.proxy(function(){this.writeLink(b.val(),c.prop("checked"))},this)),e=a('').text("UNLINK").on("click touch",a.proxy(function(){this.link=!0,this.writeLink("",c.prop("checked"))},this));this.$link_wrapper.append(a("").append('Insert link').append(a('').click(a.proxy(function(){this.$bttn_wrapper.show(),this.hideLinkWrapper(),this.options.inlineMode||this.imageMode?this.imageMode&&this.showImageEditor():this.hide(),this.restoreSelection()},this)))).append(b).append(a("").append(c).append(' Open in new tab').append(d).append(e)).end().hide()},b.prototype.buildDragUpload=function(b){var c=this;b.on({dragover:function(){return a(this).addClass("f-hover"),!1},dragend:function(){return a(this).removeClass("f-hover"),!1},drop:function(b){a(this).removeClass("f-hover"),b.preventDefault(),c.uploadFile(b.originalEvent.dataTransfer.files)}})},b.prototype.hideImageLoader=function(){this.$progress_bar.hide(),this.$progress_bar.find("span").css("width","0%").text(""),this.$image_list.show()},b.prototype.writeImage=function(b){var c=new Image;if(c.onerror=a.proxy(function(){this.hideImageLoader(),this.throwImageError(1)},this),this.imageMode)return c.onload=a.proxy(function(){this.$element.find(".f-img-editor > img").attr("src",b),this.hide(),this.hideImageLoader(),this.$image_editor.show(),this.saveUndoStep(),this.callback("replaceImage",[b])},this),c.src=b,!1;var d=this.getSelectionElements()[0];c.onload=a.proxy(function(){a(d).prepend(''),a(d).find("img:first").get(0).oncontrolselect=function(){return!1},this.hide(),this.hideImageLoader(),this.saveUndoStep(),this.callback("insertImage",[b])},this),c.src=b},b.prototype.throwImageError=function(b){var c="Unknown image upload error.";1==b?c="Bad link.":2==b?c="No link in upload response.":3==b?c="Error during file upload.":4==b&&(c="Parsing response failed."),this.options.imageErrorCallback&&a.isFunction(this.options.imageErrorCallback)&&this.options.imageErrorCallback({errorCode:b,errorStatus:c})},b.prototype.uploadFile=function(b){if(void 0!==b&&b.length>0){var c;if(this.drag_support.formdata&&(c=this.drag_support.formdata?new FormData:null),c&&c.append(this.options.imageUploadParam,b[0]),c){var d;this.options.crossDomain?d=this.createCORSRequest("POST",this.options.imageUploadURL):(d=new XMLHttpRequest,d.open("POST",this.options.imageUploadURL)),d.onload=a.proxy(function(){this.$progress_bar.find("span").css("width","100%").text("Please wait!");try{200==d.status?this.parseImageResponse(d.responseText):this.throwImageError(3)}catch(a){this.throwImageError(4)}this.hideImageLoader()},this),d.onerror=a.proxy(function(){this.throwImageError(3),this.hideImageLoader()},this),d.upload.onprogress=a.proxy(function(a){if(a.lengthComputable){var b=a.loaded/a.total*100|0;this.$progress_bar.find("span").css("width",b+"%")}},this);for(var e in this.options.imageParams)c.append(e,this.options.imageParams[e]);d.send(c),this.$image_list.hide(),this.$progress_bar.show()}}},b.prototype.parseImageResponse=function(b){try{var c=a.parseJSON(b);"http://uploads.im/api"==this.options.imageUploadURL?this.writeImage(c.data.img_url):c.link?this.writeImage(c.link):this.throwImageError(2)}catch(d){this.throwImageError(4)}},b.prototype.createCORSRequest=function(a,b){var c=new XMLHttpRequest;return"withCredentials"in c?c.open(a,b,!0):"undefined"!=typeof XDomainRequest?(c=new XDomainRequest,c.open(a,b)):c=null,c},b.prototype.writeLink=function(b,c){if(this.imageMode)return""!==b?("A"!=this.$element.find(".f-img-editor").parent().get(0).tagName?this.$element.find(".f-img-editor").wrap(c===!0?'':''):c===!0?this.$element.find(".f-img-editor").parent().attr("target","_blank"):(this.$element.find(".f-img-editor").parent().removeAttr("target"),this.$element.find(".f-img-editor").parent().attr("href",b)),this.callback("insertImageLink",[b])):("A"==this.$element.find(".f-img-editor").parent().get(0).tagName&&a(this.$element.find(".f-img-editor").get(0)).unwrap(),this.callback("removeImageLink")),this.saveUndoStep(),this.showImageEditor(),this.$element.find(".f-img-editor").find("img").click(),this.link=!1,!1;if(this.restoreSelection(),document.execCommand("unlink",!1,b),this.saveSelectionByMarkers(),this.$element.find("span.f-link").each(function(b,c){a(c).replaceWith(a(c).html())}),this.restoreSelectionByMarkers(),""!==b){document.execCommand("createLink",!1,b);for(var d=this.getSelectionLinks(),e=0;e-1&&e.push(c[h])}d.detach()}}else if(document.selection&&"Control"!=document.selection.type)if(a=document.selection.createRange(),b=a.parentElement(),"a"==b.nodeName.toLowerCase())e.push(b);else{c=b.getElementsByTagName("a"),d=document.body.createTextRange();for(var i=0;i-1&&d.compareEndPoints("EndToStart",a)<1&&e.push(c[i])}return e},b.prototype.isEnabled=function(b){return a.inArray(b,this.options.buttons)>=0},b.prototype.show=function(b){if(void 0!==b){if(this.options.inlineMode)if(null!==b&&"touchend"!==b.type){var c=b.pageX,d=b.pageY;20>c&&(c=20),0>d&&(d=0),c+this.$editor.width()>a(window).width()-50?(this.$editor.addClass("right-side"),c=a(window).width()-(c+30),this.$editor.css("top",d+20),this.$editor.css("right",c),this.$editor.css("left","auto")):(this.$editor.removeClass("right-side"),this.$editor.css("top",d+20),this.$editor.css("left",c-20),this.$editor.css("right","auto")),a(".froala-editor:not(.f-basic)").hide(),this.$editor.show()}else a(".froala-editor:not(.f-basic)").hide(),this.$editor.show(),this.repositionEditor();this.hideLinkWrapper(),this.hideVideoWrapper(),this.hideImageWrapper(),this.$bttn_wrapper.show(),this.$bttn_wrapper.find(".fr-dropdown").removeClass("active"),this.refreshButtons(),this.imageMode=!1}},b.prototype.showByCoordinates=function(b,c){b-=20,c+=15,b+this.$popup_editor.width()>a(window).width()-50?(this.$popup_editor.addClass("right-side"),b=a(window).width()-(b+40),this.$popup_editor.css("top",c),this.$popup_editor.css("right",b),this.$popup_editor.css("left","auto")):(this.$popup_editor.removeClass("right-side"),this.$popup_editor.css("top",c),this.$popup_editor.css("left",b),this.$popup_editor.css("right","auto")),this.$popup_editor.show()},b.prototype.showLinkWrapper=function(){this.$link_wrapper&&this.$link_wrapper.show()},b.prototype.hideLinkWrapper=function(){this.$link_wrapper&&this.$link_wrapper.hide()},b.prototype.showImageWrapper=function(){this.$image_wrapper&&this.$image_wrapper.show()},b.prototype.showVideoWrapper=function(){this.$video_wrapper&&this.$video_wrapper.show()},b.prototype.hideImageWrapper=function(a){this.$image_wrapper&&(this.$element.attr("data-resize")||a||this.closeImageMode(),this.$image_wrapper.hide())},b.prototype.hideVideoWrapper=function(){this.$video_wrapper&&this.$video_wrapper.hide()},b.prototype.showInsertLink=function(){this.options.inlineMode&&this.$bttn_wrapper.hide(),this.showLinkWrapper(),this.hideImageWrapper(!0),this.hideVideoWrapper(),this.$image_editor.hide(),this.link=!0},b.prototype.showInsertImage=function(){this.options.inlineMode&&this.$bttn_wrapper.hide(),this.hideLinkWrapper(),this.hideVideoWrapper(),this.showImageWrapper(),this.$image_editor.hide()},b.prototype.showInsertVideo=function(){this.options.inlineMode&&this.$bttn_wrapper.hide(),this.hideLinkWrapper(),this.hideImageWrapper(),this.showVideoWrapper(),this.$image_editor.hide()},b.prototype.showImageEditor=function(){this.options.inlineMode&&this.$bttn_wrapper.hide(),this.hideLinkWrapper(),this.hideImageWrapper(!0),this.hideVideoWrapper(),this.$image_editor.show(),this.options.imageMove||this.$element.attr("contenteditable",!1)},b.prototype.hide=function(){this.$popup_editor.hide(),this.hideLinkWrapper(),this.hideImageWrapper(),this.hideVideoWrapper(),this.$image_editor.hide(),this.link=!1},b.prototype.positionPopup=function(b){a(this.$editor.find('button.fr-bttn[data-cmd="'+b+'"]')).length&&(this.$popup_editor.css("top",this.$editor.find('button.fr-bttn[data-cmd="'+b+'"]').offset().top+30),this.$popup_editor.css("left",this.$editor.find('button.fr-bttn[data-cmd="'+b+'"]').offset().left),this.$popup_editor.show())},b.prototype.bindButtonEvents=function(){this.bindDropdownEvents(),this.bindCommandEvents()},b.prototype.bindDropdownEvents=function(){var b=this;this.$bttn_wrapper.find(".fr-dropdown").on("click touchend",function(c){return c.stopPropagation(),c.preventDefault(),0==b.options.inlineMode&&b.hide(),a(this).attr("data-disabled")?!1:(a(".fr-dropdown").not(this).removeClass("active"),void a(this).toggleClass("active"))}),a(window).on("click touchend",a.proxy(function(){this.$editor.find(".fr-dropdown").removeClass("active")},this)),this.$element.on("click touchend","img, a",a.proxy(function(){this.$editor.find(".fr-dropdown").removeClass("active")},this));var c=this.$bttn_wrapper.find(".fr-selector button.fr-bttn");c.bind("select",function(){a(this).parents(".fr-selector").find(" > button > i").attr("class",a(this).find("i").attr("class"))}).on("click touch",function(){a(this).parents("ul").find("button").removeClass("active"),a(this).parents(".fr-selector").removeClass("active").trigger("mouseout"),a(this).trigger("select")})},b.prototype.bindCommandEvents=function(){this.$bttn_wrapper.find("[data-cmd]").on("click touchend",a.proxy(function(b){b.stopPropagation(),b.preventDefault();var c=b.currentTarget,d=a(c).data("cmd"),e=a(c).data("val");a(c).parents(".fr-dropdown").removeClass("active"),this.exec(d,e),this.$bttn_wrapper.find(".fr-dropdown").removeClass("active")},this))},b.prototype.exec=function(a,b){if(!this.selectionInEditor()&&"html"!==a&&"undo"!==a&&"redo"!==a&&"selectAll"!==a&&"save"!=a&&"insertImage"!==a&&"insertVideo"!==a)return!1;if(this.selectionInEditor()&&""===this.text()&&"fontSize"!==a&&"formatBlock"!==a&&"indent"!==a&&"outdent"!==a&&"justifyLeft"!==a&&"justifyRight"!==a&&"justifyFull"!==a&&"justifyCenter"!==a&&"html"!==a&&"undo"!==a&&"redo"!==a&&"selectAll"!==a&&"save"!==a&&"insertImage"!==a&&"insertVideo"!==a&&"insertOrderedList"!==a&&"insertUnorderedList"!==a)return!1;switch(a){case"fontSize":this.fontSize(b);break;case"backColor":this.backColor(b);break;case"foreColor":this.foreColor(b);break;case"formatBlock":this.formatBlock(b);break;case"createLink":this.insertLink();break;case"insertImage":this.insertImage();break;case"indent":this.indent();break;case"outdent":this.outdent(!0);break;case"justifyLeft":case"justifyRight":case"justifyCenter":case"justifyFull":this.align(a);break;case"insertOrderedList":case"insertUnorderedList":this.formatList(a);break;case"insertVideo":this.insertVideo();break;case"indent":case"outdent":this.execDefault(a,b),this.repositionEditor();break;case"undo":this.undo();break;case"redo":this.redo();break;case"html":this.html();break;case"save":this.save();break;case"selectAll":this.$element.focus(),this.execDefault(a,b);break;default:this.execDefault(a,b)}"undo"!=a&&"redo"!=a&&"selectAll"!=a&&"createLink"!=a&&"insertImage"!=a&&"html"!=a&&"insertVideo"!=a&&this.saveUndoStep(),"createLink"!=a&&"insertImage"!=a&&this.refreshButtons()},b.prototype.undo=function(){if(this.undoIndex>1){var a=this.getHTML();this.$element.html(this.undoStack[--this.undoIndex-1]),this.hide(),this.callback("undo",[this.$element.html(),a])}this.refreshUndoRedo()},b.prototype.redo=function(){if(this.undoIndex").attr("data-font",!0).css("font-size",b).html(a(e).html());0===a(e).parents("font").length&&c.push(f),a(e).replaceWith(f)});var d=function(b,c){a(c).css("font-size","")};for(var e in c){var f=c[e];a(f).find("*").each(d)}this.$element.find('span[data-font="true"] > span[data-font="true"]').each(function(b,c){a(c).attr("style")&&(a(c).before(''),a(c).after(''))});var g=this.$element.html();g=g.replace(new RegExp('',"g"),""),g=g.replace(new RegExp('data-open="true">',"g"),">"),this.$element.html(g);for(var h=!0,i=a.proxy(function(){this.$element.find('span[data-font="true"] + span[data-font="true"]').each(function(b,c){a(c).css("font-size")==a(c).prev().css("font-size")&&(a(c).prepend(a(c).prev().html()),a(c).prev().remove(),h=!0)}),this.$element.find('span[data-font="true"] + span#marker-true + span[data-font="true"], span[data-font="true"] + span#marker-true + span[data-font="true"]').each(function(b,c){a(c).css("font-size")==a(c).prev().prev().css("font-size")&&(a(c).prepend(a(c).prev().clone()),a(c).prepend(a(c).prev().prev().html()),a(c).prev().prev().remove(),a(c).prev().remove(),h=!0)})},this);h;)h=!1,i();this.$element.find('span[style=""]').each(function(b,c){a(c).replaceWith(a(c).html())}),this.$element.find("span[data-font]").each(function(b,c){a(c).css("font-size")==a(c).parent().css("font-size")&&a(c).replaceWith(a(c).html())}),this.restoreSelectionByMarkers(),this.repositionEditor(),this.callback("fontSize")},b.prototype.backColor=function(c){var d="backColor";this.browser.msie||(d="hiliteColor");var e=a(this.getSelectionElement()).css("background-color");document.execCommand(d,!1,c);var f=this.$editor.find('button.fr-color-bttn[data-cmd="backColor"][data-val="'+c+'"]');f.addClass("active"),f.siblings().removeClass("active"),this.callback("backColor",[b.hexToRGBString(c),e])},b.prototype.foreColor=function(c){var d=a(this.getSelectionElement()).css("color");document.execCommand("foreColor",!1,c),this.saveSelectionByMarkers(),this.$element.find("font[color]").each(function(b,d){a(d).replaceWith(a("").css("color",c).html(a(d).html()))}),this.restoreSelectionByMarkers();var e=this.$editor.find('button.fr-color-bttn[data-cmd="foreColor"][data-val="'+c+'"]');e.addClass("active"),e.siblings().removeClass("active"),this.callback("foreColor",[b.hexToRGBString(c),d])},b.prototype.formatBlock=function(b){if(this.disabledList.indexOf("formatBlock")>=0)return!1;this.saveSelectionByMarkers(),this.wrapText(),this.restoreSelectionByMarkers();var c,d=this.getSelectionElements();for(var e in d){var f=a(d[e]);if(c="n"==b?a("").html(f.html()):a("<"+b+">").html(f.html()),f.get(0)!=this.$element.get(0)&&"LI"!=f.get(0).tagName){var g=f.prop("attributes");if(c.attr)for(var h in g)c.attr(g[h].name,g[h].value);f.replaceWith(c)}else f.html(c)}this.clearSelection(),this.hide(),this.callback("formatBlock")},b.prototype.formatList=function(b){this.saveSelectionByMarkers();var c,d=this.getSelectionElements(),e=!0,f=!1;for(var g in d)c=a(d[g]),c.parents("li").length>0?(c.parents("ol").length>0?(c.parents("li").before(''),c.parents("li").after('')):c.parents("ul").length>0&&(c.parents("li").before(''),c.parents("li").after('')),c.parents("li").replaceWith(c.parents("li").contents()),f=!0):e=!1;if(f){var h=this.$element.html();h=h.replace(new RegExp('',"g"),""),h=h.replace(new RegExp('',"g"),""),h=h.replace(new RegExp('',"g"),""),h=h.replace(new RegExp('',"g"),""),this.$element.html(h),this.$element.find("ul:empty, ol:empty").remove()}if(this.clearSelection(),this.wrapText(),this.restoreSelectionByMarkers(),e===!1){d=this.getSelectionElements(),this.saveSelectionByMarkers();var i=a("");"insertUnorderedList"==b&&(i=a(""));for(var j in d)c=a(d[j]),c.get(0)!=this.$element.get(0)&&(i.append(a("").append(c.clone())),j!=d.length-1?c.remove():c.replaceWith(i));this.restoreSelectionByMarkers()}this.repositionEditor(),this.callback(b)},b.prototype.align=function(b){var c=this.getSelectionElements();this.saveSelection(),"justifyLeft"==b?b="left":"justifyRight"==b?b="right":"justifyCenter"==b?b="center":"justifyFull"==b&&(b="justify");for(var d in c)a(c[d]).css("text-align",b);this.restoreSelection(),this.repositionEditor(),this.callback("align")},b.prototype.indent=function(b){var c=20;b&&(c=-20),this.saveSelectionByMarkers(),this.wrapText(),this.restoreSelectionByMarkers();var d=this.getSelectionElements();this.saveSelectionByMarkers();for(var e in d){var f=a(d[e]);if(f.get(0)!=this.$element.get(0)){var g=parseInt(f.css("margin-left").replace(/px/,""),10),h=Math.max(0,g+c);f.css("marginLeft",h)}else{var i=a("").html(f.html());f.html(i),i.css("marginLeft",Math.max(0,c))}}this.restoreSelectionByMarkers(),this.repositionEditor(),b||this.callback("indent")},b.prototype.outdent=function(){this.indent(!0),this.callback("outdent")},b.prototype.insertLink=function(){this.showInsertLink(),this.options.inlineMode||this.positionPopup("createLink"),this.saveSelection();var b=this.getSelectionLink(),c=this.getSelectionLinks();c.length>0&&this.$link_wrapper.find('input[type="checkbox"]').prop("checked","_blank"==a(c[0]).attr("target")),this.$link_wrapper.find('input[type="text"]').val(b||"http://")},b.prototype.insertImage=function(){this.showInsertImage(),this.saveSelection(),this.options.inlineMode||this.positionPopup("insertImage"),this.$image_wrapper.find('input[type="text"]').val("")},b.prototype.insertVideo=function(){this.showInsertVideo(),this.saveSelection(),this.options.inlineMode||this.positionPopup("insertVideo"),this.$video_wrapper.find("textarea").val("")},b.prototype.execDefault=function(a,b){document.execCommand(a,!1,b),"insertOrderedList"==a?this.$bttn_wrapper.find('[data-cmd="insertUnorderedList"]').removeClass("active"):"insertUnorderedList"==a&&this.$bttn_wrapper.find('[data-cmd="insertOrderedList"]').removeClass("active"),this.callback(a)},b.prototype.refreshButtons=function(){return!this.selectionInEditor()||this.isHTML?!1:(this.refreshUndoRedo(),void this.$bttn_wrapper.find("[data-cmd]").each(a.proxy(function(b,c){switch(a(c).data("cmd")){case"fontSize":this.refreshFontSize(c);break;case"backColor":this.refreshBackColor(c);break;case"foreColor":this.refreshForeColor(c);break;case"formatBlock":this.refreshFormatBlock(c);break;case"createLink":case"insertImage":break;case"justifyLeft":case"justifyRight":case"justifyCenter":case"justifyFull":this.refreshAlign(c);break;case"html":this.isHTML?a(c).addClass("active"):a(c).removeClass("active");break;case"undo":case"redo":case"save":break;default:this.refreshDefault(c)}},this)))},b.prototype.refreshFormatBlock=function(b){this.disabledList.indexOf("formatBlock")>=0&&a(b).parents(".fr-dropdown").attr("data-disabled",!0)},b.prototype.refreshUndoRedo=function(){if(this.isEnabled("undo")||this.isEnabled("redo")){if(void 0===this.$editor)return;this.$bttn_wrapper.find('[data-cmd="undo"], [data-cmd="redo"]').prop("disabled",!1),(0===this.undoStack.length||this.undoIndex<=1||this.isHTML)&&this.$bttn_wrapper.find('[data-cmd="undo"]').prop("disabled",!0),(this.undoIndex==this.undoStack.length||this.isHTML)&&this.$bttn_wrapper.find('[data-cmd="redo"]').prop("disabled",!0)}},b.prototype.refreshDefault=function(b){a(b).removeClass("active");try{document.queryCommandState(a(b).data("cmd"))===!0&&a(b).addClass("active")}catch(c){}},b.prototype.refreshAlign=function(b){var c=a(b).data("cmd"),d=this.getSelectionElements();"justifyLeft"==c?c="left":"justifyRight"==c?c="right":"justifyCenter"==c?c="center":"justifyFull"==c&&(c="justify"),c==a(d[0]).css("text-align")&&(a(b).parents("ul").find(".fr-bttn").removeClass("active"),a(b).addClass("active"),a(b).parents(".fr-dropdown").find(".fr-trigger").html(a(b).html()))},b.prototype.refreshForeColor=function(b){a(b).removeClass("active"),document.queryCommandValue("foreColor")==b.style.backgroundColor&&a(b).addClass("active")},b.prototype.refreshBackColor=function(b){a(b).removeClass("active"),document.queryCommandValue("backColor")==b.style.backgroundColor&&a(b).addClass("active")},b.prototype.refreshFontSize=function(b){a(b).removeClass("active"),parseInt(document.queryCommandValue("fontSize"),10)==parseInt(a(b).data("val"),10)&&a(b).addClass("active") },b.prototype.option=function(b,c){if(void 0===b)return this.options;if(b instanceof Object)this.options=a.extend({},this.options,b),this.initOptions(),this.setCustomText(),this.setLanguage();else{if(void 0===c)return this.options[b];switch(this.options[b]=c,b){case"borderColor":this.setBorderColor();break;case"direction":this.setDirection();break;case"height":case"width":this.setDimensions();break;case"spellcheck":this.setSpellcheck();break;case"placeholder":this.setPlaceholder();break;case"customText":this.setCustomText();break;case"inverseSkin":this.setInverseSkin();break;case"language":this.setLanguage()}}};var c=a.fn.editable;a.fn.editable=function(c){for(var d=[],e=0;ee*e+f*f||v(a,b,c,e,f,d)}function t(){return this._handled=d,!1}function u(a){try{a._handled()}catch(b){return!1}}function v(a,b,c,d,e,f){{var g,h;b.target}g=a.targetTouches,h=a.timeStamp-b.timeStamp,b.type="movestart",b.distX=d,b.distY=e,b.deltaX=d,b.deltaY=e,b.pageX=c.pageX,b.pageY=c.pageY,b.velocityX=d/h,b.velocityY=e/h,b.targetTouches=g,b.finger=g?g.length:1,b._handled=t,b._preventTouchmoveDefault=function(){a.preventDefault()},L(b.target,b),f(b.identifier)}function w(a){var b=a.data.timer;a.data.touch=a,a.data.timeStamp=a.timeStamp,b.kick()}function x(a){var b=a.data.event,c=a.data.timer;y(),D(b,c,function(){setTimeout(function(){K(b.target,"click",e)},0)})}function y(){K(document,O.move,w),K(document,O.end,x)}function z(a){var b=a.data.event,c=a.data.timer,d=j(a,b);d&&(a.preventDefault(),b.targetTouches=a.targetTouches,a.data.touch=d,a.data.timeStamp=a.timeStamp,c.kick())}function A(a){var b=a.data.event,c=a.data.timer,d=i(a.changedTouches,b.identifier);d&&(B(b),D(b,c))}function B(a){K(document,"."+a.identifier,z),K(document,"."+a.identifier,A)}function C(a,b,c){var d=c-a.timeStamp;a.type="move",a.distX=b.pageX-a.startX,a.distY=b.pageY-a.startY,a.deltaX=b.pageX-a.pageX,a.deltaY=b.pageY-a.pageY,a.velocityX=.3*a.velocityX+.7*a.deltaX/d,a.velocityY=.3*a.velocityY+.7*a.deltaY/d,a.pageX=b.pageX,a.pageY=b.pageY}function D(a,b,c){b.end(function(){return a.type="moveend",L(a.target,a),c&&c()})}function E(){return J(this,"movestart.move",u),!0}function F(){return K(this,"dragstart drag",f),K(this,"mousedown touchstart",g),K(this,"movestart",u),!0}function G(a){"move"!==a.namespace&&"moveend"!==a.namespace&&(J(this,"dragstart."+a.guid+" drag."+a.guid,f,b,a.selector),J(this,"mousedown."+a.guid,g,b,a.selector))}function H(a){"move"!==a.namespace&&"moveend"!==a.namespace&&(K(this,"dragstart."+a.guid+" drag."+a.guid),K(this,"mousedown."+a.guid))}var I=6,J=a.event.add,K=a.event.remove,L=function(b,c,d){a.event.trigger(c,d,b)},M=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){return window.setTimeout(function(){a()},25)}}(),N={textarea:!0,input:!0,select:!0,button:!0},O={move:"mousemove",cancel:"mouseup dragstart",end:"mouseup"},P={move:"touchmove",cancel:"touchend",end:"touchend"};a.event.special.movestart={setup:E,teardown:F,add:G,remove:H,_default:function(a){function d(){C(f,g.touch,g.timeStamp),L(a.target,f)}var f,g;a._handled()&&(f={target:a.target,startX:a.startX,startY:a.startY,pageX:a.pageX,pageY:a.pageY,distX:a.distX,distY:a.distY,deltaX:a.deltaX,deltaY:a.deltaY,velocityX:a.velocityX,velocityY:a.velocityY,timeStamp:a.timeStamp,identifier:a.identifier,targetTouches:a.targetTouches,finger:a.finger},g={event:f,timer:new c(d),touch:b,timeStamp:b},a.identifier===b?(J(a.target,"click",e),J(document,O.move,w,g),J(document,O.end,x,g)):(a._preventTouchmoveDefault(),J(document,P.move+"."+a.identifier,z,g),J(document,P.end+"."+a.identifier,A,g)))}},a.event.special.move={setup:function(){J(this,"movestart.move",a.noop)},teardown:function(){K(this,"movestart.move",a.noop)}},a.event.special.moveend={setup:function(){J(this,"movestart.moveend",a.noop)},teardown:function(){K(this,"movestart.moveend",a.noop)}},J(document,"mousedown.move",k),J(document,"touchstart.move",o),"function"==typeof Array.prototype.indexOf&&!function(a){for(var b=["changedTouches","targetTouches"],c=b.length;c--;)-1===a.event.props.indexOf(b[c])&&a.event.props.push(b[c])}(a)}),+function(a){function b(a,b,c,d){if(a.tag.format&&c.length>0){c.push("\n");for(var e=0;d>e;e++)c.push(" ")}}function c(d,e){var f=[],g=0==d.attributes.length,h=0;if(d.tag.isComment)e.allowComments&&(f.push("
').html(e.title));for(var g in e.value){var h=e.value[g];f.append(a("").addClass("fr-color-bttn").attr("data-cmd",e.cmd).attr("data-val",h).attr("data-activeless",b.activeless).css("background-color",h).html(" ")),g%8==7&&g>0&&(f.append(""),(7==g||15==g)&&f.append(a("").addClass("separator")))}c.append(f)}return c},b.prototype.buildDropdownAlign=function(b){var c=a("").addClass("fr-dropdown-menu");for(var d in b.seed){var e=b.seed[d],f=a("").append(a("").addClass("fr-bttn").attr("data-cmd",e.cmd).attr("title",e.title).attr("data-activeless",b.activeless).append(a("").addClass(e.icon)));c.append(f)}return c},b.prototype.buildDropdownFontsize=function(b){var c=a("").addClass("fr-dropdown-menu f-font-sizes");for(var d in b.seed)for(var e=b.seed[d],f=e.min;f<=e.max;f++){var g=a("").attr("data-cmd",b.cmd).attr("data-val",f+"px").attr("data-activeless",b.activeless).append(a('').append(a("").text(f+"px")));c.append(g)}return c},b.prototype.buildDropdownFormatblock=function(b){var c=a("").addClass("fr-dropdown-menu");for(var d in b.seed){var e=b.seed[d];if(-1!=a.inArray(e.value,this.options.blockTags)){var f=a("").append(a("").attr("data-cmd",b.cmd).attr("data-val",e.value).attr("data-activeless",b.activeless).append(a('').addClass("format_"+e.value).attr("title",e.title).text(e.title)));c.append(f)}}return c},b.prototype.buildInsertImage=function(){this.$image_wrapper=a("").addClass("image-wrapper"),this.$popup_editor.append(this.$image_wrapper);var b=this;this.$progress_bar=a('').append("");var c=a('').append('Drop Image(or click)').append(a('').append(a('')));this.browser.msie&&(this.$upload_frame=a(''),a("body").append(this.$upload_frame),this.$upload_frame.bind("load",function(){var c=a(this).contents().text();b.parseImageResponse(c)})),this.$image_wrapper.on("change",'input[type="file"]',function(){if(void 0!==this.files)b.uploadFile(this.files);else{var c=a(this).parents("form");c.find('input[type="hidden"]').remove();for(var d in b.options.imageParams)c.append('');c.append(''),c.submit()}}),this.buildDragUpload(c);var d=a('').on("mouseup touchend keydown",a.proxy(function(a){a.stopPropagation()},this));this.$image_list=a("").append(a('').append(c)).append(a('').append('Enter URL: ').append(d).append(a('OK').click(a.proxy(function(){this.writeImage(d.val())},this)))),this.$image_wrapper.append(a("").append('Insert image').append(a('').click(a.proxy(function(){this.$bttn_wrapper.show(),this.hideImageWrapper(!0),this.restoreSelection(),this.options.inlineMode||this.imageMode?this.imageMode&&this.showImageEditor():this.hide()},this)))).append(this.$image_list).append(this.$progress_bar).click(function(a){a.stopPropagation()}).find("*").click(function(a){a.stopPropagation()}).end().hide()},b.prototype.buildInsertVideo=function(){this.$video_wrapper=a("").addClass("video-wrapper"),this.$popup_editor.append(this.$video_wrapper);var b=a('').on("mouseup touchend keydown",a.proxy(function(a){a.stopPropagation()},this)),c=a("").append(a('OK').click(a.proxy(function(){this.restoreSelection(),a(this.getSelectionElements()[0]).after(this.options.paragraphy?''+b.val()+"":''+b.val()+""),this.saveUndoStep(),this.$bttn_wrapper.show(),this.hideVideoWrapper(),this.hide(),this.callback("insertVideo",[b.val()])},this)));this.$video_wrapper.append(a("").append('Insert video').append(a('').click(a.proxy(function(){this.$bttn_wrapper.show(),this.hideVideoWrapper(),this.restoreSelection(),this.options.inlineMode||this.hide()},this)))).append(b).append(c).click(function(a){a.stopPropagation()}).find("*").click(function(a){a.stopPropagation()}).end().hide()},b.prototype.buildCreateLink=function(){this.$link_wrapper=a("").addClass("link-wrapper"),this.$popup_editor.append(this.$link_wrapper);var b=a('').attr("placeholder","http://www.example.com").on("mouseup touchend keydown",function(a){a.stopPropagation()}),c=a('').click(function(a){a.stopPropagation()}),d=a('').text("OK").on("touchend",function(a){a.stopPropagation()}).click(a.proxy(function(){this.writeLink(b.val(),c.prop("checked"))},this)),e=a('').text("UNLINK").on("click touch",a.proxy(function(){this.link=!0,this.writeLink("",c.prop("checked"))},this));this.$link_wrapper.append(a("").append('Insert link').append(a('').click(a.proxy(function(){this.$bttn_wrapper.show(),this.hideLinkWrapper(),this.options.inlineMode||this.imageMode?this.imageMode&&this.showImageEditor():this.hide(),this.restoreSelection()},this)))).append(b).append(a("").append(c).append(' Open in new tab').append(d).append(e)).end().hide()},b.prototype.buildDragUpload=function(b){var c=this;b.on({dragover:function(){return a(this).addClass("f-hover"),!1},dragend:function(){return a(this).removeClass("f-hover"),!1},drop:function(b){a(this).removeClass("f-hover"),b.preventDefault(),c.uploadFile(b.originalEvent.dataTransfer.files)}})},b.prototype.hideImageLoader=function(){this.$progress_bar.hide(),this.$progress_bar.find("span").css("width","0%").text(""),this.$image_list.show()},b.prototype.writeImage=function(b){var c=new Image;if(c.onerror=a.proxy(function(){this.hideImageLoader(),this.throwImageError(1)},this),this.imageMode)return c.onload=a.proxy(function(){this.$element.find(".f-img-editor > img").attr("src",b),this.hide(),this.hideImageLoader(),this.$image_editor.show(),this.saveUndoStep(),this.callback("replaceImage",[b])},this),c.src=b,!1;var d=this.getSelectionElements()[0];c.onload=a.proxy(function(){a(d).prepend(''),a(d).find("img:first").get(0).oncontrolselect=function(){return!1},this.hide(),this.hideImageLoader(),this.saveUndoStep(),this.callback("insertImage",[b])},this),c.src=b},b.prototype.throwImageError=function(b){var c="Unknown image upload error.";1==b?c="Bad link.":2==b?c="No link in upload response.":3==b?c="Error during file upload.":4==b&&(c="Parsing response failed."),this.options.imageErrorCallback&&a.isFunction(this.options.imageErrorCallback)&&this.options.imageErrorCallback({errorCode:b,errorStatus:c})},b.prototype.uploadFile=function(b){if(void 0!==b&&b.length>0){var c;if(this.drag_support.formdata&&(c=this.drag_support.formdata?new FormData:null),c&&c.append(this.options.imageUploadParam,b[0]),c){var d;this.options.crossDomain?d=this.createCORSRequest("POST",this.options.imageUploadURL):(d=new XMLHttpRequest,d.open("POST",this.options.imageUploadURL)),d.onload=a.proxy(function(){this.$progress_bar.find("span").css("width","100%").text("Please wait!");try{200==d.status?this.parseImageResponse(d.responseText):this.throwImageError(3)}catch(a){this.throwImageError(4)}this.hideImageLoader()},this),d.onerror=a.proxy(function(){this.throwImageError(3),this.hideImageLoader()},this),d.upload.onprogress=a.proxy(function(a){if(a.lengthComputable){var b=a.loaded/a.total*100|0;this.$progress_bar.find("span").css("width",b+"%")}},this);for(var e in this.options.imageParams)c.append(e,this.options.imageParams[e]);d.send(c),this.$image_list.hide(),this.$progress_bar.show()}}},b.prototype.parseImageResponse=function(b){try{var c=a.parseJSON(b);"http://uploads.im/api"==this.options.imageUploadURL?this.writeImage(c.data.img_url):c.link?this.writeImage(c.link):this.throwImageError(2)}catch(d){this.throwImageError(4)}},b.prototype.createCORSRequest=function(a,b){var c=new XMLHttpRequest;return"withCredentials"in c?c.open(a,b,!0):"undefined"!=typeof XDomainRequest?(c=new XDomainRequest,c.open(a,b)):c=null,c},b.prototype.writeLink=function(b,c){if(this.imageMode)return""!==b?("A"!=this.$element.find(".f-img-editor").parent().get(0).tagName?this.$element.find(".f-img-editor").wrap(c===!0?'':''):c===!0?this.$element.find(".f-img-editor").parent().attr("target","_blank"):(this.$element.find(".f-img-editor").parent().removeAttr("target"),this.$element.find(".f-img-editor").parent().attr("href",b)),this.callback("insertImageLink",[b])):("A"==this.$element.find(".f-img-editor").parent().get(0).tagName&&a(this.$element.find(".f-img-editor").get(0)).unwrap(),this.callback("removeImageLink")),this.saveUndoStep(),this.showImageEditor(),this.$element.find(".f-img-editor").find("img").click(),this.link=!1,!1;if(this.restoreSelection(),document.execCommand("unlink",!1,b),this.saveSelectionByMarkers(),this.$element.find("span.f-link").each(function(b,c){a(c).replaceWith(a(c).html())}),this.restoreSelectionByMarkers(),""!==b){document.execCommand("createLink",!1,b);for(var d=this.getSelectionLinks(),e=0;e-1&&e.push(c[h])}d.detach()}}else if(document.selection&&"Control"!=document.selection.type)if(a=document.selection.createRange(),b=a.parentElement(),"a"==b.nodeName.toLowerCase())e.push(b);else{c=b.getElementsByTagName("a"),d=document.body.createTextRange();for(var i=0;i-1&&d.compareEndPoints("EndToStart",a)<1&&e.push(c[i])}return e},b.prototype.isEnabled=function(b){return a.inArray(b,this.options.buttons)>=0},b.prototype.show=function(b){if(void 0!==b){if(this.options.inlineMode)if(null!==b&&"touchend"!==b.type){var c=b.pageX,d=b.pageY;20>c&&(c=20),0>d&&(d=0),c+this.$editor.width()>a(window).width()-50?(this.$editor.addClass("right-side"),c=a(window).width()-(c+30),this.$editor.css("top",d+20),this.$editor.css("right",c),this.$editor.css("left","auto")):(this.$editor.removeClass("right-side"),this.$editor.css("top",d+20),this.$editor.css("left",c-20),this.$editor.css("right","auto")),a(".froala-editor:not(.f-basic)").hide(),this.$editor.show()}else a(".froala-editor:not(.f-basic)").hide(),this.$editor.show(),this.repositionEditor();this.hideLinkWrapper(),this.hideVideoWrapper(),this.hideImageWrapper(),this.$bttn_wrapper.show(),this.$bttn_wrapper.find(".fr-dropdown").removeClass("active"),this.refreshButtons(),this.imageMode=!1}},b.prototype.showByCoordinates=function(b,c){b-=20,c+=15,b+this.$popup_editor.width()>a(window).width()-50?(this.$popup_editor.addClass("right-side"),b=a(window).width()-(b+40),this.$popup_editor.css("top",c),this.$popup_editor.css("right",b),this.$popup_editor.css("left","auto")):(this.$popup_editor.removeClass("right-side"),this.$popup_editor.css("top",c),this.$popup_editor.css("left",b),this.$popup_editor.css("right","auto")),this.$popup_editor.show()},b.prototype.showLinkWrapper=function(){this.$link_wrapper&&this.$link_wrapper.show()},b.prototype.hideLinkWrapper=function(){this.$link_wrapper&&this.$link_wrapper.hide()},b.prototype.showImageWrapper=function(){this.$image_wrapper&&this.$image_wrapper.show()},b.prototype.showVideoWrapper=function(){this.$video_wrapper&&this.$video_wrapper.show()},b.prototype.hideImageWrapper=function(a){this.$image_wrapper&&(this.$element.attr("data-resize")||a||this.closeImageMode(),this.$image_wrapper.hide())},b.prototype.hideVideoWrapper=function(){this.$video_wrapper&&this.$video_wrapper.hide()},b.prototype.showInsertLink=function(){this.options.inlineMode&&this.$bttn_wrapper.hide(),this.showLinkWrapper(),this.hideImageWrapper(!0),this.hideVideoWrapper(),this.$image_editor.hide(),this.link=!0},b.prototype.showInsertImage=function(){this.options.inlineMode&&this.$bttn_wrapper.hide(),this.hideLinkWrapper(),this.hideVideoWrapper(),this.showImageWrapper(),this.$image_editor.hide()},b.prototype.showInsertVideo=function(){this.options.inlineMode&&this.$bttn_wrapper.hide(),this.hideLinkWrapper(),this.hideImageWrapper(),this.showVideoWrapper(),this.$image_editor.hide()},b.prototype.showImageEditor=function(){this.options.inlineMode&&this.$bttn_wrapper.hide(),this.hideLinkWrapper(),this.hideImageWrapper(!0),this.hideVideoWrapper(),this.$image_editor.show(),this.options.imageMove||this.$element.attr("contenteditable",!1)},b.prototype.hide=function(){this.$popup_editor.hide(),this.hideLinkWrapper(),this.hideImageWrapper(),this.hideVideoWrapper(),this.$image_editor.hide(),this.link=!1},b.prototype.positionPopup=function(b){a(this.$editor.find('button.fr-bttn[data-cmd="'+b+'"]')).length&&(this.$popup_editor.css("top",this.$editor.find('button.fr-bttn[data-cmd="'+b+'"]').offset().top+30),this.$popup_editor.css("left",this.$editor.find('button.fr-bttn[data-cmd="'+b+'"]').offset().left),this.$popup_editor.show())},b.prototype.bindButtonEvents=function(){this.bindDropdownEvents(),this.bindCommandEvents()},b.prototype.bindDropdownEvents=function(){var b=this;this.$bttn_wrapper.find(".fr-dropdown").on("click touchend",function(c){return c.stopPropagation(),c.preventDefault(),0==b.options.inlineMode&&b.hide(),a(this).attr("data-disabled")?!1:(a(".fr-dropdown").not(this).removeClass("active"),void a(this).toggleClass("active"))}),a(window).on("click touchend",a.proxy(function(){this.$editor.find(".fr-dropdown").removeClass("active")},this)),this.$element.on("click touchend","img, a",a.proxy(function(){this.$editor.find(".fr-dropdown").removeClass("active")},this));var c=this.$bttn_wrapper.find(".fr-selector button.fr-bttn");c.bind("select",function(){a(this).parents(".fr-selector").find(" > button > i").attr("class",a(this).find("i").attr("class"))}).on("click touch",function(){a(this).parents("ul").find("button").removeClass("active"),a(this).parents(".fr-selector").removeClass("active").trigger("mouseout"),a(this).trigger("select")})},b.prototype.bindCommandEvents=function(){this.$bttn_wrapper.find("[data-cmd]").on("click touchend",a.proxy(function(b){b.stopPropagation(),b.preventDefault();var c=b.currentTarget,d=a(c).data("cmd"),e=a(c).data("val");a(c).parents(".fr-dropdown").removeClass("active"),this.exec(d,e),this.$bttn_wrapper.find(".fr-dropdown").removeClass("active")},this))},b.prototype.exec=function(a,b){if(!this.selectionInEditor()&&"html"!==a&&"undo"!==a&&"redo"!==a&&"selectAll"!==a&&"save"!=a&&"insertImage"!==a&&"insertVideo"!==a)return!1;if(this.selectionInEditor()&&""===this.text()&&"fontSize"!==a&&"formatBlock"!==a&&"indent"!==a&&"outdent"!==a&&"justifyLeft"!==a&&"justifyRight"!==a&&"justifyFull"!==a&&"justifyCenter"!==a&&"html"!==a&&"undo"!==a&&"redo"!==a&&"selectAll"!==a&&"save"!==a&&"insertImage"!==a&&"insertVideo"!==a&&"insertOrderedList"!==a&&"insertUnorderedList"!==a)return!1;switch(a){case"fontSize":this.fontSize(b);break;case"backColor":this.backColor(b);break;case"foreColor":this.foreColor(b);break;case"formatBlock":this.formatBlock(b);break;case"createLink":this.insertLink();break;case"insertImage":this.insertImage();break;case"indent":this.indent();break;case"outdent":this.outdent(!0);break;case"justifyLeft":case"justifyRight":case"justifyCenter":case"justifyFull":this.align(a);break;case"insertOrderedList":case"insertUnorderedList":this.formatList(a);break;case"insertVideo":this.insertVideo();break;case"indent":case"outdent":this.execDefault(a,b),this.repositionEditor();break;case"undo":this.undo();break;case"redo":this.redo();break;case"html":this.html();break;case"save":this.save();break;case"selectAll":this.$element.focus(),this.execDefault(a,b);break;default:this.execDefault(a,b)}"undo"!=a&&"redo"!=a&&"selectAll"!=a&&"createLink"!=a&&"insertImage"!=a&&"html"!=a&&"insertVideo"!=a&&this.saveUndoStep(),"createLink"!=a&&"insertImage"!=a&&this.refreshButtons()},b.prototype.undo=function(){if(this.undoIndex>1){var a=this.getHTML();this.$element.html(this.undoStack[--this.undoIndex-1]),this.hide(),this.callback("undo",[this.$element.html(),a])}this.refreshUndoRedo()},b.prototype.redo=function(){if(this.undoIndex").attr("data-font",!0).css("font-size",b).html(a(e).html());0===a(e).parents("font").length&&c.push(f),a(e).replaceWith(f)});var d=function(b,c){a(c).css("font-size","")};for(var e in c){var f=c[e];a(f).find("*").each(d)}this.$element.find('span[data-font="true"] > span[data-font="true"]').each(function(b,c){a(c).attr("style")&&(a(c).before(''),a(c).after(''))});var g=this.$element.html();g=g.replace(new RegExp('',"g"),""),g=g.replace(new RegExp('data-open="true">',"g"),">"),this.$element.html(g);for(var h=!0,i=a.proxy(function(){this.$element.find('span[data-font="true"] + span[data-font="true"]').each(function(b,c){a(c).css("font-size")==a(c).prev().css("font-size")&&(a(c).prepend(a(c).prev().html()),a(c).prev().remove(),h=!0)}),this.$element.find('span[data-font="true"] + span#marker-true + span[data-font="true"], span[data-font="true"] + span#marker-true + span[data-font="true"]').each(function(b,c){a(c).css("font-size")==a(c).prev().prev().css("font-size")&&(a(c).prepend(a(c).prev().clone()),a(c).prepend(a(c).prev().prev().html()),a(c).prev().prev().remove(),a(c).prev().remove(),h=!0)})},this);h;)h=!1,i();this.$element.find('span[style=""]').each(function(b,c){a(c).replaceWith(a(c).html())}),this.$element.find("span[data-font]").each(function(b,c){a(c).css("font-size")==a(c).parent().css("font-size")&&a(c).replaceWith(a(c).html())}),this.restoreSelectionByMarkers(),this.repositionEditor(),this.callback("fontSize")},b.prototype.backColor=function(c){var d="backColor";this.browser.msie||(d="hiliteColor");var e=a(this.getSelectionElement()).css("background-color");document.execCommand(d,!1,c);var f=this.$editor.find('button.fr-color-bttn[data-cmd="backColor"][data-val="'+c+'"]');f.addClass("active"),f.siblings().removeClass("active"),this.callback("backColor",[b.hexToRGBString(c),e])},b.prototype.foreColor=function(c){var d=a(this.getSelectionElement()).css("color");document.execCommand("foreColor",!1,c),this.saveSelectionByMarkers(),this.$element.find("font[color]").each(function(b,d){a(d).replaceWith(a("").css("color",c).html(a(d).html()))}),this.restoreSelectionByMarkers();var e=this.$editor.find('button.fr-color-bttn[data-cmd="foreColor"][data-val="'+c+'"]');e.addClass("active"),e.siblings().removeClass("active"),this.callback("foreColor",[b.hexToRGBString(c),d])},b.prototype.formatBlock=function(b){if(this.disabledList.indexOf("formatBlock")>=0)return!1;this.saveSelectionByMarkers(),this.wrapText(),this.restoreSelectionByMarkers();var c,d=this.getSelectionElements();for(var e in d){var f=a(d[e]);if(c="n"==b?a("").html(f.html()):a("<"+b+">").html(f.html()),f.get(0)!=this.$element.get(0)&&"LI"!=f.get(0).tagName){var g=f.prop("attributes");if(c.attr)for(var h in g)c.attr(g[h].name,g[h].value);f.replaceWith(c)}else f.html(c)}this.clearSelection(),this.hide(),this.callback("formatBlock")},b.prototype.formatList=function(b){this.saveSelectionByMarkers();var c,d=this.getSelectionElements(),e=!0,f=!1;for(var g in d)c=a(d[g]),c.parents("li").length>0?(c.parents("ol").length>0?(c.parents("li").before(''),c.parents("li").after('')):c.parents("ul").length>0&&(c.parents("li").before(''),c.parents("li").after('')),c.parents("li").replaceWith(c.parents("li").contents()),f=!0):e=!1;if(f){var h=this.$element.html();h=h.replace(new RegExp('',"g"),""),h=h.replace(new RegExp('',"g"),""),h=h.replace(new RegExp('',"g"),""),h=h.replace(new RegExp('',"g"),""),this.$element.html(h),this.$element.find("ul:empty, ol:empty").remove()}if(this.clearSelection(),this.wrapText(),this.restoreSelectionByMarkers(),e===!1){d=this.getSelectionElements(),this.saveSelectionByMarkers();var i=a("");"insertUnorderedList"==b&&(i=a(""));for(var j in d)c=a(d[j]),c.get(0)!=this.$element.get(0)&&(i.append(a("").append(c.clone())),j!=d.length-1?c.remove():c.replaceWith(i));this.restoreSelectionByMarkers()}this.repositionEditor(),this.callback(b)},b.prototype.align=function(b){var c=this.getSelectionElements();this.saveSelection(),"justifyLeft"==b?b="left":"justifyRight"==b?b="right":"justifyCenter"==b?b="center":"justifyFull"==b&&(b="justify");for(var d in c)a(c[d]).css("text-align",b);this.restoreSelection(),this.repositionEditor(),this.callback("align")},b.prototype.indent=function(b){var c=20;b&&(c=-20),this.saveSelectionByMarkers(),this.wrapText(),this.restoreSelectionByMarkers();var d=this.getSelectionElements();this.saveSelectionByMarkers();for(var e in d){var f=a(d[e]);if(f.get(0)!=this.$element.get(0)){var g=parseInt(f.css("margin-left").replace(/px/,""),10),h=Math.max(0,g+c);f.css("marginLeft",h)}else{var i=a("").html(f.html());f.html(i),i.css("marginLeft",Math.max(0,c))}}this.restoreSelectionByMarkers(),this.repositionEditor(),b||this.callback("indent")},b.prototype.outdent=function(){this.indent(!0),this.callback("outdent")},b.prototype.insertLink=function(){this.showInsertLink(),this.options.inlineMode||this.positionPopup("createLink"),this.saveSelection();var b=this.getSelectionLink(),c=this.getSelectionLinks();c.length>0&&this.$link_wrapper.find('input[type="checkbox"]').prop("checked","_blank"==a(c[0]).attr("target")),this.$link_wrapper.find('input[type="text"]').val(b||"http://")},b.prototype.insertImage=function(){this.showInsertImage(),this.saveSelection(),this.options.inlineMode||this.positionPopup("insertImage"),this.$image_wrapper.find('input[type="text"]').val("")},b.prototype.insertVideo=function(){this.showInsertVideo(),this.saveSelection(),this.options.inlineMode||this.positionPopup("insertVideo"),this.$video_wrapper.find("textarea").val("")},b.prototype.execDefault=function(a,b){document.execCommand(a,!1,b),"insertOrderedList"==a?this.$bttn_wrapper.find('[data-cmd="insertUnorderedList"]').removeClass("active"):"insertUnorderedList"==a&&this.$bttn_wrapper.find('[data-cmd="insertOrderedList"]').removeClass("active"),this.callback(a)},b.prototype.refreshButtons=function(){return!this.selectionInEditor()||this.isHTML?!1:(this.refreshUndoRedo(),void this.$bttn_wrapper.find("[data-cmd]").each(a.proxy(function(b,c){switch(a(c).data("cmd")){case"fontSize":this.refreshFontSize(c);break;case"backColor":this.refreshBackColor(c);break;case"foreColor":this.refreshForeColor(c);break;case"formatBlock":this.refreshFormatBlock(c);break;case"createLink":case"insertImage":break;case"justifyLeft":case"justifyRight":case"justifyCenter":case"justifyFull":this.refreshAlign(c);break;case"html":this.isHTML?a(c).addClass("active"):a(c).removeClass("active");break;case"undo":case"redo":case"save":break;default:this.refreshDefault(c)}},this)))},b.prototype.refreshFormatBlock=function(b){this.disabledList.indexOf("formatBlock")>=0&&a(b).parents(".fr-dropdown").attr("data-disabled",!0)},b.prototype.refreshUndoRedo=function(){if(this.isEnabled("undo")||this.isEnabled("redo")){if(void 0===this.$editor)return;this.$bttn_wrapper.find('[data-cmd="undo"], [data-cmd="redo"]').prop("disabled",!1),(0===this.undoStack.length||this.undoIndex<=1||this.isHTML)&&this.$bttn_wrapper.find('[data-cmd="undo"]').prop("disabled",!0),(this.undoIndex==this.undoStack.length||this.isHTML)&&this.$bttn_wrapper.find('[data-cmd="redo"]').prop("disabled",!0)}},b.prototype.refreshDefault=function(b){a(b).removeClass("active");try{document.queryCommandState(a(b).data("cmd"))===!0&&a(b).addClass("active")}catch(c){}},b.prototype.refreshAlign=function(b){var c=a(b).data("cmd"),d=this.getSelectionElements();"justifyLeft"==c?c="left":"justifyRight"==c?c="right":"justifyCenter"==c?c="center":"justifyFull"==c&&(c="justify"),c==a(d[0]).css("text-align")&&(a(b).parents("ul").find(".fr-bttn").removeClass("active"),a(b).addClass("active"),a(b).parents(".fr-dropdown").find(".fr-trigger").html(a(b).html()))},b.prototype.refreshForeColor=function(b){a(b).removeClass("active"),document.queryCommandValue("foreColor")==b.style.backgroundColor&&a(b).addClass("active")},b.prototype.refreshBackColor=function(b){a(b).removeClass("active"),document.queryCommandValue("backColor")==b.style.backgroundColor&&a(b).addClass("active")},b.prototype.refreshFontSize=function(b){a(b).removeClass("active"),parseInt(document.queryCommandValue("fontSize"),10)==parseInt(a(b).data("val"),10)&&a(b).addClass("active") },b.prototype.option=function(b,c){if(void 0===b)return this.options;if(b instanceof Object)this.options=a.extend({},this.options,b),this.initOptions(),this.setCustomText(),this.setLanguage();else{if(void 0===c)return this.options[b];switch(this.options[b]=c,b){case"borderColor":this.setBorderColor();break;case"direction":this.setDirection();break;case"height":case"width":this.setDimensions();break;case"spellcheck":this.setSpellcheck();break;case"placeholder":this.setPlaceholder();break;case"customText":this.setCustomText();break;case"inverseSkin":this.setInverseSkin();break;case"language":this.setLanguage()}}};var c=a.fn.editable;a.fn.editable=function(c){for(var d=[],e=0;ee*e+f*f||v(a,b,c,e,f,d)}function t(){return this._handled=d,!1}function u(a){try{a._handled()}catch(b){return!1}}function v(a,b,c,d,e,f){{var g,h;b.target}g=a.targetTouches,h=a.timeStamp-b.timeStamp,b.type="movestart",b.distX=d,b.distY=e,b.deltaX=d,b.deltaY=e,b.pageX=c.pageX,b.pageY=c.pageY,b.velocityX=d/h,b.velocityY=e/h,b.targetTouches=g,b.finger=g?g.length:1,b._handled=t,b._preventTouchmoveDefault=function(){a.preventDefault()},L(b.target,b),f(b.identifier)}function w(a){var b=a.data.timer;a.data.touch=a,a.data.timeStamp=a.timeStamp,b.kick()}function x(a){var b=a.data.event,c=a.data.timer;y(),D(b,c,function(){setTimeout(function(){K(b.target,"click",e)},0)})}function y(){K(document,O.move,w),K(document,O.end,x)}function z(a){var b=a.data.event,c=a.data.timer,d=j(a,b);d&&(a.preventDefault(),b.targetTouches=a.targetTouches,a.data.touch=d,a.data.timeStamp=a.timeStamp,c.kick())}function A(a){var b=a.data.event,c=a.data.timer,d=i(a.changedTouches,b.identifier);d&&(B(b),D(b,c))}function B(a){K(document,"."+a.identifier,z),K(document,"."+a.identifier,A)}function C(a,b,c){var d=c-a.timeStamp;a.type="move",a.distX=b.pageX-a.startX,a.distY=b.pageY-a.startY,a.deltaX=b.pageX-a.pageX,a.deltaY=b.pageY-a.pageY,a.velocityX=.3*a.velocityX+.7*a.deltaX/d,a.velocityY=.3*a.velocityY+.7*a.deltaY/d,a.pageX=b.pageX,a.pageY=b.pageY}function D(a,b,c){b.end(function(){return a.type="moveend",L(a.target,a),c&&c()})}function E(){return J(this,"movestart.move",u),!0}function F(){return K(this,"dragstart drag",f),K(this,"mousedown touchstart",g),K(this,"movestart",u),!0}function G(a){"move"!==a.namespace&&"moveend"!==a.namespace&&(J(this,"dragstart."+a.guid+" drag."+a.guid,f,b,a.selector),J(this,"mousedown."+a.guid,g,b,a.selector))}function H(a){"move"!==a.namespace&&"moveend"!==a.namespace&&(K(this,"dragstart."+a.guid+" drag."+a.guid),K(this,"mousedown."+a.guid))}var I=6,J=a.event.add,K=a.event.remove,L=function(b,c,d){a.event.trigger(c,d,b)},M=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){return window.setTimeout(function(){a()},25)}}(),N={textarea:!0,input:!0,select:!0,button:!0},O={move:"mousemove",cancel:"mouseup dragstart",end:"mouseup"},P={move:"touchmove",cancel:"touchend",end:"touchend"};a.event.special.movestart={setup:E,teardown:F,add:G,remove:H,_default:function(a){function d(){C(f,g.touch,g.timeStamp),L(a.target,f)}var f,g;a._handled()&&(f={target:a.target,startX:a.startX,startY:a.startY,pageX:a.pageX,pageY:a.pageY,distX:a.distX,distY:a.distY,deltaX:a.deltaX,deltaY:a.deltaY,velocityX:a.velocityX,velocityY:a.velocityY,timeStamp:a.timeStamp,identifier:a.identifier,targetTouches:a.targetTouches,finger:a.finger},g={event:f,timer:new c(d),touch:b,timeStamp:b},a.identifier===b?(J(a.target,"click",e),J(document,O.move,w,g),J(document,O.end,x,g)):(a._preventTouchmoveDefault(),J(document,P.move+"."+a.identifier,z,g),J(document,P.end+"."+a.identifier,A,g)))}},a.event.special.move={setup:function(){J(this,"movestart.move",a.noop)},teardown:function(){K(this,"movestart.move",a.noop)}},a.event.special.moveend={setup:function(){J(this,"movestart.moveend",a.noop)},teardown:function(){K(this,"movestart.moveend",a.noop)}},J(document,"mousedown.move",k),J(document,"touchstart.move",o),"function"==typeof Array.prototype.indexOf&&!function(a){for(var b=["changedTouches","targetTouches"],c=b.length;c--;)-1===a.event.props.indexOf(b[c])&&a.event.props.push(b[c])}(a)}),+function(a){function b(a,b,c,d){if(a.tag.format&&c.length>0){c.push("\n");for(var e=0;d>e;e++)c.push(" ")}}function c(d,e){var f=[],g=0==d.attributes.length,h=0;if(d.tag.isComment)e.allowComments&&(f.push("
").append(c).append(' Open in new tab').append(d).append(e)).end().hide()},b.prototype.buildDragUpload=function(b){var c=this;b.on({dragover:function(){return a(this).addClass("f-hover"),!1},dragend:function(){return a(this).removeClass("f-hover"),!1},drop:function(b){a(this).removeClass("f-hover"),b.preventDefault(),c.uploadFile(b.originalEvent.dataTransfer.files)}})},b.prototype.hideImageLoader=function(){this.$progress_bar.hide(),this.$progress_bar.find("span").css("width","0%").text(""),this.$image_list.show()},b.prototype.writeImage=function(b){var c=new Image;if(c.onerror=a.proxy(function(){this.hideImageLoader(),this.throwImageError(1)},this),this.imageMode)return c.onload=a.proxy(function(){this.$element.find(".f-img-editor > img").attr("src",b),this.hide(),this.hideImageLoader(),this.$image_editor.show(),this.saveUndoStep(),this.callback("replaceImage",[b])},this),c.src=b,!1;var d=this.getSelectionElements()[0];c.onload=a.proxy(function(){a(d).prepend(''),a(d).find("img:first").get(0).oncontrolselect=function(){return!1},this.hide(),this.hideImageLoader(),this.saveUndoStep(),this.callback("insertImage",[b])},this),c.src=b},b.prototype.throwImageError=function(b){var c="Unknown image upload error.";1==b?c="Bad link.":2==b?c="No link in upload response.":3==b?c="Error during file upload.":4==b&&(c="Parsing response failed."),this.options.imageErrorCallback&&a.isFunction(this.options.imageErrorCallback)&&this.options.imageErrorCallback({errorCode:b,errorStatus:c})},b.prototype.uploadFile=function(b){if(void 0!==b&&b.length>0){var c;if(this.drag_support.formdata&&(c=this.drag_support.formdata?new FormData:null),c&&c.append(this.options.imageUploadParam,b[0]),c){var d;this.options.crossDomain?d=this.createCORSRequest("POST",this.options.imageUploadURL):(d=new XMLHttpRequest,d.open("POST",this.options.imageUploadURL)),d.onload=a.proxy(function(){this.$progress_bar.find("span").css("width","100%").text("Please wait!");try{200==d.status?this.parseImageResponse(d.responseText):this.throwImageError(3)}catch(a){this.throwImageError(4)}this.hideImageLoader()},this),d.onerror=a.proxy(function(){this.throwImageError(3),this.hideImageLoader()},this),d.upload.onprogress=a.proxy(function(a){if(a.lengthComputable){var b=a.loaded/a.total*100|0;this.$progress_bar.find("span").css("width",b+"%")}},this);for(var e in this.options.imageParams)c.append(e,this.options.imageParams[e]);d.send(c),this.$image_list.hide(),this.$progress_bar.show()}}},b.prototype.parseImageResponse=function(b){try{var c=a.parseJSON(b);"http://uploads.im/api"==this.options.imageUploadURL?this.writeImage(c.data.img_url):c.link?this.writeImage(c.link):this.throwImageError(2)}catch(d){this.throwImageError(4)}},b.prototype.createCORSRequest=function(a,b){var c=new XMLHttpRequest;return"withCredentials"in c?c.open(a,b,!0):"undefined"!=typeof XDomainRequest?(c=new XDomainRequest,c.open(a,b)):c=null,c},b.prototype.writeLink=function(b,c){if(this.imageMode)return""!==b?("A"!=this.$element.find(".f-img-editor").parent().get(0).tagName?this.$element.find(".f-img-editor").wrap(c===!0?'':''):c===!0?this.$element.find(".f-img-editor").parent().attr("target","_blank"):(this.$element.find(".f-img-editor").parent().removeAttr("target"),this.$element.find(".f-img-editor").parent().attr("href",b)),this.callback("insertImageLink",[b])):("A"==this.$element.find(".f-img-editor").parent().get(0).tagName&&a(this.$element.find(".f-img-editor").get(0)).unwrap(),this.callback("removeImageLink")),this.saveUndoStep(),this.showImageEditor(),this.$element.find(".f-img-editor").find("img").click(),this.link=!1,!1;if(this.restoreSelection(),document.execCommand("unlink",!1,b),this.saveSelectionByMarkers(),this.$element.find("span.f-link").each(function(b,c){a(c).replaceWith(a(c).html())}),this.restoreSelectionByMarkers(),""!==b){document.execCommand("createLink",!1,b);for(var d=this.getSelectionLinks(),e=0;e-1&&e.push(c[h])}d.detach()}}else if(document.selection&&"Control"!=document.selection.type)if(a=document.selection.createRange(),b=a.parentElement(),"a"==b.nodeName.toLowerCase())e.push(b);else{c=b.getElementsByTagName("a"),d=document.body.createTextRange();for(var i=0;i-1&&d.compareEndPoints("EndToStart",a)<1&&e.push(c[i])}return e},b.prototype.isEnabled=function(b){return a.inArray(b,this.options.buttons)>=0},b.prototype.show=function(b){if(void 0!==b){if(this.options.inlineMode)if(null!==b&&"touchend"!==b.type){var c=b.pageX,d=b.pageY;20>c&&(c=20),0>d&&(d=0),c+this.$editor.width()>a(window).width()-50?(this.$editor.addClass("right-side"),c=a(window).width()-(c+30),this.$editor.css("top",d+20),this.$editor.css("right",c),this.$editor.css("left","auto")):(this.$editor.removeClass("right-side"),this.$editor.css("top",d+20),this.$editor.css("left",c-20),this.$editor.css("right","auto")),a(".froala-editor:not(.f-basic)").hide(),this.$editor.show()}else a(".froala-editor:not(.f-basic)").hide(),this.$editor.show(),this.repositionEditor();this.hideLinkWrapper(),this.hideVideoWrapper(),this.hideImageWrapper(),this.$bttn_wrapper.show(),this.$bttn_wrapper.find(".fr-dropdown").removeClass("active"),this.refreshButtons(),this.imageMode=!1}},b.prototype.showByCoordinates=function(b,c){b-=20,c+=15,b+this.$popup_editor.width()>a(window).width()-50?(this.$popup_editor.addClass("right-side"),b=a(window).width()-(b+40),this.$popup_editor.css("top",c),this.$popup_editor.css("right",b),this.$popup_editor.css("left","auto")):(this.$popup_editor.removeClass("right-side"),this.$popup_editor.css("top",c),this.$popup_editor.css("left",b),this.$popup_editor.css("right","auto")),this.$popup_editor.show()},b.prototype.showLinkWrapper=function(){this.$link_wrapper&&this.$link_wrapper.show()},b.prototype.hideLinkWrapper=function(){this.$link_wrapper&&this.$link_wrapper.hide()},b.prototype.showImageWrapper=function(){this.$image_wrapper&&this.$image_wrapper.show()},b.prototype.showVideoWrapper=function(){this.$video_wrapper&&this.$video_wrapper.show()},b.prototype.hideImageWrapper=function(a){this.$image_wrapper&&(this.$element.attr("data-resize")||a||this.closeImageMode(),this.$image_wrapper.hide())},b.prototype.hideVideoWrapper=function(){this.$video_wrapper&&this.$video_wrapper.hide()},b.prototype.showInsertLink=function(){this.options.inlineMode&&this.$bttn_wrapper.hide(),this.showLinkWrapper(),this.hideImageWrapper(!0),this.hideVideoWrapper(),this.$image_editor.hide(),this.link=!0},b.prototype.showInsertImage=function(){this.options.inlineMode&&this.$bttn_wrapper.hide(),this.hideLinkWrapper(),this.hideVideoWrapper(),this.showImageWrapper(),this.$image_editor.hide()},b.prototype.showInsertVideo=function(){this.options.inlineMode&&this.$bttn_wrapper.hide(),this.hideLinkWrapper(),this.hideImageWrapper(),this.showVideoWrapper(),this.$image_editor.hide()},b.prototype.showImageEditor=function(){this.options.inlineMode&&this.$bttn_wrapper.hide(),this.hideLinkWrapper(),this.hideImageWrapper(!0),this.hideVideoWrapper(),this.$image_editor.show(),this.options.imageMove||this.$element.attr("contenteditable",!1)},b.prototype.hide=function(){this.$popup_editor.hide(),this.hideLinkWrapper(),this.hideImageWrapper(),this.hideVideoWrapper(),this.$image_editor.hide(),this.link=!1},b.prototype.positionPopup=function(b){a(this.$editor.find('button.fr-bttn[data-cmd="'+b+'"]')).length&&(this.$popup_editor.css("top",this.$editor.find('button.fr-bttn[data-cmd="'+b+'"]').offset().top+30),this.$popup_editor.css("left",this.$editor.find('button.fr-bttn[data-cmd="'+b+'"]').offset().left),this.$popup_editor.show())},b.prototype.bindButtonEvents=function(){this.bindDropdownEvents(),this.bindCommandEvents()},b.prototype.bindDropdownEvents=function(){var b=this;this.$bttn_wrapper.find(".fr-dropdown").on("click touchend",function(c){return c.stopPropagation(),c.preventDefault(),0==b.options.inlineMode&&b.hide(),a(this).attr("data-disabled")?!1:(a(".fr-dropdown").not(this).removeClass("active"),void a(this).toggleClass("active"))}),a(window).on("click touchend",a.proxy(function(){this.$editor.find(".fr-dropdown").removeClass("active")},this)),this.$element.on("click touchend","img, a",a.proxy(function(){this.$editor.find(".fr-dropdown").removeClass("active")},this));var c=this.$bttn_wrapper.find(".fr-selector button.fr-bttn");c.bind("select",function(){a(this).parents(".fr-selector").find(" > button > i").attr("class",a(this).find("i").attr("class"))}).on("click touch",function(){a(this).parents("ul").find("button").removeClass("active"),a(this).parents(".fr-selector").removeClass("active").trigger("mouseout"),a(this).trigger("select")})},b.prototype.bindCommandEvents=function(){this.$bttn_wrapper.find("[data-cmd]").on("click touchend",a.proxy(function(b){b.stopPropagation(),b.preventDefault();var c=b.currentTarget,d=a(c).data("cmd"),e=a(c).data("val");a(c).parents(".fr-dropdown").removeClass("active"),this.exec(d,e),this.$bttn_wrapper.find(".fr-dropdown").removeClass("active")},this))},b.prototype.exec=function(a,b){if(!this.selectionInEditor()&&"html"!==a&&"undo"!==a&&"redo"!==a&&"selectAll"!==a&&"save"!=a&&"insertImage"!==a&&"insertVideo"!==a)return!1;if(this.selectionInEditor()&&""===this.text()&&"fontSize"!==a&&"formatBlock"!==a&&"indent"!==a&&"outdent"!==a&&"justifyLeft"!==a&&"justifyRight"!==a&&"justifyFull"!==a&&"justifyCenter"!==a&&"html"!==a&&"undo"!==a&&"redo"!==a&&"selectAll"!==a&&"save"!==a&&"insertImage"!==a&&"insertVideo"!==a&&"insertOrderedList"!==a&&"insertUnorderedList"!==a)return!1;switch(a){case"fontSize":this.fontSize(b);break;case"backColor":this.backColor(b);break;case"foreColor":this.foreColor(b);break;case"formatBlock":this.formatBlock(b);break;case"createLink":this.insertLink();break;case"insertImage":this.insertImage();break;case"indent":this.indent();break;case"outdent":this.outdent(!0);break;case"justifyLeft":case"justifyRight":case"justifyCenter":case"justifyFull":this.align(a);break;case"insertOrderedList":case"insertUnorderedList":this.formatList(a);break;case"insertVideo":this.insertVideo();break;case"indent":case"outdent":this.execDefault(a,b),this.repositionEditor();break;case"undo":this.undo();break;case"redo":this.redo();break;case"html":this.html();break;case"save":this.save();break;case"selectAll":this.$element.focus(),this.execDefault(a,b);break;default:this.execDefault(a,b)}"undo"!=a&&"redo"!=a&&"selectAll"!=a&&"createLink"!=a&&"insertImage"!=a&&"html"!=a&&"insertVideo"!=a&&this.saveUndoStep(),"createLink"!=a&&"insertImage"!=a&&this.refreshButtons()},b.prototype.undo=function(){if(this.undoIndex>1){var a=this.getHTML();this.$element.html(this.undoStack[--this.undoIndex-1]),this.hide(),this.callback("undo",[this.$element.html(),a])}this.refreshUndoRedo()},b.prototype.redo=function(){if(this.undoIndex").attr("data-font",!0).css("font-size",b).html(a(e).html());0===a(e).parents("font").length&&c.push(f),a(e).replaceWith(f)});var d=function(b,c){a(c).css("font-size","")};for(var e in c){var f=c[e];a(f).find("*").each(d)}this.$element.find('span[data-font="true"] > span[data-font="true"]').each(function(b,c){a(c).attr("style")&&(a(c).before(''),a(c).after(''))});var g=this.$element.html();g=g.replace(new RegExp('',"g"),""),g=g.replace(new RegExp('data-open="true">',"g"),">"),this.$element.html(g);for(var h=!0,i=a.proxy(function(){this.$element.find('span[data-font="true"] + span[data-font="true"]').each(function(b,c){a(c).css("font-size")==a(c).prev().css("font-size")&&(a(c).prepend(a(c).prev().html()),a(c).prev().remove(),h=!0)}),this.$element.find('span[data-font="true"] + span#marker-true + span[data-font="true"], span[data-font="true"] + span#marker-true + span[data-font="true"]').each(function(b,c){a(c).css("font-size")==a(c).prev().prev().css("font-size")&&(a(c).prepend(a(c).prev().clone()),a(c).prepend(a(c).prev().prev().html()),a(c).prev().prev().remove(),a(c).prev().remove(),h=!0)})},this);h;)h=!1,i();this.$element.find('span[style=""]').each(function(b,c){a(c).replaceWith(a(c).html())}),this.$element.find("span[data-font]").each(function(b,c){a(c).css("font-size")==a(c).parent().css("font-size")&&a(c).replaceWith(a(c).html())}),this.restoreSelectionByMarkers(),this.repositionEditor(),this.callback("fontSize")},b.prototype.backColor=function(c){var d="backColor";this.browser.msie||(d="hiliteColor");var e=a(this.getSelectionElement()).css("background-color");document.execCommand(d,!1,c);var f=this.$editor.find('button.fr-color-bttn[data-cmd="backColor"][data-val="'+c+'"]');f.addClass("active"),f.siblings().removeClass("active"),this.callback("backColor",[b.hexToRGBString(c),e])},b.prototype.foreColor=function(c){var d=a(this.getSelectionElement()).css("color");document.execCommand("foreColor",!1,c),this.saveSelectionByMarkers(),this.$element.find("font[color]").each(function(b,d){a(d).replaceWith(a("").css("color",c).html(a(d).html()))}),this.restoreSelectionByMarkers();var e=this.$editor.find('button.fr-color-bttn[data-cmd="foreColor"][data-val="'+c+'"]');e.addClass("active"),e.siblings().removeClass("active"),this.callback("foreColor",[b.hexToRGBString(c),d])},b.prototype.formatBlock=function(b){if(this.disabledList.indexOf("formatBlock")>=0)return!1;this.saveSelectionByMarkers(),this.wrapText(),this.restoreSelectionByMarkers();var c,d=this.getSelectionElements();for(var e in d){var f=a(d[e]);if(c="n"==b?a("").html(f.html()):a("<"+b+">").html(f.html()),f.get(0)!=this.$element.get(0)&&"LI"!=f.get(0).tagName){var g=f.prop("attributes");if(c.attr)for(var h in g)c.attr(g[h].name,g[h].value);f.replaceWith(c)}else f.html(c)}this.clearSelection(),this.hide(),this.callback("formatBlock")},b.prototype.formatList=function(b){this.saveSelectionByMarkers();var c,d=this.getSelectionElements(),e=!0,f=!1;for(var g in d)c=a(d[g]),c.parents("li").length>0?(c.parents("ol").length>0?(c.parents("li").before(''),c.parents("li").after('')):c.parents("ul").length>0&&(c.parents("li").before(''),c.parents("li").after('')),c.parents("li").replaceWith(c.parents("li").contents()),f=!0):e=!1;if(f){var h=this.$element.html();h=h.replace(new RegExp('',"g"),""),h=h.replace(new RegExp('',"g"),""),h=h.replace(new RegExp('',"g"),""),h=h.replace(new RegExp('',"g"),""),this.$element.html(h),this.$element.find("ul:empty, ol:empty").remove()}if(this.clearSelection(),this.wrapText(),this.restoreSelectionByMarkers(),e===!1){d=this.getSelectionElements(),this.saveSelectionByMarkers();var i=a("");"insertUnorderedList"==b&&(i=a(""));for(var j in d)c=a(d[j]),c.get(0)!=this.$element.get(0)&&(i.append(a("").append(c.clone())),j!=d.length-1?c.remove():c.replaceWith(i));this.restoreSelectionByMarkers()}this.repositionEditor(),this.callback(b)},b.prototype.align=function(b){var c=this.getSelectionElements();this.saveSelection(),"justifyLeft"==b?b="left":"justifyRight"==b?b="right":"justifyCenter"==b?b="center":"justifyFull"==b&&(b="justify");for(var d in c)a(c[d]).css("text-align",b);this.restoreSelection(),this.repositionEditor(),this.callback("align")},b.prototype.indent=function(b){var c=20;b&&(c=-20),this.saveSelectionByMarkers(),this.wrapText(),this.restoreSelectionByMarkers();var d=this.getSelectionElements();this.saveSelectionByMarkers();for(var e in d){var f=a(d[e]);if(f.get(0)!=this.$element.get(0)){var g=parseInt(f.css("margin-left").replace(/px/,""),10),h=Math.max(0,g+c);f.css("marginLeft",h)}else{var i=a("").html(f.html());f.html(i),i.css("marginLeft",Math.max(0,c))}}this.restoreSelectionByMarkers(),this.repositionEditor(),b||this.callback("indent")},b.prototype.outdent=function(){this.indent(!0),this.callback("outdent")},b.prototype.insertLink=function(){this.showInsertLink(),this.options.inlineMode||this.positionPopup("createLink"),this.saveSelection();var b=this.getSelectionLink(),c=this.getSelectionLinks();c.length>0&&this.$link_wrapper.find('input[type="checkbox"]').prop("checked","_blank"==a(c[0]).attr("target")),this.$link_wrapper.find('input[type="text"]').val(b||"http://")},b.prototype.insertImage=function(){this.showInsertImage(),this.saveSelection(),this.options.inlineMode||this.positionPopup("insertImage"),this.$image_wrapper.find('input[type="text"]').val("")},b.prototype.insertVideo=function(){this.showInsertVideo(),this.saveSelection(),this.options.inlineMode||this.positionPopup("insertVideo"),this.$video_wrapper.find("textarea").val("")},b.prototype.execDefault=function(a,b){document.execCommand(a,!1,b),"insertOrderedList"==a?this.$bttn_wrapper.find('[data-cmd="insertUnorderedList"]').removeClass("active"):"insertUnorderedList"==a&&this.$bttn_wrapper.find('[data-cmd="insertOrderedList"]').removeClass("active"),this.callback(a)},b.prototype.refreshButtons=function(){return!this.selectionInEditor()||this.isHTML?!1:(this.refreshUndoRedo(),void this.$bttn_wrapper.find("[data-cmd]").each(a.proxy(function(b,c){switch(a(c).data("cmd")){case"fontSize":this.refreshFontSize(c);break;case"backColor":this.refreshBackColor(c);break;case"foreColor":this.refreshForeColor(c);break;case"formatBlock":this.refreshFormatBlock(c);break;case"createLink":case"insertImage":break;case"justifyLeft":case"justifyRight":case"justifyCenter":case"justifyFull":this.refreshAlign(c);break;case"html":this.isHTML?a(c).addClass("active"):a(c).removeClass("active");break;case"undo":case"redo":case"save":break;default:this.refreshDefault(c)}},this)))},b.prototype.refreshFormatBlock=function(b){this.disabledList.indexOf("formatBlock")>=0&&a(b).parents(".fr-dropdown").attr("data-disabled",!0)},b.prototype.refreshUndoRedo=function(){if(this.isEnabled("undo")||this.isEnabled("redo")){if(void 0===this.$editor)return;this.$bttn_wrapper.find('[data-cmd="undo"], [data-cmd="redo"]').prop("disabled",!1),(0===this.undoStack.length||this.undoIndex<=1||this.isHTML)&&this.$bttn_wrapper.find('[data-cmd="undo"]').prop("disabled",!0),(this.undoIndex==this.undoStack.length||this.isHTML)&&this.$bttn_wrapper.find('[data-cmd="redo"]').prop("disabled",!0)}},b.prototype.refreshDefault=function(b){a(b).removeClass("active");try{document.queryCommandState(a(b).data("cmd"))===!0&&a(b).addClass("active")}catch(c){}},b.prototype.refreshAlign=function(b){var c=a(b).data("cmd"),d=this.getSelectionElements();"justifyLeft"==c?c="left":"justifyRight"==c?c="right":"justifyCenter"==c?c="center":"justifyFull"==c&&(c="justify"),c==a(d[0]).css("text-align")&&(a(b).parents("ul").find(".fr-bttn").removeClass("active"),a(b).addClass("active"),a(b).parents(".fr-dropdown").find(".fr-trigger").html(a(b).html()))},b.prototype.refreshForeColor=function(b){a(b).removeClass("active"),document.queryCommandValue("foreColor")==b.style.backgroundColor&&a(b).addClass("active")},b.prototype.refreshBackColor=function(b){a(b).removeClass("active"),document.queryCommandValue("backColor")==b.style.backgroundColor&&a(b).addClass("active")},b.prototype.refreshFontSize=function(b){a(b).removeClass("active"),parseInt(document.queryCommandValue("fontSize"),10)==parseInt(a(b).data("val"),10)&&a(b).addClass("active") },b.prototype.option=function(b,c){if(void 0===b)return this.options;if(b instanceof Object)this.options=a.extend({},this.options,b),this.initOptions(),this.setCustomText(),this.setLanguage();else{if(void 0===c)return this.options[b];switch(this.options[b]=c,b){case"borderColor":this.setBorderColor();break;case"direction":this.setDirection();break;case"height":case"width":this.setDimensions();break;case"spellcheck":this.setSpellcheck();break;case"placeholder":this.setPlaceholder();break;case"customText":this.setCustomText();break;case"inverseSkin":this.setInverseSkin();break;case"language":this.setLanguage()}}};var c=a.fn.editable;a.fn.editable=function(c){for(var d=[],e=0;ee*e+f*f||v(a,b,c,e,f,d)}function t(){return this._handled=d,!1}function u(a){try{a._handled()}catch(b){return!1}}function v(a,b,c,d,e,f){{var g,h;b.target}g=a.targetTouches,h=a.timeStamp-b.timeStamp,b.type="movestart",b.distX=d,b.distY=e,b.deltaX=d,b.deltaY=e,b.pageX=c.pageX,b.pageY=c.pageY,b.velocityX=d/h,b.velocityY=e/h,b.targetTouches=g,b.finger=g?g.length:1,b._handled=t,b._preventTouchmoveDefault=function(){a.preventDefault()},L(b.target,b),f(b.identifier)}function w(a){var b=a.data.timer;a.data.touch=a,a.data.timeStamp=a.timeStamp,b.kick()}function x(a){var b=a.data.event,c=a.data.timer;y(),D(b,c,function(){setTimeout(function(){K(b.target,"click",e)},0)})}function y(){K(document,O.move,w),K(document,O.end,x)}function z(a){var b=a.data.event,c=a.data.timer,d=j(a,b);d&&(a.preventDefault(),b.targetTouches=a.targetTouches,a.data.touch=d,a.data.timeStamp=a.timeStamp,c.kick())}function A(a){var b=a.data.event,c=a.data.timer,d=i(a.changedTouches,b.identifier);d&&(B(b),D(b,c))}function B(a){K(document,"."+a.identifier,z),K(document,"."+a.identifier,A)}function C(a,b,c){var d=c-a.timeStamp;a.type="move",a.distX=b.pageX-a.startX,a.distY=b.pageY-a.startY,a.deltaX=b.pageX-a.pageX,a.deltaY=b.pageY-a.pageY,a.velocityX=.3*a.velocityX+.7*a.deltaX/d,a.velocityY=.3*a.velocityY+.7*a.deltaY/d,a.pageX=b.pageX,a.pageY=b.pageY}function D(a,b,c){b.end(function(){return a.type="moveend",L(a.target,a),c&&c()})}function E(){return J(this,"movestart.move",u),!0}function F(){return K(this,"dragstart drag",f),K(this,"mousedown touchstart",g),K(this,"movestart",u),!0}function G(a){"move"!==a.namespace&&"moveend"!==a.namespace&&(J(this,"dragstart."+a.guid+" drag."+a.guid,f,b,a.selector),J(this,"mousedown."+a.guid,g,b,a.selector))}function H(a){"move"!==a.namespace&&"moveend"!==a.namespace&&(K(this,"dragstart."+a.guid+" drag."+a.guid),K(this,"mousedown."+a.guid))}var I=6,J=a.event.add,K=a.event.remove,L=function(b,c,d){a.event.trigger(c,d,b)},M=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){return window.setTimeout(function(){a()},25)}}(),N={textarea:!0,input:!0,select:!0,button:!0},O={move:"mousemove",cancel:"mouseup dragstart",end:"mouseup"},P={move:"touchmove",cancel:"touchend",end:"touchend"};a.event.special.movestart={setup:E,teardown:F,add:G,remove:H,_default:function(a){function d(){C(f,g.touch,g.timeStamp),L(a.target,f)}var f,g;a._handled()&&(f={target:a.target,startX:a.startX,startY:a.startY,pageX:a.pageX,pageY:a.pageY,distX:a.distX,distY:a.distY,deltaX:a.deltaX,deltaY:a.deltaY,velocityX:a.velocityX,velocityY:a.velocityY,timeStamp:a.timeStamp,identifier:a.identifier,targetTouches:a.targetTouches,finger:a.finger},g={event:f,timer:new c(d),touch:b,timeStamp:b},a.identifier===b?(J(a.target,"click",e),J(document,O.move,w,g),J(document,O.end,x,g)):(a._preventTouchmoveDefault(),J(document,P.move+"."+a.identifier,z,g),J(document,P.end+"."+a.identifier,A,g)))}},a.event.special.move={setup:function(){J(this,"movestart.move",a.noop)},teardown:function(){K(this,"movestart.move",a.noop)}},a.event.special.moveend={setup:function(){J(this,"movestart.moveend",a.noop)},teardown:function(){K(this,"movestart.moveend",a.noop)}},J(document,"mousedown.move",k),J(document,"touchstart.move",o),"function"==typeof Array.prototype.indexOf&&!function(a){for(var b=["changedTouches","targetTouches"],c=b.length;c--;)-1===a.event.props.indexOf(b[c])&&a.event.props.push(b[c])}(a)}),+function(a){function b(a,b,c,d){if(a.tag.format&&c.length>0){c.push("\n");for(var e=0;d>e;e++)c.push(" ")}}function c(d,e){var f=[],g=0==d.attributes.length,h=0;if(d.tag.isComment)e.allowComments&&(f.push("