/* jce - 2.6.6 | 2017-01-02 | http://www.joomlacontenteditor.net | Copyright (C) 2006 - 2017 Ryan Demmer. All rights reserved | GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html */
!function(){tinymce.create("tinymce.plugins.AutolinkPlugin",{init:function(ed,url){var t=this;(ed.getParam("autolink_url",!0)||ed.getParam("autolink_email",!0))&&(ed.onKeyDown.addToTop(function(ed,e){if(13==e.keyCode)return t.handleEnter(ed)}),tinyMCE.isIE||(ed.onKeyPress.add(function(ed,e){if(41==e.which)return t.handleEclipse(ed)}),ed.onKeyUp.add(function(ed,e){if(32==e.keyCode)return t.handleSpacebar(ed)})))},handleEclipse:function(ed){this.parseCurrentLine(ed,-1,"(",!0)},handleSpacebar:function(ed){this.parseCurrentLine(ed,0,"",!0)},handleEnter:function(ed){this.parseCurrentLine(ed,-1,"",!1)},parseCurrentLine:function(ed,end_offset,delimiter,goback){var r,end,start,endContainer,bookmark,text,matches,prev,len;if(r=ed.selection.getRng(!0).cloneRange(),r.startOffset<5){if(prev=r.endContainer.previousSibling,null==prev){if(null==r.endContainer.firstChild||null==r.endContainer.firstChild.nextSibling)return;prev=r.endContainer.firstChild.nextSibling}if(len=prev.length,r.setStart(prev,len),r.setEnd(prev,len),r.endOffset<5)return;end=r.endOffset,endContainer=prev}else{if(endContainer=r.endContainer,3!=endContainer.nodeType&&endContainer.firstChild){for(;3!=endContainer.nodeType&&endContainer.firstChild;)endContainer=endContainer.firstChild;3==endContainer.nodeType&&(r.setStart(endContainer,0),r.setEnd(endContainer,endContainer.nodeValue.length))}end=1==r.endOffset?2:r.endOffset-1-end_offset}start=end;do r.setStart(endContainer,end>=2?end-2:0),r.setEnd(endContainer,end>=1?end-1:0),end-=1;while(" "!=r.toString()&&""!=r.toString()&&160!=r.toString().charCodeAt(0)&&end-2>=0&&r.toString()!=delimiter);r.toString()==delimiter||160==r.toString().charCodeAt(0)?(r.setStart(endContainer,end),r.setEnd(endContainer,start),end+=1):0==r.startOffset?(r.setStart(endContainer,0),r.setEnd(endContainer,start)):(r.setStart(endContainer,end),r.setEnd(endContainer,start));var text=r.toString();if("."==text.charAt(text.length-1)&&r.setEnd(endContainer,start-1),text=r.toString(),matches=text.match(/^(https?:\/\/|ssh:\/\/|ftp:\/\/|file:\/|www\.|(?:mailto:)?[A-Z0-9._%+-]+@)(.+)$/i)){if("www."==matches[1]){if(matches[1]="http://www.",!ed.getParam("autolink_url",!0))return}else if(/@$/.test(matches[1])&&!/^mailto:/.test(matches[1])){if(matches[1]="mailto:"+matches[1],!ed.getParam("autolink_email",!0))return}else if(!ed.getParam("autolink_url",!0))return;if(bookmark=ed.selection.getBookmark(),ed.selection.setRng(r),tinyMCE.execCommand("createlink",!1,matches[1]+matches[2]),ed.selection.moveToBookmark(bookmark),ed.nodeChanged(),tinyMCE.isWebKit){ed.selection.collapse(!1);var max=Math.min(endContainer.length,start+1);r.setStart(endContainer,max),r.setEnd(endContainer,max),ed.selection.setRng(r)}}},getInfo:function(){return{longname:"Autolink",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/autolink",version:tinymce.majorVersion+"."+tinymce.minorVersion}}}),tinymce.PluginManager.add("autolink",tinymce.plugins.AutolinkPlugin)}();