-
Notifications
You must be signed in to change notification settings - Fork 47
Fix modal dismissal #702
base: master
Are you sure you want to change the base?
Fix modal dismissal #702
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 |
|---|---|---|
|
|
@@ -610,7 +610,8 @@ tie.directive('learnerView', [function() { | |
| 'FEEDBACK_CATEGORIES', 'DEFAULT_EVENT_BATCH_PERIOD_SECONDS', | ||
| 'DELAY_STYLE_CHANGES', 'THEME_NAME_LIGHT', 'THEME_NAME_DARK', | ||
| 'CODE_RESET_CONFIRMATION_MESSAGE', 'PRIVACY_URL', 'ABOUT_TIE_URL', | ||
| 'ABOUT_TIE_LABEL', 'TERMS_OF_USE_URL', | ||
| 'ABOUT_TIE_LABEL', 'TERMS_OF_USE_URL', 'FEEDBACK_MODAL_HEIGHT_OFFSET', | ||
| 'FEEDBACK_MODAL_HIDE_HEIGHT_OFFSET', | ||
| function( | ||
| $scope, $interval, $timeout, $location, $window, | ||
| ConversationManagerService, QuestionDataService, LANGUAGE_PYTHON, | ||
|
|
@@ -626,7 +627,8 @@ tie.directive('learnerView', [function() { | |
| FEEDBACK_CATEGORIES, DEFAULT_EVENT_BATCH_PERIOD_SECONDS, | ||
| DELAY_STYLE_CHANGES, THEME_NAME_LIGHT, THEME_NAME_DARK, | ||
| CODE_RESET_CONFIRMATION_MESSAGE, PRIVACY_URL, ABOUT_TIE_URL, | ||
| ABOUT_TIE_LABEL, TERMS_OF_USE_URL) { | ||
| ABOUT_TIE_LABEL, TERMS_OF_USE_URL, FEEDBACK_MODAL_HEIGHT_OFFSET, | ||
| FEEDBACK_MODAL_HIDE_HEIGHT_OFFSET) { | ||
| $scope.PRIVACY_URL = PRIVACY_URL; | ||
| $scope.ABOUT_TIE_URL = ABOUT_TIE_URL; | ||
| $scope.ABOUT_TIE_LABEL = ABOUT_TIE_LABEL; | ||
|
|
@@ -1180,13 +1182,46 @@ tie.directive('learnerView', [function() { | |
| tasks[currentTaskIndex].getId()); | ||
| }; | ||
|
|
||
| /** | ||
| * Event handler to hide modal after transition animation ends. | ||
| */ | ||
| $scope.hideModalAfterAnimation = function(event) { | ||
| $timeout(function() { | ||
| MonospaceDisplayModalService.hideModal(); | ||
| }, 0); | ||
| event.target.removeEventListener("transitionend", | ||
| $scope.hideModalAfterAnimation, false); | ||
| }; | ||
|
|
||
| /** | ||
| * Close modal by calling MonospaceDisplayModalService.closeModal. | ||
|
Member
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. The function doesn't seem to be doing what this docstring says. |
||
| */ | ||
| $scope.closeModal = function() { | ||
|
Member
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. The code here duplicates code in MonospaceDisplayModalDirective. In general try to strictly avoid duplicating code since that makes things harder to maintain and introduces the possibility of skew. |
||
| questionWindowDiv = | ||
| document.getElementsByClassName('tie-question-window')[0]; | ||
| var modalContainerDiv = document.getElementsByClassName( | ||
| 'tie-monospace-modal-container')[0]; | ||
| var modalHeight = questionWindowDiv.offsetHeight; | ||
| var modalHideTopOffsetString = | ||
| '-' + (modalHeight + FEEDBACK_MODAL_HEIGHT_OFFSET + | ||
| FEEDBACK_MODAL_HIDE_HEIGHT_OFFSET).toString() + 'px'; | ||
|
|
||
| modalContainerDiv.style.top = modalHideTopOffsetString; | ||
| modalContainerDiv.classList.remove( | ||
| 'tie-feedback-modal-displayed'); | ||
| modalContainerDiv.addEventListener("transitionend", | ||
| $scope.hideModalAfterAnimation, false); | ||
| }; | ||
|
|
||
| /** | ||
| * Calls the processes necessary to start the code submission process. | ||
| * | ||
| * @param {string} code | ||
| */ | ||
| $scope.submitCode = function(code) { | ||
| MonospaceDisplayModalService.hideModal(); | ||
| if (MonospaceDisplayModalService.isDisplayed()) { | ||
| $scope.closeModal(); | ||
| } | ||
| SessionHistoryService.addCodeBalloon(code); | ||
|
|
||
| // Gather all tasks from the first one up to the current one. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -171,26 +171,34 @@ tie.directive('monospaceDisplayModal', [function() { | |
| }); | ||
|
|
||
| /** | ||
| * Close the modal. | ||
| * Event handler to hide modal after transition animation ends. | ||
| */ | ||
| $scope.hideModalAfterAnimation = function(event) { | ||
|
Member
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. Consider using ( |
||
| $timeout(function() { | ||
| MonospaceDisplayModalService.hideModal(); | ||
| }, 0); | ||
| event.target.removeEventListener("transitionend", | ||
|
Member
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. nit: break after '(' if contents of (...) span more than one line Here and elsewhere, use single quotes |
||
| $scope.hideModalAfterAnimation, false); | ||
| }; | ||
|
|
||
| /** | ||
| * Close modal by calling MonospaceDisplayModalService.closeModal. | ||
| */ | ||
| $scope.closeModal = function() { | ||
| var questionWindowDiv = | ||
| document.getElementsByClassName('tie-question-window')[0]; | ||
| var monospaceDisplayModalElement = | ||
| document.getElementsByTagName('monospace-display-modal')[0]; | ||
|
|
||
| var modalContainerDiv = document.getElementsByClassName( | ||
| 'tie-monospace-modal-container')[0]; | ||
| var modalHeight = questionWindowDiv.offsetHeight; | ||
| var modalHideTopOffsetString = | ||
| '-' + (modalHeight + FEEDBACK_MODAL_HEIGHT_OFFSET + | ||
| FEEDBACK_MODAL_HIDE_HEIGHT_OFFSET).toString() + 'px'; | ||
|
|
||
| monospaceDisplayModalElement.style.top = modalHideTopOffsetString; | ||
| monospaceDisplayModalElement.classList.remove( | ||
| modalContainerDiv.style.top = modalHideTopOffsetString; | ||
| modalContainerDiv.classList.remove( | ||
| 'tie-feedback-modal-displayed'); | ||
|
|
||
| $timeout(function() { | ||
| MonospaceDisplayModalService.hideModal(); | ||
| }, 0); | ||
| modalContainerDiv.addEventListener("transitionend", | ||
| $scope.hideModalAfterAnimation, false); | ||
| }; | ||
| } | ||
| ] | ||
|
|
||
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.
I'm not sure this needs to be defined here; it duplicates code in MonospaceDisplayModalService.