|
|
/*! wangEditor.js 2016-02-15 */
|
|
|
window.jQuery = require('jquery');
|
|
|
var define;!function(a){"function"==typeof define?define.amd?define("wangEditor",["jquery"],a):define.cmd?define(function(b,c,d){return a}):a(window.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)};!function(a,b){if(!a.wangEditor){var c=function(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",c.isOnWebsite=c.hostname===c.websiteHost,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){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){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?!0:!1,a=a||this.currentRange(),a&&(a.collapse(b),this.currentRange(a))},a.fn.getRangeText=d?c:function(a){return(a=a||this.currentRange())?a.toString():void 0},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?!0:!1},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(a){var b;a=a||this.currentRange(),a&&(b=document.getSelection(),b.removeAllRanges(),b.addRange(a))},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){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 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.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(){return this===c?(e=!0,!1):void 0}),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,b){var c=b.val;null!=c&&(a.txt.$txt.html(c),a.updateValue())}var d=[],e=[],f=20;a.fn.undoRecord=function(){var a=this,b=a.txt.$txt,c=b.html(),g=e.length?e[0]:"";c!==g&&(d.length&&(d=[]),e.unshift({range:a.currentRange(),val:b.html()}),e.length>f&&e.pop())},a.fn.undo=function(){if(e.length){var a=e.shift();d.unshift(a),c(this,a)}},a.fn.redo=function(){if(d.length){var a=d.shift();e.unshift(a),c(this,a)}}}),b(function(a,b){a.fn.create=function(){var c=this;c.addMenus(),c.renderMenus(),c.renderMenuContainer(),c.renderTxt(),c.renderEditorContainer(),c.eventMenus(),c.eventMenuContainer(),c.eventTxt(),c.readyHeadler(),c.initSelection();var d=a._plugins;d&&d.length&&b.each(d,function(a,b){b.call(c)}),c.$txt=c.txt.$txt},a.fn.disable=function(){this.txt.$txt.removeAttr("contenteditable")},a.fn.enable=function(){this.txt.$txt.attr("contenteditable","true")}}),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('<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 c,d=this.$menuContainer;this.$currentGroup&&this.currentGroupIdx===a||(c=b('<div class="menu-group clearfix"></div>'),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('<div class="menu-item clearfix"></div>');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(a){function c(){i.show()}function d(){i.hide()}var e,f=this,g=f.editor,h=f.title,i=b('<div class="menu-tip"></div>');f.tipWidth||(e=b('<p style="opacity:0; filter:Alpha(opacity=0); position:absolute;">'+h+"</p>"),g.$editorContainer.append(e),g.ready(function(){var a=e.outerWidth()+5,b=i.outerWidth(),c=parseFloat(i.css("margin-left"),10);e.remove(),e=null,i.css({width:a,"margin-left":c+(b-a)/2}),f.tipWidth=a})),i.append(h),a.append(i);var j;a.find("a").on("mouseenter",function(a){f.active()||f.disabled()||(j=setTimeout(c,200))}).on("mouseleave",function(a){j&&clearTimeout(j),d()}).on("click",d)},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.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||"<span>{#title}</span>",g=b('<div class="wangEditor-drop-list clearfix"></div>');b.each(e,function(d,e){a=f.replace(/{#commandValue}/gi,d).replace(/{#title}/gi,e),c=b('<a href="#" commandValue="'+d+'"></a>'),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;g.on("click","a[commandValue]",function(a){var g=b(a.currentTarget).attr("commandValue");d.selected&&c.isRangeEmpty()&&f?c.commandForElem(f,a,e,g):c.command(a,e,g)})},c.fn.initHideEvent=function(){var c=this,d=c.$list.get(0);a.$body.on("click",function(a){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()})}}),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=d.selected?d.$domSelected:d.$domNormal,f=e.offsetParent().position(),g=f.top,h=f.left,i=e.offsetParent().height(),j=e.offsetParent().width(),k=b.outerWidth(),l=c.txt.$txt.outerWidth(),m=g+i,n=h+j/2,o=0-j/2,p=n+k-l;p>-10&&(o=o-p-10),b.css({top:m,left:n,"margin-left":o})},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.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=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()})}}),b(function(a,b){var c=a.DropPanel;c.fn._render=function(){var a=this,b=a.editor,c=a.$panel;b.$editorContainer.append(c),a.rendered=!0},c.fn._position=function(){var a=this,b=a.$panel,c=a.$triangle,d=a.editor,e=a.menu,f=e.selected?e.$domSelected:e.$domNormal,g=f.offsetParent().position(),h=g.top,i=g.left,j=f.offsetParent().height(),k=f.offsetParent().width(),l=b.outerWidth(),m=d.txt.$txt.outerWidth(),n=h+j,o=i+k/2,p=0-l/2,q=p;0-p>o-10&&(p=0-(o-10));var r=o+l+p-m;r>-10&&(p=p-r-10),b.css({top:n,left:o,"margin-left":p}),c.css({"margin-left":q-p-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 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(){};c.fn=c.prototype,a.Modal=c}),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('<div class="wangEditor-txt" contentEditable="true">'+f+"</div>"),d.ready(function(){c.insertEmptyP()}),c.$txt=a,c.contentEmptyHandle(),c.bindEnterForDiv(),c.bindTabEvent(),c.bindPasteFilter()},c.fn.contentEmptyHandle=function(){var a,c=this,d=c.editor,e=c.$txt;e.on("keyup",function(c){if(8===c.keyCode){var f=b.trim(e.html());f&&"<br>"!==f||(a=b("<p><br/></p>"),e.html(""),e.append(a),d.restoreSelectionByElem(a.get(0)))}})},c.fn.bindEnterForDiv=function(){function c(){if(d){var a=b("<p>"+d.html()+"</p>");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("<p>"+e.html()+"</p>"),e.after(g),e.remove(),f.restoreSelectionByElem(g.get(0),"start"))}}})},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,g,h,i,j=e.nodeName.toLowerCase(),k=e.nodeType;if(3===k||1===k){if("a"===j&&e.href)return void(d=d+'<p><a href="'+e.href+'" >'+(e.textContent||e.innerHTML)+"</a></p>");if("img"===j&&e.src)return void(d=d+'<p><img src="'+e.src+'" style="max-width:100%"/></p>');if(/^h\d$/.test(j))return void(d=d+"<"+j+">"+(e.textContent||e.innerHTML)+"</"+j+">");if("table"===j||"ul"===j||"ol"===j)return f=b(c(e)),void(d+=b("<div></div>").append(f).html());if(3===k)return void(d=d+"<p>"+(e.textContent||e.innerHTML)+"</p>");if(g=e.childNodes,h=g.length)for(i=0;h>i;i++)a(g[i])}}}function c(a){var d=a.attributes||[],e=[];b.each(d,function(a,b){b&&2===b.nodeType&&e.push(b.nodeName)}),b.each(e,function(b,c){a.removeAttribute(c)});var f=a.childNodes;return f.length&&b.each(f,function(a,b){c(b)}),a}var d,e=this,f=e.editor,g=e.$txt;g.on("paste",function(c){if(f.config.pasteFilter){var e,g,h=c.clipboardData||c.originalEvent.clipboardData;if(h&&h.getData)e=h.getData("text/html"),g=b("<div>"+e+"</div>"),d="",a(g.get(0));else{if(!window.clipboardData||!window.clipboardData.getData)return;if(d=window.clipboardData.getData("text"),!d)return;d="<p>"+d+"</p>",d=d.replace((new RegExp("\n","g"),"</p><p>"))}d&&f.command(c,"insertHtml",d)}})}}),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=a.$valueContainer.height(),c=a.menuContainer.height(),d=b-c;d=50>d?50:d,this.$txt.height(d)},c.fn.saveSelectionEvent=function(){var a=this.$txt,b=this.editor;a.on(d+" focus blur",function(a){b.saveSelection()}),a.on("mousedown",function(){a.on("mouseleave.saveSelection",function(a){b.saveSelection(),b.updateMenuStyle()})}).on("mouseup",function(){a.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("<p><br></p>")):void("<br>"!==c.last().html()&&a.append(b("<p><br></p>")))},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 class="height-tip"><i>'),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;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()});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:"图片",vedio:"视频",width:"宽",height:"高",location:"位置",loading:"加载中",searchlocation:"搜索位置",dynamicMap:"动态地图",clearLocation:"清除位置",langDynamicOneLocation:"动态地图只能显示一个位置",insertcode:"插入代码",undo:"撤销",redo:"重复",fullscreen:"全屏"},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",vedio:"Vedio",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"}}),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","vedio","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"],a.config.fontsizes={1:"10px",2:"13px",3:"16px",4:"19px",5:"22px",6:"25px",7:"28px"},a.config.emotions={"default":{title:"默认",size:18,imgs:["../static/emotions/default/1.gif","../static/emotions/default/2.gif","../static/emotions/default/3.gif","../static/emotions/default/4.gif","../static/emotions/default/5.gif","../static/emotions/default/6.gif","../static/emotions/default/7.gif","../static/emotions/default/8.gif","../static/emotions/default/9.gif","../static/emotions/default/10.gif","../static/emotions/default/11.gif","../static/emotions/default/12.gif","../static/emotions/default/13.gif","../static/emotions/default/14.gif","../static/emotions/default/15.gif","../static/emotions/default/16.gif","../static/emotions/default/17.gif","../static/emotions/default/18.gif","../static/emotions/default/19.gif","../static/emotions/default/20.gif","../static/emotions/default/21.gif","../static/emotions/default/22.gif","../static/emotions/default/23.gif","../static/emotions/default/24.gif","../static/emotions/default/25.gif","../static/emotions/default/26.gif","../static/emotions/default/27.gif","../static/emotions/default/28.gif","../static/emotions/default/29.gif","../static/emotions/default/30.gif","../static/emotions/default/31.gif","../static/emotions/default/32.gif","../static/emotions/default/33.gif","../static/emotions/default/34.gif","../static/emotions/default/35.gif","../static/emotions/default/36.gif","../static/emotions/default/37.gif","../static/emotions/default/38.gif","../static/emotions/default/39.gif","../static/emotions/default/40.gif","../static/emotions/default/41.gif","../static/emotions/default/42.gif","../static/emotions/default/43.gif","../static/emotions/default/44.gif","../static/emotions/default/45.gif","../static/emotions/default/46.gif","../static/emotions/default/47.gif","../static/emotions/default/48.gif","../static/emotions/default/49.gif","../static/emotions/default/50.gif"]},jinxing:{title:"金星",size:50,imgs:["../static/emotions/jinxing/1.gif","../static/emotions/jinxing/2.gif","../static/emotions/jinxing/3.gif","../static/emotions/jinxing/4.gif","../static/emotions/jinxing/5.gif","../static/emotions/jinxing/6.gif"]}},a.config.mapAk="TVhjYjq1ICT2qqL5LdS8mwas",a.config.uploadImgUrl="",a.config.uploadTimeout=2e4,a.config.pasteFilter=!0}),b(function(a,b){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"},vedio:{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,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?!0:!1}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("<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 d(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="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("<div></div>");b.each(h,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),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?!0:!1},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("<p>"+f.text()+"</p>"),f.after(g).remove()),c=j.getSelfOrParentByName(a,"p,h1,h2,h3,h4,h5"),c&&(d=b(c),g=b("<p>"+d.text()+"</p>"),d.after(g).remove()),h=j.getSelfOrParentByName(a,"ul,ol"),h&&(i=b(h),g=b("<p>"+i.text()+"</p>"),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){var d="source";if(c(d)){var e=this,f=e.config.lang,g=new a.Menu({editor:e,id:d,title:f.source});g.isShowCode=!1,g.clickEvent=function(a){var c=this,d=c.editor,e=d.txt.$txt,f=e.outerHeight(),h=e.height();c.$codeTextarea||(c.$codeTextarea=b('<textarea class="code-textarea"></textarea>'));var i=c.$codeTextarea;i.css({height:h,"margin-top":f-h}),i.val(e.html()),e.after(i).hide(),i.show(),g.isShowCode=!0,this.updateSelected(),d.disableMenusExcept("source")},g.clickEventSelected=function(a){var b,c=this,d=c.editor,e=d.txt.$txt,f=c.$codeTextarea;f&&(b=f.val(),d.config.jsFilter&&(b=b.replace(/<script[\s\S]*?<\/script>/gi,"")),e.html(b),f.after(e).hide(),e.show(),g.isShowCode=!1,this.updateSelected(),d.enableMenusExcept("source"))},g.updateSelectedEvent=function(){return this.isShowCode},e.menus[d]=g}})}),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("<p>"+f.text()+"</p>"),f.after(h).remove(),h.wrap("<blockquote>")}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;return a=b(g),c=a.children(),c.length?(c.each(function(c){var d=b(this);"P"===d.get(0).nodeName?a.after(d):a.after("<p>"+d.text()+"</p>"),h=d}),void a.remove()):void 0}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?!0:!1},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='<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,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='<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,b){a.createMenu(function(b){var c="head";if(b(c)){var 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"},h="{#commandValue}{#title}";f.dropList=new a.DropList(d,f,{data:g,tpl:h}),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,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(b){var c="alignleft";if(b(c)){var d=this,e=d.config.lang,f=new a.Menu({editor:d,id:c,title:e.alignleft,commandName:"JustifyLeft"});f.updateSelectedEvent=function(){var a=d.getRangeElem();return a=d.getSelfOrParentByName(a,"p,h1,h2,h3,h4,h5,li",function(a){var b;return a&&a.style&&null!=a.style.cssText&&(b=a.style.cssText,b&&/text-align:\s*left;/.test(b))?!0:!1}),a?!0:!1},d.menus[c]=f}})}),b(function(a,b){a.createMenu(function(b){var c="aligncenter";if(b(c)){var d=this,e=d.config.lang,f=new a.Menu({editor:d,id:c,title:e.aligncenter,commandName:"JustifyCenter"});f.updateSelectedEvent=function(){var a=d.getRangeElem();return a=d.getSelfOrParentByName(a,"p,h1,h2,h3,h4,h5,li",function(a){var b;return a&&a.style&&null!=a.style.cssText&&(b=a.style.cssText,b&&/text-align:\s*center;/.test(b))?!0:!1}),a?!0:!1},d.menus[c]=f}})}),b(function(a,b){a.createMenu(function(b){var c="alignright";if(b(c)){var d=this,e=d.config.lang,f=new a.Menu({editor:d,id:c,title:e.alignright,commandName:"JustifyRight"});f.updateSelectedEvent=function(){var a=d.getRangeElem();return a=d.getSelfOrParentByName(a,"p,h1,h2,h3,h4,h5,li",function(a){var b;return a&&a.style&&null!=a.style.cssText&&(b=a.style.cssText,b&&/text-align:\s*right;/.test(b))?!0:!1}),a?!0:!1},d.menus[c]=f}})}),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("<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(a){var b=this,c=b.dropPanel;if(c.isShowing)return void c.hide();l.val(""),m.val("");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?!0:!1},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='<a href="'+s+'" target="_blank">'+t+"</a>",a.userAgent.indexOf("Firefox")>0&&(f+="<span> </span>"),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("<span>"+i.text()+"</span>");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('<div style="font-size: 14px; color: #666; text-align:right;"></div>'),l=b('<table class="choose-table" style="margin-bottom:10px;margin-top:5px;">'),m=b("<span>0</span>"),n=b("<span> 行 </span>"),o=b("<span>0</span>"),p=b("<span> 列</span>");for(f=0;10>f;f++){for(e=b('<tr index="'+(f+1)+'">'),g=0;10>g;g++)e.append(b('<td index="'+(g+1)+'">'));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")}),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="\n<table>";for(c=0;j>c;c++){for(l+="\n <tr>",d=0;k>d;d++)l+="\n <td><span> </span></td>";l+="\n </tr>"}l+="\n</table>\n",h.command(a,"insertHtml",l)}),j.dropPanel=new a.DropPanel(h,j,{$content:k,width:181}),h.menus[d]=j}})}),b(function(a,b){a.createMenu(function(c){var d="emotion";if(c(d)){var e=this,f=e.config.lang,g=e.config.emotions,h=new a.Menu({editor:e,id:d,title:f.emotion}),i=b('<div class="panel-tab"></div>'),j=b('<div class="tab-container"></div>'),k=b('<div class="content-container"></div>');b.each(g,function(a,c){var d=c.title,e=c.size,f=c.imgs,g=b('<a href="#">'+d+" </a>");j.append(g);var h=b('<div class="content"></div>');k.append(h),b.each(f,function(a,c){var d=b('<a href="#" commandValue="'+c+'"></a>'),f=b("<img>");f.css({width:e+"px",height:e+"px"}),f.attr("_src",c),d.append(f),h.append(d)}),g.click(function(a){j.children().removeClass("selected"),k.children().removeClass("selected"),h.addClass("selected"),g.addClass("selected"),a.preventDefault()})}),i.append(j).append(k),j.children().first().addClass("selected"),k.children().first().addClass("selected"),k.on("click","a[commandValue]",function(a){var c=b(a.currentTarget),d=c.attr("commandValue");e.command(a,"InsertImage",d)}),h.dropPanel=new a.DropPanel(e,h,{$content:i,width:350}),h.clickEvent=function(c){var d=this,e=d.dropPanel;return e.isShowing?void e.hide():(e.show(),void(d.imgLoaded||(k.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)))},e.menus[d]=h}})}),b(function(a,b){function c(a,c,d){function e(){h.val("")}var f=a.config.lang,g=b('<div style="margin:20px 10px 10px 10px;"></div>'),h=b('<input type="text" class="block" placeholder="http://"/>');g.append(h);var i=b('<button class="right">'+f.submit+"</button>"),j=b('<button class="right gray">'+f.cancel+"</button>");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='<img style="max-width:100%;" src="'+d+'"/>';a.command(c,"insertHtml",f,e)})}a.createMenu(function(d){function e(){n.click(function(a){l.children().removeClass("selected"),m.children().removeClass("selected"),p.addClass("selected"),n.addClass("selected"),a.preventDefault()}),o.click(function(b){l.children().removeClass("selected"),m.children().removeClass("selected"),q.addClass("selected"),o.addClass("selected"),b.preventDefault(),a.placeholder&&q.find("input[type=text]").focus()}),n.click()}function f(){l.remove(),p.remove(),q.addClass("selected")}var g="img";if(d(g)){var h=this,i=h.config.lang,j=new a.Menu({editor:h,id:g,title:i.img}),k=b('<div class="panel-tab"></div>'),l=b('<div class="tab-container"></div>'),m=b('<div class="content-container"></div>');k.append(l).append(m);var n=b('<a href="#">上传图片</a>'),o=b('<a href="#">网络图片</a>');l.append(n).append(o);var p=b('<div class="content"></div>');m.append(p);var q=b('<div class="content"></div>');m.append(q),c(h,j,q),j.dropPanel=new a.DropPanel(h,j,{$content:k,width:400}),h.menus[g]=j,h.ready(function(){var b=this,c=b.config,d=c.uploadImgUrl;return a.userAgent.indexOf("MSIE 8")>0?void f():void(d?(b.$uploadContent=p,e()):f())})}})}),b(function(a,b){a.createMenu(function(c){var d="vedio";if(c(d)){var e=this,f=e.config.lang,g=/^\s*(http:\/\/|https:\/\/).+(\.swf|\.ogg|\.mp4|\.webm)/i,h=new a.Menu({editor:e,id:d,title:f.vedio,commandName:"unLink"}),i=['<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ',' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" ',' width="#{width}" ',' height="#{height}" >',' <param name="movie" ',' value="#{vedioUrl}" />',' <param name="allowFullScreen" value="true" />',' <param name="allowScriptAccess" value="always" />',' <param value="transparent" name="wmode" />',' <embed src="#{vedioUrl}"',' width="#{width}" ',' height="#{height}" ',' name="cc_8E6888CDEA7087C49C33DC5901307461" ',' allowFullScreen="true" ',' wmode="transparent" ',' allowScriptAccess="always" ',' pluginspage="http://www.macromedia.com/go/getflashplayer" ',' type="application/x-shockwave-flash"/>',"</object>","<p><br></p>"].join(""),j=['<video src="#{vedioUrl}" controls="controls" width="#{width}" height="#{height}">',"</video>","<p><br></p>"].join(""),k=b("<div></div>"),l=b('<div style="margin:20px 10px;"></div>'),m=b('<input type="text" class="block" placeholder="*.swf, *.mp4, *.ogg, *.webm"/>');l.append(m);var n=b('<div style="margin:20px 10px;"></div>'),o=b('<input type="text" value="480" style="width:50px;text-align:center;"/>'),p=b('<input type="text" value="360" style="width:50px;text-align:center;"/>');n.append("<span> "+f.width+" </span>").append(o).append("<span> px </span>").append("<span> "+f.height+" </span>").append(p).append("<span> px </span>");var q=b("<div></div>"),r=b('<button class="right">'+f.submit+"</button>"),s=b('<button class="right gray">'+f.cancel+"</button>");q.append(r).append(s),k.append(l).append(n).append(q),s.click(function(a){a.preventDefault(),m.val(""),h.dropPanel.hide()}),r.click(function(a){a.preventDefault();var c,d=b.trim(m.val()),f=parseInt(o.val()),k=parseInt(p.val());return d?g.test(d)?isNaN(f)||isNaN(k)?void alert("宽度或高度不是数字!"):(c=/.swf/i.test(d)?i.replace(/#{vedioUrl}/gi,d).replace(/#{width}/gi,f).replace(/#{height}/gi,k):j.replace(/#{vedioUrl}/gi,d).replace(/#{width}/gi,f).replace(/#{height}/gi,k),e.command(a,"insertHtml",c),void m.val("")):(alert("视频链接格式错误!"),void h.dropPanel.focusFirstInput()):void h.dropPanel.focusFirstInput()}),h.dropPanel=new a.DropPanel(e,h,{$content:k,width:400}),e.menus[d]=h}})}),b(function(a,b){var c=function(a){return"onkeyup"in a}(document.createElement("input"));a.baiduMapAk="TVhjYjq1ICT2qqL5LdS8mwas";var d=1;a.createMenu(function(e){function f(){q.val("")}var g="location";if(e(g)){if(d++>1)return void a.error("目前不支持在一个页面多个编辑器上同时使用地图,可通过自定义菜单配置去掉地图菜单");var h=this,i=h.config,j=i.lang,k=i.mapAk;h.mapData={};var l=h.mapData;l.markers=[],l.mapContainerId="map"+a.random(),l.clearLocations=function(){var a=l.map;a&&(a.clearOverlays(),l.markers=[])},l.searchMap=function(){var a=l.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(),l.markers.push(c)):a.centerAndZoom(e,11)},e)))}},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(l.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)&&(l.searchMap(),a=c,b=d),f&&clearTimeout(f),f=setTimeout(g,1e3)},f=setTimeout(g,1e3))}var d=window.BMap;l.map||(l.map=new d.Map(l.mapContainerId));var e=l.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(),l.markers.push(b)})},l.loadMapScript=function(){var b=document.createElement("script");b.type="text/javascript",b.src="http://api.map.baidu.com/api?v=2.0&ak="+k+"&callback=baiduMapCallBack";try{document.body.appendChild(b)}catch(c){a.error("加载地图过程中发生错误")}},l.initMap=function(){window.BMap?window.baiduMapCallBack():l.loadMapScript()};var m=new a.Menu({editor:h,id:g,title:j.location});h.menus[g]=m;var n=b("<div></div>"),o=b('<div style="margin:10px 0;"></div>'),p=b('<input type="text"/>');p.css({width:"80px","text-align":"center"});var q=b('<input type="text"/>');q.css({width:"300px","margin-left":"10px"}).attr("placeholder",j.searchlocation);var r=b('<button class="right link">'+j.clearLocation+"</button>");o.append(r).append(p).append(q),n.append(o),r.click(function(a){q.val(""),q.focus(),l.clearLocations(),a.preventDefault()});var s=b('<div id="'+l.mapContainerId+'"></div>');s.css({height:"260px",width:"100%",position:"relative","margin-top":"10px",border:"1px solid #f1f1f1"});var t=b("<span>"+j.loading+"</span>");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('<div style="margin:10px 0;"></div>'),v=b('<button class="right">'+j.submit+"</button>"),w=b('<button class="right gray">'+j.cancel+"</button>"),x=b('<label style="display:inline-block;margin-top:10px;color:#666;"></label>'),y=b('<input type="checkbox">');x.append(y).append('<span style="display:inline-block;margin-left:5px;"> '+j.dynamicMap+"</span>"),u.append(x).append(v).append(w),n.append(u),w.click(function(a){a.preventDefault(),f(),m.dropPanel.hide()}),v.click(function(a){a.preventDefault();var c,d,e,g=l.map,i=y.is(":checked"),k=l.markers,m=g.getCenter(),n=m.lng,o=m.lat,p=g.getZoom(),q=g.getSize(),r=q.width,s=q.height;if(d=i?"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,k.length>0&&(d+="&markers=",b.each(k,function(a,b){c=b.getPosition(),a>0&&(d+="|"),d=d+c.lng+","+c.lat})),i){if(k.length>1)return void alert(j.langDynamicOneLocation);d+="&markerStyles=l,A",e='<iframe class="ueditor_baidumap" src="{src}" frameborder="0" width="'+r+'" height="'+s+'"></iframe>',e=e.replace("{src}",d),h.command(a,"insertHtml",e,f)}else h.command(a,"insertHtml",'<img style="max-width:100%;" src="'+d+'"/>',f)}),m.dropPanel=new a.DropPanel(h,m,{$content:n,width:500}),m.onRender=function(){k===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():(l.map||(d=!0),l.initMap(),c.show(),void(d||q.focus()))}}})}),b(function(a,b){function c(){if(!(a.userAgent.indexOf("MSIE 8")>0)){var b=document.createElement("script");b.type="text/javascript",b.src="http://apps.bdimg.com/libs/highlight.js/9.1.0/highlight.min.js",document.body.appendChild(b)}}a.createMenu(function(d){function e(a){var c=b("<div></div>");c.css({margin:"15px 5px 5px 5px",height:"160px","text-align":"center"}),m.css({width:"100%",height:"100%",padding:"10px"}),m.on("keydown",function(a){9===a.keyCode&&a.preventDefault()}),c.append(m),a.append(c);var d=b("<div></div>"),e=b('<button class="right">'+i.submit+"</button>"),f=b('<button class="right gray">'+i.cancel+"</button>");d.append(e).append(f).append(n),a.append(d),f.click(function(a){a.preventDefault(),k.dropPanel.hide()});var g='<pre style="max-width:100%;overflow-x:auto;"><code{#langClass}>{#content}</code></pre>';e.click(function(a){function c(){var a;f&&(a=o.attr("class"),a!==f+" hljs"&&o.attr("class",f+" hljs")),o.html(e)}function d(){h.restoreSelectionByElem(q),j()}a.preventDefault();var e=m.val();if(!e)return void m.focus();var f=n?n.val():"",i="",j=function(){b("pre code").each(function(a,b){window.hljs&&window.hljs.highlightBlock(b)})};if(f&&(i=' class="'+f+' hljs"'),e=e.replace(/&/gm,"&").replace(/</gm,"<").replace(/>/gm,">"),!k.selected){var l=g.replace("{#langClass}",i).replace("{#content}",e);return void h.command(a,"insertHtml",l,j)}var o,p=h.getRangeElem(),q=h.getSelfOrParentByName(p,"pre");q&&(q=h.getSelfOrParentByName(p,"code")),q&&(o=b(q),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.lang,j=h.txt.$txt,k=new a.Menu({editor:h,id:g,title:i.insertcode});k.clickEvent=function(a){var c=this,d=c.dropPanel;if(d.isShowing)return void d.hide();m.val(""),d.show();var e=window.hljs;e&&e.listLanguages?(n.css({"margin-top":"9px","margin-left":"5px"}),b.each(e.listLanguages(),function(a,b){n.append('<option value="'+b+'">'+b+"</option>")})):n.hide()},k.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),m.val(e.text()),n&&(f=e.attr("class"),f&&n.val(f.split(" ")[0])))},k.updateSelectedEvent=function(){var a,b=this,c=b.editor;return a=c.getRangeElem(),a=c.getSelfOrParentByName(a,"pre"),a?!0:!1};var l=b("<div></div>"),m=b("<textarea></textarea>"),n=b("<select></select>");e(l),k.dropPanel=new a.DropPanel(h,k,{$content:l,width:500}),h.menus[g]=k,j.on("keydown",function(a){if(13===a.keyCode){var b=h.getRangeElem(),c=h.getSelfOrParentByName(b,"code");c&&h.command(a,"insertHtml","\n")}}),j.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(){var a=this,b=a.txt.$txt;b.on("keydown",function(b){13===b.keyCode&&a.undoRecord()}),a.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){a.createMenu(function(b){var c="fullscreen";if(b(c)){var d,e,f=this,g=f.config,h=g.zindex||1e4,i=g.lang,j=!1,k=new a.Menu({editor:f,id:c,title:i.fullscreen});k.clickEvent=function(b){var c=f.$editorContainer;c.addClass("wangEditor-fullscreen"),e=c.css("z-index"),c.css("z-index",h);var g=f.txt.$txt;d=g.height();var i=f.menuContainer;g.height(a.$window.height()-i.height()),f.menuContainer.$menuContainer.attr("style",""),j=!0,f.isFullScreen=!0},k.clickEventSelected=function(a){var b=f.$editorContainer;b.removeClass("wangEditor-fullscreen"),b.css("z-index",e);var c=f.txt.$txt;d&&c.height(d),j=!1,f.isFullScreen=!1},k.updateSelectedEvent=function(a){return j},f.menus[c]=k}})}),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()}}),function(a,b,c){a.FileReader&&a.FormData&&b.plugin(function(){function c(b,c){var d,e=a.atob(b.split(",")[1]),f=new ArrayBuffer(e.length),g=new Uint8Array(f);for(d=0;d<e.length;d++)g[d]=e.charCodeAt(d);return new Blob([f],{type:c})}function d(a,c){var d=document.createElement("img");d.onload=function(){var e='<img src="'+a+'" style="max-width:100%;"/>';f.command(c,"insertHtml",e),b.log("已插入图片,地址 "+a),d=null},d.onerror=function(){b.error("使用返回的结果获取图片,发生错误。请确认以下结果是否正确:"+a),d=null},d.src=a}function e(a){if(a.lengthComputable){var b=a.loaded/a.total;f.showUploadProgress(b)}}var f=this,g=f.config,h=g.uploadImgUrl,i=g.uploadTimeout;h&&(f.xhrUploadImg=function(a){function g(){s&&clearTimeout(s),t&&t.abort&&t.abort(),j.preventDefault(),p&&p.call(f),b.log("上传超时,超时时间 "+i),alert("图片上传超时"),f.hideUploadProgress()}var j=a.event,k=a.base64,l=a.fileType||"image/png",m=a.name||"wangEditor_upload_file",n=a.successFn,o=a.errorFn,p=a.timeoutFn,q=a.failedFn,r="png";if(l.indexOf("/")>0&&l.split("/")[1]&&(r=l.split("/")[1]),b.isOnWebsite)return b.log("预览模拟上传"),void d(k,j);var s,t=new XMLHttpRequest,u=new FormData;t.onload=function(){s&&clearTimeout(s);var a=t.responseText;b.log("上传完成,返回结果为 "+a),0===a.indexOf("error|")?(b.warn("上传失败:"+a.split("|")[1]),q&&q.call(f),alert(a.split("|")[1])):(b.log("上传成功,即将插入编辑区域,结果为:"+a),d(a,j),n&&n.call(f)),f.hideUploadProgress()},t.onerror=function(){s&&clearTimeout(s),j.preventDefault(),b.error("发生错误"),alert("发生错误"),o&&o.call(f),f.hideUploadProgress()},t.upload.onprogress=e,u.append(m,c(k,l),b.random()+"."+r),t.open("POST",h,!0),t.send(u),s=setTimeout(g,i),b.log("开始上传...并开始超时计算")})})}(window,window.wangEditor,window.jQuery),function(a,b,c){b.plugin(function(){function a(){h.hide(),i=null}var b=this,d=b.menuContainer,e=d.height(),f=b.$editorContainer,g=f.width(),h=c('<div class="wangEditor-upload-progress"></div>');h.css({top:e+"px"}),f.append(h),b.showUploadProgress=function(a){i&&clearTimeout(i),h.show(),h.width(a*g)};var i;b.hideUploadProgress=function(b){i&&clearTimeout(i),b=b||750,i=setTimeout(a,b)}})}(window,window.wangEditor,window.jQuery),function(a,b,c){b.plugin(function(){var a,d=this,e=d.config,f=e.uploadImgUrl,g=e.uploadTimeout;if(f){var h=d.$uploadContent;if(h){var i=c('<div class="upload-icon-container"><i class="wangeditor-menu-img-upload"></i></div>');h.append(i);var j=new b.UploadFile({editor:d,uploadUrl:f,timeout:g,fileAccept:"image/*"});i.click(function(b){a=b,j.selectFiles()})}}})}(window,window.wangEditor,window.jQuery),function(a,b,c){if(a.FileReader&&a.FormData){var d=function(a){this.editor=a.editor,this.uploadUrl=a.uploadUrl,this.timeout=a.timeout,this.fileAccept=a.fileAccept,this.multiple=!0};d.fn=d.prototype,d.fn.clear=function(){this.$input.val(""),b.log("input value 已清空")},d.fn.render=function(){var a=this;if(!a._hasRender){b.log("渲染dom");var d=a.fileAccept,e=d?'accept="'+d+'"':"",f=a.multiple,g=f?'multiple="multiple"':"",h=c('<input type="file" '+e+" "+g+"/>"),i=c('<div style="visibility:hidden;"></div>');i.append(h),b.$body.append(i),h.on("change",function(b){a.selected(b,h.get(0))}),a.$input=h,a._hasRender=!0}},d.fn.selectFiles=function(){var a=this;b.log("使用 html5 方式上传"),a.render(),b.log("选择文件"),a.$input.click()},d.fn.selected=function(a,d){var e=this,f=d.files||[];0!==f.length&&(b.log("选中 "+f.length+" 个文件"),c.each(f,function(a,b){e.upload(b)}))},d.fn.upload=function(a){function c(){d.clear()}var d=this,e=d.editor,f=a.name||"",g=a.type||"",h=new FileReader;b.log("开始执行 "+f+" 文件的上传"),h.onload=function(a){b.log("已读取"+f+"文件");var d=a.target.result||this.result;e.xhrUploadImg({event:a,base64:d,fileType:g,name:"wangEditorH5File",successFn:c,errorFn:function(){c(),b.isOnWebsite&&alert("wangEditor官网暂时没有服务端,因此报错。实际项目中不会发生")},timeoutFn:function(){c(),b.isOnWebsite&&alert("wangEditor官网暂时没有服务端,因此超时。实际项目中不会发生")},failedFn:c})},h.readAsDataURL(a)},b.UploadFile=d}}(window,window.wangEditor,window.jQuery),function(a,b,c){if(!a.FileReader||!a.FormData){var d=function(a){this.editor=a.editor,this.uploadUrl=a.uploadUrl,this.timeout=a.timeout,this.fileAccept=a.fileAccept,this.multiple=!1};d.fn=d.prototype,d.fn.clear=function(){this.$input.val(""),b.log("input value 已清空")},d.fn.render=function(){var a=this;if(!a._hasRender){var d=a.uploadUrl;b.log("渲染dom");var e="iframe"+b.random(),f=c('<iframe name="'+e+'" id="'+e+'" frameborder="0" width="0" height="0"></iframe>'),g=a.multiple,h=g?'multiple="multiple"':"",i=c('<input type="file" '+h+' name="wangEditorFormFile"/>'),j=c('<form enctype="multipart/form-data" method="post" action="'+d+'" target="'+e+'"></form>'),k=c('<div style="visibility:hidden;"></div>');j.append(i).append(c('<input type="submit" value="form-img-submit"/>')),k.append(j),k.append(f),b.$body.append(k),i.on("change",function(b){a.selected(b,i.get(0))}),a.$input=i,a.$form=j,a.$iframe=f,a._hasRender=!0}},d.fn.selectFiles=function(){var a=this;b.log("使用 form 方式上传"),a.render(),b.log("选择文件"),a.$input.click()},d.fn.selected=function(a,c){function d(){j.onload=null,b.log("上传超时,已终止操作。超时时间为 "+l),f.clear()}var e,f=this,g=f.editor,h=f.$iframe,i=h.get(0),j=i.contentWindow,k=f.$form,l=f.timeout,m=c.value.toLowerCase(),n=m.slice(m.lastIndexOf(".")-m.length);return[".gif",".jpg","jpeg","bmp","png"].indexOf(n)<0?(alert("选择的文件不是图片"),void f.clear()):(i.onload=function(){e&&clearTimeout(e);var a,c=j.document.body.innerHTML;b.log("上传结束,返回结果为 "+c),0===c.indexOf("error|")?(b.log("上传失败:"+c.split("|")[1]),alert(c.split("|")[1])):(b.log("上传成功,开始下载"),a=document.createElement("img"),a.onload=function(){var b='<img src="'+c+'" style="max-width:100%"/>';g.command(event,"insertHtml",b),a=null},a.onerror=function(){b.error("使用返回的结果获取图片,发生错误。请确认以下结果是否正确:"+c),a=null},a.src=c),f.clear()},b.log("提交form,并开始超时计算,等待返回结果..."),k.submit(),e=setTimeout(d,l),!1)},b.UploadFile=d}}(window,window.wangEditor,window.jQuery),function(a,b,c){b.plugin(function(){function d(){var a=/^data:(image\/\w+);base64/,d=i.find("img");b.log("粘贴后,检查到编辑器有"+d.length+"个图片。开始遍历图片,试图找到刚刚粘贴过来的图片"),c.each(d,function(){var d,h,i=this,j=c(i),k=j.attr("src");f.each(function(){return i===this?(d=!0,!1):void 0}),d||(b.log("找到一个粘贴过来的图片"),a.test(k)?(b.log("src 是 base64 格式,可以上传"),h=k.match(a)[1],g.xhrUploadImg({event:e,base64:k,
|
|
|
fileType:h,name:"wangEditorPasteFile"})):b.log("src 为 "+k+" ,不是 base64 格式,暂时不支持上传"),j.remove())}),b.log("遍历结束")}var e,f,g=this,h=g.txt,i=h.$txt,j=g.config,k=j.uploadImgUrl;k&&i.on("paste",function(h){e=h;var j,k,l=e.clipboardData||e.originalEvent.clipboardData;j=null==l?a.clipboardData&&a.clipboardData.getData("text"):l.getData("text"),j||(k=l&&l.items,k?(b.log("通过 data.items 得到了数据"),c.each(k,function(a,c){var d=c.type||"";if(!(d.indexOf("image")<0)){var f=c.getAsFile(),h=new FileReader;b.log("得到一个粘贴图片"),h.onload=function(a){b.log("读取到粘贴的图片");var c=a.target.result||this.result;g.xhrUploadImg({event:e,base64:c,fileType:d,name:"wangEditorPasteFile"})},h.readAsDataURL(f)}})):(b.log("未从 data.items 得到数据,使用检测粘贴图片的方式"),f=i.find("img"),b.log("粘贴前,检查到编辑器有"+f.length+"个图片"),setTimeout(d,0)))})})}(window,window.wangEditor,window.jQuery),function(a,b,c){b.plugin(function(){var a=this,d=a.txt,e=d.$txt,f=a.config,g=f.uploadImgUrl;g&&(b.$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&&c.each(f,function(c,e){var f=e.type,g=e.name;if(!(f.indexOf("image/")<0)){b.log("得到图片 "+g);var h=new FileReader;h.onload=function(c){b.log("读取到图片 "+g);var e=c.target.result||this.result;a.xhrUploadImg({event:d,base64:e,fileType:f,name:"wangEditorDragFile"})},h.readAsDataURL(e)}})}))})}(window,window.wangEditor,window.jQuery),function(a,b,c){b.plugin(function(){function a(){k||(d(),l.append(m).append(n).append(o).append(p),h.$editorContainer.append(l),k=!0)}function d(){function a(a,c){b&&h.customCommand(a,b,c)}var b;n.click(function(c){b=function(){g.remove()},a(c,function(){setTimeout(f,100)})}),p.click(function(c){b=function(){g.css({width:"100%"})},a(c,function(){setTimeout(e)})}),o.click(function(c){b=function(){g.css({width:"auto"})},a(c,function(){setTimeout(e)})})}function e(){if(null!=g){g.addClass("clicked");var a=g.position(),b=a.top,c=a.left,d=g.outerHeight(),e=g.outerWidth(),f=b+d,h=c,i=0,k=j.position().top,m=j.outerHeight();f>k+m&&(f=k+m),l.show();var n=l.outerWidth();i=e/2-n/2,l.css({top:f+5,left:h,"margin-left":i})}}function f(){null!=g&&(g.removeClass("clicked"),g=null,l.hide())}var g,h=this,i=h.txt,j=i.$txt,k=!1,l=c('<div class="txt-toolbar"></div>'),m=c('<div class="tip-triangle"></div>'),n=c('<a href="#"><i class="wangeditor-menu-img-trash-o"></i></a>'),o=c('<a href="#"><i class="wangeditor-menu-img-search-minus"></i></a>'),p=c('<a href="#"><i class="wangeditor-menu-img-search-plus"></i></a>');j.on("click","table",function(b){var d=c(b.currentTarget);return a(),g&&g.get(0)===d.get(0)?void setTimeout(f,100):(g=d,e(),b.preventDefault(),void b.stopPropagation())}).on("click keypress scroll",function(a){setTimeout(f,100)}),b.$body.on("click keypress scroll",function(a){setTimeout(f,100)})})}(window,window.wangEditor,window.jQuery),function(a,b,c){b.userAgent.indexOf("MSIE 8")>0||b.plugin(function(){function a(){m||(d(),e(),o.append(p).append(q).append(r).append(s).append(t).append(u).append(v),j.$editorContainer.append(o).append(n),m=!0)}function d(){function a(a,c){b&&j.customCommand(a,b,c)}var b;q.click(function(c){b=function(){i.remove()},a(c,function(){setTimeout(g,100)})}),s.click(function(c){b=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"})},a(c,function(){setTimeout(f)})}),r.click(function(c){b=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"})},a(c,function(){setTimeout(f)})}),t.click(function(c){b=function(){i.css({"float":"left"})},a(c,function(){setTimeout(g,100)})}),v.click(function(c){b=function(){i.css({"float":"right"})},a(c,function(){setTimeout(g,100)})}),u.click(function(c){b=function(){i.css({"float":"none"})},a(c,function(){setTimeout(g,100)})})}function e(){function a(a){var b,g;b=a.pageX-c,g=a.pageY-d;var k=e+b,l=f+g;n.css({"margin-left":k,"margin-top":l});var m=h+b,o=j+g;i.css({width:m,height:o})}var c,d,e,f,h,j;n.on("mousedown",function(k){i&&(c=k.pageX,d=k.pageY,e=parseFloat(n.css("margin-left"),10),f=parseFloat(n.css("margin-top"),10),h=i.width(),j=i.height(),o.hide(),b.$document.on("mousemove._dragResizeImg",a),b.$document.on("mouseup._dragResizeImg",function(a){b.$document.off("mousemove._dragResizeImg"),b.$document.off("mouseup._dragResizeImg"),g(),n.css({"margin-left":e,"margin-top":f})}))})}function f(){if(null!=i){i.addClass("clicked");var a=i.position(),b=a.top,c=a.left,d=i.outerHeight(),e=i.outerWidth();n.css({top:b+d,left:c+e});var f=b+d,g=c,h=0,k=l.position().top,m=l.outerHeight();f>k+m?f=k+m:n.show(),o.show();var p=o.outerWidth();h=e/2-p/2,o.css({top:f+5,left:g,"margin-left":h}),j.disableMenusExcept()}}function g(){null!=i&&(i.removeClass("clicked"),i=null,o.hide(),n.hide(),j.enableMenusExcept())}function h(a){var b=!1;return c.each(w,function(d,e){var f=!1;return c.each(e.imgs,function(c,d){return a===d?(b=!0,f=!0,!1):void 0}),f?!1:void 0}),b}var i,j=this,k=j.txt,l=k.$txt,m=(j.$editorContainer,!1),n=c('<div class="img-drag-point"></div>'),o=c('<div class="txt-toolbar"></div>'),p=c('<div class="tip-triangle"></div>'),q=c('<a href="#"><i class="wangeditor-menu-img-trash-o"></i></a>'),r=c('<a href="#"><i class="wangeditor-menu-img-search-minus"></i></a>'),s=c('<a href="#"><i class="wangeditor-menu-img-search-plus"></i></a>'),t=c('<a href="#"><i class="wangeditor-menu-img-align-left"></i></a>'),u=c('<a href="#"><i class="wangeditor-menu-img-align-justify"></i></a>'),v=c('<a href="#"><i class="wangeditor-menu-img-align-right"></i></a>'),w=j.config.emotions;l.on("mousedown","img",function(a){a.preventDefault()}).on("click","img",function(b){var d=c(b.currentTarget),e=d.attr("src");if(e&&!h(e)){if(a(),i&&i.get(0)===d.get(0))return void setTimeout(g,100);i=d,f(),b.preventDefault(),b.stopPropagation()}}).on("click keypress scroll",function(a){setTimeout(g,100)})})}(window,window.wangEditor,window.jQuery),function(a,b,c){b.plugin(function(){var d=this,e=d.config.menuFixed;if(e!==!1&&"number"==typeof e){var f=parseFloat(b.$body.css("margin-top"),10);isNaN(f)&&(f=0);var g=d.$editorContainer,h=g.offset().top,i=g.outerHeight(),j=d.menuContainer.$menuContainer,k=j.css("position"),l=j.css("top"),m=j.width(),n=j.outerHeight(),o=j.offset().top;d.txt.$txt;b.$window.scroll(function(){if(!d.isFullScreen){var g=c(a).scrollTop();g>=o&&h+i>g+e+n+30?(j.css({position:"fixed",top:e}),j.width(m),b.$body.css({"margin-top":f+n})):(j.css({position:k,top:l}),j.css("width","100%"),b.$body.css({"margin-top":f}))}})}})}(window,window.wangEditor,window.jQuery),function(a,b){a.createMenu(function(c){var d="indent";if(c(d)){var 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 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?!0:!1):!1},e.menus[d]=f}})}(window.wangEditor,window.jQuery),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('<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}})}(window.wangEditor,window.jQuery),b(function(a,b){a.info("本页面富文本编辑器由 wangEditor 提供 http://wangeditor.github.io/ ")})}); |
|
|
\ No newline at end of file |
...
|
...
|
|