/*! colorbox v1.5.13 - 2014-08-04 jquery lightbox and modal window plugin (c) 2014 jack moore - http://www.jacklmoore.com/colorbox license: http://www.opensource.org/licenses/mit-license.php */ (function ($, document, window) { var // default settings object. // see http://jacklmoore.com/colorbox for details. defaults = { // data sources html: false, photo: false, iframe: false, inline: false, // behavior and appearance transition: "elastic", speed: 300, fadeout: 300, width: false, initialwidth: "600", innerwidth: false, maxwidth: false, height: false, initialheight: "450", innerheight: false, maxheight: false, scalephotos: true, scrolling: true, opacity: 0.9, preloading: true, classname: false, overlayclose: true, esckey: true, arrowkey: true, top: false, bottom: false, left: false, right: false, fixed: false, data: undefined, closebutton: true, fastiframe: true, open: false, reposition: true, loop: true, slideshow: false, slideshowauto: true, slideshowspeed: 2500, slideshowstart: "start slideshow", slideshowstop: "stop slideshow", photoregex: /\.(gif|png|jp(e|g|eg)|bmp|ico|webp|jxr|svg)((#|\?).*)?$/i, // alternate image paths for high-res displays retinaimage: false, retinaurl: false, retinasuffix: '@2x.$1', // internationalization current: "image {current} of {total}", previous: "previous", next: "next", close: "close", xhrerror: "this content failed to load.", imgerror: "this image failed to load.", // accessbility returnfocus: true, trapfocus: true, // callbacks onopen: false, onload: false, oncomplete: false, oncleanup: false, onclosed: false, rel: function() { return this.rel; }, href: function() { // using this.href would give the absolute url, when the href may have been inteded as a selector (e.g. '#container') return $(this).attr('href'); }, title: function() { return this.title; } }, // abstracting the html and event identifiers for easy rebranding colorbox = 'colorbox', prefix = 'cbox', boxelement = prefix + 'element', // events event_open = prefix + '_open', event_load = prefix + '_load', event_complete = prefix + '_complete', event_cleanup = prefix + '_cleanup', event_closed = prefix + '_closed', event_purge = prefix + '_purge', // cached jquery object variables $overlay, $box, $wrap, $content, $topborder, $leftborder, $rightborder, $bottomborder, $related, $window, $loaded, $loadingbay, $loadingoverlay, $title, $current, $slideshow, $next, $prev, $close, $groupcontrols, $events = $(''), // $({}) would be prefered, but there is an issue with jquery 1.4.2 // variables for cached values or use across multiple functions settings, interfaceheight, interfacewidth, loadedheight, loadedwidth, index, photo, open, active, closing, loadingtimer, publicmethod, div = "div", requests = 0, previouscss = {}, init; // **************** // helper functions // **************** // convenience function for creating new jquery objects function $tag(tag, id, css) { var element = document.createelement(tag); if (id) { element.id = prefix + id; } if (css) { element.style.csstext = css; } return $(element); } // get the window height using innerheight when available to avoid an issue with ios // http://bugs.jquery.com/ticket/6724 function winheight() { return window.innerheight ? window.innerheight : $(window).height(); } function settings(element, options) { if (options !== object(options)) { options = {}; } this.cache = {}; this.el = element; this.value = function(key) { var dataattr; if (this.cache[key] === undefined) { dataattr = $(this.el).attr('data-cbox-'+key); if (dataattr !== undefined) { this.cache[key] = dataattr; } else if (options[key] !== undefined) { this.cache[key] = options[key]; } else if (defaults[key] !== undefined) { this.cache[key] = defaults[key]; } } return this.cache[key]; }; this.get = function(key) { var value = this.value(key); return $.isfunction(value) ? value.call(this.el, this) : value; }; } // determine the next and previous members in a group. function getindex(increment) { var max = $related.length, newindex = (index + increment) % max; return (newindex < 0) ? max + newindex : newindex; } // convert '%' and 'px' values to integers function setsize(size, dimension) { return math.round((/%/.test(size) ? ((dimension === 'x' ? $window.width() : winheight()) / 100) : 1) * parseint(size, 10)); } // checks an href to see if it is a photo. // there is a force photo option (photo: true) for hrefs that cannot be matched by the regex. function isimage(settings, url) { return settings.get('photo') || settings.get('photoregex').test(url); } function retinaurl(settings, url) { return settings.get('retinaurl') && window.devicepixelratio > 1 ? url.replace(settings.get('photoregex'), settings.get('retinasuffix')) : url; } function trapfocus(e) { if ('contains' in $box[0] && !$box[0].contains(e.target) && e.target !== $overlay[0]) { e.stoppropagation(); $box.focus(); } } function setclass(str) { if (setclass.str !== str) { $box.add($overlay).removeclass(setclass.str).addclass(str); setclass.str = str; } } function getrelated(rel) { index = 0; if (rel && rel !== false && rel !== 'nofollow') { $related = $('.' + boxelement).filter(function () { var options = $.data(this, colorbox); var settings = new settings(this, options); return (settings.get('rel') === rel); }); index = $related.index(settings.el); // check direct calls to colorbox. if (index === -1) { $related = $related.add(settings.el); index = $related.length - 1; } } else { $related = $(settings.el); } } function trigger(event) { // for external use $(document).trigger(event); // for internal use $events.triggerhandler(event); } var slideshow = (function(){ var active, classname = prefix + "slideshow_", click = "click." + prefix, timeout; function clear () { cleartimeout(timeout); } function set() { if (settings.get('loop') || $related[index + 1]) { clear(); timeout = settimeout(publicmethod.next, settings.get('slideshowspeed')); } } function start() { $slideshow .html(settings.get('slideshowstop')) .unbind(click) .one(click, stop); $events .bind(event_complete, set) .bind(event_load, clear); $box.removeclass(classname + "off").addclass(classname + "on"); } function stop() { clear(); $events .unbind(event_complete, set) .unbind(event_load, clear); $slideshow .html(settings.get('slideshowstart')) .unbind(click) .one(click, function () { publicmethod.next(); start(); }); $box.removeclass(classname + "on").addclass(classname + "off"); } function reset() { active = false; $slideshow.hide(); clear(); $events .unbind(event_complete, set) .unbind(event_load, clear); $box.removeclass(classname + "off " + classname + "on"); } return function(){ if (active) { if (!settings.get('slideshow')) { $events.unbind(event_cleanup, reset); reset(); } } else { if (settings.get('slideshow') && $related[1]) { active = true; $events.one(event_cleanup, reset); if (settings.get('slideshowauto')) { start(); } else { stop(); } $slideshow.show(); } } }; }()); function launch(element) { var options; if (!closing) { options = $(element).data(colorbox); settings = new settings(element, options); getrelated(settings.get('rel')); if (!open) { open = active = true; // prevents the page-change action from queuing up if the visitor holds down the left or right keys. setclass(settings.get('classname')); // show colorbox so the sizes can be calculated in older versions of jquery $box.css({visibility:'hidden', display:'block', opacity:''}); $loaded = $tag(div, 'loadedcontent', 'width:0; height:0; overflow:hidden; visibility:hidden'); $content.css({width:'', height:''}).append($loaded); // cache values needed for size calculations interfaceheight = $topborder.height() + $bottomborder.height() + $content.outerheight(true) - $content.height(); interfacewidth = $leftborder.width() + $rightborder.width() + $content.outerwidth(true) - $content.width(); loadedheight = $loaded.outerheight(true); loadedwidth = $loaded.outerwidth(true); // opens inital empty colorbox prior to content being loaded. var initialwidth = setsize(settings.get('initialwidth'), 'x'); var initialheight = setsize(settings.get('initialheight'), 'y'); var maxwidth = settings.get('maxwidth'); var maxheight = settings.get('maxheight'); settings.w = (maxwidth !== false ? math.min(initialwidth, setsize(maxwidth, 'x')) : initialwidth) - loadedwidth - interfacewidth; settings.h = (maxheight !== false ? math.min(initialheight, setsize(maxheight, 'y')) : initialheight) - loadedheight - interfaceheight; $loaded.css({width:'', height:settings.h}); publicmethod.position(); trigger(event_open); settings.get('onopen'); $groupcontrols.add($title).hide(); $box.focus(); if (settings.get('trapfocus')) { // confine focus to the modal // uses event capturing that is not supported in ie8- if (document.addeventlistener) { document.addeventlistener('focus', trapfocus, true); $events.one(event_closed, function () { document.removeeventlistener('focus', trapfocus, true); }); } } // return focus on closing if (settings.get('returnfocus')) { $events.one(event_closed, function () { $(settings.el).focus(); }); } } var opacity = parsefloat(settings.get('opacity')); $overlay.css({ opacity: opacity === opacity ? opacity : '', cursor: settings.get('overlayclose') ? 'pointer' : '', visibility: 'visible' }).show(); if (settings.get('closebutton')) { $close.html(settings.get('close')).appendto($content); } else { $close.appendto('
'); // replace with .detach() when dropping jquery < 1.4 } load(); } } // colorbox's markup needs to be added to the dom prior to being called // so that the browser will go ahead and load the css background images. function appendhtml() { if (!$box && document.body) { init = false; $window = $(window); $box = $tag(div).attr({ id: colorbox, 'class': $.support.opacity === false ? prefix + 'ie' : '', // class for optional ie8 & lower targeted css. role: 'dialog', tabindex: '-1' }).hide(); $overlay = $tag(div, "overlay").hide(); $loadingoverlay = $([$tag(div, "loadingoverlay")[0],$tag(div, "loadinggraphic")[0]]); $wrap = $tag(div, "wrapper"); $content = $tag(div, "content").append( $title = $tag(div, "title"), $current = $tag(div, "current"), $prev = $('