Gerrit Patch Uploader has uploaded a new change for review.
https://gerrit.wikimedia.org/r/108306
Change subject: Go to top button for pages. Implements go to top button with
smooth scrolling. Hidden when on top of page and appears when scrolled down to
some extent. Configurable-Enabled by default. Can be disabled by using
"$wgShowTopButton = false;" in LocalSettings
......................................................................
Go to top button for pages.
Implements go to top button with smooth scrolling. Hidden when on top of page
and appears when scrolled down to some extent. Configurable-Enabled by default.
Can be disabled by using "$wgShowTopButton = false;" in LocalSettings.php.
Bug: 26032
Change-Id: I2dfb8953737ef4e3e38eb848bbc6ed32111557bf
---
M includes/DefaultSettings.php
M includes/Skin.php
M resources/Resources.php
A skins/common/topbutton.css
A skins/common/topbutton.js
5 files changed, 52 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/06/108306/1
diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index 31cbb4c..fae215a 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -6981,6 +6981,10 @@
*/
$wgCompiledFiles = array();
+
+// Enabled go to top button by default- To disable, do "$wgShowTopButton =
false;" in LocalSettings.php
+$wgShowTopButton = true;
+
/**
* For really cool vim folding this needs to be at the end:
* vim: foldmarker=@{,@} foldmethod=marker
diff --git a/includes/Skin.php b/includes/Skin.php
index 6722cca..507a360 100644
--- a/includes/Skin.php
+++ b/includes/Skin.php
@@ -209,6 +209,13 @@
$wgAjaxWatch, $wgEnableAPI, $wgEnableWriteAPI;
$out = $this->getOutput();
+
+ // Add go to top button if declared in LocalSettings.php
+ global $wgShowTopButton;
+ if($wgShowTopButton) {
+ $out->addModules('topbutton');
+ }
+
$user = $out->getUser();
$modules = array(
// modules that enhance the page content in some way
diff --git a/resources/Resources.php b/resources/Resources.php
index 01d4a3f..686955a 100644
--- a/resources/Resources.php
+++ b/resources/Resources.php
@@ -193,6 +193,14 @@
'position' => 'bottom',
),
+ /* Go to top button */
+ 'topbutton' => array(
+ 'scripts' => 'skins/common/topbutton.js',
+ 'styles' => array(
+ 'skins/common/topbutton.css' => array( 'media' =>
'screen' ),
+ ),
+ ),
+
/* jQuery */
'jquery' => array(
diff --git a/skins/common/topbutton.css b/skins/common/topbutton.css
new file mode 100644
index 0000000..adf87bf
--- /dev/null
+++ b/skins/common/topbutton.css
@@ -0,0 +1,17 @@
+#go-to-top {
+ position: fixed;
+ bottom: 2em;
+ left: 40px;
+ text-decoration: none;
+ color: #0645ad;
+ background-color: rgba(165, 155, 235, 0.80);
+ font-size: 12px;
+ padding: 1em;
+ display: none;
+ border-radius: 4px;
+ }
+
+#go-to-top:hover {
+ background-color: rgba(135, 135, 135, 0.40);
+ cursor: pointer;
+}
\ No newline at end of file
diff --git a/skins/common/topbutton.js b/skins/common/topbutton.js
new file mode 100644
index 0000000..ac300d3
--- /dev/null
+++ b/skins/common/topbutton.js
@@ -0,0 +1,16 @@
+(function( $ ) {
+ $('body').append('<div id="go-to-top">Go to Top</div>');
+ jQuery(window).scroll(function() {
+ if (jQuery(this).scrollTop() > 300) {
+ jQuery('#go-to-top').fadeIn(500);
+ } else {
+ jQuery('#go-to-top').fadeOut(500);
+ }
+ });
+
+ jQuery('#go-to-top').click(function(event) {
+ event.preventDefault();
+ jQuery('html, body').animate({scrollTop: 0}, 500);
+ return false;
+ })
+})( jQuery );
--
To view, visit https://gerrit.wikimedia.org/r/108306
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2dfb8953737ef4e3e38eb848bbc6ed32111557bf
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Gerrit Patch Uploader <[email protected]>
Gerrit-Reviewer: Kunalgrover05 <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits