projects
/
project
/
luci2
/
ui.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
c9f002e
)
luci2.ui: add icon() helper function
author
Jo-Philipp Wich
<
[email protected]
>
Fri, 13 Feb 2015 22:37:12 +0000
(23:37 +0100)
committer
Jo-Philipp Wich
<
[email protected]
>
Fri, 13 Feb 2015 22:43:19 +0000
(23:43 +0100)
Signed-off-by: Jo-Philipp Wich <
[email protected]
>
luci2/htdocs/luci2/ui.js
patch
|
blob
|
history
diff --git
a/luci2/htdocs/luci2/ui.js
b/luci2/htdocs/luci2/ui.js
index 5ab1ddd0bb630243f8204a517af9e69b795474fd..ea083472bcae6eaabefb89da8f11279a2805b8c9 100644
(file)
--- 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;
}
};