/* ew5e */
xBookUtils.bookID = "ew5e";
xBookUtils.discipline = {
dev: 6698,
qa: 6698,
pr: 6698,
www: 6698
}
var Player_subtype = Player_manuscript_type.extend({
cfg_LH_useOpenContent: "on",
cfg_LH_useLinksFile: "on",
initialize_sections: function() {
this._super();
// 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.
/* hack to get figure ids */
$('div[data-figure-id]').each(function(index, element) {
var jq = $(element);
jq.attr('id', jq.data('figure-id'));
});
/* hack to add img ids */
$('img').each(function(index, element) {
var img = $(element);
//safe_log(img);
img.attr('id', img.data('figure-id'));
});
//Adding IDs to the body tags
//var curr_url = xBookUtilGetPageUrl();
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 IDs to tables
if ($('[data-type="table"]').length > 0) {
var tableIdNum = 1;
$('[data-type="table"]').each(function() {
$(this).attr('id', 'tbl-' + tableIdNum++);
});
}
//Styling for the Tables
if ($('[data-type="table"]').length > 0) {
$('[data-type="table"] tr:nth-child(even)').addClass('even_row');
$('[data-type="table"] tr:nth-child(odd)').addClass('odd_row');
$('[data-type="table"] tr:nth-child(1)').removeClass('odd_row');
$('[data-type="table"] tr:nth-child(1)').addClass('head_row');
$('[data-type="table"] tr td').addClass("text_top");
$('[data-type="table"] tr:nth-child(1) td').removeClass('text_top');
$('[data-type="table"] tr:nth-child(1) td').addClass('text_bottom');
}
//HEADERS
var chap_head = 0; //First page in a chapter
var part = 0; //Part
var chap_reg = 0; //Regular chapter page
//var full_url = xBookUtilGetPageUrl();
var full_url = xBookUtils.getPageUrl();
var sec_url = full_url.match(/\/ew5e_([^\/]+)\.html/);
sec_url = sec_url[1];
var html_temp = $('[data-type="section"]').html();
html_temp = html_temp.replace(/\n/g, '__n__');
var title = $('h2 [data-type="title"]').html();
if (sec_url.match(/^ch/)) {
if (sec_url.match(/_1$/)) {
chap_head = 1;
part = 0;
chap_reg = 0;
var h2_split = title.match(/^(.*?)\s(.*?)$/);
//var new_text = '
' + h2_split[1] + '
' + h2_split[2] + '
';
var new_text = '
' + h2_split[1] + '
' + h2_split[2] + '
';
//moving the chapter head image above the header if it exists (except for chapter 50, 51)
//safe_log(xBookUtils.getChapter());
if ($('[data-type="figure"]').length > 0 && xBookUtils.getChapter() !== "50" && xBookUtils.getChapter() !== "51") {
$('[data-type="section"]').addClass('chap_intro_fig');
var fig = $('[data-type="figure"]:first').detach();
$('[data-type="section"]').prepend(fig);
}
} else {
//For numbered Sections (16a)
if (title.match(/[0-9]/)) {
chap_head = 0;
part = 0;
chap_reg = 1;
var h2_split = title.match(/^(.*?)\s(.*?)$/);
var new_text = '
' + h2_split[1] + '
' + h2_split[2] + '
';
//All other section titles (Exercise 7.6)
} else {
var new_text = '
' + title + '
';
}
}
} else if (sec_url.match(/^part/)) {
chap_head = 0;
part = 1;
chap_reg = 0;
}
$('h2').html(new_text);
if ($('.secnum').text().match(/EXERCISE/)) {
$('.sechead').css('display', 'none');
}
$(".chaptitle").each(function(index, element) {
var $h2 = $(element);
var h2_text = $h2.text();
h2_text = h2_text.replace(/#(.*?)#/g, "<$1>");
//safe_log("h2_text: " + h2_text);
$h2.html(h2_text);
});
//End Headers
//styling the Parts
if (part) {
//Moving the title below the opening image
var $jq = $('h2').detach();
$('[data-type="figure"]').after($jq);
//wrapping a "part" div around the contents of the page
var $jq2 = $('[data-type="section"]').children();
$($jq2).wrapAll('
');
//popping out the "arrow" question box
var $jq3 = $('[data-block_type="bx6_txt"]').detach();
$('.part').after($jq3);
}
if (part) {
var html = $('h2').html();
if (html.match(/APA, Chicago, and CSE Documentation/i)) {
var new_html = 'APA,Chicago, and CSE Documentation';
$('h2').html(new_html);
}
}
if ($('.sectitle').text().match(/Peer Review:|Revision:/)) {
$('.sectitle').css('display', 'none');
}
//Adding italics to a title in Ch. 34
if (title.match(/34e/)) {
new_text = new_text.replace(/(we|us)/g, "$1");
$('h2').html(new_text);
}
//Removing (VIDEO) from section titles
var title = $('.chaptitle').html();
var title_div = ".chaptitle";
if (!title) {
title = $('.sectitle').html();
title_div = ".sectitle";
}
if (title) {
if (title.match(/VIDEO/)) {
var new_title = title.replace(/\(VIDEO\)/, '');
$(title_div).html(new_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]);
//Removing the word "question" from the questions
if ($('[data-type="question"]').length > 0) {
var text = $('[data-type="question"] h3').text().replace(/question/ig, "");
$('[data-type="question"] h3').text(text);
//fixing styling on lists on "question" pages
/*
$('#manuscript ol').css({
"margin-top": "15px",
"font-family": "sans-serif",
"margin-left": "10px"
});
$('#manuscript ul').css({
"margin-top": "15px",
"font-family": "sans-serif"
});
$('#manuscript ol li, #manuscript ul li').css('margin-bottom', '25px');
//var number = $('[data-question_index]').data();
*/
}
//Adding italics to the word Chicago in some box feature titles
//
CHICAGO SOURCE MAP: Books
if ($('h3').length > 0) {
$('h3').each(function() {
var title = $(this).html();
if (title.match(/Chicago/i)) {
title = title.replace(/(Chicago)/i, '$1<\/em>');
$(this).html(title);
} else {
return true;
}
});
}
if ($('.sectitle').length > 0) {
$('.sectitle').each(function() {
var title = $(this).html();
if (title.match(/Chicago/i)) {
title = title.replace(/(Chicago)/i, '$1<\/em>');
$(this).html(title);
} else {
return true;
}
});
}
if ($('.chaptitle').length > 0) {
$('.chaptitle').each(function() {
var title = $(this).html();
if (title.match(/Chicago/i)) {
title = title.replace(/(Chicago)/i, '$1<\/em>');
$(this).html(title);
} else {
return true;
}
});
}
if ($('[data-block_type="upper_roman"]').length > 0) {
var html_temp = $('[data-type="section"]').html();
html_temp = html_temp.replace(/\n/g, '__n__');
//safe_log(html_temp);
//
Thesis statement
//
$1
0) {
$('[data-block_type="BX_v5"]').each(function() {
var full_text = $(this).html();
var box_title = $(this).find('h3').text();
full_text = full_text.replace(/bx1_h(_va)?/, "box_head");
var title_div = '
' + box_title + '
';
$(this).html(full_text);
$(this).find('[data-block_type="box_head"]').after(title_div);
});
}
//Talking about style
if ($('[data-block_type="BX_v7"]').length > 0) {
$('[data-block_type="BX_v7"]').each(function() {
var full_text = $(this).html();
var box_title = $(this).find('h3').text();
full_text = full_text.replace(/bx1_h/, "box_head");
var title_div = '
' + box_title + '
';
$(this).html(full_text);
$(this).find('[data-block_type="box_head"]').after(title_div);
});
}
//Multilingual
if ($('[data-block_type="BX_v2"]').length > 0) {
$('[data-block_type="BX_v2"]').each(function() {
var full_text = $(this).html();
var box_title = $(this).find('h3').text();
full_text = full_text.replace(/bx2_h/, "box_head");
var title_div = '
' + box_title + '
';
$(this).html(full_text);
$(this).find('[data-block_type="box_head"]').after(title_div);
});
}
//At a Glance
if ($('[data-block_type="BX_v3"]').length > 0) {
$('[data-block_type="BX_v3"]').each(function() {
var full_text = $(this).html();
var box_title = $(this).find('h3').text();
full_text = full_text.replace(/bx4_h/, "box_head");
var title_div = '
' + box_title + '
';
$(this).html(full_text);
$(this).find('[data-block_type="box_head"]').after(title_div);
});
}
//Considering Disabilities
if ($('[data-block_type="BX_v4"]').length > 0) {
$('[data-block_type="BX_v4"]').each(function() {
var full_text = $(this).html();
var box_title = $(this).find('h3').text();
full_text = full_text.replace(/bx3_h/, "box_head");
var title_div = '
' + box_title + '
';
$(this).html(full_text);
$(this).find('[data-block_type="box_head"]').after(title_div);
});
}
//MLA Directory
if ($('[data-block_type="BX_v8"]').length > 0) {
$('[data-block_type="BX_v8"]').each(function() {
var full_text = $(this).html();
var box_title = $(this).find('h3').text();
full_text = full_text.replace(/dir_h1/, "box_head");
//var title_div = '
});
}
//APA Directory
if ($('[data-block_type="BX_v9"]').length > 0) {
$('[data-block_type="BX_v9"]').each(function() {
var full_text = $(this).html();
var box_title = $(this).find('h3').text();
full_text = full_text.replace(/dir_h1/, "box_head");
//var title_div = '
' + box_title + '
';
$(this).html(full_text);
});
}
//Chicago Directory
if ($('[data-block_type="BX_v10"]').length > 0) {
$('[data-block_type="BX_v10"]').each(function() {
var full_text = $(this).html();
var box_title = $(this).find('h3').text();
full_text = full_text.replace(/dir_h1/, "box_head");
//var title_div = '
' + box_title + '
';
$(this).html(full_text);
});
}
//CSE Directory
if ($('[data-block_type="BX_v11"]').length > 0) {
$('[data-block_type="BX_v11"]').each(function() {
var full_text = $(this).html();
var box_title = $(this).find('h3').text();
full_text = full_text.replace(/dir_h1/, "box_head");
//var title_div = '
' + box_title + '
';
$(this).html(full_text);
});
}
//Adding an inner div to the box features for styling
if ($('[data-type="box"]').length > 0) {
$('[data-type="box"]').each(function(index, element) {
//safe_log($(element).data());
if ($(element).data("block_type")) {
if (!$(element).data("block_type").match(/BX/)) {
//safe_log("not a box feature");
return true;
}
var full_html = $(element).html();
full_html = full_html.replace(/\n/g, "__n__");
//safe_log(full_html);
if ($(element).data("block_type").match(/BX_v6/)) {
var inner_text = full_html.match(/
__n__(.*?)$/);
var inner_text_div = '
' + inner_text[1] + '
';
} else if ($(element).data("block_type").match(/BX_v(8|9|10|11)/)) {
//
MLA style for a list of works cited
__n__
var inner_text = full_html.match(/
__n__(.*?)$/);
var inner_text_div = '
' + inner_text[1] + '
';
} else {
var inner_text = full_html.match(/
.*?<\/div>__n__(.*?)$/);
var inner_text_div = '
' + inner_text[1] + '
';
//safe_log(inner_text[1]);
}
full_html = full_html.replace(inner_text[1], inner_text_div);
full_html = full_html.replace(/__n__/g, "\n");
$(element).html(full_html);
}
});
}
if ($('[data-block_type="BX_v7"]').length > 0) {
var title = $('[data-block_type="BX_v7"] [data-block_type="box_title"] p').html();
if (title === "Everyday Use of Be") {
var new_title = "Everyday Use of Be";
$('[data-block_type="BX_v7"] [data-block_type="box_title"] p').html(new_title);
}
}
if ($('h2 [data-type="title"]').length > 0) {
var title = $('h2 [data-type="title"]').html();
if (title === "Answers to Exercises in The Everyday Writer with Exercises") {
new_title = "Answers to Exercises in The Everyday Writer with Exercises";
$('h2 [data-type="title"]').html(new_title);
}
}
/* Adding IDs to the data-block_type="para_text" spans to line up the margin question boxes */
if ($('[data-block_type="para_text"]').length > 0) {
var number = 1;
$('[data-block_type="para_text"]').each(function() {
var id = "pl-" + number;
$(this).attr("id", id);
var tooltip = '';
$('#' + id).wrap(tooltip);
number++;
});
}
if ($('[data-block_type="para_text"]').length > 0) {
$('[data-block_type="para_text"]').click(function() {
var id = $(this).attr("id");
safe_log("id = " + id);
var idNum = id.match(/([0-9]{1,})/);
var index = idNum[1];
$('#tooltip').css('display', 'none');
showMargBox(index);
});
}
if ($('[data-block_type="quest_box"]').length > 0) {
$('div[data-block_type="quest_text"]').before('');
$('[data-block_type="quest_box"]').draggable();
}
},
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();
$(document).bind("procNativePXQuestions", function() {
$('[data-type="question"] a[data-type="lh-link"]').each(function() {
var $this = $(this);
$this.attr('target', '_pop');
});
});
},
initialize2: function() {
this._super();
var link_handler = new LinkHandler();
$('[data-altsrc]').each(function() {
var $this = $(this);
var altsrc = $this.attr('data-altsrc');
if (/^img_ch/.test(altsrc)) {
$this.attr('data-altsrc', "asset/" + altsrc);
}
});
$('[data-type="question"]').each(function() {
//safe_log($(this));
var number = $(this).data('question_index');
//safe_log(number);
if (number > 9) {
//safe_log("greater than 9");
$(this).find('.bh.essay-question div:first-child').css('margin-left', '125px');
}
});
// Add linking info to top of page
if (xBookUtils.inDFWrapper()) {
$('[data-sec-id]').each(function() {
var $this = $(this);
var sec_id = $this.attr('data-sec-id');
$('body').prepend("
LINK ID: #" + sec_id + " all anchors on pageGo to ID:
");
});
$('div, ul, ol').each(function() {
var $this = $(this);
var id = $this.attr('id');
var type = $this.attr('data-type');
if (!xBookUtils.emptyValue(id) && id !== "manuscript") {
if (xBookUtils.emptyValue(type) || type !== "section") {
$this.prepend('' + id + '');
}
}
});
/* catch any