save dates on enter key press
STUD-1506
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
require(["domReady", "jquery", "underscore", "gettext", "js/views/feedback_notification", "js/views/feedback_prompt",
|
||||
"js/utils/get_date", "js/utils/module", "js/utils/handle_iframe_binding", "jquery.ui", "jquery.leanModal", "jquery.form", "jquery.smoothScroll"],
|
||||
function(domReady, $, _, gettext, NotificationView, PromptView, DateUtils, ModuleUtils, IframeUtils) {
|
||||
"js/utils/get_date", "js/utils/module", "js/utils/handle_iframe_binding", "js/utils/change_on_enter", "jquery.ui",
|
||||
"jquery.leanModal", "jquery.form", "jquery.smoothScroll"],
|
||||
function(domReady, $, _, gettext, NotificationView, PromptView, DateUtils, ModuleUtils, IframeUtils, TriggerChangeEventOnEnter)
|
||||
{
|
||||
|
||||
var $body;
|
||||
var $newComponentItem;
|
||||
@@ -89,7 +91,7 @@ domReady(function() {
|
||||
$('.subsection-display-name-input').each(function() {
|
||||
this.val = $(this).val();
|
||||
});
|
||||
$("#start_date, #start_time, #due_date, #due_time").bind('change', autosaveInput);
|
||||
$("#start_date, #start_time, #due_date, #due_time").change(autosaveInput).keyup(TriggerChangeEventOnEnter)
|
||||
$('.sync-date, .remove-date').bind('click', autosaveInput);
|
||||
|
||||
// expand/collapse methods for optional date setters
|
||||
|
||||
11
cms/static/js/utils/change_on_enter.js
Normal file
11
cms/static/js/utils/change_on_enter.js
Normal file
@@ -0,0 +1,11 @@
|
||||
define(["jquery"], function($) {
|
||||
// Trigger "Change" event on "Enter" keyup event
|
||||
var triggerChangeEventOnEnter = function (e) {
|
||||
if(e.which == 13)
|
||||
{
|
||||
$(this).trigger("change").blur();
|
||||
}
|
||||
};
|
||||
|
||||
return triggerChangeEventOnEnter;
|
||||
});
|
||||
@@ -1,5 +1,6 @@
|
||||
define(["js/views/validation", "codemirror", "underscore", "jquery", "jquery.ui", "tzAbbr", "js/models/uploads", "js/views/uploads", "jquery.timepicker", "date"],
|
||||
function(ValidatingView, CodeMirror, _, $, ui, tzAbbr, FileUploadModel, FileUploadDialog) {
|
||||
define(["js/views/validation", "codemirror", "underscore", "jquery", "jquery.ui", "tzAbbr", "js/models/uploads",
|
||||
"js/views/uploads", "js/utils/change_on_enter", "jquery.timepicker", "date"],
|
||||
function(ValidatingView, CodeMirror, _, $, ui, tzAbbr, FileUploadModel, FileUploadDialog, TriggerChangeEventOnEnter) {
|
||||
|
||||
var DetailsView = ValidatingView.extend({
|
||||
// Model class is CMS.Models.Settings.CourseDetails
|
||||
@@ -121,7 +122,7 @@ var DetailsView = ValidatingView.extend({
|
||||
|
||||
// Using the change event causes setfield to be triggered twice, but it is necessary
|
||||
// to pick up when the date is typed directly in the field.
|
||||
datefield.change(setfield);
|
||||
datefield.change(setfield).keyup(TriggerChangeEventOnEnter);
|
||||
timefield.on('changeTime', setfield);
|
||||
timefield.on('input', setfield);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user