MediaWiki:Common.js: Difference between revisions

From The Jolly Contrarian
Jump to navigation Jump to search
No edit summary
No edit summary
 
(19 intermediate revisions by the same user not shown)
Line 155: Line 155:
group: 'format',
group: 'format',
tools: {
tools: {
"ISDAprov": {
"Prov": {
label: 'isdaprov',
label: 'isdaprov',
type: 'button',
type: 'button',
Line 174: Line 174:
group: 'format',
group: 'format',
tools: {
tools: {
"ISDAprov": {
"Prov": {
label: 'euaprov',
label: 'euaprov',
type: 'button',
type: 'button',
Line 192: Line 192:
group: 'format',
group: 'format',
tools: {
tools: {
"gmslaprov": {
"ietaprov": {
label: 'gmslaprov',
label: 'ietaprov',
type: 'button',
type: 'button',
icon: 'https://jollycontrarian.com/images/e/e9/Gms.png',
icon: 'https://jollycontrarian.com/images/e/e9/Gms.png',
Line 199: Line 199:
type: 'encapsulate',
type: 'encapsulate',
options: {
options: {
pre: "{{gmslaprov|",
pre: "{{ietaprov|",
post: "}}"
post: "}}"
}
}
Line 212: Line 212:
tools: {
tools: {
"gmraprov": {
"gmraprov": {
label: 'grmaprov',
label: '{{{1}}}|',
type: 'button',
type: 'button',
icon: 'https://jollycontrarian.com/images/4/49/Gmr.png',
icon: 'https://jollycontrarian.com/images/4/49/blank.png',
action: {
action: {
type: 'encapsulate',
type: 'encapsulate',
options: {
options: {
pre: "{{gmraprov|",
pre: "{{{{{1}}}|",
post: "}}"
post: "}}"
}
}
Line 251: Line 251:
tools: {
tools: {
"template": {
"template": {
label: 'imcsdprov',
label: 'vmcsaprov',
type: 'button',
type: 'button',
icon: 'https://jollycontrarian.com/images/3/37/Csa.png',
icon: 'https://jollycontrarian.com/images/3/37/Csa.png',
Line 257: Line 257:
type: 'encapsulate',
type: 'encapsulate',
options: {
options: {
pre: "{{imcsdprov|",
pre: "{{vmcsaprov|",
post: "}}"
post: "}}"
}
}
Line 264: Line 264:
}
}
});
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
section: 'advanced',
Line 269: Line 270:
tools: {
tools: {
"template": {
"template": {
label: 'top trumps',
label: 'hotlink',
type: 'button',
type: 'button',
icon: 'http://jollycontrarian.com/w/images/7/7d/Tag2.png',
icon: 'https://jollycontrarian.com/images/3/37/Csa.png',
action: {
type: 'encapsulate',
options: {
pre: "{{fwmdtt|nickname=",
post: "| imagetype=png| tagline= | documentation= | docscore=0| amendability= |amendscore=0| collateral= | collateralscore =0| transferability= | transferscore =0| leverage= | leveragescore =0| frightometer= | frightscore=0}}"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"template": {
label: 'wasteprov',
type: 'button',
icon: 'https://jollycontrarian.com/images/2/27/Wp.png',
action: {
type: 'encapsulate',
options: {
pre: "{{wasteprov|",
post: "}}"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"template": {
label: 'confiprov',
type: 'button',
icon: 'https://jollycontrarian.com/images/e/ec/Cp.png',
action: {
type: 'encapsulate',
options: {
pre: "{{confiprov|",
post: "}}"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"template": {
label: '{{g}}',
type: 'button',
icon: 'https://jollycontrarian.com/images/a/a7/Gl.PNG',
action: {
action: {
type: 'encapsulate',
type: 'encapsulate',
options: {
options: {
pre: "{{g}}",
pre: "{{pjchotlink|}}<li>{{pjchotlink|}}<li>{{pjchotlink|}}<li>{{pjchotlink|}}<li>{{pjchotlink|}}<li>",
post: ""
post: "{{pjchotlink|}}"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"template": {
label: '{{sa}}',
type: 'button',
icon: 'https://jollycontrarian.com/images/7/7c/Sa.PNG',
action: {
type: 'encapsulate',
options: {
pre: "{{sa}}",
post: ""
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"template": {
label: '{{ucits5prov|}}',
type: 'button',
icon: 'https://jollycontrarian.com/images/d/d7/U.PNG',
action: {
type: 'encapsulate',
options: {
pre: "{{ucits5prov|",
post: "}}"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"template": {
label: '{{strike|}}',
type: 'button',
icon: 'https://jollycontrarian.com/images/8/83/Aif.PNG',
action: {
type: 'encapsulate',
options: {
pre: "{{strike|",
post: "|}}"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'manual',
group: 'tags',
tools: {
"template": {
label: 'MI2002',
type: 'button',
icon: 'https://jollycontrarian.com/images/c/c2/MI2002.png',
action: {
type: 'encapsulate',
options: {
pre: "{{manual|MI|2002|",
post: "|Section||short}}"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'manual',
group: 'tags',
tools: {
"template": {
label: 'MI2002',
type: 'button',
icon: 'https://jollycontrarian.com/images/c/c2/MI2002.png',
action: {
type: 'encapsulate',
options: {
pre: "{{manual|MI|2002|",
post: "|Section||short}}"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'manual',
group: 'tags',
tools: {
"template": {
label: 'DCE05',
type: 'button',
icon: 'https://jollycontrarian.com/images/8/83/DCE05.png',
action: {
type: 'encapsulate',
options: {
pre: "{{manual|DCE|2005|",
post: "|Section||short}}"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'manual',
group: 'tags',
tools: {
"template": {
label: 'MCAE1995',
type: 'button',
icon: 'https://jollycontrarian.com/images/b/b3/MCAE1995.png',
action: {
type: 'encapsulate',
options: {
pre: "{{Manual|MCAE|1995|",
post: "|Paragraph||short}}"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'manual',
group: 'tags',
tools: {
"template": {
label: 'MCAE2016',
type: 'button',
icon: 'https://jollycontrarian.com/images/7/7d/MCAE2016.png',
action: {
type: 'encapsulate',
options: {
pre: "{{Manual|MCAE|2016|",
post: "|Paragraph||short}}"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'manual',
group: 'tags',
tools: {
"template": {
label: 'MCAN1994',
type: 'button',
icon: 'https://jollycontrarian.com/images/4/44/MCAN1994.png',
action: {
type: 'encapsulate',
options: {
pre: "{{Manual|MCAN|1994|",
post: "|Paragraph||short}}"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'manual',
group: 'tags',
tools: {
"template": {
label: 'MCAN2016',
type: 'button',
icon: 'https://jollycontrarian.com/images/2/26/MCAN2016.png',
action: {
type: 'encapsulate',
options: {
pre: "{{Manual|MCAN|2016|",
post: "|Paragraph||short}}"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'manual',
group: 'tags',
tools: {
"template": {
label: 'MSG2010',
type: 'button',
icon: 'https://jollycontrarian.com/images/2/26/MCAN2016.png',
action: {
type: 'encapsulate',
options: {
pre: "{{Manual|MSG|2010|",
post: "|Clause||short}}"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'manual',
group: 'tags',
tools: {
"template": {
label: 'MRG2000',
type: 'button',
icon: 'https://jollycontrarian.com/images/2/26/MCAN2016.png',
action: {
type: 'encapsulate',
options: {
pre: "{{Manual|MRG|2000|",
post: "|Paragraph||short}}"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'manual',
group: 'tags',
tools: {
"template": {
label: 'DCD2014',
type: 'button',
icon: 'https://jollycontrarian.com/images/2/26/MCAN2016.png',
action: {
type: 'encapsulate',
options: {
pre: "{{Manual|DCD|2014|",
post: "|Section||medium}}"
}
}
}
}
Line 589: 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. */


/* Any JavaScript here will be loaded for all users on every page load. */
// JavaScript to dynamically adjust table layout
/* Good site for buttons: http://commons.wikimedia.org/wiki/Mediawiki_edit_toolbar */
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`;
    });
});