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
25388dec
Commit
25388dec
authored
May 20, 2013
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor cleanup.
parent
2020923f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
5 deletions
+12
-5
cms/static/js/views/metadata_editor_view.js
+12
-5
No files found.
cms/static/js/views/metadata_editor_view.js
View file @
25388dec
...
...
@@ -158,24 +158,27 @@ CMS.Views.Metadata.Number = CMS.Views.Metadata.AbstractEditor.extend({
render
:
function
()
{
CMS
.
Views
.
Metadata
.
AbstractEditor
.
prototype
.
render
.
apply
(
this
);
if
(
!
this
.
initialized
)
{
var
numToString
=
function
(
val
)
{
return
val
.
toFixed
(
4
);
};
var
min
=
"min"
;
var
max
=
"max"
;
var
step
=
"step"
;
var
options
=
this
.
model
.
getOptions
();
if
(
options
.
hasOwnProperty
(
min
))
{
this
.
min
=
Number
(
options
[
min
]);
this
.
$el
.
find
(
'input'
).
attr
(
min
,
this
.
min
.
toFixed
(
4
));
this
.
$el
.
find
(
'input'
).
attr
(
min
,
numToString
(
this
.
min
));
}
if
(
options
.
hasOwnProperty
(
max
))
{
this
.
max
=
Number
(
options
[
max
]);
this
.
$el
.
find
(
'input'
).
attr
(
max
,
this
.
max
.
toFixed
(
4
));
this
.
$el
.
find
(
'input'
).
attr
(
max
,
numToString
(
this
.
max
.
toFixed
));
}
var
stepValue
=
undefined
;
if
(
options
.
hasOwnProperty
(
step
))
{
// Parse step and convert to String. Polyfill doesn't like float values like ".1" (expects "0.1").
stepValue
=
Number
(
options
[
step
]).
toFixed
(
4
);
stepValue
=
numToString
(
Number
(
options
[
step
])
);
}
else
if
(
this
.
model
.
getType
()
===
'Integer'
)
{
else
if
(
this
.
isIntegerField
()
)
{
stepValue
=
"1"
;
}
if
(
stepValue
!==
undefined
)
{
...
...
@@ -201,6 +204,10 @@ CMS.Views.Metadata.Number = CMS.Views.Metadata.AbstractEditor.extend({
this
.
$el
.
find
(
'input'
).
val
(
value
);
},
isIntegerField
:
function
()
{
return
this
.
model
.
getType
()
===
'Integer'
;
},
keyPressed
:
function
(
e
)
{
this
.
showClearButton
();
// This first filtering if statement is take from polyfill to prevent
...
...
@@ -212,7 +219,7 @@ CMS.Views.Metadata.Number = CMS.Views.Metadata.AbstractEditor.extend({
e
.
preventDefault
();
}
// For integers, prevent decimal points.
if
(
this
.
model
.
getType
()
===
'Integer'
&&
e
.
keyCode
===
46
)
{
if
(
this
.
isIntegerField
()
&&
e
.
keyCode
===
46
)
{
e
.
preventDefault
();
}
},
...
...
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