ONOS-6730: I18n for Topology View.
- Fix bug where localized tooltip function was invoked incorrectly.
Change-Id: I77a68e9fdd1ed3e26789ba59318792c2d500bb57
diff --git a/web/gui/src/main/webapp/app/view/topo/topoToolbar.js b/web/gui/src/main/webapp/app/view/topo/topoToolbar.js
index e9d9752..fa86f82 100644
--- a/web/gui/src/main/webapp/app/view/topo/topoToolbar.js
+++ b/web/gui/src/main/webapp/app/view/topo/topoToolbar.js
@@ -126,10 +126,16 @@
// TODO: use angular forEach instead of d3.map
keyData = d3.map(k2b);
keyData.forEach(function (key, value) {
- var data = api.getActionEntry(key);
+ var data = api.getActionEntry(key),
+ ttfn = data[1]; // tooltip-possibly-a-function
+
value.key = key;
value.cb = data[0]; // on-click callback
- value.tt = data[1] + ' (' + key + ')'; // tooltip
+
+ // tooltip function invoked at the time the tooltip is displayed
+ value.tt = function () {
+ return fs.isF(ttfn) ? ttfn() : "" + ttfn;
+ };
});
}
@@ -137,11 +143,7 @@
function deferredText(v) {
// this function will get invoked at the time the tooltip is displayed:
return function () {
- if (!v.ttText) {
- // haven't cached the value yet
- v.ttText = (fs.isF(v.tt) ? v.tt() : v.tt) + ' (' + v.key + ')';
- }
- return v.ttText;
+ return (fs.isF(v.tt) ? v.tt() : v.tt) + ' (' + v.key + ')';
};
}