Gunslingor
08/25/2020, 2:16 AM// Add and beautify tooltips
[['sw-visibility', 'Show Borders'], ['preview', 'Preview'], ['fullscreen', 'Fullscreen'],
['export-template', 'Export'], ['undo', 'Undo'], ['redo', 'Redo'],
['gjs-open-import-webpage', 'Import'], ['canvas-clear', 'Clear canvas']]
.forEach(function(item) {
pn.getButton('options', item[0]).set('attributes', {title: item[1], 'data-tooltip-pos': 'bottom'});
});
[['open-sm', 'Style Manager'], ['open-layers', 'Layers'], ['open-blocks', 'Blocks']]
.forEach(function(item) {
pn.getButton('views', item[0]).set('attributes', {title: item[1], 'data-tooltip-pos': 'bottom'});
});
var titles = document.querySelectorAll('*[title]');
for (var i = 0; i < titles.length; i++) {
var el = titles[i];
var title = el.getAttribute('title');
title = title ? title.trim(): '';
if(!title)
break;
el.setAttribute('data-tooltip', title);
el.setAttribute('title', '');
}
KJS
val toolTips = arrayOf(
arrayOf("sw-visibility", "Show Borders"),
arrayOf("preview", "Preview"),
arrayOf("fullscreen", "Fullscreen"),
arrayOf("export-template", "Export"),
arrayOf("undo", "Undo"),
arrayOf("redo", "Redo"),
arrayOf("gjs-open-import-webpage", "Import"),
arrayOf("canvas-clear", "Clear canvas")
)
toolTips.forEach {
val openTmBtn = panels.getButton("views", "open-tm")
openTmBtn.set("title", it[1])
openTmBtn.set("data-tooltip-pos", "bottom")
}
val titles = document.querySelectorAll("*[title]")
for(index in 0..titles.length) {
val el = titles.item(index)
var title = el?.parentElement?.getAttribute("title")?.trim() ?: ""
if(title.isNotEmpty()) {
el?.parentElement?.setAttribute("data-tooltip", title)
el?.parentElement?.setAttribute("title", "")
}
}
Gunslingor
08/25/2020, 2:31 AMGunslingor
08/25/2020, 5:55 AMval toolTipsForPanelOptions = arrayOf(
arrayOf("sw-visibility", "Show Borders"),
arrayOf("preview", "Preview"),
arrayOf("fullscreen", "Fullscreen"),
arrayOf("export-template", "Export"),
arrayOf("undo", "Undo"),
arrayOf("redo", "Redo"),
arrayOf("gjs-open-import-webpage", "Import"),
arrayOf("canvas-clear", "Clear canvas")
)
val toolTipsForPanelViews = arrayOf(
arrayOf("open-sm", "Style Manager"),
arrayOf("open-layers", "Layers"),
arrayOf("open-blocks", "Blocks")
)
toolTipsForPanelOptions.forEach {
val btn = panels.getButton("options", it[0])
btn.set("attributes", jsObject<dynamic>{
title = it[1]
this["data-tooltip-pos"] = "bottom"
})
}
toolTipsForPanelViews.forEach {
val btn = panels.getButton("views", it[0])
btn.set("attributes", jsObject<dynamic>{
title = it[1]
this["data-tooltip-pos"] = "bottom"
})
}
val titles = document.querySelectorAll("*[title]")
for(index in 0..titles.length) {
val el = titles.item(index) as Element
val title = el.getAttribute("title")?.trim() ?: ""
if(title.isNotEmpty()) {
el.setAttribute("data-tooltip", title)
el.setAttribute("title", "")
}
console.log(title)
}