diff --git a/ui/ui.js b/ui/ui.js index c4c06ab5..d22a8eab 100755 --- a/ui/ui.js +++ b/ui/ui.js @@ -363,6 +363,43 @@ function showContextIndicator(cls, text){ * Modal dialogs... */ +/********************************************************* Helpers ***/ + +// Set element text and tooltip +// +// NOTE: when text is a list, we will only use the first and the last +// elements... +// NOTE: if tip_elem is not given then both the text and tip will be set +// on text_elem +// +// XXX add support for quoted '|'... +function setTextWithTooltip(text, text_elem, tip_elem){ + text_elem = $(text_elem) + tip_elem = tip_elem == null ? text_elem : tip_elem + + if(typeof(text) != typeof('str')){ + tip = text + } else { + var tip = text.split(/\s*\|\s*/) + } + + // set elemnt text... + text_elem + .html(tip[0]) + + // do the tooltip... + tip = tip.slice(1) + tip = tip[tip.length-1] + if(tip != null && tip.trim().length > 0){ + $('') + .attr('tooltip', tip) + .appendTo(tip_elem) + } + + return text_elem +} + + function getOverlay(root){ root = $(root) var overlay = root.find('.overlay-block') @@ -595,15 +632,7 @@ var FIELD_TYPES = { val.prop('checked', false) } - var txt = item.find('.item-text') - .html(opts[0]) - - // tooltip... - if(opts.length > 1){ - $('') - .attr('tooltip', opts.pop()) - .appendTo(txt) - } + setTextWithTooltip(opts, item.find('.item-text')) item.appendTo(field) @@ -745,7 +774,10 @@ function formDialog(root, message, config, btn, cls){ var res = $.Deferred() // handle message and btn... - form.append($('