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
04ff6370
Commit
04ff6370
authored
Aug 24, 2015
by
Chris Rodriguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PR feedback on JS
parent
1d07b278
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
31 deletions
+20
-31
lms/static/js/utils/navigation.js
+19
-30
lms/templates/main.html
+1
-1
No files found.
lms/static/js/utils/navigation.js
View file @
04ff6370
...
...
@@ -9,64 +9,53 @@ var edx = edx || {},
if
(
$
(
'#accordion'
).
length
)
{
navigation
.
openAccordion
();
navigation
.
checkForCurrent
();
navigation
.
listenForClick
();
}
},
openAccordion
:
function
()
{
$
(
'#open_close_accordion a'
).
click
();
$
(
'.course-wrapper'
).
toggl
eClass
(
'closed'
);
$
(
'.course-wrapper'
).
remov
eClass
(
'closed'
);
$
(
'#accordion'
).
show
();
navigation
.
checkForCurrent
();
navigation
.
listenForClick
();
},
checkForCurrent
:
function
()
{
var
active
;
active
=
$
(
'#accordion div div:has(a.active)'
).
index
(
'#accordion div div'
);
var
active
=
$
(
'#accordion .chapter-content-container .chapter-menu:has(a.active)'
).
index
(
'#accordion .chapter-content-container .chapter-menu'
)
?
$
(
'#accordion .chapter-content-container .chapter-menu:has(a.active)'
).
index
(
'#accordion .chapter-content-container .chapter-menu'
)
:
0
,
activeSection
=
$
(
'#accordion .button-chapter:eq('
+
active
+
')'
);
if
(
typeof
active
===
'undefined'
||
active
<
0
)
{
active
=
0
;
}
if
(
active
>
0
)
{
$
(
'#accordion'
).
find
(
'.button-chapter:eq('
+
active
+
')'
).
trigger
(
'click'
);
}
navigation
.
closeAccordions
();
navigation
.
openAccordionSection
(
activeSection
);
},
listenForClick
:
function
()
{
$
(
'#accordion'
).
on
(
'click'
,
'.button-chapter'
,
function
(
event
)
{
// close and reset all accrdions
navigation
.
resetAllAccordions
();
// open this accordion and send focus
navigation
.
closeAccordions
();
navigation
.
openAccordionSection
(
event
.
currentTarget
);
// assign classes and set open aria
navigation
.
setAriaAttrs
(
event
.
currentTarget
);
});
},
resetAll
Accordions
:
function
()
{
close
Accordions
:
function
()
{
$
(
'.chapter-content-container'
).
hide
();
$
(
'.chapter-content-container .chapter-menu'
).
hide
();
$
(
'#accordion .button-chapter'
).
each
(
function
(
event
)
{
$
(
this
).
removeClass
(
'is-open'
).
attr
(
'aria-pressed'
,
'false'
);
$
(
this
).
next
(
'.chapter-content-container'
).
attr
(
'aria-expanded'
,
'false'
);
$
(
this
).
children
(
'.group-heading'
).
removeClass
(
'active'
);
$
(
this
).
children
(
'.group-heading'
).
find
(
'.icon'
).
addClass
(
'fa-caret-right'
).
removeClass
(
'fa-caret-down'
);
var
el
=
$
(
this
);
el
.
removeClass
(
'is-open'
).
attr
(
'aria-pressed'
,
'false'
);
el
.
next
(
'.chapter-content-container'
).
attr
(
'aria-expanded'
,
'false'
);
el
.
children
(
'.group-heading'
).
removeClass
(
'active'
);
el
.
children
(
'.group-heading'
).
find
(
'.icon'
).
addClass
(
'fa-caret-right'
).
removeClass
(
'fa-caret-down'
);
});
},
openAccordionSection
:
function
(
section
)
{
$
(
section
).
next
(
'.chapter-content-container'
).
show
().
focus
();
$
(
section
).
next
(
'.chapter-content-container'
).
find
(
'.chapter-menu'
).
show
();
var
elSection
=
$
(
section
).
next
(
'.chapter-content-container'
);
navigation
.
setAriaAttrs
(
section
);
},
elSection
.
show
().
focus
(
);
elSection
.
find
(
'.chapter-menu'
).
show
();
setAriaAttrs
:
function
(
section
)
{
$
(
section
).
addClass
(
'is-open'
).
attr
(
'aria-pressed'
,
'true'
);
$
(
section
).
next
(
'.chapter-content-container'
).
attr
(
'aria-expanded'
,
'true'
);
$
(
section
).
children
(
'.group-heading'
).
addClass
(
'active'
);
...
...
lms/templates/main.html
View file @
04ff6370
...
...
@@ -159,7 +159,7 @@ from branding import api as branding_api
<
%
block
name=
"js_extra"
/>
<script
type=
"text/javascript"
src=
"${static.url('js/vendor/noreferrer.js')}"
charset=
"utf-8"
></script>
<script
type=
"text/javascript"
src=
"${static.url('
coffee/src
/navigation.js')}"
charset=
"utf-8"
></script>
<script
type=
"text/javascript"
src=
"${static.url('
js/utils
/navigation.js')}"
charset=
"utf-8"
></script>
</body>
</html>
...
...
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