coo.mvc.static.dwz.external.xheditor.xheditor-1.2.1.min.js Maven / Gradle / Ivy
/*! xhEditor v1.2.1 | (c) 2009, 2013 xheditor.com.
Licence: http://xheditor.com/license/lgpl.txt */
(function(){var e={};window.XHEDITOR=e})(),function(e,t){e.mapLang={},e.setLang=function(i,s){s===t&&(s=i,i=""),""!==i&&(i+=".");var a,n;for(var o in s)n=s[o],a=i+o,"string"==typeof n||n instanceof Array?e.mapLang[a]=n:e.setLang(a,n)},e.getLang=function(i){var s=e.mapLang[i];if(s===t&&(s=i.replace(/{#([^{}]+)}/g,function(t,i){var s=e.mapLang[i];return s?s:i})),"string"==typeof s){var a=arguments;s=s.replace(/{\$(\d+)}/g,function(e,i){var s=a[parseInt(i,10)+1];return s!==t?s:e})}return s}}(XHEDITOR),function(XHEDITOR,$,undefined){var agent=navigator.userAgent.toLowerCase(),bMobile=/mobile/i.test(agent),browser=$.browser,browerVer=parseFloat(browser.version),isIE=browser.msie,isMozilla=browser.mozilla,isWebkit=browser.webkit,isOpera=browser.opera,isChrome=browser.chrome,bAir=agent.indexOf(" adobeair/")>-1,xCount=0,bShowPanel=!1,bClickCancel=!0,bShowModal=!1,bCheckEscInit=!1,_jPanel,_jShadow,_jCntLine,_jPanelButton,jModal,jModalShadow,layerShadow,jOverlay,jHideSelect,onModalRemove,editorRoot,getLang=XHEDITOR.getLang;if($("script[src*=xheditor]").each(function(){var e=this.src;return e.match(/xheditor[^\/]*\.js/i)?(editorRoot=e.replace(/[\?#].*$/,"").replace(/(^|[\/\\])[^\/]*$/,"$1"),!1):undefined}),isIE){try{document.execCommand("BackgroundImageCache",!1,!0)}catch(e){}var jqueryVer=$.fn.jquery;jqueryVer&&jqueryVer.match(/^1\.[67]/)&&($.attrHooks.width=$.attrHooks.height=null)}var specialKeys={27:"esc",9:"tab",32:"space",13:"enter",8:"backspace",145:"scroll",20:"capslock",144:"numlock",19:"pause",45:"insert",36:"home",46:"del",35:"end",33:"pageup",34:"pagedown",37:"left",38:"up",39:"right",40:"down",112:"f1",113:"f2",114:"f3",115:"f4",116:"f5",117:"f6",118:"f7",119:"f8",120:"f9",121:"f10",122:"f11",123:"f12"},arrAlign=[{v:"justifyleft"},{v:"justifycenter"},{v:"justifyright"},{v:"justifyfull"}],arrList=[{v:"insertOrderedList"},{v:"insertUnorderedList"}],htmlPastetext='',htmlLink='',htmlAnchor='',htmlImg=' ',htmlFlash=' ',htmlMedia=' ',htmlTable=' ',htmlAbout='',itemEmots={"default":{name:"{#default}",width:24,height:24,line:7,list:["smile","tongue","titter","laugh","sad","wronged","fastcry","cry","wail","mad","knock","curse","crazy","angry","ohmy","awkward","panic","shy","cute","envy","proud","struggle","quiet","shutup","doubt","despise","sleep","bye"]}},arrTools={Cut:{t:"Cut"},Copy:{t:"Copy"},Paste:{t:"Paste"},Pastetext:{t:"Pastetext",h:isIE?0:1},Blocktag:{t:"Blocktag",h:1},Fontface:{t:"Fontface",h:1},FontSize:{t:"FontSize",h:1},Bold:{t:"Bold",s:"Ctrl+B"},Italic:{t:"Italic",s:"Ctrl+I"},Underline:{t:"Underline",s:"Ctrl+U"},Strikethrough:{t:"Strikethrough"},FontColor:{t:"FontColor",h:1},BackColor:{t:"BackColor",h:1},SelectAll:{t:"SelectAll"},Removeformat:{t:"Removeformat"},Align:{t:"Align",h:1},List:{t:"List",h:1},Outdent:{t:"Outdent"},Indent:{t:"Indent"},Link:{t:"Link",s:"Ctrl+L",h:1},Unlink:{t:"Unlink"},Anchor:{t:"Anchor",h:1},Img:{t:"Img",h:1},Flash:{t:"Flash",h:1},Media:{t:"Media",h:1},Hr:{t:"Hr"},Emot:{t:"Emot",s:"ctrl+e",h:1},Table:{t:"Table",h:1},Source:{t:"Source"},Preview:{t:"Preview"},Print:{t:"Print",s:"Ctrl+P"},Fullscreen:{t:"Fullscreen",s:"Esc"},About:{t:"About"}},toolsThemes={mini:"Bold,Italic,Underline,Strikethrough,|,Align,List,|,Link,Img",simple:"Blocktag,Fontface,FontSize,Bold,Italic,Underline,Strikethrough,FontColor,BackColor,|,Align,List,Outdent,Indent,|,Link,Img,Emot",full:"Cut,Copy,Paste,Pastetext,|,Blocktag,Fontface,FontSize,Bold,Italic,Underline,Strikethrough,FontColor,BackColor,SelectAll,Removeformat,|,Align,List,Outdent,Indent,|,Link,Unlink,Anchor,Img,Flash,Media,Hr,Emot,Table,|,Source,Preview,Print,Fullscreen"};toolsThemes.mfull=toolsThemes.full.replace(/\|(,Align)/i,"/$1");var arrDbClick={a:"Link",img:"Img",embed:"Embed"},uploadInputname="filedata",arrEntities={"<":"<",">":">",'"':""","\u00ae":"®","\u00a9":"©"},regEntities=/[<>"\u00ae\u00a9]/g,Xheditor=function(textarea,options){function checkDblClick(e){var t=e.target,i=arrDbClick[t.tagName.toLowerCase()];if(i){if("Embed"===i){var s={"application/x-shockwave-flash":"Flash","application/x-mplayer2":"Media"};i=s[t.type.toLowerCase()]}_this.exec(i)}}function checkEsc(e){return 27===e.which?(bShowModal?_this.removeModal():bShowPanel&&_this.hidePanel(),!1):undefined}function loadReset(){setTimeout(_this.setSource,10)}function saveResult(){_this.getSource()}function cleanPaste(e){var t,i,s;if(e&&(t=e.originalEvent.clipboardData)&&(i=t.items)&&(s=i[0])&&"file"==s.kind&&s.type.match(/^image\//i)){var a=s.getAsFile(),n=new FileReader;return n.onload=function(){var e='';e=replaceRemoteImg(e),_this.pasteHTML(e)},n.readAsDataURL(a),!1}var o=settings.cleanPaste;if(0===o||bSource||bCleanPaste)return!0;bCleanPaste=!0,_this.saveBookmark();var l=isIE?"pre":"div",r=$("<"+l+' class="xhe-paste">\ufeff\ufeff'+l+">",_doc).appendTo(_doc.body),h=r[0],c=_this.getSel(),d=_this.getRng(!0);r.css("top",_jWin.scrollTop()),isIE?(d.moveToElementText(h),d.select()):(d.selectNodeContents(h),c.removeAllRanges(),c.addRange(d)),setTimeout(function(){var e,t=3===o;if(t)r.html(r.html().replace(/
]*)?>/gi,"\n")),e=r.text();else{var i=$(".xhe-paste",_doc.body),s=[];i.each(function(e,t){0==$(t).find(".xhe-paste").length&&s.push(t.innerHTML)}),e=s.join("
")}r.remove(),_this.loadBookmark(),e=e.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g,""),e&&(t?_this.pasteText(e):(e=_this.cleanHTML(e),e=_this.cleanWord(e),e=_this.formatXHTML(e),(!settings.onPaste||settings.onPaste&&(e=settings.onPaste(e))!==!1)&&(e=replaceRemoteImg(e),_this.pasteHTML(e)))),bCleanPaste=!1},0)}function replaceRemoteImg(e){var t=settings.localUrlTest,i=settings.remoteImgSaveUrl;if(t&&i){var s=[],a=0;e=e.replace(/(]*?)?(?:\s+src="\s*([^"]+)\s*")(?: [^>]*)?)(\/?>)/gi,function(e,i,n,o,l){return!/^(https?|data:image)/i.test(o)||/_xhe_temp/.test(n)||t.test(o)||(s[a]=o,n=n.replace(/\s+(width|height)="[^"]*"/gi,"").replace(/\s+src="[^"]*"/gi,' src="'+skinPath+'img/waiting.gif" remoteimg="'+a++ +'"')),i+n+l}),s.length>0&&$.post(i,{urls:s.join("|")},function(e){e=e.split("|"),$("img[remoteimg]",_this.doc).each(function(){var t=$(this);xheAttr(t,"src",e[t.attr("remoteimg")]),t.removeAttr("remoteimg")})})}return e}function setCSS(e){try{_this._exec("styleWithCSS",e,!0)}catch(t){try{_this._exec("useCSS",!e,!0)}catch(t){}}}function setOpts(){if(bInit&&!bSource){setCSS(!1);try{_this._exec("enableObjectResizing",!0,!0)}catch(e){}if(isIE)try{_this._exec("BackgroundImageCache",!0,!0)}catch(e){}}}function forcePtag(e){if(bSource||13!==e.which||e.shiftKey||e.ctrlKey||e.altKey)return!0;var t=_this.getParent("p,h1,h2,h3,h4,h5,h6,pre,address,div,li");return t.is("li")?!0:settings.forcePtag?(0===t.length&&_this._exec("formatblock",""),undefined):(_this.pasteHTML("
"),isIE&&t.length>0&&2===_this.getRng().parentElement().childNodes.length&&_this.pasteHTML("
"),!1)}function fixFullHeight(){isMozilla||isWebkit||(bFullscreen&&_jArea.height("100%").css("height",_jArea.outerHeight()-_jTools.outerHeight()),isIE&&_jTools.hide().show())}function fixAppleSel(e){if(e=e.target,e.tagName.match(/(img|embed)/i)){var t=_this.getSel(),i=_this.getRng(!0);i.selectNode(e),t.removeAllRanges(),t.addRange(i)}}function xheAttr(e,t,i){if(!t)return!1;var s="_xhe_"+t;return i&&(urlType&&(i=getLocalUrl(i,urlType,urlBase)),e.attr(t,urlBase?getLocalUrl(i,"abs",urlBase):i).removeAttr(s).attr(s,i)),e.attr(s)||e.attr(t)}function clickCancelPanel(){bClickCancel&&_this.hidePanel()}function checkShortcuts(e){if(bSource)return!0;var t=e.which,i=specialKeys[t],s=i?i:String.fromCharCode(t).toLowerCase();sKey="",sKey+=e.ctrlKey?"ctrl+":"",sKey+=e.altKey?"alt+":"",sKey+=e.shiftKey?"shift+":"",sKey+=s;var a,n=arrShortCuts[sKey];for(a in n){if(a=n[a],!$.isFunction(a))return _this.exec(a),!1;if(a.call(_this)===!1)return!1}}function is(e,t){var i=typeof e;return t?"array"===t&&e.hasOwnProperty&&e instanceof Array?!0:i===t:"undefined"!=i}function getLocalUrl(e,t,i){if(e.match(/^(\w+):\/\//i)&&!e.match(/^https?:/i)||/^#/i.test(e)||/^data:/i.test(e))return e;var s=i?$('')[0]:location,a=s.protocol,n=s.host,o=s.hostname,l=s.port,r=s.pathname.replace(/\\/g,"/").replace(/[^\/]+$/i,"");if(""===l&&(l="80"),""===r?r="/":"/"!==r.charAt(0)&&(r="/"+r),e=$.trim(e),"abs"!==t&&(e=e.replace(RegExp(a+"\\/\\/"+o.replace(/\./g,"\\.")+"(?::"+l+")"+("80"===l?"?":"")+"(/|$)","i"),"/")),"rel"===t&&(e=e.replace(RegExp("^"+r.replace(/([\/\.\+\[\]\(\)])/g,"\\$1"),"i"),"")),"rel"!==t&&(e.match(/^(https?:\/\/|\/)/i)||(e=r+e),"/"===e.charAt(0))){var h,c,d=[],u=e.split("/"),p=u.length;for(c=0;p>c;c++)h=u[c],".."===h?d.pop():""!==h&&"."!==h&&d.push(h);""===u[p-1]&&d.push(""),e="/"+d.join("/")}return"abs"!==t||e.match(/^https?:\/\//i)||(e=a+"//"+n+e),e=e.replace(/(https?:\/\/[^:\/?#]+):80(\/|$)/i,"$1$2")}function checkFileExt(e,t){return"*"===t||e.match(RegExp(".("+t.replace(/,/g,"|")+")$","i"))?!0:(alert(getLang("upload.extLimit",t)),!1)}function formatBytes(e){var t=["Byte","KB","MB","GB","TB","PB"],i=Math.floor(Math.log(e)/Math.log(1024));return(e/Math.pow(1024,Math.floor(i))).toFixed(2)+t[i]}function returnFalse(){return!1}var _this=this,_text=textarea,_jText=$(_text),_jForm=_jText.closest("form"),_jTools,_jArea,_win,_jWin,_doc,_jDoc,bookmark,bInit=!1,bSource=!1,bFullscreen=!1,bCleanPaste=!1,outerScroll,bShowBlocktag=!1,sLayoutStyle="",ev=null,timer,bDisableHoverExec=!1,bQuickHoverExec=!1,lastPoint=null,lastAngle=null,editorHeight=0,settings=_this.settings=$.extend({},XHEDITOR.settings,options),plugins=settings.plugins,strPlugins=[];if(plugins&&(arrTools=$.extend({},arrTools,plugins),$.each(plugins,function(e){strPlugins.push(e)}),strPlugins=strPlugins.join(",")),settings.tools.match(/^\s*(m?full|simple|mini)\s*$/i)){var toolsTheme=toolsThemes[$.trim(settings.tools)];settings.tools=settings.tools.match(/m?full/i)&&plugins?toolsTheme.replace("Table","Table,"+strPlugins):toolsTheme}settings.tools.match(/(^|,)\s*About\s*(,|$)/i)||(settings.tools+=",About"),settings.tools=settings.tools.split(","),settings.editorRoot&&(editorRoot=settings.editorRoot),bAir===!1&&(editorRoot=getLocalUrl(editorRoot,"abs")),settings.urlBase&&(settings.urlBase=getLocalUrl(settings.urlBase,"abs"));var idCSS="xheCSS_"+settings.skin,idContainer="xhe"+xCount+"_container",idTools="xhe"+xCount+"_Tool",idIframeArea="xhe"+xCount+"_iframearea",idIframe="xhe"+xCount+"_iframe",idFixFFCursor="xhe"+xCount+"_fixffcursor",headHTML="",bodyClass="",skinPath=editorRoot+"xheditor_skin/"+settings.skin+"/",arrEmots=itemEmots,urlType=settings.urlType,urlBase=settings.urlBase,emotPath=settings.emotPath,emotPath=emotPath?emotPath:editorRoot+"xheditor_emot/",selEmotGroup="";arrEmots=$.extend({},arrEmots,settings.emots),emotPath=getLocalUrl(emotPath,"rel",urlBase?urlBase:null),bShowBlocktag=settings.showBlocktag,bShowBlocktag&&(bodyClass+=" showBlocktag");var arrShortCuts=[];this.init=function(){function e(e){var t,i=$(e.target);(t=i.css("width"))&&i.css("width","").attr("width",t.replace(/[^0-9%]+/g,"")),(t=i.css("height"))&&i.css("height","").attr("height",t.replace(/[^0-9%]+/g,""))}0===$("#"+idCSS).length&&$("head").append('');var t=_jText.outerWidth(),i=_jText.outerHeight(),s=settings.width||_text.style.width||(t>10?t:0);editorHeight=settings.height||_text.style.height||(i>10?i:150),/^\d+(?:\.\d+)?$/.test(s)&&(s+="px"),is(editorHeight,"string")&&(editorHeight=editorHeight.replace(/[^\d]+/g,""));var a,n,o=settings.background||_text.style.background,l=[''],r=/\||\//i;$.each(settings.tools,function(e,t){if(t.match(r)&&l.push(''),"|"===t)l.push('');else if("/"===t)l.push("
");else{if(a=arrTools[t],!a)return;n=a.c?a.c:"xheIcon xheBtn"+t,l.push(''+a.t+""),a.s&&_this.addShortcuts(a.s,t)}t.match(r)&&l.push('')}),l.push('
'),_jText.after($(' ')),_jTools=$("#"+idTools),_jArea=$("#"+idIframeArea),headHTML='';var h=settings.loadCSS;if(h)if(is(h,"array"))for(var c in h)headHTML+='';else headHTML+=h.match(/\s*"),d+='