Add show all challenges button to all challenge views and refactor bonfire to use same modal and button ids

This commit is contained in:
Michael Q Larson
2015-03-29 17:09:12 -07:00
parent f0ae47dcf2
commit aa01a896a5
9 changed files with 63 additions and 35 deletions

View File

@ -11,6 +11,7 @@ var _ = require('lodash'),
*/ */
exports.showAllCoursewares = function(req, res) { exports.showAllCoursewares = function(req, res) {
console.log('i made it!');
var completedCoursewares = req.user.completedCoursewares.map(function(elem) { var completedCoursewares = req.user.completedCoursewares.map(function(elem) {
return elem._id; return elem._id;
}); });

View File

@ -836,6 +836,10 @@ iframe.iphone {
max-height: 110px; max-height: 110px;
} }
.button-spacer {
padding: 3px 0 2px 0;
}
.spacer { .spacer {
padding: 15px 0 15px 0; padding: 15px 0 15px 0;
} }

View File

@ -179,7 +179,7 @@ $(document).ready(function() {
}); });
$('#showAllButton').on('click', function() { $('#showAllButton').on('click', function() {
$('#all-bonfires-dialog').modal('show'); $('#all-challenges-dialog').modal('show');
}); });
$('.next-challenge-button').on('click', function() { $('.next-challenge-button').on('click', function() {

View File

@ -139,7 +139,7 @@ block content
- else - else
a.animated.fadeIn.btn.btn-lg.signup-btn.btn-block(href='/login') Sign in so you can save your progress a.animated.fadeIn.btn.btn-lg.signup-btn.btn-block(href='/login') Sign in so you can save your progress
#all-bonfires-dialog.modal(tabindex='-1') #all-challenges-dialog.modal(tabindex='-1')
.modal-dialog.animated.fadeInUp.fast-animation .modal-dialog.animated.fadeInUp.fast-animation
.modal-content .modal-content
.modal-header.all-list-header Bonfires .modal-header.all-list-header Bonfires

View File

@ -39,7 +39,7 @@ block content
| Less information | Less information
br br
- if (user) - if (user)
a.btn.btn-primary.btn-lg.btn-block#next-courseware-button a.btn.btn-primary.btn-big.btn-block#next-courseware-button
| Go to my next challenge | Go to my next challenge
br br
| (ctrl + enter) | (ctrl + enter)
@ -49,6 +49,8 @@ block content
a.btn.btn-lg.signup-btn.btn-block(href='/login') Sign in so you can save your progress a.btn.btn-lg.signup-btn.btn-block(href='/login') Sign in so you can save your progress
script. script.
var userLoggedIn = false; var userLoggedIn = false;
.button-spacer
#showAllButton.btn.btn-info.btn-big.btn-block Show all challenges
br br
ul#testSuite.list-group ul#testSuite.list-group
br br
@ -83,3 +85,10 @@ block content
span.completion-icon.ion-checkmark-circled.text-primary span.completion-icon.ion-checkmark-circled.text-primary
a.animated.fadeIn.btn.btn-lg.signup-btn.btn-block(href='/login') Sign in so you can save your progress a.animated.fadeIn.btn.btn-lg.signup-btn.btn-block(href='/login') Sign in so you can save your progress
script(src="/js/lib/coursewares/coursewaresHCJQFramework_v0.1.1.js") script(src="/js/lib/coursewares/coursewaresHCJQFramework_v0.1.1.js")
#all-challenges-dialog.modal(tabindex='-1')
.modal-dialog.animated.fadeInUp.fast-animation
.modal-content
.modal-header.all-list-header Challenges
a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') ×
.modal-body
include ../partials/challenges

View File

@ -35,6 +35,7 @@ block content
span.ion-arrow-up-b span.ion-arrow-up-b
| Less information | Less information
#submitButton.btn.btn-primary.btn-big.btn-block Run code (ctrl + enter) #submitButton.btn.btn-primary.btn-big.btn-block Run code (ctrl + enter)
#showAllButton.btn.btn-info.btn-big.btn-block Show all challenges
br br
form.code form.code
.form-group.codeMirrorView .form-group.codeMirrorView
@ -74,3 +75,10 @@ block content
= phrase = phrase
- else - else
a.animated.fadeIn.btn.btn-lg.signup-btn.btn-block(href='/login') Sign in so you can save your progress a.animated.fadeIn.btn.btn-lg.signup-btn.btn-block(href='/login') Sign in so you can save your progress
#all-challenges-dialog.modal(tabindex='-1')
.modal-dialog.animated.fadeInUp.fast-animation
.modal-content
.modal-header.all-list-header Challenges
a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') ×
.modal-body
include ../partials/challenges

View File

@ -13,15 +13,17 @@ block content
iframe.embed-responsive-item(src='//player.vimeo.com/video/#{video}') iframe.embed-responsive-item(src='//player.vimeo.com/video/#{video}')
br br
- if (user) - if (user)
a.btn.btn-primary.btn-lg.btn-block#completed-courseware I've completed this challenge (ctrl + enter) a.btn.btn-primary.btn-big.btn-block#completed-courseware I've completed this challenge (ctrl + enter)
script. script.
var userLoggedIn = true; var userLoggedIn = true;
- else - else
a.btn.btn-lg.signup-btn.btn-block(href='/login') Sign in so you can save your progress a.btn.btn-big.signup-btn.btn-block(href='/login') Sign in so you can save your progress
script. script.
var userLoggedIn = false; var userLoggedIn = false;
br br
script(type="text/javascript"). .button-spacer
#showAllButton.btn.btn-info.btn-big.btn-block Show all challenges
script(type="text/javascript").
var tests = !{JSON.stringify(tests)}; var tests = !{JSON.stringify(tests)};
var passedCoursewareHash = !{JSON.stringify(coursewareHash)}; var passedCoursewareHash = !{JSON.stringify(coursewareHash)};
var challengeName = !{JSON.stringify(name)}; var challengeName = !{JSON.stringify(name)};
@ -52,3 +54,10 @@ block content
$('#complete-courseware-dialog').modal('show'); $('#complete-courseware-dialog').modal('show');
} }
}); });
#all-challenges-dialog.modal(tabindex='-1')
.modal-dialog.animated.fadeInUp.fast-animation
.modal-content
.modal-header.all-list-header Challenges
a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') ×
.modal-body
include ../partials/challenges

