-
Notifications
You must be signed in to change notification settings - Fork 36
Added double click feature to calendar challenges #128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -130,13 +130,27 @@ app.controller('SummerCampController', function ($interval, $timeout, $scope, $r | |
| $scope.selectedSummerChallengeDay = startDate.date() + day; | ||
| $scope.selectedSummerChallenge = selectedChallenge; | ||
| $scope.selectedSummerChallengeObj = challenges[selectedChallenge]; | ||
| $scope.isFutureChallenge = (day > currentDayIndex()) ? true : false; | ||
| $scope.isFutureChallenge = isFutureChallenge(day); | ||
| analytics.track('Viewed Challenge ' + day, { | ||
| category : 'Viewed Summer Camp Challenge' | ||
| }); | ||
| countDownToNext(); | ||
| }; | ||
|
|
||
| /* | ||
| * Open a challenge by double-clicking and check if it's unlocked and not a future | ||
| * challenge. | ||
| * | ||
| * @param {Number} day | ||
| * @return void | ||
| */ | ||
| $scope.openChallenge = function (day) { | ||
| if (!$scope.isLocked(day) && !isFutureChallenge(day)) { | ||
| day = day + 1; | ||
| $location.path('/summercamp/challenge/' + day); | ||
| } | ||
| }; | ||
|
|
||
| /* | ||
| * Deselect a challenge and close challenge modal | ||
| * | ||
|
|
@@ -181,6 +195,16 @@ app.controller('SummerCampController', function ($interval, $timeout, $scope, $r | |
| return index === (now.getDay() || 7) - 1; | ||
| } | ||
|
|
||
| /* | ||
| * Returns true if challenge is a future challenge | ||
| * | ||
| * @param {Number} day | ||
| * @return {Boolean} | ||
| */ | ||
| function isFutureChallenge(day) { | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @arifshanji @rcocetta I've just refactored the isFutureChallenge into a function. Is this better? |
||
| return (day > currentDayIndex()) ? true : false; | ||
| }; | ||
|
|
||
| function currentDayIndex() { | ||
| var today = moment(), | ||
| diff = today.diff(startDate), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,6 +48,7 @@ | |
| ul.calendar | ||
| li.day(ng-repeat='day in range(21)') | ||
| a( | ||
| ng-dblClick='openChallenge(day)', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't you use the same code we already use to open challenges?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rcocetta the only way to open a challenge from the calendar before was through an href.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. |
||
| ng-click='selectChallenge(day)', | ||
| ng-class='{ locked: isLocked(day) && !currentDay(day), completed: isCompleted(day), current: isCurrent(day), unlocked: currentDay(day) }', | ||
| ) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
woah! Is this on master? We missed it!