lptest
by Warspawn
JavaScript
/**
* lessonPlayer.js
* the main lesson player application
**/
var stateArgs = {};
var oldStateArgs = {};
var previewOn = false;
var modalState = 'closed';
var previewImages = [];
var lessonPlayer = lessonPlayer || {};
var onHashChange = function(e) {
debug.warn("HASH CHANGE!", arguments);
// read the parameters
var params = e.getState(true);
debug.log("PARAMS:", params);
var searchFacets = {};
$.each(oleApp.validFacets, function(i, facet) {
searchFacets[facet] = $.bbq.getState(facet);
});
debug.log("current searchFacets", searchFacets);
stateArgs = {
facets: searchFacets
};
};
// main entry point
var launchLessonPlayer = function(lessonData) {
// watch for hashchange
$(window).bind("hashchange", onHashChange);
// initial data passed in from server
lessonData = lessonData || {};
// insert instructions into contentItems
if (lessonData.instruction != '') {
var instructions = fluid.copy(lessonData.contentItems[0]);
instructions.attachments = []; //clear out the attachments so that the remote/sco overrides don't kick in
instructions.fileType = "instructions";
instructions.title = "Instructions";
instructions.text = lessonData.instruction;
instructions.teacherOnly = "false";
lessonData.contentItems.unshift(instructions);
}
debug.log("LESSON DATA IS WHAT WE IS CHECKIN!", lessonData);
// add the lesson title and description to the info box
$.tmpl('lp-lessonInfo', lessonData).appendTo('#infoBox');
// adjust the height of the infoBox description based on the height of the title element
$('#infoBox .description').css('height', 105 - $('#infoBox .title').height() + 'px');
// add the top navigation bar
$.tmpl('lp-topNav').appendTo('#topNav');
// grab the total number of items
var totalItems = lessonData.contentItems.length;
// render pageTools for the topNav
oleApp.topNav =...