wire/modules/Inputfield/InputfieldTextTags/InputfieldTextTags.js
// initialize select with predefined selectable tags, optionally with user-entered as well
initialize select with predefined selectable tags, optionally with user-entered as well
initialize select with predefined selectable tags optionally with user - entered as well
function initSelect($select) {
		var o = JSON.parse($select.attr('data-opts'));
		var cfgName = typeof o.cfgName === "undefined" ? '' : o.cfgName;
		var tags = cfgName.length ? ProcessWire.config[cfgName] : o.tags;
		var tagsList = [];
		var n = 0;
		for(var tag in tags) {
			var label = tags[tag];
			tagsList[n] = { value: tag, label: label };
			n++;
		}
		var options = jQuery.extend(defaults, {
			allowUserTags: o.allowUserTags,
			delimiter: o.delimiter,
			closeAfterSelect: o.closeAfterSelect,
			createOnBlur: o.createOnBlur,
			maxItems: (o.maxItems > 0 ? o.maxItems : null),
			plugins: (o.maxItems === 1 ? pluginsSingle : pluginsMulti),
			persist: true,
			valueField: 'value',
			labelField: 'label',
			searchField: [ 'value', 'label' ],
			options: tagsList,
			createFilter: function(input) {
				if(o.allowUserTags) return true;
				var allow = false;
				for(var n = 0; n < tags.length; n++) {
					if(typeof tags[input] !== "undefined") {
						allow = true;
						break;
					}
				}
				return allow;
			},
			render: {
				item: function(item, escape) {
					if(typeof item.label === "undefined" || !item.label.length) item.label = item.value;
					return '<div>' + escape(item.label) + '</div>';
				},
				option: function(item, escape) {
					if(typeof item.label === "undefined" || !item.label.length) item.label = item.value;
					return '<div>' + escape(item.label) + '</div>';
				}
			}
		});
		if(o.tagsUrl.length) {
			options.load = function(query, callback) {
				if(!query.length) return callback();
				var tagsUrl = o.tagsUrl.replace('{q}', encodeURIComponent(query));
				Inputfields.startSpinner($select);
				jQuery.ajax({
					url: tagsUrl,
					type: 'GET',
					error: function() {
						Inputfields.stopSpinner($select);
						callback(); 
					},
					success: function(items) { 
						for(var n = 0; n < items.length; n++) {
							var item = items[n];
							if(typeof item === "object") {
								if(typeof item.label === "undefined") {
									item.label = item.value;
									items[n] = item;
								}
							} else {
								items[n] = { value: item, label: item };
							}
						}
						Inputfields.stopSpinner($select);
						callback(items);
					}
				});
			}
		}
		$select.selectize(options);
	}
function initSelect ( $select ) { var o = JSON . parse ( $select . attr ( 'data-opts' ) ) ; var cfgName = typeof o . cfgName === "undefined" ? '' : o . cfgName ; var tags = cfgName . length ? ProcessWire . config [ cfgName ] : o . tags ; var tagsList = [ ] ; var n = 0 ; for ( var tag in tags ) { var label = tags [ tag ] ; tagsList [ n ] = { value : tag , label : label } ; n ++ ; } var options = jQuery . extend ( defaults , { allowUserTags : o . allowUserTags , delimiter : o . delimiter , closeAfterSelect : o . closeAfterSelect , createOnBlur : o . createOnBlur , maxItems : ( o . maxItems > 0 ? o . maxItems : null ) , plugins : ( o . maxItems === 1 ? pluginsSingle : pluginsMulti ) , persist : true , valueField : 'value' , labelField : 'label' , searchField : [ 'value' , 'label' ] , options : tagsList , createFilter : function ( input ) { if ( o . allowUserTags ) return true ; var allow = false ; for ( var n = 0 ; n < tags . length ; n ++ ) { if ( typeof tags [ input ] !== "undefined" ) { allow = true ; break ; } } return allow ; } , render : { item : function ( item , escape ) { if ( typeof item . label === "undefined" || ! item . label . length ) item . label = item . value ; return '<div>' + escape ( item . label ) + '</div>' ; } , option : function ( item , escape ) { if ( typeof item . label === "undefined" || ! item . label . length ) item . label = item . value ; return '<div>' + escape ( item . label ) + '</div>' ; } } } ) ; if ( o . tagsUrl . length ) { options . load = function ( query , callback ) { if ( ! query . length ) return callback ( ) ; var tagsUrl = o . tagsUrl . replace ( '{q}' , encodeURIComponent ( query ) ) ; Inputfields . startSpinner ( $select ) ; jQuery . ajax ( { url : tagsUrl , type : 'GET' , error : function ( ) { Inputfields . stopSpinner ( $select ) ; callback ( ) ; } , success : function ( items ) { for ( var n = 0 ; n < items . length ; n ++ ) { var item = items [ n ] ; if ( typeof item === "object" ) { if ( typeof item . label === "undefined" ) { item . label = item . value ; items [ n ] = item ; } } else { items [ n ] = { value : item , label : item } ; } } Inputfields . stopSpinner ( $select ) ; callback ( items ) ; } } ) ; } } $select . selectize ( options ) ; }
initialize select with predefined selectable tags, optionally with user-entered as well
initialize select with predefined selectable tags optionally with user - entered as well
/*
			onDropdownOpen: function($dropdown) {
				$dropdown.closest('li, .InputfieldImageEdit').css('z-index', 100);
			},
			onDropdownClose: function($dropdown) {
				$dropdown.closest('li, .InputfieldImageEdit').css('z-index', 'auto');
			},
			*/