UI Library for Waze Map Editor Greasy Fork scripts
WMEUI.addTranslation(name, translation)– add translation to theI180nobject, to call use syntax like thisI180n.t(name).elementWMEUI.addStyle(css)– inject CSS to the pageWMEUI.addShortcut (name, desc, group, title, shortcut, callback, scope = null)- create shortcut
createPanel (title, description = null, attributes = {})– create a panel for the sidebar containercreateTab (title, description = null, attributes = {})– create a tab for the sidebar containercreateModal (title, description = null)– create a modal window containercreateFieldset (title, description = null)– create a field container
A parent class for all containers
addElement (element)- addWMEUIHelperElementto a containeraddDiv (id, innerHTML, attributes)- addWMEUIHelperDivto a containeraddText (id, text)- addWMEUIHelperTextto a containeraddFieldset (id, title, description)- addWMEUIHelperFieldsetto a containeraddInput (id, title, callback, value = '')- addWMEUIHelperControlInputwithtype=textto a containeraddNumber (id, title, callback, value = 0, min, max, step = 10)-WMEUIHelperControlInputwithtype=numberto a containeraddCheckbox (id, title, callback, checked = false)- addWMEUIHelperControlInputwithtype=checkboxto a containeraddRadio (id, title, callback, name, value, checked = false)- addWMEUIHelperControlInputwithtype=radioto a containeraddRange (id, title, callback, value, min, max, step = 10)- addWMEUIHelperControlInputwithtype=rangeto a containeraddButton (id, title, description, callback, shortcut = null)- addWMEUIHelperControlButtonto a containeraddButtons (buttons)- add set of theWMEUIHelperControlButtonto a container
A container for the sidebar panel
A container for the sidebar tab
A container for modal window
A container for field set HTML element
Create shortcut for callback function
new WMEUIShortcut(name, description, group, title, shortcut, callback, scope = null)- create shortcut
(function () {
'use strict'
const NAME = 'Script Name'
// translation structure
const TRANSLATION = {
'en': {
title: 'Copy address',
},
'uk': {
title: 'Копіювати адресу',
},
'ru': {
title: 'Копировать адреc',
}
}
const STYLE = '.script-name { border: 1px solid #ccc }'
// Add translation
WMEUI.addTranslation(NAME, TRANSLATION)
// Add custom style
WMEUI.addStyle(STYLE)
// Create shortcut
new WMEUIShortcut(
NAME + '-script', // unique name
I18n.t(NAME).title, // description
NAME, // group (use the same group for all shortcuts of the script)
I18n.t(NAME).title, // title shortcut section
'C+D', // shortcut
() => console.log('ok'), // callback
null // scope
)
// buttons structure
const BUTTONS = {
A: {
title: I180n.t(NAME).buttons.A.title,
description: I180n.t(NAME).buttons.A.description,
shortcut: 'S+49',
callback: function() {
console.log('Button 1');
return false;
}
},
B: {
title: I180n.t(NAME).buttons.B.title,
description: I180n.t(NAME).buttons.B.description,
shortcut: 'S+50',
callback: function() {
console.log('Button 2');
return false;
}
},
};
let helper, panel, modal, tab;
$(document)
.on('bootstrap.wme', function () {
console.info('ready');
helper = new WMEUIHelper(NAME);
// Create buttons on the sidebar
panel = helper.createPanel(I18n.t(NAME).title);
panel.addButtons(BUTTONS);
// Create buttons in the modal
modal = helper.createModal(I18n.t(NAME).title);
modal.addButtons(BUTTONS);
// Create buttons on the sidebar in the dedicated tab
tab = helper.createTab(I18n.t(NAME).title);
tab.addButtons(BUTTONS);
tab.inject();
})
.on('point.wme', (e, el) => {
console.log('point', el);
el.append(panel.toHTML());
})
.on('place.wme', (e, el) => {
console.info('place', el);
el.append(panel.toHTML());
});
})();Author homepage: https://anton.shevchuk.name/
Author pet projects: https://hohli.com/
Support author: https://donate.hohli.com/
Script homepage: https://github.com/AntonShevchuk/wme-ui
GreasyFork: https://greasyfork.org/en/scripts/450320-wme-ui