From 1f4f99744b90c36c57a41f07bb7b7eec61034719 Mon Sep 17 00:00:00 2001 From: Lorenzo Natali Date: Tue, 28 Mar 2017 13:11:53 +0200 Subject: [PATCH 1/3] Fix #1633. Add scroll to top plugin --- docma-config.json | 4 ++- package.json | 1 + web/client/localConfig.json | 2 +- web/client/plugins/ScrollTop.jsx | 52 ++++++++++++++++++++++++++++++ web/client/product/plugins.js | 3 +- web/client/translations/data.de-DE | 1 + web/client/translations/data.en-US | 1 + web/client/translations/data.fr-FR | 1 + web/client/translations/data.it-IT | 1 + 9 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 web/client/plugins/ScrollTop.jsx diff --git a/docma-config.json b/docma-config.json index a17bba87a2..f3719d60cc 100644 --- a/docma-config.json +++ b/docma-config.json @@ -131,7 +131,9 @@ "web/client/plugins/BackgroundSwitcher.jsx", "web/client/plugins/Map.jsx", "web/client/plugins/Identify.jsx", - "web/client/plugins/Login.jsx" + "web/client/plugins/Login.jsx", + + "web/client/plugins/ScrollTop" ] }, "./docs/**/*md", diff --git a/package.json b/package.json index c88620b3fa..3c444a186c 100644 --- a/package.json +++ b/package.json @@ -132,6 +132,7 @@ "react-responsive": "1.1.3", "react-router": "2.5.2", "react-router-redux": "3.0.0", + "react-scroll-up": "^1.2.1", "react-select": "1.0.0-rc.1", "react-selectize": "2.0.3", "react-share": "1.8.0", diff --git a/web/client/localConfig.json b/web/client/localConfig.json index 2132105f90..387d7546fe 100644 --- a/web/client/localConfig.json +++ b/web/client/localConfig.json @@ -263,7 +263,7 @@ "cfg": { "className": "navbar shadow navbar-home" } - }, "ManagerMenu", "Login", "Language", "Attribution"], + }, "ManagerMenu", "Login", "Language", "Attribution", "ScrollTop"], "maps": ["Header", "Fork", "MapSearch", "HomeDescription", "MapType", "ThemeSwitcher", "CreateNewMap", "Maps", "Examples", "Footer"], "manager": ["Header", "Redirect", "Manager", "Home", "UserManager", "GroupManager", "Footer"] } diff --git a/web/client/plugins/ScrollTop.jsx b/web/client/plugins/ScrollTop.jsx new file mode 100644 index 0000000000..b372830ba7 --- /dev/null +++ b/web/client/plugins/ScrollTop.jsx @@ -0,0 +1,52 @@ +/* + * Copyright 2017, GeoSolutions Sas. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. + */ +const React = require('react'); +const ScrollUp = require('react-scroll-up'); +const Message = require('../components/I18N/Message'); +const {Glyphicon, Button, OverlayTrigger, Tooltip} = require('react-bootstrap'); + +/** + * ScrollUp Plugin. Show a button that allows to scroll to the top of the page. Only for full pages. + * @prop style the style of the scrollUp div + * @memberof plugins + * @static + */ +const ScrollTop = React.createClass({ + propTypes: { + style: React.PropTypes.object, + showUnder: React.PropTypes.number + }, + getDefaultProps() { + return { + showUnder: 200, + style: { + zIndex: 10, + position: 'fixed', + bottom: 50, + right: 30, + cursor: 'pointer', + transitionDuration: '0.2s', + transitionTimingFunction: 'linear', + transitionDelay: '0s' + } + }; + }, + render() { + return ( + + }> + + + ); + } +}); + + +module.exports = { + ScrollTopPlugin: ScrollTop +}; diff --git a/web/client/product/plugins.js b/web/client/product/plugins.js index f2bcb7bf4a..bdff739f33 100644 --- a/web/client/product/plugins.js +++ b/web/client/product/plugins.js @@ -62,7 +62,8 @@ module.exports = { QueryPanelPlugin: require('../plugins/QueryPanel'), FeatureGridPlugin: require('../plugins/FeatureGrid'), TutorialPlugin: require('../plugins/Tutorial'), - ThemeSwitchePluginr: require('../plugins/ThemeSwitcher') + ThemeSwitchePluginr: require('../plugins/ThemeSwitcher'), + ScrollTopPlugin: require('../plugins/ScrollTop') }, requires: { ReactSwipe: require('react-swipeable-views').default, diff --git a/web/client/translations/data.de-DE b/web/client/translations/data.de-DE index 38ffd70ce0..6465137ea9 100644 --- a/web/client/translations/data.de-DE +++ b/web/client/translations/data.de-DE @@ -69,6 +69,7 @@ "Applications": "Anwendungen", "Examples": "Beispiele", "LinkedinGroup": "Mapstore Linkedin Gruppe", + "scrollTop": "An den Anfang der Seite scrollen", "ml": { "title": "Bleibe in Verbindung und auf dem Laufenden mit der Mailing Liste", "subscribe_users": "Abonniere die Benutzer Mailing Liste", diff --git a/web/client/translations/data.en-US b/web/client/translations/data.en-US index 38e4b093f4..b8aadcfa4e 100644 --- a/web/client/translations/data.en-US +++ b/web/client/translations/data.en-US @@ -69,6 +69,7 @@ "Applications": "Applications", "Examples": "Examples", "LinkedinGroup": "Mapstore Linkedin Group", + "scrollTop": "Scroll to the top of the page", "ml": { "title": "Keep in touch and stay up-to-date with the mailing lists", "subscribe_users": "Subscribe Users Mailing List", diff --git a/web/client/translations/data.fr-FR b/web/client/translations/data.fr-FR index f60e80f9e3..c96b299313 100644 --- a/web/client/translations/data.fr-FR +++ b/web/client/translations/data.fr-FR @@ -70,6 +70,7 @@ "Applications": "Applications", "Examples": "Exemples", "LinkedinGroup": "Mapstore Linkedin groupe", + "scrollTop": "Retour en haut de la page", "ml": { "title": "Restez au fait des derniers développements via les mailing lists", "subscribe_users": "Souscrire à la Mailing List utilisateurs", diff --git a/web/client/translations/data.it-IT b/web/client/translations/data.it-IT index 6015884853..9eba02a033 100644 --- a/web/client/translations/data.it-IT +++ b/web/client/translations/data.it-IT @@ -69,6 +69,7 @@ "Applications": "Applicazioni", "Examples": "Esempi", "LinkedinGroup": "Gruppo Linkedin Mapstore", + "scrollTop": "Torna all'inizio della pagina", "ml": { "title": "Resta in contatto e tieniti aggiornato con le mailing list", "subscribe_users": "Sottoscrivi la mailing list degli utenti", From 7b02ed8399886e6ddce3a09c5ca9fd5b3ff1a755 Mon Sep 17 00:00:00 2001 From: Lorenzo Natali Date: Tue, 28 Mar 2017 13:17:12 +0200 Subject: [PATCH 2/3] fixed docs --- docma-config.json | 2 +- web/client/plugins/ScrollTop.jsx | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docma-config.json b/docma-config.json index f3719d60cc..d7e5854f42 100644 --- a/docma-config.json +++ b/docma-config.json @@ -133,7 +133,7 @@ "web/client/plugins/Identify.jsx", "web/client/plugins/Login.jsx", - "web/client/plugins/ScrollTop" + "web/client/plugins/ScrollTop.jsx" ] }, "./docs/**/*md", diff --git a/web/client/plugins/ScrollTop.jsx b/web/client/plugins/ScrollTop.jsx index b372830ba7..c16867cb04 100644 --- a/web/client/plugins/ScrollTop.jsx +++ b/web/client/plugins/ScrollTop.jsx @@ -12,8 +12,10 @@ const {Glyphicon, Button, OverlayTrigger, Tooltip} = require('react-bootstrap'); /** * ScrollUp Plugin. Show a button that allows to scroll to the top of the page. Only for full pages. - * @prop style the style of the scrollUp div + * @prop style {object} the style of the scrollUp div + * @prop showUnder {number} pixels of scroll before to show the button * @memberof plugins + * @class * @static */ const ScrollTop = React.createClass({ From 95f47738009e44408369fb9a8fb127aaac6e444d Mon Sep 17 00:00:00 2001 From: Lorenzo Natali Date: Tue, 28 Mar 2017 14:04:22 +0200 Subject: [PATCH 3/3] Fixed version and empty line --- docma-config.json | 1 - package.json | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/docma-config.json b/docma-config.json index d7e5854f42..eb40f9dd6a 100644 --- a/docma-config.json +++ b/docma-config.json @@ -132,7 +132,6 @@ "web/client/plugins/Map.jsx", "web/client/plugins/Identify.jsx", "web/client/plugins/Login.jsx", - "web/client/plugins/ScrollTop.jsx" ] }, diff --git a/package.json b/package.json index 3c444a186c..c5615ba3b1 100644 --- a/package.json +++ b/package.json @@ -132,7 +132,7 @@ "react-responsive": "1.1.3", "react-router": "2.5.2", "react-router-redux": "3.0.0", - "react-scroll-up": "^1.2.1", + "react-scroll-up": "1.2.1", "react-select": "1.0.0-rc.1", "react-selectize": "2.0.3", "react-share": "1.8.0",