X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=js%2FCommon.js;h=0ed3e38c67b131ba9db029c452cbda00595042cc;hb=5e884aa11e68bdba189d729d6cf6c17abf9956df;hp=f4c2a60a6f09eeb0ed0b4eae89e90867f5001d19;hpb=f11c4d96e71e7eb7fe32e12c520f8c8df2a406de;p=civicrm-core.git diff --git a/js/Common.js b/js/Common.js index f4c2a60a6f..0ed3e38c67 100644 --- a/js/Common.js +++ b/js/Common.js @@ -387,7 +387,7 @@ if (!CRM.vars) CRM.vars = {}; description = row.description || $(row.element).data('description'), ret = ''; if (icon) { - ret += ' '; + ret += ' '; } if (color) { ret += ' '; @@ -395,6 +395,35 @@ if (!CRM.vars) CRM.vars = {}; return ret + _.escape(row.text) + (description ? '

' + _.escape(description) + '

' : ''); } + /** + * Helper to generate an icon with alt text. + * + * See also smarty `{icon}` and CRM_Core_Page::crmIcon() functions + * + * @param string icon + * The Font Awesome icon class to use. + * @param string text + * Alt text to display. + * @param mixed condition + * This will only display if this is truthy. + * + * @return string + * The formatted icon markup. + */ + CRM.utils.formatIcon = function (icon, text, condition) { + if (typeof condition !== 'undefined' && !condition) { + return ''; + } + var title = ''; + var sr = ''; + if (text) { + text = _.escape(text); + title = ' title="' + text + '"'; + sr = '' + text + ''; + } + return '' + sr; + }; + /** * Wrapper for select2 initialization function; supplies defaults * @param options object @@ -434,7 +463,7 @@ if (!CRM.vars) CRM.vars = {}; placeholder = settings.placeholder || $el.data('placeholder') || $el.attr('placeholder') || $('option[value=""]', $el).text(); if (m.length && placeholder === m) { iconClass = $el.attr('class').match(/(fa-\S*)/)[1]; - out = ' ' + out; + out = ' ' + out; } return out; }; @@ -704,7 +733,7 @@ if (!CRM.vars) CRM.vars = {}; } _.each(createLinks, function(link) { markup += ' ' + - ' ' + + ' ' + _.escape(link.label) + ''; }); markup += '';