Commit fbbf9e9c by Tom Giannattasio

key bindings and speed reworkings for the my courses and courseware pages

parent 62fa734c
...@@ -93,7 +93,7 @@ $(document).ready(function() { ...@@ -93,7 +93,7 @@ $(document).ready(function() {
// section name editing // section name editing
$('.section-name').bind('click', editSectionName); $('.section-name').bind('click', editSectionName);
$('.edit-section-name-cancel').bind('click', cancelEditSectionName); $('.edit-section-name-cancel').bind('click', cancelEditSectionName);
$('.edit-section-name-save').bind('click', saveEditSectionName); // $('.edit-section-name-save').bind('click', saveEditSectionName);
// section date setting // section date setting
$('.set-publish-date').bind('click', setSectionScheduleDate); $('.set-publish-date').bind('click', setSectionScheduleDate);
...@@ -585,33 +585,44 @@ function hideToastMessage(e) { ...@@ -585,33 +585,44 @@ function hideToastMessage(e) {
$(this).closest('.toast-notification').remove(); $(this).closest('.toast-notification').remove();
} }
function addNewSection(e) { function addNewSection(e, isTemplate) {
e.preventDefault(); e.preventDefault();
var $newSection = $($('#new-section-template').html()); var $newSection = $($('#new-section-template').html());
var $cancelButton = $newSection.find('.new-section-name-cancel');
$('.new-courseware-section-button').after($newSection); $('.new-courseware-section-button').after($newSection);
$newSection.find('.new-section-name').focus().select(); $newSection.find('.new-section-name').focus().select();
$newSection.find('.new-section-name-save').bind('click', saveNewSection); $newSection.find('.section-name-form').bind('submit', saveNewSection);
$newSection.find('.new-section-name-cancel').bind('click', cancelNewSection); $cancelButton.bind('click', cancelNewSection);
$body.bind('keyup', { $cancelButton: $cancelButton }, checkForCancel);
}
function checkForCancel(e) {
if(e.which == 27) {
$body.unbind('keyup', checkForCancel);
e.data.$cancelButton.click();
}
} }
function saveNewSection(e) { function saveNewSection(e) {
e.preventDefault(); e.preventDefault();
parent = $(this).data('parent'); var $saveButton = $(this).find('.new-section-name-save');
template = $(this).data('template'); var parent = $saveButton.data('parent');
var template = $saveButton.data('template');
display_name = $(this).prev('.new-section-name').val(); var display_name = $(this).find('.new-section-name').val();
$.post('/clone_item', $.post('/clone_item', {
{'parent_location' : parent, 'parent_location' : parent,
'template' : template, 'template' : template,
'display_name': display_name, 'display_name': display_name,
}, },
function(data) { function(data) {
if (data.id != undefined) if (data.id != undefined)
location.reload(); location.reload();
}); }
);
} }
function cancelNewSection(e) { function cancelNewSection(e) {
...@@ -619,44 +630,44 @@ function cancelNewSection(e) { ...@@ -619,44 +630,44 @@ function cancelNewSection(e) {
$(this).parents('section.new-section').remove(); $(this).parents('section.new-section').remove();
} }
function addNewCourse(e) { function addNewCourse(e) {
e.preventDefault(); e.preventDefault();
var $newCourse = $($('#new-course-template').html()); var $newCourse = $($('#new-course-template').html());
var $cancelButton = $newCourse.find('.new-course-cancel');
$('.new-course-button').after($newCourse); $('.new-course-button').after($newCourse);
$newCourse.find('.new-course-name').focus().select(); $newCourse.find('.new-course-name').focus().select();
$newCourse.find('.new-course-save').bind('click', saveNewCourse); $newCourse.find('form').bind('submit', saveNewCourse);
$newCourse.find('.new-course-cancel').bind('click', cancelNewCourse); $cancelButton.bind('click', cancelNewCourse);
$body.bind('keyup', { $cancelButton: $cancelButton }, checkForCancel);
} }
function saveNewCourse(e) { function saveNewCourse(e) {
e.preventDefault(); e.preventDefault();
var $newCourse = $(this).closest('.new-course'); var $newCourse = $(this).closest('.new-course');
var template = $(this).find('.new-course-save').data('template');
template = $(this).data('template'); var org = $newCourse.find('.new-course-org').val();
var number = $newCourse.find('.new-course-number').val();
org = $newCourse.find('.new-course-org').val(); var display_name = $newCourse.find('.new-course-name').val();
number = $newCourse.find('.new-course-number').val();
display_name = $newCourse.find('.new-course-name').val();
if (org == '' || number == '' || display_name == ''){ if (org == '' || number == '' || display_name == ''){
alert('You must specify all fields in order to create a new course.'); alert('You must specify all fields in order to create a new course.');
return; return;
} }
$.post('/create_new_course', $.post('/create_new_course', {
{ 'template' : template, 'template' : template,
'org' : org, 'org' : org,
'number' : number, 'number' : number,
'display_name': display_name, 'display_name': display_name,
}, },
function(data) { function(data) {
if (data.id != undefined) if (data.id != undefined) {
location.reload(); window.location = '/' + data.id.replace(/.*:\/\//, '');
else if (data.ErrMsg != undefined) } else if (data.ErrMsg != undefined) {
alert(data.ErrMsg); alert(data.ErrMsg);
}); }
});
} }
function cancelNewCourse(e) { function cancelNewCourse(e) {
...@@ -672,35 +683,37 @@ function addNewSubsection(e) { ...@@ -672,35 +683,37 @@ function addNewSubsection(e) {
$section.find('.new-subsection-name-input').focus().select(); $section.find('.new-subsection-name-input').focus().select();
var $saveButton = $newSubsection.find('.new-subsection-name-save'); var $saveButton = $newSubsection.find('.new-subsection-name-save');
$saveButton.bind('click', saveNewSubsection); var $cancelButton = $newSubsection.find('.new-subsection-name-cancel');
parent = $(this).parents("section.branch").data("id"); var parent = $(this).parents("section.branch").data("id");
$saveButton.data('parent', parent) $saveButton.data('parent', parent)
$saveButton.data('template', $(this).data('template')); $saveButton.data('template', $(this).data('template'));
$newSubsection.find('.new-subsection-name-cancel').bind('click', cancelNewSubsection); $newSubsection.find('.new-subsection-form').bind('submit', saveNewSubsection);
$cancelButton.bind('click', cancelNewSubsection);
$body.bind('keyup', { $cancelButton: $cancelButton }, checkForCancel);
} }
function saveNewSubsection(e) { function saveNewSubsection(e) {
e.preventDefault(); e.preventDefault();
parent = $(this).data('parent'); var parent = $(this).find('.new-subsection-name-save').data('parent');
template = $(this).data('template'); var template = $(this).find('.new-subsection-name-save').data('template');
display_name = $(this).prev('.subsection-name').find('.new-subsection-name-input').val() var display_name = $(this).find('.new-subsection-name-input').val();
$.post('/clone_item', $.post('/clone_item', {
{'parent_location' : parent, 'parent_location' : parent,
'template' : template, 'template' : template,
'display_name': display_name, 'display_name': display_name
}, },
function(data) { function(data) {
if (data.id != undefined) { if (data.id != undefined) {
location.reload(); location.reload();
} }
}); }
);
} }
function cancelNewSubsection(e) { function cancelNewSubsection(e) {
...@@ -710,22 +723,30 @@ function cancelNewSubsection(e) { ...@@ -710,22 +723,30 @@ function cancelNewSubsection(e) {
function editSectionName(e) { function editSectionName(e) {
e.preventDefault(); e.preventDefault();
$(this).children('div.section-name-edit').show(); $(this).unbind('click', editSectionName);
$(this).children('span.section-name-span').hide(); $(this).children('.section-name-edit').show();
$(this).find('.edit-section-name').focus();
$(this).children('.section-name-span').hide();
$(this).find('.section-name-edit').bind('submit', saveEditSectionName);
$(this).find('.edit-section-name-cancel').bind('click', cancelNewSection);
$body.bind('keyup', { $cancelButton: $(this).find('.edit-section-name-cancel') }, checkForCancel);
} }
function cancelEditSectionName(e) { function cancelEditSectionName(e) {
e.preventDefault(); e.preventDefault();
$(this).parent().hide(); $(this).parent().hide();
$(this).parent().siblings('span.section-name-span').show(); $(this).parent().siblings('.section-name-span').show();
$(this).closest('.section-name').bind('click', editSectionName);
e.stopPropagation(); e.stopPropagation();
} }
function saveEditSectionName(e) { function saveEditSectionName(e) {
e.preventDefault(); e.preventDefault();
id = $(this).closest("section.courseware-section").data("id"); $(this).closest('.section-name').unbind('click', editSectionName);
display_name = $.trim($(this).prev('.edit-section-name').val());
var id = $(this).closest('.courseware-section').data('id');
var display_name = $.trim($(this).find('.edit-section-name').val());
$(this).closest('.courseware-section .section-name').append($spinner); $(this).closest('.courseware-section .section-name').append($spinner);
$spinner.show(); $spinner.show();
...@@ -746,10 +767,10 @@ function saveEditSectionName(e) { ...@@ -746,10 +767,10 @@ function saveEditSectionName(e) {
}).success(function() }).success(function()
{ {
$spinner.delay(250).fadeOut(250); $spinner.delay(250).fadeOut(250);
$_this.parent().siblings('span.section-name-span').html(display_name); $_this.closest('h3').find('.section-name-span').html(display_name).show();
$_this.parent().siblings('span.section-name-span').show(); $_this.hide();
$_this.parent().hide(); $_this.closest('.section-name').bind('click', editSectionName);
e.stopPropagation(); e.stopPropagation();
}); });
} }
......
...@@ -146,7 +146,7 @@ input.courseware-unit-search-input { ...@@ -146,7 +146,7 @@ input.courseware-unit-search-input {
.section-name-edit { .section-name-edit {
input { input {
font-size: 16px; font-size: 16px;
} }
.save-button { .save-button {
...@@ -205,7 +205,7 @@ input.courseware-unit-search-input { ...@@ -205,7 +205,7 @@ input.courseware-unit-search-input {
.new-section-name-save, .new-section-name-save,
.new-subsection-name-save { .new-subsection-name-save {
@include blue-button; @include blue-button;
padding: 2px 20px 5px; padding: 6px 20px 8px;
margin: 0 5px; margin: 0 5px;
color: #fff !important; color: #fff !important;
} }
...@@ -213,7 +213,7 @@ input.courseware-unit-search-input { ...@@ -213,7 +213,7 @@ input.courseware-unit-search-input {
.new-section-name-cancel, .new-section-name-cancel,
.new-subsection-name-cancel { .new-subsection-name-cancel {
@include white-button; @include white-button;
padding: 2px 20px 5px; padding: 6px 20px 8px;
color: #8891a1 !important; color: #8891a1 !important;
} }
......
...@@ -22,14 +22,14 @@ ...@@ -22,14 +22,14 @@
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<a href="#" class="new-course-save" data-template="${new_course_template}">Save</a> <input type="submit" value="Save" class="new-course-save" data-template="${new_course_template}" />
<a href="#" class="new-course-cancel">Cancel</a> <input type="button" value="Cancel" class="new-course-cancel" />
</div> </div>
</form> </form>
</div> </div>
</section> </section>
</script> </script>
</%block> </%block>
<%block name="content"> <%block name="content">
<div class="main-wrapper"> <div class="main-wrapper">
......
...@@ -12,10 +12,10 @@ ...@@ -12,10 +12,10 @@
<%namespace name="units" file="widgets/units.html" /> <%namespace name="units" file="widgets/units.html" />
<%block name="jsextra"> <%block name="jsextra">
<link rel="stylesheet" type="text/css" href="${static.url('js/vendor/timepicker/jquery.timepicker.css')}" /> <link rel="stylesheet" type="text/css" href="${static.url('js/vendor/timepicker/jquery.timepicker.css')}" />
<script src="${static.url('js/vendor/timepicker/jquery.timepicker.js')}"></script> <script src="${static.url('js/vendor/timepicker/jquery.timepicker.js')}"></script>
<script src="${static.url('js/vendor/timepicker/datepair.js')}"></script> <script src="${static.url('js/vendor/timepicker/datepair.js')}"></script>
<script src="${static.url('js/vendor/date.js')}"></script> <script src="${static.url('js/vendor/date.js')}"></script>
</%block> </%block>
<%block name="header_extras"> <%block name="header_extras">
...@@ -24,7 +24,33 @@ ...@@ -24,7 +24,33 @@
<header> <header>
<a href="#" class="expand-collapse-icon collapse"></a> <a href="#" class="expand-collapse-icon collapse"></a>
<div class="item-details"> <div class="item-details">
<h3 class="section-name"><input type="text" value="New Section Name" class="new-section-name" /><a href="#" class="new-section-name-save" data-parent="${parent_location}" data-template="${new_section_template}">Save</a><a href="#" class="new-section-name-cancel">Cancel</a></h3> <h3 class="section-name">
<form class="section-name-form">
<input type="text" value="New Section Name" class="new-section-name" />
<input type="submit" class="new-section-name-save" data-parent="${parent_location}" data-template="${new_section_template}" value="Save" />
<input type="button" class="new-section-name-cancel" value="Cancel" /></h3>
</form>
</div>
</header>
</section>
</script>
<script type="text/template" id="blank-slate-template">
<section class="courseware-section branch new-section">
<header>
<a href="#" class="expand-collapse-icon collapse"></a>
<div class="item-details">
<h3 class="section-name">
<span class="section-name-span">Click here to set the section name</span>
<form class="section-name-form">
<input type="text" value="New Section Name" class="new-section-name" />
<input type="submit" class="new-section-name-save" data-parent="${parent_location}" data-template="${new_section_template}" value="Save" />
<input type="button" class="new-section-name-cancel" value="Cancel" /></h3>
</form>
</div>
<div class="item-actions">
<a href="#" class="delete-button delete-section-button"><span class="delete-icon"></span></a>
<a href="#" class="drag-handle"></a>
</div> </div>
</header> </header>
</section> </section>
...@@ -33,14 +59,14 @@ ...@@ -33,14 +59,14 @@
<script type="text/template" id="new-subsection-template"> <script type="text/template" id="new-subsection-template">
<li class="branch collapsed"> <li class="branch collapsed">
<div class="section-item editing"> <div class="section-item editing">
<div> <form class="new-subsection-form">
<span class="folder-icon"></span> <span class="folder-icon"></span>
<span class="subsection-name"> <span class="subsection-name">
<input type="text" value="New Subsection" class="new-subsection-name-input" /> <input type="text" value="New Subsection" class="new-subsection-name-input" />
</span> </span>
<a href="#" class="new-subsection-name-save">Save</a> <input type="submit" value="Save" class="new-subsection-name-save" />
<a href="#" class="new-subsection-name-cancel">Cancel</a> <input type="button" value="Cancel" class="new-subsection-name-cancel" />
</div> </form>
</div> </div>
<ol> <ol>
<li> <li>
...@@ -83,10 +109,11 @@ ...@@ -83,10 +109,11 @@
<div class="item-details" data-id="${section.location}"> <div class="item-details" data-id="${section.location}">
<h3 class="section-name"> <h3 class="section-name">
<span class="section-name-span">${section.display_name}</span> <span class="section-name-span">${section.display_name}</span>
<div class="section-name-edit" style="display:none"> <form class="section-name-edit" style="display:none">
<input type="text" value="${section.display_name}" class="edit-section-name" autocomplete="off"/> <input type="text" value="${section.display_name}" class="edit-section-name" autocomplete="off"/>
<a href="#" class="save-button edit-section-name-save">Save</a><a href="#" class="cancel-button edit-section-name-cancel">Cancel</a> <input type="submit" class="save-button edit-section-name-save" value="Save" />
</div> <input type="button" class="cancel-button edit-section-name-cancel" value="Cancel" />
</form>
</h3> </h3>
<div class="section-published-date"> <div class="section-published-date">
<% <%
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment