diff --git a/views/coursewares/showVideo.jade b/views/coursewares/showVideo.jade index fa6f96da70..83b3ab759f 100644 --- a/views/coursewares/showVideo.jade +++ b/views/coursewares/showVideo.jade @@ -34,6 +34,24 @@ block content var passedCoursewareName = challengeName; var started = Math.floor(Date.now()); var challengeType = !{JSON.stringify(challengeType)}; + var controlEnterHandler = function(e) { + $('body').unbind('keypress'); + if (e.ctrlKey && e.keyCode == 13) { + $('#complete-courseware-dialog').modal('show'); + } else { + $('body').bind('keypress', controlEnterHandler); + } + }; + var modalControlEnterHandler = function(e) { + $('#complete-courseware-dialog').unbind('keypress'); + if (e.ctrlKey && e.keyCode == 13) { + $('#next-courseware-button').click(); + } else { + $('#complete-courseware-dialog').bind('keypress', modalControlEnterHandler); + } + }; + + #complete-courseware-dialog.modal(tabindex='-1') .modal-dialog.animated.zoomIn.fast-animation .modal-content @@ -45,6 +63,9 @@ block content span.completion-icon.ion-checkmark-circled.text-primary - if (user) a.animated.fadeIn.btn.btn-lg.btn-primary.btn-block#next-courseware-button(name='_csrf', value=_csrf) On to my next challenge (ctrl + enter) + script. + $('#complete-courseware-dialog').bind('keypress', modalControlEnterHandler); + - if (user.progressTimestamps.length > 2) a.animated.fadeIn.btn.btn-lg.btn-block.btn-twitter(href="https://twitter.com/intent/tweet?text=I%20just%20#{verb}%20%40FreeCodeCamp%20Bonfire:%20#{name}&url=http%3A%2F%2Ffreecodecamp.com/bonfires/#{dashedName}&hashtags=LearnToCode, JavaScript" target="_blank") i.fa.fa-twitter   @@ -53,8 +74,4 @@ block content a.animated.fadeIn.btn.btn-lg.signup-btn.btn-block(href='/login') Sign in so you can save your progress h1 #{name} script. - $('body').on('keypress', function(e) { - if (e.ctrlKey && e.keyCode == 13) { - $('#complete-courseware-dialog').modal('show'); - } - }); + $('body').bind('keypress', controlEnterHandler); diff --git a/views/coursewares/showZiplineOrBasejump.jade b/views/coursewares/showZiplineOrBasejump.jade index e7936304fc..73fe8564e7 100644 --- a/views/coursewares/showZiplineOrBasejump.jade +++ b/views/coursewares/showZiplineOrBasejump.jade @@ -32,6 +32,23 @@ block content var passedCoursewareName = challengeName; var started = Math.floor(Date.now()); var challengeType = !{JSON.stringify(challengeType)}; + var controlEnterHandler = function (e) { + $('body').unbind('keypress'); + if (e.ctrlKey && e.keyCode == 13) { + $('#complete-courseware-dialog').modal('show'); + } else { + $('body').bind('keypress', controlEnterHandler); + } + }; + var modalControlEnterHandler = function (e) { + $('#complete-courseware-dialog').unbind('keypress'); + if (e.ctrlKey && e.keyCode == 13) { + $('#next-courseware-button').click(); + } else { + $('#complete-zipline-or-basejump-dialog').on('keypress', modalControlEnterHandler); + } + }; + #complete-zipline-or-basejump-dialog.modal(tabindex='-1') .modal-dialog.animated.zoomIn.fast-animation .modal-content @@ -62,6 +79,8 @@ block content if (user) a.animated.fadeIn.btn.btn-lg.btn-primary.btn-block#next-courseware-button(name='_csrf', value=_csrf, ng-disabled='completedWithForm.$invalid && existingUser.length > 0') Go to my next challenge (ctrl + enter) + script. + $('#complete-zipline-or-basejump-dialog').on('keypress', modalControlEnterHandler); - if (user.progressTimestamps.length > 2) a.animated.fadeIn.btn.btn-lg.btn-block.btn-twitter(target="_blank") @@ -70,8 +89,4 @@ block content - else a.animated.fadeIn.btn.btn-lg.signup-btn.btn-block(href='/login') Sign in so you can save your progress script. - $('body').on('keypress', function(e) { - if (e.ctrlKey && e.keyCode == 13) { - $('#complete-zipline-or-basejump-dialog').modal('show'); - } - }); + $('body').on('keypress', controlEnterHandler);