All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.resources.butterfaces-dist-js.butterfaces-maxlength.jquery.min.js Maven / Gradle / Ivy

There is a newer version: 3.5.0
Show newest version
!function(t){t.fn.butterMaxLength=function(e){return this.each(function(n,i){new ButterFaces.MaxLengthIndicator(t(i),e)})}}(jQuery);var ButterFaces;!function(t){var e=function(){function e(t,e){this.rootElement=t,this.options=e,this.valueElement=this.rootElement.find("textarea"),this.maxLengthElement=$("
").addClass("butter-component-maxlength-counter"),this.maxLengthElement.insertAfter(this.valueElement),this.initializeComponent()}return e.prototype.initializeComponent=function(){console.log("ButterFaces.MaxLengthIndicator - initializeComponent"),this.hasInitialValidationError=this.rootElement.hasClass("has-error"),console.log(this.valueElement);var t=this;this.valueElement.on("focus blur keyup cut paste",function(){t.checkValue()}),this.checkValue()},e.prototype.checkValue=function(){var e=this.valueElement.val();if(!t.Object.isNullOrUndefined(e)){console.log("ButterFaces.MaxLengthIndicator: updating maxlength value");var n=this.options.maxLength-e.length,i=t.String.format(this.options.maxLengthText,[n,this.options.maxLength]);this.maxLengthElement.text(i),this.hasInitialValidationError||(n<0?(this.rootElement.addClass("has-error"),this.valueElement.addClass("is-invalid")):(this.rootElement.removeClass("has-error"),this.valueElement.removeClass("is-invalid")))}},e}();t.MaxLengthIndicator=e}(ButterFaces||(ButterFaces={})); //# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImJ1dHRlcmZhY2VzLW1heGxlbmd0aC5qcXVlcnkudHMiXSwibmFtZXMiOlsiJCIsImZuIiwib3B0aW9ucyIsInRoaXMiLCJlYWNoIiwiaW5kZXgiLCJlbGVtZW50IiwiQnV0dGVyRmFjZXMiLCJNYXhMZW5ndGhJbmRpY2F0b3IiLCJqUXVlcnkiLCJyb290RWxlbWVudCIsInZhbHVlRWxlbWVudCIsImZpbmQiLCJtYXhMZW5ndGhFbGVtZW50IiwiYWRkQ2xhc3MiLCJpbnNlcnRB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6IEpRdWVyeTtcbiAgICAgICAgcHJpdmF0ZSBoYXNJbml0aWFsVmFsaWRhdGlvbkVycm9yOiBib29sZWFuO1xuXG4gICAgICAgIGNvbnN0cnVjdG9yKHJvb3RFbGVtZW50OiBKUXVlcnksIG9wdGlvbnM6IE1heExlbmd0aEluZGljYXRvck9wdGlvbnMpIHtcbiAgICAgICAgICAgIHRoaXMucm9vdEVsZW1lbnQgPSByb290RWxlbWVudDtcbiAgICAgICAgICAgIHRoaXMub3B0aW9ucyA9IG9wdGlvbnM7XG4gICAgICAgICAgICB0aGlzLnZhbHVlRWxlbWVudCA9IHRoaXMucm9vdEVsZW1lbnQuZmluZChcInRleHRhcmVhXCIpO1xuICAgICAgICAgICAgdGhpcy5tYXhMZW5ndGhFbGVtZW50ID0gJChcIjxkaXY+XCIpLmFkZENsYXNzKFwiYnV0dGVyLWNvbXBvbmVudC1tYXhsZW5ndGgtY291bnRlclwiKTtcblxuICAgICAgICAgICAgdGhpcy5tYXhMZW5ndGhFbGVtZW50Lmluc2VydEFmdGVyKHRoaXMudmFsdWVFbGVtZW50KTtcblxuICAgICAgICAgICAgdGhpcy5pbml0aWFsaXplQ29tcG9uZW50KCk7XG4gICAgICAgIH1cblxuICAgICAgICBwcml2YXRlIGluaXRpYWxpemVDb21wb25lbnQoKTogdm9pZCB7XG4gICAgICAgICAgICBjb25zb2xlLmxvZyhcIkJ1dHRlckZhY2VzLk1heExlbmd0aEluZGljYXRvciAtIGluaXRpYWxpemVDb21wb25lbnRcIik7XG4gICAgICAgICAgICB0aGlzLmhhc0luaXRpYWxWYWxpZGF0aW9uRXJyb3IgPSB0aGlzLnJvb3RFbGVtZW50Lmhhc0NsYXNzKEVSUk9SX1NUWUxFX0NMQVNTKTtcblxuICAgICAgICAgICAgY29uc29sZS5sb2codGhpcy52YWx1ZUVsZW1lbnQpO1xuICAgICAgICAgICAgbGV0IHRoYXQgPSB0aGlzO1xuICAgICAgICAgICAgdGhpcy52YWx1ZUVsZW1lbnQub24oXCJmb2N1cyBibHVyIGtleXVwIGN1dCBwYXN0ZVwiLCBmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICAgICAgdGhhdC5jaGVja1ZhbHVlKCk7XG4gICAgICAgICAgICB9KTtcblxuICAgICAgICAgICAgLy8gaW5pdGlhbCBjaGVja1xuICAgICAgICAgICAgdGhpcy5jaGVja1ZhbHVlKCk7XG4gICAgICAgIH1cblxuICAgICAgICBwcml2YXRlIGNoZWNrVmFsdWUoKTogdm9pZCB7XG4gICAgICAgICAgICBsZXQgdmFsdWU6IHN0cmluZyA9ICg8c3RyaW5nPnRoaXMudmFsdWVFbGVtZW50LnZhbCgpKTtcblxuICAgICAgICAgICAgaWYgKCFCdXR0ZXJGYWNlcy5PYmplY3QuaXNOdWxsT3JVbmRlZmluZWQodmFsdWUpKSB7XG4gICAgICAgICAgICAgICAgY29uc29sZS5sb2coXCJCdXR0ZXJGYWNlcy5NYXhMZW5ndGhJbmRpY2F0b3I6IHVwZGF0aW5nIG1heGxlbmd0aCB2YWx1ZVwiKTtcbiAgICAgICAgICAgICAgICBsZXQgZnJlZUxldHRlckNvdW50ID0gdGhpcy5vcHRpb25zLm1heExlbmd0aCAtIHZhbHVlLmxlbmd0aDtcbiAgICAgICAgICAgICAgICBsZXQgZm9ybWF0dGVkID0gQnV0dGVyRmFjZXMuU3RyaW5nLmZvcm1hdCh0aGlzLm9wdGlvbnMubWF4TGVuZ3RoVGV4dCwgW2ZyZWVMZXR0ZXJDb3VudCwgdGhpcy5vcHRpb25zLm1heExlbmd0aF0pO1xuICAgICAgICAgICAgICAgIHRoaXMubWF4TGVuZ3RoRWxlbWVudC50ZXh0KGZvcm1hdHRlZCk7XG5cbiAgICAgICAgICAgICAgICBpZiAoIXRoaXMuaGFzSW5pdGlhbFZhbGlkYXRpb25FcnJvcikge1xuICAgICAgICAgICAgICAgICAgICBpZiAoZnJlZUxldHRlckNvdW50IDwgMCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5yb290RWxlbWVudC5hZGRDbGFzcyhFUlJPUl9TVFlMRV9DTEFTUyk7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnZhbHVlRWxlbWVudC5hZGRDbGFzcyhJTlZBTElEX1NUWUxFX0NMQVNTKTtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucm9vdEVsZW1lbnQucmVtb3ZlQ2xhc3MoRVJST1JfU1RZTEVfQ0xBU1MpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy52YWx1ZUVsZW1lbnQucmVtb3ZlQ2xhc3MoSU5WQUxJRF9TVFlMRV9DTEFTUyk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG59Il19




© 2015 - 2024 Weber Informatics LLC | Privacy Policy