Add taglist-cat widget for categories in taglist style

This commit is contained in:
Nathan Gray 2016-02-29 20:29:49 +00:00
parent 73009e2f4e
commit c8c25b35ee
2 changed files with 47 additions and 3 deletions

View File

@ -90,6 +90,9 @@ var et2_taglist = et2_selectbox.extend(
"width": { "width": {
"default": "100%" "default": "100%"
}, },
"height": {
"description": "Maximum allowed height of the result list in pixels"
},
"maxSelection": { "maxSelection": {
"name": "max Selection", "name": "max Selection",
"type": "integer", "type": "integer",
@ -194,9 +197,18 @@ var et2_taglist = et2_selectbox.extend(
highlight: false, // otherwise renderer have to return strings highlight: false, // otherwise renderer have to return strings
selectFirst: true selectFirst: true
}, this.lib_options); }, this.lib_options);
if(this.options.height) {
this.div.css('height','');
this.taglist_options.maxDropHeight = parseInt(this.options.height);
}
this.taglist = this.taglist.magicSuggest(this.taglist_options); this.taglist = this.taglist.magicSuggest(this.taglist_options);
this.$taglist = $j(this.taglist); this.$taglist = $j(this.taglist);
if(this.options.value)
{
this.taglist.addToSelection(this.options.value,true); this.taglist.addToSelection(this.options.value,true);
}
// AJAX _and_ select options - use custom function // AJAX _and_ select options - use custom function
if(this.options.autocomplete_url && !jQuery.isEmptyObject(this.options.select_options)) if(this.options.autocomplete_url && !jQuery.isEmptyObject(this.options.select_options))
@ -802,16 +814,32 @@ var et2_taglist_category = et2_taglist.extend(
} }
}, },
lib_options: { lib_options: {
toggleOnClick: true
}, },
init: function() { init: function() {
this._super.apply(this, arguments); this._super.apply(this, arguments);
this.div.addClass('et2_taglist_category');
}, },
/** /**
* convert _options to taglist data [{id:...,label:...},...] format * Get options automatically from select option cache
* @param {type} _attrs
*/
transformAttributes: function(_attrs) {
// Pretend to be a select box so it works
var type = this._type;
this._type = 'select-cat';
this._super.apply(this, arguments);
this._type = type;
},
/**
* convert selectbox options from the cache to taglist data [{id:...,label:...},...] format
* *
* @param {(object|array)} _options id: label or id: {label: ..., title: ...} pairs, or array if id's are 0, 1, ... * @param {(object|array)} _options id: label or id: {label: ..., title: ...} pairs, or array if id's are 0, 1, ...
*
* @return {Object[]} Returns an array of objects with ID and label
*/ */
_options2data: function(_options) _options2data: function(_options)
{ {
@ -845,7 +873,7 @@ var et2_taglist_category = et2_taglist.extend(
return label; return label;
} }
}); });
et2_register_widget(et2_taglist_category, ["taglist-category"]); et2_register_widget(et2_taglist_category, ["taglist-cat"]);
/** /**

View File

@ -921,6 +921,22 @@ ul.et2_link_string {
.et2_taglist > div { .et2_taglist > div {
min-height: 2em; min-height: 2em;
} }
/* Taglist category */
.et2_taglist_category span[class*="cat_"] {
height: 1.7em;
width: 6px;
margin: -3px -6px;
float: left;
}
.et2_taglist_category .ms-res-item > span {
margin-left: 3px;
}
.et2_taglist_category .ms-sel-item > span:first-child {
padding-left: 5px;
}
/** /**
* VFS widget(s) * VFS widget(s)
*/ */