View File

@ -1,8 +1,28 @@
h3 h3
ol(start='0') ol#coursewareList
for challenge in challenges script(src='/js/lib/ramda/ramda.min.js')
li script.
a(href="/challenges/#{challenge.challengeNumber}", class="#{ (cc && cc[challenge.challengeNumber] > 0) ? 'strikethrough' : '' }") #{challenge.name} var getLinkedName = function getLinkedName(name) {
|   (#{challenge.time} mins) return name.toLowerCase().replace(/\s/g, '-');
}
$.ajax({
url: '/challenges/getCoursewareList',
type: 'GET'
})
.success(
function(data) {
var docfrag = document.createDocumentFragment();
for (var i = 0; i < data.coursewareList.length; i++) {
var li = document.createElement("li");
var linkedName = getLinkedName(data.coursewareList[i].name);
if (data.completedList.length > 0 && R.contains(data.coursewareList[i]._id, data.completedList)) {
$(li).html("<span class='sr-only'>completed</span><a href='/challenges/" + linkedName + "'>" + data.coursewareList[i].name + "</a></li>");
$(li).addClass('strikethrough');
} else {
$(li).html("<a href='/challenges/" + linkedName + "'>" + data.coursewareList[i].name + "</a></li>");
}
a.btn.btn-lg.btn-primary.btn-block(href="/done-with-first-100-hours", class="#{ ((points && points < 54) || (!points)) ? 'disabled' : '' }") I'm done with all the challenges! docfrag.appendChild(li);
};
$('#coursewareList').append(docfrag);
});

View File

@ -1,23 +0,0 @@
h3
ol#coursewareList
script.
var getLinkedName = function getLinkedName(name) {
return name.toLowerCase().replace(/\s/g, '-');
}
$.ajax({
url: '/coursewares/getCoursewareList',
type: 'GET'
})
.success(
function(data) {
for (var i = 0; i < data.coursewareList.length; i++) {
var li = document.createElement('li');
var linkedName = getLinkedName(data.coursewareList[i].name);
if (R.contains(data.coursewareList[i]._id, data.completedList)) {
$(li).addClass('strikethrough');
}
$(li).html("<a href='/coursewares/" + linkedName + "'>" + data.coursewareList[i].name + "</a></li>");
$(li).appendTo($('#coursewareList'));
}
});