From a5227f2359e169cfc1c9fbfc632f209c0a7dc6a4 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 25 Nov 2013 18:10:48 +0000 Subject: [PATCH] Add read-only taglist --- etemplate/js/et2_widget_selectbox.js | 16 ++++++------- etemplate/js/et2_widget_taglist.js | 28 ++++++++++++++++++++++ etemplate/templates/default/etemplate2.css | 5 ++++ 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/etemplate/js/et2_widget_selectbox.js b/etemplate/js/et2_widget_selectbox.js index cdb6ad3797..a6a402b294 100644 --- a/etemplate/js/et2_widget_selectbox.js +++ b/etemplate/js/et2_widget_selectbox.js @@ -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("
  • "+option+"
  • "); + $j("
  • "+option+"
  • ") + .attr('data-value', _value[i]) + .appendTo(this.span); } } return; diff --git a/etemplate/js/et2_widget_taglist.js b/etemplate/js/et2_widget_taglist.js index f397e029fb..aa434eee06 100644 --- a/etemplate/js/et2_widget_taglist.js +++ b/etemplate/js/et2_widget_taglist.js @@ -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('
    ') + .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"); diff --git a/etemplate/templates/default/etemplate2.css b/etemplate/templates/default/etemplate2.css index af72b631c8..96d881997f 100644 --- a/etemplate/templates/default/etemplate2.css +++ b/etemplate/templates/default/etemplate2.css @@ -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) */