diff --git a/src/js/App.js b/src/js/App.js
index 5c769576..8a953284 100755
--- a/src/js/App.js
+++ b/src/js/App.js
@@ -30,11 +30,19 @@ class App extends React.Component{
super(props);
this.handleKeyUp = this.handleKeyUp.bind(this);
this.handleKeyDown = this.handleKeyDown.bind(this);
+ this.handleWindowResize = this.handleWindowResize.bind(this);
}
componentWillMount(){
window.addEventListener("keyup", this.handleKeyUp, false);
window.addEventListener("keydown", this.handleKeyDown, false);
+ window.addEventListener("resize", this.handleWindowResize, false);
+ }
+
+ componentWillUnmount(){
+ window.removeEventListener("keyup", this.handleKeyUp, false);
+ window.removeEventListener("keydown", this.handleKeyDown, false);
+ window.removeEventListener("resize", this.handleWindowResize, false);
}
componentDidMount(){
@@ -56,6 +64,9 @@ class App extends React.Component{
// hide our sidebar
this.props.uiActions.toggleSidebar( false )
});
+
+ // Check our slim_mode
+ this.handleWindowResize(null)
}
componentWillReceiveProps(nextProps){
@@ -76,11 +87,6 @@ class App extends React.Component{
}
}
- componentWillUnmount(){
- window.removeEventListener("keyup", this.handleKeyUp, false);
- window.removeEventListener("keydown", this.handleKeyDown, false);
- }
-
shouldTriggerShortcut(e){
var ignoreNodes = ['INPUT', 'TEXTAREA']
var keyCodes = [32,27,191,37,38,39,40,70]
@@ -95,6 +101,21 @@ class App extends React.Component{
}
}
+ handleWindowResize(e){
+ var width = Math.max(document.documentElement.clientWidth, window.innerWidth || 0)
+ var height = Math.max(document.documentElement.clientHeight, window.innerHeight || 0)
+
+ if (width <= 800){
+ if (!this.props.slim_mode){
+ this.props.uiActions.setSlimMode(true)
+ }
+ } else {
+ if (this.props.slim_mode){
+ this.props.uiActions.setSlimMode(false)
+ }
+ }
+ }
+
handleKeyDown(e){
this.shouldTriggerShortcut(e)
}
@@ -197,6 +218,7 @@ class App extends React.Component{
if (this.props.dragger && this.props.dragger.active) className += ' dragging'
if (this.props.sidebar_open) className += ' sidebar-open'
if (this.props.modal) className += ' modal-open'
+ if (this.props.slim_mode) className += ' slim-mode'
if (helpers.isTouchDevice()){
className += ' touch'
} else {
@@ -236,6 +258,7 @@ class App extends React.Component{
const mapStateToProps = (state, ownProps) => {
return {
+ slim_mode: state.ui.slim_mode,
broadcasts: (state.ui.broadcasts ? state.ui.broadcasts : []),
volume: (state.mopidy.volume ? state.mopidy.volume : false),
notifications: (state.ui.notifications ? state.ui.notifications : []),
diff --git a/src/js/bootstrap.js b/src/js/bootstrap.js
index 8d749e94..2594daef 100755
--- a/src/js/bootstrap.js
+++ b/src/js/bootstrap.js
@@ -53,6 +53,7 @@ var initialState = {
autocomplete_results: {}
},
ui: {
+ slim_mode: false,
current_tracklist: [],
current_tltrack: false,
notifications: [],
diff --git a/src/js/components/DebugInfo.js b/src/js/components/DebugInfo.js
index 1c2d8564..41ff9e96 100755
--- a/src/js/components/DebugInfo.js
+++ b/src/js/components/DebugInfo.js
@@ -81,6 +81,9 @@ class DebugInfo extends React.Component{
Enqueue batches: {this.props.mopidy.enqueue_uris_batches ? this.props.mopidy.enqueue_uris_batches.length : '0'}
+