diff options
Diffstat (limited to 'luci2')
-rw-r--r-- | luci2/htdocs/luci2/ui.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/luci2/htdocs/luci2/ui.js b/luci2/htdocs/luci2/ui.js index 5ab1ddd..ea08347 100644 --- a/luci2/htdocs/luci2/ui.js +++ b/luci2/htdocs/luci2/ui.js @@ -733,6 +733,26 @@ .attr('title', title ? title : '') .addClass('btn btn-' + style) .text(label); + }, + + icon: function(src, alt, title) + { + if (!src.match(/\.[a-z]+$/)) + src += '.png'; + + if (!src.match(/^\//)) + src = L.globals.resource + '/icons/' + src; + + var icon = $('<img />') + .attr('src', src); + + if (typeof(alt) !== 'undefined') + icon.attr('alt', alt); + + if (typeof(title) !== 'undefined') + icon.attr('title', title); + + return icon; } }; |