-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangular-schema-form-tokenfield.min.js
2 lines (2 loc) · 3.78 KB
/
angular-schema-form-tokenfield.min.js
1
2
angular.module("schemaForm").run(["$templateCache",function(e){e.put("directives/decorators/bootstrap/tokenfield/angular-schema-form-tokenfield.html",'<div class="form-group schema-form-{{form.type}} {{form.htmlClass}}" sf-field-model="sf-new-array" sf-new-array="tokenfield" schema-validate="form" data-ng-controller="angularBootstrapTokenfieldController" data-ng-class="{\'has-error\': form.disableErrorState !== true && hasError(), \'has-success\': form.disableSuccessState !== true && hasSuccess(), \'has-feedback\': form.feedback !== false }" data-ng-model="tokenfield">\n <label class="control-label {{form.labelHtmlClass}}" data-ng-class="{\'sr-only\': !showTitle()}">{{form.title}}</label>\n <input sf-field-model="replaceAll" tokens="form.tokens" limit="form.limit" min-length="form.minLength" min-width="form.minWidth" show-autocomplete-on-focus="form.showAutocompleteOnFocus" autocomplete="form.autocomplete" create-tokens-on-blur="form.createTokensOnBlur" delimiter="form.delimiter" beautify="form.beautify" input-type="form.schema.items.type" type="form.schema.items.type" angular-bootstrap-tokenfield="" data-ng-model="$$value$$">\n\n <div class="help-block" sf-message="form.description"></div>\n\n</div>')}]);
!function(){"use strict";angular.module("schemaForm").config(["schemaFormProvider","schemaFormDecoratorsProvider","sfPathProvider","sfBuilderProvider",function(e,t,n,a){var o=function(t,a,o){if("array"===a.type&&"tokenfield"===a.format){var i=a.items;if("object"!==i.type&&"array"!==i.type){var r=e.stdFormObj(t,a,o);return r.key=o.path,r.type="tokenfield",r.validationMessage={100:"Value is not a multiple of {{schema.items.multipleOf}}",101:"{{value}} contains an item that is less than the minimum of {{schema.items.minimum}}",102:"{{value}} contains an item that is equal to the exclusive minimum {{schema.items.minimum}}",103:"{{value}} contains an item that is greater than the allowed maximum of {{schema.items.maximum}}",104:"{{value}} contains an item that is equal to the exclusive maximum {{schema.items.maximum}}",105:"{{value}} contains an item that is not a valid number",200:"{{value}} contains a string that is too short, minimum {{schema.items.minLength}}",201:"{{value}} contains a string that is too long ({{value.length}} chars), maximum {{schema.items.maxLength}}",202:"{{value}} contains a string that does not match pattern: {{schema.items.pattern}}"},o.lookup[n.stringify(o.path)]=r,r}console.warn("Cannot use tokenfield for arrays of arrays or objects")}};e.defaults.array.unshift(o),t.defineAddOn("bootstrapDecorator","tokenfield","directives/decorators/bootstrap/tokenfield/angular-schema-form-tokenfield.html",a.stdBuilders)}]),angular.module("schemaForm").controller("angularBootstrapTokenfieldController",["$scope",function(e){e.tokenfield=[]}]),angular.module("schemaForm").directive("angularBootstrapTokenfield",function(){var e=function(e,t){var n=e.$parent.form.schema.items.type;return"number"===n||"integer"===n?Number(t):"boolean"===n?Boolean(t):t};return{restrict:"A",require:"ngModel",scope:{tokens:"=",limit:"=",minLength:"=",minWidth:"=",showAutocompleteOnFocus:"=",autocomplete:"=",createTokensOnBlur:"=",delimiter:"=",beautify:"=",inputType:"=",schemaFormModel:"="},link:function(t,n,a,o,i){n.tokenfield(t)[0];t.original=n[0],t.tokenInput=n.siblings(".token-input")[0],t.tokenInput.placeholder="",t.$watch(function(){return n[0]},function(){t.tokenInput.placeholder=t.original.placeholder}),t.$watch(function(){return t.$parent.tokenfield},function(e,t){e!==o.$modelValue&&(o.$modelValue=e,n.tokenfield("setTokens",e.join()))}),o.$parsers.push(function(n){var a=[];return"string"==typeof n?n.indexOf(",")>=0?a=n.split(",").map(function(n){return e(t,n)}):n.length>0&&a.push(e(t,n)):a=n,t.$parent.tokenfield=a,a}),o.$formatters.push(function(e){if(e)return e.constructor===Array?e.join():e})}}})}();