Skip to content

Commit

Permalink
Updated to backbone 1.1.0, fixes #6
Browse files Browse the repository at this point in the history
  • Loading branch information
johvik committed Oct 20, 2013
1 parent 4b724f2 commit 20de486
Show file tree
Hide file tree
Showing 15 changed files with 31 additions and 17 deletions.
6 changes: 2 additions & 4 deletions js/vendor/backbone-min.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion js/views/active/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ define([
], function($, _, Backbone, Vm, Events, Workouts, Exercises, ActiveStartView, ActiveStepView, ActiveSummaryView, globalNotFoundTemplate, workoutDataGoneTemplate) {
var ActiveRunPage = Backbone.View.extend({
el : '#page',
initialize : function() {
initialize : function(options) {
this.options = options;
var workout = Workouts.get(this.options.workoutId);
if (_.isUndefined(workout)) {
this.listenTo(Workouts, 'sync', this.render); // If workout isn't loaded directly
Expand Down
3 changes: 2 additions & 1 deletion js/views/active/step.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ define([
'change input#weight-step' : 'onDataChange',
'change input#reps-step' : 'onDataChange'
},
initialize : function() {
initialize : function(options) {
this.options = options;
this.data = JSON.parse(sessionStorage.getItem('workoutData'));
this.exerciseData = JSON.parse(sessionStorage.getItem('exerciseData'));
var setData = this.exerciseData[this.options.step - 1];
Expand Down
3 changes: 2 additions & 1 deletion js/views/active/steprow.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ define([
], function($, _, Backbone, Events, activeStepRowTemplate) {
var ActiveStepRow = Backbone.View.extend({
tagName : 'tr',
initialize : function() {
initialize : function(options) {
this.options = options;
this.listenTo(Events, 'steprows:clear', this.remove);
},
render : function() {
Expand Down
3 changes: 2 additions & 1 deletion js/views/active/summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ define([
'click tr.click' : 'onRowClick',
'change input#activeDate' : 'onDataChange'
},
initialize : function() {
initialize : function(options) {
this.options = options;
this.data = JSON.parse(sessionStorage.getItem('workoutData'));
this.$el.html(_.template(activeSummaryTemplate, {
workoutName : this.getWorkoutName(),
Expand Down
3 changes: 2 additions & 1 deletion js/views/active/summaryrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ define([
var ActiveSummaryRow = Backbone.View.extend({
tagName : 'tr',
className : 'click',
initialize : function() {
initialize : function(options) {
this.options = options;
this.listenTo(Exercises, 'sync', this.render);
},
render : function() {
Expand Down
3 changes: 2 additions & 1 deletion js/views/exercise/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ define([
'keyup input' : 'onKeyup',
'keypress input' : 'onKeypress'
},
initialize : function() {
initialize : function(options) {
this.options = options;
this.$el.html(exerciseEditTemplate);
},
render : function() {
Expand Down
3 changes: 2 additions & 1 deletion js/views/exercise/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ define([
events : {
'click #create-exercise' : 'createExercise'
},
initialize : function() {
initialize : function(options) {
this.options = options;
this.listenTo(Exercises, 'change:_id', function(e) {
// New items will trigger id change
this.options.editId = e.id;
Expand Down
3 changes: 2 additions & 1 deletion js/views/exercise/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ define([
], function($, _, Backbone, Vm, Exercises, exerciseSelectAddTemplate, exerciseSelectRemoveTemplate, exerciseOptionTemplate, exerciseOptionSelectTemplate) {
var ExerciseSelectPage = Backbone.View.extend({
className : 'form-group',
initialize : function() {
initialize : function(options) {
this.options = options;
this.listenTo(Exercises, 'add', this.addOne);
this.listenTo(Exercises, 'reset sort', this.reset);
if (this.options.type === 'add') {
Expand Down
3 changes: 3 additions & 0 deletions js/views/global/confirm.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ define([
'backbone',
], function($, _, Backbone) {
var ConfirmView = Backbone.View.extend({
initialize : function(options) {
this.options = options;
},
render : function() {
var message = this.options.message || 'Are you sure?';
if (true == confirm(message)) {
Expand Down
3 changes: 2 additions & 1 deletion js/views/history/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ define([
], function($, _, Backbone, Vm, Events, HistoryData, Workouts, WeightRowView, WorkoutDataRowView, historyListTemplate) {
var HistoryDataPage = Backbone.View.extend({
el : '#page',
initialize : function() {
initialize : function(options) {
this.options = options;
this.listenTo(Workouts, 'sync', this.reset); // If workouts aren't loaded directly
this.listenTo(HistoryData, 'add', this.addOne);
this.listenTo(HistoryData, 'reset sort', this.reset);
Expand Down
3 changes: 2 additions & 1 deletion js/views/history/weight/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ define([
'keyup input' : 'onKeyup',
'keypress input' : 'onKeypress'
},
initialize : function() {
initialize : function(options) {
this.options = options;
this.$el.html(weightEditTemplate);
},
render : function() {
Expand Down
3 changes: 2 additions & 1 deletion js/views/history/workoutdata/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ define([
], function($, _, Backbone, Vm, Events, Workouts, Exercises, ActiveStepView, ActiveSummaryView, workoutDataGoneTemplate) {
var WorkoutDataEditPage = Backbone.View.extend({
el : '#page',
initialize : function() {
initialize : function(options) {
this.options = options;
var workout = Workouts.get(this.options.workoutId);
if (_.isUndefined(workout)) {
this.listenTo(Workouts, 'sync', this.render); // If workout isn't loaded directly
Expand Down
3 changes: 2 additions & 1 deletion js/views/workout/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ define([
'keyup input' : 'onKeyup',
'keypress input' : 'onKeypress'
},
initialize : function() {
initialize : function(options) {
this.options = options;
this.$el.html(workoutEditTemplate);
this.selectAddView = new ExerciseSelectView({
type : 'add'
Expand Down
3 changes: 2 additions & 1 deletion js/views/workout/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ define([
events : {
'click #create-workout' : 'createWorkout'
},
initialize : function() {
initialize : function(options) {
this.options = options;
this.listenTo(Workouts, 'change:_id', function(w) {
// New items will trigger id change
this.options.editId = w.id;
Expand Down

0 comments on commit 20de486

Please sign in to comment.