From 60cf22e4b2a42440e12f2f7ebd91d4630ae84556 Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Wed, 17 Oct 2012 13:46:40 -0400 Subject: [PATCH] work in progress: set start date --- cms/static/js/base.js | 41 +++++++++++++++++++++++++++++++++++++ cms/templates/overview.html | 15 +++++++++++--- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/cms/static/js/base.js b/cms/static/js/base.js index 256759e7d8..7ef7aff963 100644 --- a/cms/static/js/base.js +++ b/cms/static/js/base.js @@ -77,6 +77,10 @@ $(document).ready(function() { $('.new-course-button').bind('click', addNewCourse); + // section name editing + $('.section-name').bind('click', editSectionName); + $('.edit-section-name-cancel').bind('click', cancelEditSectionName); + $('.edit-section-name-save').bind('click', saveEditSectionName); }); function showImportSubmit(e) { @@ -576,3 +580,40 @@ function cancelNewSubsection(e) { e.preventDefault(); $(this).parents('li.branch').remove(); } + +function editSectionName(e) { + e.preventDefault(); + $(this).children('div.section-name-edit').show(); + $(this).children('span.section-name-span').hide(); +} + +function cancelEditSectionName(e) { + e.preventDefault(); + $(this).parent().hide(); + $(this).parent().siblings('span.section-name-span').show(); + e.stopPropagation(); +} + +function saveEditSectionName(e) { + e.preventDefault(); + + id = $(this).closest("section.courseware-section").data("id"); + display_name = $(this).prev('.edit-section-name').val(); + + var $_this = $(this); + // call into server to commit the new order + $.ajax({ + url: "/save_item", + type: "POST", + dataType: "json", + contentType: "application/json", + data:JSON.stringify({ 'id' : id, 'metadata' : {'display_name' : display_name}, 'data': null, 'children' : null}) + }).success(function() + { + alert('Your changes have been saved.'); + $_this.parent().siblings('span.section-name-span').html(display_name); + $_this.parent().siblings('span.section-name-span').show(); + $_this.parent().hide(); + e.stopPropagation(); + }); +} diff --git a/cms/templates/overview.html b/cms/templates/overview.html index 9739f4c1a2..7f08a313fe 100644 --- a/cms/templates/overview.html +++ b/cms/templates/overview.html @@ -52,9 +52,18 @@
-
-

${section.display_name}

-

Unscheduled: click here to set

+
+

+ ${section.display_name} + +

+

+ Unscheduled: + click here to set +