angular-tags-input
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "angular-local-storage", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"main": "ng-tags-input.min.js", | ||
@@ -5,0 +5,0 @@ "description": "Angular Tags Input module", |
@@ -1,1 +0,1 @@ | ||
/*! ngTagsInput v1.1.1 License: MIT */!function(){"use strict";var a={backspace:8,tab:9,enter:13,escape:27,space:32,up:38,down:40,comma:188},b=angular.module("ngTagsInput",[]);b.directive("tagsInput",["$timeout","$document","tagsInputConfig",function(b,c,d){function e(){var a={};return{on:function(b,c){a[b]||(a[b]=[]),a[b].push(c)},trigger:function(b,c){angular.forEach(a[b],function(a){a.call(null,c)})}}}return{restrict:"E",require:"ngModel",scope:{tags:"=ngModel",onTagAdded:"&",onTagRemoved:"&"},replace:!1,transclude:!0,templateUrl:"ngTagsInput/tags-input.html",controller:["$scope","$attrs","$element",function(a,b,c){var f;d.load("tagsInput",a,b,{customClass:[String],placeholder:[String,"Add a tag"],tabindex:[Number],removeTagSymbol:[String,String.fromCharCode(215)],replaceSpacesWithDashes:[Boolean,!0],minLength:[Number,3],maxLength:[Number],addOnEnter:[Boolean,!0],addOnSpace:[Boolean,!1],addOnComma:[Boolean,!0],addOnBlur:[Boolean,!0],allowedTagsPattern:[RegExp,/^[a-zA-Z0-9\s]+$/],enableEditingLastTag:[Boolean,!1],minTags:[Number],maxTags:[Number]}),a.events=new e,a.events.on("tag-added",a.onTagAdded),a.events.on("tag-removed",a.onTagRemoved),a.newTag="",a.tags=a.tags||[],a.tryAdd=function(){var b=!1,c=a.newTag;return c.length>=a.options.minLength&&a.options.allowedTagsPattern.test(c)&&(a.options.replaceSpacesWithDashes&&(c=c.replace(/\s/g,"-")),-1===a.tags.indexOf(c)&&(a.tags.push(c),a.events.trigger("tag-added",{$tag:c})),a.newTag="",a.events.trigger("input-change",""),b=!0),b},a.tryRemoveLast=function(){var b=!1;return a.tags.length>0&&(a.options.enableEditingLastTag?a.newTag=a.remove(a.tags.length-1):f?(a.remove(a.tags.length-1),f=!1):f=!0,b=!0),b},a.remove=function(b){var c=a.tags.splice(b,1)[0];return a.events.trigger("tag-removed",{$tag:c}),c},a.getCssClass=function(b){var c=b===a.tags.length-1;return f&&c?"selected":""},a.$watch(function(){return a.newTag.length>0},function(){f=!1}),this.registerAutocomplete=function(){var b=c.find("input");return b.on("keydown",function(b){a.events.trigger("input-keydown",b)}),a.newTagChange=function(){a.events.trigger("input-change",a.newTag)},{tryAddTag:function(b){return a.newTag=b,a.tryAdd()},focusInput:function(){b[0].focus()},getTags:function(){return a.tags},on:function(b,c){return a.events.on(b,c),this}}}}],link:function(d,e,f,g){var h=[a.enter,a.comma,a.space,a.backspace],i=e.find("input");i.on("keydown",function(b){if(!b.isImmediatePropagationStopped||!b.isImmediatePropagationStopped()){var c=b.keyCode,e=b.shiftKey||b.altKey||b.ctrlKey||b.metaKey;e||-1===h.indexOf(c)||(c===a.enter&&d.options.addOnEnter||c===a.comma&&d.options.addOnComma||c===a.space&&d.options.addOnSpace?(d.tryAdd()&&d.$apply(),b.preventDefault()):c===a.backspace&&0===this.value.length&&d.tryRemoveLast()&&(d.$apply(),b.preventDefault()))}}).on("focus",function(){d.hasFocus||(d.hasFocus=!0,d.$apply())}).on("blur",function(){b(function(){var a=angular.element(c[0].activeElement).parent();a[0]!==e[0]&&(d.hasFocus=!1,d.options.addOnBlur&&d.tryAdd(),d.events.trigger("input-blur"),d.$apply())},0,!1)}),e.find("div").on("click",function(){i[0].focus()}),d.$watch("tags.length",function(){g.$setValidity("maxTags",angular.isUndefined(d.options.maxTags)||d.tags.length<=d.options.maxTags),g.$setValidity("minTags",angular.isUndefined(d.options.minTags)||d.tags.length>=d.options.minTags)})}}}]),b.directive("autoComplete",["$document","$timeout","$sce","tagsInputConfig",function(b,c,d,e){function f(a,b){var d,e,f,g={};return e=function(a,b){var c=[];return a.forEach(function(a){-1===b.indexOf(a)&&c.push(a)}),c},g.reset=function(){f=null,g.items=[],g.visible=!1,g.index=-1,g.selected=null,g.query=null,c.cancel(d)},g.show=function(){g.selected=null,g.visible=!0},g.load=function(h,i){return h.length<b.minLength?(g.reset(),void 0):(c.cancel(d),d=c(function(){g.query=h;var b=a({$query:h});f=b,b.then(function(a){b===f&&(g.items=e(a.data||a,i),g.items.length>0?g.show():g.reset())})},b.debounceDelay,!1),void 0)},g.selectNext=function(){g.select(++g.index)},g.selectPrior=function(){g.select(--g.index)},g.select=function(a){0>a?a=g.items.length-1:a>=g.items.length&&(a=0),g.index=a,g.selected=g.items[a]},g.reset(),g}function g(a){return a.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}return{restrict:"E",require:"^tagsInput",scope:{source:"&"},templateUrl:"ngTagsInput/auto-complete.html",link:function(c,h,i,j){var k,l,m,n=[a.enter,a.tab,a.escape,a.up,a.down];e.load("autoComplete",c,i,{debounceDelay:[Number,100],minLength:[Number,3],highlightMatchedText:[Boolean,!0],maxResultsToShow:[Number,10]}),l=j.registerAutocomplete(),k=new f(c.source,c.options),m=c.options.highlightMatchedText?function(a,b){var c=new RegExp(b,"gi");return a.replace(c,"**$&**")}:function(a){return a},c.suggestionList=k,c.addSuggestion=function(){var a=!1;return k.selected&&(l.tryAddTag(k.selected),k.reset(),l.focusInput(),a=!0),a},c.highlight=function(a){return a=m(a,k.query),a=g(a),a=a.replace(/\*\*(.+?)\*\*/g,"<em>$1</em>"),d.trustAsHtml(a)},l.on("input-change",function(a){a?k.load(a,l.getTags()):k.reset()}).on("input-keydown",function(b){var d,e;if(-1!==n.indexOf(b.keyCode)){var f=!1;b.stopImmediatePropagation=function(){f=!0,b.stopPropagation()},b.isImmediatePropagationStopped=function(){return f},k.visible&&(d=b.keyCode,e=!1,d===a.down?(k.selectNext(),e=!0):d===a.up?(k.selectPrior(),e=!0):d===a.escape?(k.reset(),e=!0):(d===a.enter||d===a.tab)&&(e=c.addSuggestion()),e&&(b.preventDefault(),b.stopImmediatePropagation(),c.$apply()))}}).on("input-blur",function(){k.reset()}),b.on("click",function(){k.visible&&(k.reset(),c.$apply())})}}}]),b.directive("tiTranscludeAppend",function(){return function(a,b,c,d,e){e(function(a){b.append(a)})}}),b.directive("tiAutosize",function(){return{restrict:"A",require:"ngModel",link:function(a,b,c,d){var e,f;e=angular.element('<span class="tag-input"></span>'),e.css("display","none").css("visibility","hidden").css("width","auto"),b.parent().append(e),f=function(a){var c=a;angular.isString(a)&&0===a.length&&(a=b.attr("placeholder")),e.text(a),e.css("display","");try{b.css("width",e.prop("offsetWidth")+"px")}finally{e.css("display","none")}return c},d.$parsers.unshift(f),d.$formatters.unshift(f)}}}),b.provider("tagsInputConfig",function(){var a={};this.setDefaults=function(b,c){return a[b]=c,this},this.$get=["$interpolate",function(b){var c={};return c[String]=function(a){return a},c[Number]=function(a){return parseInt(a,10)},c[Boolean]=function(a){return"true"===a.toLowerCase()},c[RegExp]=function(a){return new RegExp(a)},{load:function(d,e,f,g){e.options={},angular.forEach(g,function(g,h){var i=f[h]&&b(f[h])(e.$parent),j=c[g[0]],k=function(b){var c=a[d]&&a[d][b];return angular.isDefined(c)?c:g[1]};e.options[h]=i?j(i):k(h)})}}}]}),b.run(["$templateCache",function(a){a.put("ngTagsInput/tags-input.html",'<div class="ngTagsInput" tabindex="-1" ng-class="options.customClass" ti-transclude-append=""><div class="tags" ng-class="{focused: hasFocus}"><ul class="tag-list"><li class="tag-item" ng-repeat="tag in tags" ng-class="getCssClass($index)"><span>{{tag}}</span> <button type="button" ng-click="remove($index)">{{options.removeTagSymbol}}</button></li></ul><input class="tag-input" placeholder="{{options.placeholder}}" maxlength="{{options.maxLength}}" tabindex="{{options.tabindex}}" ng-model="newTag" ng-change="newTagChange()" ti-autosize=""></div></div>'),a.put("ngTagsInput/auto-complete.html",'<div class="autocomplete" ng-show="suggestionList.visible"><ul class="suggestion-list"><li class="suggestion-item" ng-repeat="item in suggestionList.items | limitTo:options.maxResultsToShow" ng-class="{selected: item == suggestionList.selected}" ng-click="addSuggestion()" ng-mouseenter="suggestionList.select($index)" ng-bind-html="highlight(item)"></li></ul></div>')}])}(); | ||
/*! ngTagsInput v1.1.1 License: MIT */!function(){"use strict";var a={backspace:8,tab:9,enter:13,escape:27,space:32,up:38,down:40,comma:188},b=angular.module("ngTagsInput",[]);b.directive("tagsInput",["$timeout","$document","tagsInputConfig",function(b,c,d){function e(){var a={};return{on:function(b,c){a[b]||(a[b]=[]),a[b].push(c)},trigger:function(b,c){angular.forEach(a[b],function(a){a.call(null,c)})}}}return{restrict:"E",require:"ngModel",scope:{tags:"=ngModel",onTagAdded:"&",onTagRemoved:"&"},replace:!1,transclude:!0,templateUrl:"ngTagsInput/tags-input.html",controller:["$scope","$attrs","$element",function(a,b,c){var f;d.load("tagsInput",a,b,{customClass:[String],placeholder:[String,"Add a tag"],tabindex:[Number],removeTagSymbol:[String,String.fromCharCode(215)],replaceSpacesWithDashes:[Boolean,!0],minLength:[Number,3],maxLength:[Number],addOnEnter:[Boolean,!0],addOnSpace:[Boolean,!1],addOnComma:[Boolean,!0],addOnBlur:[Boolean,!0],allowedTagsPattern:[RegExp,/^[a-zA-Z0-9\s]+$/],enableEditingLastTag:[Boolean,!1],minTags:[Number],maxTags:[Number],formName:[String]}),a.events=new e,a.events.on("tag-added",a.onTagAdded),a.events.on("tag-removed",a.onTagRemoved),a.newTag="",a.tags=a.tags||[],a.tryAdd=function(){var b=!1,c=a.newTag;return c.length>=a.options.minLength&&a.options.allowedTagsPattern.test(c)&&(a.options.replaceSpacesWithDashes&&(c=c.replace(/\s/g,"-")),-1===a.tags.indexOf(c)&&(a.tags.push(c),a.events.trigger("tag-added",{$tag:c})),a.newTag="",a.events.trigger("input-change",""),b=!0),b},a.tryRemoveLast=function(){var b=!1;return a.tags.length>0&&(a.options.enableEditingLastTag?a.newTag=a.remove(a.tags.length-1):f?(a.remove(a.tags.length-1),f=!1):f=!0,b=!0),b},a.remove=function(b){var c=a.tags.splice(b,1)[0];return a.events.trigger("tag-removed",{$tag:c}),c},a.getCssClass=function(b){var c=b===a.tags.length-1;return f&&c?"selected":""},a.$watch(function(){return a.newTag.length>0},function(){f=!1}),this.registerAutocomplete=function(){var b=c.find("input");return b.on("keydown",function(b){a.events.trigger("input-keydown",b)}),a.newTagChange=function(){a.events.trigger("input-change",a.newTag)},{tryAddTag:function(b){return a.newTag=b,a.tryAdd()},focusInput:function(){b[0].focus()},getTags:function(){return a.tags},on:function(b,c){return a.events.on(b,c),this}}}}],link:function(d,e,f,g){var h=[a.enter,a.comma,a.space,a.backspace],i=e.find("input");i.on("keydown",function(b){if(!b.isImmediatePropagationStopped||!b.isImmediatePropagationStopped()){var c=b.keyCode,e=b.shiftKey||b.altKey||b.ctrlKey||b.metaKey;e||-1===h.indexOf(c)||(c===a.enter&&d.options.addOnEnter||c===a.comma&&d.options.addOnComma||c===a.space&&d.options.addOnSpace?(d.tryAdd()&&d.$apply(),b.preventDefault()):c===a.backspace&&0===this.value.length&&d.tryRemoveLast()&&(d.$apply(),b.preventDefault()))}}).on("focus",function(){d.hasFocus||(d.hasFocus=!0,d.$apply())}).on("blur",function(){b(function(){var a=angular.element(c[0].activeElement).parent();a[0]!==e[0]&&(d.hasFocus=!1,d.options.addOnBlur&&d.tryAdd(),d.events.trigger("input-blur"),d.$apply())},0,!1)}),e.find("div").on("click",function(){i[0].focus()}),d.$watch("tags.length",function(){g.$setValidity("maxTags",angular.isUndefined(d.options.maxTags)||d.tags.length<=d.options.maxTags),g.$setValidity("minTags",angular.isUndefined(d.options.minTags)||d.tags.length>=d.options.minTags)})}}}]),b.directive("autoComplete",["$document","$timeout","$sce","tagsInputConfig",function(b,c,d,e){function f(a,b){var d,e,f,g={};return e=function(a,b){var c=[];return a.forEach(function(a){-1===b.indexOf(a)&&c.push(a)}),c},g.reset=function(){f=null,g.items=[],g.visible=!1,g.index=-1,g.selected=null,g.query=null,c.cancel(d)},g.show=function(){g.selected=null,g.visible=!0},g.load=function(h,i){return h.length<b.minLength?(g.reset(),void 0):(c.cancel(d),d=c(function(){g.query=h;var b=a({$query:h});f=b,b.then(function(a){b===f&&(g.items=e(a.data||a,i),g.items.length>0?g.show():g.reset())})},b.debounceDelay,!1),void 0)},g.selectNext=function(){g.select(++g.index)},g.selectPrior=function(){g.select(--g.index)},g.select=function(a){0>a?a=g.items.length-1:a>=g.items.length&&(a=0),g.index=a,g.selected=g.items[a]},g.reset(),g}function g(a){return a.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}return{restrict:"E",require:"^tagsInput",scope:{source:"&"},templateUrl:"ngTagsInput/auto-complete.html",link:function(c,h,i,j){var k,l,m,n=[a.enter,a.tab,a.escape,a.up,a.down];e.load("autoComplete",c,i,{debounceDelay:[Number,100],minLength:[Number,3],highlightMatchedText:[Boolean,!0],maxResultsToShow:[Number,10]}),l=j.registerAutocomplete(),k=new f(c.source,c.options),m=c.options.highlightMatchedText?function(a,b){var c=new RegExp(b,"gi");return a.replace(c,"**$&**")}:function(a){return a},c.suggestionList=k,c.addSuggestion=function(){var a=!1;return k.selected&&(l.tryAddTag(k.selected),k.reset(),l.focusInput(),a=!0),a},c.highlight=function(a){return a=m(a,k.query),a=g(a),a=a.replace(/\*\*(.+?)\*\*/g,"<em>$1</em>"),d.trustAsHtml(a)},l.on("input-change",function(a){a?k.load(a,l.getTags()):k.reset()}).on("input-keydown",function(b){var d,e;if(-1!==n.indexOf(b.keyCode)){var f=!1;b.stopImmediatePropagation=function(){f=!0,b.stopPropagation()},b.isImmediatePropagationStopped=function(){return f},k.visible&&(d=b.keyCode,e=!1,d===a.down?(k.selectNext(),e=!0):d===a.up?(k.selectPrior(),e=!0):d===a.escape?(k.reset(),e=!0):(d===a.enter||d===a.tab)&&(e=c.addSuggestion()),e&&(b.preventDefault(),b.stopImmediatePropagation(),c.$apply()))}}).on("input-blur",function(){k.reset()}),b.on("click",function(){k.visible&&(k.reset(),c.$apply())})}}}]),b.directive("tiTranscludeAppend",function(){return function(a,b,c,d,e){e(function(a){b.append(a)})}}),b.directive("tiAutosize",function(){return{restrict:"A",require:"ngModel",link:function(a,b,c,d){var e,f;e=angular.element('<span class="tag-input"></span>'),e.css("display","none").css("visibility","hidden").css("width","auto"),b.parent().append(e),f=function(a){var c=a;angular.isString(a)&&0===a.length&&(a=b.attr("placeholder")),e.text(a),e.css("display","");try{b.css("width",e.prop("offsetWidth")+"px")}finally{e.css("display","none")}return c},d.$parsers.unshift(f),d.$formatters.unshift(f)}}}),b.provider("tagsInputConfig",function(){var a={};this.setDefaults=function(b,c){return a[b]=c,this},this.$get=["$interpolate",function(b){var c={};return c[String]=function(a){return a},c[Number]=function(a){return parseInt(a,10)},c[Boolean]=function(a){return"true"===a.toLowerCase()},c[RegExp]=function(a){return new RegExp(a)},{load:function(d,e,f,g){e.options={},angular.forEach(g,function(g,h){var i=f[h]&&b(f[h])(e.$parent),j=c[g[0]],k=function(b){var c=a[d]&&a[d][b];return angular.isDefined(c)?c:g[1]};e.options[h]=i?j(i):k(h)})}}}]}),b.run(["$templateCache",function(a){a.put("ngTagsInput/tags-input.html",'<div class="ngTagsInput" tabindex="-1" ng-class="options.customClass" ti-transclude-append=""><div class="tags" ng-class="{focused: hasFocus}"><ul class="tag-list"><li class="tag-item" ng-repeat="tag in tags" ng-class="getCssClass($index)"><span>{{tag}}</span> <button type="button" ng-click="remove($index)">{{options.removeTagSymbol}}</button></li></ul><input name="{{options.formName}}" class="tag-input" placeholder="{{options.placeholder}}" maxlength="{{options.maxLength}}" tabindex="{{options.tabindex}}" ng-model="newTag" ng-change="newTagChange()" ti-autosize=""></div></div>'),a.put("ngTagsInput/auto-complete.html",'<div class="autocomplete" ng-show="suggestionList.visible"><ul class="suggestion-list"><li class="suggestion-item" ng-repeat="item in suggestionList.items | limitTo:options.maxResultsToShow" ng-class="{selected: item == suggestionList.selected}" ng-click="addSuggestion()" ng-mouseenter="suggestionList.select($index)" ng-bind-html="highlight(item)"></li></ul></div>')}])}(); |
@@ -5,3 +5,3 @@ { | ||
"description": "Angular Tags Input module", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"main": "ng-tags-input.min.js", | ||
@@ -22,3 +22,3 @@ "homepage": "https://github.com/mbenford/ngTagsInput", | ||
}, | ||
"_id": "angular-tags-input@0.0.1", | ||
"_id": "angular-tags-input@0.0.2", | ||
"_from": "angular-tags-input@latest", | ||
@@ -25,0 +25,0 @@ "readme": "# Angular Tags Input module", |
8875