Commit 3ba03d79 by Calen Pennington

Remove old generated static content that was accidentally checked in

parent 3fa636e0
// Generated by CoffeeScript 1.3.3
(function() {
this.Calculator = (function() {
function Calculator() {
$('.calc').click(this.toggle);
$('form#calculator').submit(this.calculate).submit(function(e) {
return e.preventDefault();
});
$('div.help-wrapper a').hover(this.helpToggle).click(function(e) {
return e.preventDefault();
});
}
Calculator.prototype.toggle = function() {
$('li.calc-main').toggleClass('open');
$('#calculator_wrapper #calculator_input').focus();
if ($('.calc.closed').length) {
$('.calc').attr('aria-label', 'Open Calculator');
} else {
$('.calc').attr('aria-label', 'Close Calculator');
}
return $('.calc').toggleClass('closed');
};
Calculator.prototype.helpToggle = function() {
return $('.help').toggleClass('shown');
};
Calculator.prototype.calculate = function() {
return $.getWithPrefix('/calculate', {
equation: $('#calculator_input').val()
}, function(data) {
return $('#calculator_output').val(data.result);
});
};
return Calculator;
})();
}).call(this);
// Generated by CoffeeScript 1.3.3
(function() {
this.Courseware = (function() {
Courseware.prefix = '';
function Courseware() {
Courseware.prefix = $("meta[name='path_prefix']").attr('content');
new Navigation;
new Calculator;
new FeedbackForm;
Logger.bind();
this.bind();
this.render();
}
Courseware.start = function() {
return new Courseware;
};
Courseware.prototype.bind = function() {
return $('.course-content .sequence, .course-content .tab').bind('contentChanged', this.render);
};
Courseware.prototype.render = function() {
$('.course-content .video').each(function() {
var id;
id = $(this).attr('id').replace(/video_/, '');
return new Video(id, $(this).data('streams'), $(this).data('caption-url'));
});
$('.course-content .problems-wrapper').each(function() {
var id;
id = $(this).attr('id').replace(/problem_/, '');
return new Problem(id, $(this).data('url'));
});
return $('.course-content .histogram').each(function() {
var id;
id = $(this).attr('id').replace(/histogram_/, '');
return new Histogram(id, $(this).data('histogram'));
});
};
return Courseware;
})();
}).call(this);
// Generated by CoffeeScript 1.3.3
(function() {
this.FeedbackForm = (function() {
function FeedbackForm() {
$('#feedback_button').click(function() {
var data;
data = {
subject: $('#feedback_subject').val(),
message: $('#feedback_message').val(),
url: window.location.href
};
return $.postWithPrefix('/send_feedback', data, function() {
return $('#feedback_div').html('Feedback submitted. Thank you');
}, 'json');
});
}
return FeedbackForm;
})();
}).call(this);
// Generated by CoffeeScript 1.3.3
(function() {
this.Histogram = (function() {
function Histogram(id, rawData) {
this.id = id;
this.rawData = rawData;
this.xTicks = [];
this.yTicks = [];
this.data = [];
this.calculate();
this.render();
}
Histogram.prototype.calculate = function() {
var count, log_count, score, _i, _len, _ref, _ref1, _results;
_ref = this.rawData;
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
_ref1 = _ref[_i], score = _ref1[0], count = _ref1[1];
log_count = Math.log(count + 1);
this.data.push([score, log_count]);
this.xTicks.push([score, score.toString()]);
_results.push(this.yTicks.push([log_count, count.toString()]));
}
return _results;
};
Histogram.prototype.render = function() {
return $.plot($("#histogram_" + this.id), [
{
data: this.data,
bars: {
show: true,
align: 'center',
lineWidth: 0,
fill: 1.0
},
color: "#b72121"
}
], {
xaxis: {
min: -1,
max: Math.max.apply(Math, $.map(this.xTicks, function(data) {
return data[0] + 1;
})),
ticks: this.xTicks,
tickLength: 0
},
yaxis: {
min: 0.0,
max: Math.max.apply(Math, $.map(this.yTicks, function(data) {
return data[0] * 1.1;
})),
ticks: this.yTicks,
labelWidth: 50
}
});
};
return Histogram;
})();
}).call(this);
// Generated by CoffeeScript 1.3.3
(function() {
this.Logger = (function() {
function Logger() {}
Logger.log = function(event_type, data) {
return $.getWithPrefix('/event', {
event_type: event_type,
event: JSON.stringify(data),
page: window.location.href
});
};
Logger.bind = function() {
return window.onunload = function() {
return $.ajax({
url: "" + Courseware.prefix + "/event",
data: {
event_type: 'page_close',
event: '',
page: window.location.href
},
async: false
});
};
};
return Logger;
})();
this.log_event = Logger.log;
}).call(this);
// Generated by CoffeeScript 1.3.3
(function() {
jQuery.postWithPrefix = function(url, data, callback, type) {
return $.post("" + Courseware.prefix + url, data, callback, type);
};
jQuery.getWithPrefix = function(url, data, callback, type) {
return $.get("" + Courseware.prefix + url, data, callback, type);
};
$(function() {
$.ajaxSetup({
headers: {
'X-CSRFToken': $.cookie('csrftoken')
},
dataType: 'json'
});
window.onTouchBasedDevice = function() {
return navigator.userAgent.match(/iPhone|iPod|iPad/i);
};
$("a[rel*=leanModal]").leanModal();
$('#csrfmiddlewaretoken').attr('value', $.cookie('csrftoken'));
if ($('body').hasClass('courseware')) {
Courseware.start();
}
window.submit_circuit = function(circuit_id) {
$("input.schematic").each(function(index, element) {
return element.schematic.update_value();
});
schematic_value($("#schematic_" + circuit_id).attr("value"));
return $.postWithPrefix("/save_circuit/" + circuit_id, {
schematic: schematic_value
}, function(data) {
if (data.results === 'success') {
return alert('Saved');
}
});
};
return window.postJSON = function(url, data, callback) {
return $.postWithPrefix(url, data, callback);
};
});
}).call(this);
// Generated by CoffeeScript 1.3.3
(function() {
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
this.Problem = (function() {
function Problem(id, url) {
this.id = id;
this.refreshAnswers = __bind(this.refreshAnswers, this);
this.save = __bind(this.save, this);
this.show = __bind(this.show, this);
this.reset = __bind(this.reset, this);
this.check = __bind(this.check, this);
this.bind = __bind(this.bind, this);
this.element = $("#problem_" + id);
this.content_url = "" + url + "problem_get?id=" + this.id;
this.render();
}
Problem.prototype.$ = function(selector) {
return $(selector, this.element);
};
Problem.prototype.bind = function() {
MathJax.Hub.Queue(["Typeset", MathJax.Hub]);
window.update_schematics();
this.$('section.action input:button').click(this.refreshAnswers);
this.$('section.action input.check').click(this.check);
this.$('section.action input.reset').click(this.reset);
this.$('section.action input.show').click(this.show);
return this.$('section.action input.save').click(this.save);
};
Problem.prototype.render = function(content) {
if (content) {
this.element.html(content);
return this.bind();
} else {
return this.element.load(this.content_url, this.bind);
}
};
Problem.prototype.check = function() {
var _this = this;
Logger.log('problem_check', this.answers);
return $.postWithPrefix("/modx/problem/" + this.id + "/problem_check", this.answers, function(response) {
switch (response.success) {
case 'incorrect':
case 'correct':
return _this.render(response.contents);
default:
return alert(response.success);
}
});
};
Problem.prototype.reset = function() {
var _this = this;
Logger.log('problem_reset', this.answers);
return $.postWithPrefix("/modx/problem/" + this.id + "/problem_reset", {
id: this.id
}, function(content) {
return _this.render(content);
});
};
Problem.prototype.show = function() {
var _this = this;
if (!this.element.hasClass('showed')) {
Logger.log('problem_show', {
problem: this.id
});
return $.postWithPrefix("/modx/problem/" + this.id + "/problem_show", function(response) {
$.each(response, function(key, value) {
var choice, _i, _len, _results;
if ($.isArray(value)) {
_results = [];
for (_i = 0, _len = value.length; _i < _len; _i++) {
choice = value[_i];
_results.push(_this.$("label[for='input_" + key + "_" + choice + "']").attr({
correct_answer: 'true'
}));
}
return _results;
} else {
return _this.$("#answer_" + key).text(value);
}
});
_this.$('.show').val('Hide Answer');
return _this.element.addClass('showed');
});
} else {
this.$('[id^=answer_]').text('');
this.$('[correct_answer]').attr({
correct_answer: null
});
this.element.removeClass('showed');
return this.$('.show').val('Show Answer');
}
};
Problem.prototype.save = function() {
var _this = this;
Logger.log('problem_save', this.answers);
return $.postWithPrefix("/modx/problem/" + this.id + "/problem_save", this.answers, function(response) {
if (response.success) {
return alert('Saved');
}
});
};
Problem.prototype.refreshAnswers = function() {
this.$('input.schematic').each(function(index, element) {
return element.schematic.update_value();
});
this.$(".CodeMirror").each(function(index, element) {
if (element.CodeMirror.save) {
return element.CodeMirror.save();
}
});
return this.answers = this.$("[id^=input_" + this.id + "_]").serialize();
};
return Problem;
})();
}).call(this);
// Generated by CoffeeScript 1.3.3
(function() {
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
this.Sequence = (function() {
function Sequence(id, elements, tag, position) {
this.id = id;
this.elements = elements;
this.tag = tag;
this.previous = __bind(this.previous, this);
this.next = __bind(this.next, this);
this.goto = __bind(this.goto, this);
this.toggleArrows = __bind(this.toggleArrows, this);
this.element = $("#sequence_" + this.id);
this.buildNavigation();
this.bind();
this.render(position);
}
Sequence.prototype.$ = function(selector) {
return $(selector, this.element);
};
Sequence.prototype.bind = function() {
this.element.bind('contentChanged', this.toggleArrows);
return this.$('#sequence-list a').click(this.goto);
};
Sequence.prototype.buildNavigation = function() {
var _this = this;
return $.each(this.elements, function(index, item) {
var link, list_item, title;
link = $('<a>').attr({
"class": "seq_" + item.type + "_inactive",
'data-element': index + 1
});
title = $('<p>').html(item.title);
list_item = $('<li>').append(link.append(title));
return _this.$('#sequence-list').append(list_item);
});
};
Sequence.prototype.toggleArrows = function() {
this.$('.sequence-nav-buttons a').unbind('click');
if (this.position === 1) {
this.$('.sequence-nav-buttons .prev a').addClass('disabled');
} else {
this.$('.sequence-nav-buttons .prev a').removeClass('disabled').click(this.previous);
}
if (this.position === this.elements.length) {
return this.$('.sequence-nav-buttons .next a').addClass('disabled');
} else {
return this.$('.sequence-nav-buttons .next a').removeClass('disabled').click(this.next);
}
};
Sequence.prototype.render = function(new_position) {
if (this.position !== new_position) {
if (this.position !== void 0) {
this.mark_visited(this.position);
$.postWithPrefix("/modx/" + this.tag + "/" + this.id + "/goto_position", {
position: new_position
});
}
this.mark_active(new_position);
this.$('#seq_content').html(eval(this.elements[new_position - 1].content));
MathJax.Hub.Queue(["Typeset", MathJax.Hub]);
this.position = new_position;
return this.element.trigger('contentChanged');
}
};
Sequence.prototype.goto = function(event) {
var new_position;
event.preventDefault();
new_position = $(event.target).data('element');
Logger.log("seq_goto", {
old: this.position,
"new": new_position,
id: this.id
});
return this.render(new_position);
};
Sequence.prototype.next = function(event) {
var new_position;
event.preventDefault();
new_position = this.position + 1;
Logger.log("seq_next", {
old: this.position,
"new": new_position,
id: this.id
});
return this.render(new_position);
};
Sequence.prototype.previous = function(event) {
var new_position;
event.preventDefault();
new_position = this.position - 1;
Logger.log("seq_prev", {
old: this.position,
"new": new_position,
id: this.id
});
return this.render(new_position);
};
Sequence.prototype.link_for = function(position) {
return this.$("#sequence-list a[data-element=" + position + "]");
};
Sequence.prototype.mark_visited = function(position) {
return this.link_for(position).attr({
"class": "seq_" + this.elements[position - 1].type + "_visited"
});
};
Sequence.prototype.mark_active = function(position) {
return this.link_for(position).attr({
"class": "seq_" + this.elements[position - 1].type + "_active"
});
};
return Sequence;
})();
}).call(this);
// Generated by CoffeeScript 1.3.3
(function() {
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
this.Tab = (function() {
function Tab(id, items) {
this.id = id;
this.items = items;
this.onShow = __bind(this.onShow, this);
this.element = $("#tab_" + id);
this.render();
}
Tab.prototype.$ = function(selector) {
return $(selector, this.element);
};
Tab.prototype.render = function() {
var _this = this;
$.each(this.items, function(index, item) {
var tab;
tab = $('<a>').attr({
href: "#" + (_this.tabId(index))
}).html(item.title);
_this.$('.navigation').append($('<li>').append(tab));
return _this.element.append($('<section>').attr({
id: _this.tabId(index)
}));
});
return this.element.tabs({
show: this.onShow
});
};
Tab.prototype.onShow = function(element, ui) {
this.$('section.ui-tabs-hide').html('');
this.$("#" + (this.tabId(ui.index))).html(eval(this.items[ui.index]['content']));
return this.element.trigger('contentChanged');
};
Tab.prototype.tabId = function(index) {
return "tab-" + this.id + "-" + index;
};
return Tab;
})();
}).call(this);
// Generated by CoffeeScript 1.3.3
(function() {
this.Video = (function() {
function Video(id, videos) {
var _this = this;
this.id = id;
window.player = null;
this.element = $("#video_" + this.id);
this.parseVideos(videos);
this.fetchMetadata();
this.parseSpeed();
$("#video_" + this.id).data('video', this);
if (YT.Player) {
this.embed();
} else {
window.onYouTubePlayerAPIReady = function() {
return $('.course-content .video').each(function() {
return $(this).data('video').embed();
});
};
}
}
Video.prototype.youtubeId = function(speed) {
return this.videos[speed || this.speed];
};
Video.prototype.parseVideos = function(videos) {
var _this = this;
this.videos = {};
return $.each(videos.split(/,/), function(index, video) {
var speed;
video = video.split(/:/);
speed = parseFloat(video[0]).toFixed(2).replace(/\.00$/, '.0');
return _this.videos[speed] = video[1];
});
};
Video.prototype.parseSpeed = function() {
this.setSpeed($.cookie('video_speed'));
return this.speeds = ($.map(this.videos, function(url, speed) {
return speed;
})).sort();
};
Video.prototype.setSpeed = function(newSpeed) {
if (this.videos[newSpeed] !== void 0) {
this.speed = newSpeed;
return $.cookie('video_speed', "" + newSpeed, {
expires: 3650,
path: '/'
});
} else {
return this.speed = '1.0';
}
};
Video.prototype.embed = function() {
return this.player = new VideoPlayer(this);
};
Video.prototype.fetchMetadata = function(url) {
var _this = this;
this.metadata = {};
return $.each(this.videos, function(speed, url) {
return $.get("http://gdata.youtube.com/feeds/api/videos/" + url + "?v=2&alt=jsonc", (function(data) {
return _this.metadata[data.data.id] = data.data;
}), 'jsonp');
});
};
Video.prototype.getDuration = function() {
return this.metadata[this.youtubeId()].duration;
};
return Video;
})();
}).call(this);
// Generated by CoffeeScript 1.3.3
(function() {
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
this.VideoCaption = (function() {
function VideoCaption(player, youtubeId) {
this.player = player;
this.youtubeId = youtubeId;
this.toggle = __bind(this.toggle, this);
this.seekPlayer = __bind(this.seekPlayer, this);
this.onMouseLeave = __bind(this.onMouseLeave, this);
this.onMovement = __bind(this.onMovement, this);
this.onMouseEnter = __bind(this.onMouseEnter, this);
this.onWindowResize = __bind(this.onWindowResize, this);
this.onUpdatePlayTime = __bind(this.onUpdatePlayTime, this);
this.render();
this.bind();
}
VideoCaption.prototype.$ = function(selector) {
return this.player.$(selector);
};
VideoCaption.prototype.bind = function() {
$(window).bind('resize', this.onWindowResize);
$(this.player).bind('resize', this.onWindowResize);
$(this.player).bind('updatePlayTime', this.onUpdatePlayTime);
this.$('.hide-subtitles').click(this.toggle);
return this.$('.subtitles').mouseenter(this.onMouseEnter).mouseleave(this.onMouseLeave).mousemove(this.onMovement).bind('mousewheel', this.onMovement).bind('DOMMouseScroll', this.onMovement);
};
VideoCaption.prototype.captionURL = function() {
return "/static/subs/" + this.youtubeId + ".srt.sjson";
};
VideoCaption.prototype.render = function() {
this.$('.video-wrapper').after("<ol class=\"subtitles\"><li>Attempting to load captions...</li></ol>");
this.$('.video-controls .secondary-controls').append("<a href=\"#\" class=\"hide-subtitles\" title=\"Turn off captions\">Captions</a>");
this.$('.subtitles').css({
maxHeight: this.$('.video-wrapper').height() - 5
});
return this.fetchCaption();
};
VideoCaption.prototype.fetchCaption = function() {
var _this = this;
return $.getWithPrefix(this.captionURL(), function(captions) {
_this.captions = captions.text;
_this.start = captions.start;
return _this.renderCaption();
});
};
VideoCaption.prototype.renderCaption = function() {
var container,
_this = this;
container = $('<ol>');
$.each(this.captions, function(index, text) {
return container.append($('<li>').html(text).attr({
'data-index': index,
'data-start': _this.start[index]
}));
});
this.$('.subtitles').html(container.html());
this.$('.subtitles li[data-index]').click(this.seekPlayer);
return this.$('.subtitles').prepend($('<li class="spacing">').height(this.topSpacingHeight())).append($('<li class="spacing">').height(this.bottomSpacingHeight()));
};
VideoCaption.prototype.search = function(time) {
var index, max, min;
min = 0;
max = this.start.length - 1;
while (min < max) {
index = Math.ceil((max + min) / 2);
if (time < this.start[index]) {
max = index - 1;
}
if (time >= this.start[index]) {
min = index;
}
}
return min;
};
VideoCaption.prototype.onUpdatePlayTime = function(event, time) {
var newIndex;
time = Math.round(Time.convert(time, this.player.currentSpeed(), '1.0') * 1000 + 250);
newIndex = this.search(time);
if (newIndex !== void 0 && this.currentIndex !== newIndex) {
if (this.currentIndex) {
this.$(".subtitles li.current").removeClass('current');
}
this.$(".subtitles li[data-index='" + newIndex + "']").addClass('current');
this.currentIndex = newIndex;
return this.scrollCaption();
}
};
VideoCaption.prototype.onWindowResize = function() {
this.$('.subtitles').css({
maxHeight: this.captionHeight()
});
this.$('.subtitles .spacing:first').height(this.topSpacingHeight());
this.$('.subtitles .spacing:last').height(this.bottomSpacingHeight());
return this.scrollCaption();
};
VideoCaption.prototype.onMouseEnter = function() {
if (this.frozen) {
clearTimeout(this.frozen);
}
return this.frozen = setTimeout(this.onMouseLeave, 10000);
};
VideoCaption.prototype.onMovement = function() {
return this.onMouseEnter();
};
VideoCaption.prototype.onMouseLeave = function() {
if (this.frozen) {
clearTimeout(this.frozen);
}
this.frozen = null;
if (this.player.isPlaying()) {
return this.scrollCaption();
}
};
VideoCaption.prototype.scrollCaption = function() {
if (!this.frozen && this.$('.subtitles .current:first').length) {
return this.$('.subtitles').scrollTo(this.$('.subtitles .current:first'), {
offset: -this.calculateOffset(this.$('.subtitles .current:first'))
});
}
};
VideoCaption.prototype.seekPlayer = function(event) {
var time;
event.preventDefault();
time = Math.round(Time.convert($(event.target).data('start'), '1.0', this.player.currentSpeed()) / 1000);
return $(this.player).trigger('seek', time);
};
VideoCaption.prototype.calculateOffset = function(element) {
return this.captionHeight() / 2 - element.height() / 2;
};
VideoCaption.prototype.topSpacingHeight = function() {
return this.calculateOffset(this.$('.subtitles li:not(.spacing):first'));
};
VideoCaption.prototype.bottomSpacingHeight = function() {
return this.calculateOffset(this.$('.subtitles li:not(.spacing):last'));
};
VideoCaption.prototype.toggle = function(event) {
event.preventDefault();
if (this.player.element.hasClass('closed')) {
this.$('.hide-subtitles').attr('title', 'Turn off captions');
this.player.element.removeClass('closed');
return this.scrollCaption();
} else {
this.$('.hide-subtitles').attr('title', 'Turn on captions');
return this.player.element.addClass('closed');
}
};
VideoCaption.prototype.captionHeight = function() {
if (this.player.element.hasClass('fullscreen')) {
return $(window).height() - this.$('.video-controls').height();
} else {
return this.$('.video-wrapper').height();
}
};
return VideoCaption;
})();
}).call(this);
// Generated by CoffeeScript 1.3.3
(function() {
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
this.VideoControl = (function() {
function VideoControl(player) {
this.player = player;
this.togglePlayback = __bind(this.togglePlayback, this);
this.onPause = __bind(this.onPause, this);
this.onPlay = __bind(this.onPlay, this);
this.render();
this.bind();
}
VideoControl.prototype.$ = function(selector) {
return this.player.$(selector);
};
VideoControl.prototype.bind = function() {
$(this.player).bind('play', this.onPlay).bind('pause', this.onPause).bind('ended', this.onPause);
return this.$('.video_control').click(this.togglePlayback);
};
VideoControl.prototype.render = function() {
return this.$('.video-controls').append("<div class=\"slider\"></div>\n<div>\n <ul class=\"vcr\">\n <li><a class=\"video_control play\">Play</a></li>\n <li>\n <div class=\"vidtime\">0:00 / 0:00</div>\n </li>\n </ul>\n <div class=\"secondary-controls\">\n <a href=\"#\" class=\"add-fullscreen\" title=\"Fill browser\">Fill Browser</a>\n </div>\n</div>");
};
VideoControl.prototype.onPlay = function() {
return this.$('.video_control').removeClass('play').addClass('pause').html('Pause');
};
VideoControl.prototype.onPause = function() {
return this.$('.video_control').removeClass('pause').addClass('play').html('Play');
};
VideoControl.prototype.togglePlayback = function(event) {
event.preventDefault();
if (this.player.isPlaying()) {
return $(this.player).trigger('pause');
} else {
return $(this.player).trigger('play');
}
};
return VideoControl;
})();
}).call(this);
// Generated by CoffeeScript 1.3.3
(function() {
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
this.VideoPlayer = (function() {
function VideoPlayer(video) {
this.video = video;
this.toggleFullScreen = __bind(this.toggleFullScreen, this);
this.onUpdatePlayTime = __bind(this.onUpdatePlayTime, this);
this.update = __bind(this.update, this);
this.onSpeedChange = __bind(this.onSpeedChange, this);
this.onPause = __bind(this.onPause, this);
this.onPlay = __bind(this.onPlay, this);
this.onStateChange = __bind(this.onStateChange, this);
this.onReady = __bind(this.onReady, this);
this.bindExitFullScreen = __bind(this.bindExitFullScreen, this);
this.currentTime = 0;
this.element = $("#video_" + this.video.id);
this.render();
this.bind();
}
VideoPlayer.prototype.$ = function(selector) {
return $(selector, this.element);
};
VideoPlayer.prototype.bind = function() {
$(this).bind('seek', this.onSeek).bind('updatePlayTime', this.onUpdatePlayTime).bind('speedChange', this.onSpeedChange).bind('play', this.onPlay).bind('pause', this.onPause).bind('ended', this.onPause);
$(document).keyup(this.bindExitFullScreen);
this.$('.add-fullscreen').click(this.toggleFullScreen);
if (!onTouchBasedDevice()) {
return this.addToolTip();
}
};
VideoPlayer.prototype.bindExitFullScreen = function(event) {
if (this.element.hasClass('fullscreen') && event.keyCode === 27) {
return this.toggleFullScreen(event);
}
};
VideoPlayer.prototype.render = function() {
new VideoControl(this);
new VideoCaption(this, this.video.youtubeId('1.0'));
new VideoSpeedControl(this, this.video.speeds);
new VideoProgressSlider(this);
return this.player = new YT.Player(this.video.id, {
playerVars: {
controls: 0,
wmode: 'transparent',
rel: 0,
showinfo: 0,
enablejsapi: 1
},
videoId: this.video.youtubeId(),
events: {
onReady: this.onReady,
onStateChange: this.onStateChange
}
});
};
VideoPlayer.prototype.addToolTip = function() {
return this.$('.add-fullscreen, .hide-subtitles').qtip({
position: {
my: 'top right',
at: 'top center'
}
});
};
VideoPlayer.prototype.onReady = function() {
$(this).trigger('ready');
$(this).trigger('updatePlayTime', 0);
if (!onTouchBasedDevice()) {
return $('.course-content .video:first').data('video').player.play();
}
};
VideoPlayer.prototype.onStateChange = function(event) {
switch (event.data) {
case YT.PlayerState.PLAYING:
return $(this).trigger('play');
case YT.PlayerState.PAUSED:
return $(this).trigger('pause');
case YT.PlayerState.ENDED:
return $(this).trigger('ended');
}
};
VideoPlayer.prototype.onPlay = function() {
Logger.log('play_video', {
id: this.currentTime,
code: this.player.getVideoEmbedCode()
});
if (window.player && window.player !== this.player) {
window.player.pauseVideo();
}
window.player = this.player;
if (!this.player.interval) {
return this.player.interval = setInterval(this.update, 200);
}
};
VideoPlayer.prototype.onPause = function() {
Logger.log('pause_video', {
id: this.currentTime,
code: this.player.getVideoEmbedCode()
});
if (window.player === this.player) {
window.player = null;
}
clearInterval(this.player.interval);
return this.player.interval = null;
};
VideoPlayer.prototype.onSeek = function(event, time) {
this.player.seekTo(time, true);
if (this.isPlaying()) {
clearInterval(this.player.interval);
return this.player.interval = setInterval(this.update, 200);
} else {
this.currentTime = time;
return $(this).trigger('updatePlayTime', time);
}
};
VideoPlayer.prototype.onSpeedChange = function(event, newSpeed) {
this.currentTime = Time.convert(this.currentTime, parseFloat(this.currentSpeed()), newSpeed);
this.video.setSpeed(parseFloat(newSpeed).toFixed(2).replace(/\.00$/, '.0'));
if (this.isPlaying()) {
this.player.loadVideoById(this.video.youtubeId(), this.currentTime);
} else {
this.player.cueVideoById(this.video.youtubeId(), this.currentTime);
}
return $(this).trigger('updatePlayTime', this.currentTime);
};
VideoPlayer.prototype.update = function() {
if (this.currentTime = this.player.getCurrentTime()) {
return $(this).trigger('updatePlayTime', this.currentTime);
}
};
VideoPlayer.prototype.onUpdatePlayTime = function(event, time) {
var progress;
progress = Time.format(time) + ' / ' + Time.format(this.duration());
return this.$(".vidtime").html(progress);
};
VideoPlayer.prototype.toggleFullScreen = function(event) {
event.preventDefault();
if (this.element.hasClass('fullscreen')) {
this.$('.exit').remove();
this.$('.add-fullscreen').attr('title', 'Fill browser');
this.element.removeClass('fullscreen');
} else {
this.element.append('<a href="#" class="exit">Exit</a>').addClass('fullscreen');
this.$('.add-fullscreen').attr('title', 'Exit fill browser');
this.$('.exit').click(this.toggleFullScreen);
}
return $(this).trigger('resize');
};
VideoPlayer.prototype.play = function() {
if (this.player.playVideo) {
return this.player.playVideo();
}
};
VideoPlayer.prototype.isPlaying = function() {
return this.player.getPlayerState() === YT.PlayerState.PLAYING;
};
VideoPlayer.prototype.pause = function() {
return this.player.pauseVideo();
};
VideoPlayer.prototype.duration = function() {
return this.video.getDuration();
};
VideoPlayer.prototype.currentSpeed = function() {
return this.video.speed;
};
return VideoPlayer;
})();
}).call(this);
// Generated by CoffeeScript 1.3.3
(function() {
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
this.VideoProgressSlider = (function() {
function VideoProgressSlider(player) {
this.player = player;
this.onStop = __bind(this.onStop, this);
this.onChange = __bind(this.onChange, this);
this.onSlide = __bind(this.onSlide, this);
this.onUpdatePlayTime = __bind(this.onUpdatePlayTime, this);
this.onReady = __bind(this.onReady, this);
this.buildSlider();
this.buildHandle();
$(this.player).bind('updatePlayTime', this.onUpdatePlayTime);
$(this.player).bind('ready', this.onReady);
}
VideoProgressSlider.prototype.$ = function(selector) {
return this.player.$(selector);
};
VideoProgressSlider.prototype.buildSlider = function() {
return this.slider = this.$('.slider').slider({
range: 'min',
change: this.onChange,
slide: this.onSlide,
stop: this.onStop
});
};
VideoProgressSlider.prototype.buildHandle = function() {
this.handle = this.$('.ui-slider-handle');
return this.handle.qtip({
content: "" + (Time.format(this.slider.slider('value'))),
position: {
my: 'bottom center',
at: 'top center',
container: this.handle
},
hide: {
delay: 700
},
style: {
classes: 'ui-tooltip-slider',
widget: true
}
});
};
VideoProgressSlider.prototype.onReady = function() {
return this.slider.slider('option', 'max', this.player.duration());
};
VideoProgressSlider.prototype.onUpdatePlayTime = function(event, currentTime) {
if (!this.frozen) {
this.slider.slider('option', 'max', this.player.duration());
return this.slider.slider('value', currentTime);
}
};
VideoProgressSlider.prototype.onSlide = function(event, ui) {
this.frozen = true;
this.updateTooltip(ui.value);
return $(this.player).trigger('seek', ui.value);
};
VideoProgressSlider.prototype.onChange = function(event, ui) {
return this.updateTooltip(ui.value);
};
VideoProgressSlider.prototype.onStop = function(event, ui) {
var _this = this;
this.frozen = true;
$(this.player).trigger('seek', ui.value);
return setTimeout((function() {
return _this.frozen = false;
}), 200);
};
VideoProgressSlider.prototype.updateTooltip = function(value) {
return this.handle.qtip('option', 'content.text', "" + (Time.format(value)));
};
return VideoProgressSlider;
})();
}).call(this);
// Generated by CoffeeScript 1.3.3
(function() {
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
this.VideoSpeedControl = (function() {
function VideoSpeedControl(player, speeds) {
this.player = player;
this.speeds = speeds;
this.onSpeedChange = __bind(this.onSpeedChange, this);
this.changeVideoSpeed = __bind(this.changeVideoSpeed, this);
this.render();
this.bind();
}
VideoSpeedControl.prototype.$ = function(selector) {
return this.player.$(selector);
};
VideoSpeedControl.prototype.bind = function() {
$(this.player).bind('speedChange', this.onSpeedChange);
this.$('.video_speeds a').click(this.changeVideoSpeed);
if (onTouchBasedDevice()) {
return this.$('.speeds').click(function() {
return $(this).toggleClass('open');
});
} else {
this.$('.speeds').mouseenter(function() {
return $(this).addClass('open');
});
this.$('.speeds').mouseleave(function() {
return $(this).removeClass('open');
});
return this.$('.speeds').click(function(event) {
event.preventDefault();
return $(this).removeClass('open');
});
}
};
VideoSpeedControl.prototype.render = function() {
var _this = this;
this.$('.secondary-controls').prepend("<div class=\"speeds\">\n <a href=\"#\">\n <h3>Speed</h3>\n <p class=\"active\"></p>\n </a>\n <ol class=\"video_speeds\"></ol>\n</div>");
$.each(this.speeds, function(index, speed) {
var link;
link = $('<a>').attr({
href: "#"
}).html("" + speed + "x");
return _this.$('.video_speeds').prepend($('<li>').attr('data-speed', speed).html(link));
});
return this.setSpeed(this.player.currentSpeed());
};
VideoSpeedControl.prototype.changeVideoSpeed = function(event) {
event.preventDefault();
if (!$(event.target).parent().hasClass('active')) {
return $(this.player).trigger('speedChange', $(event.target).parent().data('speed'));
}
};
VideoSpeedControl.prototype.onSpeedChange = function(event, speed) {
return this.setSpeed(parseFloat(speed).toFixed(2).replace(/\.00$/, '.0'));
};
VideoSpeedControl.prototype.setSpeed = function(speed) {
this.$('.video_speeds li').removeClass('active');
this.$(".video_speeds li[data-speed='" + speed + "']").addClass('active');
return this.$('.speeds p.active').html("" + speed + "x");
};
return VideoSpeedControl;
})();
}).call(this);
// Generated by CoffeeScript 1.3.3
(function() {
this.Navigation = (function() {
function Navigation() {
var active;
if ($('#accordion').length) {
active = $('#accordion ul:has(li.active)').index('#accordion ul');
$('#accordion').bind('accordionchange', this.log).accordion({
active: active >= 0 ? active : 1,
header: 'h3',
autoHeight: false
});
$('#open_close_accordion a').click(this.toggle);
$('#accordion').show();
}
}
Navigation.prototype.log = function(event, ui) {
return log_event('accordion', {
newheader: ui.newHeader.text(),
oldheader: ui.oldHeader.text()
});
};
Navigation.prototype.toggle = function() {
return $('.course-wrapper').toggleClass('closed');
};
return Navigation;
})();
}).call(this);
// Generated by CoffeeScript 1.3.3
(function() {
this.Time = (function() {
function Time() {}
Time.format = function(time) {
var hours, minutes, pad, seconds;
pad = function(number) {
if (number < 10) {
return "0" + number;
} else {
return number;
}
};
seconds = Math.floor(time);
minutes = Math.floor(seconds / 60);
hours = Math.floor(minutes / 60);
seconds = seconds % 60;
minutes = minutes % 60;
if (hours) {
return "" + hours + ":" + (pad(minutes)) + ":" + (pad(seconds % 60));
} else {
return "" + minutes + ":" + (pad(seconds % 60));
}
};
Time.convert = function(time, oldSpeed, newSpeed) {
return (time * oldSpeed / newSpeed).toFixed(3);
};
return Time;
})();
}).call(this);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment