(function ($) { $.fn.changeElementType = function (newType) { var attrs = {}; $.each(this[0].attributes, function (idx, attr) { attrs[attr.nodeName] = attr.nodeValue; }); this.replaceWith(function () { return $("<" + newType + "/>", attrs).append($(this).contents()); }); }; })(jQuery); $('#manuscript').append('
'); function handleTextResize(event, args) { /* console.log('caught text resize event'); console.log(event); console.log(args); */ resizeIframe(); } function resizeIframe() { var $iframeDiv = $('[data-figure_iframe="true"]'); if ($iframeDiv.length < 1) { return; } var $iframe = $iframeDiv.children('iframe'); if ($iframe.length < 1) { return; } var iframeContentHeight = calculateFigureIframeHeight($iframe); if (iframeContentHeight > 0) { //console.log('resizeIframe: setting iframe height to ' + iframeContentHeight); $iframeDiv.css('height', iframeContentHeight + 'px'); $iframe.attr('height', iframeContentHeight); } } function calculateFigureIframeHeight($iframe) { return $iframe.contents().find('#data-visualization-activities').height(); } function initTextResize() { //console.log('initTextResize'); TextResizeDetector.addEventListener(handleTextResize, null); } //id of element to check for and insert control TextResizeDetector.TARGET_ELEMENT_ID = 'text_resize'; //function to call once TextResizeDetector has init'd TextResizeDetector.USER_INIT_FUNC = initTextResize; $('div[data-type="question"]').each(function () { $(this).hide(); }); $('div[data-block_type="paragraph_left"]').each(function () { $(this).hide(); }); var g2dContainer, currentG2DContainerHeight, descriptionParams = { flag: false, height: 315 }; var iframeContainer, currentIfameContanerHeight; function alignVisibleChoicesCells() { var visibleChoices = $('[data-type="question"]:not([style="display: none;"]) .query_mc_choice_table'); var maxVisibleChoiceHeight = Math.max.apply(null, visibleChoices.map(function (index, el) { return $(el).outerHeight(); })); visibleChoices.css('height', maxVisibleChoiceHeight + 'px'); } function alignSubmitBtnByLastChoice() { var visibleQuestion = $('[data-type="question"]:not([style="display: none;"])'); var checkboxTable = visibleQuestion.find('div[data-type="table"] table'); var currentlastVisibleChoice = visibleQuestion.find('.query_mc_choice_table').eq(3); var newBattonsNavWidth; if (currentlastVisibleChoice.length) { newBattonsNavWidth = (currentlastVisibleChoice.position().left + currentlastVisibleChoice.outerWidth() + 30); // 30 - choiceMargin $('.buttonsNav').css('width', newBattonsNavWidth + 'px'); } else if (checkboxTable.length) { newBattonsNavWidth = (checkboxTable.position().left + checkboxTable.outerWidth()); $('.buttonsNav').css('width', newBattonsNavWidth + 'px'); } } function customizeVisibleQuestionRadioButtons() { var labels = $('[data-type="question"]:not([style="display: none;"]) label'), inputContaners = $('[data-type="question"]:not([style="display: none;"]) td div'); for (var i = 0; i < labels.length; i++) { labels.eq(i).appendTo(inputContaners.eq(i)); } } var timerFigureonLoad = setInterval(function () { if ($('div[data-type="figure"] iframe').length) { clearInterval(timerFigureonLoad); var timerFigureonContentLoad = setInterval(function () { var iframeBody = $('div[data-type="figure"] iframe')[0].contentWindow.document.body; if ($(iframeBody).find('#btnLongDescription').length) { clearInterval(timerFigureonContentLoad); var iframeDiv = $('div[data-type="figure"] iframe'); var $iframeBody = $(iframeDiv[0].contentWindow.document.body); var title = $('h1'); $(iframeDiv).attr('aria-label', title.html()); $(iframeDiv).attr('title', title.html()); //fix issue with focusable iframe's body element for IE and Firefox var G2DBoxElement = iframeBody.querySelector('div.G2Dbox'); var navBackButton = $(".button_back"); G2DBoxElement.addEventListener('keydown', function (event) { if (event.shiftKey && event.keyCode == 9) { event.preventDefault(); setTimeout(function () { navBackButton.focus(); }, 100); } }); navBackButton.bind('keydown', function (event) { if (!event.shiftKey && event.keyCode == 9) { event.preventDefault(); setTimeout(function () { G2DBoxElement.focus(); }, 100); } }); //fix issue with double reading of fieldset legend on Mac VoiceOver; //legend have attribute aria-hidden. We update aria-live element when query get focus if (platform.mac) { var $ariaLiveElement = $iframeBody.find('#activeDescription'); var $descriptionButton = $iframeBody.find('#btnLongDescription'); var $submitButtons = $('.question_submit_button'); $descriptionButton.bind('keydown', function (event) { if (event.keyCode == 9) { setTimeout(updateAriaLive, 100); } }); $submitButtons.each(function () { $(this).bind('keydown', function (event) { if (event.shiftKey && event.keyCode == 9) { setTimeout(updateAriaLive, 100); } }); }); $('fieldset').each(function () { $(this).bind('focusout', function (e) { $ariaLiveElement.html(' '); }); }); function updateAriaLive() { var $activeQuestionLegend = $('legend:visible'); var radio = document.activeElement; var activeRadioDescription = $(radio).next().text(); $ariaLiveElement.text($activeQuestionLegend.text() + activeRadioDescription + (radio.checked ? '. Selected' : '') + ', radio button'); } } $('title')[0].innerHTML = title[0].innerHTML; //$(iframeDiv[0]).attr('role', 'none'); $("strong").replaceWith(function (index, oldHTML) { return $("