Support descriptions in plugin embeds (fixes #224)
Change-Id: I65f15113c08d464d6eef2af1186e1ebfa7dab225
diff --git a/dev/js/src/buttongroup.js b/dev/js/src/buttongroup.js
index 31f60c8..c6a772e 100644
--- a/dev/js/src/buttongroup.js
+++ b/dev/js/src/buttongroup.js
@@ -81,7 +81,7 @@
*/
add : function (title, data, cb) {
const b = this._insert('span');
- b.setAttribute('title',title);
+ let desc = title;
if (data !== undefined) {
if (data['cls'] !== undefined) {
@@ -94,9 +94,14 @@
if (data['state'] !== undefined) {
b['state'] = data['state'];
- }
+ };
+
+ if (data['desc'] !== undefined) {
+ desc = data['desc'];
+ };
};
-
+
+ b.setAttribute('title', desc);
b.addE('span').addT(title);
let that = this;
@@ -149,7 +154,7 @@
*/
addToggle : function (title, data, state) {
const b = this._insert('span');
- b.setAttribute('title',title);
+ let desc = title;
if (data != undefined) {
if (data['cls'] !== undefined) {
@@ -158,8 +163,18 @@
data['cls']
);
};
+
+ if (data['icon'] !== undefined) {
+ b.setAttribute('data-icon', data['icon']);
+ };
+
+ if (data['desc'] !== undefined) {
+ desc = data['desc'];
+ };
};
+ b.setAttribute('title',desc);
+
// Set check marker
const check = b.addE('span');
check.classList.add("check", "button-icon");
diff --git a/dev/js/src/plugin/server.js b/dev/js/src/plugin/server.js
index ecf436c..c99f695 100644
--- a/dev/js/src/plugin/server.js
+++ b/dev/js/src/plugin/server.js
@@ -205,7 +205,10 @@
// Button object
- let obj = {'cls':embed["classes"], 'icon': icon }
+ let obj = {'cls':embed["classes"], 'icon': icon };
+
+ if (embed['desc'] != undefined)
+ obj['desc'] = embed['desc'];
if (onClick["action"] && onClick["action"] == "setWidget") {
@@ -231,7 +234,6 @@
}
}
- // TODO There is no possibility to add icons to a plugin toggle button right now.
else if (onClick["action"] == "toggle") {
// TODO:
@@ -244,9 +246,14 @@
onClick["default"]
);
+ let obj = {'cls':["title"], 'icon': icon};
+
+ if (embed['desc'] != undefined)
+ obj['desc'] = embed['desc'];
+
// TODO:
// Lazy registration (see above!)
- KorAP.Panel[panel].actions().addToggle(title, {'cls':["title"]}, state);
+ KorAP.Panel[panel].actions().addToggle(title, obj, state);
// Add the service
let id = this.addService({