Commit 5acf9cb3 by cahrens

Reformat to 4 spaces.

parent 2486ebc2
......@@ -5,7 +5,7 @@ var $newComponentItem;
var $changedInput;
var $spinner;
$(document).ready(function() {
$(document).ready(function () {
$body = $('body');
$modal = $('.history-modal');
$modalCover = $('<div class="modal-cover">');
......@@ -34,7 +34,9 @@ $(document).ready(function() {
$('.uploads .upload-button').bind('click', showUploadModal);
$('.upload-modal .close-button').bind('click', hideModal);
$body.on('click', '.embeddable-xml-input', function(){ $(this).select(); });
$body.on('click', '.embeddable-xml-input', function () {
$(this).select();
});
$('.unit .item-actions .delete-button').bind('click', deleteUnit);
$('.new-unit-item').bind('click', createNewUnit);
......@@ -42,12 +44,12 @@ $(document).ready(function() {
$('body').addClass('js');
// nav - dropdown related
$body.click(function(e){
$body.click(function (e) {
$('.nav-dropdown .nav-item .wrapper-nav-sub').removeClass('is-shown');
$('.nav-dropdown .nav-item .title').removeClass('is-selected');
});
$('.nav-dropdown .nav-item .title').click(function(e){
$('.nav-dropdown .nav-item .title').click(function (e) {
$subnav = $(this).parent().find('.wrapper-nav-sub');
$title = $(this).parent().find('.title');
......@@ -68,20 +70,20 @@ $(document).ready(function() {
});
// general link management - new window/tab
$('a[rel="external"]').attr('title','This link will open in a new browser window/tab').click(function(e) {
$('a[rel="external"]').attr('title', 'This link will open in a new browser window/tab').click(function (e) {
window.open($(this).attr('href'));
e.preventDefault();
});
// general link management - lean modal window
$('a[rel="modal"]').attr('title','This link will open in a modal window').leanModal({overlay : 0.50, closeButton: '.action-modal-close' });
$('.action-modal-close').click(function(e){
$('a[rel="modal"]').attr('title', 'This link will open in a modal window').leanModal({overlay: 0.50, closeButton: '.action-modal-close' });
$('.action-modal-close').click(function (e) {
(e).preventDefault();
});
// toggling overview section details
$(function(){
if($('.courseware-section').length > 0) {
$(function () {
if ($('.courseware-section').length > 0) {
$('.toggle-button-sections').addClass('is-shown');
}
});
......@@ -89,7 +91,7 @@ $(document).ready(function() {
// autosave when a field is updated on the subsection page
$body.on('keyup', '.subsection-display-name-input, .unit-subtitle, .policy-list-value', checkForNewValue);
$('.subsection-display-name-input, .unit-subtitle, .policy-list-name, .policy-list-value').each(function(i) {
$('.subsection-display-name-input, .unit-subtitle, .policy-list-name, .policy-list-value').each(function (i) {
this.val = $(this).val();
});
$("#start_date, #start_time, #due_date, #due_time").bind('change', autosaveInput);
......@@ -115,7 +117,7 @@ $(document).ready(function() {
// import form setup
$('.import .file-input').bind('change', showImportSubmit);
$('.import .choose-file-button, .import .choose-file-button-inline').bind('click', function(e) {
$('.import .choose-file-button, .import .choose-file-button-inline').bind('click', function (e) {
e.preventDefault();
$('.import .file-input').click();
});
......@@ -138,12 +140,12 @@ $(document).ready(function() {
$body.on('click', '.section-published-date .schedule-button', editSectionPublishDate);
$body.on('click', '.edit-subsection-publish-settings .save-button', saveSetSectionScheduleDate);
$body.on('click', '.edit-subsection-publish-settings .cancel-button', hideModal);
$body.on('change', '.edit-subsection-publish-settings .start-date', function() {
if($('.edit-subsection-publish-settings').find('.start-time').val() == '') {
$body.on('change', '.edit-subsection-publish-settings .start-date', function () {
if ($('.edit-subsection-publish-settings').find('.start-time').val() == '') {
$('.edit-subsection-publish-settings').find('.start-time').val('12:00am');
}
});
$('.edit-subsection-publish-settings').on('change', '.start-date, .start-time', function() {
$('.edit-subsection-publish-settings').on('change', '.start-date, .start-time', function () {
$('.edit-subsection-publish-settings').find('.save-button').show();
});
});
......@@ -165,7 +167,7 @@ function toggleSections(e) {
var buttonLabel = $button.hasClass('is-activated') ? $labelCollapsed : $labelExpanded;
$button.toggleClass('is-activated').html(buttonLabel);
if($button.hasClass('is-activated')) {
if ($button.hasClass('is-activated')) {
$section.addClass('collapsed');
// first child in order to avoid the icons on the subsection lists which are not in the first child
$section.find('header .expand-collapse-icon').removeClass('collapse').addClass('expand');
......@@ -183,7 +185,7 @@ function editSectionPublishDate(e) {
$modal.attr('data-id', $(this).attr('data-id'));
$modal.find('.start-date').val($(this).attr('data-date'));
$modal.find('.start-time').val($(this).attr('data-time'));
if($modal.find('.start-date').val() == '' && $modal.find('.start-time').val() == '') {
if ($modal.find('.start-date').val() == '' && $modal.find('.start-time').val() == '') {
$modal.find('.save-button').hide();
}
$modal.find('.section-name').html('"' + $(this).closest('.courseware-section').find('.section-name-span').text() + '"');
......@@ -192,7 +194,7 @@ function editSectionPublishDate(e) {
function showImportSubmit(e) {
var filepath = $(this).val();
if(filepath.substr(filepath.length - 6, 6) == 'tar.gz') {
if (filepath.substr(filepath.length - 6, 6) == 'tar.gz') {
$('.error-block').hide();
$('.file-name').html($(this).val().replace('C:\\fakepath\\', ''));
$('.file-name-block').show();
......@@ -213,7 +215,7 @@ function syncReleaseDate(e) {
function addPolicyMetadata(e) {
e.preventDefault();
var template =$('#add-new-policy-element-template > li');
var template = $('#add-new-policy-element-template > li');
var newNode = template.clone();
var _parent_el = $(this).parent('ol:.policy-list');
newNode.insertBefore('.add-policy-data');
......@@ -235,7 +237,7 @@ function cancelPolicyMetadata(e) {
e.preventDefault();
var $policyElement = $(this).parents('.policy-list-element');
if(!$policyElement.hasClass('editing')) {
if (!$policyElement.hasClass('editing')) {
$policyElement.remove();
} else {
$policyElement.removeClass('new-policy-list-element');
......@@ -248,7 +250,7 @@ function cancelPolicyMetadata(e) {
function removePolicyMetadata(e) {
e.preventDefault();
if(!confirm('Are you sure you wish to delete this item. It cannot be reversed!'))
if (!confirm('Are you sure you wish to delete this item. It cannot be reversed!'))
return;
policy_name = $(this).data('policy-name');
......@@ -280,30 +282,30 @@ function getEdxTimeFromDateTimeVals(date_val, time_val, format) {
}
function getEdxTimeFromDateTimeInputs(date_id, time_id, format) {
var input_date = $('#'+date_id).val();
var input_time = $('#'+time_id).val();
var input_date = $('#' + date_id).val();
var input_time = $('#' + time_id).val();
return getEdxTimeFromDateTimeVals(input_date, input_time, format);
}
function checkForNewValue(e) {
if($(this).parents('.new-policy-list-element')[0]) {
if ($(this).parents('.new-policy-list-element')[0]) {
return;
}
if(this.val) {
if (this.val) {
this.hasChanged = this.val != $(this).val();
} else {
this.hasChanged = false;
}
this.val = $(this).val();
if(this.hasChanged) {
if(this.saveTimer) {
if (this.hasChanged) {
if (this.saveTimer) {
clearTimeout(this.saveTimer);
}
this.saveTimer = setTimeout(function() {
this.saveTimer = setTimeout(function () {
$changedInput = $(e.target);
saveSubsection();
this.saveTimer = null;
......@@ -312,11 +314,11 @@ function checkForNewValue(e) {
}
function autosaveInput(e) {
if(this.saveTimer) {
if (this.saveTimer) {
clearTimeout(this.saveTimer);
}
this.saveTimer = setTimeout(function() {
this.saveTimer = setTimeout(function () {
$changedInput = $(e.target);
saveSubsection();
this.saveTimer = null;
......@@ -324,7 +326,7 @@ function autosaveInput(e) {
}
function saveSubsection() {
if($changedInput && !$changedInput.hasClass('no-spinner')) {
if ($changedInput && !$changedInput.hasClass('no-spinner')) {
$spinner.css({
'position': 'absolute',
'top': Math.floor($changedInput.position().top + ($changedInput.outerHeight() / 2) + 3),
......@@ -341,20 +343,20 @@ function saveSubsection() {
var metadata_fields = $('input[data-metadata-name]');
var metadata = {};
for(var i=0; i< metadata_fields.length;i++) {
for (var i = 0; i < metadata_fields.length; i++) {
var el = metadata_fields[i];
metadata[$(el).data("metadata-name")] = el.value;
}
// now add 'free-formed' metadata which are presented to the user as dual input fields (name/value)
$('ol.policy-list > li.policy-list-element').each( function(i, element) {
$('ol.policy-list > li.policy-list-element').each(function (i, element) {
var name = $(element).children('.policy-list-name').val();
metadata[name] = $(element).children('.policy-list-value').val();
});
// now add any 'removed' policy metadata which is stored in a separate hidden div
// 'null' presented to the server means 'remove'
$("#policy-to-delete > li.policy-list-element").each(function(i, element) {
$("#policy-to-delete > li.policy-list-element").each(function (i, element) {
var name = $(element).children('.policy-list-name').val();
if (name != "")
metadata[name] = null;
......@@ -371,11 +373,11 @@ function saveSubsection() {
type: "POST",
dataType: "json",
contentType: "application/json",
data:JSON.stringify({ 'id' : id, 'metadata' : metadata}),
success: function() {
data: JSON.stringify({ 'id': id, 'metadata': metadata}),
success: function () {
$spinner.delay(500).fadeOut(150);
},
error: function() {
error: function () {
showToastMessage('There has been an error while saving your changes.');
}
});
......@@ -389,11 +391,11 @@ function createNewUnit(e) {
template = $(this).data('template');
$.post('/clone_item',
{'parent_location' : parent,
'template' : template,
{'parent_location': parent,
'template': template,
'display_name': 'New Unit'
},
function(data) {
function (data) {
// redirect to the edit page
window.location = "/edit/" + data['id'];
});
......@@ -415,14 +417,14 @@ function deleteSection(e) {
}
function _deleteItem($el) {
if(!confirm('Are you sure you wish to delete this item. It cannot be reversed!'))
if (!confirm('Are you sure you wish to delete this item. It cannot be reversed!'))
return;
var id = $el.data('id');
$.post('/delete_item',
{'id': id, 'delete_children' : true, 'delete_all_versions' : true},
function(data) {
{'id': id, 'delete_children': true, 'delete_all_versions': true},
function (data) {
$el.remove();
});
}
......@@ -451,7 +453,7 @@ function startUpload(e) {
$('.upload-modal .progress-bar').removeClass('loaded').show();
}
function resetUploadBar(){
function resetUploadBar() {
var percentVal = '0%';
$('.upload-modal .progress-fill').width(percentVal);
$('.upload-modal .progress-fill').html(percentVal);
......@@ -464,7 +466,7 @@ function showUploadFeedback(event, position, total, percentComplete) {
}
function displayFinishedUpload(xhr) {
if(xhr.status = 200){
if (xhr.status = 200) {
markAsLoaded();
}
......@@ -491,7 +493,7 @@ function markAsLoaded() {
}
function hideModal(e) {
if(e) {
if (e) {
e.preventDefault();
}
// Unit editors do not want the modal cover to hide when users click outside
......@@ -505,7 +507,7 @@ function hideModal(e) {
}
function onKeyUp(e) {
if(e.which == 87) {
if (e.which == 87) {
$body.toggleClass('show-wip hide-wip');
}
}
......@@ -555,14 +557,14 @@ function showToastMessage(message, $button, lifespan) {
var $content = $('<div class="notification-content"></div>');
$content.html(message);
$toast.append($content);
if($button) {
if ($button) {
$button.addClass('action-button');
$button.bind('click', hideToastMessage);
$content.append($button);
}
$closeBtn.bind('click', hideToastMessage);
if($('.toast-notification')[0]) {
if ($('.toast-notification')[0]) {
var targetY = $('.toast-notification').offset().top + $('.toast-notification').outerHeight();
$toast.css('top', (targetY + 10) + 'px');
}
......@@ -570,8 +572,8 @@ function showToastMessage(message, $button, lifespan) {
$body.prepend($toast);
$toast.fadeIn(200);
if(lifespan) {
$toast.timer = setTimeout(function() {
if (lifespan) {
$toast.timer = setTimeout(function () {
$toast.fadeOut(300);
}, lifespan * 1000);
}
......@@ -597,7 +599,7 @@ function addNewSection(e, isTemplate) {
}
function checkForCancel(e) {
if(e.which == 27) {
if (e.which == 27) {
$body.unbind('keyup', checkForCancel);
e.data.$cancelButton.click();
}
......@@ -613,11 +615,11 @@ function saveNewSection(e) {
var display_name = $(this).find('.new-section-name').val();
$.post('/clone_item', {
'parent_location' : parent,
'template' : template,
'parent_location': parent,
'template': template,
'display_name': display_name,
},
function(data) {
function (data) {
if (data.id != undefined)
location.reload();
}
......@@ -652,18 +654,18 @@ function saveNewCourse(e) {
var number = $newCourse.find('.new-course-number').val();
var 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.');
return;
}
$.post('/create_new_course', {
'template' : template,
'org' : org,
'number' : number,
'template': template,
'org': org,
'number': number,
'display_name': display_name
},
function(data) {
function (data) {
if (data.id != undefined) {
window.location = '/' + data.id.replace(/.*:\/\//, '');
} else if (data.ErrMsg != undefined) {
......@@ -707,11 +709,11 @@ function saveNewSubsection(e) {
var display_name = $(this).find('.new-subsection-name-input').val();
$.post('/clone_item', {
'parent_location' : parent,
'template' : template,
'parent_location': parent,
'template': template,
'display_name': display_name
},
function(data) {
function (data) {
if (data.id != undefined) {
location.reload();
}
......@@ -766,9 +768,8 @@ function saveEditSectionName(e) {
type: "POST",
dataType: "json",
contentType: "application/json",
data:JSON.stringify({ 'id' : id, 'metadata' : {'display_name' : display_name}})
}).success(function()
{
data: JSON.stringify({ 'id': id, 'metadata': {'display_name': display_name}})
}).success(function () {
$spinner.delay(250).fadeOut(250);
$_this.closest('h3').find('.section-name-span').html(display_name).show();
$_this.hide();
......@@ -805,9 +806,8 @@ function saveSetSectionScheduleDate(e) {
type: "POST",
dataType: "json",
contentType: "application/json",
data:JSON.stringify({ 'id' : id, 'metadata' : {'start' : start}})
}).success(function()
{
data: JSON.stringify({ 'id': id, 'metadata': {'start': start}})
}).success(function () {
var $thisSection = $('.courseware-section[data-id="' + id + '"]');
$thisSection.find('.section-published-date').html('<span class="published-status"><strong>Will Release:</strong> ' + input_date + ' at ' + input_time + '</span><a href="#" class="edit-button" data-date="' + input_date + '" data-time="' + input_time + '" data-id="' + id + '">Edit</a>');
$thisSection.find('.section-published-date').animate({
......
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