Gerrit Patch Uploader has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/108323


Change subject: Go to top button for pages
......................................................................

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: I866cd88201948177da2fec3cc9d4c713bb39bc0f
---
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, 53 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/23/108323/1

diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index 31cbb4c..5ed0cc0 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -6981,6 +6981,12 @@
  */
 $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..6c6f475 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..b233fe9
--- /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;
+}
diff --git a/skins/common/topbutton.js b/skins/common/topbutton.js
new file mode 100644
index 0000000..bf57ed1
--- /dev/null
+++ b/skins/common/topbutton.js
@@ -0,0 +1,15 @@
+(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/108323
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I866cd88201948177da2fec3cc9d4c713bb39bc0f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Gerrit Patch Uploader <gerritpatchuploa...@gmail.com>
Gerrit-Reviewer: Kunalgrover05 <kunalgrove...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to