//>>built
define("dojox/editor/plugins/AutoUrlLink","dojo dijit dojox dijit/_editor/_Plugin dijit/form/Button dojo/_base/declare dojo/string".split(" "),function(e,l,u,r){var q=e.declare("dojox.editor.plugins.AutoUrlLink",[r],{_template:"\x3ca _djrealurl\x3d'${url}' href\x3d'${url}'\x3e${url}\x3c/a\x3e",setEditor:function(a){this.editor=a;e.isIE||(e.some(a._plugins,function(d){return d.isInstanceOf(l._editor.plugins.EnterKeyHandling)?(this.blockNodeForEnter=d.blockNodeForEnter,!0):!1},this),this.connect(a,
"onKeyPress","_keyPress"),this.connect(a,"onClick","_recognize"),this.connect(a,"onBlur","_recognize"))},_keyPress:function(a){var d=e.keys,c=a.keyCode,b=a.charCode;b==d.SPACE||a.ctrlKey&&(118==b||86==b)?setTimeout(e.hitch(this,"_recognize"),0):c==d.ENTER?setTimeout(e.hitch(this,function(){this._recognize({enter:!0})}),0):this._saved=this.editor.window.getSelection().anchorNode},_recognize:function(a){var d=this._template,c=a?a.enter:!1;a=this.editor;var b=a.window.getSelection();if(b){c=c?this._findLastEditingNode(b.anchorNode):
this._saved||b.anchorNode;var g=this._saved=b.anchorNode,h=b.anchorOffset;if(3==c.nodeType&&!this._inLink(c)){var f=!1,n=this._findUrls(c,g,h),k=a.document.createRange(),m,p=0,t=g==c;for(m=n.shift();m;)k.setStart(c,m.start),k.setEnd(c,m.end),b.removeAllRanges(),b.addRange(k),a.execCommand("insertHTML",e.string.substitute(d,{url:k.toString()})),p+=m.end,m=n.shift(),f=!0;if(!(t&&0>=(h-=p))&&f)try{k.setStart(g,0),k.setEnd(g,h),b.removeAllRanges(),b.addRange(k),a._sCall("collapse",[])}catch(v){}}}},_inLink:function(a){var d=
this.editor.editNode,c=!1;for(a=a.parentNode;a&&a!==d;){var b=a.tagName?a.tagName.toLowerCase():"";if("a"==b){c=!0;break}a=a.parentNode}return c},_findLastEditingNode:function(a){var d=l.range.BlockTagNames,c=this.editor.editNode,b;if(!a)return a;if("BR"!=this.blockNodeForEnter||(b=l.range.getBlockAncestor(a,null,c).blockNode)&&"LI"==b.tagName.toUpperCase()){for(a=(b||(b=l.range.getBlockAncestor(a,null,c).blockNode))&&"LI"==b.tagName.toUpperCase()?b:l.range.getBlockAncestor(a,null,c).blockNode;(a=
a.previousSibling)&&(!a.tagName||!a.tagName.match(d)););if(a)for(a=a.lastChild;a&&(3!=a.nodeType||""==e.trim(a.nodeValue));)a=1==a.nodeType?a.lastChild:a.previousSibling}else for(;(a=a.previousSibling)&&3!=a.nodeType;);return a},_findUrls:function(a,d,c){var b=/(http|https|ftp):\/\/[^\s]+/ig,g=[],h=0,f=a.nodeValue,n;for(a===d&&c<f.length&&(f=f.substr(0,c));null!=(a=b.exec(f));)if(0==a.index||" "==(n=f.charAt(a.index-1))||"\u00a0"==n)g.push({start:a.index-h,end:a.index+a[0].length-h}),h=a.index+a[0].length;
return g}});e.subscribe(l._scopeName+".Editor.getPlugin",null,function(a){a.plugin||"autourllink"!==a.args.name.toLowerCase()||(a.plugin=new q)});return q});