From: Banana Date: Sun, 25 Dec 2016 18:53:21 +0000 (+0100) Subject: datalist with suggestion and modified version to allow entries which are not in the... X-Git-Tag: 2.1-alpha-2019-0-29~55 X-Git-Url: http://91.132.146.200/gitweb/?a=commitdiff_plain;h=edba0970ffd67e7ca8ec5eba3a18b4113a90c705;p=insipid.git datalist with suggestion and modified version to allow entries which are not in the list yet. --- diff --git a/source/flexdatalist/jquery-flexdatalist-1.8.1.zip b/source/flexdatalist/jquery-flexdatalist-1.8.1.zip new file mode 100644 index 0000000..7ca3757 Binary files /dev/null and b/source/flexdatalist/jquery-flexdatalist-1.8.1.zip differ diff --git a/source/flexdatalist/jquery.flexdatalist.inspid.js b/source/flexdatalist/jquery.flexdatalist.inspid.js new file mode 100644 index 0000000..ce224a2 --- /dev/null +++ b/source/flexdatalist/jquery.flexdatalist.inspid.js @@ -0,0 +1,1200 @@ +/** + * jQuery Flexdatalist. + * Autocomplete for input fields with support for datalists. + * + * Version: + * 1.8.0 + * + * Depends: + * jquery.js 1.7+ + * + * Demo and Documentation: + * http://projects.sergiodinislopes.pt/flexdatalist/ + * + * Github: + * https://github.com/sergiodlopes/jquery-flexdatalist/ + * + */ + +jQuery.fn.flexdatalist = function (options, value) { + 'use strict'; + var $document = $(document), + $input = $(this), + input, + _this = this; + +/** + * Each iteration. + */ + input = function () { + var $this = $(this), + _cache = {}, + _previousText = '', + _requestTimeout = null, + _inputName = $this.attr('name'); + + if ($this.hasClass('flexdatalist-set')) { + _this._destroy($this); + } + + /** + * Option management. + */ + $this._options = function (option, _value) { + var _options = $this.data('flexdatalist'); + if (!_this._isDefined(option)) { + return $this.data('flexdatalist'); + } else if (_this._isDefined(_value)) { + _options[option] = _value; + } else if (!_this._isObject(option)) { + return (_this._isDefined(_options, option) ? _options[option] : null); + } else { + _options = option; + } + + _options.searchIn = _this._csvToArray(_options.searchIn); + _options.relatives = _options.relatives && $(_options.relatives).length > 0 ? $(_options.relatives) : null; + _options.textProperty = _options.textProperty === null ? _options.searchIn[0] : _options.textProperty; + _options.visibleProperties = _this._csvToArray(_options.visibleProperties, _options.searchIn); + $this.data('flexdatalist', _options); + return $this; + } + + $this._options($.extend({ + url: null, + data: [], + params: {}, + relatives: null, + chainedRelatives: false, + cache: true, + minLength: 2, + groupBy: false, + selectionRequired: false, + focusFirstResult: false, + textProperty: null, + valueProperty: null, + visibleProperties: [], + searchIn: ['label'], + searchContain: false, + searchEqual: false, + searchDisabled: false, // New + normalizeString: null, + multiple: $this.attr('multiple'), + maxShownResults: 100, + noResultsText: 'No results found for "{keyword}"', + toggleSelected: false, // New + _values: [] + }, options, $this.data()) + ); + + // Handle multiple values + var $_this = $this + .clone(false) + .attr({ + 'list': null, + 'name': null, + 'id': ($this.attr('id') ? $this.attr('id') + '-flexdatalist' : null) + }) + .addClass('flexdatalist-alias') + .removeClass('flexdatalist'); + if ($this._options('multiple')) { + var $ulMultiple = $('