Refactor module loading using class detection
This commit is contained in:
19
templates/coffee/src/courseware_navigation.coffee
Normal file
19
templates/coffee/src/courseware_navigation.coffee
Normal file
@@ -0,0 +1,19 @@
|
||||
class CoursewareNavigation
|
||||
constructor: ->
|
||||
if $('#accordion').length
|
||||
active = $('#accordion ul:has(li.active)').index('#accordion ul')
|
||||
$('#accordion').bind('accordionchange', @log).accordion
|
||||
active: if active >= 0 then active else 1
|
||||
header: 'h3'
|
||||
autoHeight: false
|
||||
$('#open_close_accordion a').click @toggle
|
||||
|
||||
$('#accordion').show()
|
||||
|
||||
log: (event, ui) ->
|
||||
log_event 'accordion',
|
||||
newheader: ui.newHeader.text()
|
||||
oldheader: ui.oldHeader.text()
|
||||
|
||||
toggle: ->
|
||||
$('.course-wrapper').toggleClass('closed')
|
||||
@@ -40,20 +40,20 @@ class window.Sequence
|
||||
@position = new_position
|
||||
@toggleArrows()
|
||||
|
||||
goto: (e) =>
|
||||
e.preventDefault()
|
||||
new_position = $(e.srcElement).data('element')
|
||||
goto: (event) =>
|
||||
event.preventDefault()
|
||||
new_position = $(event.target).data('element')
|
||||
log_event("seq_goto", old: @position, new: new_position, id: @id)
|
||||
@render new_position
|
||||
|
||||
next: (e) =>
|
||||
e.preventDefault()
|
||||
next: (event) =>
|
||||
event.preventDefault()
|
||||
new_position = @position + 1
|
||||
log_event("seq_next", old: @position, new: new_position, id: @id)
|
||||
@render new_position
|
||||
|
||||
previous: (e) =>
|
||||
e.preventDefault()
|
||||
previous: (event) =>
|
||||
event.preventDefault()
|
||||
new_position = @position - 1
|
||||
log_event("seq_prev", old: @position, new: new_position, id: @id)
|
||||
@render new_position
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class window.Video
|
||||
class Video
|
||||
constructor: (@id, videos) ->
|
||||
@element = $("#video_#{@id}")
|
||||
@parseVideos videos
|
||||
@@ -14,9 +14,10 @@ class window.Video
|
||||
|
||||
parseVideos: (videos) ->
|
||||
@videos = {}
|
||||
$.each videos, (speed, url) =>
|
||||
speed = parseFloat(speed).toFixed(2).replace /\.00$/, '.0'
|
||||
@videos[speed] = url
|
||||
$.each videos.split(/,/), (index, video) =>
|
||||
video = video.split(/:/)
|
||||
speed = parseFloat(video[0]).toFixed(2).replace /\.00$/, '.0'
|
||||
@videos[speed] = video[1]
|
||||
|
||||
parseSpeed: ->
|
||||
@setSpeed($.cookie('video_speed'))
|
||||
|
||||
19
templates/coffee/src/navigation.coffee
Normal file
19
templates/coffee/src/navigation.coffee
Normal file
@@ -0,0 +1,19 @@
|
||||
class Courseware::Navigation
|
||||
constructor: ->
|
||||
if $('#accordion').length
|
||||
active = $('#accordion ul:has(li.active)').index('#accordion ul')
|
||||
$('#accordion').bind('accordionchange', @log).accordion
|
||||
active: if active >= 0 then active else 1
|
||||
header: 'h3'
|
||||
autoHeight: false
|
||||
$('#open_close_accordion a').click @toggle
|
||||
|
||||
$('#accordion').show()
|
||||
|
||||
log: (event, ui) ->
|
||||
log_event 'accordion',
|
||||
newheader: ui.newHeader.text()
|
||||
oldheader: ui.oldHeader.text()
|
||||
|
||||
toggle: ->
|
||||
$('.course-wrapper').toggleClass('closed')
|
||||
@@ -2,7 +2,7 @@
|
||||
<h1> ${name} </h1>
|
||||
% endif
|
||||
|
||||
<div id="video_${id}" class="video">
|
||||
<div id="video_${id}" class="video" data-streams="${streams}">
|
||||
<div class="tc-wrapper">
|
||||
<article class="video-wrapper">
|
||||
<section class="video-player">
|
||||
@@ -41,14 +41,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%block name="js_extra">
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
new Video('${id}', ${streams});
|
||||
});
|
||||
</script>
|
||||
</%block>
|
||||
|
||||
<ol class="video-mod">
|
||||
% for t in annotations:
|
||||
<li id="video-${annotations.index(t)}">
|
||||
|
||||
Reference in New Issue
Block a user