Skip to content

Commit

Permalink
Show help text window on mouseover
Browse files Browse the repository at this point in the history
This ensures that the window with the helptexts appears on the
first mouseover-event on a 'HelpBadge' (not on help modus activation).
To hide the helptext window the help modus has to be disabled.
  • Loading branch information
chrismayer committed Nov 9, 2015
1 parent b24eb94 commit f72225c
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 14 deletions.
12 changes: 11 additions & 1 deletion web/client/actions/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

const CHANGE_HELP_STATE = 'CHANGE_HELP_STATE';
const CHANGE_HELP_TEXT = 'CHANGE_HELP_TEXT';
const CHANGE_HELPWIN_VIZ = 'CHANGE_HELPWIN_VIZ';

function changeHelpState(enabled) {
return {
Expand All @@ -23,9 +24,18 @@ function changeHelpText(helpText) {
};
}

function changeHelpwinVisibility(helpwinViz) {
return {
type: CHANGE_HELPWIN_VIZ,
helpwinViz: helpwinViz
};
}

module.exports = {
CHANGE_HELP_STATE,
CHANGE_HELP_TEXT,
CHANGE_HELPWIN_VIZ,
changeHelpState,
changeHelpText
changeHelpText,
changeHelpwinVisibility
};
8 changes: 5 additions & 3 deletions web/client/components/Help/HelpBadge.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,24 @@ var HelpBadge = React.createClass({
id: React.PropTypes.string,
helpText: React.PropTypes.string,
isVisible: React.PropTypes.bool,
changeHelpText: React.PropTypes.func
changeHelpText: React.PropTypes.func,
changeHelpwinVisibility: React.PropTypes.func
},
getDefaultProps() {
return {
helpText: '',
isVisible: false
};
},
onClick() {
onMouseOver() {
this.props.changeHelpText({helpText: this.props.helpText});
this.props.changeHelpwinVisibility({helpwinViz: true});
},
render() {
return (
<Badge
id={this.props.id}
onClick={this.onClick}
onMouseOver={this.onMouseOver}
className={this.props.isVisible ? '' : 'hidden'}
>?</Badge>
);
Expand Down
49 changes: 49 additions & 0 deletions web/client/components/Help/HelpToggleBtn.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* Copyright 2015, 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.
*/


var React = require('react');
var ToggleButton = require('../buttons/ToggleButton');
require("./help.css");

/**
* A toggle button class for enabling / disabling help modus
*/
let HelpToggleBtn = React.createClass({
propTypes: {
key: React.PropTypes.string,
isButton: React.PropTypes.bool,
glyphicon: React.PropTypes.string,
pressed: React.PropTypes.bool,
changeHelpState: React.PropTypes.func,
changeHelpwinVisibility: React.PropTypes.func
},
getDefaultProps() {
return {
key: 'helpButton',
isButton: true,
glyphicon: 'question-sign'
};
},
onClick: function() {
this.props.changeHelpState(!this.props.pressed);
this.props.changeHelpwinVisibility(false);
},
render: function() {
return (
<ToggleButton
key={this.props.key}
isButton={this.props.isButton}
glyphicon={this.props.glyphicon}
pressed={this.props.pressed}
onClick={this.onClick}/>
);
}
});

module.exports = HelpToggleBtn;
4 changes: 3 additions & 1 deletion web/client/components/Help/HelpWrapper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ let HelpWrapper = React.createClass({
propTypes: {
helpText: React.PropTypes.string,
helpEnabled: React.PropTypes.bool,
changeHelpText: React.PropTypes.func
changeHelpText: React.PropTypes.func,
changeHelpwinVisibility: React.PropTypes.func
},

render: function() {
Expand All @@ -34,6 +35,7 @@ let HelpWrapper = React.createClass({
isVisible = {this.props.helpEnabled}
helpText = {this.props.helpText}
changeHelpText = {this.props.changeHelpText}
changeHelpwinVisibility = {this.props.changeHelpwinVisibility}
/>
{this.props.children}
</div>);
Expand Down
19 changes: 11 additions & 8 deletions web/client/examples/viewer/plugins/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ var {textSearch, resultsPurge} = require("../../../actions/search");

var {changeMeasurementState} = require('../../../actions/measurement');

var {changeHelpState, changeHelpText} = require('../../../actions/help');
var {changeHelpState, changeHelpText, changeHelpwinVisibility} = require('../../../actions/help');
var HelpWrapper = require('../../../components/Help/HelpWrapper');
var HelpTextPanel = require('../../../components/Help/HelpTextPanel');
var HelpToggleBtn = require('../../../components/Help/HelpToggleBtn');

var React = require('react');

Expand Down Expand Up @@ -81,6 +82,7 @@ module.exports = {
helpText={<Message msgId="helptexts.searchBar"/>}
helpEnabled={props.help.enabled}
changeHelpText={props.changeHelpText}
changeHelpwinVisibility={props.changeHelpwinVisibility}
>
<SearchBar key="seachBar" onSearch={props.textSearch} onSearchReset={props.resultsPurge}/>
</HelpWrapper>,
Expand Down Expand Up @@ -172,12 +174,10 @@ module.exports = {
disabled: (props.mapHistory.future.length > 0) ? false : true
}}/>
</Settings>
<ToggleButton
key="helpButton"
isButton={true}
glyphicon="question-sign"
<HelpToggleBtn
pressed={props.help.enabled}
onClick={props.changeHelpState}/>
changeHelpState={props.changeHelpState}
changeHelpwinVisibility={props.changeHelpwinVisibility}/>
</MapToolBar>,
<GetFeatureInfo
key="getFeatureInfo"
Expand All @@ -202,6 +202,7 @@ module.exports = {
helpText={<Message msgId="helptexts.scaleBox"/>}
helpEnabled={props.help.enabled}
changeHelpText={props.changeHelpText}
changeHelpwinVisibility={props.changeHelpwinVisibility}
>
<ScaleBox
key="scaleBox"
Expand All @@ -212,6 +213,7 @@ module.exports = {
helpText={<Message msgId="helptexts.zoomToMaxExtentButton"/>}
helpEnabled={props.help.enabled}
changeHelpText={props.changeHelpText}
changeHelpwinVisibility={props.changeHelpwinVisibility}
>
<ZoomToMaxExtentButton
key="zoomToMaxExtent"
Expand All @@ -224,7 +226,7 @@ module.exports = {
<GlobalSpinner key="globalSpinner"/>,
<HelpTextPanel
key="helpTextPanel"
isVisible={props.help.enabled}
isVisible={props.help.helpwinViz}
helpText={props.help.helpText}/>
];
},
Expand All @@ -251,6 +253,7 @@ module.exports = {
changeMapInfoFormat,
changeMeasurementState,
changeHelpState,
changeHelpText
changeHelpText,
changeHelpwinVisibility
}
};
8 changes: 7 additions & 1 deletion web/client/reducers/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

var {
CHANGE_HELP_STATE,
CHANGE_HELP_TEXT
CHANGE_HELP_TEXT,
CHANGE_HELPWIN_VIZ
} = require('../actions/help');

const assign = require('object-assign');
Expand All @@ -24,6 +25,11 @@ function help(state = null, action) {
helpText: action.helpText
});
}
case CHANGE_HELPWIN_VIZ: {
return assign({}, state, {
helpwinViz: action.helpwinViz
});
}
default:
return state;
}
Expand Down

0 comments on commit f72225c

Please sign in to comment.