/* concisebedguide1ebim */
/*
* jQuery Orbit Plugin 1.2.3
* www.ZURB.com/playground
* Copyright 2010, ZURB
* Free to use under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
*/
(function($) {
$.fn.orbit = function(options) {
//Defaults to extend options
var defaults = {
animation: 'horizontal-push', // fade, horizontal-slide, vertical-slide, horizontal-push
animationSpeed: 600, // how fast animtions are
timer: false, // true or false to have the timer
advanceSpeed: 1000, // if timer is enabled, time between transitions
pauseOnHover: false, // if you hover pauses the slider
startClockOnMouseOut: false, // if clock should start on MouseOut
startClockOnMouseOutAfter: 1000, // how long after MouseOut should the timer start again
directionalNav: true, // manual advancing directional navs
captions: true, // do you want captions?
captionAnimation: 'fade', // fade, slideOpen, none
captionAnimationSpeed: 600, // if so how quickly should they animate in
bullets: false, // true or false to activate the bullet navigation
bulletThumbs: false, // thumbnails for the bullets
bulletThumbLocation: '', // location from this file where thumbs will be
afterSlideChange: function(){} // empty function
};
//Extend those options
var options = $.extend(defaults, options);
return this.each(function() {
// ==============
// ! SETUP
// ==============
//Global Variables
var activeSlide = 0,
numberSlides = 0,
orbitWidth,
orbitHeight,
locked;
//Initialize
var orbit = $(this).addClass('orbit'),
orbitWrapper = orbit.wrap('
').parent();
//orbit.add(orbitWidth).width('1px').height('1px');
//Collect all slides and set slider size of largest image
var slides = orbit.children('img, a, div');
var _slide = slides.eq(activeSlide);
_slideWidth = _slide.width(),
_slideHeight = _slide.height();
orbit.add(orbitWrapper).width(_slideWidth);
orbitWidth = orbit.width();
orbit.add(orbitWrapper).height(_slideHeight);
orbitHeight = orbit.height();
slides.each(function() {
/*var _slide = $(this),
_slideWidth = _slide.width(),
_slideHeight = _slide.height();
if(_slideWidth > orbit.width()) {
orbit.add(orbitWrapper).width(_slideWidth);
orbitWidth = orbit.width();
}
if(_slideHeight > orbit.height()) {
orbit.add(orbitWrapper).height(_slideHeight);
orbitHeight = orbit.height();
}*/
numberSlides++;
});
//Animation locking functions
function unlock() {
locked = false;
}
function lock() {
locked = true;
}
//If there is only a single slide remove nav, timer and bullets
if(slides.length == 1) {
options.directionalNav = false;
options.timer = false;
options.bullets = false;
}
//Set initial front photo z-index and fades it in
slides.eq(activeSlide)
.css({"z-index" : 3})
.fadeIn(function() {
//brings in all other slides IF css declares a display: none
slides.css({"display":"block"})
});
// ==============
// ! TIMER
// ==============
//Timer Execution
function startClock() {
if(!options.timer || options.timer == 'false') {
return false;
//if timer is hidden, don't need to do crazy calculations
} else if(timer.is(':hidden')) {
clock = setInterval(function(e){
shift("next");
}, options.advanceSpeed);
//if timer is visible and working, let's do some math
} else {
timerRunning = true;
pause.removeClass('active')
clock = setInterval(function(e){
var degreeCSS = "rotate("+degrees+"deg)"
degrees += 2
rotator.css({
"-webkit-transform": degreeCSS,
"-moz-transform": degreeCSS,
"-o-transform": degreeCSS
});
if(degrees > 180) {
rotator.addClass('move');
mask.addClass('move');
}
if(degrees > 360) {
rotator.removeClass('move');
mask.removeClass('move');
degrees = 0;
shift("next");
}
}, options.advanceSpeed/180);
}
}
function stopClock() {
if(!options.timer || options.timer == 'false') { return false; } else {
timerRunning = false;
clearInterval(clock);
pause.addClass('active');
}
}
//Timer Setup
if(options.timer) {
var timerHTML = '
'
orbitWrapper.append(timerHTML);
var timer = orbitWrapper.children('div.timer'),
timerRunning;
if(timer.length != 0) {
var rotator = $('div.timer span.rotator'),
mask = $('div.timer span.mask'),
pause = $('div.timer span.pause'),
degrees = 0,
clock;
startClock();
timer.click(function() {
if(!timerRunning) {
startClock();
} else {
stopClock();
}
});
if(options.startClockOnMouseOut){
var outTimer;
orbitWrapper.mouseleave(function() {
outTimer = setTimeout(function() {
if(!timerRunning){
startClock();
}
}, options.startClockOnMouseOutAfter)
})
orbitWrapper.mouseenter(function() {
clearTimeout(outTimer);
})
}
}
}
//Pause Timer on hover
if(options.pauseOnHover) {
orbitWrapper.mouseenter(function() {
stopClock();
});
}
// ==============
// ! CAPTIONS
// ==============
//Caption Setup
if(options.captions) {
var captionHTML = '';
orbitWrapper.after(captionHTML);
var caption = orbitWrapper.next('.orbit-caption');
setCaption();
}
//Caption Execution
function setCaption() {
if(!options.captions || options.captions =="false") {
return false;
} else {
var _captionLocation = slides.eq(activeSlide).data('caption'); //get ID from rel tag on image
_captionHTML = $(_captionLocation).html(); //get HTML from the matching HTML entity
//Set HTML for the caption if it exists
if(_captionHTML) {
caption
.attr('id',_captionLocation) // Add ID caption
.html(_captionHTML); // Change HTML in Caption
//Animations for Caption entrances
if(options.captionAnimation == 'none') {
caption.show();
}
if(options.captionAnimation == 'fade') {
caption.fadeIn(options.captionAnimationSpeed);
}
if(options.captionAnimation == 'slideOpen') {
caption.slideDown(options.captionAnimationSpeed);
}
} else {
//Animations for Caption exits
if(options.captionAnimation == 'none') {
caption.hide();
}
if(options.captionAnimation == 'fade') {
caption.fadeOut(options.captionAnimationSpeed);
}
if(options.captionAnimation == 'slideOpen') {
caption.slideUp(options.captionAnimationSpeed);
}
}
}
}
// ==================
// ! DIRECTIONAL NAV
// ==================
//DirectionalNav { rightButton --> shift("next"), leftButton --> shift("prev");
if(options.directionalNav) {
if(options.directionalNav == "false") { return false; }
var directionalNavHTML = 'RightLeft
';
orbitWrapper.append(directionalNavHTML);
var _slide = slides.eq(activeSlide);
var index = _slide.index();
var leftBtn = orbitWrapper.children('div.slider-nav').children('span.left'),
rightBtn = orbitWrapper.children('div.slider-nav').children('span.right');
if (index === 0) {
leftBtn.hide();
}
leftBtn.click(function() {
stopClock();
shift("prev");
var _slide = slides.eq(activeSlide);
var index = _slide.index();
if (index === 0) {
leftBtn.hide();
} else {
rightBtn.show();
leftBtn.show();
}
var _slideHeight = _slide.height();
var _slideWidth = _slide.width();
orbit.add(orbitWrapper).height(_slideHeight).width(_slideWidth);
});
rightBtn.click(function() {
stopClock();
shift("next");
var _slide = slides.eq(activeSlide);
var index = _slide.index();
if (index + 1 == numberSlides) {
rightBtn.hide();
} else {
rightBtn.show();
leftBtn.show();
}
var _slideHeight = _slide.height();
var _slideWidth = _slide.width()
orbit.add(orbitWrapper).height(_slideHeight).width(_slideWidth);
});
}
// ==================
// ! BULLET NAV
// ==================
//Bullet Nav Setup
if(options.bullets) {
var bulletHTML = '';
orbitWrapper.append(bulletHTML);
var bullets = orbitWrapper.children('ul.orbit-bullets');
for(i=0; i'+(i+1)+'');
if(options.bulletThumbs) {
var thumbName = slides.eq(i).data('thumb');
if(thumbName) {
var liMarkup = $(''+i+'')
liMarkup.css({"background" : "url("+options.bulletThumbLocation+thumbName+") no-repeat"});
}
}
orbitWrapper.children('ul.orbit-bullets').append(liMarkup);
liMarkup.data('index',i);
liMarkup.click(function() {
stopClock();
shift($(this).data('index'));
});
}
setActiveBullet();
}
//Bullet Nav Execution
function setActiveBullet() {
if(!options.bullets) { return false; } else {
bullets.children('li').removeClass('active').eq(activeSlide).addClass('active');
}
}
// ====================
// ! SHIFT ANIMATIONS
// ====================
//Animating the shift!
function shift(direction) {
//remember previous activeSlide
var prevActiveSlide = activeSlide,
slideDirection = direction;
//exit function if bullet clicked is same as the current image
if(prevActiveSlide == slideDirection) { return false; }
//reset Z & Unlock
function resetAndUnlock() {
slides
.eq(prevActiveSlide)
.css({"z-index" : 1});
unlock();
options.afterSlideChange.call(this);
}
if(slides.length == "1") { return false; }
if(!locked) {
lock();
//deduce the proper activeImage
if(direction == "next") {
activeSlide++
if(activeSlide == numberSlides) {
activeSlide = 0;
}
} else if(direction == "prev") {
activeSlide--
if(activeSlide < 0) {
activeSlide = numberSlides-1;
}
} else {
activeSlide = direction;
if (prevActiveSlide < activeSlide) {
slideDirection = "next";
} else if (prevActiveSlide > activeSlide) {
slideDirection = "prev"
}
}
//set to correct bullet
setActiveBullet();
//set previous slide z-index to one below what new activeSlide will be
slides
.eq(prevActiveSlide)
.css({"z-index" : 2});
//fade
if(options.animation == "fade") {
slides
.eq(activeSlide)
.css({"opacity" : 0, "z-index" : 3})
.animate({"opacity" : 1}, options.animationSpeed, resetAndUnlock);
}
//horizontal-slide
if(options.animation == "horizontal-slide") {
if(slideDirection == "next") {
slides
.eq(activeSlide)
.css({"left": orbitWidth, "z-index" : 3})
.animate({"left" : 0}, options.animationSpeed, resetAndUnlock);
}
if(slideDirection == "prev") {
slides
.eq(activeSlide)
.css({"left": -orbitWidth, "z-index" : 3})
.animate({"left" : 0}, options.animationSpeed, resetAndUnlock);
}
}
//vertical-slide
if(options.animation == "vertical-slide") {
if(slideDirection == "prev") {
slides
.eq(activeSlide)
.css({"top": orbitHeight, "z-index" : 3})
.animate({"top" : 0}, options.animationSpeed, resetAndUnlock);
}
if(slideDirection == "next") {
slides
.eq(activeSlide)
.css({"top": -orbitHeight, "z-index" : 3})
.animate({"top" : 0}, options.animationSpeed, resetAndUnlock);
}
}
//push-over
if(options.animation == "horizontal-push") {
if(slideDirection == "next") {
slides
.eq(activeSlide)
.css({"left": orbitWidth, "z-index" : 3})
.animate({"left" : 0}, options.animationSpeed, resetAndUnlock);
slides
.eq(prevActiveSlide)
.animate({"left" : -orbitWidth}, options.animationSpeed);
}
if(slideDirection == "prev") {
slides
.eq(activeSlide)
.css({"left": -orbitWidth, "z-index" : 3})
.animate({"left" : 0}, options.animationSpeed, resetAndUnlock);
slides
.eq(prevActiveSlide)
.animate({"left" : orbitWidth}, options.animationSpeed);
}
}
setCaption();
} //lock
}//orbit function
});//each call
}//orbit plugin call
})(jQuery);
xBookUtils.bookID = "concisebedguide1ebim";
xBookUtils.discipline = {
dev: 6698,
qa: 6698,
pr: 6698,
www: 6698
}
var Player_subtype = Player_manuscript_type.extend({
cfg_LH_ebookTargetDefault: "_pop",
initialize_sections: function() {
this._super();
/* remove any rawhtml divs */
/* This isn't strictly necessary, I just don't like the fact that our
raw html code is wrapped in a div */
$('[data-type="rawhtml"]').each(function() {
var raw_content = $(this).contents();
$(this).replaceWith(raw_content);
});
if ($('[data-block_type="lbd"]').length > 0) {
$("body").addClass('lbd');
$("h2").hide();
var $phrase = $("span");
$phrase.addClass('testing');
var $h3 = $("h3:first");
var h3_text = $h3.text();
var $box = $('div[data-type="box_inner"]:first');
if (match = h3_text.match(/(Learning by Doing) !Learn! (.*)/)) {
$box.prepend('');
$h3.remove();
}
$('[data-type="ref"]').each(
function() {
var ref_content = $(this).contents();
$(this).replaceWith(ref_content);
});
}
/*
if($.browser.msie) {
// call slideshow plugin IE fix
$('#featured').orbit();
}
else {
//$(window).load(function() {
// call slideshow plugin
$('#featured').orbit();
//});
}
*/
if ($('[data-block_type="low"]').length > 0) {
$("body").addClass('low');
var $h2 = $("h2:first");
var h2_text = $h2.text();
$h2.addClass('page_title');
var $h3 = $("h3:first");
var h3_text = $h3.text();
if (match = h2_text.match(/(Learning from Other Writers: Research Cluster)/)) {
$h2.text(match[1]);
$h2.removeClass('page_title');
}
if ($h2.hasClass('page_title')) {
if (match = h2_text.match(/(Learning from Other Writers): .*?/)) {
$h2.text(match[1]);
}
}
if (match = h3_text.match(/(The Game Ain’t Over Til the Fatso Man Sings)/)) {
$h3.html("" + match[1] + "");
}
else if (match = h3_text.match(/(Dirty Water)( Campaign)/)) {
$h3.html("" + match[1] + "" + match[2]);
}
else if (match = h3_text.match(/(Texting While Walking)/)) {
$h3.html("" + match[1] + "");
}
else if (match = h3_text.match(/(Best Buttermilk Pancakes)/)) {
$h3.html("" + match[1] + "");
}
else if (match = h3_text.match(/(Celebrity Relationships: Why Do We Care\?)/)) {
$h3.html("" + match[1] + "");
}
else if (match = h3_text.match(/(The Strange Power of Celebrity)/)) {
$h3.html("" + match[1] + "");
}
else if (match = h3_text.match(/(Mind Games: Football and Head Injuries)/)) {
$h3.html("" + match[1] + "");
}
var $box = $('div[data-block_type="low"]');
$box.addClass('low_content');
var $inner = $('div[data-type="box_inner"]');
$inner.addClass('inner');
var $author = $('div[data-block_type="author"]');
$author.addClass('author');
var $media = $('div[data-block_type="media"]');
$media.addClass('media');
$(".low_content").each(
function() {
var $h3 = $(".low_content h3");
var h3_html = $h3.html();
var $auth = $(".low_content .author");
var auth_text = $auth.text();
var $med = $(".low_content .media");
var med_text = $med.text();
var $inn = $(".low_content .inner:first");
$inn.prepend('');
$h3.remove();
$auth.remove();
$med.remove();
$(".low_content").removeClass('low_content');
});
}
if ($('[data-block_type="questions"]').length > 0) {
$("body").addClass('questions');
}
if ($('[data-block_type="awr"]').length > 0) {
$("body").addClass('awr');
$("h2:first").hide();
var $box = $('div[data-block_type="awr"]');
$box.addClass('awr_content');
var $inner = $('div[data-type="box_inner"]');
$inner.addClass('inner');
var $author = $('div[data-block_type="author"]');
$author.addClass('author');
var $media = $('div[data-block_type="media"]');
$media.addClass('media');
$(".awr_content").each(
function() {
var $h3 = $(".awr_content h3:first");
var h3_text = $h3.text();
var $auth = $(".awr_content .author");
var auth_text = $auth.text();
var $med = $(".awr_content .media");
var med_text = $med.text();
var $inn = $(".awr_content .inner:first");
$inn.prepend('');
$h3.remove();
$auth.remove();
$med.remove();
$(".awr_content").removeClass('awr_content');
});
}
var $author = $("td.author");
var author_text = $author.text();
if (author_text.match(/National Geographic Editors/)) {
$author.html('National Geographic Editors');
}
// rearrange slideshow images for slider plugin
var $slideShow = $('[data-block_type="slideshow"]');
var $slideShowInner = $slideShow.find(".inner");
$slideShow.attr("id", "featured");
$('[data-block_type="ss_fig"] img').addClass('ss_img');
$('[data-block_type="ss_fig"]').each(function(index) {
$this = $(this);
var $img = $this.find(".ss_img");
var $cap = $this.find('[data-type="caption"]');
$cap.attr("id", "cap" + index);
$img.attr("data-caption", "#cap" + index);
$this.remove();
$slideShowInner.append($img);
$slideShow.append($cap);
});
$(".ss_img").unwrap();
//$('[data-type="caption"]').unwrap();
},
initialize: function(id) {
this._super(id);
this.xrefs = new XRefs_manuscript_subtype();
this.glossary = new Glossary_manuscript_subtype();
this.figures = new Figures_manuscript_subtype();
},
initialize2: function() {
this._super();
// anything that you want to do after *everything* has been set up
// should be done here.
var link_handler = new LinkHandler();
// replace span tags inside questions IE fix
$(".essay-question").each (
function() {
//grab all list spans in the question
$list = $(this).find('[data-block_type="list"]');
//replace list span with
$list.replaceWith(function() {
var $this = $(this);
return '
• ' + $this.html() + '
';
});
// grab all txt_ni_tm spans in the question
$txt = $(this).find('[data-block_type="txt_ni_tm"]');
// replace with
$txt.replaceWith(function() {
var $this = $(this);
return '
' + $this.html() + '
';
});
});
// change spans in slideshow captions to s
$('#featured [data-type="caption"]').each (
function() {
//grab all source spans in the caption
$source = $(this).find('[data-block_type="source"]');
//replace list span with
$source.replaceWith(function() {
var $this = $(this);
return '
' + $this.html() + '
';
});
// grab all source_rt spans in the caption
$sourceRight = $(this).find('[data-block_type="source_rt"]');
// replace with
$sourceRight.replaceWith(function() {
var $this = $(this);
return '
' + $this.html() + '
';
});
//grab all cap_title spans in the caption
$capTitle = $(this).find('[data-block_type="cap_title"]');
//replace list span with
$capTitle.replaceWith(function() {
var $this = $(this);
return '
' + $this.html() + '
';
});
// grab all caption spans in the caption
$caption = $(this).find('[data-block_type="caption"]');
// replace with
$caption.replaceWith(function() {
var $this = $(this);
return '
' + $this.html() + '
';
});
});
$('#featured').orbit();
}
});
$(window).load(function() {
// change spans in questions to s
$(".essay-question").each (
function() {
//grab all list spans in the question
$list = $(this).find('[data-block_type="list"]');
//replace list span with
$list.replaceWith(function() {
var $this = $(this);
return '
• ' + $this.html() + '
';
});
// grab all txt_ni_tm spans in the question
$txt = $(this).find('[data-block_type="txt_ni_tm"]');
// replace with
$txt.replaceWith(function() {
var $this = $(this);
return '
' + $this.html() + '
';
});
});
// change spans in slideshow captions to s
$('#featured [data-type="caption"]').each (
function() {
//grab all source spans in the caption
$source = $(this).find('[data-block_type="source"]');
//replace list span with
$source.replaceWith(function() {
var $this = $(this);
return '
' + $this.html() + '
';
});
// grab all source_rt spans in the caption
$sourceRight = $(this).find('[data-block_type="source_rt"]');
// replace with
$sourceRight.replaceWith(function() {
var $this = $(this);
return '
' + $this.html() + '
';
});
//grab all cap_title spans in the caption
$capTitle = $(this).find('[data-block_type="cap_title"]');
//replace list span with
$capTitle.replaceWith(function() {
var $this = $(this);
return '
' + $this.html() + '
';
});
// grab all caption spans in the caption
$caption = $(this).find('[data-block_type="caption"]');
// replace with
$caption.replaceWith(function() {
var $this = $(this);
return '
' + $this.html() + '
';
});
});
});
player = new Player_subtype();