FANDOM


BackToTopButton adds a button to the right corner of the Oasis footer that takes you back to the top of the page when pressed.

Installation

See also: Help:Including additional CSS and JS, Help:Advanced CSS and JS
  • For site-wide use, an administrator can add the line below to the wiki's MediaWiki:ImportJS page. Note that JavaScript must be enabled on the wiki.
dev:BackToTopButton/code.js
  • For personal use, add the code snippet below to your global.js page (for use on all wikis) or your common.js page on your wiki (for use on a single wiki). Note that personal JS must be enabled for your account.
importArticles({
    type: 'script',
    articles: [
        'u:dev:BackToTopButton/code.js',
    ]
});
importArticles — Best Practices for installing JavaScript on FANDOM
The importArticles statement is designed to combine multiple HTTP requests into a single data transfer, allowing multiple scripts to load and execute faster. If you've been installing several different scripts, your JavaScript file has probably accumulated unnecessary import statements. Click "Expand" to learn how to efficiently batch import scripts to speed up performance and make your code look cleaner. One other approach is by using the MediaWiki:ImportJS.
If your JavaScript file has several lines of code that say importScript, importScriptPage, or importArticles, you may be able to combine them! By batch importing a collection of scripts with a single import, your JavaScript code will load faster and look cleaner. Consider the example below. On the left is an example of what your JavaScript file might currently look like. On the right is how you could improve that code.
Multiple imports — messy and slow One import — clean and efficient
importScriptPage('AjaxRC/code.js','dev');
 
importScript('MediaWiki:localScript.js');
 
importArticle({
  type: 'script',
  article: 'u:dev:FloatingToc/code.js'
});
 
importScriptPage('page1.js', 'wikiname');
 
importScriptPage('page2.js', 'wikiname');
importArticles({
    type: 'script',
    articles: [
        'u:dev:AjaxRC/code.js',
        'MediaWiki:localScript.js',
        'u:dev:FloatingToc/code.js',
        'u:wikiname:page1.js',
        'u:wikiname:page2.js'
    ]
});
Note: In this example, pay close attention to the placement of commas and other punctuation. For people who aren't familiar with programming (and even those who are!), a common mistake when writing code is to accidentally delete, forget, or misplace critical symbols like commas or quotation marks. This can cause a syntax error that breaks the code. Carefully follow the convention shown here when using importArticles.
But there's much more to importArticles than just this! For more examples and advanced usage, see the help page at Help:Including additional JavaScript and CSS.

Customization

If you want to adjust the speed of the scroll up or the amount of scroll down you have to do for the button to appear and a bunch of other options, add the following lines before importing the script (for global.js) or to your community's Wikia.js page.

Button Text

The button text will be automatically shown in the user's language. However, if you wish to change the text, you can do so with the following.

window.BackToTopText = "new text";

Scroll Speed

To adjust scroll speed add this:

window.BackToTopSpeed = number;

Where number is the speed, in milliseconds. Higher numbers result in slower scrolling and smaller numbers result in faster scrolling. Default value is 600.

Button Appearance

To adjust the "depth" you have to reach for the button to appear/disappear add this:

window.BackToTopStart = number;

Where number is distance down the page, in pixels, before the button appears. Higher numbers will make you scroll down further before the button appears. Default value is 800.

Button Format

You can also format the button any way you like with CSS. For example:

/* Back-to-top Button Format */
#backtotop button{
    background: none;
    background-color: transparent;
    color: white;
    border: none;
}
#backtotop button:hover {
    text-decoration: underline;
}

The above CSS rules will make the button look like a simple link.

Disable Button's Fade In/Out Effect

To disable the fade effect add this:

window.BackToTopFade = 0;

To re-enable the effect simply remove this line from your JS page. The fade In/Out effect for the button is On by default.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.