User:Jackmcbarn/advancedtemplatesandbox.js: Difference between revisions

Content deleted Content added
Jackmcbarn (talk | contribs)
Expand functionality
Jackmcbarn (talk | contribs)
make the page box have autocomplete like the real thing does
 
(8 intermediate revisions by the same user not shown)
Line 8:
This hardcodes contents of messages, rather than fetching them.
The span is left as a span, rather than being changed to a fieldset.
Tab indexes assume that we're the first thing after "Show changes". If we're not (or if any other code does this trick), tab order will be wrong. Also, it relies on non-integer tab indexes working.
*/
 
if($('#wpTemplateSandboxPage').attr('type') == 'hidden') {
mw.loader.using('jquery.makeCollapsible', function() {
$('#templatesandbox-editform').makeCollapsible({collapsed: !$('#wpTemplateSandboxPage').attr('value') });
});
$('#templatesandbox-editform').prepend('<legend>Preview page with this template</legend>');
$('#wpTemplateSandboxPage').before('<span class="mw-templatesandbox-page" id="wpTemplateSandboxPageLabel"><label for="wpTemplateSandboxPage">Page title:</label></span> ').after('<input id="wpTemplateSandboxPreview" name="wpTemplateSandboxPreview" tabindex="' + (0.75 + ($('#wpDiff').attr('tabIndex')) + 0.75) + '" value="Show preview" type="submit" />').replaceWith($('#wpTemplateSandboxPage').clone().attr({type: 'text', tabindex: 0.5 + ($('#wpDiff').attr('tabIndex')) + 0.5, size: 60, spellcheck: true, 'data-mw-searchsuggest': '{"wrapAsLink":false}'}).addClass('mw-searchInput'));
}
if($('#wpTemplateSandboxTemplate').attr('type') == 'hidden') {
$('#wpTemplateSandboxTemplate').before('<span class="mw-templatesandbox-template" id="wpTemplateSandboxTemplateLabel"><label for="wpTemplateSandboxTemplate">Template name:</label></span> ').after('<br />').replaceWith($('#wpTemplateSandboxTemplate').clone().attr({type: 'text', tabindex: 0.25 + ($('#wpDiff').attr('tabIndex')) + 0.25, size: 60, spellcheck: true}));
}
$('#wpTemplateSandboxTemplate').before('<span class="mw-templatesandbox-template" id="wpTemplateSandboxTemplateLabel"><label for="wpTemplateSandboxTemplate">Template name:</label></span> ').after('<br />').replaceWith($('#wpTemplateSandboxTemplate').clone().attr({type: 'text', tabindex: 0.25 + $('#wpDiff').attr('tabIndex'), size: 60, spellcheck: true}));