var Player_subtype = Player_manuscript_type.extend({
//cfg_removeRawHtmlDivs: "on",
//cfg_displayImagesInSuppHtml: "on",
//cfg_suppWinWidth: 600,
//cfg_Figures_targetDefault: "_blank",
//cfg_Figures_resizeDivWidth: "off",
cfg_Figures_autoHtml: "on",
//cfg_LH_externalTargetDefault: "_pop",
//cfg_LH_internalTargetDefault: "_pop",
//cfg_LH_ebookTargetDefault: "_pop",
//cfg_LH_imageTargetDefault: "_blank",
cfg_LH_autoHtml: "on",
cfg_LH_useLinksFile: "on",
//cfg_Glossary_hoverTerms: "on",
cfg_LH_useOpenContent: "on",
initialize_sections: function() {
// Do not delete this
this._super();
// Anything that needs to be done before the page displays
// should be done here.
//Replace [] tags with <> tags in chapter titles
$('[data-block_type="chap_num"] h3[data-type="title"]').each(function () {
$(this).html($(this).html().replace(/\[([^\]]+)\](.*?)\[\/([^\]]+)\]/g, '<$1>$2$3>'));
});
//Replace [] tags with <> tags in section titles
$('h2.section-title span[data-type="title"]').each(function () {
$(this).html($(this).html().replace(/\[([^\]]+)\](.*?)\[\/([^\]]+)\]/g, '<$1>$2$3>'));
$(this).html($(this).html().replace(/\[([^\]]+)\]/g, '<$1>'));
});
//Replace [] tags with <> tags in titles within sections array
for (var i = 0; i < player.sections.length; ++i) {
if (player.sections[i].title !== null) {
player.sections[i].title = player.sections[i].title.replace(/\[([^\]]+)\](.*?)\[\/([^\]]+)\]/g, '<$1>$2$3>');
player.sections[i].title = player.sections[i].title.replace(/\[([^\]]+)\]/g, '<$1>');
}
}
//Replace [] tags with <> tags in toolbox titles
$('[data-block_type="toolbox"] h3[data-type="title"]').each(function () {
$(this).html($(this).html().replace(/\[([^\]]+)\](.*?)\[\/([^\]]+)\]/g, '<$1>$2$3>'));
});
//Replace [] tags with <> tags in what if titles
$('[data-block_type="what_if"] h3[data-type="title"]').each(function () {
$(this).html($(this).html().replace(/\[([^\]]+)\](.*?)\[\/([^\]]+)\]/g, '<$1>$2$3>'));
});
//Hide extra Margin Question titles
$("h3:contains('Margin Question')").next().each(function () {
$(this).find('h3').hide();
});
//Change color of Summary of Key Ideas heading
$('span[data-type="title"]:contains("Summary of Key Ideas")').css("color", "#000099");
//Change color of Key Terms for Review heading
$('span[data-type="title"]:contains("Key Terms for Review")').css("color", "#000099");
//Hide EOC question titles
$('h2.section-title').has('span[data-type="title"]:contains("Key Terms for Review")').siblings('[data-block_type="exercises"]').each(function () {
$(this).find('[data-type="question"] h3').hide();
});
//Prepend each eoc question with number found in data-question_index attr (bolded), moving the asterisk to before number when applicable
$('h2.section-title').has('span[data-type="title"]:contains("Key Terms for Review")').siblings('[data-block_type="exercises"]').each(function () {
$(this).find('[data-type="question"]').each(function () {
if ($(this).find('p').first().html().match(/^\* ?/)) {
$(this).find('p').first().html($(this).find('p').first().html().replace(/^\* ?/, ''));
$(this).find('p').first().html("*" + $(this).attr("data-question_index") + ". " + $(this).find('p').first().html());
} else {
$(this).find('p').first().html("" + $(this).attr("data-question_index") + ". " + $(this).find('p').first().html());
}
});
});
//Change data-block_type to margin-questions for margin questions
$('[data-block_type="exercises"]').has("h3:contains('Margin Question')").attr("data-block_type", "margin-questions");
//Change data-block_type for EOC question subheads for stylizing with css
$('h2.section-title').has('span[data-type="title"]:contains("Key Terms for Review")').siblings().each(function () {
if ($(this).attr("data-block_type") != "what_if") {
$(this).find('span[data-block_type="subhead"]').attr("data-block_type", "eoc-subhead");
}
});
// Dropcap 1st letter of what if boxes on key terms page
$('h2.section-title').has('span[data-type="title"]:contains("Key Terms for Review")').siblings('[data-block_type="what_if"]').addClass("eoc");
//Remove bottom margin from p tags that contain eoc-subheads
$('p').has('span[data-block_type="eoc-subhead"]').css("margin", "0");
//Move table titles and numbers to above the actual table
$('div[data-type="table"]').each(function () {
table_num = $(this).find('span[data-type="number"]').text().replace(/: /, '');
$(this).find('span[data-type="number"]').remove();
table_text = $(this).find('div[data-type="table_text"]').html();
if (table_text) {
$(this).html(table_text + $(this).html());
}
$(this).find('div[data-type="table_text"]').html('');
if (table_num && table_num != 'Table ') {
$(this).before('
' + table_num + '
');
}
});
//Insert title div before "what if" box
$('div[data-block_type="what_if"]').before('WHAT IF...
');
//Remove extraneous "WHAT IF...: " in what if title within box
$('div[data-block_type="what_if"] h3').each(function () {
$(this).html($(this).html().replace(/^WHAT IF…: /, ''));
});
//Insert title span before "insight" box
$('div[data-block_type="insight"]').before('Insight Into Science
');
//Remove extraneous "Insight Into Science: " in what if title within box
$('div[data-block_type="insight"] h3').each(function () {
$(this).html($(this).html().replace(/^Insight Into Science: /, ''));
});
//Make sure Starry Night is correct color
$("strong:contains('Starry Night')").each(function () {
if ($(this).text().match(/™/) || $(this).html().match(/Starry/)) {
$(this).css("color", "#5DA4A5");
}
});
$('em strong:contains("Starry Night")').css("color", "#5DA4A5");
//Get rid of colon in figure numbers
$('div[data-type="figure_text"] span[data-type="number"]').each(function () {
$(this).html($(this).html().replace(/:/, ' '));
});
//Make animation icons linkable
$("img[src*='/animation']").each(function () {
animation_alias = $(this).attr('src').match(/animation\d+_\d+\.jpg/);
$(this).attr("data-href", "alias:" + animation_alias);
$(this).attr("data-target", "_pop");
});
//Make video icons linkable
$("img[src*='/video']").each(function () {
video_alias = $(this).attr('src').match(/video\d+[-_]\d+\.jpg/);
$(this).attr("data-href", "alias:" + video_alias);
$(this).attr("data-target", "_pop");
});
//Auto-link chapter references
$('p:contains("Chapter ")').each(function () {
$(this).html($(this).html().replace(/Chapter (\d+)/g, '$&'));
});
//Auto-link section references
$('p:contains("Section ")').each(function () {
$(this).html($(this).html().replace(/Section \d+-\d+/g, '$&'));
});
//Auto-link Astronomer's Toolboxes xrefs
$('strong:contains("Toolbox ")').each(function () {
toolbox_alias = $(this).html().match(/Toolbox \d+-\d+/);
if (toolbox_alias) {
$(this).wrap('');
}
});
//Auto-link Guided Discovery box xrefs
$('strong:contains("Guided Discovery")').each(function () {
guided_alias = $(this).text().replace(/[’–]/g, '');
safe_log('guided alias found: ' + guided_alias);
if (guided_alias) {
$(this).wrap('');
}
});
//Link "see Figure #-#" instnces
$('p:contains("see Figure")').each(function () {
$(this).html($(this).html().replace(/see Figure (\d+)-(\d+)[a-z]?\,?\ ?\-?[a-z]?/g, function (match, chap, figNum, offset, s) {
var chapOut, figNumOut;
if (chap < 10) {
chapOut = '0' + chap;
} else {
chapOut = chap;
}
if (figNum < 10) {
figNumOut = '0' + figNum;
} else {
figNumOut = figNum;
}
return '' + match + '';
}));
});
}, // end initialize_sections
initialize: function(id) {
// Do not delete this
this._super(id);
this.xrefs = new XRefs_manuscript_subtype();
this.glossary = new Glossary_manuscript_subtype();
this.figures = new Figures_manuscript_subtype();
}, // end initialize
initialize2: function() {
// Do not delete this
this._super();
var link_handler = new LinkHandler();
// Anything that can be done after the page displays
// should be done here.
// Show all sections within certain pages
if (document.location.href.indexOf('dtu10e_ch7_5.html') > -1 || document.location.href.indexOf('dtu10e_ch9_2.html') > -1 || document.location.href.indexOf('dtu10e_ch9_4.html') > -1) {
$('[data-type="section"]').each(function () {
$(this).css("border-bottom", "0");
$(this).css("padding-bottom", "0");
});
player.show_all_sections();
}
// Change level 2 & 3 sections to 1 & 2, respectively, in Preface, and show all sections
if (document.location.href.indexOf('dtu10e_fm1_4.html') > -1) {
$('div[data-type="section"][level="2"]').attr("level", "1");
$('div[data-type="section"][level="3"]').attr("level", "2");
$('[data-type="section"]').each(function () {
$(this).css("border-bottom", "0");
$(this).css("padding-bottom", "0");
});
player.show_all_sections();
}
//Expand to first section for this page (14-7)
if (document.location.href.indexOf('dtu10e_ch14_4.html') > -1) {
$('#digfir_section_0').css("border-bottom", "0");
$('#digfir_section_0').css("padding-bottom", "0");
$('#digfir_section_0').addClass("singlepage");
$(".rightnav_page").filter("[section_index=1]").html(player.rightnav_page_off_showing_html);
$('#digfir_section_1').show();
player.last_section_showing = 1;
}
// set up page links for PX -BB
$('a').each(function() {
var $this = $(this);
var href = $this.attr('href');
var href_match = href.match(/dtu10e_ch(\d+)_(\d+).html/);
if (href_match !== null) {
if (href_match[1] != "19" || href_match[2] == "1") {
$this.attr('data-href-px', "dtu10e_" + href_match[1] + "_" + href_match[2]);
}
}
});
} // end initialize2
}); // end Player_subtype
// Do not delete this
player = new Player_subtype();