/*! wangeditor.js 2017-02-26 */ !function(a){"function"==typeof window.define?window.define.amd?window.define("wangEditor",["jquery"],a):window.define.cmd?window.define(function(b,c,d){return a}):a(window.jQuery):"object"==typeof module&&"object"==typeof module.exports?(require("../css/wangEditor.css"),module.exports=a(require("jquery"))):a(window.jQuery)}(function(a){if(!a||!a.fn||!a.fn.jquery)return void alert("在引用wangEditor.js之前,先引用jQuery,否则无法使用 wangEditor");var b=function(b){var c=window.wangEditor;c&&b(c,a)};return function(a,b){if(a.wangEditor)return void alert("一个页面不能重复引用 wangEditor.js 或 wangEditor.min.js !!!");var c=function(a){"string"==typeof a&&(a="#"+a);var c=b(a);if(1===c.length){var d=c[0].nodeName;"TEXTAREA"!==d&&"DIV"!==d||(this.valueNodeName=d.toLowerCase(),this.$valueContainer=c,this.$prev=c.prev(),this.$parent=c.parent(),this.init())}};c.fn=c.prototype,c.$body=b("body"),c.$document=b(document),c.$window=b(a),c.userAgent=navigator.userAgent,c.getComputedStyle=a.getComputedStyle,c.w3cRange="function"==typeof document.createRange,c.hostname=location.hostname.toLowerCase(),c.websiteHost="wangeditor.github.io|www.wangeditor.com|wangeditor.coding.me",c.isOnWebsite=c.websiteHost.indexOf(c.hostname)>=0,c.docsite="http://www.kancloud.cn/wangfupeng/wangeditor2/113961",a.wangEditor=c,c.plugin=function(a){c._plugins||(c._plugins=[]),"function"==typeof a&&c._plugins.push(a)}}(window,a),b(function(a,b){a.fn.init=function(){this.initDefaultConfig(),this.addEditorContainer(),this.addTxt(),this.addMenuContainer(),this.menus={},this.commandHooks()}}),b(function(a,b){a.fn.ready=function(a){this.readyFns||(this.readyFns=[]),this.readyFns.push(a)},a.fn.readyHeadler=function(){for(var a=this.readyFns;a.length;)a.shift().call(this)},a.fn.updateValue=function(){var a=this,b=a.$valueContainer,c=a.txt.$txt;if(b!==c){var d=c.html();b.val(d)}},a.fn.getInitValue=function(){var a=this,b=a.$valueContainer,c="",d=a.valueNodeName;return"div"===d?c=b.html():"textarea"===d&&(c=b.val()),c},a.fn.updateMenuStyle=function(){var a=this.menus;b.each(a,function(a,b){b.updateSelected()})},a.fn.enableMenusExcept=function(a){this._disabled||(a=a||[],"string"==typeof a&&(a=[a]),b.each(this.menus,function(b,c){a.indexOf(b)>=0||c.disabled(!1)}))},a.fn.disableMenusExcept=function(a){this._disabled||(a=a||[],"string"==typeof a&&(a=[a]),b.each(this.menus,function(b,c){a.indexOf(b)>=0||c.disabled(!0)}))},a.fn.hideDropPanelAndModal=function(){var a=this.menus;b.each(a,function(a,b){var c=b.dropPanel||b.dropList||b.modal;c&&c.hide&&c.hide()})}}),b(function(a,b){function c(){}var d=!a.w3cRange;a.fn.currentRange=function(a){return a?void(this._rangeData=a):this._rangeData},a.fn.collapseRange=function(a,b){b=b||"end",b="start"===b,a=a||this.currentRange(),a&&(a.collapse(b),this.currentRange(a))},a.fn.getRangeText=d?c:function(a){if(a=a||this.currentRange())return a.toString()},a.fn.getRangeElem=d?c:function(a){a=a||this.currentRange();var b=a.commonAncestorContainer;return 1===b.nodeType?b:b.parentNode},a.fn.isRangeEmpty=d?c:function(a){return a=a||this.currentRange(),!(!a||!a.startContainer||a.startContainer!==a.endContainer||a.startOffset!==a.endOffset)},a.fn.saveSelection=d?c:function(a){var c,d,e=this,f=e.txt.$txt.get(0);a?c=a.commonAncestorContainer:(d=document.getSelection(),d.getRangeAt&&d.rangeCount&&(a=document.getSelection().getRangeAt(0),c=a.commonAncestorContainer)),c&&(b.contains(f,c)||f===c)&&e.currentRange(a)},a.fn.restoreSelection=d?c:function(b){var c;if(b=b||this.currentRange())try{c=document.getSelection(),c.removeAllRanges(),c.addRange(b)}catch(d){a.error("执行 editor.restoreSelection 时,IE可能会有异常,不影响使用")}},a.fn.restoreSelectionByElem=d?c:function(a,b){a&&(b=b||"end",this.setRangeByElem(a),"start"===b&&this.collapseRange(this.currentRange(),"start"),"end"===b&&this.collapseRange(this.currentRange(),"end"),this.restoreSelection())},a.fn.initSelection=d?c:function(){var a=this;if(!a.currentRange()){var b=a.txt.$txt,c=b.children().first();c.length&&a.restoreSelectionByElem(c.get(0))}},a.fn.setRangeByElem=d?c:function(a){var c=this,d=c.txt.$txt.get(0);if(a&&b.contains(d,a)){for(var e=a.firstChild;e&&3!==e.nodeType;)e=e.firstChild;for(var f=a.lastChild;f&&3!==f.nodeType;)f=f.lastChild;var g=document.createRange();e&&f?(g.setStart(e,0),g.setEnd(f,f.textContent.length)):(g.setStart(a,0),g.setEnd(a,0)),c.saveSelection(g)}}}),b(function(a,b){a.w3cRange||(a.fn.getRangeText=function(a){if(a=a||this.currentRange())return a.text},a.fn.getRangeElem=function(a){if(a=a||this.currentRange()){var b=a.parentElement();return 1===b.nodeType?b:b.parentNode}},a.fn.isRangeEmpty=function(a){return a=a||this.currentRange(),!a||!a.text},a.fn.saveSelection=function(a){var c,d=this,e=d.txt.$txt.get(0);a?c=a.parentElement():(a=document.selection.createRange(),c="undefined"==typeof a.parentElement?null:a.parentElement()),c&&(b.contains(e,c)||e===c)&&d.currentRange(a)},a.fn.restoreSelection=function(a){var b,c=this;if(a=a||c.currentRange()){b=document.selection.createRange();try{b.setEndPoint("EndToEnd",a)}catch(d){}if(0===a.text.length)try{b.collapse(!1)}catch(d){}else b.setEndPoint("StartToStart",a);b.select()}})}),b(function(a,b){a.fn.commandHooks=function(){var a=this,c={};c.insertHtml=function(c){var d,e=b(c),f=a.getRangeElem();d=a.getLegalTags(f),d&&b(d).after(e)},a.commandHooks=c}}),b(function(a,b){a.fn.command=function(a,b,c,d){function e(){b&&(g.queryCommandSupported(b)?document.execCommand(b,!1,c):(f=g.commandHooks,b in f&&f[b](c)))}var f,g=this;this.customCommand(a,e,d)},a.fn.commandForElem=function(a,b,c,d,e){var f,g;"string"==typeof a?f=a:(f=a.selector,g=a.check);var h=this.getRangeElem();h=this.getSelfOrParentByName(h,f,g),h&&this.setRangeByElem(h),this.command(b,c,d,e)},a.fn.customCommand=function(a,b,c){function d(){e.hideDropPanelAndModal()}var e=this,f=e.currentRange();return f?(e.undoRecord(),this.restoreSelection(f),b.call(e),this.saveSelection(),this.restoreSelection(),c&&"function"==typeof c&&c.call(e),e.txt.insertEmptyP(),e.txt.wrapImgAndText(),e.updateValue(),e.updateMenuStyle(),setTimeout(d,200),void(a&&a.preventDefault())):void(a&&a.preventDefault())},a.fn.queryCommandValue=function(a){var b="";try{b=document.queryCommandValue(a)}catch(c){}return b},a.fn.queryCommandState=function(a){var b=!1;try{b=document.queryCommandState(a)}catch(c){}return b},a.fn.queryCommandSupported=function(a){var b=!1;try{b=document.queryCommandSupported(a)}catch(c){}return b}}),b(function(a,b){function c(a){var c=this,d=b(a),e=!1;return d.each(function(){if(this===c)return e=!0,!1}),e}var d;a.fn.getLegalTags=function(b){var c=this.config.legalTags;return c?this.getSelfOrParentByName(b,c):void a.error("配置项中缺少 legalTags 的配置")},a.fn.getSelfOrParentByName=function(a,e,f){if(a&&e){d||(d=a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.matchesSelector),d||(d=c);for(var g=this.txt.$txt.get(0);a&&g!==a&&b.contains(g,a);){if(d.call(a,e)){if(!f)return a;if(f(a))return a}a=a.parentNode}}}}),b(function(a,b){function c(a){return null==a._redoList&&(a._redoList=[]),a._redoList}function d(a){return null==a._undoList&&(a._undoList=[]),a._undoList}function e(a,b,c){var d=b.val,e=a.txt.$txt.html();if(null!=d){if(d===e)return"redo"===c?void a.redo():"undo"===c?void a.undo():void 0;a.txt.$txt.html(d),a.updateValue(),a.onchange&&"function"==typeof a.onchange&&a.onchange.call(a)}}var f=20;a.fn.undoRecord=function(){var a=this,b=a.txt.$txt,e=b.html(),g=d(a),h=c(a),i=g.length?g[0]:"";e!==i.val&&(h.length&&(h=[]),g.unshift({range:a.currentRange(),val:e}),g.length>f&&g.pop())},a.fn.undo=function(){var a=this,b=d(a),f=c(a);if(b.length){var g=b.shift();f.unshift(g),e(this,g,"undo")}},a.fn.redo=function(){var a=this,b=d(a),f=c(a);if(f.length){var g=f.shift();b.unshift(g),e(this,g,"redo")}}}),b(function(a,b){a.fn.create=function(){var c=this;a.$body&&0!==a.$body.length||(a.$body=b("body"),a.$document=b(document),a.$window=b(window)),c.addMenus(),c.renderMenus(),c.renderMenuContainer(),c.renderTxt(),c.renderEditorContainer(),c.eventMenus(),c.eventMenuContainer(),c.eventTxt(),c.readyHeadler(),c.initSelection(),c.$txt=c.txt.$txt;var d=a._plugins;d&&d.length&&b.each(d,function(a,b){b.call(c)})},a.fn.disable=function(){this.txt.$txt.removeAttr("contenteditable"),this.disableMenusExcept(),this._disabled=!0},a.fn.enable=function(){this._disabled=!1,this.txt.$txt.attr("contenteditable","true"),this.enableMenusExcept()},a.fn.destroy=function(){var a=this,b=a.$valueContainer,c=a.$editorContainer,d=a.valueNodeName;"div"===d?(b.removeAttr("contenteditable"),c.after(b),c.hide()):(b.show(),c.hide())},a.fn.undestroy=function(){var a=this,b=a.$valueContainer,c=a.$editorContainer,d=a.menuContainer.$menuContainer,e=a.valueNodeName;"div"===e?(b.attr("contenteditable","true"),d.after(b),c.show()):(b.hide(),c.show())},a.fn.clear=function(){var a=this,b=a.txt.$txt;b.html("


"),a.restoreSelectionByElem(b.find("p").get(0))}}),b(function(a,b){var c=function(a){this.editor=a,this.init()};c.fn=c.prototype,a.MenuContainer=c}),b(function(a,b){var c=a.MenuContainer;c.fn.init=function(){var a=this,c=b('
');a.$menuContainer=c,a.changeShadow()},c.fn.changeShadow=function(){var a=this.$menuContainer,b=this.editor,c=b.txt.$txt;c.on("scroll",function(){c.scrollTop()>10?a.addClass("wangEditor-menu-shadow"):a.removeClass("wangEditor-menu-shadow")})}}),b(function(a,b){var c=a.MenuContainer;c.fn.render=function(){var a=this.$menuContainer,b=this.editor.$editorContainer;b.append(a)},c.fn.height=function(){var a=this.$menuContainer;return a.height()},c.fn.appendMenu=function(a,b){return this._addGroup(a),this._addOneMenu(b)},c.fn._addGroup=function(a){var c,d=this.$menuContainer;this.$currentGroup&&this.currentGroupIdx===a||(c=b(''),d.append(c),this.$currentGroup=c,this.currentGroupIdx=a)},c.fn._addOneMenu=function(a){var c=a.$domNormal,d=a.$domSelected,e=this.$currentGroup,f=b('');return d.hide(),f.append(c).append(d),e.append(f),f}}),b(function(a,b){var c=function(a){this.editor=a.editor,this.id=a.id,this.title=a.title,this.$domNormal=a.$domNormal,this.$domSelected=a.$domSelected||a.$domNormal,this.commandName=a.commandName,this.commandValue=a.commandValue,this.commandNameSelected=a.commandNameSelected||a.commandName,this.commandValueSelected=a.commandValueSelected||a.commandValue};c.fn=c.prototype,a.Menu=c}),b(function(a,b){var c=a.Menu;c.fn.initUI=function(){var c=this.editor,d=c.UI.menus,e=this.id,f=d[e];this.$domNormal&&this.$domSelected||(null==f&&(a.warn('editor.UI配置中,没有菜单 "'+e+'" 的UI配置,只能取默认值'),f=d.default),this.$domNormal=b(f.normal),/^\./.test(f.selected)?this.$domSelected=this.$domNormal.clone().addClass(f.selected.slice(1)):this.$domSelected=b(f.selected))}}),b(function(a,b){var c=a.Menu;c.fn.render=function(a){this.initUI();var b=this.editor,c=b.menuContainer,d=c.appendMenu(a,this),e=this.onRender;this._renderTip(d),e&&"function"==typeof e&&e.call(this)},c.fn._renderTip=function(c){function d(){j.show()}function e(){j.hide()}var f,g=this,h=g.editor,i=g.title,j=b('');g.tipWidth||(f=b('

'+i+"

"),a.$body.append(f),h.ready(function(){var a=f.outerWidth()+5,b=j.outerWidth(),c=parseFloat(j.css("margin-left"),10);f.remove(),f=null,j.css({width:a,"margin-left":c+(b-a)/2}),g.tipWidth=a})),j.append(i),c.append(j);var k;c.find("a").on("mouseenter",function(a){g.active()||g.disabled()||(k=setTimeout(d,200))}).on("mouseleave",function(a){k&&clearTimeout(k),e()}).on("click",e)},c.fn.bindEvent=function(){var b=this,c=b.$domNormal,d=b.$domSelected,e=b.clickEvent;e||(e=function(c){var d=b.dropPanel||b.dropList||b.modal;if(d&&d.show)return void(d.isShowing?d.hide():d.show());var e,f,g=b.editor,h=b.selected;h?(e=b.commandNameSelected,f=b.commandValueSelected):(e=b.commandName,f=b.commandValue),e?g.command(c,e,f):(a.warn('菜单 "'+b.id+'" 未定义click事件'),c.preventDefault())});var f=b.clickEventSelected||e;c.click(function(a){b.disabled()||(e.call(b,a),b.updateSelected()),a.preventDefault()}),d.click(function(a){b.disabled()||(f.call(b,a),b.updateSelected()),a.preventDefault()})},c.fn.updateSelected=function(){var a=this,b=(a.editor,a.updateSelectedEvent);b||(b=function(){var a=this,b=a.editor,c=a.commandName,d=a.commandValue;if(d){if(b.queryCommandValue(c).toLowerCase()===d.toLowerCase())return!0}else if(b.queryCommandState(c))return!0;return!1});var c=b.call(a);c=!!c,a.changeSelectedState(c)},c.fn.changeSelectedState=function(a){var b=this,c=b.selected;if(null!=a&&"boolean"==typeof a){if(c===a)return;b.selected=a,a?(b.$domNormal.hide(),b.$domSelected.show()):(b.$domNormal.show(),b.$domSelected.hide())}},c.fn.active=function(a){return null==a?this._activeState:void(this._activeState=a)},c.fn.activeStyle=function(a){var b=(this.selected,this.$domNormal),c=this.$domSelected;a?(b.addClass("active"),c.addClass("active")):(b.removeClass("active"),c.removeClass("active")),this.active(a)},c.fn.disabled=function(a){if(null==a)return!!this._disabled;if(this._disabled!==a){var b=this.$domNormal,c=this.$domSelected;a?(b.addClass("disable"),c.addClass("disable")):(b.removeClass("disable"),c.removeClass("disable")),this._disabled=a}}}),b(function(a,b){var c=function(a,b,c){this.editor=a,this.menu=b,this.data=c.data,this.tpl=c.tpl,this.selectorForELemCommand=c.selectorForELemCommand,this.beforeEvent=c.beforeEvent,this.afterEvent=c.afterEvent,this.init()};c.fn=c.prototype,a.DropList=c}),b(function(a,b){var c=a.DropList;c.fn.init=function(){var a=this;a.initDOM(),a.bindEvent(),a.initHideEvent()},c.fn.initDOM=function(){var a,c,d=this,e=d.data,f=d.tpl||"{#title}",g=b('
');b.each(e,function(d,e){a=f.replace(/{#commandValue}/gi,d).replace(/{#title}/gi,e),c=b(''),c.append(a),g.append(c)}),d.$list=g},c.fn.bindEvent=function(){var a=this,c=a.editor,d=a.menu,e=d.commandName,f=a.selectorForELemCommand,g=a.$list,h=a.beforeEvent,i=a.afterEvent;g.on("click","a[commandValue]",function(a){h&&"function"==typeof h&&h.call(a);var g=b(a.currentTarget).attr("commandValue");d.selected&&c.isRangeEmpty()&&f?c.commandForElem(f,a,e,g):c.command(a,e,g),i&&"function"==typeof i&&i.call(a)})},c.fn.initHideEvent=function(){var c=this,d=c.$list.get(0);a.$body.on("click",function(a){if(c.isShowing){var e,f=a.target,g=c.menu;e=g.selected?g.$domSelected.get(0):g.$domNormal.get(0),e===f||b.contains(e,f)||d===f||b.contains(d,f)||c.hide()}}),a.$window.scroll(function(){c.hide()}),a.$window.on("resize",function(){c.hide()})}}),b(function(a,b){var c=a.DropList;c.fn._render=function(){var a=this,b=a.editor,c=a.$list;b.$editorContainer.append(c),a.rendered=!0},c.fn._position=function(){var a=this,b=a.$list,c=a.editor,d=a.menu,e=c.menuContainer.$menuContainer,f=d.selected?d.$domSelected:d.$domNormal,g=f.offsetParent().position(),h=g.top,i=g.left,j=f.offsetParent().height(),k=f.offsetParent().width(),l=b.outerWidth(),m=c.txt.$txt.outerWidth(),n=h+j,o=i+k/2,p=0-k/2,q=o+l-m;q>-10&&(p=p-q-10),b.css({top:n,left:o,"margin-left":p}),c._isMenufixed&&(n+=e.offset().top+e.outerHeight()-b.offset().top,b.css({top:n}))},c.fn.show=function(){var a=this,b=a.menu;if(a.rendered||a._render(),!a.isShowing){var c=a.$list;c.show(),a._position(),a.isShowing=!0,b.activeStyle(!0)}},c.fn.hide=function(){var a=this,b=a.menu;if(a.isShowing){var c=a.$list;c.hide(),a.isShowing=!1,b.activeStyle(!1)}}}),b(function(a,b){var c=function(a,b,c){this.editor=a,this.menu=b,this.$content=c.$content,this.width=c.width||200,this.height=c.height,this.onRender=c.onRender,this.init()};c.fn=c.prototype,a.DropPanel=c}),b(function(a,b){var c=a.DropPanel;c.fn.init=function(){var a=this;a.initDOM(),a.initHideEvent()},c.fn.initDOM=function(){var a=this,c=a.$content,d=a.width,e=a.height,f=b('
'),g=b('
');f.css({width:d,height:e?e:"auto"}),f.append(g),f.append(c),a.$panel=f,a.$triangle=g},c.fn.initHideEvent=function(){var c=this,d=c.$panel.get(0);a.$body.on("click",function(a){if(c.isShowing){var e,f=a.target,g=c.menu;e=g.selected?g.$domSelected.get(0):g.$domNormal.get(0),e===f||b.contains(e,f)||d===f||b.contains(d,f)||c.hide()}}),a.$window.scroll(function(a){c.hide()}),a.$window.on("resize",function(){c.hide()})}}),b(function(a,b){var c=a.DropPanel;c.fn._render=function(){var a=this,b=a.onRender,c=a.editor,d=a.$panel;c.$editorContainer.append(d),b&&b.call(a),a.rendered=!0},c.fn._position=function(){var a=this,b=a.$panel,c=a.$triangle,d=a.editor,e=d.menuContainer.$menuContainer,f=a.menu,g=f.selected?f.$domSelected:f.$domNormal,h=g.offsetParent().position(),i=h.top,j=h.left,k=g.offsetParent().height(),l=g.offsetParent().width(),m=b.outerWidth(),n=d.txt.$txt.outerWidth(),o=i+k,p=j+l/2,q=0-m/2,r=q;0-q>p-10&&(q=0-(p-10));var s=p+m+q-n;s>-10&&(q=q-s-10),b.css({top:o,left:p,"margin-left":q}),d._isMenufixed&&(o+=e.offset().top+e.outerHeight()-b.offset().top,b.css({top:o})),c.css({"margin-left":r-q-5})},c.fn.focusFirstInput=function(){var a=this,c=a.$panel;c.find("input[type=text],textarea").each(function(){var a=b(this);if(null==a.attr("disabled"))return a.focus(),!1})},c.fn.show=function(){var b=this,c=b.menu;if(b.rendered||b._render(),!b.isShowing){var d=b.$panel;d.show(),b._position(),b.isShowing=!0,c.activeStyle(!0),a.w3cRange?b.focusFirstInput():a.placeholderForIE8(d)}},c.fn.hide=function(){var a=this,b=a.menu;if(a.isShowing){var c=a.$panel;c.hide(),a.isShowing=!1,b.activeStyle(!1)}}}),b(function(a,b){var c=function(a,b,c){this.editor=a,this.menu=b,this.$content=c.$content,this.init()};c.fn=c.prototype,a.Modal=c}),b(function(a,b){var c=a.Modal;c.fn.init=function(){var a=this;a.initDom(),a.initHideEvent()},c.fn.initDom=function(){var a=this,c=a.$content,d=b('
'),e=b('
');d.append(e),d.append(c),a.$modal=d,a.$close=e},c.fn.initHideEvent=function(){var c=this,d=c.$close,e=c.$modal.get(0);d.click(function(){c.hide()}),a.$body.on("click",function(a){if(c.isShowing){var d,f=a.target,g=c.menu;g&&(d=g.selected?g.$domSelected.get(0):g.$domNormal.get(0),d===f||b.contains(d,f))||e===f||b.contains(e,f)||c.hide()}})}}),b(function(a,b){var c=a.Modal;c.fn._render=function(){var b=this,c=b.editor,d=b.$modal;d.css("z-index",c.config.zindex+10+""),a.$body.append(d),b.rendered=!0},c.fn._position=function(){var b=this,c=b.$modal,d=c.offset().top,e=c.outerWidth(),f=c.outerHeight(),g=0-e/2,h=0-f/2,i=a.$window.scrollTop();f/2>d&&(h=0-d),c.css({"margin-left":g+"px","margin-top":h+i+"px"})},c.fn.show=function(){var a=this,b=a.menu;if(a.rendered||a._render(),!a.isShowing){a.isShowing=!0;var c=a.$modal;c.show(),a._position(),b&&b.activeStyle(!0)}},c.fn.hide=function(){var a=this,b=a.menu;if(a.isShowing){a.isShowing=!1;var c=a.$modal;c.hide(),b&&b.activeStyle(!1)}}}),b(function(a,b){var c=function(a){this.editor=a,this.init()};c.fn=c.prototype,a.Txt=c}),b(function(a,b){var c=a.Txt;c.fn.init=function(){var a,c=this,d=c.editor,e=d.$valueContainer,f=d.getInitValue();"DIV"===e.get(0).nodeName?(a=e,a.addClass("wangEditor-txt"),a.attr("contentEditable","true")):a=b('
'+f+"
"),d.ready(function(){c.insertEmptyP()}),c.$txt=a,c.contentEmptyHandle(),c.bindEnterForDiv(),c.bindEnterForText(),c.bindTabEvent(),c.bindPasteFilter(),c.bindFormatText(),c.bindHtml()},c.fn.contentEmptyHandle=function(){var a,c=this,d=c.editor,e=c.$txt;e.on("keydown",function(a){if(8===a.keyCode){var c=b.trim(e.html().toLowerCase());return"


"===c?void a.preventDefault():void 0}}),e.on("keyup",function(c){if(8===c.keyCode){var f=b.trim(e.html().toLowerCase());f&&"
"!==f||(a=b("


"),e.html(""),e.append(a),d.restoreSelectionByElem(a.get(0)))}})},c.fn.bindEnterForDiv=function(){function c(){if(d){var a=b("

"+d.html()+"

");d.after(a),d.remove()}}var d,e=(a.config.legalTags,this),f=e.editor,g=e.$txt;g.on("keydown keyup",function(a){if(13===a.keyCode){var e,g,h=f.getRangeElem(),i=f.getLegalTags(h);if(!i){if(i=f.getSelfOrParentByName(h,"div"),!i)return;e=b(i),"keydown"===a.type&&(d=e,setTimeout(c,0)),"keyup"===a.type&&(g=b("

"+e.html()+"

"),e.after(g),e.remove(),f.restoreSelectionByElem(g.get(0),"start"))}}})},c.fn.bindEnterForText=function(){var a,b=this,c=b.$txt;c.on("keyup",function(c){13===c.keyCode&&(a||(a=function(){b.wrapImgAndText()}),setTimeout(a))})},c.fn.bindTabEvent=function(){var a=this,b=a.editor,c=a.$txt;c.on("keydown",function(a){9===a.keyCode&&b.queryCommandSupported("insertHtml")&&b.command(a,"insertHtml","    ")})},c.fn.bindPasteFilter=function(){function a(e){if(e&&e.nodeType&&e.nodeName){var f,h,i=e.nodeName.toLowerCase(),k=e.nodeType;if(3===k||1===k){if(f=b(e),"div"===i)return h=[],b.each(e.childNodes,function(a,b){h.push(b)}),void b.each(h,function(){a(this)});if(j.indexOf(i)>=0)g+=c(e);else if(3===k)g+="

"+e.textContent+"

";else if("br"===i)g+="
";else{if(["meta","style","script","object","form","iframe","hr"].indexOf(i)>=0)return;f=b(d(e)),g+=b("
").append(f.clone()).html()}}}}function c(a){var c,e=a.nodeName.toLowerCase(),f="",g="";return["blockquote"].indexOf(e)>=0?(c=b(a),"<"+e+">"+c.text()+""):["p","h1","h2","h3","h4","h5"].indexOf(e)>=0?(a=d(a),c=b(a),f=c.html(),f=f.replace(/<.*?>/gi,function(a){return""===a||0===a.indexOf(""+f+""):["ul","ol"].indexOf(e)>=0?(c=b(a),c.children().each(function(){var a=b(d(this)),c=a.html();c=c.replace(/<.*?>/gi,function(a){return""===a||0===a.indexOf(""}),"<"+e+">"+g+""):(c=b(d(a)),b("
").append(c).html())}function d(a){var c=a.attributes||[],e=[],f=["href","target","src","alt","rowspan","colspan"];b.each(c,function(a,b){b&&2===b.nodeType&&e.push(b.nodeName)}),b.each(e,function(b,c){f.indexOf(c)<0&&a.removeAttribute(c)});var g=a.childNodes;return g.length&&b.each(g,function(a,b){d(b)}),a}var e=this,f=e.editor,g="",h=e.$txt,i=f.config.legalTags,j=i.split(",");h.on("paste",function(c){if(f.config.pasteFilter){var d=f.getRangeElem().nodeName;if("TD"!==d&&"TH"!==d){g="";var h,i,j,k=c.clipboardData||c.originalEvent.clipboardData,l=window.clipboardData;if(f.config.pasteText){if(k&&k.getData)h=k.getData("text/plain");else{if(!l||!l.getData)return;h=l.getData("text")}h&&(g="

"+h+"

")}else if(k&&k.getData)h=k.getData("text/html"),j=h.split(""),2===j.length&&(h=j[0]),h?(i=b("
"+h+"
"),a(i.get(0))):(h=k.getData("text/plain"),h&&(h=h.replace(/[ ]/g," ").replace(//g,">").replace(/\n/g,"

"),g="

"+h+"

",g=g.replace(/

(https?:\/\/.*?)<\/p>/gi,function(a,b){return'

'+b+"

"})));else{if(!l||!l.getData)return;if(g=l.getData("text"),!g)return;g="

"+g+"

",g=g.replace(new RegExp("\n","g"),"

")}g&&(f.command(c,"insertHtml",g),e.clearEmptyOrNestP())}}})},c.fn.bindFormatText=function(){var c=this,d=(c.editor,c.$txt),e=a.config.legalTags,f=e.split(","),g=(f.length,[]);b.each(f,function(a,b){var c=">\\s*<("+b+")>";g.push(new RegExp(c,"ig"))}),g.push(new RegExp(">\\s*<(li)>","ig")),g.push(new RegExp(">\\s*<(tr)>","ig")),g.push(new RegExp(">\\s*<(code)>","ig")),d.formatText=function(){var a=b("

"),c=d.html();return c=c.replace(/\s*\n<"+b+">"}))}),a.html(c),a.text()}},c.fn.bindHtml=function(){var a=this,c=a.editor,d=a.$txt,e=c.$valueContainer,f=c.valueNodeName;d.html=function(a){var c;return"div"===f&&(c=b.fn.html.call(d,a)),void 0===a?(c=b.fn.html.call(d),c=c.replace(/(href|src)\=\"(.*)\"/gim,function(a,b,c){return b+'="'+c.replace("&","&")+'"'})):(c=b.fn.html.call(d,a),e.val(a)),void 0===a?c:void d.change()}}}),b(function(a,b){var c=a.Txt,d="propertychange change click keyup input paste";c.fn.render=function(){var a=this.$txt,b=this.editor.$editorContainer;b.append(a)},c.fn.initHeight=function(){var a=this.editor,b=this.$txt,c=a.$valueContainer.height(),d=a.menuContainer.height(),e=c-d;e=e<50?50:e,b.height(e),a.valueContainerHeight=c,this.initMaxHeight(e,d)},c.fn.initMaxHeight=function(c,d){var e=this.editor,f=e.menuContainer.$menuContainer,g=this.$txt,h=b("
");if(window.getComputedStyle&&"max-height"in window.getComputedStyle(g.get(0))){var i=parseInt(e.$valueContainer.css("max-height"));if(isNaN(i))return;if(e.menus.fullscreen)return void a.warn("max-height和『全屏』菜单一起使用时,会有一些问题尚未解决,请暂时不要两个同时使用");e.useMaxHeight=!0,h.css({"max-height":i-d+"px","overflow-y":"auto"}),g.css({height:"auto","overflow-y":"visible","min-height":c+"px"}),h.on("scroll",function(){g.parent().scrollTop()>10?f.addClass("wangEditor-menu-shadow"):f.removeClass("wangEditor-menu-shadow")}),g.wrap(h)}},c.fn.saveSelectionEvent=function(){function a(){g.saveSelection()}function b(){Date.now()-h<100||(h=Date.now(),a())}function c(){e&&clearTimeout(e),e=setTimeout(a,300)}var e,f=this.$txt,g=this.editor,h=Date.now();f.on(d+" focus blur",function(a){b(),c()}),f.on("mousedown",function(){f.on("mouseleave.saveSelection",function(a){b(),c(),g.updateMenuStyle()})}).on("mouseup",function(){f.off("mouseleave.saveSelection")})},c.fn.updateValueEvent=function(){function a(){var a=e.html();c!==a&&(f.onchange&&"function"==typeof f.onchange&&f.onchange.call(f),f.updateValue(),c=a)}var b,c,e=this.$txt,f=this.editor;e.on(d,function(d){null==c&&(c=e.html()),b&&clearTimeout(b),b=setTimeout(a,100)})},c.fn.updateMenuStyleEvent=function(){var a=this.$txt,b=this.editor;a.on(d,function(a){b.updateMenuStyle()})},c.fn.insertEmptyP=function(){var a=this.$txt,c=a.children();return 0===c.length?void a.append(b("


")):void("
"!==b.trim(c.last().html()).toLowerCase()&&a.append(b("


")))},c.fn.wrapImgAndText=function(){var a,c,d=this.$txt,e=d.children("img"),f=d[0],g=f.childNodes,h=g.length;for(e.length&&e.each(function(){b(this).wrap("

")}),a=0;a")},c.fn.clearEmptyOrNestP=function(){var a=this.$txt,c=a.find("p");c.each(function(){var a,c=b(this),d=c.children(),e=d.length,f=b.trim(c.html());return f?void(1===e&&(a=d.first(),a.get(0)&&"P"===a.get(0).nodeName&&c.html(a.html()))):void c.remove()})},c.fn.scrollTop=function(a){var b=this,c=b.editor,d=b.$txt;return c.useMaxHeight?d.parent().scrollTop(a):d.scrollTop(a)},c.fn.showHeightOnHover=function(){function a(a){i||(e.append(h),i=!0);var b=(g.position().top,g.outerHeight(),a.height()),c=a.position().top,d=parseInt(a.css("margin-top"),10),j=parseInt(a.css("padding-top"),10),k=parseInt(a.css("margin-bottom"),10),l=parseInt(a.css("padding-bottom"),10);c+f.height();h.css({height:b+j+d+l+k,top:c+f.height()})}function c(){i&&(h.remove(),i=!1)}var d=this.editor,e=d.$editorContainer,f=d.menuContainer,g=this.$txt,h=b(''),i=!1;g.on("mouseenter","ul,ol,blockquote,p,h1,h2,h3,h4,h5,table,pre",function(c){a(b(c.currentTarget))}).on("mouseleave",function(){c()})}}),b(function(a,b){Array.prototype.indexOf||(Array.prototype.indexOf=function(a){for(var b=0,c=this.length;b=0;b--)if(this[b]===a)return b;return-1}),Date.now||(Date.now=function(){return(new Date).valueOf()});var c=window.console,d=function(){};b.each(["info","log","warn","error"],function(b,e){null==c?a[e]=d:a[e]=function(b){a.config&&a.config.printLog&&c[e]("wangEditor提示: "+b)}}),a.random=function(){return Math.random().toString().slice(2)},a.placeholder="placeholder"in document.createElement("input"),a.placeholderForIE8=function(c){a.placeholder||c.find("input[placeholder]").each(function(){var a=b(this),c=a.attr("placeholder");""===a.val()&&(a.css("color","#666"),a.val(c),a.on("focus.placeholder click.placeholder",function(){a.val(""),a.css("color","#333"),a.off("focus.placeholder click.placeholder")}))})}}),b(function(a,b){a.langs={},a.langs["zh-cn"]={bold:"粗体",underline:"下划线",italic:"斜体",forecolor:"文字颜色",bgcolor:"背景色",strikethrough:"删除线",eraser:"清空格式",source:"源码",quote:"引用",fontfamily:"字体",fontsize:"字号",head:"标题",orderlist:"有序列表",unorderlist:"无序列表",alignleft:"左对齐",aligncenter:"居中",alignright:"右对齐",link:"链接",text:"文本",submit:"提交",cancel:"取消",unlink:"取消链接",table:"表格",emotion:"表情",img:"图片",uploadImg:"上传图片",linkImg:"网络图片",video:"视频",width:"宽",height:"高",location:"位置",loading:"加载中",searchlocation:"搜索位置",dynamicMap:"动态地图",clearLocation:"清除位置",langDynamicOneLocation:"动态地图只能显示一个位置",insertcode:"插入代码",undo:"撤销",redo:"重复",fullscreen:"全屏",openLink:"打开链接"},a.langs.en={bold:"Bold",underline:"Underline",italic:"Italic",forecolor:"Color",bgcolor:"Backcolor",strikethrough:"Strikethrough",eraser:"Eraser",source:"Codeview",quote:"Quote",fontfamily:"Font family",fontsize:"Font size",head:"Head",orderlist:"Ordered list",unorderlist:"Unordered list",alignleft:"Align left",aligncenter:"Align center",alignright:"Align right",link:"Insert link",text:"Text",submit:"Submit",cancel:"Cancel",unlink:"Unlink",table:"Table",emotion:"Emotions",img:"Image",uploadImg:"Upload",linkImg:"Link",video:"Video",width:"width",height:"height",location:"Location",loading:"Loading",searchlocation:"search",dynamicMap:"Dynamic",clearLocation:"Clear",langDynamicOneLocation:"Only one location in dynamic map",insertcode:"Insert Code",undo:"Undo",redo:"Redo",fullscreen:"Full screnn",openLink:"open link"}}),b(function(a,b){a.config={},a.config.zindex=1e4,a.config.printLog=!0,a.config.menuFixed=0,a.config.jsFilter=!0,a.config.legalTags="p,h1,h2,h3,h4,h5,h6,blockquote,table,ul,ol,pre",a.config.lang=a.langs["zh-cn"],a.config.menus=["source","|","bold","underline","italic","strikethrough","eraser","forecolor","bgcolor","|","quote","fontfamily","fontsize","head","unorderlist","orderlist","alignleft","aligncenter","alignright","|","link","unlink","table","emotion","|","img","video","location","insertcode","|","undo","redo","fullscreen"],a.config.colors={"#880000":"暗红色","#800080":"紫色","#ff0000":"红色","#ff00ff":"鲜粉色","#000080":"深蓝色","#0000ff":"蓝色","#00ffff":"湖蓝色","#008080":"蓝绿色","#008000":"绿色","#808000":"橄榄色","#00ff00":"浅绿色","#ffcc00":"橙黄色","#808080":"灰色","#c0c0c0":"银色","#000000":"黑色","#ffffff":"白色"},a.config.familys=["宋体","黑体","楷体","微软雅黑","Arial","Verdana","Georgia","Times New Roman","Microsoft JhengHei","Trebuchet MS","Courier New","Impact","Comic Sans MS","Consolas"],a.config.fontsizes={1:"12px",2:"13px",3:"16px",4:"18px",5:"24px",6:"32px",7:"48px"},a.config.emotionsShow="icon",a.config.emotions={weibo:{title:"微博表情",data:[{icon:"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/7a/shenshou_thumb.gif",value:"[草泥马]"},{icon:"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/60/horse2_thumb.gif",value:"[神马]"},{icon:"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/bc/fuyun_thumb.gif",value:"[浮云]"},{icon:"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/c9/geili_thumb.gif",value:"[给力]"},{icon:"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/f2/wg_thumb.gif",value:"[围观]"},{icon:"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/70/vw_thumb.gif",value:"[威武]"},{icon:"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/6e/panda_thumb.gif",value:"[熊猫]"},{icon:"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/81/rabbit_thumb.gif",value:"[兔子]"},{icon:"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/bc/otm_thumb.gif",value:"[奥特曼]"},{icon:"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/15/j_thumb.gif",value:"[囧]"},{icon:"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/89/hufen_thumb.gif",value:"[互粉]"},{icon:"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/c4/liwu_thumb.gif",value:"[礼物]"},{icon:"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/ac/smilea_thumb.gif", value:"[呵呵]"},{icon:"http://img.t.sinajs.cn/t35/style/images/common/face/ext/normal/0b/tootha_thumb.gif",value:"[哈哈]"}]}},a.config.mapAk="TVhjYjq1ICT2qqL5LdS8mwas",a.config.uploadImgUrl="",a.config.uploadTimeout=2e4,a.config.uploadImgFns={},a.config.customUpload=!1,a.config.uploadParams={},a.config.uploadHeaders={},a.config.withCredentials=!0,a.config.hideLinkImg=!1,a.config.pasteFilter=!0,a.config.pasteText=!1,a.config.codeDefaultLang="javascript"}),b(function(a,b){a.UI={},a.UI.menus={default:{normal:'',selected:".selected"},bold:{normal:'',selected:".selected"},underline:{normal:'',selected:".selected"},italic:{normal:'',selected:".selected"},forecolor:{normal:'',selected:".selected"},bgcolor:{normal:'',selected:".selected"},strikethrough:{normal:'',selected:".selected"},eraser:{normal:'',selected:".selected"},quote:{normal:'',selected:".selected"},source:{normal:'',selected:".selected"},fontfamily:{normal:'',selected:".selected"},fontsize:{normal:'',selected:".selected"},head:{normal:'',selected:".selected"},orderlist:{normal:'',selected:".selected"},unorderlist:{normal:'',selected:".selected"},alignleft:{normal:'',selected:".selected"},aligncenter:{normal:'',selected:".selected"},alignright:{normal:'',selected:".selected"},link:{normal:'',selected:".selected"},unlink:{normal:'',selected:".selected"},table:{normal:'',selected:".selected"},emotion:{normal:'',selected:".selected"},img:{normal:'',selected:".selected"},video:{normal:'',selected:".selected"},location:{normal:'',selected:".selected"},insertcode:{normal:'',selected:".selected"},undo:{normal:'',selected:".selected"},redo:{normal:'',selected:".selected"},fullscreen:{normal:'',selected:''}}}),b(function(a,b){a.fn.initDefaultConfig=function(){var c=this;c.config=b.extend({},a.config),c.UI=b.extend({},a.UI)}}),b(function(a,b){a.fn.addEditorContainer=function(){this.$editorContainer=b('

')}}),b(function(a,b){a.fn.addTxt=function(){var b=this,c=new a.Txt(b);b.txt=c}}),b(function(a,b){a.fn.addMenuContainer=function(){var b=this;b.menuContainer=new a.MenuContainer(b)}}),b(function(a,b){a.createMenuFns=[],a.createMenu=function(b){a.createMenuFns.push(b)},a.fn.addMenus=function(){function c(a){return e.indexOf(a)>=0}var d=this,e=d.config.menus;b.each(a.createMenuFns,function(a,b){b.call(d,c)})}}),b(function(a,b){a.createMenu(function(b){var c="bold";if(b(c)){var d=this,e=d.config.lang,f=new a.Menu({editor:d,id:c,title:e.bold,commandName:"Bold"});f.clickEventSelected=function(a){var b=d.isRangeEmpty();b?d.commandForElem("b,strong,h1,h2,h3,h4,h5",a,"Bold"):d.command(a,"Bold")},d.menus[c]=f}})}),b(function(a,b){a.createMenu(function(b){var c="underline";if(b(c)){var d=this,e=d.config.lang,f=new a.Menu({editor:d,id:c,title:e.underline,commandName:"Underline"});f.clickEventSelected=function(a){var b=d.isRangeEmpty();b?d.commandForElem("u,a",a,"Underline"):d.command(a,"Underline")},d.menus[c]=f}})}),b(function(a,b){a.createMenu(function(b){var c="italic";if(b(c)){var d=this,e=d.config.lang,f=new a.Menu({editor:d,id:c,title:e.italic,commandName:"Italic"});f.clickEventSelected=function(a){var b=d.isRangeEmpty();b?d.commandForElem("i",a,"Italic"):d.command(a,"Italic")},d.menus[c]=f}})}),b(function(a,b){a.createMenu(function(c){var d="forecolor";if(c(d)){var e=this,f=e.config.lang,g=e.config.colors,h=new a.Menu({editor:e,id:d,title:f.forecolor}),i=b("
");b.each(g,function(a,b){i.append([''].join(""))}),i.on("click","a[commandValue]",function(a){var c=b(this),d=c.attr("commandValue");h.selected&&e.isRangeEmpty()?e.commandForElem("font[color]",a,"forecolor",d):e.command(a,"forecolor",d)}),h.dropPanel=new a.DropPanel(e,h,{$content:i,width:125}),h.updateSelectedEvent=function(){var a=e.getRangeElem();return a=e.getSelfOrParentByName(a,"font[color]"),!!a},e.menus[d]=h}})}),b(function(a,b){a.createMenu(function(c){function d(a){var b;return!!(a&&a.style&&null!=a.style.cssText&&(b=a.style.cssText,b&&b.indexOf("background-color:")>=0))}var e="bgcolor";if(c(e)){var f=this,g=f.config.lang,h=f.config.colors,i=new a.Menu({editor:f,id:e,title:g.bgcolor}),j=b("
");b.each(h,function(a,b){j.append([''].join(""))}),j.on("click","a[commandValue]",function(a){var c=b(this),e=c.attr("commandValue");i.selected&&f.isRangeEmpty()?f.commandForElem({selector:"span,font",check:d},a,"BackColor",e):f.command(a,"BackColor",e)}),i.dropPanel=new a.DropPanel(f,i,{$content:j,width:125}),i.updateSelectedEvent=function(){var a=f.getRangeElem();return a=f.getSelfOrParentByName(a,"span,font",d),!!a},f.menus[e]=i}})}),b(function(a,b){a.createMenu(function(b){var c="strikethrough";if(b(c)){var d=this,e=d.config.lang,f=new a.Menu({editor:d,id:c,title:e.strikethrough,commandName:"StrikeThrough"});f.clickEventSelected=function(a){var b=d.isRangeEmpty();b?d.commandForElem("strike",a,"StrikeThrough"):d.command(a,"StrikeThrough")},d.menus[c]=f}})}),b(function(a,b){a.createMenu(function(c){var d="eraser";if(c(d)){var e=this,f=e.config.lang,g=new a.Menu({editor:e,id:d,title:f.eraser,commandName:"RemoveFormat"});g.clickEvent=function(a){function c(){var a,c,d,e,f,h,i,j=this;a=j.getRangeElem(),e=j.getSelfOrParentByName(a,"blockquote"),e&&(f=b(e),g=b("

"+f.text()+"

"),f.after(g).remove()),c=j.getSelfOrParentByName(a,"p,h1,h2,h3,h4,h5"),c&&(d=b(c),g=b("

"+d.text()+"

"),d.after(g).remove()),h=j.getSelfOrParentByName(a,"ul,ol"),h&&(i=b(h),g=b("

"+i.text()+"

"),i.after(g).remove())}function d(){var a=this;g&&a.restoreSelectionByElem(g.get(0))}var f=e.isRangeEmpty();if(!f)return void e.command(a,"RemoveFormat");var g;e.customCommand(a,c,d)},e.menus[d]=g}})}),b(function(a,b){a.createMenu(function(c){function d(){var a=i.$codeTextarea,c=g.txt.$txt,d=b.trim(a.val());d||(d="


"),g.config.jsFilter&&(d=d.replace(//gi,""));try{c.html(d)}catch(e){}}var e="source";if(c(e)){var f,g=this,h=g.config.lang,i=new a.Menu({editor:g,id:e,title:h.source});i.isShowCode=!1,i.clickEvent=function(a){var c=this,e=c.editor,g=e.txt.$txt,h=g.outerHeight(),j=g.height();c.$codeTextarea||(c.$codeTextarea=b(''));var k=c.$codeTextarea;k.css({height:j,"margin-top":h-j}),k.val(g.html()),k.on("change",function(a){d()}),g.after(k).hide(),k.show(),i.isShowCode=!0,this.updateSelected(),e.disableMenusExcept("source"),f=g.html()},i.clickEventSelected=function(a){var b=this,c=b.editor,e=c.txt.$txt,g=b.$codeTextarea;g&&(d(),g.after(e).hide(),e.show(),i.isShowCode=!1,this.updateSelected(),c.enableMenusExcept("source"),e.html()!==f&&c.onchange&&"function"==typeof c.onchange&&c.onchange.call(c))},i.updateSelectedEvent=function(){return this.isShowCode},g.menus[e]=i}})}),b(function(a,b){a.createMenu(function(c){var d="quote";if(c(d)){var e=this,f=e.config.lang,g=new a.Menu({editor:e,id:d,title:f.quote,commandName:"formatBlock",commandValue:"blockquote"});g.clickEvent=function(a){function c(){h=b("

"+f.text()+"

"),f.after(h).remove(),h.wrap("
")}function d(){var a=this;h&&a.restoreSelectionByElem(h.get(0))}var f,g=e.getRangeElem();if(!g)return void a.preventDefault();var h,i=e.getSelfOrParentByName(g,"blockquote");return i?void a.preventDefault():(g=e.getLegalTags(g),f=b(g),f.text()?g?void e.customCommand(a,c,d):void e.command(a,"formatBlock","blockquote"):void 0)},g.clickEventSelected=function(a){function c(){var a,c;if(a=b(g),c=a.children(),c.length)return c.each(function(c){var d=b(this);"P"===d.get(0).nodeName?a.after(d):a.after("

"+d.text()+"

"),h=d}),void a.remove()}function d(){var a=this;h&&a.restoreSelectionByElem(h.get(0))}var f,g,h;return f=e.getRangeElem(),(g=e.getSelfOrParentByName(f,"blockquote"))?void e.customCommand(a,c,d):void a.preventDefault()},g.updateSelectedEvent=function(){var a,b=this,c=b.editor;return a=c.getRangeElem(),a=c.getSelfOrParentByName(a,"blockquote"),!!a},e.menus[d]=g,e.ready(function(){var a=this,c=a.txt.$txt,d=!1;c.on("keydown",function(c){if(13!==c.keyCode)return void(d=!1);var e=a.getRangeElem();if(e=a.getSelfOrParentByName(e,"blockquote"),!e)return void(d=!1);if(!d)return void(d=!0);var f=a.getRangeElem(),g=b(f);g.length&&g.parent().after(g),a.restoreSelectionByElem(f,"start"),d=!1,c.preventDefault()})}),e.ready(function(){function a(){d&&d.remove()}function c(){if(d){var a=d.prev();a.length?e.restoreSelectionByElem(a.get(0)):e.initSelection()}}var d,e=this,f=e.txt.$txt;f.on("keydown",function(f){if(8===f.keyCode){var g=e.getRangeElem();if(g=e.getSelfOrParentByName(g,"blockquote")){d=b(g);var h=d.text();h||e.customCommand(f,a,c)}}})})}})}),b(function(a,b){a.createMenu(function(c){var d="fontfamily";if(c(d)){var e=this,f=e.config.lang,g=e.config.familys,h=new a.Menu({editor:e,id:d,title:f.fontfamily,commandName:"fontName"}),i={};b.each(g,function(a,b){i[b]=b});var j='{#title}';h.dropList=new a.DropList(e,h,{data:i,tpl:j,selectorForELemCommand:"font[face]"}),h.updateSelectedEvent=function(){var a=e.getRangeElem();return a=e.getSelfOrParentByName(a,"font[face]"),!!a},e.menus[d]=h}})}),b(function(a,b){a.createMenu(function(b){var c="fontsize";if(b(c)){var d=this,e=d.config.lang,f=d.config.fontsizes,g=new a.Menu({editor:d,id:c,title:e.fontsize,commandName:"fontSize"}),h=f,i='{#title}';g.dropList=new a.DropList(d,g,{data:h,tpl:i,selectorForELemCommand:"font[size]"}),g.updateSelectedEvent=function(){var a=d.getRangeElem();return a=d.getSelfOrParentByName(a,"font[size]"),!!a},d.menus[c]=g}})}),b(function(a,b){a.createMenu(function(b){function c(a){g.queryCommandState("InsertOrderedList")?(f=!0,g.command(a,"InsertOrderedList")):f=!1}function d(a){f&&g.command(a,"InsertOrderedList")}var e="head";if(b(e)){var f,g=this,h=g.config.lang,i=new a.Menu({editor:g,id:e,title:h.head,commandName:"formatBlock"}),j={"

":"标题1","

":"标题2","

":"标题3","

":"标题4","

":"标题5"},k="{#commandValue}{#title}";i.dropList=new a.DropList(g,i,{data:j,tpl:k,beforeEvent:c,afterEvent:d}),i.updateSelectedEvent=function(){var a=g.getRangeElem();return a=g.getSelfOrParentByName(a,"h1,h2,h3,h4,h5"),!!a},g.menus[e]=i}})}),b(function(a,b){a.createMenu(function(b){var c="unorderlist";if(b(c)){var d=this,e=d.config.lang,f=new a.Menu({editor:d,id:c,title:e.unorderlist,commandName:"InsertUnorderedList"});d.menus[c]=f}})}),b(function(a,b){a.createMenu(function(b){var c="orderlist";if(b(c)){var d=this,e=d.config.lang,f=new a.Menu({editor:d,id:c,title:e.orderlist,commandName:"InsertOrderedList"});d.menus[c]=f}})}),b(function(a,b){a.createMenu(function(c){var d="alignleft";if(c(d)){var e=this,f=e.config.lang,g=new a.Menu({editor:e,id:d,title:f.alignleft,commandName:"JustifyLeft"});g.updateSelectedEvent=function(){var a=e.getRangeElem();return a=e.getSelfOrParentByName(a,"p,h1,h2,h3,h4,h5,li",function(a){var c;return!!(a&&a.style&&null!=a.style.cssText&&(c=a.style.cssText,c&&/text-align:\s*left;/.test(c)))||"left"===b(a).attr("align")}),!!a},e.menus[d]=g}})}),b(function(a,b){a.createMenu(function(c){var d="aligncenter";if(c(d)){var e=this,f=e.config.lang,g=new a.Menu({editor:e,id:d,title:f.aligncenter,commandName:"JustifyCenter"});g.updateSelectedEvent=function(){var a=e.getRangeElem();return a=e.getSelfOrParentByName(a,"p,h1,h2,h3,h4,h5,li",function(a){var c;return!!(a&&a.style&&null!=a.style.cssText&&(c=a.style.cssText,c&&/text-align:\s*center;/.test(c)))||"center"===b(a).attr("align")}),!!a},e.menus[d]=g}})}),b(function(a,b){a.createMenu(function(c){var d="alignright";if(c(d)){var e=this,f=e.config.lang,g=new a.Menu({editor:e,id:d,title:f.alignright,commandName:"JustifyRight"});g.updateSelectedEvent=function(){var a=e.getRangeElem();return a=e.getSelfOrParentByName(a,"p,h1,h2,h3,h4,h5,li",function(a){var c;return!!(a&&a.style&&null!=a.style.cssText&&(c=a.style.cssText,c&&/text-align:\s*right;/.test(c)))||"right"===b(a).attr("align")}),!!a},e.menus[d]=g}})}),b(function(a,b){a.createMenu(function(c){var d="link";if(c(d)){var e=this,f=e.config.lang,g=new a.Menu({editor:e,id:d,title:f.link}),h=b("
"),i=b('
'),j=i.clone(),k=i.clone().css("margin","0 10px"),l=b(''),m=b(''),n=b('"),o=b('");i.append(l),j.append(m),k.append(n).append(o),h.append(i).append(j).append(k),g.dropPanel=new a.DropPanel(e,g,{$content:h,width:300}),g.clickEvent=function(a){var b=this,c=b.dropPanel;if(c.isShowing)return void c.hide();l.val(""),m.val("http://");var d="",f=e.getRangeElem();f=e.getSelfOrParentByName(f,"a"),f&&(d=f.href||"");var g="",h=e.isRangeEmpty();h?f&&(g=f.textContent||f.innerHTML):g=e.getRangeText()||"",d&&m.val(d),g&&l.val(g),h?l.removeAttr("disabled"):l.attr("disabled",!0),c.show()},g.updateSelectedEvent=function(){var a=e.getRangeElem();return a=e.getSelfOrParentByName(a,"a"),!!a},o.click(function(a){a.preventDefault(),g.dropPanel.hide()}),n.click(function(c){c.preventDefault();var d,f,h,i,j,k,n=e.getRangeElem(),o=e.getSelfOrParentByName(n,"a"),p=e.isRangeEmpty(),q=e.txt.$txt,r="link"+a.random(),s=b.trim(m.val()),t=b.trim(l.val());return s?(t||(t=s),void(p?o?(d=b(o),h=function(){d.attr("href",s),d.text(t)},i=function(){var a=this;a.restoreSelectionByElem(o)},e.customCommand(c,h,i)):(f=''+t+"",a.userAgent.indexOf("Firefox")>0&&(f+=" "),e.command(c,"insertHtml",f)):(j=q.find("a"),j.attr(r,"1"),e.command(c,"createLink",s),k=q.find("a").not("["+r+"]"),k.attr("target","_blank"),j.removeAttr(r)))):void g.dropPanel.focusFirstInput()}),e.menus[d]=g}})}),b(function(a,b){a.createMenu(function(c){var d="unlink";if(c(d)){var e=this,f=e.config.lang,g=new a.Menu({editor:e,id:d,title:f.unlink,commandName:"unLink"});g.clickEvent=function(a){function c(){i.after(j).remove()}function d(){e.restoreSelectionByElem(j.get(0))}var f=e.isRangeEmpty();if(!f)return void e.command(a,"unLink");var g=e.getRangeElem(),h=e.getSelfOrParentByName(g,"a");if(!h)return void a.preventDefault();var i=b(h),j=b(""+i.text()+"");e.customCommand(a,c,d)},e.menus[d]=g}})}),b(function(a,b){a.createMenu(function(c){var d="table";if(c(d)){var e,f,g,h=this,i=h.config.lang,j=new a.Menu({editor:h,id:d,title:i.table}),k=b('
'),l=b(''),m=b("0"),n=b(""),o=b("0"),p=b("");for(f=0;f<15;f++){for(e=b(''),g=0;g<20;g++)e.append(b('
'));l.append(e)}k.append(l),k.append(m).append(n).append(o).append(p),l.on("mouseenter","td",function(a){var c=b(a.currentTarget),d=c.attr("index"),e=c.parent(),f=e.attr("index");m.text(f),o.text(d),l.find("tr").each(function(){var a=b(this),c=a.attr("index");parseInt(c,10)<=parseInt(f,10)?a.find("td").each(function(){var a=b(this),c=a.attr("index");parseInt(c,10)<=parseInt(d,10)?a.addClass("active"):a.removeClass("active")}):a.find("td").removeClass("active")})}).on("mouseleave",function(a){l.find("td").removeClass("active"),m.text(0),o.text(0)}),l.on("click","td",function(a){var c,d,e=b(a.currentTarget),f=e.attr("index"),g=e.parent(),i=g.attr("index"),j=parseInt(i,10),k=parseInt(f,10),l="";for(c=0;c",d=0;d ";l+=""}l+="
",h.command(a,"insertHtml",l)}),j.dropPanel=new a.DropPanel(h,j,{$content:k,width:262}),h.menus[d]=j}})}),b(function(a,b){a.createMenu(function(c){function d(a,c){b.each(a,function(a,d){var e=d.icon||d.url,g=d.value||d.title,h="icon"===j?e:g,i=b(''),k=b("");k.attr("_src",e),i.append(k),c.append(i),f.emotionUrls.push(e)})}var e="emotion";if(c(e)){var f=this,g=f.config,h=g.lang,i=g.emotions,j=g.emotionsShow;f.emotionUrls=[];var k=new a.Menu({editor:f,id:e,title:h.emotion}),l=b('
'),m=b('
'),n=b('
');b.each(i,function(c,e){var f=e.title,g=e.data;a.log("正在处理 "+f+" 表情的数据...");var h=b(''+f+" ");m.append(h);var i=b('
');if(n.append(i),h.click(function(a){m.children().removeClass("selected"),n.children().removeClass("selected"),i.addClass("selected"),h.addClass("selected"),a.preventDefault()}),"string"==typeof g)a.log("将通过 "+g+" 地址ajax下载表情包"),b.get(g,function(c){c=b.parseJSON(c),a.log("下载完毕,得到 "+c.length+" 个表情"),d(c,i)});else{if(!(Object.prototype.toString.call(g).toLowerCase().indexOf("array")>0))return void a.error("data 数据格式错误,请修改为正确格式,参考文档:"+a.docsite);d(g,i)}}),l.append(m).append(n),m.children().first().addClass("selected"),n.children().first().addClass("selected"),n.on("click","a[commandValue]",function(a){var c=b(a.currentTarget),d=c.attr("commandValue");"icon"===j?f.command(a,"InsertImage",d):f.command(a,"insertHtml",""+d+""),a.preventDefault()}),k.dropPanel=new a.DropPanel(f,k,{$content:l,width:350}),k.clickEvent=function(c){var d=this,e=d.dropPanel;return e.isShowing?void e.hide():(e.show(),void(d.imgLoaded||(n.find("img").each(function(){var c=b(this),d=c.attr("_src");c.on("error",function(){a.error("加载不出表情图片 "+d)}),c.attr("src",d),c.removeAttr("_src")}),d.imgLoaded=!0)))},f.menus[e]=k}})}),b(function(a,b){function c(a,c,d){function e(){h.val("")}var f=a.config.lang,g=b('
'),h=b('');g.append(h);var i=b('"),j=b('");d.append(g).append(i).append(j),j.click(function(a){a.preventDefault(),c.dropPanel.hide()}),i.click(function(c){c.preventDefault();var d=b.trim(h.val());if(!d)return void h.focus();var f='';a.command(c,"insertHtml",f,e)})}a.createMenu(function(d){function e(){o.click(function(a){m.children().removeClass("selected"),n.children().removeClass("selected"),q.addClass("selected"),o.addClass("selected"),a.preventDefault()}),p.click(function(b){m.children().removeClass("selected"),n.children().removeClass("selected"),r.addClass("selected"),p.addClass("selected"),b.preventDefault(),a.placeholder&&r.find("input[type=text]").focus()}),o.click()}function f(){m.remove(),q.remove(),r.addClass("selected")}function g(){m.remove(),r.remove(),q.addClass("selected")}var h="img";if(d(h)){var i=this,j=i.config.lang,k=new a.Menu({editor:i,id:h,title:j.img}),l=b('
'),m=b('
'),n=b('
');l.append(m).append(n);var o=b(''+j.uploadImg+""),p=b(''+j.linkImg+"");m.append(o).append(p);var q=b('
');n.append(q);var r=b('
');n.append(r),c(i,k,r),k.dropPanel=new a.DropPanel(i,k,{$content:l,width:400,onRender:function(){var a=i.config.customUploadInit;a&&a.call(i)}}),i.menus[h]=k,i.ready(function(){function a(){k.dropPanel.hide()}var b=this,c=b.config,d=c.uploadImgUrl,h=c.customUpload,i=c.hideLinkImg;d||h?(b.$uploadContent=q,e(),i&&g()):f(),q.click(function(){setTimeout(a)})})}})}),b(function(a,b){a.createMenu(function(c){var d="video";if(c(d)){var e=this,f=e.config.lang,g=/^<(iframe)|(embed)/i,h=new a.Menu({editor:e,id:d,title:f.video}),i=b("
"),j=b('
'),k=b('\'/>');j.append(k);var l=b('
'),m=b(''),n=b('');l.append(" "+f.width+" ").append(m).append(" px    ").append(" "+f.height+" ").append(n).append(" px ");var o=b("
"),p=b('如何复制视频链接?'),q=b('"),r=b('");o.append(p).append(q).append(r),i.append(j).append(l).append(o),r.click(function(a){a.preventDefault(),k.val(""),h.dropPanel.hide()}),q.click(function(a){a.preventDefault();var c,d=b.trim(k.val()),f=parseInt(m.val()),i=parseInt(n.val()),j=b("
"),l="

{content}

";return d?g.test(d)?isNaN(f)||isNaN(i)?void alert("宽度或高度不是数字!"):(c=b(d),c.attr("width",f).attr("height",i),l=l.replace("{content}",j.append(c).html()),e.command(a,"insertHtml",l),void k.val("")):(alert("视频链接格式错误!"),void h.dropPanel.focusFirstInput()):void h.dropPanel.focusFirstInput()}),h.dropPanel=new a.DropPanel(e,h,{$content:i,width:400}),e.menus[d]=h}})}),b(function(a,b){var c=function(a){return"onkeyup"in a}(document.createElement("input"));a.baiduMapAk="TVhjYjq1ICT2qqL5LdS8mwas",a.numberOfLocation=0,a.createMenu(function(d){function e(){q.val("")}var f="location";if(d(f)){if(++a.numberOfLocation>1)return void a.error("目前不支持在一个页面多个编辑器上同时使用地图,可通过自定义菜单配置去掉地图菜单");var g=this,h=g.config,i=h.lang,j=h.mapAk;g.mapData={};var k=g.mapData;k.markers=[],k.mapContainerId="map"+a.random(),k.clearLocations=function(){var a=k.map;a&&(a.clearOverlays(),k.markers=[])},k.searchMap=function(){var a=k.map;if(a){var b,c,d=window.BMap,e=p.val(),f=q.val();""!==e&&(f&&""!==f||a.centerAndZoom(e,11),f&&""!==f&&(b=new d.Geocoder,b.getPoint(f,function(b){b?(a.centerAndZoom(b,13),c=new d.Marker(b),a.addOverlay(c),c.enableDragging(),k.markers.push(c)):a.centerAndZoom(e,11)},e)))}};var l=!1;window.baiduMapCallBack=function(){function b(b){var d=b.name;e.setCenter(d),p.val(d),a.placeholder&&q.focus();var f,g;c?(g=function(a){"keyup"===a.type&&13===a.keyCode&&a.preventDefault(),f&&clearTimeout(f),f=setTimeout(k.searchMap,500)},p.on("keyup change paste",g),q.on("keyup change paste",g)):(g=function(){if(!n.is(":visible"))return void clearTimeout(f);var a="",b="",c=p.val(),d=q.val();c===a&&d===b||(k.searchMap(),a=c,b=d),f&&clearTimeout(f),f=setTimeout(g,1e3)},f=setTimeout(g,1e3))}if(!l){l=!0;var d=window.BMap;k.map||(k.map=new d.Map(k.mapContainerId));var e=k.map;e.centerAndZoom(new d.Point(116.404,39.915),11),e.addControl(new d.MapTypeControl),e.setCurrentCity("北京"),e.enableScrollWheelZoom(!0);var f=new d.LocalCity;f.get(b),e.addEventListener("click",function(a){var b=new d.Marker(new d.Point(a.point.lng,a.point.lat));e.addOverlay(b),b.enableDragging(),k.markers.push(b)},!1)}},k.loadMapScript=function(){var b=document.createElement("script");b.type="text/javascript",b.src="https://api.map.baidu.com/api?v=2.0&ak="+j+"&s=1&callback=baiduMapCallBack";try{document.body.appendChild(b)}catch(c){a.error("加载地图过程中发生错误")}},k.initMap=function(){window.BMap?window.baiduMapCallBack():k.loadMapScript()};var m=new a.Menu({editor:g,id:f,title:i.location});g.menus[f]=m;var n=b("
"),o=b('
'),p=b('');p.css({width:"80px","text-align":"center"});var q=b('');q.css({width:"300px","margin-left":"10px"}).attr("placeholder",i.searchlocation);var r=b('");o.append(r).append(p).append(q),n.append(o),r.click(function(a){q.val(""),q.focus(),k.clearLocations(),a.preventDefault()});var s=b('
');s.css({height:"260px",width:"100%",position:"relative","margin-top":"10px",border:"1px solid #f1f1f1"});var t=b(""+i.loading+"");t.css({position:"absolute",width:"100px","text-align":"center",top:"45%",left:"50%","margin-left":"-50px"}),s.append(t),n.append(s);var u=b('
'),v=b('"),w=b('"),x=b(''),y=b('');x.append(y).append(' '+i.dynamicMap+""),u.append(x).append(v).append(w),n.append(u),w.click(function(a){a.preventDefault(),e(),m.dropPanel.hide()}),v.click(function(a){a.preventDefault();var c,d,f,h=k.map,j=y.is(":checked"),l=k.markers,m=h.getCenter(),n=m.lng,o=m.lat,p=h.getZoom(),q=h.getSize(),r=q.width,s=q.height;if(d=j?"http://ueditor.baidu.com/ueditor/dialogs/map/show.html#":"http://api.map.baidu.com/staticimage?",d=d+"center="+n+","+o+"&zoom="+p+"&width="+r+"&height="+s,l.length>0&&(d+="&markers=",b.each(l,function(a,b){c=b.getPosition(),a>0&&(d+="|"),d=d+c.lng+","+c.lat})),j){if(l.length>1)return void alert(i.langDynamicOneLocation);d+="&markerStyles=l,A",f='',f=f.replace("{src}",d),g.command(a,"insertHtml",f,e)}else g.command(a,"insertHtml",'',e)}),m.dropPanel=new a.DropPanel(g,m,{$content:n,width:500}),m.onRender=function(){j===a.baiduMapAk&&a.warn("建议在配置中自定义百度地图的mapAk,否则可能影响地图功能,文档:"+a.docsite)},m.clickEvent=function(a){var b=this,c=b.dropPanel,d=!1;return c.isShowing?void c.hide():(k.map||(d=!0),c.show(),k.initMap(),void(d||q.focus()))}}})}),b(function(a,b){function c(){if(!(a.userAgent.indexOf("MSIE 8")>0||window.hljs)){var b=document.createElement("script");b.type="text/javascript",b.src="//cdn.bootcss.com/highlight.js/9.2.0/highlight.min.js",document.body.appendChild(b)}}a.createMenu(function(d){function e(a){var c=b("
");c.css({margin:"15px 5px 5px 5px",height:"160px","text-align":"center"}),n.css({width:"100%",height:"100%",padding:"10px"}),n.on("keydown",function(a){9===a.keyCode&&a.preventDefault()}),c.append(n),a.append(c);var d=b("
"),e=b('"),f=b('");d.append(e).append(f).append(o),a.append(d),f.click(function(a){a.preventDefault(),l.dropPanel.hide()});var g='
{#content}
';e.click(function(a){function c(){var a;i&&(a=q.attr("class"),a!==i+" hljs"&&q.attr("class",i+" hljs")),q.html(e)}function d(){h.restoreSelectionByElem(r),m()}a.preventDefault();var e=n.val();if(!e)return void n.focus();var f=h.getRangeElem();b.trim(b(f).text())&&0!==g.indexOf("


")&&(g="


"+g);var i=o?o.val():"",j="",m=function(){k.find("pre code").each(function(a,c){var d=b(c);d.attr("codemark")||window.hljs&&(window.hljs.highlightBlock(c),d.attr("codemark","1"))})};if(i&&(j=' class="'+i+' hljs"'),e=e.replace(/&/gm,"&").replace(//gm,">"),!l.selected){var p=g.replace("{#langClass}",j).replace("{#content}",e);return void h.command(a,"insertHtml",p,m)}var q,r=h.getSelfOrParentByName(f,"pre");r&&(r=h.getSelfOrParentByName(f,"code")),r&&(q=b(r),h.customCommand(a,c,d))})}function f(){var a=h.getRangeElem(),b=h.getSelfOrParentByName(a,"code");b?h.disableMenusExcept("insertcode"):h.enableMenusExcept("insertcode")}var g="insertcode";if(d(g)){setTimeout(c,0);var h=this,i=h.config,j=i.lang,k=h.txt.$txt,l=new a.Menu({editor:h,id:g,title:j.insertcode});l.clickEvent=function(a){var c=this,d=c.dropPanel;if(d.isShowing)return void d.hide();n.val(""),d.show();var e=window.hljs;if(e&&e.listLanguages){if(0!==o.children().length)return;o.css({"margin-top":"9px","margin-left":"5px"}),b.each(e.listLanguages(),function(a,b){"xml"===b&&(b="html"),b===i.codeDefaultLang?o.append('"):o.append('")})}else o.hide()},l.clickEventSelected=function(a){var c=this,d=c.dropPanel;if(d.isShowing)return void d.hide();d.show();var e,f,g=h.getRangeElem(),i=h.getSelfOrParentByName(g,"pre");i&&(i=h.getSelfOrParentByName(g,"code")),i&&(e=b(i),n.val(e.text()),o&&(f=e.attr("class"),f&&o.val(f.split(" ")[0])))},l.updateSelectedEvent=function(){var a,b=this,c=b.editor;return a=c.getRangeElem(),a=c.getSelfOrParentByName(a,"pre"),!!a};var m=b("
"),n=b(""),o=b("");e(m),l.dropPanel=new a.DropPanel(h,l,{$content:m,width:500}),h.menus[g]=l,k.on("keydown",function(a){if(13===a.keyCode){var b=h.getRangeElem(),c=h.getSelfOrParentByName(b,"code");c&&h.command(a,"insertHtml","\n")}}),k.on("keydown click",function(a){setTimeout(f)})}})}),b(function(a,b){a.createMenu(function(b){var c="undo";if(b(c)){var d=this,e=d.config.lang,f=new a.Menu({editor:d,id:c,title:e.undo});f.clickEvent=function(a){d.undo()},d.menus[c]=f,d.ready(function(){function a(){c.undoRecord()}var b,c=this,d=c.txt.$txt;d.on("keydown",function(d){var e=d.keyCode;return d.ctrlKey&&90===e?void c.undo():void(13===e?a():(b&&clearTimeout(b),b=setTimeout(a,1e3)))}),c.undoRecord()})}})}),b(function(a,b){a.createMenu(function(b){var c="redo";if(b(c)){var d=this,e=d.config.lang,f=new a.Menu({editor:d,id:c,title:e.redo});f.clickEvent=function(a){d.redo()},d.menus[c]=f}})}),b(function(a,b){var c;a.createMenu(function(b){var d="fullscreen";if(b(d)){var e,f,g=this,h=g.txt.$txt,i=g.config,j=i.zindex||1e4,k=i.lang,l=!1,m=new a.Menu({editor:g,id:d,title:k.fullscreen});m.clickEvent=function(b){var d=g.$editorContainer;d.addClass("wangEditor-fullscreen"),e=d.css("z-index"),d.css("z-index",j); var i,k=h.height(),m=h.outerHeight();g.useMaxHeight&&(f=h.css("max-height"),h.css("max-height","none"),i=h.parent(),i.after(h),i.remove(),h.css("overflow-y","auto"));var n=g.menuContainer;h.height(a.$window.height()-n.height()-(m-k)),g.menuContainer.$menuContainer.attr("style",""),l=!0,g.isFullScreen=!0,c=a.$window.scrollTop()},m.clickEventSelected=function(b){var d=g.$editorContainer;d.removeClass("wangEditor-fullscreen"),d.css("z-index",e),g.useMaxHeight?h.css("max-height",f):g.$valueContainer.css("height",g.valueContainerHeight),g.txt.initHeight(),l=!1,g.isFullScreen=!1,null!=c&&a.$window.scrollTop(c)},m.updateSelectedEvent=function(a){return l},g.menus[d]=m}})}),b(function(a,b){a.fn.renderMenus=function(){var a,c=this,d=c.menus,e=c.config.menus,f=(c.menuContainer,0);b.each(e,function(b,c){return"|"===c?void f++:(a=d[c],void(a&&a.render(f)))})}}),b(function(a,b){a.fn.renderMenuContainer=function(){var a=this,b=a.menuContainer;a.$editorContainer;b.render()}}),b(function(a,b){a.fn.renderTxt=function(){var a=this,b=a.txt;b.render(),a.ready(function(){b.initHeight()})}}),b(function(a,b){a.fn.renderEditorContainer=function(){var a,b,c=this,d=c.$valueContainer,e=c.$editorContainer,f=c.txt.$txt;d===f?(a=c.$prev,b=c.$parent,a&&a.length?a.after(e):b.prepend(e)):(d.after(e),d.hide())}}),b(function(a,b){a.fn.eventMenus=function(){var a=this.menus;b.each(a,function(a,b){b.bindEvent()})}}),b(function(a,b){a.fn.eventMenuContainer=function(){}}),b(function(a,b){a.fn.eventTxt=function(){var a=this.txt;a.saveSelectionEvent(),a.updateValueEvent(),a.updateMenuStyleEvent()}}),b(function(a,b){a.plugin(function(){var b=this,c=b.config.uploadImgFns;c.onload||(c.onload=function(b,c){a.log("上传结束,返回结果为 "+b);var d,e=this,f=e.uploadImgOriginalName||"";0===b.indexOf("error|")?(a.warn("上传失败:"+b.split("|")[1]),alert(b.split("|")[1])):(a.log("上传成功,即将插入编辑区域,结果为:"+b),d=document.createElement("img"),d.onload=function(){var c=''+f+'';e.command(null,"insertHtml",c),a.log("已插入图片,地址 "+b),d=null},d.onerror=function(){a.error("使用返回的结果获取图片,发生错误。请确认以下结果是否正确:"+b),d=null},d.src=b)}),c.ontimeout||(c.ontimeout=function(b){a.error("上传图片超时"),alert("上传图片超时")}),c.onerror||(c.onerror=function(b){a.error("上传上图片发生错误"),alert("上传上图片发生错误")})})}),b(function(a,b){window.FileReader&&window.FormData&&a.plugin(function(){function c(a,b){var c,d=window.atob(a.split(",")[1]),e=new ArrayBuffer(d.length),f=new Uint8Array(e);for(c=0;c';f.command(c,"insertHtml",e),a.log("已插入图片,地址 "+b),d=null},d.onerror=function(){a.error("使用返回的结果获取图片,发生错误。请确认以下结果是否正确:"+b),d=null},d.src=b}function e(a){if(a.lengthComputable){var b=a.loaded/a.total;f.showUploadProgress(100*b)}}var f=this,g=f.config,h=g.uploadImgUrl,i=g.uploadTimeout,j=g.uploadImgFns,k=j.onload,l=j.ontimeout,m=j.onerror;h&&(f.xhrUploadImg=function(g){function j(){y&&clearTimeout(y),z&&z.abort&&z.abort(),n.preventDefault(),u&&u.call(f,z),f.hideUploadProgress()}var n=g.event,o=g.filename||"",p=g.base64,q=g.fileType||"image/png",r=g.name||"wangEditor_upload_file",s=g.loadfn||k,t=g.errorfn||m,u=g.timeoutfn||l,v=f.config.uploadParams||{},w=f.config.uploadHeaders||{},x="png";if(o.indexOf(".")>0?x=o.slice(o.lastIndexOf(".")-o.length+1):q.indexOf("/")>0&&q.split("/")[1]&&(x=q.split("/")[1]),a.isOnWebsite)return a.log("预览模拟上传"),void d(p,n);var y,z=new XMLHttpRequest,A=new FormData;z.onload=function(){y&&clearTimeout(y),f.uploadImgOriginalName=o,o.indexOf(".")>0&&(f.uploadImgOriginalName=o.split(".")[0]),s&&s.call(f,z.responseText,z),f.hideUploadProgress()},z.onerror=function(){y&&clearTimeout(y),n.preventDefault(),t&&t.call(f,z),f.hideUploadProgress()},z.upload.onprogress=e,A.append(r,c(p,q),a.random()+"."+x),b.each(v,function(a,b){A.append(a,b)}),z.open("POST",h,!0),b.each(w,function(a,b){z.setRequestHeader(a,b)}),z.withCredentials=f.config.withCredentials||!0,z.send(A),y=setTimeout(j,i),a.log("开始上传...并开始超时计算")})})}),b(function(a,b){a.plugin(function(){function a(){j||(j=!0,i.css({top:f+"px"}),g.append(i))}function c(){i.hide(),k=null}var d=this,e=d.menuContainer,f=e.height(),g=d.$editorContainer,h=g.width(),i=b('
'),j=!1;d.showUploadProgress=function(b){k&&clearTimeout(k),a(),i.show(),i.width(b*h/100)};var k;d.hideUploadProgress=function(a){k&&clearTimeout(k),a=a||750,k=setTimeout(c,a)}})}),b(function(a,b){a.plugin(function(){var c,d=this,e=d.config,f=e.uploadImgUrl,g=e.uploadTimeout;if(f){var h=d.$uploadContent;if(h){var i=b('
');h.append(i);var j=new a.UploadFile({editor:d,uploadUrl:f,timeout:g,fileAccept:"image/jpg,image/jpeg,image/png,image/gif,image/bmp"});i.click(function(a){c=a,j.selectFiles()})}}})}),b(function(a,b){if(window.FileReader&&window.FormData){var c=function(a){this.editor=a.editor,this.uploadUrl=a.uploadUrl,this.timeout=a.timeout,this.fileAccept=a.fileAccept,this.multiple=!0};c.fn=c.prototype,c.fn.clear=function(){this.$input.val(""),a.log("input value 已清空")},c.fn.render=function(){var c=this;if(!c._hasRender){a.log("渲染dom");var d=c.fileAccept,e=d?'accept="'+d+'"':"",f=c.multiple,g=f?'multiple="multiple"':"",h=b('"),i=b('
');i.append(h),a.$body.append(i),h.on("change",function(a){c.selected(a,h.get(0))}),c.$input=h,c._hasRender=!0}},c.fn.selectFiles=function(){var b=this;a.log("使用 html5 方式上传"),b.render(),a.log("选择文件"),b.$input.click()},c.fn.selected=function(c,d){var e=this,f=d.files||[];0!==f.length&&(a.log("选中 "+f.length+" 个文件"),b.each(f,function(a,b){e.upload(b)}))},c.fn.upload=function(b){function c(){d.clear()}var d=this,e=d.editor,f=b.name||"",g=b.type||"",h=e.config.uploadImgFns,i=e.config.uploadImgFileName||"wangEditorH5File",j=h.onload,k=h.ontimeout,l=h.onerror,m=new FileReader;return j&&k&&l?(a.log("开始执行 "+f+" 文件的上传"),m.onload=function(b){a.log("已读取"+f+"文件");var d=b.target.result||this.result;e.xhrUploadImg({event:b,filename:f,base64:d,fileType:g,name:i,loadfn:function(a,b){c();var d=this;j.call(d,a,b)},errorfn:function(b){c(),a.isOnWebsite&&alert("wangEditor官网暂时没有服务端,因此报错。实际项目中不会发生");var d=this;l.call(d,b)},timeoutfn:function(b){c(),a.isOnWebsite&&alert("wangEditor官网暂时没有服务端,因此超时。实际项目中不会发生");var d=this;k(d,b)}})},void m.readAsDataURL(b)):void a.error("请为编辑器配置上传图片的 onload ontimeout onerror 回调事件")},a.UploadFile=c}}),b(function(a,b){if(!window.FileReader||!window.FormData){var c=function(a){this.editor=a.editor,this.uploadUrl=a.uploadUrl,this.timeout=a.timeout,this.fileAccept=a.fileAccept,this.multiple=!1};c.fn=c.prototype,c.fn.clear=function(){this.$input.val(""),a.log("input value 已清空")},c.fn.hideModal=function(){this.modal.hide()},c.fn.render=function(){var c=this,d=c.editor,e=d.config.uploadImgFileName||"wangEditorFormFile";if(!c._hasRender){var f=c.uploadUrl;a.log("渲染dom");var g="iframe"+a.random(),h=b(''),i=c.multiple,j=i?'multiple="multiple"':"",k=b("

选择图片并上传

"),l=b(''),m=b(''),n=b('
'),o=b('
');n.append(k).append(l).append(m),b.each(d.config.uploadParams,function(a,c){n.append(b(''))}),o.append(n),o.append(h),c.$input=l,c.$iframe=h;var p=new a.Modal(d,(void 0),{$content:o});c.modal=p,c._hasRender=!0}},c.fn.bindLoadEvent=function(){function a(){var a=b.trim(g.document.body.innerHTML);if(a){var e=c.$input.val(),f=e;e.lastIndexOf("\\")>=0&&(f=e.slice(e.lastIndexOf("\\")+1),f.indexOf(".")>0&&(f=f.split(".")[0])),d.uploadImgOriginalName=f,h.call(d,a),c.clear(),c.hideModal()}}var c=this;if(!c._hasBindLoad){var d=c.editor,e=c.$iframe,f=e.get(0),g=f.contentWindow,h=d.config.uploadImgFns.onload;f.attachEvent?f.attachEvent("onload",a):f.onload=a,c._hasBindLoad=!0}},c.fn.show=function(){function a(){c.show(),b.bindLoadEvent()}var b=this,c=b.modal;setTimeout(a)},c.fn.selectFiles=function(){var b=this;a.log("使用 form 方式上传"),b.render(),b.clear(),b.show()},a.UploadFile=c}}),b(function(a,b){a.plugin(function(){function c(){var c=/^data:(image\/\w+);base64/,g=h.find("img");a.log("粘贴后,检查到编辑器有"+g.length+"个图片。开始遍历图片,试图找到刚刚粘贴过来的图片"),b.each(g,function(){var g,h,i=this,j=b(i),l=j.attr("src");e.each(function(){if(i===this)return g=!0,!1}),g||(a.log("找到一个粘贴过来的图片"),c.test(l)?(a.log("src 是 base64 格式,可以上传"),h=l.match(c)[1],f.xhrUploadImg({event:d,base64:l,fileType:h,name:k})):a.log("src 为 "+l+" ,不是 base64 格式,暂时不支持上传"),j.remove())}),a.log("遍历结束")}var d,e,f=this,g=f.txt,h=g.$txt,i=f.config,j=i.uploadImgUrl,k=i.uploadImgFileName||"wangEditorPasteFile";j&&h.on("paste",function(g){d=g;var i,j,l=d.clipboardData||d.originalEvent.clipboardData;i=null==l?window.clipboardData&&window.clipboardData.getData("text"):l.getData("text/plain")||l.getData("text/html"),i||(j=l&&l.items,j?(a.log("通过 data.items 得到了数据"),b.each(j,function(b,c){var e=c.type||"";if(!(e.indexOf("image")<0)){var g=c.getAsFile(),h=new FileReader;a.log("得到一个粘贴图片"),h.onload=function(b){a.log("读取到粘贴的图片");var c=b.target.result||this.result;f.xhrUploadImg({event:d,base64:c,fileType:e,name:k})},h.readAsDataURL(g)}})):(a.log("未从 data.items 得到数据,使用检测粘贴图片的方式"),e=h.find("img"),a.log("粘贴前,检查到编辑器有"+e.length+"个图片"),setTimeout(c,0)))})})}),b(function(a,b){a.plugin(function(){var c=this,d=c.txt,e=d.$txt,f=c.config,g=f.uploadImgUrl,h=f.uploadImgFileName||"wangEditorDragFile";g&&(a.$document.on("dragleave drop dragenter dragover",function(a){a.preventDefault()}),e.on("drop",function(d){d.preventDefault();var e=d.originalEvent,f=e.dataTransfer&&e.dataTransfer.files;f&&f.length&&b.each(f,function(b,e){var f=e.type,g=e.name;if(!(f.indexOf("image/")<0)){a.log("得到图片 "+g);var i=new FileReader;i.onload=function(b){a.log("读取到图片 "+g);var e=b.target.result||this.result;c.xhrUploadImg({event:d,base64:e,fileType:f,name:h})},i.readAsDataURL(e)}})}))})}),b(function(a,b){a.plugin(function(){function c(){m||(d(),n.append(o).append(p).append(q).append(r),h.$editorContainer.append(n),m=!0)}function d(){function a(a,c){k=j.html();var d=function(){c&&c(),k!==j.html()&&j.change()};b&&h.customCommand(a,b,d)}var b;p.click(function(c){b=function(){g.remove()},a(c,function(){setTimeout(f,100)})}),r.click(function(c){b=function(){g.css({width:"100%"})},a(c,function(){setTimeout(e)})}),q.click(function(c){b=function(){g.css({width:"auto"})},a(c,function(){setTimeout(e)})})}function e(){if(!h._disabled&&null!=g){g.addClass("clicked");var a=g.position(),b=a.top,c=a.left,d=g.outerHeight(),e=g.outerWidth(),f=b+d,i=c,j=0,k=l.position().top,m=l.outerHeight();f>k+m&&(f=k+m),n.show();var p=n.outerWidth();j=e/2-p/2,n.css({top:f+5,left:i,"margin-left":j}),j<0?(n.css("margin-left","0"),o.hide()):o.show()}}function f(){null!=g&&(g.removeClass("clicked"),g=null,n.hide())}var g,h=this,i=h.txt,j=i.$txt,k="",l=h.useMaxHeight?j.parent():j,m=!1,n=b('
'),o=b('
'),p=b(''),q=b(''),r=b('');l.on("click","table",function(a){var d=b(a.currentTarget);return c(),g&&g.get(0)===d.get(0)?void setTimeout(f,100):(g=d,e(),a.preventDefault(),void a.stopPropagation())}).on("click keydown scroll",function(a){setTimeout(f,100)}),a.$body.on("click keydown scroll",function(a){setTimeout(f,100)})})}),b(function(a,b){a.userAgent.indexOf("MSIE 8")>0||a.plugin(function(){function c(a,c){if(j){var d,e,f=function(){null!=c&&(q=c),o!==n.html()&&n.change()},g=!1,h=j.parent();if("a"===h.get(0).nodeName.toLowerCase()?(e=h,g=!0):e=b(''),null==c)return e.attr("href")||"";if(""===c)g&&(d=function(){j.unwrap()});else{if(c===q)return;d=function(){e.attr("href",c),g||j.wrap(e)}}d&&(o=n.html(),k.customCommand(a,d,f))}}function d(){r||(e(),f(),v.append(w).append(x).append(y).append(z).append(A).append(B).append(C).append(D),E.append(F).append(H).append(G),t.append(u).append(v).append(E),k.$editorContainer.append(t).append(s),r=!0)}function e(){function a(a,b){var c;o=n.html(),c=function(){b&&b(),o!==n.html()&&n.change()},d&&k.customCommand(a,d,c)}var d;w.click(function(b){c(b,""),d=function(){j.remove()},a(b,function(){setTimeout(h,100)})}),y.click(function(b){d=function(){var a=j.get(0),b=a.width,c=a.height;b=1.1*b,c=1.1*c,j.css({width:b+"px",height:c+"px"})},a(b,function(){setTimeout(g)})}),x.click(function(b){d=function(){var a=j.get(0),b=a.width,c=a.height;b=.9*b,c=.9*c,j.css({width:b+"px",height:c+"px"})},a(b,function(){setTimeout(g)})}),z.click(function(b){d=function(){j.parents("p").css({"text-align":"left"}).attr("align","left")},a(b,function(){setTimeout(h,100)})}),B.click(function(b){d=function(){j.parents("p").css({"text-align":"right"}).attr("align","right")},a(b,function(){setTimeout(h,100)})}),A.click(function(b){d=function(){j.parents("p").css({"text-align":"center"}).attr("align","center")},a(b,function(){setTimeout(h,100)})}),C.click(function(a){a.preventDefault(),q=c(a),F.val(q),v.hide(),E.show()}),G.click(function(a){a.preventDefault();var d=b.trim(F.val());d&&c(a,d),setTimeout(h)}),H.click(function(a){a.preventDefault(),F.val(q),v.show(),E.hide()}),D.click(function(a){a.preventDefault(),c(a,""),setTimeout(h)})}function f(){function b(a){var b,h;b=a.pageX-c,h=a.pageY-d;var k=e+b,l=f+h;s.css({"margin-left":k,"margin-top":l});var m=g+b,n=i+h;j&&j.css({width:m,height:n})}var c,d,e,f,g,i;s.on("mousedown",function(k){j&&(c=k.pageX,d=k.pageY,e=parseFloat(s.css("margin-left"),10),f=parseFloat(s.css("margin-top"),10),g=j.width(),i=j.height(),t.hide(),a.$document.on("mousemove._dragResizeImg",b),a.$document.on("mouseup._dragResizeImg",function(b){a.$document.off("mousemove._dragResizeImg"),a.$document.off("mouseup._dragResizeImg"),h(),s.css({"margin-left":e,"margin-top":f}),I=!1}),I=!0)})}function g(){if(!k._disabled&&null!=j){j.addClass("clicked");var a=j.position(),b=a.top,c=a.left,d=j.outerHeight(),e=j.outerWidth();s.css({top:b+d,left:c+e});var f=b+d,g=c,h=0,i=p.position().top,l=p.outerHeight();f>i+l?f=i+l:s.show(),t.show();var m=t.outerWidth();h=e/2-m/2,t.css({top:f+5,left:g,"margin-left":h}),h<0?(t.css("margin-left","0"),u.hide()):u.show(),k.disableMenusExcept()}}function h(){null!=j&&(j.removeClass("clicked"),j=null,t.hide(),s.hide(),k.enableMenusExcept())}function i(a){var c=!1;return k.emotionUrls?(b.each(k.emotionUrls,function(b,d){var e=!1;if(a===d&&(c=!0,e=!0),e)return!1}),c):c}var j,k=this,l=k.config.lang,m=k.txt,n=m.$txt,o="",p=k.useMaxHeight?n.parent():n,q=(k.$editorContainer,""),r=!1,s=b('
'),t=b('
'),u=b('
'),v=b("
"),w=b(''),x=b(''),y=b(''),z=b(''),A=b(''),B=b(''),C=b(''),D=b(''),E=b('
'),F=b(''),G=b('"),H=b('"),I=!1;p.on("mousedown","img",function(a){a.preventDefault()}).on("click","img",function(a){var c=b(a.currentTarget),e=c.attr("src");if(e&&!i(e)){if(d(),j&&j.get(0)===c.get(0))return void setTimeout(h,100);j=c,g(),v.show(),E.hide(),a.preventDefault(),a.stopPropagation()}}).on("click keydown scroll",function(a){I||setTimeout(h,100)})})}),b(function(a,b){a.plugin(function(){function a(){g||(n.append(o).append(p),k.$editorContainer.append(n),g=!0)}function c(){if(f){var a=f.position(),b=a.left,c=a.top,d=f.height(),e=c+d+5,g=k.menuContainer.height(),h=k.txt.$txt.outerHeight();e>g+h&&(e=g+h+5),n.css({top:e,left:b})}}function d(){if(!q&&f){a(),n.show();var b=f.attr("href");p.attr("href",b),c(),q=!0}}function e(){q&&f&&(n.hide(),q=!1)}var f,g,h,i,j,k=this,l=k.config.lang,m=k.txt.$txt,n=b('
'),o=b('
'),p=b(' '+l.openLink+""),q=!1;m.on("mouseenter","a",function(a){h&&clearTimeout(h),h=setTimeout(function(){var c=a.currentTarget,g=b(c);f=g;var h=g.children("img");h.length&&(h.click(function(a){e()}),h.hasClass("clicked"))||d()},500)}).on("mouseleave","a",function(a){i&&clearTimeout(i),i=setTimeout(e,500)}).on("click keydown scroll",function(a){setTimeout(e,100)}),n.on("mouseenter",function(a){i&&clearTimeout(i)}).on("mouseleave",function(a){j&&clearTimeout(j),j=setTimeout(e,500)})})}),b(function(a,b){a.plugin(function(){var b=this,c=b.config.menuFixed;if(c!==!1&&"number"==typeof c){var d=parseFloat(a.$body.css("margin-top"),10);isNaN(d)&&(d=0);var e=b.$editorContainer,f=e.offset().top,g=e.outerHeight(),h=b.menuContainer.$menuContainer,i=h.css("position"),j=h.css("top"),k=h.offset().top,l=h.outerHeight();b.txt.$txt;a.$window.scroll(function(){if(!b.isFullScreen){var m=a.$window.scrollTop(),n=h.width();0===k&&(k=h.offset().top,f=e.offset().top,g=e.outerHeight(),l=h.outerHeight()),m>=k&&m+c+l+30'),$domSelected:b('')});f.clickEvent=function(a){function c(){d.css("text-indent","2em")}var d,f=e.getRangeElem(),g=e.getSelfOrParentByName(f,"p");return g?(d=b(g),void e.customCommand(a,c)):a.preventDefault()},f.clickEventSelected=function(a){function c(){d.css("text-indent","0")}var d,f=e.getRangeElem(),g=e.getSelfOrParentByName(f,"p");return g?(d=b(g),void e.customCommand(a,c)):a.preventDefault()},f.updateSelectedEvent=function(){var a,c,d=e.getRangeElem(),f=e.getSelfOrParentByName(d,"p");return!!f&&(a=b(f),c=a.css("text-indent"),!(!c||"0px"===c))},e.menus[d]=f}})}),b(function(a,b){a.createMenu(function(c){var d="lineheight";if(c(d)){var e=this;e.commandHooks.lineHeight=function(a){var c=e.getRangeElem(),d=e.getSelfOrParentByName(c,"p,h1,h2,h3,h4,h5,pre");d&&b(d).css("line-height",a+"")};var f=new a.Menu({editor:e,id:d,title:"行高",commandName:"lineHeight",$domNormal:b(''),$domSelected:b('')}),g={"1.0":"1.0倍",1.5:"1.5倍",1.8:"1.8倍","2.0":"2.0倍",2.5:"2.5倍","3.0":"3.0倍"},h='{#title}';f.dropList=new a.DropList(e,f,{data:g,tpl:h}),e.menus[d]=f}})}),b(function(a,b){a.plugin(function(){var c=this,d=c.config.customUpload;if(d){if(c.config.uploadImgUrl)return alert("自定义上传无效,详看浏览器日志console.log"),void a.error("已经配置了 uploadImgUrl ,就不能再配置 customUpload ,两者冲突。将导致自定义上传无效。");var e=c.$uploadContent;e||a.error("自定义上传,无法获取 editor.$uploadContent");var f=b('
');e.append(f);var g="upload"+a.random(),h="upload"+a.random();f.attr("id",g),e.attr("id",h),c.customUploadBtnId=g,c.customUploadContainerId=h}})}),b(function(a,b){a.info("本页面富文本编辑器由 wangEditor 提供 http://wangeditor.github.io/ ")}),window.wangEditor});