//=========================================================================== // Detect platform with https://github.com/bestiejs/platform.js var iOS = platform.os.family === 'iOS'; //detect iOS (VoiceOver) var isAndroid = platform.os.family === 'Android'; //detect Android (TalkBack) var isFirefox = platform.name === 'Firefox'; //detect Firefox (NVDA) var isIE = platform.name === 'IE'; //detect IE (Jaws) console.info('System configuration:', platform); //=========================================================================== // Syntactic sugar for aria-live element ------------------------------------ function liveMessage(msg) { setTimeout(function () { $('#liveFeedback').text(msg) }, 400); } //--------------------------------------------------------------------------- if (isIE) { //prevents focusing on the body in the IE document.body.setAttribute('tabindex', '-1'); } /*************************************************************************** * Extending and overriding DigFir default classes * * player.js * query_types.js * html_quiz.js * utilities.js ***************************************************************************/ /** * Defines in js/player.js */ Figures = Figures.extend({ process_media: function () { // we're not currently using this (jwplayer is not being included) $("[data-mmtype='mp3']").each(function (index, element) { var jq = $(element); var id = jq.attr("data-figure-id"); var mmsrc = jq.attr("data-mmsrc"); // http://www.longtailvideo.com/jw/upload/bunny.mp3 // http://www.youtube.com/embed/CsGYh8AacgY var src = jq.attr("src"); var attr = jq.attr("data-attr"); if (attr == null) { attr = ""; } attr = attr.split(/\s*,\s*/); var params = new Object(); params.width = jq.width(); params.height = jq.height() + 24; // 24 is for the controler at the bottom params.file = mmsrc; params.image = src; params.controlbar = "bottom"; params.screencolor = "ffffff"; params["viral.allowmenu"] = "false"; params["viral.onpause"] = "false"; params["viral.oncomplete"] = "false"; // determine url of flashplayer based on whether we're published or not if (UI_Elements.in_preview_mode()) { params.flashplayer = "/js/preview/player.swf"; } else { params.flashplayer = "js/player.swf"; } safe_log(params.flashplayer); for (var i = 0; i < attr.length; ++i) { var a = attr[i].split(/\s*=\s*/); params[a[0]] = a[1]; } jwplayer(id).setup(params); }); //AF: this is less than ideal, but i had to make this a global variable so it can be accessed by the video players when they fire the templateloaded event. // we should look into changing it. videos.templateReady = function (figureObjectID) { var KEY_CODES = { SPACE: 32, ENTER: 13 }; var vidplayer = brightcove.api.getExperience(figureObjectID); var experienceModule = vidplayer.getModule(brightcove.api.modules.APIModules.EXPERIENCE); var playerModule = vidplayer.getModule(brightcove.api.modules.APIModules.VIDEO_PLAYER); var el = document.querySelector("[data-figure-id=" + figureObjectID + "]"); $(el).find('object').attr('aria-hidden', true); el.setAttribute("tabindex", "0"); el.setAttribute("role", "application"); el.setAttribute('aria-label', 'Press enter to start or pause video. Press the transcript button to see the content of the video'); el.addEventListener("keydown", (function (isPlay) { return function (evt) { var keyCode = evt.keyCode || evt.which; if (keyCode === KEY_CODES.SPACE || keyCode === KEY_CODES.ENTER) { if (isPlay) { playerModule.pause(); isPlay = false; return; } playerModule.play(); isPlay = true; } } })(false)); var questionSequence = $("#" + figureObjectID).closest('[data-type="figure"]').nextAll( '[data-block_type="question_sequence"], [data-block_type="question_sequence_one_at_a_time"]'); questionSequence.each(function (index, element) { if ($(element).attr("data-block_type") == "figure") { if ($(element).find(".BrightcoveExperience").size() > 0) { //we have found another video following the current one, so stop return false; } } var questionSequenceIndex = $(element).attr("question_sequence_index"); var questionSequenceMetaData = $(element).find('[data-type="box_inner"]').children( '[data-type="metadata"]').find('[key="cuepoint"]').html(); $(element).hide(); if (questionSequenceMetaData != null) { var cuePointsModule = vidplayer.getModule(brightcove.api.modules.APIModules.CUE_POINTS); var CuePointType = brightcove.api.modules.CuePointsModule.CuePointType; var cuePoints = [{ name: figureObjectID, metadata: questionSequenceIndex, time: questionSequenceMetaData, type: CuePointType.CODE }]; cuePointsModule.addCuePoints(videos[figureObjectID], cuePoints); videos.question_sequence_to_video_map[questionSequenceIndex] = figureObjectID; } }); playerModule.addEventListener(brightcove.api.events.CuePointEvent.CUE, videos.cuePointEvent); }; videos.cuePointEvent = function (e) { //get the player - the name property of the cuePoint is set to the ID of the Brightcove experience //so we can find the player here. var vidplayer = brightcove.api.getExperience(e.cuePoint.name); globalPlayer = brightcove.api.getExperience(e.cuePoint.name); safe_log("got vid player"); var playerModule = vidplayer.getModule(brightcove.api.modules.APIModules.VIDEO_PLAYER); safe_log("got module"); playerModule.pause(true); safe_log("paused"); player.show_question_sequence(e.cuePoint.metadata, false); }; $("[data-mmtype='mov']").each(function (index, element) { var jq = $(element); var id = jq.attr("data-figure-id"); var mmsrc = jq.attr("data-mmsrc"); var src = jq.attr("src"); var attr = jq.attr("data-attr"); if (attr == null) { attr = ""; } attr = attr.split(/\s*,\s*/); var params = new Object(); for (var i = 0; i < attr.length; ++i) { var a = attr[i].split(/\s*=\s*/); params[a[0]] = a[1]; safe_log("added param " + a[0] + ": " + a[1]); } params.autoStart = jq.attr("data-autoplay"); var videoPlayerID = ""; var videoPlayerKey = ""; //if(params.showVideoControls == 'true'){ //AF: This is the video player with playback controls. We are only using this one for right now. videoPlayerID = "1513003547001"; if (jq.attr("data-playerid")) { videoPlayerID = jq.attr("data-playerid"); } videoPlayerKey = "AQ~~,AAABXVHBMdE~,bnY9CM55Z1MLPZuidy4KYEC_16wi-U8Q"; //}else{ // videoPlayerID = "1504927982001"; // videoPlayerKey = "AQ~~,AAABXVHBMdE~,bnY9CM55Z1PiqOYprq-NHmUPG2yKZ4U-"; //} videos[id] = mmsrc; var BCL = {}; BCL.markup = function (html, data) { var m; var i = 0; var match = html.match(data instanceof Array ? /{{\d+}}/g : /{{\w+}}/g) || []; while (m = match[i++]) { html = html.replace(m, data[m.substr(2, m.length - 4)]); } return html; }; videos.templateLoad = function (e) { //AF: For now, we are not using captions. var vidplayer = brightcove.api.getExperience(e); var CuePointType = brightcove.api.modules.CuePointsModule.CuePointType; var modExp = vidplayer.getModule(brightcove.api.modules.APIModules.EXPERIENCE); modExp.addEventListener(brightcove.api.events.ExperienceEvent.TEMPLATE_READY, function (evt) { videos.templateReady(e); }); //captionsModule.loadDFXP(player.md.video_caption_url + videos[e] + ".xml", videos[e]); //if needed, we can use these events to trigger code upon the success or error of loading captions. //if there is an error, it fails silently and just doesn't show captions. //captionsModule.addEventListener(brightcove.api.events.CaptionsEvent.DFXP_LOAD_SUCCESS, onDFXPLoadSuccess); //captionsModule.addEventListener(brightcove.api.events.CaptionsEvent.DFXP_LOAD_ERROR, onDFXPLoadError); }; BCL.playerData = { "playerID": videoPlayerID, "playerKey": videoPlayerKey, "width": jq.width(), "height": jq.height(), "videoID": mmsrc, "autoStart": params.autoStart }; BCL.playerTemplate = "
"; console.log(BCL.playerTemplate); var playerHTML = ""; playerHTML = BCL.markup(BCL.playerTemplate, BCL.playerData); //replaces placeholders with values jq.replaceWith(playerHTML); brightcove.createExperiences(); }); } }); /** * Defines in js/player.js */ var Activity_Mediaculture = Activity.extend({ update_question_action_div: function (question_index) { var question = this.questions[question_index]; // calculate points_awarded and points_possible var points_awarded = 0; var points_possible = 0; var points_provisional = false; for (var i = 0; i < question.queries.length; ++i) { var query = question.queries[i]; points_awarded += query.getPointsAwarded(); points_possible += query.getPointsPossible(); if (query.pointsAreProvisional() == true) { points_provisional = true; } } // round to at most two decimal places points_awarded = Math.round(points_awarded * 100) / 100; points_possible = Math.round(points_possible * 100) / 100; // hide submit button (and any other similar buttons that might be added by subtypes), but show points earned var $questionActionDiv = $("#question_action_div_" + question.index); $questionActionDiv.find(".question_submit_button").hide(); var $points = $('').text('Select a slide to view it. Note: Grey slides are not accessible until preceding slides have been viewed or completed.') ); var $menuList = $('
" + qt + "
" } else { return ""; } }, getHTML: function (mode) { // start with the query text, if there var html = this.query_text_html(); var val, disabled; if (!this.userHasAnswered() || mode == 'preview') { val = ""; disabled = ""; // otherwise we have an answer, so fill it in } else { // make sure we convert double quotes to " for placement in 'value="xxx"' attributes val = this.user_answer; // convert breaks to newlines val = val.replace(/