Add read-only taglist

This commit is contained in:
Nathan Gray 2013-11-25 18:10:48 +00:00
parent 84420db6ea
commit a5227f2359
3 changed files with 40 additions and 9 deletions

View File

@ -807,15 +807,11 @@ var et2_selectbox_ro = et2_selectbox.extend([et2_IDetachedDOM],
}
}
// Allow some special extras for objects by passing the whole thing - value might not be key
if(typeof _options[key] == 'object' && _options[key] != null && typeof _options[key].value != 'undefined' && _options[key].value != key)
{
// Use value, not key, so it goes into the right place
this.optionValues[_options[key].value] = _options[key];
}
else
{
this.optionValues[key] = _options[key];
var option_id = _options[key].value || _options[key].id || key;
if(option_id != key) {
egw.debug('log', 'Options not indexed. TODO: what is up?', this);
}
this.optionValues[option_id] = _options[key];
}
},
@ -842,7 +838,9 @@ var et2_selectbox_ro = et2_selectbox.extend([et2_IDetachedDOM],
// Not a valid option
continue;
}
this.span.append("<li>"+option+"</li>");
$j("<li>"+option+"</li>")
.attr('data-value', _value[i])
.appendTo(this.span);
}
}
return;

View File

@ -383,6 +383,34 @@ var et2_taglist_email = et2_taglist.extend(
});
et2_register_widget(et2_taglist_email, ["taglist-email"]);
/**
* et2_taglist_ro is the readonly implementation of the taglist.
*
* @augments et2_selectbox
*/
var et2_taglist_ro = et2_selectbox_ro.extend(
{
/**
* Constructor
*
* @memberOf et2_selectbox_ro
*/
init: function() {
this._super.apply(this, arguments);
this.span = jQuery('<div><ul /></div>')
.addClass('et2_taglist_ro');
this.setDOMNode(this.span[0]);
this.span = $j('ul',this.span)
.addClass('ms-sel-ctn');
},
set_value: function(_value) {
this._super.apply(this, arguments);
$j('li',this.span).addClass('ms-sel-item');
}
});
et2_register_widget(et2_taglist_ro, ["taglist_ro","taglist_email_ro" ]);
// Require css
// TODO: merge into etemplate2.css with all other widgets when done
if(typeof egw != 'undefined') egw(window).includeCSS(egw.webserverUrl + "/phpgwapi/js/jquery/magicsuggest/src/magicsuggest-1.3.1.css");

View File

@ -639,6 +639,11 @@ ul.et2_link_string {
background-position: bottom;
background-repeat: repeat-x;
}
.et2_taglist_ro ul {
margin: 0px;
padding: 0px;
}
/**
* VFS widget(s)
*/