-
-
Save stan229/4513177 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ext.define('Workout.controller.Main', { | |
extend : 'Ext.app.Controller', | |
config : { | |
models: [ | |
'Workout' | |
], | |
stores: [ | |
'Workouts' | |
], | |
views: [ | |
'Calendar', | |
'Logs', | |
'ManageWorkouts', | |
'Workout', | |
'Workouts', | |
'Exercise' | |
], | |
refs: { | |
shitHead : 'main', | |
mainMenu : 'mainmenu', | |
workoutsList: 'workouts' | |
}, | |
control: { | |
'mainmenu' : { | |
menuItemSelected : 'onMenuItemSelected' | |
}, | |
'workouts' : { | |
workoutSelected : 'onWorkoutSelected' | |
}, | |
'workout' : { | |
exerciseSelected : 'onExerciseSelected' | |
}, | |
'main' : { | |
titleDoubleTap: 'onTitleDoubleTap' | |
} | |
} | |
}, | |
onMenuItemSelected : function(action) { | |
var me = this, | |
store = Ext.getStore('Workouts'), | |
data = []; | |
this.getMain().push({ | |
xtype : action | |
}); | |
store.on('load', function () { | |
store.each(function (record) { | |
data.push(record.getData()); | |
}); | |
me.getWorkoutsList().setData(data); | |
}); | |
store.load(); | |
}, | |
onWorkoutSelected: function(workout) { | |
this.getMain().push({ | |
xtype: 'workout', | |
title: workout | |
}); | |
}, | |
onExerciseSelected: function(exercise) { | |
this.getMain().push({ | |
xtype: 'exercise', | |
title: exercise | |
}); | |
}, | |
/* when a user double taps the title, take them back to the home screen */ | |
onTitleDoubleTap: function() { | |
this.getShitHead().reset(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment