From aa01a896a50846ca9eecedea92f4400ffc3f7314 Mon Sep 17 00:00:00 2001 From: Michael Q Larson Date: Sun, 29 Mar 2015 17:09:12 -0700 Subject: [PATCH] Add show all challenges button to all challenge views and refactor bonfire to use same modal and button ids --- controllers/courseware.js | 1 + public/css/main.less | 4 ++++ public/js/main.js | 2 +- views/bonfire/show.jade | 2 +- views/coursewares/showHTML.jade | 11 ++++++++++- views/coursewares/showJS.jade | 8 ++++++++ views/coursewares/showVideo.jade | 15 ++++++++++++--- views/partials/challenges.jade | 32 ++++++++++++++++++++++++++------ views/partials/coursewares.jade | 23 ----------------------- 9 files changed, 63 insertions(+), 35 deletions(-) delete mode 100644 views/partials/coursewares.jade diff --git a/controllers/courseware.js b/controllers/courseware.js index 82987ea7a7..b218997959 100644 --- a/controllers/courseware.js +++ b/controllers/courseware.js @@ -11,6 +11,7 @@ var _ = require('lodash'), */ exports.showAllCoursewares = function(req, res) { + console.log('i made it!'); var completedCoursewares = req.user.completedCoursewares.map(function(elem) { return elem._id; }); diff --git a/public/css/main.less b/public/css/main.less index ad76627718..4ed3704882 100644 --- a/public/css/main.less +++ b/public/css/main.less @@ -836,6 +836,10 @@ iframe.iphone { max-height: 110px; } +.button-spacer { + padding: 3px 0 2px 0; +} + .spacer { padding: 15px 0 15px 0; } diff --git a/public/js/main.js b/public/js/main.js index 9e57f48afb..de082f167a 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -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() { diff --git a/views/bonfire/show.jade b/views/bonfire/show.jade index f72ef0dc4e..99ee61ba12 100644 --- a/views/bonfire/show.jade +++ b/views/bonfire/show.jade @@ -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 diff --git a/views/coursewares/showHTML.jade b/views/coursewares/showHTML.jade index 7ad3530f9b..e4ac72909e 100644 --- a/views/coursewares/showHTML.jade +++ b/views/coursewares/showHTML.jade @@ -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 diff --git a/views/coursewares/showJS.jade b/views/coursewares/showJS.jade index 3e33ee4a4b..3d54d61c42 100644 --- a/views/coursewares/showJS.jade +++ b/views/coursewares/showJS.jade @@ -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 diff --git a/views/coursewares/showVideo.jade b/views/coursewares/showVideo.jade index b6264c395a..9f35202412 100644 --- a/views/coursewares/showVideo.jade +++ b/views/coursewares/showVideo.jade @@ -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 diff --git a/views/partials/challenges.jade b/views/partials/challenges.jade index 0c959ff122..bea0d0a786 100644 --- a/views/partials/challenges.jade +++ b/views/partials/challenges.jade @@ -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} - |   (#{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("completed" + data.coursewareList[i].name + ""); + $(li).addClass('strikethrough'); + } else { + $(li).html("" + data.coursewareList[i].name + ""); + } -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! \ No newline at end of file + docfrag.appendChild(li); + }; + $('#coursewareList').append(docfrag); + }); diff --git a/views/partials/coursewares.jade b/views/partials/coursewares.jade deleted file mode 100644 index 8218b82c7a..0000000000 --- a/views/partials/coursewares.jade +++ /dev/null @@ -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("" + data.coursewareList[i].name + ""); - $(li).appendTo($('#coursewareList')); - - } - });