diff --git a/cms/envs/common.py b/cms/envs/common.py
index 7190ba9e51..7ea70114c1 100644
--- a/cms/envs/common.py
+++ b/cms/envs/common.py
@@ -275,7 +275,7 @@ PIPELINE_JS = {
pth.replace(PROJECT_ROOT / 'static/', '')
for pth
in glob2.glob(PROJECT_ROOT / 'static/coffee/src/**/*.coffee')
- ],
+ ] + ['js/base.js'],
'output_filename': 'js/cms-application.js',
},
'module-js': {
diff --git a/cms/static/js/base.js b/cms/static/js/base.js
new file mode 100644
index 0000000000..bf8c845f57
--- /dev/null
+++ b/cms/static/js/base.js
@@ -0,0 +1,169 @@
+var $body;
+var $modal;
+var $modalCover;
+var $newComponentItem;
+var $newComponentStep1;
+var $newComponentStep2;
+
+$(document).ready(function() {
+ $body = $('body');
+ $modal = $('.history-modal');
+ $modalCover = $('.modal-cover');
+ $newComponentItem = $('.new-component-item');
+ $newComponentStep1 = $('.new-component-step-1');
+ $newComponentStep2 = $('.new-component-step-2');
+ $newComponentButton = $('.new-component-button');
+
+ $('.expand-collapse-icon').bind('click', toggleSubmodules);
+ $('.visibility-options').bind('change', setVisibility);
+
+ $body.delegate('.components .edit-button', 'click', editComponent);
+ $body.delegate('.component-editor .save-button, .component-editor .cancel-button', 'click', closeComponentEditor);
+
+ $newComponentButton.bind('click', showNewComponentForm);
+ $newComponentStep1.find('.new-component-type a').bind('click', showNewComponentProperties);
+ $newComponentStep2.find('.save-button').bind('click', saveNewComponent);
+ $newComponentStep2.find('.cancel-button').bind('click', cancelNewComponent);
+
+ $('.unit-history ol a').bind('click', showHistoryModal);
+ $modal.bind('click', hideHistoryModal);
+ $modalCover.bind('click', hideHistoryModal);
+});
+
+function toggleSubmodules(e) {
+ e.preventDefault();
+ $(this).toggleClass('expand').toggleClass('collapse');
+ $(this).closest('.branch, .window').toggleClass('collapsed');
+}
+
+function setVisibility(e) {
+ $(this).find('.checked').removeClass('checked');
+ $(e.target).closest('.option').addClass('checked');
+}
+
+function editComponent(e) {
+ e.preventDefault();
+ $(this).closest('li').addClass('editing').find('.component-editor').slideDown(150);
+}
+
+function closeComponentEditor(e) {
+ e.preventDefault();
+ $(this).closest('li').removeClass('editing').find('.component-editor').slideUp(150);
+}
+
+function showNewComponentForm(e) {
+ e.preventDefault();
+ $newComponentItem.addClass('adding');
+ $(this).slideUp(150);
+ $newComponentStep1.slideDown(150);
+}
+
+function showNewComponentProperties(e) {
+ e.preventDefault();
+
+ var displayName;
+ var componentSource;
+ var selectionRange;
+ var $renderedComponent;
+
+ switch($(this).attr('data-type')) {
+ case 'video':
+ displayName = 'Video';
+ componentSource = '';
+ selectionRange = [21, 24];
+ $renderedComponent = $('
');
+ break;
+ case 'textbook':
+ displayName = 'Textbook';
+ componentSource = 'book';
+ selectionRange = [17, 20];
+ $renderedComponent = $('More information given in the text.
');
+ break;
+ case 'slide':
+ displayName = 'Slide';
+ componentSource = 'slides';
+ selectionRange = [17, 20];
+ $renderedComponent = $('Lecture Slides Handout [Clean] [Annotated]
');
+ break;
+ case 'discussion':
+ displayName = 'Discussion';
+ componentSource = '';
+ selectionRange = [17, 20];
+ $renderedComponent = $('');
+ break;
+ case 'problem':
+ displayName = 'Problem';
+ componentSource = '___';
+ selectionRange = [9, 12];
+ $renderedComponent = $('');
+ break;
+ case 'freeform':
+ displayName = 'Freeform HTML';
+ componentSource = '';
+ selectionRange = [0, 0];
+ $renderedComponent = $('');
+ break;
+ }
+
+ $newComponentItem.prepend($renderedComponent);
+ $renderedComponent.slideDown(250);
+
+ $newComponentStep2.find('h5').html('Edit ' + displayName + ' Component');
+ $newComponentStep2.find('textarea').html(componentSource);
+ setTimeout(function() {
+ $newComponentStep2.find('textarea').focus().get(0).setSelectionRange(selectionRange[0], selectionRange[1]);
+ }, 10);
+
+ $newComponentStep1.slideUp(250);
+ $newComponentStep2.slideDown(250);
+}
+
+function cancelNewComponent(e) {
+ e.preventDefault();
+
+ $newComponentStep2.slideUp(250);
+ $newComponentButton.slideDown(250);
+ $newComponentItem.removeClass('adding');
+ $newComponentItem.find('.rendered-component').remove();
+}
+
+function saveNewComponent(e) {
+ e.preventDefault();
+
+ var $newComponent = $newComponentItem.clone();
+ $newComponent.removeClass('adding').removeClass('new-component-item');
+ $newComponent.find('.new-component-step-2').removeClass('new-component-step-2').addClass('component-editor');
+ setTimeout(function() {
+ $newComponent.find('.component-editor').slideUp(250);
+ }, 10);
+ $newComponent.append('');
+ $newComponent.find('.new-component-step-1').remove();
+ $newComponent.find('.new-component-button').remove();
+
+ $newComponentStep2.slideUp(250);
+ $newComponentButton.slideDown(250);
+ $newComponentItem.removeClass('adding');
+ $newComponentItem.find('.rendered-component').remove();
+
+ $newComponentItem.before($newComponent);
+}
+
+function showHistoryModal(e) {
+ e.preventDefault();
+
+ $modal.show();
+ $modalCover.show();
+}
+
+function hideHistoryModal(e) {
+ e.preventDefault();
+
+ $modal.hide();
+ $modalCover.hide();
+}
+
+
+
+
+
+
diff --git a/cms/static/sass/_content-types.scss b/cms/static/sass/_content-types.scss
index 1d7a7695e4..eda947e380 100644
--- a/cms/static/sass/_content-types.scss
+++ b/cms/static/sass/_content-types.scss
@@ -1,5 +1,8 @@
.content-type {
- padding-left: 34px;
+ display: inline-block;
+ width: 14px;
+ height: 16px;
+ padding-left: 14px;
background-position: 8px center;
background-repeat: no-repeat;
}
diff --git a/cms/templates/overview.html b/cms/templates/overview.html
index c11f0fb2a3..a3f31a3613 100644
--- a/cms/templates/overview.html
+++ b/cms/templates/overview.html
@@ -2,6 +2,30 @@
<%block name="title">CMS Courseware Overview%block>
<%include file="widgets/header.html"/>
+<%def name="branch(section)">
+
+
+
+ % for unit in section.get_children():
+ ${branch(unit)}
+ % endfor
+
+
+%def>
+
+
<%block name="content">
@@ -25,30 +49,7 @@
% for section in week.get_children():
- -
-
-
- % for unit in section.get_children():
- -
-
-
- % endfor
-
-
+ ${branch(section)}
% endfor