diff --git a/cms/static/coffee/src/views/module_edit.coffee b/cms/static/coffee/src/views/module_edit.coffee index b1157f713e..729c4dc2e9 100644 --- a/cms/static/coffee/src/views/module_edit.coffee +++ b/cms/static/coffee/src/views/module_edit.coffee @@ -56,7 +56,7 @@ class CMS.Views.ModuleEdit extends Backbone.View event.preventDefault() data = @module.save() data.metadata = _.extend(data.metadata, @metadata()) - $modalCover.hide() + @hideModal() @model.save(data).done( => # # showToastMessage("Your changes have been saved.", null, 3) @module = null @@ -70,11 +70,15 @@ class CMS.Views.ModuleEdit extends Backbone.View event.preventDefault() @$el.removeClass('editing') @$component_editor().slideUp(150) + @hideModal() + + hideModal: -> $modalCover.hide() + $modalCover.removeClass('is-fixed') clickEditButton: (event) -> event.preventDefault() @$el.addClass('editing') - $modalCover.show() + $modalCover.show().addClass('is-fixed') @$component_editor().slideDown(150) @loadEdit() diff --git a/cms/static/js/base.js b/cms/static/js/base.js index 9fa4489c36..81e37bed72 100644 --- a/cms/static/js/base.js +++ b/cms/static/js/base.js @@ -29,9 +29,7 @@ $(document).ready(function() { $('.expand-collapse-icon').bind('click', toggleSubmodules); $('.visibility-options').bind('change', setVisibility); - $('.unit-history ol a').bind('click', showHistoryModal); $modal.bind('click', hideModal); - $modalCover.bind('click', hideHistoryModal); $modalCover.bind('click', hideModal); $('.assets .upload-button').bind('click', showUploadModal); $('.upload-modal .close-button').bind('click', hideModal); @@ -498,9 +496,14 @@ function hideModal(e) { if(e) { e.preventDefault(); } - $('.file-input').unbind('change', startUpload); - $modal.hide(); - $modalCover.hide(); + // Unit editors do not want the modal cover to hide when users click outside + // of the editor. Users must press Cancel or Save to exit the editor. + // module_edit adds and removes the "is-fixed" class. + if (!$modalCover.hasClass("is-fixed")) { + $('.file-input').unbind('change', startUpload); + $modal.hide(); + $modalCover.hide(); + } } function onKeyUp(e) { @@ -530,21 +533,6 @@ function closeComponentEditor(e) { $(this).closest('.xmodule_edit').removeClass('editing').find('.component-editor').slideUp(150); } - -function showHistoryModal(e) { - e.preventDefault(); - - $modal.show(); - $modalCover.show(); -} - -function hideHistoryModal(e) { - e.preventDefault(); - - $modal.hide(); - $modalCover.hide(); -} - function showDateSetter(e) { e.preventDefault(); var $block = $(this).closest('.due-date-input');