Seditio Source
Root |
./othercms/b2evolution_7.2.3/rsc/ext/tiny_mce/plugins/autocomplete/plugin.min.js
!function(){function e(e){return null==e.options&&"boolean"!=typeof e?e.split(","):e.options}var t={},n=40,i=38,o=27,l=13,a=[32,59,186,188,190];tinymce.create("tinymce.plugins.AutoCompletePlugin",{setOptions:function(n){t.options=e(n)},getOptions:function(){return t.options},init:function(r,c){function s(e){if(!t.visible&&e.keyCode!=o&&e.keyCode!=l||e.keyCode!=n&&e.keyCode!=i&&e.keyCode!=l&&e.keyCode!=o){var a=_(r);a=a.replace(t.trigger,"");var c=Q(a);a.length>0&&u(a),(0==a.length||0==c.length)&&y()}}function u(e){var n=e.replace(t.trigger,"");if(e.length>=t.minLength&&(e.length<t.minLengthAjax||!t.optionsUrl))matches=Q(n),matches.length>0&&(f(matches,n,r),v());else{if(n.length<=1)return!1;var i=t.options;jQuery.ajax({type:"GET",dataType:"JSON",url:t.optionsUrl,cache:!1,data:"q="+n,success:function(e){if(e&&"undefined"!=typeof e.users){var o=[];for(var l in e.users)o.push(e.users[l].login);t.options=o,matches=Q(n),matches.length>0&&(f(matches,n,r),v()),t.options=i}}}),t.options=i}}function g(e){return e.keyCode==l&&t.cancelEnter?(t.cancelEnter=!1,tinymce.dom.Event.cancel(e)):void 0}function d(e){if(t.visible){if(e.keyCode==n)return v(),tinymce.dom.Event.cancel(e);if(e.keyCode==i)return C(),tinymce.dom.Event.cancel(e);if(e.keyCode==l)return k(r,_(r)),t.cancelEnter=!0,!1;if(e.keyCode==o)return y(),tinymce.dom.Event.cancel(e);if(t.onMatch&&a.indexOf(e.keyCode)){var c=_(r),s=Q(c),u=new RegExp("^"+s[0]+"$","i");1==s.length&&c.match(u)&&b.onMatch.dispatch(r,s[0])}}}function m(e){y()}function f(e,n,i){var o="",l=new RegExp("("+n+")");for(var a in e)null!=e[a].key?o+="<li data-value='"+e[a].key+"'><a>"+e[a].key.replace(l,"<mark>$1</mark>")+" "+e[a].description+"</a></li>":"string"==typeof e[a]&&(o+="<li data-value='"+e[a]+"'><a>"+e[a].replace(l,"<mark>$1</mark>")+"</a></li>");jQuery(t.list).html(o);var r=jQuery(i.getContainer()).find("iframe").offset(),c=0,s=0;i.selection.getRng().getClientRects().length>0?(c=i.selection.getRng().getClientRects()[0].top+i.selection.getRng().getClientRects()[0].height,s=i.selection.getRng().getClientRects()[0].left):(c=1.3*parseInt(jQuery(i.selection.getNode()).css("font-size"))+nodePosition.top,s=nodePosition.left),jQuery(t.list).css("position","absolute"),jQuery(t.list).css("top",r.top+c),jQuery(t.list).css("left",r.left+s),jQuery(t.list).css("display","block"),t.visible=!0,p(i)}function p(e){jQuery(t.list).find("li").hover(function(){jQuery(t.list).find("[data-selected=true]").attr("data-selected","false").removeClass("active"),jQuery(this).attr("data-selected","true").addClass("active")}),jQuery(t.list).find("li").click(function(){k(e,_(e))})}function h(){var e=document.createElement("ul");return jQuery(e).addClass("dropdown-menu textcomplete-dropdown"),document.body.appendChild(e),e}function y(){jQuery(t.list).css("display","none"),t.visible=!1}function v(){var e=jQuery(t.list).find("[data-selected=true]");0==e.size()||0==e.next().size()?jQuery(t.list).find("li:first-child").attr("data-selected","true").addClass("active"):e.next().attr("data-selected","true").addClass("active"),e.attr("data-selected","false").removeClass("active")}function C(){var e=jQuery(t.list).find("[data-selected=true]");0==e.size()||0==e.prev().size()?jQuery(t.list).find("li:last-child").attr("data-selected","true").addClass("active"):e.prev().attr("data-selected","true").addClass("active"),e.attr("data-selected","false").removeClass("active")}function k(e,n){var i=jQuery(t.list).find("[data-selected=true]").attr("data-value");null==i&&(i=jQuery(t.list).find("li:first-child").attr("data-value"));var o=x(e.selection.getSel().anchorNode,""),l=e.selection.getSel().anchorNode.textContent,a=e.selection.getRng();a.setStart(a.startContainer,a.startOffset-n.length),e.selection.setRng(a);var r="";if(t.delimiter.length>0&&(r=String.fromCharCode(t.delimiter[0])),e.selection.setContent(t.trigger+i.toString()+r),t.enclosing.length>0&&!j(o,l)){var c=e.selection.getBookmark();e.selection.setContent(r+t.trigger+t.enclosing),e.selection.moveToBookmark(c)}y(),t.onSelect&&b.onSelect.dispatch(e,i),y()}function j(e,n){var i=t.trigger+t.enclosing;e=e.substr(n.length);var o=new RegExp(t.trigger+".{"+t.enclosing.length+"}","g").exec(e);return null!=o&&o.length>0&&o[0]==i?!0:!1}function x(e,t){return t+=e.textContent,null!=e.nextSibling?x(e.nextSibling,t):t}function Q(e){var n=t.options,i=[];for(var o in n)null!=n[o].key||0!=e.length&&!S(e,n[o])?null==n[o].key||0!=e.length&&!S(e,n[o].key)||i.push(n[o]):i.push(n[o]);return i}function S(e,t){var n=new RegExp("^"+e,"i");return"string"==typeof t?t.match(n):""}function _(e){var n=null==e.selection.getSel().focusNode?"":e.selection.getSel().focusNode.nodeValue,i=e.selection.getSel().focusOffset;if(null==n||0==n.length)return"";for(var o=0,l=0;i>l;l++)-1!=t.delimiter.indexOf(n.charCodeAt(l).toString())&&(o=l+1);var a=n.substr(o,i-o),r="";return""==t.trigger?a.length>=t.minLength&&(r=a):a.length>t.minLength&&a.charAt(0).toString()==t.trigger&&(r=a),r}t={list:h(),visible:!1,cancelEnter:!1,delimiter:r.getParam("autocomplete_delimiters","160,32").split(","),options:e(r.getParam("autocomplete_options","")),optionsUrl:e(r.getParam("autocomplete_options_url",!1)),trigger:r.getParam("autocomplete_trigger","@"),enclosing:r.getParam("autocomplete_end_option",""),minLength:r.getParam("autocomplete_min_length","1"),minLengthAjax:r.getParam("autocomplete_min_length_ajax","4"),onSelect:r.getParam("autocomplete_on_select",!1),onMatch:r.getParam("autocomplete_on_match",!1)};var b=this;t.onSelect&&(b.onSelect=new tinymce.util.Dispatcher(b),b.onSelect.add(function(e,t){e.execCallback("autocomplete_on_select",e,t)})),t.onMatch&&(b.onMatch=new tinymce.util.Dispatcher(b),b.onMatch.add(function(e,t){e.execCallback("autocomplete_on_match",e,t)})),r.on("keyup",s),r.on("keydown",d),r.on("keypress",g),r.on("click",m)},getInfo:function(){return{longname:"AutoComplete",author:"Mijura Pty Ltd",authorurl:"http://mijura.com",infourl:"http://blog.mijura.com",version:tinymce.majorVersion+"."+tinymce.minorVersion}}}),tinymce.PluginManager.add("autocomplete",tinymce.plugins.AutoCompletePlugin)}();