@gitlab/at.js 1.5.6 → 1.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/css/jquery.atwho.min.css +1 -1
- package/dist/js/jquery.atwho.js +389 -275
- package/dist/js/jquery.atwho.min.js +1 -1
- package/package.json +15 -17
- package/CHANGELOG.md +0 -314
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"function"==typeof define&&define.amd?define(["jquery"],function(t){return e(t)}):"object"==typeof exports?module.exports=e(require("jquery")):e(jQuery)}(this,function(t){var e,i;i={ESC:27,TAB:9,ENTER:13,CTRL:17,A:65,P:80,N:78,LEFT:37,UP:38,RIGHT:39,DOWN:40,BACKSPACE:8,SPACE:32},e={beforeSave:function(t){return r.arrayToDefaultHash(t)},matcher:function(t,e,i,n){var r,o,s,a,h;return t=t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),i&&(t="(?:^|\\s)"+t),r=decodeURI("%C3%80"),o=decodeURI("%C3%BF"),h=n?" ":"",a=new RegExp(t+"([A-Za-z"+r+"-"+o+"0-9_"+h+"'.+-]*)$|"+t+"([^\\x00-\\xff]*)$","gi"),s=a.exec(e),s?s[2]||s[1]:null},filter:function(t,e,i){var n,r,o,s;for(n=[],r=0,s=e.length;r<s;r++)o=e[r],~new String(o[i]).toLowerCase().indexOf(t.toLowerCase())&&n.push(o);return n},remoteFilter:null,sorter:function(t,e,i){var n,r,o,s;if(!t)return e;for(n=[],r=0,s=e.length;r<s;r++)o=e[r],o.atwho_order=new String(o[i]).toLowerCase().indexOf(t.toLowerCase()),o.atwho_order>-1&&n.push(o);return n.sort(function(t,e){return t.atwho_order-e.atwho_order})},tplEval:function(t,e){var i,n;n=t;try{return"string"!=typeof t&&(n=t(e)),n.replace(/\$\{([^\}]*)\}/g,function(t,i,n){return e[i]})}catch(r){return i=r,""}},highlighter:function(t,e){var i;return e?(i=new RegExp(">\\s*([^<]*?)("+e.replace("+","\\+")+")([^<]*)\\s*<","ig"),t.replace(i,function(t,e,i,n){return"> "+e+"<strong>"+i+"</strong>"+n+" <"})):t},beforeInsert:function(t,e,i){return t},beforeReposition:function(t){return t},afterMatchFailed:function(t,e){}};var n;n=function(){function e(e){this.currentFlag=null,this.controllers={},this.aliasMaps={},this.$inputor=t(e),this.setupRootElement(),this.listen()}return e.prototype.createContainer=function(e){var i;return null!=(i=this.$el)&&i.remove(),t(e.body).append(this.$el=t("<div class='atwho-container'></div>"))},e.prototype.setupRootElement=function(e,i){var n;if(null==i&&(i=!1),e)this.window=e.contentWindow,this.document=e.contentDocument||this.window.document,this.iframe=e;else{this.document=this.$inputor[0].ownerDocument,this.window=this.document.defaultView||this.document.parentWindow;try{this.iframe=this.window.frameElement}catch(r){if(n=r,this.iframe=null,t.fn.atwho.debug)throw new Error("iframe auto-discovery is failed.\nPlease use `setIframe` to set the target iframe manually.\n"+n)}}return this.createContainer((this.iframeAsRoot=i)?this.document:document)},e.prototype.controller=function(t){var e,i,n,r;if(this.aliasMaps[t])i=this.controllers[this.aliasMaps[t]];else{r=this.controllers;for(n in r)if(e=r[n],n===t){i=e;break}}return i?i:this.controllers[this.currentFlag]},e.prototype.setContextFor=function(t){return this.currentFlag=t,this},e.prototype.reg=function(t,e){var i,n;return n=(i=this.controllers)[t]||(i[t]=this.$inputor.is("[contentEditable]")?new l(this,t):new s(this,t)),e.alias&&(this.aliasMaps[e.alias]=t),n.init(e),this},e.prototype.listen=function(){return this.$inputor.on("compositionstart",function(t){return function(e){var i;return null!=(i=t.controller())&&i.view.hide(),t.isComposing=!0,null}}(this)).on("compositionend",function(t){return function(e){return t.isComposing=!1,setTimeout(function(e){return t.dispatch(e)}),null}}(this)).on("keyup.atwhoInner",function(t){return function(e){return t.onKeyup(e)}}(this)).on("keydown.atwhoInner",function(t){return function(e){return t.onKeydown(e)}}(this)).on("blur.atwhoInner",function(t){return function(e){var i;if(i=t.controller())return i.expectedQueryCBId=null,i.view.hide(e,i.getOpt("displayTimeout"))}}(this)).on("click.atwhoInner",function(t){return function(e){return t.dispatch(e)}}(this)).on("scroll.atwhoInner",function(t){return function(){var e;return e=t.$inputor.scrollTop(),function(i){var n,r;return n=i.target.scrollTop,e!==n&&null!=(r=t.controller())&&r.view.hide(i),e=n,!0}}}(this)())},e.prototype.shutdown=function(){var t,e,i;i=this.controllers;for(t in i)e=i[t],e.destroy(),delete this.controllers[t];return this.$inputor.off(".atwhoInner"),this.$el.remove()},e.prototype.dispatch=function(t){var e,i,n,r;if(void 0!==t){n=this.controllers,r=[];for(e in n)i=n[e],r.push(i.lookUp(t));return r}},e.prototype.onKeyup=function(e){var n;switch(e.keyCode){case i.ESC:e.preventDefault(),null!=(n=this.controller())&&n.view.hide();break;case i.DOWN:case i.UP:case i.CTRL:case i.ENTER:t.noop();break;case i.P:case i.N:e.ctrlKey||this.dispatch(e);break;default:this.dispatch(e)}},e.prototype.onKeydown=function(e){var n,r;if(r=null!=(n=this.controller())?n.view:void 0,r&&r.visible())switch(e.keyCode){case i.ESC:e.preventDefault(),r.hide(e);break;case i.UP:e.preventDefault(),r.prev();break;case i.DOWN:e.preventDefault(),r.next();break;case i.P:if(!e.ctrlKey)return;e.preventDefault(),r.prev();break;case i.N:if(!e.ctrlKey)return;e.preventDefault(),r.next();break;case i.TAB:case i.ENTER:case i.SPACE:if(!r.visible())return;if(!this.controller().getOpt("spaceSelectsMatch")&&e.keyCode===i.SPACE)return;if(!this.controller().getOpt("tabSelectsMatch")&&e.keyCode===i.TAB)return;r.highlighted()?(e.preventDefault(),r.choose(e)):r.hide(e);break;default:t.noop()}},e}();var r,o=[].slice;r=function(){function i(e,i){this.app=e,this.at=i,this.$inputor=this.app.$inputor,this.id=this.$inputor[0].id||this.uid(),this.expectedQueryCBId=null,this.setting=null,this.query=null,this.pos=0,this.range=null,0===(this.$el=t("#atwho-ground-"+this.id,this.app.$el)).length&&this.app.$el.append(this.$el=t("<div id='atwho-ground-"+this.id+"'></div>")),this.model=new u(this),this.view=new c(this)}return i.prototype.uid=function(){return(Math.random().toString(16)+"000000000").substr(2,8)+(new Date).getTime()},i.prototype.init=function(e){return this.setting=t.extend({},this.setting||t.fn.atwho["default"],e),this.view.init(),this.model.reload(this.setting.data)},i.prototype.destroy=function(){return this.trigger("beforeDestroy"),this.model.destroy(),this.view.destroy(),this.$el.remove()},i.prototype.callDefault=function(){var i,n,r;r=arguments[0],i=2<=arguments.length?o.call(arguments,1):[];try{return e[r].apply(this,i)}catch(s){return n=s,t.error(n+" Or maybe At.js doesn't have function "+r)}},i.prototype.trigger=function(t,e){var i,n;return null==e&&(e=[]),e.push(this),i=this.getOpt("alias"),n=i?t+"-"+i+".atwho":t+".atwho",this.$inputor.trigger(n,e)},i.prototype.callbacks=function(t){return this.getOpt("callbacks")[t]||e[t]},i.prototype.getOpt=function(t,e){var i;try{return this.setting[t]}catch(n){return i=n,null}},i.prototype.insertContentFor=function(e){var i,n;return n=this.getOpt("insertTpl"),i=t.extend({},e.data("item-data"),{"atwho-at":this.at}),this.callbacks("tplEval").call(this,n,i,"onInsert")},i.prototype.renderView=function(t){var e;return e=this.getOpt("searchKey"),t=this.callbacks("sorter").call(this,this.query.text,t,e),this.view.render(t.slice(0,this.getOpt("limit")))},i.arrayToDefaultHash=function(e){var i,n,r,o;if(!t.isArray(e))return e;for(o=[],i=0,r=e.length;i<r;i++)n=e[i],t.isPlainObject(n)?o.push(n):o.push({name:n});return o},i.prototype.lookUp=function(t){var e,i;if((!t||"click"!==t.type||this.getOpt("lookUpOnClick"))&&(!this.getOpt("suspendOnComposing")||!this.app.isComposing))return(e=this.catchQuery(t))?(this.app.setContextFor(this.at),(i=this.getOpt("delay"))?this._delayLookUp(e,i):this._lookUp(e),e):(this.expectedQueryCBId=null,e)},i.prototype._delayLookUp=function(t,e){var i,n;return i=Date.now?Date.now():(new Date).getTime(),this.previousCallTime||(this.previousCallTime=i),n=e-(i-this.previousCallTime),0<n&&n<e?(this.previousCallTime=i,this._stopDelayedCall(),this.delayedCallTimeout=setTimeout(function(e){return function(){return e.previousCallTime=0,e.delayedCallTimeout=null,e._lookUp(t)}}(this),e)):(this._stopDelayedCall(),this.previousCallTime!==i&&(this.previousCallTime=0),this._lookUp(t))},i.prototype._stopDelayedCall=function(){if(this.delayedCallTimeout)return clearTimeout(this.delayedCallTimeout),this.delayedCallTimeout=null},i.prototype._generateQueryCBId=function(){return{}},i.prototype._lookUp=function(e){var i;return i=function(t,e){if(t===this.expectedQueryCBId)return e&&e.length>0?this.renderView(this.constructor.arrayToDefaultHash(e)):this.view.hide()},this.expectedQueryCBId=this._generateQueryCBId(),this.model.query(e.text,t.proxy(i,this,this.expectedQueryCBId))},i}();var s,a=function(t,e){function i(){this.constructor=t}for(var n in e)h.call(e,n)&&(t[n]=e[n]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t},h={}.hasOwnProperty;s=function(e){function i(){return i.__super__.constructor.apply(this,arguments)}return a(i,e),i.prototype.catchQuery=function(){var t,e,i,n,r,o,s;if(e=this.$inputor.val(),t=this.$inputor.caret("pos",{iframe:this.app.iframe}),s=e.slice(0,t),r=this.callbacks("matcher").call(this,this.at,s,this.getOpt("startWithSpace"),this.getOpt("acceptSpaceBar")),n="string"==typeof r,!(n&&r.length<this.getOpt("minLen",0)))return n&&r.length<=this.getOpt("maxLen",20)?(o=t-r.length,i=o+r.length,this.pos=o,r={text:r,headPos:o,endPos:i},this.trigger("matched",[this.at,r.text])):(r=null,this.view.hide()),this.query=r},i.prototype.rect=function(){var e,i,n;if(e=this.$inputor.caret("offset",this.pos-1,{iframe:this.app.iframe}))return this.app.iframe&&!this.app.iframeAsRoot&&(i=t(this.app.iframe).offset(),e.left+=i.left,e.top+=i.top),n=this.app.document.selection?0:2,{left:e.left,top:e.top,bottom:e.top+e.height+n}},i.prototype.insert=function(t,e){var i,n,r,o,s;return i=this.$inputor,n=i.val(),r=n.slice(0,Math.max(this.query.headPos-this.at.length,0)),o=""===(o=this.getOpt("suffix"))?o:o||" ",t+=o,s=""+r+t+n.slice(this.query.endPos||0),i.val(s),i.caret("pos",r.length+t.length,{iframe:this.app.iframe}),i.is(":focus")||i.focus(),i.change()},i}(r);var l,a=function(t,e){function i(){this.constructor=t}for(var n in e)h.call(e,n)&&(t[n]=e[n]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t},h={}.hasOwnProperty;l=function(e){function n(){return n.__super__.constructor.apply(this,arguments)}return a(n,e),n.prototype._getRange=function(){var t;if(t=this.app.window.getSelection(),t.rangeCount>0)return t.getRangeAt(0)},n.prototype._setRange=function(e,i,n){if(null==n&&(n=this._getRange()),n&&i)return i=t(i)[0],"after"===e?(n.setEndAfter(i),n.setStartAfter(i)):(n.setEndBefore(i),n.setStartBefore(i)),n.collapse(!1),this._clearRange(n)},n.prototype._clearRange=function(t){var e;if(null==t&&(t=this._getRange()),e=this.app.window.getSelection(),null==this.ctrl_a_pressed)return e.removeAllRanges(),e.addRange(t)},n.prototype._movingEvent=function(t){var e;return"click"===t.type||(e=t.which)===i.RIGHT||e===i.LEFT||e===i.UP||e===i.DOWN},n.prototype._unwrap=function(e){var i;return e=t(e).unwrap().get(0),(i=e.nextSibling)&&i.nodeValue&&(e.nodeValue+=i.nodeValue,t(i).remove()),e},n.prototype.catchQuery=function(e){var n,r,o,s,a,h,l,u,c,p,f,d;if((d=this._getRange())&&d.collapsed){if(e.which===i.ENTER)return(r=t(d.startContainer).closest(".atwho-query")).contents().unwrap(),r.is(":empty")&&r.remove(),(r=t(".atwho-query",this.app.document)).text(r.text()).contents().last().unwrap(),void this._clearRange();if(/firefox/i.test(navigator.userAgent)){if(t(d.startContainer).is(this.$inputor))return void this._clearRange();e.which===i.BACKSPACE&&d.startContainer.nodeType===document.ELEMENT_NODE&&(c=d.startOffset-1)>=0?(o=d.cloneRange(),o.setStart(d.startContainer,c),t(o.cloneContents()).contents().last().is(".atwho-inserted")&&(a=t(d.startContainer).contents().get(c),this._setRange("after",t(a).contents().last()))):e.which===i.LEFT&&d.startContainer.nodeType===document.TEXT_NODE&&(n=t(d.startContainer.previousSibling),n.is(".atwho-inserted")&&0===d.startOffset&&this._setRange("after",n.contents().last()))}if(t(d.startContainer).closest(".atwho-inserted").addClass("atwho-query").siblings().removeClass("atwho-query"),(r=t(".atwho-query",this.app.document)).length>0&&r.is(":empty")&&0===r.text().length&&r.remove(),this._movingEvent(e)||r.removeClass("atwho-inserted"),r.length>0)switch(e.which){case i.LEFT:return this._setRange("before",r.get(0),d),void r.removeClass("atwho-query");case i.RIGHT:return this._setRange("after",r.get(0).nextSibling,d),void r.removeClass("atwho-query")}if(r.length>0&&(f=r.attr("data-atwho-at-query"))&&(r.empty().html(f).attr("data-atwho-at-query",null),this._setRange("after",r.get(0),d)),o=d.cloneRange(),o.setStart(d.startContainer,0),u=this.callbacks("matcher").call(this,this.at,o.toString(),this.getOpt("startWithSpace"),this.getOpt("acceptSpaceBar")),h="string"==typeof u,0===r.length&&h&&(s=d.startOffset-this.at.length-u.length)>=0&&(d.setStart(d.startContainer,s),r=t("<span/>",this.app.document).attr(this.getOpt("editableAtwhoQueryAttrs")).addClass("atwho-query"),d.surroundContents(r.get(0)),l=r.contents().last().get(0),l&&(/firefox/i.test(navigator.userAgent)?(d.setStart(l,l.length),d.setEnd(l,l.length),this._clearRange(d)):this._setRange("after",l,d))),!(h&&u.length<this.getOpt("minLen",0)))return h&&u.length<=this.getOpt("maxLen",20)?(p={text:u,el:r},this.trigger("matched",[this.at,p.text]),this.query=p):(this.view.hide(),this.query={el:r},r.text().indexOf(this.at)>=0&&(this._movingEvent(e)&&r.hasClass("atwho-inserted")?r.removeClass("atwho-query"):!1!==this.callbacks("afterMatchFailed").call(this,this.at,r)&&this._setRange("after",this._unwrap(r.text(r.text()).contents().first()))),null)}},n.prototype.rect=function(){var e,i,n;if(n=this.query.el.offset(),n&&this.query.el[0].getClientRects().length)return this.app.iframe&&!this.app.iframeAsRoot&&(i=(e=t(this.app.iframe)).offset(),n.left+=i.left-this.$inputor.scrollLeft(),n.top+=i.top-this.$inputor.scrollTop()),n.bottom=n.top+this.query.el.height(),n},n.prototype.insert=function(t,e){var i,n,r,o,s;return this.$inputor.is(":focus")||this.$inputor.focus(),n=this.getOpt("functionOverrides"),n.insert?n.insert.call(this,t,e):(o=""===(o=this.getOpt("suffix"))?o:o||" ",i=e.data("item-data"),this.query.el.removeClass("atwho-query").addClass("atwho-inserted").html(t).attr("data-atwho-at-query",""+i["atwho-at"]+this.query.text).attr("contenteditable","false"),(r=this._getRange())&&(this.query.el.length&&r.setEndAfter(this.query.el[0]),r.collapse(!1),r.insertNode(s=this.app.document.createTextNode(""+o)),this._setRange("after",s,r)),this.$inputor.is(":focus")||this.$inputor.focus(),this.$inputor.change())},n}(r);var u;u=function(){function t(t){this.context=t,this.at=this.context.at,this.storage=this.context.$inputor}return t.prototype.destroy=function(){return this.storage.data(this.at,null)},t.prototype.saved=function(){return this.fetch()>0},t.prototype.query=function(t,e){var i,n,r;return n=this.fetch(),r=this.context.getOpt("searchKey"),n=this.context.callbacks("filter").call(this.context,t,n,r)||[],i=this.context.callbacks("remoteFilter"),n.length>0||!i&&0===n.length?e(n):i.call(this.context,t,e)},t.prototype.fetch=function(){return this.storage.data(this.at)||[]},t.prototype.save=function(t){return this.storage.data(this.at,this.context.callbacks("beforeSave").call(this.context,t||[]))},t.prototype.load=function(t){if(!this.saved()&&t)return this._load(t)},t.prototype.reload=function(t){return this._load(t)},t.prototype._load=function(t){if("string"==typeof t)throw new Error("@gitlab/at.js removed support for $.ajax");return this.save(t)},t}();var c;c=function(){function e(e){this.context=e,this.$el=t("<div class='atwho-view'><ul class='atwho-view-ul'></ul></div>"),this.$elUl=this.$el.children(),this.timeoutID=null,this.context.$el.append(this.$el),this.bindEvent()}return e.prototype.init=function(){var t,e;return e=this.context.getOpt("alias")||this.context.at.charCodeAt(0),t=this.context.getOpt("headerTpl"),t&&1===this.$el.children().length&&this.$el.prepend(t),this.$el.attr({id:"at-view-"+e})},e.prototype.destroy=function(){return this.$el.remove()},e.prototype.bindEvent=function(){var e,i,n;return e=this.$el.find("ul"),i=0,n=0,e.on("mousemove.atwho-view","li",function(r){return function(r){var o;if((i!==r.clientX||n!==r.clientY)&&(i=r.clientX,n=r.clientY,o=t(r.currentTarget),!o.hasClass("cur")))return e.find(".cur").removeClass("cur"),o.addClass("cur")}}(this)).on("click.atwho-view","li",function(i){return function(n){return e.find(".cur").removeClass("cur"),t(n.currentTarget).addClass("cur"),i.choose(n),n.preventDefault()}}(this))},e.prototype.visible=function(){return t.expr.filters.visible(this.$el[0])},e.prototype.highlighted=function(){return this.$el.find(".cur").length>0},e.prototype.choose=function(t){var e,i;if((e=this.$el.find(".cur")).length&&(i=this.context.insertContentFor(e),this.context._stopDelayedCall(),this.context.insert(this.context.callbacks("beforeInsert").call(this.context,i,e,t),e),this.context.trigger("inserted",[e,t]),this.hide(t)),this.context.getOpt("hideWithoutSuffix"))return this.stopShowing=!0},e.prototype.reposition=function(e){var i,n,r,o;return i=this.context.app.iframeAsRoot?this.context.app.window:window,e.bottom+this.$el.height()-t(i).scrollTop()>t(i).height()&&(e.bottom=e.top-this.$el.height()),e.left>(r=t(i).width()-this.$el.width()-5)&&(e.left=r),n={left:e.left,top:e.bottom},null!=(o=this.context.callbacks("beforeReposition"))&&o.call(this.context,n),this.$el.offset(n),this.context.trigger("reposition",[n])},e.prototype.next=function(){var t,e,i,n;return t=this.$el.find(".cur").removeClass("cur"),e=t.next(),e.length||(e=this.$el.find("li:first")),e.addClass("cur"),i=e[0],n=i.offsetTop+i.offsetHeight+(i.nextSibling?i.nextSibling.offsetHeight:0),this.scrollTop(Math.max(0,n-this.$el.height()))},e.prototype.prev=function(){var t,e,i,n;return t=this.$el.find(".cur").removeClass("cur"),i=t.prev(),i.length||(i=this.$el.find("li:last")),i.addClass("cur"),n=i[0],e=n.offsetTop+n.offsetHeight+(n.nextSibling?n.nextSibling.offsetHeight:0),this.scrollTop(Math.max(0,e-this.$el.height()))},e.prototype.scrollTop=function(t){return this.$elUl.scrollTop(t)},e.prototype.show=function(){var t;return this.stopShowing?void(this.stopShowing=!1):(this.visible()||(this.$el.show(),this.$el.scrollTop(0),this.context.trigger("shown")),(t=this.context.rect())?this.reposition(t):void 0)},e.prototype.hide=function(t,e){var i;if(this.visible())return isNaN(e)?(this.$el.hide(),this.context.trigger("hidden",[t])):(i=function(t){return function(){return t.hide()}}(this),clearTimeout(this.timeoutID),this.timeoutID=setTimeout(i,e))},e.prototype.render=function(e){var i,n,r,o,s,a,h;if(!(t.isArray(e)&&e.length>0))return void this.hide();for(this.$el.find("ul").empty(),n=this.$el.find("ul"),h=this.context.getOpt("displayTpl"),r=0,s=e.length;r<s;r++)o=e[r],o=t.extend({},o,{"atwho-at":this.context.at}),a=this.context.callbacks("tplEval").call(this.context,h,o,"onDisplay"),i=t(this.context.callbacks("highlighter").call(this.context,a,this.context.query.text)),i.data("item-data",o),n.append(i);return this.show(),this.context.getOpt("highlightFirst")?n.find("li:first").addClass("cur"):void 0},e}();var p;p={load:function(t,e){var i;if(i=this.controller(t))return i.model.load(e)},isSelecting:function(){var t;return!!(null!=(t=this.controller())?t.view.visible():void 0)},hide:function(){var t;return null!=(t=this.controller())?t.view.hide():void 0},reposition:function(){var t;if(t=this.controller())return t.view.reposition(t.rect())},setIframe:function(t,e){return this.setupRootElement(t,e),null},run:function(){return this.dispatch()},destroy:function(){return this.shutdown(),this.$inputor.data("atwho",null)}},t.fn.atwho=function(e){var i,r;return i=arguments,r=null,this.filter('textarea, input, [contenteditable=""], [contenteditable=true]').each(function(){var o,s;return(s=(o=t(this)).data("atwho"))||o.data("atwho",s=new n(this)),"object"!=typeof e&&e?p[e]&&s?r=p[e].apply(s,Array.prototype.slice.call(i,1)):t.error("Method "+e+" does not exist on jQuery.atwho"):s.reg(e.at,e)}),null!=r?r:this},t.fn.atwho["default"]={at:void 0,alias:void 0,data:null,displayTpl:"<li>${name}</li>",insertTpl:"${atwho-at}${name}",headerTpl:null,callbacks:e,functionOverrides:{},searchKey:"name",suffix:void 0,hideWithoutSuffix:!1,startWithSpace:!0,acceptSpaceBar:!1,highlightFirst:!0,limit:5,maxLen:20,minLen:0,displayTimeout:300,delay:null,spaceSelectsMatch:!1,tabSelectsMatch:!0,editableAtwhoQueryAttrs:{},scrollDuration:150,suspendOnComposing:!0,lookUpOnClick:!0},t.fn.atwho.debug=!1});
|
|
1
|
+
(t=>{"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof exports?module.exports=t(require("jquery")):t(jQuery)})(function(o){var a={ESC:27,TAB:9,ENTER:13,CTRL:17,A:65,P:80,N:78,LEFT:37,UP:38,RIGHT:39,DOWN:40,BACKSPACE:8,SPACE:32},i={beforeSave:function(t){return e.arrayToDefaultHash(t)},matcher:function(t,e,i,s){var r;return t=t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),i&&(t="(?:^|\\s)"+t),i=decodeURI("%C3%80"),r=decodeURI("%C3%BF"),(i=new RegExp(t+`([A-Za-z${i}-${r}0-9_${s?" ":""}'.+-]*)$|${t}([^\\x00-\\xff]*)$`,"gi").exec(e))?i[2]||i[1]:null},filter:function(t,e,i){for(var s,r=[],n=0,a=e.length;n<a;n++)s=e[n],~new String(s[i]).toLowerCase().indexOf(t.toLowerCase())&&r.push(s);return r},remoteFilter:null,sorter:function(t,e,i){var s,r,n,a;if(!t)return e;for(s=[],r=0,a=e.length;r<a;r++)(n=e[r]).atwho_order=new String(n[i]).toLowerCase().indexOf(t.toLowerCase()),-1<n.atwho_order&&s.push(n);return s.sort(function(t,e){return t.atwho_order-e.atwho_order})},tplEval:function(t,s){var e=t;try{return(e="string"!=typeof t?t(s):e).replace(/\$\{([^\}]*)\}/g,function(t,e,i){return s[e]})}catch(t){return""}},highlighter:function(t,e){return e?(e=new RegExp(">\\s*([^<]*?)("+e.replace("+","\\+")+")([^<]*)\\s*<","ig"),t.replace(e,function(t,e,i,s){return"> "+e+"<strong>"+i+"</strong>"+s+" <"})):t},beforeInsert:function(t,e,i){return t},beforeReposition:function(t){return t},afterMatchFailed:function(t,e){}},n=class{constructor(t){this.currentFlag=null,this.controllers={},this.aliasMaps={},this.$inputor=o(t),this.setupRootElement(),this.listen()}createContainer(t){var e;return null!=(e=this.$el)&&e.remove(),o(t.body).append(this.$el=o("<div class='atwho-container'></div>"))}setupRootElement(e,t=!1){if(e)this.window=e.contentWindow,this.document=e.contentDocument||this.window.document,this.iframe=e;else{this.document=this.$inputor[0].ownerDocument,this.window=this.document.defaultView||this.document.parentWindow;try{this.iframe=this.window.frameElement}catch(t){if(e=t,this.iframe=null,o.fn.atwho.debug)throw new Error("iframe auto-discovery is failed.\nPlease use `setIframe` to set the target iframe manually.\n"+e)}}return this.createContainer((this.iframeAsRoot=t)?this.document:document)}controller(t){var e,i,s,r;if(this.aliasMaps[t])i=this.controllers[this.aliasMaps[t]];else for(s in r=this.controllers)if(e=r[s],s===t){i=e;break}return i||this.controllers[this.currentFlag]}setContextFor(t){return this.currentFlag=t,this}reg(t,e){var i=(i=this.controllers)[t]||(i[t]=new(this.$inputor.is("[contentEditable]")?r:s)(this,t));return e.alias&&(this.aliasMaps[e.alias]=t),i.init(e),this}listen(){return this.$inputor.on("compositionstart",t=>{var e;return null!=(e=this.controller())&&e.view.hide(),this.isComposing=!0,null}).on("compositionend",t=>(this.isComposing=!1,setTimeout(t=>this.dispatch(t)),null)).on("keyup.atwhoInner",t=>this.onKeyup(t)).on("keydown.atwhoInner",t=>this.onKeydown(t)).on("blur.atwhoInner",t=>{var e;if(e=this.controller())return e.expectedQueryCBId=null,e.view.hide(t,e.getOpt("displayTimeout"))}).on("click.atwhoInner",t=>this.dispatch(t)).on("scroll.atwhoInner",(s=this.$inputor.scrollTop(),t=>{var e,i=t.target.scrollTop;return s!==i&&null!=(e=this.controller())&&e.view.hide(t),s=i,!0}));var s}shutdown(){var t,e=this.controllers;for(t in e)e[t].destroy(),delete this.controllers[t];return this.$inputor.off(".atwhoInner"),this.$el.remove()}dispatch(t){var e,i,s,r;if(void 0!==t){for(e in r=[],s=this.controllers)i=s[e],r.push(i.lookUp(t));return r}}onKeyup(t){var e;switch(t.keyCode){case a.ESC:t.preventDefault(),null!=(e=this.controller())&&e.view.hide();break;case a.DOWN:case a.UP:case a.CTRL:case a.ENTER:o.noop();break;case a.P:case a.N:t.ctrlKey||this.dispatch(t);break;default:this.dispatch(t)}}onKeydown(t){var e,i=null!=(e=this.controller())?e.view:void 0;if(i&&i.visible())switch(t.keyCode){case a.ESC:t.preventDefault(),i.hide(t);break;case a.UP:t.preventDefault(),i.prev();break;case a.DOWN:t.preventDefault(),i.next();break;case a.P:t.ctrlKey&&(t.preventDefault(),i.prev());break;case a.N:t.ctrlKey&&(t.preventDefault(),i.next());break;case a.TAB:case a.ENTER:case a.SPACE:!i.visible()||!this.controller().getOpt("spaceSelectsMatch")&&t.keyCode===a.SPACE||!this.controller().getOpt("tabSelectsMatch")&&t.keyCode===a.TAB||(i.highlighted()?(t.preventDefault(),i.choose(t)):i.hide(t));break;default:o.noop()}}},e=class{uid(){return(Math.random().toString(16)+"000000000").substr(2,8)+(new Date).getTime()}constructor(t,e){this.app=t,this.at=e,this.$inputor=this.app.$inputor,this.id=this.$inputor[0].id||this.uid(),this.expectedQueryCBId=null,this.setting=null,this.query=null,this.pos=0,this.range=null,0===(this.$el=o("#atwho-ground-"+this.id,this.app.$el)).length&&this.app.$el.append(this.$el=o(`<div id='atwho-ground-${this.id}'></div>`)),this.model=new h(this),this.view=new l(this)}init(t){return this.setting=o.extend({},this.setting||o.fn.atwho.default,t),this.view.init(),this.model.reload(this.setting.data)}destroy(){return this.trigger("beforeDestroy"),this.model.destroy(),this.view.destroy(),this.$el.remove()}callDefault(e,...t){try{return i[e].apply(this,t)}catch(t){return o.error(t+" Or maybe At.js doesn't have function "+e)}}trigger(t,e=[]){var i;return e.push(this),i=this.getOpt("alias"),this.$inputor.trigger(i?t+`-${i}.atwho`:t+".atwho",e)}callbacks(t){return this.getOpt("callbacks")[t]||i[t]}getOpt(t,e){try{return this.setting[t]}catch(t){return null}}insertContentFor(t){var e=this.getOpt("insertTpl"),t=o.extend({},t.data("item-data"),{"atwho-at":this.at});return this.callbacks("tplEval").call(this,e,t,"onInsert")}renderView(t){var e=this.getOpt("searchKey");return t=this.callbacks("sorter").call(this,this.query.text,t,e),this.view.render(t.slice(0,this.getOpt("limit")))}static arrayToDefaultHash(t){var e,i,s,r;if(!o.isArray(t))return t;for(r=[],e=0,s=t.length;e<s;e++)i=t[e],o.isPlainObject(i)?r.push(i):r.push({name:i});return r}lookUp(t){var e;if((!t||"click"!==t.type||this.getOpt("lookUpOnClick"))&&(!this.getOpt("suspendOnComposing")||!this.app.isComposing))return(t=this.catchQuery(t))?(this.app.setContextFor(this.at),(e=this.getOpt("delay"))?this._delayLookUp(t,e):this._lookUp(t)):this.expectedQueryCBId=null,t}_delayLookUp(t,e){var i,s=Date.now?Date.now():(new Date).getTime();return this.previousCallTime||(this.previousCallTime=s),0<(i=e-(s-this.previousCallTime))&&i<e?(this.previousCallTime=s,this._stopDelayedCall(),this.delayedCallTimeout=setTimeout(()=>(this.previousCallTime=0,this.delayedCallTimeout=null,this._lookUp(t)),e)):(this._stopDelayedCall(),this.previousCallTime!==s&&(this.previousCallTime=0),this._lookUp(t))}_stopDelayedCall(){if(this.delayedCallTimeout)return clearTimeout(this.delayedCallTimeout),this.delayedCallTimeout=null}_generateQueryCBId(){return{}}_lookUp(t){var e=function(t,e){if(t===this.expectedQueryCBId)return e&&0<e.length?this.renderView(this.constructor.arrayToDefaultHash(e)):this.view.hide()};return this.expectedQueryCBId=this._generateQueryCBId(),this.model.query(t.text,o.proxy(e,this,this.expectedQueryCBId))}},s=class extends e{catchQuery(){var t=this.$inputor.val(),e=this.$inputor.caret("pos",{iframe:this.app.iframe}),t=t.slice(0,e),t=this.callbacks("matcher").call(this,this.at,t,this.getOpt("startWithSpace"),this.getOpt("acceptSpaceBar")),i="string"==typeof t;if(!(i&&t.length<this.getOpt("minLen",0)))return i&&t.length<=this.getOpt("maxLen",20)?(e=(i=e-t.length)+t.length,this.pos=i,this.trigger("matched",[this.at,(t={text:t,headPos:i,endPos:e}).text])):(t=null,this.view.hide()),this.query=t}rect(){var t,e;if(t=this.$inputor.caret("offset",this.pos-1,{iframe:this.app.iframe}))return this.app.iframe&&!this.app.iframeAsRoot&&(e=o(this.app.iframe).offset(),t.left+=e.left,t.top+=e.top),e=this.app.document.selection?0:2,{left:t.left,top:t.top,bottom:t.top+t.height+e}}insert(t,e){var i=this.$inputor,s=i.val(),r=s.slice(0,Math.max(this.query.headPos-this.at.length,0)),n=""===(n=this.getOpt("suffix"))?n:n||" ",n=""+r+(t+=n)+s.slice(this.query.endPos||0);return i.val(n),i.caret("pos",r.length+t.length,{iframe:this.app.iframe}),i.is(":focus")||i.focus(),i.change()}},r=class extends e{_getRange(){var t=this.app.window.getSelection();if(0<t.rangeCount)return t.getRangeAt(0)}_setRange(t,e,i=this._getRange()){if(i&&e)return e=o(e)[0],"after"===t?(i.setEndAfter(e),i.setStartAfter(e)):(i.setEndBefore(e),i.setStartBefore(e)),i.collapse(!1),this._clearRange(i)}_clearRange(t=this._getRange()){var e=this.app.window.getSelection();if(null==this.ctrl_a_pressed)return e.removeAllRanges(),e.addRange(t)}_movingEvent(t){return"click"===t.type||(t=t.which)===a.RIGHT||t===a.LEFT||t===a.UP||t===a.DOWN}_unwrap(t){var e;return(e=(t=o(t).unwrap().get(0)).nextSibling)&&e.nodeValue&&(t.nodeValue+=e.nodeValue,o(e).remove()),t}catchQuery(t){var e,i,s,r,n;if((n=this._getRange())&&n.collapsed)if(t.which===a.ENTER)(e=o(n.startContainer).closest(".atwho-query")).contents().unwrap(),e.is(":empty")&&e.remove(),(e=o(".atwho-query",this.app.document)).text(e.text()).contents().last().unwrap(),this._clearRange();else{if(/firefox/i.test(navigator.userAgent)){if(o(n.startContainer).is(this.$inputor))return void this._clearRange();t.which===a.BACKSPACE&&n.startContainer.nodeType===document.ELEMENT_NODE&&0<=(r=n.startOffset-1)?((i=n.cloneRange()).setStart(n.startContainer,r),o(i.cloneContents()).contents().last().is(".atwho-inserted")&&(r=o(n.startContainer).contents().get(r),this._setRange("after",o(r).contents().last()))):t.which===a.LEFT&&n.startContainer.nodeType===document.TEXT_NODE&&(r=o(n.startContainer.previousSibling)).is(".atwho-inserted")&&0===n.startOffset&&this._setRange("after",r.contents().last())}if(o(n.startContainer).closest(".atwho-inserted").addClass("atwho-query").siblings().removeClass("atwho-query"),0<(e=o(".atwho-query",this.app.document)).length&&e.is(":empty")&&0===e.text().length&&e.remove(),this._movingEvent(t)||e.removeClass("atwho-inserted"),0<e.length)switch(t.which){case a.LEFT:return this._setRange("before",e.get(0),n),void e.removeClass("atwho-query");case a.RIGHT:return this._setRange("after",e.get(0).nextSibling,n),void e.removeClass("atwho-query")}if(0<e.length&&(r=e.attr("data-atwho-at-query"))&&(e.empty().html(r).attr("data-atwho-at-query",null),this._setRange("after",e.get(0),n)),(i=n.cloneRange()).setStart(n.startContainer,0),i="string"==typeof(r=this.callbacks("matcher").call(this,this.at,i.toString(),this.getOpt("startWithSpace"),this.getOpt("acceptSpaceBar"))),0===e.length&&i&&0<=(s=n.startOffset-this.at.length-r.length)&&(n.setStart(n.startContainer,s),e=o("<span/>",this.app.document).attr(this.getOpt("editableAtwhoQueryAttrs")).addClass("atwho-query"),n.surroundContents(e.get(0)),s=e.contents().last().get(0))&&(/firefox/i.test(navigator.userAgent)?(n.setStart(s,s.length),n.setEnd(s,s.length),this._clearRange(n)):this._setRange("after",s,n)),!(i&&r.length<this.getOpt("minLen",0)))return i&&r.length<=this.getOpt("maxLen",20)?(this.trigger("matched",[this.at,(s={text:r,el:e}).text]),this.query=s):(this.view.hide(),this.query={el:e},0<=e.text().indexOf(this.at)&&(this._movingEvent(t)&&e.hasClass("atwho-inserted")?e.removeClass("atwho-query"):!1!==this.callbacks("afterMatchFailed").call(this,this.at,e)&&this._setRange("after",this._unwrap(e.text(e.text()).contents().first()))),null)}}rect(){var t,e=this.query.el.offset();if(e&&this.query.el[0].getClientRects().length)return this.app.iframe&&!this.app.iframeAsRoot&&(t=o(this.app.iframe).offset(),e.left+=t.left-this.$inputor.scrollLeft(),e.top+=t.top-this.$inputor.scrollTop()),e.bottom=e.top+this.query.el.height(),e}insert(t,e){var i;return this.$inputor.is(":focus")||this.$inputor.focus(),(i=this.getOpt("functionOverrides")).insert?i.insert.call(this,t,e):(i=""===(i=this.getOpt("suffix"))?i:i||" ",e=e.data("item-data"),this.query.el.removeClass("atwho-query").addClass("atwho-inserted").html(t).attr("data-atwho-at-query",""+e["atwho-at"]+this.query.text).attr("contenteditable","false"),(t=this._getRange())&&(this.query.el.length&&t.setEndAfter(this.query.el[0]),t.collapse(!1),t.insertNode(e=this.app.document.createTextNode(""+i)),this._setRange("after",e,t)),this.$inputor.is(":focus")||this.$inputor.focus(),this.$inputor.change())}},h=class{constructor(t){this.context=t,this.at=this.context.at,this.storage=this.context.$inputor}destroy(){return this.storage.data(this.at,null)}saved(){return 0<this.fetch()}query(t,e){var i=this.fetch(),s=this.context.getOpt("searchKey");return i=this.context.callbacks("filter").call(this.context,t,i,s)||[],s=this.context.callbacks("remoteFilter"),0<i.length||!s&&0===i.length?e(i):s.call(this.context,t,e)}fetch(){return this.storage.data(this.at)||[]}save(t){return this.storage.data(this.at,this.context.callbacks("beforeSave").call(this.context,t||[]))}load(t){if(!this.saved()&&t)return this._load(t)}reload(t){return this._load(t)}_load(t){if("string"==typeof t)throw new Error("@gitlab/at.js removed support for $.ajax");return this.save(t)}},l=class{constructor(t){this.context=t,this.$el=o("<div class='atwho-view'><ul class='atwho-view-ul'></ul></div>"),this.$elUl=this.$el.children(),this.timeoutID=null,this.context.$el.append(this.$el),this.bindEvent()}init(){var t=this.context.getOpt("alias")||this.context.at.charCodeAt(0),e=this.context.getOpt("headerTpl");return e&&1===this.$el.children().length&&this.$el.prepend(e),this.$el.attr({id:"at-view-"+t})}destroy(){return this.$el.remove()}bindEvent(){var e=this.$el.find("ul"),i=0,s=0;return e.on("mousemove.atwho-view","li",t=>{if((i!==t.clientX||s!==t.clientY)&&(i=t.clientX,s=t.clientY,!(t=o(t.currentTarget)).hasClass("cur")))return e.find(".cur").removeClass("cur"),t.addClass("cur")}).on("click.atwho-view","li",t=>(e.find(".cur").removeClass("cur"),o(t.currentTarget).addClass("cur"),this.choose(t),t.preventDefault()))}visible(){return o.expr.filters.visible(this.$el[0])}highlighted(){return 0<this.$el.find(".cur").length}choose(t){var e,i;if((e=this.$el.find(".cur")).length&&(i=this.context.insertContentFor(e),this.context._stopDelayedCall(),this.context.insert(this.context.callbacks("beforeInsert").call(this.context,i,e,t),e),this.context.trigger("inserted",[e,t]),this.hide(t)),this.context.getOpt("hideWithoutSuffix"))return this.stopShowing=!0}reposition(t){var e=this.context.app.iframeAsRoot?this.context.app.window:window;return t.bottom+this.$el.height()-o(e).scrollTop()>o(e).height()&&(t.bottom=t.top-this.$el.height()),t.left>(e=o(e).width()-this.$el.width()-5)&&(t.left=e),e={left:t.left,top:t.bottom},null!=(t=this.context.callbacks("beforeReposition"))&&t.call(this.context,e),this.$el.offset(e),this.context.trigger("reposition",[e])}next(){var t=this.$el.find(".cur").removeClass("cur").next();return(t=t.length?t:this.$el.find("li:first")).addClass("cur"),t=(t=t[0]).offsetTop+t.offsetHeight+(t.nextSibling?t.nextSibling.offsetHeight:0),this.scrollTop(Math.max(0,t-this.$el.height()))}prev(){var t=this.$el.find(".cur").removeClass("cur").prev();return(t=t.length?t:this.$el.find("li:last")).addClass("cur"),t=(t=t[0]).offsetTop+t.offsetHeight+(t.nextSibling?t.nextSibling.offsetHeight:0),this.scrollTop(Math.max(0,t-this.$el.height()))}scrollTop(t){return this.$elUl.scrollTop(t)}show(){var t;if(!this.stopShowing)return this.visible()||(this.$el.show(),this.$el.scrollTop(0),this.context.trigger("shown")),(t=this.context.rect())?this.reposition(t):void 0;this.stopShowing=!1}hide(t,e){if(this.visible())return isNaN(e)?(this.$el.hide(),this.context.trigger("hidden",[t])):(t=()=>this.hide(),clearTimeout(this.timeoutID),this.timeoutID=setTimeout(t,e))}render(t){var e,i,s,r,n,a;if(o.isArray(t)&&0<t.length){for(this.$el.find("ul").empty(),e=this.$el.find("ul"),a=this.context.getOpt("displayTpl"),i=0,r=t.length;i<r;i++)s=t[i],s=o.extend({},s,{"atwho-at":this.context.at}),n=this.context.callbacks("tplEval").call(this.context,a,s,"onDisplay"),(n=o(this.context.callbacks("highlighter").call(this.context,n,this.context.query.text))).data("item-data",s),e.append(n);return this.show(),this.context.getOpt("highlightFirst")?e.find("li:first").addClass("cur"):void 0}this.hide()}},c={load:function(t,e){if(t=this.controller(t))return t.model.load(e)},isSelecting:function(){var t;return!(null==(t=this.controller())||!t.view.visible())},hide:function(){var t;return null!=(t=this.controller())?t.view.hide():void 0},reposition:function(){var t;if(t=this.controller())return t.view.reposition(t.rect())},setIframe:function(t,e){return this.setupRootElement(t,e),null},run:function(){return this.dispatch()},destroy:function(){return this.shutdown(),this.$inputor.data("atwho",null)}};o.fn.atwho=function(i){var s=arguments,r=null;return this.filter('textarea, input, [contenteditable=""], [contenteditable=true]').each(function(){var t,e;return(e=(t=o(this)).data("atwho"))||t.data("atwho",e=new n(this)),"object"!=typeof i&&i?c[i]&&e?r=c[i].apply(e,Array.prototype.slice.call(s,1)):o.error(`Method ${i} does not exist on jQuery.atwho`):e.reg(i.at,i)}),null!=r?r:this},o.fn.atwho.default={at:void 0,alias:void 0,data:null,displayTpl:"<li>${name}</li>",insertTpl:"${atwho-at}${name}",headerTpl:null,callbacks:i,functionOverrides:{},searchKey:"name",suffix:void 0,hideWithoutSuffix:!1,startWithSpace:!0,acceptSpaceBar:!1,highlightFirst:!0,limit:5,maxLen:20,minLen:0,displayTimeout:300,delay:null,spaceSelectsMatch:!1,tabSelectsMatch:!0,editableAtwhoQueryAttrs:{},scrollDuration:150,suspendOnComposing:!0,lookUpOnClick:!0},o.fn.atwho.debug=!1});
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
},
|
|
8
8
|
"homepage": "https://gitlab.com/gitlab-org/frontend/At.js",
|
|
9
9
|
"license": "MIT",
|
|
10
|
-
"version": "1.5.
|
|
10
|
+
"version": "1.5.8",
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
13
|
"url": "https://gitlab.com/gitlab-org/frontend/At.js"
|
|
@@ -22,8 +22,6 @@
|
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
24
|
"bower": "bower install --allow-root",
|
|
25
|
-
"postinstall": "cd ./node_modules/minijasminenode2 && ln -sf ../../node_modules node_modules",
|
|
26
|
-
"build": "rm -rf dist && gulp && gulp",
|
|
27
25
|
"test": "gulp test"
|
|
28
26
|
},
|
|
29
27
|
"peerDependencies": {
|
|
@@ -31,22 +29,22 @@
|
|
|
31
29
|
},
|
|
32
30
|
"devDependencies": {
|
|
33
31
|
"bower": "^1.8.8",
|
|
34
|
-
"
|
|
35
|
-
"gulp
|
|
36
|
-
"gulp-
|
|
37
|
-
"gulp-
|
|
38
|
-
"gulp-
|
|
39
|
-
"gulp-
|
|
40
|
-
"gulp-header": "^
|
|
41
|
-
"gulp-
|
|
42
|
-
"gulp-
|
|
43
|
-
"gulp-
|
|
44
|
-
"gulp-uglify": "^1.5.1",
|
|
45
|
-
"gulp-umd": "^0.2.0",
|
|
46
|
-
"gulp-util": "^3.0.7",
|
|
32
|
+
"fancy-log": "^2.0.0",
|
|
33
|
+
"gulp": "^4.0.2",
|
|
34
|
+
"gulp-bump": "^3.2.0",
|
|
35
|
+
"gulp-clean-css": "^4.3.0",
|
|
36
|
+
"gulp-coffee": "^3.0.3",
|
|
37
|
+
"gulp-concat": "^2.6.1",
|
|
38
|
+
"gulp-header": "^2.0.9",
|
|
39
|
+
"gulp-rename": "^2.0.0",
|
|
40
|
+
"gulp-uglify": "^3.0.2",
|
|
41
|
+
"gulp-umd": "^2.0.0",
|
|
47
42
|
"jasmine-ajax": "^3.2.0",
|
|
43
|
+
"jasmine-core": "^3.99.1",
|
|
48
44
|
"jasmine-jquery": "^2.1.1",
|
|
49
|
-
"
|
|
45
|
+
"karma": "^6.4.3",
|
|
46
|
+
"karma-chrome-launcher": "^3.2.0",
|
|
47
|
+
"karma-jasmine": "^4.0.2"
|
|
50
48
|
},
|
|
51
49
|
"spm": {
|
|
52
50
|
"main": "dist/js/jquery.atwho.js",
|
package/CHANGELOG.md
DELETED
|
@@ -1,314 +0,0 @@
|
|
|
1
|
-
### v1.5.0
|
|
2
|
-
|
|
3
|
-
add `headerTpl` settings
|
|
4
|
-
|
|
5
|
-
* 7a41d93 - #375 from vcekov/fix_scroll_position - Valentin Cekov
|
|
6
|
-
* ecbf34f - #373 from vcekov/val/fix_key_navigation_interefence_with_mouse - Valentin Cekov
|
|
7
|
-
* b68cf84 - #364 from WorktileTech/master - Harold.Luo
|
|
8
|
-
* f836f04 - #372 from vcekov/fix_caret_for_space_after_@ - Harold.Luo
|
|
9
|
-
* 06cf6bb - Properly set caret position after failed match - Valentin Cekov
|
|
10
|
-
* c9ed2e2 - support header template. - htz
|
|
11
|
-
|
|
12
|
-
### v1.4.0
|
|
13
|
-
|
|
14
|
-
#### Contenteditable
|
|
15
|
-
|
|
16
|
-
Pressing `Backspace` will turn the inserted element back to the origin query 'moment'.
|
|
17
|
-
|
|
18
|
-
* 84edc9f - skip inserted element when moving left or right - ichord
|
|
19
|
-
* 25a61d3 - the jQuery npm package is now called jquery. Fixes #338 - Mick Staugaard
|
|
20
|
-
* 03ed71f - Merge pull request #351 from mociepka/master - Harold.Luo
|
|
21
|
-
* ae00dc3 - Point main script in package json - Michał Ociepka
|
|
22
|
-
* c5f31f5 - Merge branch 'dev' into HEAD - ichord
|
|
23
|
-
* c399397 - fix contenteditable cursor bug when typing "a" into query - ichord
|
|
24
|
-
* 7f4295a - fix previous replacements get clobbered when re-intering the inserted element - ichord
|
|
25
|
-
* f00fabd - Merge pull request #354 from lvegerano/master - Harold.Luo
|
|
26
|
-
* a42065e - Adds guard to event and dist file - Luis Vegerano
|
|
27
|
-
* e4aaa30 - Add option to disable loopUp on click - Luis Vegerano
|
|
28
|
-
* c9b7609 - Fix bug where callbacks would run before reaching minLen. Fixes #329. - Mike Leone
|
|
29
|
-
* f8692dc - Add support for minLen. Connects to issue #316. - Mike Leone
|
|
30
|
-
* fd7d298 - FIX: the value of `isSelecting` - ichord
|
|
31
|
-
* c374c93 - FIX: IME typing error - ichord
|
|
32
|
-
|
|
33
|
-
### v1.3.0
|
|
34
|
-
|
|
35
|
-
* 7f2189d - fix #294 inserts "" suffix in contenteditable
|
|
36
|
-
* bae95d9 - add `tabSelectsMatch` setting to make tab selection optional
|
|
37
|
-
* e966aba - Merge pull request #298 from kkirsche/patch-1 - Harold.Luo
|
|
38
|
-
* 9f78239 - Remove moot `version` property from bower.json - Kevin Kirsche
|
|
39
|
-
|
|
40
|
-
### v1.2.0
|
|
41
|
-
|
|
42
|
-
db09ac7 -> 886613f
|
|
43
|
-
|
|
44
|
-
* 886613f - add `$.fn.atwho.debug = false` to trigger debug mode
|
|
45
|
-
* 6567af9 - Enable default events when nothing is highlighted - Teemu
|
|
46
|
-
* 752ad4a - Add scrollDuration option. - Takuru
|
|
47
|
-
* bf17d43 - add parameter to allow for a spacebar in the middle of a search so that you can match a first + last name, for example - Feather Knee
|
|
48
|
-
* a1d5fe7 - add `reposition` API - ichord
|
|
49
|
-
* 9bcb06e - add "onInsert", "onDispaly" arguments to `tplEval` - ichord
|
|
50
|
-
* db09ac7 - add `hide` api - ichord
|
|
51
|
-
|
|
52
|
-
### v1.1.0
|
|
53
|
-
|
|
54
|
-
* lisafeather/displyTplCallBack - #259
|
|
55
|
-
* ADD: `editableAtwhoQueryAttrs` options
|
|
56
|
-
* Added setting for 'spaceSelectsMatch' (default false/off)
|
|
57
|
-
|
|
58
|
-
### v1.0.0
|
|
59
|
-
|
|
60
|
-
**The naming convention are using camel case**.
|
|
61
|
-
It means that every callback and setting's name are switched from underscope_naming to CamelNaming.
|
|
62
|
-
Sorry about this.
|
|
63
|
-
|
|
64
|
-
Future version's naming will follow the rules of http://semver.org constantly.
|
|
65
|
-
|
|
66
|
-
#### Options:
|
|
67
|
-
|
|
68
|
-
* Replaced `tpl` with `displayTpl`: display template of dropdown menu items.
|
|
69
|
-
In previous versions, At.js will fetch the value of `data-value` to insert; It stops doing it.
|
|
70
|
-
Please use the `insertTpl` option to manage the content to insert instead.
|
|
71
|
-
The default value is `"<li>${name}</li>"`
|
|
72
|
-
* The `insertTpl` option will be used in *textarea* as well.
|
|
73
|
-
The default value is `"${atwho-at}${name}"`
|
|
74
|
-
|
|
75
|
-
#### Callbacks:
|
|
76
|
-
|
|
77
|
-
* Added `afterMatchFailed` callback to *contentEditable*
|
|
78
|
-
It will be invoked after fail to match any query and stopping matching.
|
|
79
|
-
Open *examples/hashtas.html* to examine how it work.
|
|
80
|
-
* Removed `inserting_wrapper` callback to *contentEditable*
|
|
81
|
-
|
|
82
|
-
#### Internal changes:
|
|
83
|
-
|
|
84
|
-
* refactor the `Controller`
|
|
85
|
-
Introduced `EditableController` class to control actions of `contenteditable` element.
|
|
86
|
-
Introduced `TextareaController` class to control actions of `textarea` element.
|
|
87
|
-
Both of them are inherit from the `Controller` class.
|
|
88
|
-
|
|
89
|
-
* Refactored contentEditable mode
|
|
90
|
-
Inserted content are wrapped in a span: `<span class=".atwho-inserted"/>`
|
|
91
|
-
Querying content are wrapped in a span: `<span class=".atwho-query"/>`
|
|
92
|
-
|
|
93
|
-
* Bring back auto-discovery to iframe.
|
|
94
|
-
* Fix wrong offset in iframe
|
|
95
|
-
* Replaced `iframeStandalone` with `iframeAdRoot`
|
|
96
|
-
* All processed events are preventing default and stopping propagation.
|
|
97
|
-
|
|
98
|
-
### v0.5.2
|
|
99
|
-
|
|
100
|
-
* e1f6566 - fix error that doesn't display mention list on new line
|
|
101
|
-
* 8fe3a54 - can insert multiple node from `inserting_wrapper`
|
|
102
|
-
* 4080151 - scroll to top after showing
|
|
103
|
-
* 01555f8 - scroll long dropdown list
|
|
104
|
-
* 1b8999d - Add spm support
|
|
105
|
-
* f2b8e9c - change name in package.json
|
|
106
|
-
* b61bfdc - search on click
|
|
107
|
-
* b1efd09 - Fixes error with selecting always first item on the list on iOS WebView when using https://github.com/ftlabs/fastclick
|
|
108
|
-
* 7ed2890 - Allow accented characters in matcher
|
|
109
|
-
|
|
110
|
-
### v0.5.1
|
|
111
|
-
|
|
112
|
-
* 219de3d - fix Goes off screen / gets cropped if there isn't enough room
|
|
113
|
-
* 1100c5b - No longer inherits text colour from document
|
|
114
|
-
* ce60958 - on more boolean argument for `setIframe` api to work cross-document issues #199
|
|
115
|
-
|
|
116
|
-
### v0.5.0
|
|
117
|
-
|
|
118
|
-
* 593893c - refactor inserting of contenteditable
|
|
119
|
-
Adding `inserting_wrapper` for customize wrapping inserting content.
|
|
120
|
-
Not to insert item as a block in Firefox. check out issue #109.
|
|
121
|
-
Removing `getInsertedItems`, `getInsertedIDs` API. You have to collect them on your own.
|
|
122
|
-
* 4d3fb8f - have to set IFRAME manually
|
|
123
|
-
* 1f13a16 - change space_after to suffix
|
|
124
|
-
* b099ebb - fix caret position error after inserting
|
|
125
|
-
* 2c47d7a - fix #178 hide view while clicking somewhere else
|
|
126
|
-
|
|
127
|
-
### v0.4.12
|
|
128
|
-
|
|
129
|
-
* eeafab1 - fix error: will always call hidden atwho event
|
|
130
|
-
* b0f6ceb - Highlighter finds the first occurrence
|
|
131
|
-
* da256db - Adds possibility of having empty prefix (at keyword) in controllers
|
|
132
|
-
* b884225 - add `space_after` option
|
|
133
|
-
* 65d6273 - Passes esc/tab/return keyup events through to emitted hide event
|
|
134
|
-
|
|
135
|
-
### v0.4.11
|
|
136
|
-
|
|
137
|
-
* bf938db - add `delay` setting, support delay searching
|
|
138
|
-
* a0b5a6f - fix bug: terminate if query out of max_len
|
|
139
|
-
* 01d6d5b - add css min file
|
|
140
|
-
|
|
141
|
-
### v0.4.10
|
|
142
|
-
|
|
143
|
-
* update jquery dependence version
|
|
144
|
-
|
|
145
|
-
### v0.4.9
|
|
146
|
-
|
|
147
|
-
* f317bd7 not lowercase query, add `highlight_first` option
|
|
148
|
-
|
|
149
|
-
### v0.4.8
|
|
150
|
-
|
|
151
|
-
* 79bbef4 destroy atwho view container dom
|
|
152
|
-
* 0372d65 update bower and component keywords
|
|
153
|
-
* 52a41f5 add optional `before_repostion` callback
|
|
154
|
-
* cc1c239 Fixes #143 - ichord
|
|
155
|
-
|
|
156
|
-
### v0.4.7
|
|
157
|
-
|
|
158
|
-
* resolved #133, #135, #137.
|
|
159
|
-
* add `beforeDestroy` event
|
|
160
|
-
* wouldn't concat `caret.js` into `dist/js/jquery.atwho.js` any more.
|
|
161
|
-
* seperate `jquery.atwho.coffee` into pieces.
|
|
162
|
-
* seperate testing.
|
|
163
|
-
|
|
164
|
-
### v0.4.6
|
|
165
|
-
|
|
166
|
-
* 2d9ab23 fix `wrong document` error in IE iframe
|
|
167
|
-
|
|
168
|
-
### v0.4.5
|
|
169
|
-
|
|
170
|
-
* 664a765 support iframe
|
|
171
|
-
|
|
172
|
-
### v0.4.4
|
|
173
|
-
|
|
174
|
-
* 9ac7e75 - improve contentEditable for IE 8
|
|
175
|
-
|
|
176
|
-
It's still some bugs in IE 8, just DON'T use it
|
|
177
|
-
I don't want to spend more time on IE 8.
|
|
178
|
-
So it would be the ending fixup. And i will still leave related code for
|
|
179
|
-
a while maybe in case anyone want to help to improve it.
|
|
180
|
-
Just encourge your users to upgrate the browers or just switch to a
|
|
181
|
-
batter one please !!
|
|
182
|
-
|
|
183
|
-
* a8371b3 - move project page to master from gh-pages.
|
|
184
|
-
* 24b6225 - fix bugs #122
|
|
185
|
-
* 645e030 - update Caret.js to v0.0.5
|
|
186
|
-
|
|
187
|
-
### v0.4.3
|
|
188
|
-
|
|
189
|
-
* e8e7561 update `Caret.js` to `v0.0.4`
|
|
190
|
-
|
|
191
|
-
### v0.4.2
|
|
192
|
-
|
|
193
|
-
* 4169b74 - binding data storage to the inputor. issues #121
|
|
194
|
-
* 11d053f - reduse querying twice. issues#112
|
|
195
|
-
|
|
196
|
-
### v0.4.1
|
|
197
|
-
|
|
198
|
-
* b7721be - fix bug at view id was not been assign. close issues #99
|
|
199
|
-
* 407f069 - fix bug: Can not autofocus after click the at-list in FireFox. #95
|
|
200
|
-
* 917f033 - fix bug: click do not work in div-contenteditable. close issues #93
|
|
201
|
-
|
|
202
|
-
### v0.4.0
|
|
203
|
-
|
|
204
|
-
* update `Caret.js` to `v0.0.2`
|
|
205
|
-
* `contenteditable` support !!
|
|
206
|
-
* change content of default item template `tpl`
|
|
207
|
-
* new rule to insert the `at` : will always remove the `at` from inputor but will add it back from `tpl` in default.
|
|
208
|
-
so, if you are using your own `tpl` and want to show the `at` char, you have to do it yourself.
|
|
209
|
-
* add `insert_tpl` setting for `contenteditable`.
|
|
210
|
-
it will insert `data-value` of li element that eval from `tpl` in default.
|
|
211
|
-
* new APIs for `contenteditable`: `getInsertedItemsWithIDs`, `getInsertedItems`, `getInsertedIDs`
|
|
212
|
-
|
|
213
|
-
### 2013-08-07 - v0.3.2
|
|
214
|
-
|
|
215
|
-
* bower
|
|
216
|
-
* remove `Caret.js` codes and add it as bower dependencies
|
|
217
|
-
* remove `display_flag` settings.
|
|
218
|
-
* add `start_with_space` settings, default `true`
|
|
219
|
-
* change `super_call` function to `call_default`
|
|
220
|
-
|
|
221
|
-
### 2013-04-28
|
|
222
|
-
|
|
223
|
-
* release new api `load`, `run`
|
|
224
|
-
* add `alias` setting for `load` data or as the view's id
|
|
225
|
-
* matching key with a space before it
|
|
226
|
-
* register key in settings `{at: "@", data: []}` instead of being a argument
|
|
227
|
-
* `max_len` setting for max length to search
|
|
228
|
-
* change the default matcher regrex rule: occur at start of line or after whitespace
|
|
229
|
-
* will not sort the datay without valid query string
|
|
230
|
-
|
|
231
|
-
### 2013-04-23
|
|
232
|
-
|
|
233
|
-
* group all data handlers as `Model` class.
|
|
234
|
-
* All callbacks's context would be current `Controller`
|
|
235
|
-
|
|
236
|
-
### 2013-04-05
|
|
237
|
-
|
|
238
|
-
* `data` setting will be used to load data either local or remote. If it's String as URL it will preload data from remote by launch a ajax request (every times At.js call `reg` to update settings)
|
|
239
|
-
|
|
240
|
-
* remove default `remote_filter` from callbacks list.
|
|
241
|
-
* add `get_data` and `save_data` function to contoller. They are used to get and save whole data for At.js
|
|
242
|
-
* `save_data` will invoke `data_refactor` everytime
|
|
243
|
-
|
|
244
|
-
* will filter local data which is set in `settings` first and if it get nothing then call `remote_filter` if it's exists in callbacks list that is set by user.
|
|
245
|
-
|
|
246
|
-
### 2013-04
|
|
247
|
-
|
|
248
|
-
* remove ability of changing common setting after inputor binded
|
|
249
|
-
* can fix list view after matched query in IE now.
|
|
250
|
-
* separated core function (get offset of inputor) as a jquery plugins.
|
|
251
|
-
|
|
252
|
-
### v0.2.0 - 2012-12
|
|
253
|
-
|
|
254
|
-
**No more testing in IEs browsers.**
|
|
255
|
-
|
|
256
|
-
#### Note
|
|
257
|
-
The name `atWho` was changed to `atwho`.
|
|
258
|
-
|
|
259
|
-
#### New features
|
|
260
|
-
|
|
261
|
-
* Customer data handlers(matcher, filter, sorter) and template renders(highlight, template eval) by a group of configurable callbacks.
|
|
262
|
-
* Support **AMD**
|
|
263
|
-
|
|
264
|
-
#### Removed features
|
|
265
|
-
|
|
266
|
-
* Filter by local data and remote (by ajax) data at the same time.
|
|
267
|
-
* Caching
|
|
268
|
-
* Mouse event
|
|
269
|
-
|
|
270
|
-
#### Changed settings
|
|
271
|
-
|
|
272
|
-
`-` mean removed option
|
|
273
|
-
`+` mean new added option
|
|
274
|
-
The one that start without `-` or `+` mean not change.
|
|
275
|
-
|
|
276
|
-
* `-` data: [],
|
|
277
|
-
* `+` data: null,
|
|
278
|
-
|
|
279
|
-
* `-` choose: "data-value",
|
|
280
|
-
* `+` search_key: "name",
|
|
281
|
-
|
|
282
|
-
* `-` callback: null,
|
|
283
|
-
* `+` callbacks: DEFAULT_CALLBACKS,
|
|
284
|
-
|
|
285
|
-
* `+` display_timeout: 300,
|
|
286
|
-
|
|
287
|
-
* `-` tpl: _DEFAULT_TPL
|
|
288
|
-
* `+` tpl: DEFAULT_TPL
|
|
289
|
-
|
|
290
|
-
* `-` cache: false
|
|
291
|
-
|
|
292
|
-
Not change settings
|
|
293
|
-
|
|
294
|
-
* cache: true,
|
|
295
|
-
* limit: 5,
|
|
296
|
-
* display_flag: true,
|
|
297
|
-
|
|
298
|
-
### v0.1.7
|
|
299
|
-
|
|
300
|
-
同步 `jquery-atwho-rails` gem 的版本号
|
|
301
|
-
这会是 `v0.1` 的固定版本. 不再有新功能更新.
|
|
302
|
-
|
|
303
|
-
###v0.1.2 2012-3-23
|
|
304
|
-
* box showing above instead of bottom when it get close to the bottom of window
|
|
305
|
-
* coffeescript here is.
|
|
306
|
-
* every registered character able to have thire own options such as template(`tpl`)
|
|
307
|
-
* every inputor (textarea, input) able to have their own registered character and different behavior
|
|
308
|
-
even the same character to other inputor
|
|
309
|
-
|
|
310
|
-
###v0.1.0
|
|
311
|
-
* 可以監聽多個字符
|
|
312
|
-
multiple char listening.
|
|
313
|
-
* 顯示缺省列表.
|
|
314
|
-
show default list.
|