Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
aad5015a
Commit
aad5015a
authored
Jan 31, 2013
by
Don Mitchell
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1398 from MITx/feature/christina/misc2
Fixes date bug (#149).
parents
fbd9a126
b613bdc3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
46 deletions
+50
-46
cms/static/js/views/settings/main_settings_view.js
+50
-46
No files found.
cms/static/js/views/settings/main_settings_view.js
View file @
aad5015a
...
...
@@ -211,15 +211,15 @@ CMS.Views.Settings.Details = CMS.Views.ValidatingView.extend({
'intro_video'
:
'course-introduction-video'
,
'effort'
:
"course-effort"
},
setupDatePicker
:
function
(
fieldName
)
{
var
cacheModel
=
this
.
model
;
var
div
=
this
.
$el
.
find
(
'#'
+
this
.
fieldToSelectorMap
[
fieldName
]);
var
datefield
=
$
(
div
).
find
(
".date"
);
var
timefield
=
$
(
div
).
find
(
".time"
);
var
cachethis
=
this
;
var
savefield
=
function
()
{
cachethis
.
clearValidationErrors
();
setupDatePicker
:
function
(
fieldName
)
{
var
cacheModel
=
this
.
model
;
var
div
=
this
.
$el
.
find
(
'#'
+
this
.
fieldToSelectorMap
[
fieldName
]);
var
datefield
=
$
(
div
).
find
(
".date"
);
var
timefield
=
$
(
div
).
find
(
".time"
);
var
cachethis
=
this
;
var
savefield
=
function
()
{
cachethis
.
clearValidationErrors
();
var
date
=
datefield
.
datepicker
(
'getDate'
);
if
(
date
)
{
var
time
=
timefield
.
timepicker
(
"getSecondsFromMidnight"
);
...
...
@@ -227,21 +227,24 @@ CMS.Views.Settings.Details = CMS.Views.ValidatingView.extend({
time
=
0
;
}
var
newVal
=
new
Date
(
date
.
getTime
()
+
time
*
1000
);
if
(
cacheModel
.
get
(
fieldName
)
!=
newVal
)
cacheModel
.
save
(
fieldName
,
newVal
,
{
error
:
CMS
.
ServerError
});
if
(
cacheModel
.
get
(
fieldName
).
getTime
()
!==
newVal
.
getTime
())
{
cacheModel
.
save
(
fieldName
,
newVal
,
{
error
:
CMS
.
ServerError
});
}
}
};
// instrument as date and time pickers
timefield
.
timepicker
();
// FIXME being called 2x on each change. Was trapping datepicker onSelect b4 but change to datepair broke that
datefield
.
datepicker
({
onSelect
:
savefield
});
timefield
.
on
(
'changeTime'
,
savefield
);
datefield
.
datepicker
(
'setDate'
,
this
.
model
.
get
(
fieldName
));
if
(
this
.
model
.
has
(
fieldName
))
timefield
.
timepicker
(
'setTime'
,
this
.
model
.
get
(
fieldName
));
},
};
// instrument as date and time pickers
timefield
.
timepicker
();
datefield
.
datepicker
();
// Using the change event causes savefield to be triggered twice, but it is necessary
// to pick up when the date is typed directly in the field.
datefield
.
change
(
savefield
);
timefield
.
on
(
'changeTime'
,
savefield
);
datefield
.
datepicker
(
'setDate'
,
this
.
model
.
get
(
fieldName
));
if
(
this
.
model
.
has
(
fieldName
))
timefield
.
timepicker
(
'setTime'
,
this
.
model
.
get
(
fieldName
));
},
updateModel
:
function
(
event
)
{
switch
(
event
.
currentTarget
.
id
)
{
...
...
@@ -294,29 +297,30 @@ CMS.Views.Settings.Details = CMS.Views.ValidatingView.extend({
}
},
codeMirrors
:
{},
codeMirrorize
:
function
(
e
,
forcedTarget
)
{
if
(
forcedTarget
)
{
thisTarget
=
forcedTarget
;
thisTarget
.
id
=
$
(
thisTarget
).
attr
(
'id'
);
}
else
{
thisTarget
=
e
.
currentTarget
;
}
codeMirrorize
:
function
(
e
,
forcedTarget
)
{
var
thisTarget
;
if
(
forcedTarget
)
{
thisTarget
=
forcedTarget
;
thisTarget
.
id
=
$
(
thisTarget
).
attr
(
'id'
);
}
else
{
thisTarget
=
e
.
currentTarget
;
}
if
(
!
this
.
codeMirrors
[
thisTarget
.
id
])
{
var
cachethis
=
this
;
var
field
=
this
.
selectorToField
[
thisTarget
.
id
];
this
.
codeMirrors
[
thisTarget
.
id
]
=
CodeMirror
.
fromTextArea
(
thisTarget
,
{
mode
:
"text/html"
,
lineNumbers
:
true
,
lineWrapping
:
true
,
onBlur
:
function
(
mirror
)
{
mirror
.
save
();
cachethis
.
clearValidationErrors
();
var
newVal
=
mirror
.
getValue
();
if
(
cachethis
.
model
.
get
(
field
)
!=
newVal
)
cachethis
.
model
.
save
(
field
,
newVal
,
{
error
:
CMS
.
ServerError
});
}
});
}
}
if
(
!
this
.
codeMirrors
[
thisTarget
.
id
])
{
var
cachethis
=
this
;
var
field
=
this
.
selectorToField
[
thisTarget
.
id
];
this
.
codeMirrors
[
thisTarget
.
id
]
=
CodeMirror
.
fromTextArea
(
thisTarget
,
{
mode
:
"text/html"
,
lineNumbers
:
true
,
lineWrapping
:
true
,
onBlur
:
function
(
mirror
)
{
mirror
.
save
();
cachethis
.
clearValidationErrors
();
var
newVal
=
mirror
.
getValue
();
if
(
cachethis
.
model
.
get
(
field
)
!=
newVal
)
cachethis
.
model
.
save
(
field
,
newVal
,
{
error
:
CMS
.
ServerError
});
}
});
}
}
});
...
...
@@ -668,7 +672,7 @@ CMS.Views.Settings.GraderView = CMS.Views.ValidatingView.extend({
$
(
event
.
currentTarget
).
parent
().
append
(
this
.
errorTemplate
({
message
:
'For grading to work, you must change all "'
+
oldName
+
'" subsections to "'
+
this
.
model
.
get
(
'type'
)
+
'".'
}));
}
;
}
break
;
default
:
this
.
saveIfChanged
(
event
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment