Merge pull request #278 from FreeCodeCamp/accessability

Fix some bugs, improver perf of show all bonfires/challenges and add buttons to challenge views
This commit is contained in:
Berkeley Martinez
2015-03-30 13:12:56 -07:00
11 changed files with 85 additions and 47 deletions

View File

@ -12,10 +12,12 @@ var _ = require('lodash'),
*/
exports.showAllBonfires = function(req, res) {
var completedBonfires = req.user.completedBonfires.map(function(elem) {
return elem._id;
});
var completedBonfires = [];
if(req.user) {
completedBonfires = req.user.completedBonfires.map(function (elem) {
return elem._id;
});
}
var noDuplicateBonfires = R.uniq(completedBonfires);
var data = {};
data.bonfireList = resources.allBonfireNames();

View File

@ -11,9 +11,12 @@ var _ = require('lodash'),
*/
exports.showAllCoursewares = function(req, res) {
var completedCoursewares = req.user.completedCoursewares.map(function(elem) {
return elem._id;
});
var completedList = [];
if(req.user) {
completedList = req.user.completedList.map(function (elem) {
return elem._id;
});
}
var noDuplicatedCoursewares = R.uniq(completedCoursewares);
var data = {};

View File

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

View File

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

View File

@ -139,7 +139,7 @@ block content
- else
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-content
.modal-header.all-list-header Bonfires

View File

@ -39,7 +39,7 @@ block content
| Less information
br
- 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
br
| (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
script.
var userLoggedIn = false;
.button-spacer
#showAllButton.btn.btn-info.btn-big.btn-block Show all challenges
br
ul#testSuite.list-group
br
@ -83,3 +85,10 @@ block content
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
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
| Less information
#submitButton.btn.btn-primary.btn-big.btn-block Run code (ctrl + enter)
#showAllButton.btn.btn-info.btn-big.btn-block Show all challenges
br
form.code
.form-group.codeMirrorView
@ -74,3 +75,10 @@ block content
= phrase
- else
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}')
br
- 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.
var userLoggedIn = true;
- 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.
var userLoggedIn = false;
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 passedCoursewareHash = !{JSON.stringify(coursewareHash)};
var challengeName = !{JSON.stringify(name)};
@ -52,3 +54,10 @@ block content
$('#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

@ -3,6 +3,8 @@ h3
script(src='/js/lib/ramda/ramda.min.js')
script.
var getLinkedName = function getLinkedName(name) {
// ensure name is a string
name = name + '';
return name.toLowerCase().replace(/\s/g, '-');
}
$.ajax({
@ -11,14 +13,18 @@ h3
})
.success(
function(data) {
var docfrag = document.createDocumentFragment();
for (var i = 0; i < data.bonfireList.length; i++) {
var li = document.createElement('li');
var li = document.createElement("li");
var linkedName = getLinkedName(data.bonfireList[i].name);
if (R.contains(data.bonfireList[i]._id, data.completedList)) {
if (data.completedList.length > 0 && R.contains(data.bonfireList[i]._id, data.completedList)) {
$(li).html("<span class='sr-only'>completed</span><a href='/bonfires/" + linkedName + "'>" + data.bonfireList[i].name + "</a></li>");
$(li).addClass('strikethrough');
} else {
$(li).html("<a href='/bonfires/" + linkedName + "'>" + data.bonfireList[i].name + "</a></li>");
}
$(li).html("<a href='/bonfires/" + linkedName + "'>" + data.bonfireList[i].name + "</a></li>");
$(li).appendTo($('#bonfireList'));
}
docfrag.appendChild(li);
};
$('#bonfireList').append(docfrag);
});

View File

@ -1,8 +1,28 @@
h3
ol(start='0')
for challenge in challenges
li
a(href="/challenges/#{challenge.challengeNumber}", class="#{ (cc && cc[challenge.challengeNumber] > 0) ? 'strikethrough' : '' }") #{challenge.name}
| &thinsp; (#{challenge.time} mins)
ol#coursewareList
script(src='/js/lib/ramda/ramda.min.js')
script.
var getLinkedName = function getLinkedName(name) {
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'));
}
});