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

Content deleted Content added
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 160:
templateTools[buttonId] = {
type: 'element',
element: function$('<button>') {
return $.addClass('<tool tool-button>')
.addClasstext('tool tool-button'displayTitle)
.textcss(displayTitle){
.css({'padding': '4px 8px',
'paddingmargin': '4px 8px2px',
'marginborder': '2px1px solid #a2a9b1',
'border-radius': '1px solid #a2a9b12px',
'border-radiusbackground': '2px#f8f9fa',
'backgroundcursor': '#f8f9fapointer',
'cursorfont-size': 'pointer11px',
'font-sizefamily': '11pxsans-serif',
'font-family': 'sans-serif'})
}).hover(
function() { $(this).hovercss('background', '#eaecf0'); },
function() { $(this).css('background', '#eaecf0f8f9fa'); },
function() { $(this).css('background', '#f8f9fa'); }
.click((function(syntax) ){
.click(return function(e) {
e.preventDefault();
// Get the textarea
Line 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))
};
}