/*lunsford_franchise.js */ xBookUtils.printDebugStatements = "on"; /************************************** Set this to the DF book ID (Subtype) **************************************/ xBookUtils.bookID = "lunsford_franchise"; var ids = {}; var LinkHandler_manuscript = LinkHandler.extend({ fn_popindex: function(href, target, $jqLinkObj, event) { if (event !== undefined) { event.stopImmediatePropagation(); } var supp_win_name = href; // remove hash from href href = href.replace(/#.*/, ""); // If we have a PX ID then we need to convert it back to // the filename if (/^px:/.test(href)) { href = href.replace("px:", ""); // go through xBookUtils.links until we find the ID for (var key in xBookUtils.links) { if (xBookUtils.links[key].px === href) { href = key; break; } } if (!(/^smhandbook8e_ch/.test(href))) { safe_log("fn_popindex: can't find file name for PX ID " + href); return false; } } href = xBookUtils.getBaseUrl() + href; xBookUtils.openSuppWin({url: href, width: "600", name: supp_win_name}); return false; }, /* fn_popindex: function(href, target, $jqLinkObj, event) { if (event !== undefined) { event.stopImmediatePropagation(); } var supp_win_name = href; xBookUtils.openSuppWin({url: href, name: "index"}); return false; } */ }); var Player_subtype = Player_manuscript_type.extend({ cfg_removeRawHtmlDivs: "on", //cfg_showAnswer: "on", //cfg_showAnswerAutoWrapThis: "off", cfg_Box_moveTitle: "all", cfg_Box_moveTitleExclude: "bxqh", cfg_Figures_targetDefault: "_pop", //cfg_Figures_resizeDivWidth: "off", cfg_Figures_autoHtml: "on", cfg_LH_autoHtml: "on", cfg_LH_externalTargetDefault: "_pop", cfg_LH_internalTargetDefault: "_self", //cfg_LH_ebookTargetDefault: "_pop", //cfg_LH_imageTargetDefault: "_blank", cfg_LH_useOpenContent: "on", cfg_LH_useLinksFile: "on", //cfg_Glossary_hoverTerms: "on", //cfg_Glossary_useStickyDiv: "on", //cfg_Glossary_hoverTermsNoClick: "", cfg_pageNumbers: "off", initialize_sections: function() { this._super(); this.xrefs = new XRefs_manuscript_subtype(); this.glossary = new Glossary_manuscript_subtype(); this.figures = new Figures_manuscript_subtype(); // 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')); }); if ($('[data-type="question"]').length > 0) { var text = $('[data-type="question"] h3').text().replace(/question/ig, ""); $('[data-type="question"] h3').text(text); } /* //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]); */ /* Styling for the Talking the Talk boxes */ $('[data-block_type="bx4"]').each(function(index, element) { $jq = $(element); //Fixing the title var title = $jq.find('h3').html(); title = title.replace(/(Talking the Talk)\:\s(.*?)$/i, '$1: $2'); $jq.find('h3').html(title); //Adding the corner images //$jq.prepend(''); //$jq.append(''); }); /* Styling for the Considering Disabilities boxes */ $('[data-block_type="bx4a"]').each(function(index, element) { $jq = $(element); //Fixing the title var title = $jq.find('h3').html(); title = title.replace(/(Considering Disabilities)\:\s(.*?)$/i, '$1: $2'); $jq.find('h3').html(title); //Adding the corner images //$jq.prepend(''); //$jq.append(''); }); /* Styling for the Multilingual boxes */ $('[data-block_type="bx3"]').each(function(index, element) { $jq = $(element); //Fixing the title /* var title = $jq.find('h3').html(); console.log("title = " + title); title = title.replace(/\{(\/)?em\}/g, "<$1em>"); $jq.find('h3').html(title); var img = $jq.find('img'); img.attr('class', 'bxmulti'); $jq.find('h3').before(img); */ //$(".bxmulti, h3").wrapAll('
'); var title = $jq.find('h3').html(); //safe_log("bx3 title: [" + title + "]"); title = $.trim(title); title = title.replace(/(For Multilingual Writers)\:\s(.*?)$/i, '$1: $2'); //safe_log("bx3 title: [" + title + "]"); $jq.find('h3').html(title); //Adding the corner images //$jq.prepend(''); //$jq.append(''); }); /* Styling for Exercise boxes */ $('[data-block_type="bxex"]').each(function() { if ($(this).find('h3').text().match(/^EXERCISE/)) { $(this).prepend(''); } }); /* Styling for Thinking Critically boxes */ $('[data-block_type="bx1"]').each(function() { if ($(this).find('h3').text().match(/^THINKING CRITICALLY/)) { $(this).prepend(''); } }); /* Styling for Student Writing boxes */ $('[data-block_type="mn4"]').each(function() { $(this).find('[data-type="box_inner"] [data-type="figure"]:first-child, [data-type="box_inner"] [data-block_type^="sel_hn"]').wrapAll(''); }); /* Moving the image in the Quick Help boxes */ /* $('[data-block_type="bxqh"]').each(function() { var img = $(this).find('[data-block_type="qh_img"]').detach(); //$(this).find('[data-block_type="bx_v1_t"]').prepend(img); $(this).before(img); }); */ /* Making links on Exercise pages pop up */ /* if ($('[data-block_type="bxex"]').length !== 0 || $('[data-block_type="bx1"]').length !== 0) { $('a').each(function() { if (!$(this).attr("target")) { $(this).attr("target", "_pop"); $(this).attr("data-xrefs-target", ""); } }); } */ /* swap exercise number for title */ if ($('[data-block_type="hide_title"]').length > 0) { var $h2 = $('h2.section-title'); var h2_txt = $h2.text(); $('[data-block_type="bxex"] h3[data-type="title"]').text(h2_txt); //$box_title.text(h2_txt); } /* 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++; }); } var margBoxArray = []; /* Marginal Question Boxes */ if ($('[data-block_type="quest_click"]').length > 0) { $('[data-block_type="quest_click"]').click(function() { var id = $(this).attr("id"); margBoxArray.push(id); $('#manuscript #' + id + '+div').slideToggle("slow"); }); } 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); }); } $('[data-block_type="quest_box"]').each(function() { var $this = $(this); $this.prepend(''); $this.draggable(); }); // for creating links in Page content boxes var h3_headers = {}; // Turninto
into
' + $this.html() + '
'); }); }); $('[data-block_type="txt_quest_title"]').each(function() { $(this).children('p').replaceWith(function(){ return $("").append($(this).contents()); }); }); $('h2.section-title').siblings('[data-block_type="sec_title"]').filter(':first').children('p').each(function() { var $this = $(this); var html = $this.html(); $('h2.section-title').children('span').html(html); $this.parent().remove(); $('#digfir_section_0').attr('data-block_type', 'show_title'); }); }, initialize: function(id) { if (xBookUtils.inDFWrapper()) { var idsFile = xBookUtils.getBaseUrl() + "asset/ids.js"; var body = document.getElementsByTagName("body")[0]; var script = document.createElement('script'); script.setAttribute('type','text/javascript'); script.setAttribute('src', idsFile); body.appendChild(script); } 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_manuscript(); // Add "Back to top" links if needed // If we have a Page Contents box if ($('[data-block_type="bx-v5-h"]').length > 0) { // If we don't have any Back to top links on the page if ($('[data-block_type="back_to_top"]').length == 0) { xBookUtils.debug("Adding 'Back to top' links"); // Add a Back to top link before each h2 subhead $('[data-block_type="h2"]').each(function() { $(this).before(''); }); $('[data-type="section"]').append(''); } } $('#manuscript').imagesLoaded(function($images, $proper, $broken) { $proper.each(function() { var $image = $(this); var $figure_div = $image.parent(); var orig_height = parseInt($image[0].naturalHeight); var curr_height = $image.height(); var height_ratio = curr_height/orig_height; // % height of image has changed var captionjs = $figure_div.attr('data-captionjs'); if (xBookUtils.emptyValue(captionjs) || captionjs !== "on") { return; } function set_wrapper_height(height) { $image.parent('.captionjs_imgwrap').css("height", wrapper_height + "px"); } var data_credit_size = $figure_div.attr('data-credit-size'); // If data-credit-size has been hardcoded to 0 we are done if (data_credit_size === "0") { return; } if (xBookUtils.emptyValue(data_credit_size)) { // Normally we would check the EXIF data if data-credit-size is not set // but since we can't do this with IE9 yet we'll just assume we // want to use the default value data_credit_size = xBookUtils.defaultCreditSize; } // Make sure data-credit-size is a positive int data_credit_size = Math.round(Math.abs(parseFloat(data_credit_size))); // If credit size is a number then use it if (!isNaN(data_credit_size)) { safe_log("Using data-credit-size " + data_credit_size + " for " + $figure_div.attr('id')); // Need to create a way to pass in other options var margin = "margin-" + "bottom"; $image.captionjs(); // this adds a wrapper div around the image // set the new wrapper div to the specified height var wrapper_height = curr_height - (Math.round(data_credit_size * height_ratio)); safe_log("Setting img wrapper to height " + wrapper_height + "px"); set_wrapper_height(wrapper_height); return; } }); }); $('[data-block_type="back_to_top"]').each(function() { $(this).parent('a').parent('p').parent('div').addClass('btt_link'); }); $('[data-block_type="cap_top"]').each(function(index, element) { var $jq = $(element); var cap = $jq.find('[data-type="figure_text"]:first-of-type').detach(); $jq.prepend(cap); }); $('a').each(function() { var $this = $(this); var href = $this.attr('href'); if (/^#/.test(href)) { if ($(href).length == 0) { var alias = href.replace(/#/, ""); $this.attr('href', "alias:" + alias); } } }); // Quick Help Boxes //$('[data-block_type="quick_help"] > h2.section-title').addClass('aria-hidden'); //$('[data-block_type="bxqh"]').prepend(''); $('[data-block_type="quick_help"] > h2.section-title').each(function() { var $this = $(this); var title = $this.html(); title = title.replace(/Quick Help: (.*)/, "Quick Help: $1"); $this.html(title); }); // Talking the Talk Boxes $('[data-block_type="talking_talk"] > h2.section-title').addClass('aria-hidden'); $("[data-title]").each(function() { var $this = $(this); var title = $this.attr('data-title'); $this.attr("title", title); }); // add blue circle triangles $('[data-block_type="ex-v3-txt"]').children("p").each(function() { var $this = $(this); var content = $this.html(); content = "s that don't have block_types
$('p').each(function() {
var $this = $(this);
var id = $this.attr('id');
if (!xBookUtils.emptyValue(id)) {
$this.prepend('' + id + '');
}
});
$('.show_anchors').click(function() {
var $this = $(this);
$('body').toggleClass("show_all_anchors");
});
$('.goto').click(function() {
var $this = $(this);
var id = $('#goto_id').val();
if (id in ids) {
window.location.href = ids[id];
}
else {
alert("Can't find ID " + id);
}
});
} // end inDFWrapper*/
}
});
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();
function fixCollisions(item1, item2) {
var $item1 = $(item1);
var $item2 = $(item2);
if ($item2.length === 0) {
return false;
}
var height1 = $item1.offset().top;
var height2 = $item2.offset().top;
var mTop1 = $item1.css("margin-top");
var mTop2 = $item2.css("margin-top");
//safe_log($item1.attr("id") + " = " + height1);
//safe_log($item1.attr("id") + " = " + mTop1);
//safe_log($item2.attr("id") + " = " + height2);
//safe_log($item2.attr("id") + " = " + mTop2);
var diff = height2 - height1;
//safe_log("diff = " + diff);
if (diff < 27) {
var newHeight2 = height1 + 27;
//safe_log("new " + $item2.attr("id") + " = " + newHeight2);
}
newHeight2 = height2 - newHeight2;
//safe_log($item2.css("margin-top"));
$item2.css("margin-top", "500px");
}
function showMargBox(num) {
num = parseInt(num);
var idNum = num;
if (num < 10) {
idNum = "0" + num;
}
var margId = '#lunsford_franchise_preview-ac_ch1-bx3-0' + idNum + 'a';
if ($(margId).length === 0) {
idNum = num + 25;
margId = '#lunsford_franchise_preview-ac_ch1-bx3-0' + idNum + 'a';
}
//smhandbook8e_preview-ac_Ch06-bx1-001
//smhandbook8e_preview-ac_Ch06-bx1-002
var paraBoxId = "#lunsford_franchise_preview-ac_ch1-bx1-001";
if ($(paraBoxId).length === 0) {
paraBoxId = "#lunsford_franchise_preview-ac_ch1-bx1-002";
}
safe_log(margId);
if ($(margId).css("display") === "block") {
return false;
} else {
$('#manuscript [data-block_type="quest_box"]').css("display", "none");
//$('#manuscript ' + margId).css("display", "block");
$('#manuscript ' + margId).css("display", "block");
$('#manuscript ' + margId + ':hover').css("cursor", "pointer");
lineUpBox(margId,"#pl-" + num, paraBoxId)
$('.cancel').click(function() {
$('#manuscript [data-block_type="quest_box"]').css("display", "none");
});
}
}
//When consumers enter almost any major supermarket today they can find an array of produce that is truly dazzling.
//