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
12d2c47c
Commit
12d2c47c
authored
Oct 11, 2013
by
polesye
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix BLD-165.
parent
f00f9001
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
13 deletions
+43
-13
lms/static/coffee/fixtures/calculator.html
+4
-4
lms/static/coffee/src/calculator.coffee
+39
-9
No files found.
lms/static/coffee/fixtures/calculator.html
View file @
12d2c47c
...
...
@@ -4,14 +4,14 @@
<div
id=
"calculator_wrapper"
>
<form
id=
"calculator"
>
<div
class=
"input-wrapper"
>
<input
type=
"text"
id=
"calculator_input"
/>
<input
type=
"text"
id=
"calculator_input"
tabindex=
"-1"
/>
<div
class=
"help-wrapper"
>
<a
href=
"#"
>
Hints
</a>
<a
href=
"#"
aria-expanded=
"false"
tabindex=
"-1"
>
Hints
</a>
<dl
class=
"help"
></dl>
</div>
</div>
<input
id=
"calculator_button"
type=
"submit"
value=
"="
/>
<input
type=
"text"
id=
"calculator_output"
readonly
/>
<input
id=
"calculator_button"
type=
"submit"
value=
"="
tabindex=
"-1"
/>
<input
type=
"text"
id=
"calculator_output"
readonly
tabindex=
"-1"
/>
</form>
</div>
</li>
...
...
lms/static/coffee/src/calculator.coffee
View file @
12d2c47c
...
...
@@ -3,25 +3,55 @@ class @Calculator
$
(
'.calc'
).
click
@
toggle
$
(
'form#calculator'
).
submit
(
@
calculate
).
submit
(
e
)
->
e
.
preventDefault
()
$
(
'div.help-wrapper a'
).
hover
(
@
helpToggle
).
click
(
e
)
->
e
.
preventDefault
()
$
(
'div.help-wrapper a'
)
.
focus
(
$
.
proxy
@
helpOnFocus
,
@
)
.
blur
(
$
.
proxy
@
helpOnBlur
,
@
)
.
hover
(
$
.
proxy
(
@
helpShow
,
@
),
$
.
proxy
(
@
helpHide
,
@
)
)
.
click
(
e
)
->
e
.
preventDefault
()
toggle
:
(
event
)
->
event
.
preventDefault
()
$calc
=
$
(
'.calc'
)
$calcWrapper
=
$
(
'#calculator_wrapper'
)
$
(
'div.calc-main'
).
toggleClass
'open'
if
$
(
'.calc.closed'
).
length
$
(
'.calc'
).
attr
'aria-label'
,
'Open Calculator'
if
$calc
.
hasClass
(
'closed'
)
$calc
.
attr
'aria-label'
,
'Open Calculator'
$calcWrapper
.
find
(
'input, a'
)
.
attr
'tabindex'
,
-
1
else
$
(
'.calc'
).
attr
'aria-label'
,
'Close Calculator'
$calc
.
attr
'aria-label'
,
'Close Calculator'
$calcWrapper
.
find
(
'input, a'
)
.
attr
'tabindex'
,
null
# TODO: Investigate why doing this without the timeout causes it to jump
# down to the bottom of the page. I suspect it's because it's putting the
# focus on the text field before it transitions onto the page.
setTimeout
(
->
$
(
'#calculator_wrapper #calculator_input'
).
focus
()),
100
setTimeout
(
->
$calcWrapper
.
find
(
'#calculator_input'
).
focus
()),
100
$calc
.
toggleClass
'closed'
helpOnFocus
:
(
e
)
->
e
.
preventDefault
()
@
isFocusedHelp
=
true
@
helpShow
()
helpOnBlur
:
(
e
)
->
e
.
preventDefault
()
@
isFocusedHelp
=
false
@
helpHide
()
$
(
'.calc'
).
toggleClass
'closed'
helpShow
:
->
$
(
'.help'
).
addClass
'shown'
helpToggle
:
->
$
(
'.help'
).
toggleClass
'shown'
helpHide
:
->
if
not
@
isFocusedHelp
$
(
'.help'
).
removeClass
'shown'
calculate
:
->
$
.
getWithPrefix
'/calculate'
,
{
equation
:
$
(
'#calculator_input'
).
val
()
},
(
data
)
->
...
...
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