Skip to content

Instantly share code, notes, and snippets.

@stan229
Forked from dmackerman/Main.js
Last active December 10, 2015 23:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stan229/4513177 to your computer and use it in GitHub Desktop.
Save stan229/4513177 to your computer and use it in GitHub Desktop.
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