/* bh9e */
/**************************************
Set this to the DF book ID (Subtype)
**************************************/
xBookUtils.bookID = "bh9e";
/*
You only need to set the disciplines if you are using the HTML Quiz
question delivery method, which only BSM ebooks are at this time
(in other words, if this is a FW ebook then you don't need to do a thing).
Change the zeros to the discipline number for each tier on PX.
Discipline numbers:
History: 6696 (all tiers)
Composition: 6698 (all tiers)
Communication: 6700 (all tiers)
*/
xBookUtils.discipline = {
dev: 6698,
qa: 6698,
pr: 6698,
www: 6698
}
var Player_subtype = Player_manuscript_type.extend({
initialize_sections: function() {
this._super();
this.glossary = new Glossary_manuscript_subtype({terms: false});
// This is where you will do most of your DOM manipulation.
// Anything here gets done before the browser displays the
// page. Anything that doesn't need to be done early should
// probably be done in initialize2.
//Moving the box title out of the "inner" element
$("[data-type='box']").each(function(index, element) {
var $jq = $(element);
var element = $jq.find("h3:first").detach();
$jq.prepend(element);
if ($jq.data('block_type') === "mn3" || $jq.data('block_type') === "mn3b" ||$jq.data('block_type') === "bx2") {
var element2 = $jq.find("[data-block_type='bx_v1_h1']:first").detach();
$(element).after(element2);
}
var box_title = $jq.find('h3[data-type="title"]').html();
if (box_title.match(/#/)) {
box_title = box_title.replace(/#(.*?)#/g, '<$1>');
$jq.find('h3[data-type="title"]:first').html(box_title);
}
if (box_title.match(/THE COMMENT/)) {
var text = box_title.match(/THE COMMENT:\s(.*?)$/);
var new_text = "THE COMMENT: " + text[1] + "";
$jq.find('h3[data-type="title"]').html(new_text);
//Adding a class to the figure on these pages for styling
$jq.find('[data-type="figure"]').addClass("tc_fig");
} else if (box_title.match(/Directory to MLA/)) {
var new_text = box_title.replace(/(MLA\s[^\s]+\s[^\s]+)\s/, "$1 ");
$jq.find('h3[data-type="title"]').html(new_text);
} else if (box_title.match(/Directory to APA/)) {
var new_text = box_title.replace(/(APA\s[^\s]+\s[^\s]+)\s/, "$1 ");
$jq.find('h3[data-type="title"]').html(new_text);
}
});
/*
//Adding IDs to the body tags
var curr_url = xBookUtils.getPageUrl();
var secId = curr_url.match(/([^\/]+)$/);
secId = secId[1];
var new_secId = secId.match(/_([^\.]+)\.html/);
new_secId = new_secId[1];
$('body').attr('id', new_secId);
*/
//adding a class to the body tags to style pages that don't have questions
if ($('[data-type="question"]').length === 0) {
$('body').addClass('no_ques');
}
//Moving the figure captions to above the images and adding the asset directory to the altsrc
$('[data-type="figure"]').each(function(index, element) {
if ($(element).attr('id') === "bh9e-ch05-figure-1" || $(element).attr('id') === "bh9e-ch05-figure-2" || $(element).attr('id') === "bh9e-ch06-figure-2" || $(element).attr('id') === "bh9e-ch43-figure-1" || $(element).attr('id') === "bh9e-ch43-figure-2" || $(element).attr('id') === "bh9e-fm01-figure-1" || $(element).attr('id') === 'bh9e-fm01-figure-3' || $(element).attr('id') === 'bh9e-ch50-figure-3' || $(element).attr('id') === 'bh9e-ch52-figure-3' || $(element).attr('id') === 'bh9e-ch52-figure-4' || $(element).attr('id') === 'App04-fig-002' || $(element).attr('id') === 'App04-fig-003') {
return true;
}
var $jq = $(element);
var cap = $jq.find('[data-type="figure_text"]').detach();
$jq.prepend(cap);
var altsrc = $(element).attr('data-altsrc');
if (altsrc.match(/asset/)) {
return true;
} else {
altsrc = "asset/" + altsrc;
$(element).attr('data-altsrc', altsrc);
}
});
/* hack to get figure ids */
$('div[data-figure-id]').each(function(index, element) {
var jq = $(element);
jq.attr('id', jq.data('figure-id'));
});
if ($('[data-type="question"]').length > 0) {
var text = $('[data-type="question"] h3').text().replace(/question/ig, "");
$('[data-type="question"] h3').text(text);
}
var sec_title = $('h2 [data-type="title"]').text();
if ($('.sec_head').length === 0 && $('.chap_head').length === 0 && $('.part_head').length === 0 && $('.wg_head').length === 0 && $('[data-block_type="x_ins"]').length === 0 && $('[data-block_type="mn2"]').length === 0 && $('[data-block_type="x_n_t"]').length === 0 && $('[data-block_type="tc_box"]').length === 0 && ('[data-block_type="mn11"]').length === 0) {
$('h2 [data-type="title"]').addClass('show');
}
if (sec_title.match(/Chicago/)) {
sec_title = sec_title.replace("Chicago", "Chicago");
$('h2 [data-type="title"]').html(sec_title);
}
/*
//Creating the "printed page" box (They decided they don't want this anymore)
var curr_pageId = $('[id^="page"]:first').attr('id');
var curr_page = curr_pageId.match(/page-(.*?)$/);
$('[id^="page"]:first').addClass("ppage");
$('.ppage').text("Printed Page " + curr_page[1]);
*/
/*
var box_title = $('h3[data-type="title"]').html();
if ($('[data-block_type="tc_box"]').length > 0) {
if (box_title.match(/THE COMMENT/)) {
var text = box_title.match(/THE COMMENT:\s(.*?)$/);
var new_text = "THE COMMENT: " + text[1] + "";
$('h3[data-type="title"]').html(new_text);
//Adding a class to the figure on these pages for styling
$('[data-type="figure"]').addClass("tc_fig");
} else if (box_title.match(/Directory to MLA/)) {
var new_text = box_title.replace(/MLA in-text citation/, "MLA in-text citation");
$('h3[data-type="title"]').html(new_text);
}
}
if ($('[data-type="box"]').length > 0) {
$('[data-type="box"]').each(function(index, element) {
var $jq = $(element);
var box_title = $jq.find('h3[data-type="title"]').html();
if (box_title.match(/#/)) {
box_title = box_title.replace(/#(.*?)#/g, '<$1>');
$jq.find('h3[data-type="title"]').html(box_title);
}
});
}
*/
//Adding a class to the tag for styling on Writing Guides
if ($('.wg_title').length > 0) {
$('[data-type="section"]').addClass("writ_guide");
}
//Adding a class to the tag for styling on Becoming a College Writer and wrapping a box around the whole feature
if ($('[data-block_type="mn2"]').length > 0) {
$('[data-type="section"]').addClass("bacw");
$('[data-block_type="mn2"]').wrap("");
}
if ($('.part_head').length > 0) {
$('[data-type="section"]').addClass("part");
}
},
initialize: function(id) {
this._super(id);
this.xrefs = new XRefs_manuscript_subtype();
this.glossary = new Glossary_manuscript_subtype({terms: false});
this.figures = new Figures_manuscript_subtype({autoHtml: false
});
},
initialize2: function() {
this._super();
// This should be used for everything that doesn't need to be
// done before the page displays.
var link_handler = new LinkHandler;
}
});
function adjustFigBorders() {
$('[data-type="figure"], [data-block_type^="map"]').each(function(index, element) {
var jq = $(element);
var ijq = $("[data-mmtype]", jq); // the figure's main image will have a mmtype tag
var width = ijq.width();
// If we can't get the image width yet then just go with the defaults
if (width > 0) {
jq.css("width", width + "px");
}
else {
}
});
}
// NEVER delete this
player = new Player_subtype();