You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3 lines
84 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

!function(a){"function"==typeof window.define?window.define.amd?window.define("wangEditor",["jquery"],a):window.define.cmd?window.define(function(){return a}):a(window.jQuery):"object"==typeof module&&"object"==typeof module.exports?(window.wangEditorCssPath?require(window.wangEditorCssPath):require("../css/wangEditor.css"),module.exports=a(window.wangEditorJQueryPath?require(window.wangEditorJQueryPath):require("jquery"))):a(window.jQuery)}(function(a){if(!a||!a.fn||!a.fn.jquery)return alert("在引用wangEditor.js之前先引用jQuery否则无法使用 wangEditor"),void 0;var b=function(b){var c=window.wangEditor;c&&b(c,a)};return function(a,b){if(a.wangEditor)return alert("一个页面不能重复引用 wangEditor.js 或 wangEditor.min.js "),void 0;var c=function(a){var c,d;"string"==typeof a&&(a="#"+a),c=b(a),1===c.length&&(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){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 d,a=this,b=a.$valueContainer,c=a.txt.$txt;b!==c&&(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 d(){}var c=!a.w3cRange;a.fn.currentRange=function(a){return a?(this._rangeData=a,void 0):this._rangeData},a.fn.collapseRange=function(a,b){b=b||"end",b="start"===b?!0:!1,a=a||this.currentRange(),a&&(a.collapse(b),this.currentRange(a))},a.fn.getRangeText=c?d:function(a){return(a=a||this.currentRange())?a.toString():void 0},a.fn.getRangeElem=c?d:function(a){a=a||this.currentRange();var b=a.commonAncestorContainer;return 1===b.nodeType?b:b.parentNode},a.fn.isRangeEmpty=c?d:function(a){return a=a||this.currentRange(),a&&a.startContainer&&a.startContainer===a.endContainer&&a.startOffset===a.endOffset?!0:!1},a.fn.saveSelection=c?d:function(a){var d,e,c=this,f=c.txt.$txt.get(0);a?d=a.commonAncestorContainer:(e=document.getSelection(),e.getRangeAt&&e.rangeCount&&(a=document.getSelection().getRangeAt(0),d=a.commonAncestorContainer)),d&&(b.contains(f,d)||f===d)&&c.currentRange(a)},a.fn.restoreSelection=c?d: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=c?d: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=c?d:function(){var c,d,a=this;a.currentRange()||(c=a.txt.$txt,d=c.children().first(),d.length&&a.restoreSelectionByElem(d.get(0)))},a.fn.setRangeByElem=c?d:function(a){var e,f,g,c=this,d=c.txt.$txt.get(0);if(a&&b.contains(d,a)){for(e=a.firstChild;e&&3!==e.nodeType;)e=e.firstChild;for(f=a.lastChild;f&&3!==f.nodeType;)f=f.lastChild;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){return(a=a||this.currentRange())?a.text:void 0},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?!1:!0},a.fn.saveSelection=function(a){var d,c=this,f=c.txt.$txt.get(0);a?d=a.parentElement():(a=document.selection.createRange(),d="undefined"==typeof a.parentElement?null:a.parentElement()),d&&(b.contains(f,d)||f===d)&&c.currentRange(a)},a.fn.restoreSelection=function(a){var d,b=this;if(a=a||b.currentRange()){d=document.selection.createRange();try{d.setEndPoint("EndToEnd",a)}catch(e){}if(0===a.text.length)try{d.collapse(!1)}catch(e){}else d.setEndPoint("StartToStart",a);d.select()}})}),b(function(a,b){a.fn.commandHooks=function(){var a=this,c={};c.insertHtml=function(c){var d=b(c),e=a.getRangeElem(),f=a.getLegalTags(e);f&&b(f).after(d)},a.commandHooks=c}}),b(function(a){a.fn.command=function(a,b,c,d){function g(){b&&(e.queryCommandSupported(b)?document.execCommand(b,!1,c):(f=e.commandHooks,b in f&&f[b](c)))}var f,e=this;this.customCommand(a,g,d)},a.fn.commandForElem=function(a,b,c,d,e){var f,g,h;"string"==typeof a?f=a:(f=a.selector,g=a.check),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 f(){d.hideDropPanelAndModal()}var d=this,e=d.currentRange();return e?(d.undoRecord(),this.restoreSelection(e),b.call(d),this.saveSelection(),this.restoreSelection(),c&&"function"==typeof c&&c.call(d),d.txt.insertEmptyP(),d.txt.wrapImgAndText(),d.updateValue(),d.updateMenuStyle(),setTimeout(f,200),a&&a.preventDefault(),void 0):(a&&a.preventDefault(),void 0)},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 d(a){var c=this,d=b(a),e=!1;return d.each(function(){return this===c?(e=!0,!1):void 0}),e}var c;a.fn.getLegalTags=function(b){var c=this.config.legalTags;return c?this.getSelfOrParentByName(b,c):(a.error("配置项中缺少 legalTags 的配置"),void 0)},a.fn.getSelfOrParentByName=function(a,e,f){if(a&&e){c||(c=a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.matchesSelector),c||(c=d);for(var g=this.txt.$txt.get(0);a&&g!==a&&b.contains(g,a);){if(c.call(a,e)){if(!f)return a;if(f(a))return a}a=a.parentNode}}}}),b(function(a){function d(a){return null==a._redoList&&(a._redoList=[]),a._redoList}function e(a){return null==a._undoList&&(a._undoList=[]),a._undoList}function f(a,b,c){var d=b.val,e=a.txt.$txt.html();if(null!=d){if(d===e)return"redo"===c?(a.redo(),void 0):"undo"===c?(a.undo(),void 0):void 0;a.txt.$txt.html(d),a.updateValue(),a.onchange&&"function"==typeof a.onchange&&a.onchange.call(a)}}var c=20;a.fn.undoRecord=function(){var a=this,b=a.txt.$txt,f=b.html(),g=e(a),h=d(a),i=g.length?g[0]:"";f!==i.val&&(h.length&&(h=[]),g.unshift({range:a.currentRange(),val:f}),g.length>c&&g.pop())},a.fn.undo=function(){var g,a=this,b=e(a),c=d(a);b.length&&(g=b.shift(),c.unshift(g),f(this,g,"undo"))},a.fn.redo=function(){var g,a=this,b=e(a),c=d(a);c.length&&(g=c.shift(),b.unshift(g),f(this,g,"redo"))}}),b(function(a,b){a.fn.create=function(){var d,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,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("<p><br></p>"),a.restoreSelectionByElem(b.find("p").get(0))}}),b(function(a){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('<div class="wangEditor-menu-container clearfix"></div>');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 d,c=this.$menuContainer;this.$currentGroup&&this.currentGroupIdx===a||(d=b('<div class="menu-group clearfix"></div>'),c.append(d),this.$currentGroup=d,this.currentGroupIdx=a)},c.fn._addOneMenu=function(a){var c=a.$domNormal,d=a.$domSelected,e=this.$currentGroup,f=b('<div class="menu-item clearfix"></div>');return d.hide(),f.append(c).append(d),e.append(f),f}}),b(function(a){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),this.$domSelected=/^\./.test(f.selected)?this.$domNormal.clone().addClass(f.selected.slice(1)):b(f.selected))}}),b(function(a,b){var c=a.Menu;c.fn.render=function(a){var b,c,d,e;this.initUI(),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 i(){g.show()}function j(){g.hide()}var h,k,d=this,e=d.editor,f=d.title,g=b('<div class="menu-tip"></div>');d.tipWidth||(h=b('<p style="opacity:0; filter:Alpha(opacity=0); position:absolute;top:-10000px;">'+f+"</p>"),a.$body.append(h),e.ready(function(){var b=h.outerWidth()+5,c=g.outerWidth(),e=parseFloat(g.css("margin-left"),10);h.remove(),h=null,g.css({width:b,"margin-left":e+(c-b)/2}),d.tipWidth=b})),g.append(f),c.append(g),c.find("a").on("mouseenter",function(){d.active()||d.disabled()||(k=setTimeout(i,200))}).on("mouseleave",function(){k&&clearTimeout(k),j()}).on("click",j)},c.fn.bindEvent=function(){var f,b=this,c=b.$domNormal,d=b.$domSelected,e=b.clickEvent;e||(e=function(c){var e,f,g,h,d=b.dropPanel||b.dropList||b.modal;return d&&d.show?(d.isShowing?d.hide():d.show(),void 0):(e=b.editor,h=b.selected,h?(f=b.commandNameSelected,g=b.commandValueSelected):(f=b.commandName,g=b.commandValue),f?e.command(c,f,g):(a.warn('菜单 "'+b.id+'" 未定义click事件'),c.preventDefault()),void 0)}),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 c,d,a=this;a.editor,c=a.updateSelectedEvent,c||(c=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}),d=c.call(a),d=!!d,a.changeSelectedState(d)},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:(this._activeState=a,void 0)},c.fn.activeStyle=function(a){var c,d;this.selected,c=this.$domNormal,d=this.$domSelected,a?(c.addClass("active"),d.addClass("active")):(c.removeClass("active"),d.removeClass("active")),this.active(a)},c.fn.disabled=function(a){var b,c;return null==a?!!this._disabled:(this._disabled!==a&&(b=this.$domNormal,c=this.$domSelected,a?(b.addClass("disable"),c.addClass("disable")):(b.removeClass("disable"),c.removeClass("disable")),this._disabled=a),void 0)}}),b(function(a){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 f,g,a=this,c=a.data,d=a.tpl||"<span>{#title}</span>",e=b('<div class="wangEditor-drop-list clearfix"></div>');b.each(c,function(a,c){f=d.replace(/{#commandValue}/gi,a).replace(/{#title}/gi,c),g=b('<a href="#" commandValue="'+a+'"></a>'),g.append(f),e.append(g)}),a.$list=e},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){var e,f,g;c.isShowing&&(e=a.target,f=c.menu,g=f.selected?f.$domSelected.get(0):f.$domNormal.get(0),g===e||b.contains(g,e)||d===e||b.contains(d,e)||c.hide())}),a.$window.scroll(function(){c.hide()}),a.$window.on("resize",function(){c.hide()})}}),b(function(a){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 c,a=this,b=a.menu;a.rendered||a._render(),a.isShowing||(c=a.$list,c.show(),a._position(),a.isShowing=!0,b.activeStyle(!0))},c.fn.hide=function(){var c,a=this,b=a.menu;a.isShowing&&(c=a.$list,c.hide(),a.isShowing=!1,b.activeStyle(!1))}}),b(function(a){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('<div class="wangEditor-drop-panel clearfix"></div>'),g=b('<div class="tip-triangle"></div>');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){var e,f,g;c.isShowing&&(e=a.target,f=c.menu,g=f.selected?f.$domSelected.get(0):f.$domNormal.get(0),g===e||b.contains(g,e)||d===e||b.contains(d,e)||c.hide())}),a.$window.scroll(function(){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 s,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)),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);return null==a.attr("disabled")?(a.focus(),!1):void 0})},c.fn.show=function(){var d,b=this,c=b.menu;b.rendered||b._render(),b.isShowing||(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 c,a=this,b=a.menu;a.isShowing&&(c=a.$panel,c.hide(),a.isShowing=!1,b.activeStyle(!1))}}),b(function(a){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('<div class="wangEditor-modal"></div>'),e=b('<div class="wangEditor-modal-close"><i class="wangeditor-menu-img-cancel-circle"></i></div>');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){var d,f,g;c.isShowing&&(d=a.target,f=c.menu,f&&(g=f.selected?f.$domSelected.get(0):f.$domNormal.get(0),g===d||b.contains(g,d))||e===d||b.contains(e,d)||c.hide())})}}),b(function(a){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 c,a=this,b=a.menu;a.rendered||a._render(),a.isShowing||(a.isShowing=!0,c=a.$modal,c.show(),a._position(),b&&b.activeStyle(!0))},c.fn.hide=function(){var c,a=this,b=a.menu;a.isShowing&&(a.isShowing=!1,c=a.$modal,c.hide(),b&&b.activeStyle(!1))}}),b(function(a){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 f,a=this,c=a.editor,d=c.$valueContainer,e=c.getInitValue();"DIV"===d.get(0).nodeName?(f=d,f.addClass("wangEditor-txt"),f.attr("contentEditable","true")):f=b('<div class="wangEditor-txt" contentEditable="true">'+e+"</div>"),c.ready(function(){a.insertEmptyP()}),a.$txt=f,a.contentEmptyHandle(),a.bindEnterForDiv(),a.bindEnterForText(),a.bindTabEvent(),a.bindPasteFilter(),a.bindFormatText(),a.bindHtml()},c.fn.contentEmptyHandle=function(){var e,a=this,c=a.editor,d=a.$txt;d.on("keydown",function(a){if(8===a.keyCode){var c=b.trim(d.html().toLowerCase());return"<p><br></p>"===c?(a.preventDefault(),void 0):void 0}}),d.on("keyup",function(a){if(8===a.keyCode){var f=b.trim(d.html().toLowerCase());f&&"<br>"!==f||(e=b("<p><br/></p>"),d.html(""),d.append(e),c.restoreSelectionByElem(e.get(0)))}})},c.fn.bindEnterForDiv=function(){function h(){if(g){var a=b("<p>"+g.html()+"</p>");g.after(a),g.remove()}}var d,e,f,g;a.config.legalTags,d=this,e=d.editor,f=d.$txt,f.on("keydown keyup",function(a){var c,d,f,i;if(13===a.keyCode&&(c=e.getRangeElem(),d=e.getLegalTags(c),!d)){if(d=e.getSelfOrParentByName(c,"div"),!d)return;f=b(d),"keydown"===a.type&&(g=f,setTimeout(h,0)),"keyup"===a.type&&(i=b("<p>"+f.html()+"</p>"),f.after(i),f.remove(),e.restoreSelectionByElem(i.get(0),"start"))}})},c.fn.bindEnterForText=function(){var c,a=this,b=a.$txt;b.on("keyup",function(b){13===b.keyCode&&(c||(c=function(){a.wrapImgAndText()}),setTimeout(c))})},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","&nbsp;&nbsp;&nbsp;&nbsp;")})},c.fn.bindPasteFilter=function(){function h(a){var c,e,f,k;if(a&&a.nodeType&&a.nodeName&&(e=a.nodeName.toLowerCase(),f=a.nodeType,3===f||1===f)){if(c=b(a),"div"===e)return k=[],b.each(a.childNodes,function(a,b){k.push(b)}),b.each(k,function(){h(this)}),void 0;if(g.indexOf(e)>=0)d+=i(a);else if(3===f)d+="<p>"+a.textContent+"</p>";else if("br"===e)d+="<br/>";else{if(["meta","style","script","object","form","iframe","hr"].indexOf(e)>=0)return;c=b(j(a)),d+=b("<div>").append(c.clone()).html()}}}function i(a){var d,c=a.nodeName.toLowerCase(),e="",f="";return["blockquote"].indexOf(c)>=0?(d=b(a),"<"+c+">"+d.text()+"</"+c+">"):["p","h1","h2","h3","h4","h5"].indexOf(c)>=0?(a=j(a),d=b(a),e=d.html(),e=e.replace(/<.*?>/gi,function(a){return"</a>"===a||0===a.indexOf("<a ")||0===a.indexOf("<img ")?a:""}),"<"+c+">"+e+"</"+c+">"):["ul","ol"].indexOf(c)>=0?(d=b(a),d.children().each(function(){var a=b(j(this)),c=a.html();c=c.replace(/<.*?>/gi,function(a){return"</a>"===a||0===a.indexOf("<a ")||0===a.indexOf("<img ")?a:""}),f+="<li>"+c+"</li>"}),"<"+c+">"+f+"</"+c+">"):(d=b(j(a)),b("<div>").append(d).html())}function j(a){var f,c=a.attributes||[],d=[],e=["href","target","src","alt","rowspan","colspan"];return b.each(c,function(a,b){b&&2===b.nodeType&&d.push(b.nodeName)}),b.each(d,function(b,c){e.indexOf(c)<0&&a.removeAttribute(c)}),f=a.childNodes,f.length&&b.each(f,function(a,b){j(b)}),a}var a=this,c=a.editor,d="",e=a.$txt,f=c.config.legalTags,g=f.split(",");e.on("paste",function(e){var f,g,i,j,k;if(c.config.pasteFilter&&(f=c.getRangeElem().nodeName,"TD"!==f&&"TH"!==f)){if(d="",j=e.clipboardData||e.originalEvent.clipboardData,k=window.clipboardData,c.config.pasteText){if(j&&j.getData)g=j.getData("text/plain");else{if(!k||!k.getData)return;g=k.getData("text")}g&&(d="<p>"+g+"</p>")}else if(j&&j.getData)g=j.getData("text/html"),g?(i=b("<div>"+g+"</div>"),h(i.get(0))):(g=j.getData("text/plain"),g&&(g=g.replace(/[ ]/g,"&nbsp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"</p><p>"),d="<p>"+g+"</p>",d=d.replace(/<p>(https?:\/\/.*?)<\/p>/gi,function(a,b){return'<p><a href="'+b+'" target="_blank">'+b+"</p>"})));else{if(!k||!k.getData)return;if(d=k.getData("text"),!d)return;d="<p>"+d+"</p>",d=d.replace(new RegExp("\n","g"),"</p><p>")}d&&(c.command(e,"insertHtml",d),a.clearEmptyOrNestP())}})},c.fn.bindFormatText=function(){var e,f,g,i,c=this;c.editor,e=c.$txt,f=a.config.legalTags,g=f.split(","),g.length,i=[],b.each(g,function(a,b){var c=">\\s*<("+b+")>";i.push(new RegExp(c,"ig"))}),i.push(new RegExp(">\\s*<(li)>","ig")),i.push(new RegExp(">\\s*<(tr)>","ig")),i.push(new RegExp(">\\s*<(code)>","ig")),e.formatText=function(){var a=b("<div>"),c=e.html();return c=c.replace(/\s*</gi,"<"),b.each(i,function(a,b){b.test(c)&&(c=c.replace(b,function(a,b){return">\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("&amp;","&")+'"'})):(c=b.fn.html.call(d,a),e.val(a)),void 0===a?c:(d.change(),void 0)}}}),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=50>e?50:e,b.height(e),a.valueContainerHeight=c,this.initMaxHeight(e,d)},c.fn.initMaxHeight=function(c,d){var i,e=this.editor,f=e.menuContainer.$menuContainer,g=this.$txt,h=b("<div>");if(window.getComputedStyle&&"max-height"in window.getComputedStyle(g.get(0))){if(i=parseInt(e.$valueContainer.css("max-height")),isNaN(i))return;if(e.menus.fullscreen)return a.warn("max-height和『全屏』菜单一起使用时会有一些问题尚未解决请暂时不要两个同时使用"),void 0;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 f(){b.saveSelection()}function g(){Date.now()-e<100||(e=Date.now(),f())}function h(){c&&clearTimeout(c),c=setTimeout(f,300)}var c,a=this.$txt,b=this.editor,e=Date.now();a.on(d+" focus blur",function(){g(),h()}),a.on("mousedown",function(){a.on("mouseleave.saveSelection",function(){g(),h(),b.updateMenuStyle()})}).on("mouseup",function(){a.off("mouseleave.saveSelection")})},c.fn.updateValueEvent=function(){function f(){var c=a.html();e!==c&&(b.onchange&&"function"==typeof b.onchange&&b.onchange.call(b),b.updateValue(),e=c)}var c,e,a=this.$txt,b=this.editor;a.on(d,function(){null==e&&(e=a.html()),c&&clearTimeout(c),c=setTimeout(f,100)})},c.fn.updateMenuStyleEvent=function(){var a=this.$txt,b=this.editor;a.on(d,function(){b.updateMenuStyle()})},c.fn.insertEmptyP=function(){var a=this.$txt,c=a.children();return 0===c.length?(a.append(b("<p><br></p>")),void 0):("<br>"!==b.trim(c.last().html()).toLowerCase()&&a.append(b("<p><br></p>")),void 0)},c.fn.wrapImgAndText=function(){var g,h,a=this.$txt,c=a.children("img"),d=a[0],e=d.childNodes,f=e.length;for(c.length&&c.each(function(){b(this).wrap("<p>")}),g=0;f>g;g++)h=e[g],3===h.nodeType&&h.textContent&&b.trim(h.textContent)&&b(h).wrap("<p>")},c.fn.clearEmptyOrNestP=function(){var a=this.$txt,c=a.find("p");c.each(function(){var e,a=b(this),c=a.children(),d=c.length,f=b.trim(a.html());return f?(1===d&&(e=c.first(),e.get(0)&&"P"===e.get(0).nodeName&&a.html(e.html())),void 0):(a.remove(),void 0)})},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 h(a){var i,j,k,l,m,n;g||(c.append(f),g=!0),e.position().top,e.outerHeight(),i=a.height(),j=a.position().top,k=parseInt(a.css("margin-top"),10),l=parseInt(a.css("padding-top"),10),m=parseInt(a.css("margin-bottom"),10),n=parseInt(a.css("padding-bottom"),10),j+d.height(),f.css({height:i+l+k+n+m,top:j+d.height()})}function i(){g&&(f.remove(),g=!1)}var a=this.editor,c=a.$editorContainer,d=a.menuContainer,e=this.$txt,f=b('<i class="height-tip"><i>'),g=!1;e.on("mouseenter","ul,ol,blockquote,p,h1,h2,h3,h4,h5,table,pre",function(a){h(b(a.currentTarget))}).on("mouseleave",function(){i()})}}),b(function(a,b){var c,d;Array.prototype.indexOf||(Array.prototype.indexOf=function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},Array.prototype.lastIndexOf=function(a){var b=this.length;for(b-=1;b>=0;b--)if(this[b]===a)return b;return-1}),Date.now||(Date.now=function(){return(new Date).valueOf()}),c=window.console,d=function(){},b.each(["info","log","warn","error"],function(b,e){a[e]=null==c?d: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){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:"图片",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",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){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.hideLinkImg=!1,a.config.pasteFilter=!0,a.config.pasteText=!1,a.config.codeDefaultLang="javascript"
}),b(function(a){a.UI={},a.UI.menus={"default":{normal:'<a href="#" tabindex="-1"><i class="wangeditor-menu-img-command"></i></a>',selected:".selected"},bold:{normal:'<a href="#" tabindex="-1"><i class="wangeditor-menu-img-bold"></i></a>',selected:".selected"},underline:{normal:'<a href="#" tabindex="-1"><i class="wangeditor-menu-img-underline"></i></a>',selected:".selected"},italic:{normal:'<a href="#" tabindex="-1"><i class="wangeditor-menu-img-italic"></i></a>',selected:".selected"},forecolor:{normal:'<a href="#" tabindex="-1"><i class="wangeditor-menu-img-pencil"></i></a>',selected:".selected"},bgcolor:{normal:'<a href="#" tabindex="-1"><i class="wangeditor-menu-img-brush"></i></a>',selected:".selected"},strikethrough:{normal:'<a href="#" tabindex="-1"><i class="wangeditor-menu-img-strikethrough"></i></a>',selected:".selected"},eraser:{normal:'<a href="#" tabindex="-1"><i class="wangeditor-menu-img-eraser"></i></a>',selected:".selected"},quote:{normal:'<a href="#" tabindex="-1"><i class="wangeditor-menu-img-quotes-left"></i></a>',selected:".selected"},source:{normal:'<a href="#" tabindex="-1"><i class="wangeditor-menu-img-code"></i></a>',selected:".selected"},fontfamily:{normal:'<a href="#" tabindex="-1"><i class="wangeditor-menu-img-font2"></i></a>',selected:".selected"},fontsize:{normal:'<a href="#" tabindex="-1"><i class="wangeditor-menu-img-text-height"></i></a>',selected:".selected"},head:{normal:'<a href="#" tabindex="-1"><i class="wangeditor-menu-img-header"></i></a>',selected:".selected"},orderlist:{normal:'<a href="#" tabindex="-1"><i class="wangeditor-menu-img-list-numbered"></i></a>',selected:".selected"},unorderlist:{normal:'<a href="#" tabindex="-1"><i class="wangeditor-menu-img-list-bullet"></i></a>',selected:".selected"},alignleft:{normal:'<a href="#" tabindex="-1"><i class="wangeditor-menu-img-align-left"></i></a>',selected:".selected"},aligncenter:{normal:'<a href="#" tabindex="-1"><i class="wangeditor-menu-img-align-center"></i></a>',selected:".selected"},alignright:{normal:'<a href="#" tabindex="-1"><i class="wangeditor-menu-img-align-right"></i></a>',selected:".selected"},link:{normal:'<a href="#" tabindex="-1"><i class="wangeditor-menu-img-link"></i></a>',selected:".selected"},unlink:{normal:'<a href="#" tabindex="-1"><i class="wangeditor-menu-img-unlink"></i></a>',selected:".selected"},table:{normal:'<a href="#" tabindex="-1"><i class="wangeditor-menu-img-table"></i></a>',selected:".selected"},emotion:{normal:'<a href="#" tabindex="-1"><i class="wangeditor-menu-img-happy"></i></a>',selected:".selected"},img:{normal:'<a href="#" tabindex="-1"><i class="wangeditor-menu-img-picture"></i></a>',selected:".selected"},video:{normal:'<a href="#" tabindex="-1"><i class="wangeditor-menu-img-play"></i></a>',selected:".selected"},location:{normal:'<a href="#" tabindex="-1"><i class="wangeditor-menu-img-location"></i></a>',selected:".selected"},insertcode:{normal:'<a href="#" tabindex="-1"><i class="wangeditor-menu-img-terminal"></i></a>',selected:".selected"},undo:{normal:'<a href="#" tabindex="-1"><i class="wangeditor-menu-img-ccw"></i></a>',selected:".selected"},redo:{normal:'<a href="#" tabindex="-1"><i class="wangeditor-menu-img-cw"></i></a>',selected:".selected"},fullscreen:{normal:'<a href="#" tabindex="-1"><i class="wangeditor-menu-img-enlarge2"></i></a>',selected:'<a href="#" tabindex="-1" class="selected"><i class="wangeditor-menu-img-shrink2"></i></a>'}}}),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('<div class="wangEditor-container"></div>')}}),b(function(a){a.fn.addTxt=function(){var b=this,c=new a.Txt(b);b.txt=c}}),b(function(a){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 e(a){return d.indexOf(a)>=0?!0:!1}var c=this,d=c.config.menus;b.each(a.createMenuFns,function(a,b){b.call(c,e)})}}),b(function(a){a.createMenu(function(b){var d,e,f,c="bold";b(c)&&(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){a.createMenu(function(b){var d,e,f,c="underline";b(c)&&(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){a.createMenu(function(b){var d,e,f,c="italic";b(c)&&(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 e,f,g,h,i,d="forecolor";c(d)&&(e=this,f=e.config.lang,g=e.config.colors,h=new a.Menu({editor:e,id:d,title:f.forecolor}),i=b("<div></div>"),b.each(g,function(a,b){i.append(['<a href="#" class="color-item"',' title="'+b+'" commandValue="'+a+'" ',' style="color: '+a+'" ','><i class="wangeditor-menu-img-pencil"></i></a>'].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?!0:!1},e.menus[d]=h)})}),b(function(a,b){a.createMenu(function(c){function h(a){var b;return a&&a.style&&null!=a.style.cssText&&(b=a.style.cssText,b&&b.indexOf("background-color:")>=0)?!0:!1}var e,f,g,i,j,d="bgcolor";c(d)&&(e=this,f=e.config.lang,g=e.config.colors,i=new a.Menu({editor:e,id:d,title:f.bgcolor}),j=b("<div></div>"),b.each(g,function(a,b){j.append(['<a href="#" class="color-item"',' title="'+b+'" commandValue="'+a+'" ',' style="color: '+a+'" ','><i class="wangeditor-menu-img-brush"></i></a>'].join(""))}),j.on("click","a[commandValue]",function(a){var c=b(this),d=c.attr("commandValue");i.selected&&e.isRangeEmpty()?e.commandForElem({selector:"span,font",check:h},a,"BackColor",d):e.command(a,"BackColor",d)}),i.dropPanel=new a.DropPanel(e,i,{$content:j,width:125}),i.updateSelectedEvent=function(){var a=e.getRangeElem();return a=e.getSelfOrParentByName(a,"span,font",h),a?!0:!1},e.menus[d]=i)})}),b(function(a){a.createMenu(function(b){var d,e,f,c="strikethrough";b(c)&&(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 e,f,g,d="eraser";c(d)&&(e=this,f=e.config.lang,g=new a.Menu({editor:e,id:d,title:f.eraser,commandName:"RemoveFormat"}),g.clickEvent=function(a){function f(){var e,f,h,i,j,a=this,c=a.getRangeElem(),g=a.getSelfOrParentByName(c,"blockquote");g&&(h=b(g),d=b("<p>"+h.text()+"</p>"),h.after(d).remove()),e=a.getSelfOrParentByName(c,"p,h1,h2,h3,h4,h5"),e&&(f=b(e),d=b("<p>"+f.text()+"</p>"),f.after(d).remove()),i=a.getSelfOrParentByName(c,"ul,ol"),i&&(j=b(i),d=b("<p>"+j.text()+"</p>"),j.after(d).remove())}function g(){var a=this;d&&a.restoreSelectionByElem(d.get(0))}var d,c=e.isRangeEmpty();return c?(e.customCommand(a,f,g),void 0):(e.command(a,"RemoveFormat"),void 0)},e.menus[d]=g)})}),b(function(a,b){a.createMenu(function(c){function i(){var a=h.$codeTextarea,c=e.txt.$txt,d=b.trim(a.val());d||(d="<p><br></p>"),e.config.jsFilter&&(d=d.replace(/<script[\s\S]*?<\/script>/gi,"")),c.html(d)}var e,f,g,h,d="source";c(d)&&(e=this,f=e.config.lang,h=new a.Menu({editor:e,id:d,title:f.source}),h.isShowCode=!1,h.clickEvent=function(){var j,c=this,d=c.editor,e=d.txt.$txt,f=e.outerHeight(),i=e.height();c.$codeTextarea||(c.$codeTextarea=b('<textarea class="code-textarea"></textarea>')),j=c.$codeTextarea,j.css({height:i,"margin-top":f-i}),j.val(e.html()),e.after(j).hide(),j.show(),h.isShowCode=!0,this.updateSelected(),d.disableMenusExcept("source"),g=e.html()},h.clickEventSelected=function(){var b=this,c=b.editor,d=c.txt.$txt,e=b.$codeTextarea;e&&(i(),e.after(d).hide(),d.show(),h.isShowCode=!1,this.updateSelected(),c.enableMenusExcept("source"),d.html()!==g&&c.onchange&&"function"==typeof c.onchange&&c.onchange.call(c))},h.updateSelectedEvent=function(){return this.isShowCode},e.menus[d]=h)})}),b(function(a,b){a.createMenu(function(c){var e,f,g,d="quote";c(d)&&(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 h(){g=b("<p>"+d.text()+"</p>"),d.after(g).remove(),g.wrap("<blockquote>")}function i(){var a=this;g&&a.restoreSelectionByElem(g.get(0))}var d,f,g,c=e.getRangeElem();return c?(f=e.getSelfOrParentByName(c,"blockquote"))?(a.preventDefault(),void 0):(c=e.getLegalTags(c),d=b(c),d.text()?c?(e.customCommand(a,h,i),void 0):(e.command(a,"formatBlock","blockquote"),void 0):void 0):(a.preventDefault(),void 0)},g.clickEventSelected=function(a){function g(){var a=b(d),c=a.children();return c.length?(c.each(function(){var d=b(this);"P"===d.get(0).nodeName?a.after(d):a.after("<p>"+d.text()+"</p>"),f=d}),a.remove(),void 0):void 0}function h(){var a=this;f&&a.restoreSelectionByElem(f.get(0))}var f,c=e.getRangeElem(),d=e.getSelfOrParentByName(c,"blockquote");return d?(e.customCommand(a,g,h),void 0):(a.preventDefault(),void 0)},g.updateSelectedEvent=function(){var a=this,b=a.editor,c=b.getRangeElem();return c=b.getSelfOrParentByName(c,"blockquote"),c?!0:!1},e.menus[d]=g,e.ready(function(){var a=this,c=a.txt.$txt,d=!1;c.on("keydown",function(c){var e,f,g;return 13!==c.keyCode?(d=!1,void 0):(e=a.getRangeElem(),(e=a.getSelfOrParentByName(e,"blockquote"))?d?(f=a.getRangeElem(),g=b(f),g.length&&g.parent().after(g),a.restoreSelectionByElem(f,"start"),d=!1,c.preventDefault(),void 0):(d=!0,void 0):(d=!1,void 0))})}),e.ready(function(){function e(){d&&d.remove()}function f(){if(d){var b=d.prev();b.length?a.restoreSelectionByElem(b.get(0)):a.initSelection()}}var d,a=this,c=a.txt.$txt;c.on("keydown",function(c){var g,h;8===c.keyCode&&(g=a.getRangeElem(),g=a.getSelfOrParentByName(g,"blockquote"),g&&(d=b(g),h=d.text(),h||a.customCommand(c,e,f)))})}))})}),b(function(a,b){a.createMenu(function(c){var e,f,g,h,i,j,d="fontfamily";c(d)&&(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}),j='<span style="font-family:{#commandValue};">{#title}</span>',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?!0:!1},e.menus[d]=h)})}),b(function(a){a.createMenu(function(b){var d,e,f,g,h,i,c="fontsize";b(c)&&(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='<span style="font-size:{#title};">{#title}</span>',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?!0:!1},d.menus[c]=g)})}),b(function(a){a.createMenu(function(b){function i(a){d.queryCommandState("InsertOrderedList")?(h=!0,d.command(a,"InsertOrderedList")):h=!1}function j(a){h&&d.command(a,"InsertOrderedList")}var d,e,f,g,h,k,c="head";b(c)&&(d=this,e=d.config.lang,f=new a.Menu({editor:d,id:c,title:e.head,commandName:"formatBlock"}),g={"<h1>":"标题1","<h2>":"标题2","<h3>":"标题3","<h4>":"标题4","<h5>":"标题5"},k="{#commandValue}{#title}",f.dropList=new a.DropList(d,f,{data:g,tpl:k,beforeEvent:i,afterEvent:j}),f.updateSelectedEvent=function(){var a=d.getRangeElem();return a=d.getSelfOrParentByName(a,"h1,h2,h3,h4,h5"),a?!0:!1},d.menus[c]=f)})}),b(function(a){a.createMenu(function(b){var d,e,f,c="unorderlist";b(c)&&(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){a.createMenu(function(b){var d,e,f,c="orderlist";b(c)&&(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 e,f,g,d="alignleft";c(d)&&(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))?!0:"left"===b(a).attr("align")?!0:!1}),a?!0:!1},e.menus[d]=g)})}),b(function(a,b){a.createMenu(function(c){var e,f,g,d="aligncenter";c(d)&&(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))?!0:"center"===b(a).attr("align")?!0:!1}),a?!0:!1},e.menus[d]=g)})}),b(function(a,b){a.createMenu(function(c){var e,f,g,d="alignright";c(d)&&(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))?!0:"right"===b(a).attr("align")?!0:!1}),a?!0:!1},e.menus[d]=g)})}),b(function(a,b){a.createMenu(function(c){var e,f,g,h,i,j,k,l,m,n,o,d="link";c(d)&&(e=this,f=e.config.lang,g=new a.Menu({editor:e,id:d,title:f.link}),h=b("<div></div>"),i=b('<div style="margin:20px 10px;" class="clearfix"></div>'),j=i.clone(),k=i.clone().css("margin","0 10px"),l=b('<input type="text" class="block" placeholder="'+f.text+'"/>'),m=b('<input type="text" class="block" placeholder="'+f.link+'"/>'),n=b('<button class="right">'+f.submit+"</button>"),o=b('<button class="right gray">'+f.cancel+"</button>"),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(){var d,f,g,h,b=this,c=b.dropPanel;return c.isShowing?(c.hide(),void 0):(l.val(""),m.val("http://"),d="",f=e.getRangeElem(),f=e.getSelfOrParentByName(f,"a"),f&&(d=f.href||""),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(),void 0)},g.updateSelectedEvent=function(){var a=e.getRangeElem();return a=e.getSelfOrParentByName(a,"a"),a?!0:!1},o.click(function(a){a.preventDefault(),g.dropPanel.hide()}),n.click(function(c){var d,f,h,i,j,k,n,o,p,q,r,s,t;return c.preventDefault(),d=e.getRangeElem(),f=e.getSelfOrParentByName(d,"a"),h=e.isRangeEmpty(),o=e.txt.$txt,r="link"+a.random(),s=b.trim(m.val()),t=b.trim(l.val()),s?(t||(t=s),h?f?(i=b(f),k=function(){i.attr("href",s),i.text(t)},n=function(){var a=this;a.restoreSelectionByElem(f)},e.customCommand(c,k,n)):(j='<a href="'+s+'" target="_blank">'+t+"</a>",a.userAgent.indexOf("Firefox")>0&&(j+="<span>&nbsp;</span>"),e.command(c,"insertHtml",j)):(p=o.find("a"),p.attr(r,"1"),e.command(c,"createLink",s),q=o.find("a").not("["+r+"]"),q.attr("target","_blank"),p.removeAttr(r)),void 0):(g.dropPanel.focusFirstInput(),void 0)}),e.menus[d]=g)})}),b(function(a,b){a.createMenu(function(c){var e,f,g,d="unlink";c(d)&&(e=this,f=e.config.lang,g=new a.Menu({editor:e,id:d,title:f.unlink,commandName:"unLink"}),g.clickEvent=function(a){function i(){g.after(h).remove()}function j(){e.restoreSelectionByElem(h.get(0))}var d,f,g,h,c=e.isRangeEmpty();return c?(d=e.getRangeElem(),(f=e.getSelfOrParentByName(d,"a"))?(g=b(f),h=b("<span>"+g.text()+"</span>"),e.customCommand(a,i,j),void 0):(a.preventDefault(),void 0)):(e.command(a,"unLink"),void 0)},e.menus[d]=g)})}),b(function(a,b){a.createMenu(function(c){var e,f,g,h,i,j,k,l,m,n,o,p,d="table";if(c(d)){for(e=this,f=e.config.lang,g=new a.Menu({editor:e,id:d,title:f.table}),h=b('<div style="font-size: 14px; color: #666; text-align:right;"></div>'),i=b('<table class="choose-table" style="margin-bottom:10px;margin-top:5px;">'),j=b("<span>0</span>"),k=b("<span> 行 </span>"),l=b("<span>0</span>"),m=b("<span> 列</span>"),o=0;15>o;o++){for(n=b('<tr index="'+(o+1)+'">'),p=0;20>p;p++)n.append(b('<td index="'+(p+1)+'">'));i.append(n)}h.append(i),h.append(j).append(k).append(l).append(m),i.on("mouseenter","td",function(a){var c=b(a.currentTarget),d=c.attr("index"),e=c.parent(),f=e.attr("index");j.text(f),l.text(d),i.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(){i.find("td").removeClass("active"),j.text(0),l.text(0)}),i.on("click","td",function(a){var j,k,c=b(a.currentTarget),d=c.attr("index"),f=c.parent(),g=f.attr("index"),h=parseInt(g,10),i=parseInt(d,10),l="<table>";for(j=0;h>j;j++){for(l+="<tr>",k=0;i>k;k++)l+="<td><span>&nbsp;</span></td>";l+="</tr>"}l+="</table>",e.command(a,"insertHtml",l)}),g.dropPanel=new a.DropPanel(e,g,{$content:h,width:262}),e.menus[d]=g}})}),b(function(a,b){a.createMenu(function(c){function k(a,c){b.each(a,function(a,d){var f=d.icon||d.url,g=d.value||d.title,h="icon"===i?f:g,j=b('<a href="#" commandValue="'+h+'"></a>'),k=b("<img>");k.attr("_src",f),j.append(k),c.append(j),e.emotionUrls.push(f)})}var e,f,g,h,i,j,l,m,n,d="emotion";c(d)&&(e=this,f=e.config,g=f.lang,h=f.emotions,i=f.emotionsShow,e.emotionUrls=[],j=new a.Menu({editor:e,id:d,title:g.emotion}),l=b('<div class="panel-tab"></div>'),m=b('<div class="tab-container"></div>'),n=b('<div class="content-container emotion-content-container"></div>'),b.each(h,function(c,d){var g,h,e=d.title,f=d.data;if(a.log("正在处理 "+e+" 表情的数据..."),g=b('<a href="#">'+e+" </a>"),m.append(g),h=b('<div class="content"></div>'),n.append(h),g.click(function(a){m.children().removeClass("selected"),n.children().removeClass("selected"),h.addClass("selected"),g.addClass("selected"),a.preventDefault()}),"string"==typeof f)a.log("将通过 "+f+" 地址ajax下载表情包"),b.get(f,function(c){c=b.parseJSON(c),a.log("下载完毕,得到 "+c.length+" 个表情"),k(c,h)});else{if(!(Object.prototype.toString.call(f).toLowerCase().indexOf("array")>0))return a.error("data 数据格式错误,请修改为正确格式,参考文档:"+a.docsite),void 0;k(f,h)}}),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"===i?e.command(a,"InsertImage",d):e.command(a,"insertHtml","<span>"+d+"</span>"),a.preventDefault()}),j.dropPanel=new a.DropPanel(e,j,{$content:l,width:350}),j.clickEvent=function(){var d=this,e=d.dropPanel;return e.isShowing?(e.hide(),void 0):(e.show(),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),void 0)},e.menus[d]=j)})}),b(function(a,b){function c(a,c,d){function j(){g.val("")}var h,i,e=a.config.lang,f=b('<div style="margin:20px 10px 10px 10px;"></div>'),g=b('<input type="text" class="block" placeholder="http://"/>');f.append(g),h=b('<button class="right">'+e.submit+"</button>"),i=b('<button class="right gray">'+e.cancel+"</button>"),d.append(f).append(h).append(i),i.click(function(a){a.preventDefault(),c.dropPanel.hide()}),h.click(function(c){var d,e;return c.preventDefault(),(d=b.trim(g.val()))?(e='<img style="max-width:100%;" src="'+d+'"/>',a.command(c,"insertHtml",e,j),void 0):(g.focus(),void 0)})}a.createMenu(function(d){function p(){l.click(function(a){j.children().removeClass("selected"),k.children().removeClass("selected"),n.addClass("selected"),l.addClass("selected"),a.preventDefault()}),m.click(function(b){j.children().removeClass("selected"),k.children().removeClass("selected"),o.addClass("selected"),m.addClass("selected"),b.preventDefault(),a.placeholder&&o.find("input[type=text]").focus()}),l.click()}function q(){j.remove(),n.remove(),o.addClass("selected")}function r(){j.remove(),o.remove(),n.addClass("selected")}var f,g,h,i,j,k,l,m,n,o,e="img";d(e)&&(f=this,g=f.config.lang,h=new a.Menu({editor:f,id:e,title:g.img}),i=b('<div class="panel-tab"></div>'),j=b('<div class="tab-container"></div>'),k=b('<div class="content-container"></div>'),i.append(j).append(k),l=b('<a href="#">上传图片</a>'),m=b('<a href="#">网络图片</a>'),j.append(l).append(m),n=b('<div class="content"></div>'),k.append(n),o=b('<div class="content"></div>'),k.append(o),c(f,h,o),h.dropPanel=new a.DropPanel(f,h,{$content:i,width:400,onRender:function(){var a=f.config.customUploadInit;a&&a.call(f)}}),f.menus[e]=h,f.ready(function(){function g(){h.dropPanel.hide()}var a=this,b=a.config,c=b.uploadImgUrl,d=b.customUpload,e=b.hideLinkImg;c||d?(a.$uploadContent=n,p(),e&&r()):q(),n.click(function(){setTimeout(g)})}))})}),b(function(a,b){a.createMenu(function(c){var e,f,g,h,i,j,k,l,m,n,o,p,q,r,d="video";c(d)&&(e=this,f=e.config.lang,g=/^<(iframe)|(embed)/i,h=new a.Menu({editor:e,id:d,title:f.video}),i=b("<div></div>"),j=b('<div style="margin:20px 10px;"></div>'),k=b('<input type="text" class="block" placeholder=\'格式如:<iframe src="..." frameborder=0 allowfullscreen></iframe>\'/>'),j.append(k),l=b('<div style="margin:20px 10px;"></div>'),m=b('<input type="text" value="640" style="width:50px;text-align:center;"/>'),n=b('<input type="text" value="498" style="width:50px;text-align:center;"/>'),l.append("<span> "+f.width+" </span>").append(m).append("<span> px &nbsp;&nbsp;&nbsp;</span>").append("<span> "+f.height+" </span>").append(n).append("<span> px </span>"),o=b("<div></div>"),p=b('<a href="http://www.kancloud.cn/wangfupeng/wangeditor2/134973" target="_blank" style="display:inline-block;margin-top:10px;margin-left:10px;color:#999;">如何复制视频链接?</a>'),q=b('<button class="right">'+f.submit+"</button>"),r=b('<button class="right gray">'+f.cancel+"</button>"),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){var c,d,f,i,j,l;return a.preventDefault(),c=b.trim(k.val()),f=parseInt(m.val()),i=parseInt(n.val()),j=b("<div>"),l="<p>{content}</p>",c?g.test(c)?isNaN(f)||isNaN(i)?(alert("宽度或高度不是数字!"),void 0):(d=b(c),d.attr("width",f).attr("height",i),l=l.replace("{content}",j.append(d).html()),e.command(a,"insertHtml",l),k.val(""),void 0):(alert("视频链接格式错误!"),h.dropPanel.focusFirstInput(),void 0):(h.dropPanel.focusFirstInput(),void 0)}),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 y(){p.val("")}var f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,e="location";if(d(e)){if(++a.numberOfLocation>1)return a.error("目前不支持在一个页面多个编辑器上同时使用地图,可通过自定义菜单配置去掉地图菜单"),void 0;f=this,g=f.config,h=g.lang,i=g.mapAk,f.mapData={},j=f.mapData,j.markers=[],j.mapContainerId="map"+a.random(),j.clearLocations=function(){var a=j.map;a&&(a.clearOverlays(),j.markers=[])},j.searchMap=function(){var b,c,d,e,f,a=j.map;a&&(b=window.BMap,c=o.val(),d=p.val(),""!==c&&(d&&""!==d||a.centerAndZoom(c,11),d&&""!==d&&(e=new b.Geocoder,e.getPoint(d,function(d){d?(a.centerAndZoom(d,13),f=new b.Marker(d),a.addOverlay(f),f.enableDragging(),j.markers.push(f)):a.centerAndZoom(c,11)},c))))},k=!1,window.baiduMapCallBack=function(){function e(b){var f,g,e=b.name;d.setCenter(e),o.val(e),a.placeholder&&p.focus(),c?(g=function(a){"keyup"===a.type&&13===a.keyCode&&a.preventDefault(),f&&clearTimeout(f),f=setTimeout(j.searchMap,500)},o.on("keyup change paste",g),p.on("keyup change paste",g)):(g=function(){var a,b,c,d;return m.is(":visible")?(a="",b="",c=o.val(),d=p.val(),(c!==a||d!==b)&&(j.searchMap(),a=c,b=d),f&&clearTimeout(f),f=setTimeout(g,1e3),void 0):(clearTimeout(f),void 0)},f=setTimeout(g,1e3))}var b,d,f;k||(k=!0,b=window.BMap,j.map||(j.map=new b.Map(j.mapContainerId)),d=j.map,d.centerAndZoom(new b.Point(116.404,39.915),11),d.addControl(new b.MapTypeControl),d.setCurrentCity("北京"),d.enableScrollWheelZoom(!0),f=new b.LocalCity,f.get(e),d.addEventListener("click",function(a){var c=new b.Marker(new b.Point(a.point.lng,a.point.lat));d.addOverlay(c),c.enableDragging(),j.markers.push(c)},!1))},j.loadMapScript=function(){var b=document.createElement("script");b.type="text/javascript",b.src="https://api.map.baidu.com/api?v=2.0&ak="+i+"&s=1&callback=baiduMapCallBack";try{document.body.appendChild(b)}catch(c){a.error("加载地图过程中发生错误")}},j.initMap=function(){window.BMap?window.baiduMapCallBack():j.loadMapScript()},l=new a.Menu({editor:f,id:e,title:h.location}),f.menus[e]=l,m=b("<div></div>"),n=b('<div style="margin:10px 0;"></div>'),o=b('<input type="text"/>'),o.css({width:"80px","text-align":"center"}),p=b('<input type="text"/>'),p.css({width:"300px","margin-left":"10px"}).attr("placeholder",h.searchlocation),q=b('<button class="right link">'+h.clearLocation+"</button>"),n.append(q).append(o).append(p),m.append(n),q.click(function(a){p.val(""),p.focus(),j.clearLocations(),a.preventDefault()}),r=b('<div id="'+j.mapContainerId+'"></div>'),r.css({height:"260px",width:"100%",position:"relative","margin-top":"10px",border:"1px solid #f1f1f1"}),s=b("<span>"+h.loading+"</span>"),s.css({position:"absolute",width:"100px","text-align":"center",top:"45%",left:"50%","margin-left":"-50px"}),r.append(s),m.append(r),t=b('<div style="margin:10px 0;"></div>'),u=b('<button class="right">'+h.submit+"</button>"),v=b('<button class="right gray">'+h.cancel+"</button>"),w=b('<label style="display:inline-block;margin-top:10px;color:#666;"></label>'),x=b('<input type="checkbox">'),w.append(x).append('<span style="display:inline-block;margin-left:5px;"> '+h.dynamicMap+"</span>"),t.append(w).append(u).append(v),m.append(t),v.click(function(a){a.preventDefault(),y(),l.dropPanel.hide()}),u.click(function(a){a.preventDefault();var p,q,r,c=j.map,d=x.is(":checked"),e=j.markers,g=c.getCenter(),i=g.lng,k=g.lat,l=c.getZoom(),m=c.getSize(),n=m.width,o=m.height;if(q=d?"http://ueditor.baidu.com/ueditor/dialogs/map/show.html#":"http://api.map.baidu.com/staticimage?",q=q+"center="+i+","+k+"&zoom="+l+"&width="+n+"&height="+o,e.length>0&&(q+="&markers=",b.each(e,function(a,b){p=b.getPosition(),a>0&&(q+="|"),q=q+p.lng+","+p.lat})),d){if(e.length>1)return alert(h.langDynamicOneLocation),void 0;q+="&markerStyles=l,A",r='<iframe class="ueditor_baidumap" src="{src}" frameborder="0" width="'+n+'" height="'+o+'"></iframe>',r=r.replace("{src}",q),f.command(a,"insertHtml",r,y)}else f.command(a,"insertHtml",'<img style="max-width:100%;" src="'+q+'"/>',y)}),l.dropPanel=new a.DropPanel(f,l,{$content:m,width:500}),l.onRender=function(){i===a.baiduMapAk&&a.warn("建议在配置中自定义百度地图的mapAk否则可能影响地图功能文档"+a.docsite)},l.clickEvent=function(){var b=this,c=b.dropPanel,d=!1;return c.isShowing?(c.hide(),void 0):(j.map||(d=!0),c.show(),j.initMap(),d||p.focus(),void 0)}}})}),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 n(a){var d,e,g,k,c=b("<div></div>");c.css({margin:"15px 5px 5px 5px",height:"160px","text-align":"center"}),l.css({width:"100%",height:"100%",padding:"10px"}),l.on("keydown",function(a){9===a.keyCode&&a.preventDefault()}),c.append(l),a.append(c),d=b("<div></div>"),e=b('<button class="right">'+h.submit+"</button>"),g=b('<button class="right gray">'+h.cancel+"</button>"),d.append(e).append(g).append(m),a.append(d),g.click(function(a){a.preventDefault(),j.dropPanel.hide()}),k='<pre style="max-width:100%;overflow-x:auto;"><code{#langClass}>{#content}</code></pre>',e.click(function(a){function q(){var a;e&&(a=p.attr("class"),a!==e+" hljs"&&p.attr("class",e+" hljs")),p.html(c)}function r(){f.restoreSelectionByElem(o),h()}var c,d,e,g,h,n,o,p;return a.preventDefault(),(c=l.val())?(d=f.getRangeElem(),b.trim(b(d).text())&&0!==k.indexOf("<p><br></p>")&&(k="<p><br></p>"+k),e=m?m.val():"",g="",h=function(){i.find("pre code").each(function(a,c){var d=b(c);d.attr("codemark")||window.hljs&&(window.hljs.highlightBlock(c),d.attr("codemark","1"))})},e&&(g=' class="'+e+' hljs"'),c=c.replace(/&/gm,"&amp;").replace(/</gm,"&lt;").replace(/>/gm,"&gt;"),j.selected?(o=f.getSelfOrParentByName(d,"pre"),o&&(o=f.getSelfOrParentByName(d,"code")),o&&(p=b(o),f.customCommand(a,q,r)),void 0):(n=k.replace("{#langClass}",g).replace("{#content}",c),f.command(a,"insertHtml",n,h),void 0)):(l.focus(),void 0)})}function o(){var a=f.getRangeElem(),b=f.getSelfOrParentByName(a,"code");b?f.disableMenusExcept("insertcode"):f.enableMenusExcept("insertcode")}var f,g,h,i,j,k,l,m,e="insertcode";d(e)&&(setTimeout(c,0),f=this,g=f.config,h=g.lang,i=f.txt.$txt,j=new a.Menu({editor:f,id:e,title:h.insertcode}),j.clickEvent=function(){var e,c=this,d=c.dropPanel;if(d.isShowing)return d.hide(),void 0;if(l.val(""),d.show(),e=window.hljs,e&&e.listLanguages){if(0!==m.children().length)return;m.css({"margin-top":"9px","margin-left":"5px"}),b.each(e.listLanguages(),function(a,b){"xml"===b&&(b="html"),b===g.codeDefaultLang?m.append('<option value="'+b+'" selected="selected">'+b+"</option>"):m.append('<option value="'+b+'">'+b+"</option>")})}else m.hide()},j.clickEventSelected=function(){var e,g,h,i,c=this,d=c.dropPanel;return d.isShowing?(d.hide(),void 0):(d.show(),e=f.getRangeElem(),g=f.getSelfOrParentByName(e,"pre"),g&&(g=f.getSelfOrParentByName(e,"code")),g&&(h=b(g),l.val(h.text()),m&&(i=h.attr("class"),i&&m.val(i.split(" ")[0]))),void 0)},j.updateSelectedEvent=function(){var a=this,b=a.editor,c=b.getRangeElem();return c=b.getSelfOrParentByName(c,"pre"),c?!0:!1},k=b("<div></div>"),l=b("<textarea></textarea>"),m=b("<select></select>"),n(k),j.dropPanel=new a.DropPanel(f,j,{$content:k,width:500}),f.menus[e]=j,i.on("keydown",function(a){var b,c;13===a.keyCode&&(b=f.getRangeElem(),c=f.getSelfOrParentByName(b,"code"),c&&f.command(a,"insertHtml","\n"))}),i.on("keydown click",function(){setTimeout(o)}))})}),b(function(a){a.createMenu(function(b){var d,e,f,c="undo";b(c)&&(d=this,e=d.config.lang,f=new a.Menu({editor:d,id:c,title:e.undo}),f.clickEvent=function(){d.undo()},d.menus[c]=f,d.ready(function(){function d(){a.undoRecord()}var c,a=this,b=a.txt.$txt;b.on("keydown",function(b){var e=b.keyCode;return b.ctrlKey&&90===e?(a.undo(),void 0):(13===e?d():(c&&clearTimeout(c),c=setTimeout(d,1e3)),void 0)}),a.undoRecord()}))})}),b(function(a){a.createMenu(function(b){var d,e,f,c="redo";b(c)&&(d=this,e=d.config.lang,f=new a.Menu({editor:d,id:c,title:e.redo}),f.clickEvent=function(){d.redo()},d.menus[c]=f)})}),b(function(a){var c;a.createMenu(function(b){var e,f,g,h,i,j,k,l,m,d="fullscreen";b(d)&&(e=this,f=e.txt.$txt,g=e.config,h=g.zindex||1e4,i=g.lang,j=!1,m=new a.Menu({editor:e,id:d,title:i.fullscreen}),m.clickEvent=function(){var g,i,m,n,d=e.$editorContainer;d.addClass("wangEditor-fullscreen"),k=d.css("z-index"),d.css("z-index",h),i=f.height(),m=f.outerHeight(),e.useMaxHeight&&(l=f.css("max-height"),f.css("max-height","none"),g=f.parent(),g.after(f),g.remove(),f.css("overflow-y","auto")),n=e.menuContainer,f.height(a.$window.height()-n.height()-(m-i)),e.menuContainer.$menuContainer.attr("style",""),j=!0,e.isFullScreen=!0,c=a.$window.scrollTop()
},m.clickEventSelected=function(){var d=e.$editorContainer;d.removeClass("wangEditor-fullscreen"),d.css("z-index",k),e.useMaxHeight?f.css("max-height",l):e.$valueContainer.css("height",e.valueContainerHeight),e.txt.initHeight(),j=!1,e.isFullScreen=!1,null!=c&&a.$window.scrollTop(c)},m.updateSelectedEvent=function(){return j},e.menus[d]=m)})}),b(function(a,b){a.fn.renderMenus=function(){var f,g,a=this,c=a.menus,d=a.config.menus;a.menuContainer,g=0,b.each(d,function(a,b){return"|"===b?(g++,void 0):(f=c[b],f&&f.render(g),void 0)})}}),b(function(a){a.fn.renderMenuContainer=function(){var a=this,b=a.menuContainer;a.$editorContainer,b.render()}}),b(function(a){a.fn.renderTxt=function(){var a=this,b=a.txt;b.render(),a.ready(function(){b.initHeight()})}}),b(function(a){a.fn.renderEditorContainer=function(){var e,f,a=this,b=a.$valueContainer,c=a.$editorContainer,d=a.txt.$txt;b===d?(e=a.$prev,f=a.$parent,e&&e.length?e.after(c):f.prepend(c)):(b.after(c),b.hide())}}),b(function(a,b){a.fn.eventMenus=function(){var a=this.menus;b.each(a,function(a,b){b.bindEvent()})}}),b(function(a){a.fn.eventMenuContainer=function(){}}),b(function(a){a.fn.eventTxt=function(){var a=this.txt;a.saveSelectionEvent(),a.updateValueEvent(),a.updateMenuStyleEvent()}}),b(function(a){a.plugin(function(){var b=this,c=b.config.uploadImgFns;c.onload||(c.onload=function(b){var d,e,f;a.log("上传结束,返回结果为 "+b),d=this,e=d.uploadImgOriginalName||"",0===b.indexOf("error|")?(a.warn("上传失败:"+b.split("|")[1]),alert(b.split("|")[1])):(a.log("上传成功,即将插入编辑区域,结果为:"+b),f=document.createElement("img"),f.onload=function(){var c='<img src="'+b+'" alt="'+e+'" style="max-width:100%;"/>';d.command(null,"insertHtml",c),a.log("已插入图片,地址 "+b),f=null},f.onerror=function(){a.error("使用返回的结果获取图片,发生错误。请确认以下结果是否正确:"+b),f=null},f.src=b)}),c.ontimeout||(c.ontimeout=function(){a.error("上传图片超时"),alert("上传图片超时")}),c.onerror||(c.onerror=function(){a.error("上传上图片发生错误"),alert("上传上图片发生错误")})})}),b(function(a,b){window.FileReader&&window.FormData&&a.plugin(function(){function k(a,b){var f,c=window.atob(a.split(",")[1]),d=new ArrayBuffer(c.length),e=new Uint8Array(d);for(f=0;f<c.length;f++)e[f]=c.charCodeAt(f);return new Blob([d],{type:b})}function l(b,d){var e=document.createElement("img");e.onload=function(){var f='<img src="'+b+'" style="max-width:100%;"/>';c.command(d,"insertHtml",f),a.log("已插入图片,地址 "+b),e=null},e.onerror=function(){a.error("使用返回的结果获取图片,发生错误。请确认以下结果是否正确:"+b),e=null},e.src=b}function m(a){if(a.lengthComputable){var b=a.loaded/a.total;c.showUploadProgress(100*b)}}var c=this,d=c.config,e=d.uploadImgUrl,f=d.uploadTimeout,g=d.uploadImgFns,h=g.onload,i=g.ontimeout,j=g.onerror;e&&(c.xhrUploadImg=function(d){function E(){B&&clearTimeout(B),A&&A.abort&&A.abort(),g.preventDefault(),t&&t.call(c,A),c.hideUploadProgress()}var x,y,z,A,B,D,g=d.event,n=d.filename||"",o=d.base64,p=d.fileType||"image/png",q=d.name||"wangEditor_upload_file",r=d.loadfn||h,s=d.errorfn||j,t=d.timeoutfn||i,u=c.config.uploadParams||{},v=c.config.uploadHeaders||{},w="png";if(n.indexOf(".")>0?w=n.slice(n.lastIndexOf(".")-n.length+1):p.indexOf("/")>0&&p.split("/")[1]&&(w=p.split("/")[1]),c.config.imgExt){x=c.config.imgExt.split(","),y=!1;for(z in x)if(x[z]==w){y=!0;break}if(y===!1)return alert("只允许上传后缀名为:"+c.config.imgExt+"的图片"),!1}return a.isOnWebsite?(a.log("预览模拟上传"),l(o,g),void 0):(A=new XMLHttpRequest,D=new FormData,A.onload=function(){B&&clearTimeout(B),c.uploadImgOriginalName=n,n.indexOf(".")>0&&(c.uploadImgOriginalName=n.split(".")[0]),r&&r.call(c,A.responseText,A),c.hideUploadProgress()},A.onerror=function(){B&&clearTimeout(B),g.preventDefault(),s&&s.call(c,A),c.hideUploadProgress()},A.upload.onprogress=m,n=n||a.random()+"."+w,D.append(q,k(o,p),n),b.each(u,function(a,b){D.append(a,b)}),A.open("POST",e,!0),b.each(v,function(a,b){A.setRequestHeader(a,b)}),A.withCredentials=!0,A.send(D),B=setTimeout(E,f),a.log("开始上传...并开始超时计算"),void 0)})})}),b(function(a,b){a.plugin(function(){function i(){h||(h=!0,g.css({top:d+"px"}),e.append(g))}function k(){g.hide(),j=null}var j,a=this,c=a.menuContainer,d=c.height(),e=a.$editorContainer,f=e.width(),g=b('<div class="wangEditor-upload-progress"></div>'),h=!1;a.showUploadProgress=function(a){j&&clearTimeout(j),i(),g.show(),g.width(a*f/100)},a.hideUploadProgress=function(a){j&&clearTimeout(j),a=a||750,j=setTimeout(k,a)}})}),b(function(a,b){a.plugin(function(){var g,h,i,j,c=this,d=c.config,e=d.uploadImgUrl,f=d.uploadTimeout;e&&(h=c.$uploadContent,h&&(i=b('<div class="upload-icon-container"><i class="wangeditor-menu-img-upload"></i></div>'),h.append(i),j=new a.UploadFile({editor:c,uploadUrl:e,timeout:f,fileAccept:"image/*"}),i.click(function(a){g=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 d,e,f,g,h,i,c=this;c._hasRender||(a.log("渲染dom"),d=c.fileAccept,e=d?'accept="'+d+'"':"",f=c.multiple,g=f?'multiple="multiple"':"",h=b('<input type="file" '+e+" "+g+"/>"),i=b('<div style="visibility:hidden;"></div>'),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 m(){c.clear()}var c=this,d=c.editor,e=b.name||"",f=b.type||"",g=d.config.uploadImgFns,h=d.config.uploadImgFileName||"wangEditorH5File",i=g.onload,j=g.ontimeout,k=g.onerror,l=new FileReader;return i&&j&&k?(a.log("开始执行 "+e+" 文件的上传"),l.onload=function(b){a.log("已读取"+e+"文件");var c=b.target.result||this.result;d.xhrUploadImg({event:b,filename:e,base64:c,fileType:f,name:h,loadfn:function(a,b){m();var c=this;i.call(c,a,b)},errorfn:function(b){m(),a.isOnWebsite&&alert("wangEditor官网暂时没有服务端因此报错。实际项目中不会发生");var c=this;k.call(c,b)},timeoutfn:function(b){m(),a.isOnWebsite&&alert("wangEditor官网暂时没有服务端因此超时。实际项目中不会发生");var c=this;j(c,b)}})},l.readAsDataURL(b),void 0):(a.error("请为编辑器配置上传图片的 onload ontimeout onerror 回调事件"),void 0)},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 f,g,h,i,j,k,l,m,n,o,p,c=this,d=c.editor,e=d.config.uploadImgFileName||"wangEditorFormFile";c._hasRender||(f=c.uploadUrl,a.log("渲染dom"),g="iframe"+a.random(),h=b('<iframe name="'+g+'" id="'+g+'" frameborder="0" width="0" height="0"></iframe>'),i=c.multiple,j=i?'multiple="multiple"':"",k=b("<p>选择图片并上传</p>"),l=b('<input type="file" '+j+' name="'+e+'"/>'),m=b('<input type="submit" value="上传"/>'),n=b('<form enctype="multipart/form-data" method="post" action="'+f+'" target="'+g+'"></form>'),o=b('<div style="margin:10px 20px;"></div>'),n.append(k).append(l).append(m),b.each(d.config.uploadParams,function(a,c){n.append(b('<input type="hidden" name="'+a+'" value="'+c+'"/>'))}),o.append(n),o.append(h),c.$input=l,c.$iframe=h,p=new a.Modal(d,void 0,{$content:o}),c.modal=p,c._hasRender=!0)},c.fn.bindLoadEvent=function(){function h(){var e,h,d=b.trim(f.document.body.innerHTML);d&&(e=a.$input.val(),h=e,e.lastIndexOf("\\")>=0&&(h=e.slice(e.lastIndexOf("\\")+1),h.indexOf(".")>0&&(h=h.split(".")[0])),c.uploadImgOriginalName=h,g.call(c,d),a.clear(),a.hideModal())}var c,d,e,f,g,a=this;a._hasBindLoad||(c=a.editor,d=a.$iframe,e=d.get(0),f=e.contentWindow,g=c.config.uploadImgFns.onload,e.attachEvent?e.attachEvent("onload",h):e.onload=h,a._hasBindLoad=!0)},c.fn.show=function(){function c(){b.show(),a.bindLoadEvent()}var a=this,b=a.modal;setTimeout(c)},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 k(){var d=/^data:(image\/\w+);base64/,f=e.find("img");a.log("粘贴后,检查到编辑器有"+f.length+"个图片。开始遍历图片,试图找到刚刚粘贴过来的图片"),b.each(f,function(){var g,l,e=this,f=b(e),k=f.attr("src");j.each(function(){return e===this?(g=!0,!1):void 0}),g||(a.log("找到一个粘贴过来的图片"),d.test(k)?(a.log("src 是 base64 格式,可以上传"),l=k.match(d)[1],c.xhrUploadImg({event:i,base64:k,fileType:l,name:h})):a.log("src 为 "+k+" ,不是 base64 格式,暂时不支持上传"),f.remove())}),a.log("遍历结束")}var i,j,c=this,d=c.txt,e=d.$txt,f=c.config,g=f.uploadImgUrl,h=f.uploadImgFileName||"wangEditorPasteFile";g&&e.on("paste",function(d){var f,g,l;i=d,f=i.clipboardData||i.originalEvent.clipboardData,g=null==f?window.clipboardData&&window.clipboardData.getData("text"):f.getData("text/plain")||f.getData("text/html"),g||(l=f&&f.items,l?(a.log("通过 data.items 得到了数据"),b.each(l,function(b,d){var f,g,e=d.type||"";e.indexOf("image")<0||(f=d.getAsFile(),g=new FileReader,a.log("得到一个粘贴图片"),g.onload=function(b){a.log("读取到粘贴的图片");var d=b.target.result||this.result;c.xhrUploadImg({event:i,base64:d,fileType:e,name:h})},g.readAsDataURL(f))})):(a.log("未从 data.items 得到数据,使用检测粘贴图片的方式"),j=e.find("img"),a.log("粘贴前,检查到编辑器有"+j.length+"个图片"),setTimeout(k,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){var e,f;d.preventDefault(),e=d.originalEvent,f=e.dataTransfer&&e.dataTransfer.files,f&&f.length&&b.each(f,function(b,e){var i,f=e.type,g=e.name;f.indexOf("image/")<0||(a.log("得到图片 "+g),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 n(){h||(o(),i.append(j).append(k).append(l).append(m),c.$editorContainer.append(i),h=!0)}function o(){function b(b,d){a&&c.customCommand(b,a,d)}var a;k.click(function(c){a=function(){g.remove()},b(c,function(){setTimeout(q,100)})}),m.click(function(c){a=function(){g.css({width:"100%"})},b(c,function(){setTimeout(p)})}),l.click(function(c){a=function(){g.css({width:"auto"})},b(c,function(){setTimeout(p)})})}function p(){var a,b,d,e,h,k,l,m,n,o,p;c._disabled||null!=g&&(g.addClass("clicked"),a=g.position(),b=a.top,d=a.left,e=g.outerHeight(),h=g.outerWidth(),k=b+e,l=d,m=0,n=f.position().top,o=f.outerHeight(),k>n+o&&(k=n+o),i.show(),p=i.outerWidth(),m=h/2-p/2,i.css({top:k+5,left:l,"margin-left":m}),0>m?(i.css("margin-left","0"),j.hide()):j.show())}function q(){null!=g&&(g.removeClass("clicked"),g=null,i.hide())}var g,c=this,d=c.txt,e=d.$txt,f=c.useMaxHeight?e.parent():e,h=!1,i=b('<div class="txt-toolbar"></div>'),j=b('<div class="tip-triangle"></div>'),k=b('<a href="#"><i class="wangeditor-menu-img-trash-o"></i></a>'),l=b('<a href="#"><i class="wangeditor-menu-img-search-minus"></i></a>'),m=b('<a href="#"><i class="wangeditor-menu-img-search-plus"></i></a>');f.on("click","table",function(a){var c=b(a.currentTarget);return n(),g&&g.get(0)===c.get(0)?(setTimeout(q,100),void 0):(g=c,p(),a.preventDefault(),a.stopPropagation(),void 0)}).on("click keydown scroll",function(){setTimeout(q,100)}),a.$body.on("click keydown scroll",function(){setTimeout(q,100)})})}),b(function(a,b){a.userAgent.indexOf("MSIE 8")>0||a.plugin(function(){function C(a,d){var e,f,g,h,k;if(i){if(f=function(){null!=d&&(j=d)},h=!1,k=i.parent(),"a"===k.get(0).nodeName.toLowerCase()?(g=k,h=!0):g=b('<a target="_blank"></a>'),null==d)return g.attr("href")||"";if(""===d)h&&(e=function(){i.unwrap()});else{if(d===j)return;e=function(){g.attr("href",d),h||i.wrap(g)}}e&&c.customCommand(a,e,f)}}function D(){k||(E(),F(),o.append(p).append(q).append(r).append(s).append(t).append(u).append(v).append(w),x.append(y).append(A).append(z),m.append(n).append(o).append(x),c.$editorContainer.append(m).append(l),k=!0)}function E(){function d(b,d){a&&c.customCommand(b,a,d)}var a;p.click(function(b){C(b,""),a=function(){i.remove()},d(b,function(){setTimeout(H,100)})}),r.click(function(b){a=function(){var a=i.get(0),b=a.width,c=a.height;b=1.1*b,c=1.1*c,i.css({width:b+"px",height:c+"px"})},d(b,function(){setTimeout(G)})}),q.click(function(b){a=function(){var a=i.get(0),b=a.width,c=a.height;b=.9*b,c=.9*c,i.css({width:b+"px",height:c+"px"})},d(b,function(){setTimeout(G)})}),s.click(function(b){a=function(){i.parents("p").css({"text-align":"left"}).attr("align","left")},d(b,function(){setTimeout(H,100)})}),u.click(function(b){a=function(){i.parents("p").css({"text-align":"right"}).attr("align","right")},d(b,function(){setTimeout(H,100)})}),t.click(function(b){a=function(){i.parents("p").css({"text-align":"center"}).attr("align","center")},d(b,function(){setTimeout(H,100)})}),v.click(function(a){a.preventDefault(),j=C(a),y.val(j),o.hide(),x.show()}),z.click(function(a){a.preventDefault();var c=b.trim(y.val());c&&C(a,c),setTimeout(H)}),A.click(function(a){a.preventDefault(),y.val(j),o.show(),x.hide()}),w.click(function(a){a.preventDefault(),C(a,""),setTimeout(H)})}function F(){function h(a){var n,o,h=a.pageX-b,j=a.pageY-c,k=d+h,m=e+j;l.css({"margin-left":k,"margin-top":m}),n=f+h,o=g+j,i&&i.css({width:n,height:o})}var b,c,d,e,f,g;l.on("mousedown",function(j){i&&(b=j.pageX,c=j.pageY,d=parseFloat(l.css("margin-left"),10),e=parseFloat(l.css("margin-top"),10),f=i.width(),g=i.height(),m.hide(),a.$document.on("mousemove._dragResizeImg",h),a.$document.on("mouseup._dragResizeImg",function(){a.$document.off("mousemove._dragResizeImg"),a.$document.off("mouseup._dragResizeImg"),H(),l.css({"margin-left":d,"margin-top":e}),B=!1}),B=!0)})}function G(){var a,b,d,e,f,h,j,k,o,p,q;c._disabled||null!=i&&(i.addClass("clicked"),a=i.position(),b=a.top,d=a.left,e=i.outerHeight(),f=i.outerWidth(),l.css({top:b+e,left:d+f}),h=b+e,j=d,k=0,o=g.position().top,p=g.outerHeight(),h>o+p?h=o+p:l.show(),m.show(),q=m.outerWidth(),k=f/2-q/2,m.css({top:h+5,left:j,"margin-left":k}),0>k?(m.css("margin-left","0"),n.hide()):n.show(),c.disableMenusExcept())}function H(){null!=i&&(i.removeClass("clicked"),i=null,m.hide(),l.hide(),c.enableMenusExcept())}function I(a){var d=!1;return c.emotionUrls?(b.each(c.emotionUrls,function(b,c){var e=!1;return a===c&&(d=!0,e=!0),e?!1:void 0}),d):d}var i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,c=this,d=c.config.lang,e=c.txt,f=e.$txt,g=c.useMaxHeight?f.parent():f;c.$editorContainer,j="",k=!1,l=b('<div class="img-drag-point"></div>'),m=b('<div class="txt-toolbar"></div>'),n=b('<div class="tip-triangle"></div>'),o=b("<div></div>"),p=b('<a href="#"><i class="wangeditor-menu-img-trash-o"></i></a>'),q=b('<a href="#"><i class="wangeditor-menu-img-search-minus"></i></a>'),r=b('<a href="#"><i class="wangeditor-menu-img-search-plus"></i></a>'),s=b('<a href="#"><i class="wangeditor-menu-img-align-left"></i></a>'),t=b('<a href="#"><i class="wangeditor-menu-img-align-center"></i></a>'),u=b('<a href="#"><i class="wangeditor-menu-img-align-right"></i></a>'),v=b('<a href="#"><i class="wangeditor-menu-img-link"></i></a>'),w=b('<a href="#"><i class="wangeditor-menu-img-unlink"></i></a>'),x=b('<div style="display:none;"></div>'),y=b('<input type="text" style="height:26px; margin-left:10px; width:200px;"/>'),z=b('<button class="right">'+d.submit+"</button>"),A=b('<button class="right gray">'+d.cancel+"</button>"),B=!1,g.on("mousedown","img",function(a){a.preventDefault()}).on("click","img",function(a){var c=b(a.currentTarget),d=c.attr("src");if(d&&!I(d)){if(D(),i&&i.get(0)===c.get(0))return setTimeout(H,100),void 0;i=c,G(),o.show(),x.hide(),a.preventDefault(),a.stopPropagation()}}).on("click keydown scroll",function(){B||setTimeout(H,100)})})}),b(function(a,b){a.plugin(function(){function o(){i||(f.append(g).append(h),a.$editorContainer.append(f),i=!0)}function p(){var b,c,d,g,h,i,j;e&&(b=e.position(),c=b.left,d=b.top,g=e.height(),h=d+g+5,i=a.menuContainer.height(),j=a.txt.$txt.outerHeight(),h>i+j&&(h=i+j+5),f.css({top:h,left:c}))}function q(){if(!j&&e){o(),f.show();var a=e.attr("href");h.attr("href",a),p(),j=!0}}function r(){j&&e&&(f.hide(),j=!1)}var e,i,k,l,m,a=this,c=a.config.lang,d=a.txt.$txt,f=b('<div class="txt-toolbar"></div>'),g=b('<div class="tip-triangle"></div>'),h=b('<a href="#" target="_blank"><i class="wangeditor-menu-img-link"></i> '+c.openLink+"</a>"),j=!1;d.on("mouseenter","a",function(a){k&&clearTimeout(k),k=setTimeout(function(){var f,c=a.currentTarget,d=b(c);e=d,f=d.children("img"),f.length&&(f.click(function(){r()}),f.hasClass("clicked"))||q()},500)}).on("mouseleave","a",function(){l&&clearTimeout(l),l=setTimeout(r,500)}).on("click keydown scroll",function(){setTimeout(r,100)}),f.on("mouseenter",function(){l&&clearTimeout(l)}).on("mouseleave",function(){m&&clearTimeout(m),m=setTimeout(r,500)})})}),b(function(a){a.plugin(function(){var d,e,f,g,h,i,j,k,l,b=this,c=b.config.menuFixed;c!==!1&&"number"==typeof c&&(d=parseFloat(a.$body.css("margin-top"),10),isNaN(d)&&(d=0),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(){var m,n;b.isFullScreen||(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&&f+g>m+c+l+30?(h.css({position:"fixed",top:c}),h.width(n),a.$body.css({"margin-top":d+l}),b._isMenufixed||(b._isMenufixed=!0)):(h.css({position:i,top:j}),h.css("width","100%"),a.$body.css({"margin-top":d}),b._isMenufixed&&(b._isMenufixed=!1)))}))})}),b(function(a,b){a.createMenu(function(c){var e,f,d="indent";c(d)&&(e=this,f=new a.Menu({editor:e,id:d,title:"缩进",$domNormal:b('<a href="#" tabindex="-1"><i class="wangeditor-menu-img-indent-left"></i></a>'),$domSelected:b('<a href="#" tabindex="-1" class="selected"><i class="wangeditor-menu-img-indent-left"></i></a>')}),f.clickEvent=function(a){function g(){f.css("text-indent","2em")}var f,c=e.getRangeElem(),d=e.getSelfOrParentByName(c,"p");return d?(f=b(d),e.customCommand(a,g),void 0):a.preventDefault()},f.clickEventSelected=function(a){function g(){f.css("text-indent","0")}var f,c=e.getRangeElem(),d=e.getSelfOrParentByName(c,"p");return d?(f=b(d),e.customCommand(a,g),void 0):a.preventDefault()},f.updateSelectedEvent=function(){var d,f,a=e.getRangeElem(),c=e.getSelfOrParentByName(a,"p");return c?(d=b(c),f=d.css("text-indent"),f&&"0px"!==f?!0:!1):!1},e.menus[d]=f)})}),b(function(a,b){a.createMenu(function(c){var e,f,g,h,d="lineheight";c(d)&&(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+"")},f=new a.Menu({editor:e,id:d,title:"行高",commandName:"lineHeight",$domNormal:b('<a href="#" tabindex="-1"><i class="wangeditor-menu-img-arrows-v"></i></a>'),$domSelected:b('<a href="#" tabindex="-1" class="selected"><i class="wangeditor-menu-img-arrows-v"></i></a>')}),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='<span style="line-height:{#commandValue}">{#title}</span>',f.dropList=new a.DropList(e,f,{data:g,tpl:h}),e.menus[d]=f)})}),b(function(a,b){a.plugin(function(){var e,f,g,h,c=this,d=c.config.customUpload;if(d){if(c.config.uploadImgUrl)return alert("自定义上传无效详看浏览器日志console.log"),a.error("已经配置了 uploadImgUrl ,就不能再配置 customUpload ,两者冲突。将导致自定义上传无效。"),void 0;e=c.$uploadContent,e||a.error("自定义上传,无法获取 editor.$uploadContent"),f=b('<div class="upload-icon-container"><i class="wangeditor-menu-img-upload"></i></div>'),e.append(f),g="upload"+a.random(),h="upload"+a.random(),f.attr("id",g),e.attr("id",h),c.customUploadBtnId=g,c.customUploadContainerId=h}})}),window.wangEditor});