OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openproject/frontend/vendor/at.js/jquery.atwho.min.js

1 line
19 KiB

!function(a,b){"function"==typeof define&&define.amd?define(["jquery"],function(a){return b(a)}):"object"==typeof exports?module.exports=b(require("jquery")):b(jQuery)}(this,function(a){var b,c,d,e,f,g,h,i,j,k,l=[].slice,m=function(a,b){function c(){this.constructor=a}for(var d in b)n.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},n={}.hasOwnProperty;b=a,d=function(){function a(a){this.currentFlag=null,this.controllers={},this.aliasMaps={},this.$inputor=b(a),this.setupRootElement(),this.listen()}return a.prototype.createContainer=function(a){var c;return null!=(c=this.$el)&&c.remove(),b(a.body).append(this.$el=b("<div class='atwho-container'></div>"))},a.prototype.setupRootElement=function(a,c){var d;if(null==c&&(c=!1),a)this.window=a.contentWindow,this.document=a.contentDocument||this.window.document,this.iframe=a;else{this.document=this.$inputor[0].ownerDocument,this.window=this.document.defaultView||this.document.parentWindow;try{this.iframe=this.window.frameElement}catch(e){if(d=e,this.iframe=null,b.fn.atwho.debug)throw new Error("iframe auto-discovery is failed.\nPlease use `setIframe` to set the target iframe manually.\n"+d)}}return this.createContainer((this.iframeAsRoot=c)?this.document:document)},a.prototype.controller=function(a){var b,c,d,e;if(this.aliasMaps[a])c=this.controllers[this.aliasMaps[a]];else{e=this.controllers;for(d in e)if(b=e[d],d===a){c=b;break}}return c?c:this.controllers[this.currentFlag]},a.prototype.setContextFor=function(a){return this.currentFlag=a,this},a.prototype.reg=function(a,b){var c,d;return d=(c=this.controllers)[a]||(c[a]=this.$inputor.is("[contentEditable]")?new g(this,a):new j(this,a)),b.alias&&(this.aliasMaps[b.alias]=a),d.init(b),this},a.prototype.listen=function(){return this.$inputor.on("compositionstart",function(a){return function(b){var c;return null!=(c=a.controller())&&c.view.hide(),a.isComposing=!0,null}}(this)).on("compositionend",function(a){return function(b){return a.isComposing=!1,null}}(this)).on("keyup.atwhoInner",function(a){return function(b){return a.onKeyup(b)}}(this)).on("keydown.atwhoInner",function(a){return function(b){return a.onKeydown(b)}}(this)).on("blur.atwhoInner",function(a){return function(b){var c;return(c=a.controller())?(c.expectedQueryCBId=null,c.view.hide(b,c.getOpt("displayTimeout"))):void 0}}(this)).on("click.atwhoInner",function(a){return function(b){return a.dispatch(b)}}(this)).on("scroll.atwhoInner",function(a){return function(){var b;return b=a.$inputor.scrollTop(),function(c){var d,e;return d=c.target.scrollTop,b!==d&&null!=(e=a.controller())&&e.view.hide(c),b=d,!0}}}(this)())},a.prototype.shutdown=function(){var a,b,c;c=this.controllers;for(a in c)b=c[a],b.destroy(),delete this.controllers[a];return this.$inputor.off(".atwhoInner"),this.$el.remove()},a.prototype.dispatch=function(a){var b,c,d,e;d=this.controllers,e=[];for(b in d)c=d[b],e.push(c.lookUp(a));return e},a.prototype.onKeyup=function(a){var c;switch(a.keyCode){case h.ESC:a.preventDefault(),null!=(c=this.controller())&&c.view.hide();break;case h.DOWN:case h.UP:case h.CTRL:case h.ENTER:b.noop();break;case h.P:case h.N:a.ctrlKey||this.dispatch(a);break;default:this.dispatch(a)}},a.prototype.onKeydown=function(a){var c,d;if(d=null!=(c=this.controller())?c.view:void 0,d&&d.visible())switch(a.keyCode){case h.ESC:a.preventDefault(),d.hide(a);break;case h.UP:a.preventDefault(),d.prev();break;case h.DOWN:a.preventDefault(),d.next();break;case h.P:if(!a.ctrlKey)return;a.preventDefault(),d.prev();break;case h.N:if(!a.ctrlKey)return;a.preventDefault(),d.next();break;case h.TAB:case h.ENTER:case h.SPACE:if(!d.visible())return;if(!this.controller().getOpt("spaceSelectsMatch")&&a.keyCode===h.SPACE)return;if(!this.controller().getOpt("tabSelectsMatch")&&a.keyCode===h.TAB)return;d.highlighted()?(a.preventDefault(),d.choose(a)):d.hide(a);break;default:b.noop()}},a}(),e=function(){function a(a,c){this.app=a,this.at=c,this.$inputor=this.app.$inputor,this.id=this.$inputor[0].id||this.uid(),this.expectedQueryCBId=null,this.setting=null,this.q