MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
Amwelladmin (talk | contribs) No edit summary |
Amwelladmin (talk | contribs) No edit summary |
||
(33 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
var customizeToolbar = function() { | var customizeToolbar = function() { | ||
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | |||
'sections': { | |||
'manual': { | |||
'type': 'toolbar', // Can also be 'booklet' | |||
'label': 'Manual' | |||
// or 'labelMsg': 'section-manual-label' for a localized label | |||
} | |||
} | |||
} ); | |||
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | |||
'section': 'manual', | |||
'groups': { | |||
'tags': { | |||
'label': 'Tags' // or use labelMsg for a localized label, see above | |||
} | |||
} | |||
} ); | |||
$('#wpTextbox1').wikiEditor('addToToolbar', { | $('#wpTextbox1').wikiEditor('addToToolbar', { | ||
Line 8: | Line 26: | ||
label: 'long dash', | label: 'long dash', | ||
type: 'button', | type: 'button', | ||
icon: ' | icon: 'https://jollycontrarian.com/images/5/55/Dash.png', | ||
action: { | action: { | ||
type: 'encapsulate', | type: 'encapsulate', | ||
Line 26: | Line 44: | ||
label: 'scarequotes', | label: 'scarequotes', | ||
type: 'button', | type: 'button', | ||
icon: ' | icon: 'https://jollycontrarian.com/images/b/ba/Scare.png', | ||
action: { | action: { | ||
type: 'encapsulate', | type: 'encapsulate', | ||
Line 44: | Line 62: | ||
label: 'apostrophe', | label: 'apostrophe', | ||
type: 'button', | type: 'button', | ||
icon: ' | icon: 'https://jollycontrarian.com/images/5/5b/Apo.png', | ||
action: { | action: { | ||
type: 'encapsulate', | type: 'encapsulate', | ||
Line 54: | Line 72: | ||
} | } | ||
} | } | ||
}); | |||
}); | |||
$('#wpTextbox1').wikiEditor('addToToolbar', { | $('#wpTextbox1').wikiEditor('addToToolbar', { | ||
Line 78: | Line 78: | ||
group: 'format', | group: 'format', | ||
tools: { | tools: { | ||
" | "template": { | ||
label: ' | label: '{{ - }}', | ||
type: 'button', | type: 'button', | ||
icon: ' | icon: 'https://jollycontrarian.com/images/3/30/Template.png', | ||
action: { | action: { | ||
type: 'encapsulate', | type: 'encapsulate', | ||
options: { | options: { | ||
pre: "{{ | pre: "{{", | ||
post: "}}" | post: "}}" | ||
} | } | ||
Line 137: | Line 100: | ||
label: 'subst:', | label: 'subst:', | ||
type: 'button', | type: 'button', | ||
icon: ' | icon: 'https://jollycontrarian.com/images/0/03/Sbs.png', | ||
action: { | action: { | ||
type: 'encapsulate', | type: 'encapsulate', | ||
Line 153: | Line 116: | ||
group: 'format', | group: 'format', | ||
tools: { | tools: { | ||
" | "redirect": { | ||
label: ' | label: '==>', | ||
type: 'button', | type: 'button', | ||
icon: ' | icon: 'https://jollycontrarian.com/images/9/91/Redirect.png', | ||
action: { | action: { | ||
type: 'encapsulate', | type: 'encapsulate', | ||
options: { | options: { | ||
pre: " | pre: "#redirect[[", | ||
post: " | post: "]]" | ||
} | } | ||
} | } | ||
Line 167: | Line 130: | ||
} | } | ||
}); | }); | ||
$('#wpTextbox1').wikiEditor('addToToolbar', { | $('#wpTextbox1').wikiEditor('addToToolbar', { | ||
Line 173: | Line 137: | ||
tools: { | tools: { | ||
"template": { | "template": { | ||
label: ' | label: 'tag', | ||
type: 'button', | type: 'button', | ||
icon: ' | icon: 'https://jollycontrarian.com/images/7/76/Tag.png', | ||
action: { | action: { | ||
type: 'encapsulate', | type: 'encapsulate', | ||
options: { | options: { | ||
pre: "{{", | pre: "{{t|", | ||
post: "}}" | post: "}}" | ||
} | } | ||
Line 191: | Line 155: | ||
group: 'format', | group: 'format', | ||
tools: { | tools: { | ||
" | "Prov": { | ||
label: ' | label: 'isdaprov', | ||
type: 'button', | type: 'button', | ||
icon: ' | icon: 'https://jollycontrarian.com/images/5/50/Isd.png', | ||
action: { | action: { | ||
type: 'encapsulate', | type: 'encapsulate', | ||
options: { | options: { | ||
pre: "{{ | pre: "{{isdaprov|", | ||
post: "}}" | post: "}}" | ||
} | } | ||
Line 204: | Line 168: | ||
} | } | ||
} | } | ||
}); | }); | ||
$('#wpTextbox1').wikiEditor('addToToolbar', { | $('#wpTextbox1').wikiEditor('addToToolbar', { | ||
Line 210: | Line 174: | ||
group: 'format', | group: 'format', | ||
tools: { | tools: { | ||
" | "Prov": { | ||
label: ' | label: 'euaprov', | ||
type: 'button', | type: 'button', | ||
icon: ' | icon: 'https://jollycontrarian.com/images/5/50/eua.png', | ||
action: { | action: { | ||
type: 'encapsulate', | type: 'encapsulate', | ||
options: { | options: { | ||
pre: "{{ | pre: "{{euaprov|", | ||
post: "}}" | post: "}}" | ||
} | } | ||
} | } | ||
Line 278: | Line 188: | ||
} | } | ||
}); | }); | ||
$('#wpTextbox1').wikiEditor('addToToolbar', { | $('#wpTextbox1').wikiEditor('addToToolbar', { | ||
section: 'advanced', | section: 'advanced', | ||
group: 'format', | group: 'format', | ||
tools: { | tools: { | ||
" | "ietaprov": { | ||
label: ' | label: 'ietaprov', | ||
type: 'button', | type: 'button', | ||
icon: ' | icon: 'https://jollycontrarian.com/images/e/e9/Gms.png', | ||
action: { | action: { | ||
type: 'encapsulate', | type: 'encapsulate', | ||
options: { | options: { | ||
pre: "{{ | pre: "{{ietaprov|", | ||
post: " | post: "}}" | ||
} | } | ||
} | } | ||
} | } | ||
} | } | ||
}); | }); | ||
$('#wpTextbox1').wikiEditor('addToToolbar', { | $('#wpTextbox1').wikiEditor('addToToolbar', { | ||
section: 'advanced', | section: 'advanced', | ||
group: 'format', | group: 'format', | ||
tools: { | tools: { | ||
" | "gmraprov": { | ||
label: ' | label: '{{{1}}}|', | ||
type: 'button', | type: 'button', | ||
icon: 'https://jollycontrarian.com/images/ | icon: 'https://jollycontrarian.com/images/4/49/blank.png', | ||
action: { | action: { | ||
type: 'encapsulate', | type: 'encapsulate', | ||
options: { | options: { | ||
pre: "{{ | pre: "{{{{{1}}}|", | ||
post: "}}" | post: "}}" | ||
} | } | ||
Line 421: | Line 224: | ||
} | } | ||
} | } | ||
}); | }); | ||
$('#wpTextbox1').wikiEditor('addToToolbar', { | $('#wpTextbox1').wikiEditor('addToToolbar', { | ||
section: 'advanced', | section: 'advanced', | ||
group: 'format', | group: 'format', | ||
tools: { | tools: { | ||
" | "Equity Derivs": { | ||
label: ' | label: 'eqderivprov', | ||
type: 'button', | type: 'button', | ||
icon: 'https://jollycontrarian.com/images/ | icon: 'https://jollycontrarian.com/images/c/c3/Eqd.png', | ||
action: { | action: { | ||
type: 'encapsulate', | type: 'encapsulate', | ||
options: { | options: { | ||
pre: "{{ | pre: "{{eqderivprov|", | ||
post: "}}" | post: "}}" | ||
} | } | ||
Line 439: | Line 243: | ||
} | } | ||
} | } | ||
}); | }); | ||
$('#wpTextbox1').wikiEditor('addToToolbar', { | $('#wpTextbox1').wikiEditor('addToToolbar', { | ||
section: 'advanced', | section: 'advanced', | ||
Line 481: | Line 251: | ||
tools: { | tools: { | ||
"template": { | "template": { | ||
label: ' | label: 'vmcsaprov', | ||
type: 'button', | type: 'button', | ||
icon: 'https://jollycontrarian.com/images/ | icon: 'https://jollycontrarian.com/images/3/37/Csa.png', | ||
action: { | action: { | ||
type: 'encapsulate', | type: 'encapsulate', | ||
options: { | options: { | ||
pre: "{{ | pre: "{{vmcsaprov|", | ||
post: "}}" | post: "}}" | ||
} | } | ||
Line 494: | Line 264: | ||
} | } | ||
}); | }); | ||
$('#wpTextbox1').wikiEditor('addToToolbar', { | $('#wpTextbox1').wikiEditor('addToToolbar', { | ||
section: 'advanced', | section: 'advanced', | ||
Line 499: | Line 270: | ||
tools: { | tools: { | ||
"template": { | "template": { | ||
label: ' | label: 'hotlink', | ||
type: 'button', | type: 'button', | ||
icon: 'https://jollycontrarian.com/images/ | icon: 'https://jollycontrarian.com/images/3/37/Csa.png', | ||
action: { | action: { | ||
type: 'encapsulate', | type: 'encapsulate', | ||
options: { | options: { | ||
pre: "{{ | pre: "{{pjchotlink|}}<li>{{pjchotlink|}}<li>{{pjchotlink|}}<li>{{pjchotlink|}}<li>{{pjchotlink|}}<li>", | ||
post: "}}" | post: "{{pjchotlink|}}" | ||
} | } | ||
} | } | ||
Line 512: | Line 283: | ||
} | } | ||
}); | }); | ||
}; | }; | ||
if ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) { | if ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) { | ||
mw.loader.using( 'user.options' ).then( function () { | mw.loader.using( 'user.options' ).then( function () { | ||
Line 546: | Line 302: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
// JavaScript to dynamically adjust table layout | |||
function adjustTableLayout() { | |||
var staticTable = document.getElementById('static-table'); | |||
var adaptiveTable = document.getElementById('adaptive-table'); | |||
if (!staticTable || !adaptiveTable) return; | |||
// Get the bounding rectangles of the tables | |||
var staticRect = staticTable.getBoundingClientRect(); | |||
var adaptiveRect = adaptiveTable.getBoundingClientRect(); | |||
// Check if the adaptive table is below the static table | |||
if (adaptiveRect.top >= staticRect.bottom) { | |||
adaptiveTable.classList.add('stacked'); | |||
} else { | |||
adaptiveTable.classList.remove('stacked'); | |||
} | |||
} | |||
// Function to request a reflow and check layout | |||
function checkLayout() { | |||
requestAnimationFrame(function() { | |||
adjustTableLayout(); | |||
}); | |||
} | |||
// Initial adjustment | |||
checkLayout(); | |||
// Adjust on window resize | |||
window.addEventListener('resize', checkLayout); | |||
// Adjust on content changes | |||
document.addEventListener('DOMContentLoaded', checkLayout); | |||
/* DIALOGUE MALARKEY */ | |||
document.addEventListener("DOMContentLoaded", function() { | |||
document.querySelectorAll('.dialogue').forEach(dialogue => { | |||
const character = dialogue.querySelector('.character'); | |||
const text = dialogue.querySelector('.text'); | |||
const characterWidth = character.offsetWidth; | |||
text.style.marginLeft = `${characterWidth + 30}px`; | |||
}); | |||
}); |
Latest revision as of 17:50, 10 September 2024
var customizeToolbar = function() { $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { 'sections': { 'manual': { 'type': 'toolbar', // Can also be 'booklet' 'label': 'Manual' // or 'labelMsg': 'section-manual-label' for a localized label } } } ); $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { 'section': 'manual', 'groups': { 'tags': { 'label': 'Tags' // or use labelMsg for a localized label, see above } } } ); $('#wpTextbox1').wikiEditor('addToToolbar', { section: 'advanced', group: 'format', tools: { "template": { label: 'long dash', type: 'button', icon: 'https://jollycontrarian.com/images/5/55/Dash.png', action: { type: 'encapsulate', options: { pre: "—", post: "" } } } } }); $('#wpTextbox1').wikiEditor('addToToolbar', { section: 'advanced', group: 'format', tools: { "template": { label: 'scarequotes', type: 'button', icon: 'https://jollycontrarian.com/images/b/ba/Scare.png', action: { type: 'encapsulate', options: { pre: "“", post: "”" } } } } }); $('#wpTextbox1').wikiEditor('addToToolbar', { section: 'advanced', group: 'format', tools: { "template": { label: 'apostrophe', type: 'button', icon: 'https://jollycontrarian.com/images/5/5b/Apo.png', action: { type: 'encapsulate', options: { pre: "’", post: "" } } } } }); $('#wpTextbox1').wikiEditor('addToToolbar', { section: 'advanced', group: 'format', tools: { "template": { label: '{{ - }}', type: 'button', icon: 'https://jollycontrarian.com/images/3/30/Template.png', action: { type: 'encapsulate', options: { pre: "{{", post: "}}" } } } } }); $('#wpTextbox1').wikiEditor('addToToolbar', { section: 'advanced', group: 'format', tools: { "Substitute": { label: 'subst:', type: 'button', icon: 'https://jollycontrarian.com/images/0/03/Sbs.png', action: { type: 'encapsulate', options: { pre: "{{subst:", post: "}}" } } } } }); $('#wpTextbox1').wikiEditor('addToToolbar', { section: 'advanced', group: 'format', tools: { "redirect": { label: '==>', type: 'button', icon: 'https://jollycontrarian.com/images/9/91/Redirect.png', action: { type: 'encapsulate', options: { pre: "#redirect[[", post: "]]" } } } } }); $('#wpTextbox1').wikiEditor('addToToolbar', { section: 'advanced', group: 'format', tools: { "template": { label: 'tag', type: 'button', icon: 'https://jollycontrarian.com/images/7/76/Tag.png', action: { type: 'encapsulate', options: { pre: "{{t|", post: "}}" } } } } }); $('#wpTextbox1').wikiEditor('addToToolbar', { section: 'advanced', group: 'format', tools: { "Prov": { label: 'isdaprov', type: 'button', icon: 'https://jollycontrarian.com/images/5/50/Isd.png', action: { type: 'encapsulate', options: { pre: "{{isdaprov|", post: "}}" } } } } }); $('#wpTextbox1').wikiEditor('addToToolbar', { section: 'advanced', group: 'format', tools: { "Prov": { label: 'euaprov', type: 'button', icon: 'https://jollycontrarian.com/images/5/50/eua.png', action: { type: 'encapsulate', options: { pre: "{{euaprov|", post: "}}" } } } } }); $('#wpTextbox1').wikiEditor('addToToolbar', { section: 'advanced', group: 'format', tools: { "ietaprov": { label: 'ietaprov', type: 'button', icon: 'https://jollycontrarian.com/images/e/e9/Gms.png', action: { type: 'encapsulate', options: { pre: "{{ietaprov|", post: "}}" } } } } }); $('#wpTextbox1').wikiEditor('addToToolbar', { section: 'advanced', group: 'format', tools: { "gmraprov": { label: '{{{1}}}|', type: 'button', icon: 'https://jollycontrarian.com/images/4/49/blank.png', action: { type: 'encapsulate', options: { pre: "{{{{{1}}}|", post: "}}" } } } } }); $('#wpTextbox1').wikiEditor('addToToolbar', { section: 'advanced', group: 'format', tools: { "Equity Derivs": { label: 'eqderivprov', type: 'button', icon: 'https://jollycontrarian.com/images/c/c3/Eqd.png', action: { type: 'encapsulate', options: { pre: "{{eqderivprov|", post: "}}" } } } } }); $('#wpTextbox1').wikiEditor('addToToolbar', { section: 'advanced', group: 'format', tools: { "template": { label: 'vmcsaprov', type: 'button', icon: 'https://jollycontrarian.com/images/3/37/Csa.png', action: { type: 'encapsulate', options: { pre: "{{vmcsaprov|", post: "}}" } } } } }); $('#wpTextbox1').wikiEditor('addToToolbar', { section: 'advanced', group: 'format', tools: { "template": { label: 'hotlink', type: 'button', icon: 'https://jollycontrarian.com/images/3/37/Csa.png', action: { type: 'encapsulate', options: { pre: "{{pjchotlink|}}<li>{{pjchotlink|}}<li>{{pjchotlink|}}<li>{{pjchotlink|}}<li>{{pjchotlink|}}<li>", post: "{{pjchotlink|}}" } } } } }); }; if ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) { mw.loader.using( 'user.options' ).then( function () { if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) { $.when( mw.loader.using( 'ext.wikiEditor' ), $.ready ).then( customizeToolbar ); } } ); } // Add the customizations to LiquidThreads' edit toolbar, if available mw.hook( 'ext.lqt.textareaCreated' ).add( customizeToolbar ); /* Any JavaScript here will be loaded for all users on every page load. */ // JavaScript to dynamically adjust table layout function adjustTableLayout() { var staticTable = document.getElementById('static-table'); var adaptiveTable = document.getElementById('adaptive-table'); if (!staticTable || !adaptiveTable) return; // Get the bounding rectangles of the tables var staticRect = staticTable.getBoundingClientRect(); var adaptiveRect = adaptiveTable.getBoundingClientRect(); // Check if the adaptive table is below the static table if (adaptiveRect.top >= staticRect.bottom) { adaptiveTable.classList.add('stacked'); } else { adaptiveTable.classList.remove('stacked'); } } // Function to request a reflow and check layout function checkLayout() { requestAnimationFrame(function() { adjustTableLayout(); }); } // Initial adjustment checkLayout(); // Adjust on window resize window.addEventListener('resize', checkLayout); // Adjust on content changes document.addEventListener('DOMContentLoaded', checkLayout); /* DIALOGUE MALARKEY */ document.addEventListener("DOMContentLoaded", function() { document.querySelectorAll('.dialogue').forEach(dialogue => { const character = dialogue.querySelector('.character'); const text = dialogue.querySelector('.text'); const characterWidth = character.offsetWidth; text.style.marginLeft = `${characterWidth + 30}px`; }); });