User:Polygnotus/Scripts/FavouriteTemplates.js: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 160:
templateTools[buttonId] = {
type: 'element',
element: function$('<button>') {
return $.addClass('<a>tool tool-button')
.attrtext('href', '#'displayTitle)
.addClasscss('tool tool-button'){
.text(displayTitle)'padding': '4px 8px',
.click(function(e)'margin': {'2px',
'border': '1px solid #a2a9b1',
'border-radius': '2px',
'background': '#f8f9fa',
'cursor': 'pointer',
'font-size': '11px',
'font-family': 'sans-serif'
})
.hover(
function() { $(this).css('background', '#eaecf0'); },
function() { $(this).css('background', '#f8f9fa'); }
)
.click((function(syntax) {
return function(e) {
e.preventDefault();
// Get the textarea
Line 174 ⟶ 187:
const end = textarea.selectionEnd;
const text = textarea.value;
textarea.value = text.substring(0, start) + templateSyntaxsyntax + text.substring(end);
// Move cursor to end of inserted text
textarea.selectionStart = textarea.selectionEnd = start + templateSyntaxsyntax.length;
textarea.focus();
}
});
})(templateSyntax))
};
}