', {
class: 'tools_flyout',
@@ -1020,6 +1017,23 @@ class Editor extends EditorStartup {
return div;
}
+ /**
+ * @function module:SVGEditor.setIcon
+ * @param {string|Element|external:jQuery} elem
+ * @param {string|external:jQuery} iconId
+ * @returns {void}
+ */
+ setIcon (elem, iconId) {
+ // eslint-disable-next-line max-len
+ const icon = (typeof iconId === 'string') ? $('
') : iconId.clone();
+ if (!icon) {
+ // Todo: Investigate why this still occurs in some cases
+ console.log('NOTE: Icon image missing: ' + iconId); // eslint-disable-line no-console
+ return;
+ }
+ $(elem).empty().append(icon);
+ }
+
/**
* @param {string} elemSel
* @param {string} listSel
@@ -1031,8 +1045,9 @@ class Editor extends EditorStartup {
* @todo Combine this with `addDropDown` or find other way to optimize.
* @returns {void}
*/
- // eslint-disable-next-line class-methods-use-this
addAltDropDown (elemSel, listSel, callback, opts) {
+ // eslint-disable-next-line no-shadow
+ const self = this;
const button = $(elemSel);
const {dropUp} = opts;
const list = $(listSel);
@@ -1041,7 +1056,7 @@ class Editor extends EditorStartup {
}
list.find('li').bind('mouseup', function (...args) {
if (opts.seticon) {
- // setIcon('#cur_' + button[0].id, $(this).children());
+ self.setIcon('#cur_' + button[0].id, $(this).children());
$(this).addClass('current').siblings().removeClass('current');
}
callback.apply(this, ...args);
@@ -1088,7 +1103,7 @@ class Editor extends EditorStartup {
onButton = true;
});
}
- };
+ }
/**
* @param {external:Window} win
@@ -1097,6 +1112,7 @@ class Editor extends EditorStartup {
* @returns {Promise
|void} Resolves to `undefined`
*/
async extAdded (win, ext) {
+ // eslint-disable-next-line no-shadow
const self = this;
const btnSelects = [];
if (!ext) {
@@ -1174,7 +1190,9 @@ class Editor extends EditorStartup {
break;
} case 'button-select': {
html = '';
+ '' +
+ '' +
+ ' ';
const list = $('