Skip to content

Commit

Permalink
Merge pull request #54 from makinacorpus/menu
Browse files Browse the repository at this point in the history
Menu
  • Loading branch information
lellex authored Mar 2, 2017
2 parents c5f9d29 + a1e16b2 commit 261c30a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion electron/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function createWindow () {
mainWindow.loadURL('file://' + __dirname + '/index.html');

// Open the DevTools.
mainWindow.webContents.openDevTools();
// mainWindow.webContents.openDevTools();
app.commandLine.appendSwitch('enable-speech-dispatcher');

// Emitted when the window is closed.
Expand Down
2 changes: 1 addition & 1 deletion modules/der-reader/src/der-reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var DerReader = {
childRoutes: [
{ path: 'file', component: SelectFile, name: 'Charger un nouveau document en relief' },
{ path: 'doc', component: SelectDocument, name: 'Définir le document à visualiser' },
{ path: 'mode', component: SwitchMode, name: 'Changer le mode de lecture' },
// { path: 'mode', component: SwitchMode, name: 'Changer le mode de lecture' },
{ path: 'quit', name: 'Quitter l\'application' }
]
},
Expand Down
9 changes: 8 additions & 1 deletion modules/der-reader/src/routes/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,14 @@ const App = React.createClass({
},

changeDerFile: function(file) {
this.setState({derFile: file, selectedDocument: 0});
if (file !== null) {
this.setState({derFile: file, selectedDocument: 0}, () => {
// this.context.router.push('/');
this.toggleMenu('menu', 'Nouveau document sélectionné, fermeture du menu')
});
} else {
this.context.router.push('/menu');
}
},

changeDocument: function(fileIndex) {
Expand Down
10 changes: 7 additions & 3 deletions modules/der-reader/src/routes/Menu/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ const Menu = React.createClass({
},

componentWillReceiveProps: function(nextProps) {
if (nextProps.options !== this.props.options) {
this.context.router.push('/');
}
// if (nextProps.options !== this.props.options) {
// this.context.router.push('/');
// } else {
// if (nextProps.routes[nextProps.routes.length-1].path === 'file') {
// this.context.router.push('/menu');
// }
// }
},

render: function() {
Expand Down
10 changes: 7 additions & 3 deletions modules/der-reader/src/routes/Menu/SelectFile/SelectFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ var SelectFile = React.createClass({
componentDidMount: function() {
document.body.onfocus = () => {
if (this.state.file === null) {
this.props.actions.toggleMenu('menu', 'Fermeture du menu');
this.props.options.tts.speak('Aucun fichier sélectionné, retour au menu');
this.props.actions.changeDerFile(null);
}
}
this.refs.inputfile.click();
Expand All @@ -21,8 +22,11 @@ var SelectFile = React.createClass({
if (this.refs.inputfile) {
let file = this.refs.inputfile.files[0];
if (file !== undefined) {
this.props.actions.changeDerFile(file);
this.props.actions.changeFilter(null);
this.setState({file: file}, () => {
this.props.actions.changeDerFile(file);
this.props.actions.changeFilter(null);
});

} else {
this.props.options.message('Aucun fichier seléctionné', 'error');
}
Expand Down

0 comments on commit 261c30a

Please sign in to comment.