(function() { var $, aeReady, createCurrMapCopyButtons, createFloatingToc, createInteractiveGraphCopyButtons, createVideoCopyButtons, isMob, loadTables, loc, logging, mobileReady, oldIE, once, onceAfter, toggleDictionarySection, videos, _this = this; $ = jQuery; logging = true; $(function() { $("body").on("click", "[data-ga-category]", function(e) { var $this, url; $this = $(this); url = $this.attr("href"); if (typeof url !== "undefined" && url !== false) { e.preventDefault(); } dataLayer.push({ 'event': 'linkClick', 'linkCategory': $(this).attr("data-ga-category"), 'linkAction': $(this).attr("data-ga-action"), 'linkLabel': $(this).attr("data-ga-label") }); if (typeof url !== "undefined" && url !== false) { return setTimeout((function() { window.location.href = url; }), 200); } }); }); $(function() { $("body").on("click", "[data-search-result]", function(e) { var $this, customEventData, rank, searchTerms, url; $this = $(this); url = $this.attr("href"); rank = parseInt($this.attr("data-search-result")) + 1; searchTerms = $this.attr("data-search-terms"); if (typeof url !== "undefined" && url !== false) { e.preventDefault(); } customEventData = { 'event': 'searchLinkClick', 'searchCategory': 'SearchClick', 'searchAction': e.target.href, 'searchLabel': searchTerms, 'searchValue': rank, 'eventCallback': function() { return window.location = url; } }; return dataLayer.push(customEventData); }); }); toggleDictionarySection = $('.toggleDictionarySection'); toggleDictionarySection.click(function() { $('.dictionary-result').slideToggle('fast', function() { if (toggleDictionarySection.find('.toggle-dict-btn-text').text() === 'Hide') { return toggleDictionarySection.find('.toggle-dict-btn-text').text('View'); } else { return toggleDictionarySection.find('.toggle-dict-btn-text').text('Hide'); } }); }); window.LOG = function(s) { if (logging) { return console.log(s); } }; oldIE = function() { return $.browser.msie && ($.browser.version <= 9); }; isMob = function() { return $('.m-jumpto').css("display") === "block"; }; loc = function() { return location.protocol + "//" + location.hostname + (location.port !== "" ? ":" + location.port : '') + location.pathname; }; $.fn.copyBtn = function(opts) { var $this, input, left, over, right, rightAligned, _this = this; if (!($.fn.copyBtn.button != null)) { $.fn.copyBtn.button = /Mac/.test(navigator.userAgent) ? "CMD" : "CTRL"; } if (!($.fn.copyBtn.count != null)) { $.fn.copyBtn.count = 1; } if (!($.fn.copyBtn.docEvent != null)) { $(document).on('click', function(e) { var el; el = $(e.target || e.srcElement); if (!el.data('copyBtn') && el.closest('.copy-btn-over').length === 0) { return $('.copy-btn-over').hide(); } }); $.fn.copyBtn.docEvent = true; } $this = $(this); $this.css("position", "relative"); $this.data('copyBtn', true); left = $this.offset().left; right = $(window).width() - (left + $this.width()); rightAligned = right < left; $this.append("
\n \n \n
"); over = $('.copy-btn-over', $this); input = $('[type="text"]', $this); $this.on('click', function(e) { e.preventDefault(); over.show(); input.val(opts.copy); input.focus(); return input.select(); }); input.on('click', function(e) { input.val(opts.copy); input.focus(); return input.select(); }); return $.fn.copyBtn.count++; }; createVideoCopyButtons = function() { var itemurl, linktds; itemurl = loc(); linktds = $("div.video_metadata"); return linktds.each(function() { var $this, copy_p, figureId, link; copy_p = $(""); $this = $(this); $this.append(copy_p); figureId = $(this).closest('figure').attr("id"); if (figureId !== void 0) { figureId = "#" + figureId; } else { figureId = ""; } link = itemurl + figureId; return copy_p.find('span').copyBtn({ copy: link }); }); }; createInteractiveGraphCopyButtons = function() { var itemurl, linktds; if (this.called) { return; } this.called = true; itemurl = loc(); linktds = $("graphobject"); return linktds.each(function() { var $this, copy_p, link; if ($(this).attr("sipp2:functionality") !== "NONE") { copy_p = $(""); $this = $(this); $this.parent().after(copy_p); link = itemurl + "#" + $(this).closest('figure').attr("id"); LOG(link); return copy_p.find('span').copyBtn({ copy: itemurl + "#" + $(this).closest('figure').attr("id") }); } }); }; createCurrMapCopyButtons = function() { var linktds, old_links; linktds = $(".curr-map td:first-child"); old_links = $('.curr-map .copy_link'); LOG(old_links); old_links.remove(); if ($('body').hasClass('fragr-enabled')) { return; } LOG("full"); return linktds.each(function() { var $this, copyAs, copyUrl, copy_div; $this = $(this); copyAs = $("a", $this); copyUrl = copyAs.attr("href"); if (copyAs.length !== 0 && copyUrl.charAt(0) === '/') { copyUrl = window.baseUrl + copyUrl.substr(1, copyUrl.length); copy_div = $(""); $this.prepend(copy_div); return copy_div.find('span').copyBtn({ copy: copyUrl }); } }); }; createFloatingToc = function() { var $doc, $footer, $inner, $newEditionInfo, $source, $toc, $win, feat_offset, lockClass, newEditionInfoHeight, offset, taller; $toc = $("#filter[data-toc=\"t§rue\"]"); if ($toc.length === 0) { return; } $source = $("#source"); $newEditionInfo = $("#book-new-edition"); if ($newEditionInfo) { newEditionInfoHeight = $newEditionInfo.height(); } else { newEditionInfoHeight = 0; } $win = $(window); $doc = $(document); $footer = $("#page-footer-container"); $inner = $toc.find(".inner:eq(0)"); lockClass = "lock-toc"; offset = void 0; taller = ($toc.height() + newEditionInfoHeight) > $win.height(); $toc.data({ width: $source.width(), height: (taller ? $win.height() - newEditionInfoHeight : "auto"), bottom: (taller ? 0 : "auto") }); $inner.data({ height: $inner.height() }); feat_offset = $('#featured').offset().top; $(window).resize(function() { var height, ob, width; width = $source.width(); height = $win.height() - newEditionInfoHeight; taller = ($toc.height() + newEditionInfoHeight) > $win.height(); ob = { width: width, height: (taller ? height : "auto"), bottom: (taller ? 0 : "auto") }; $toc.data(ob); $toc.css(ob); $inner.data({ height: $inner.height() }); return $newEditionInfo.css({ width: width }); }); offset = $toc.offset().top; return $(window).scroll(onceAfter(250, function() { var footerLimit, top; top = $(this).scrollTop() + newEditionInfoHeight; footerLimit = $doc.height() - ($footer.height() + 50) - $win.height() - newEditionInfoHeight; if (top > offset) { if (top > footerLimit) { return $toc.css({ height: "" }); } else { $toc.css($toc.data()); $toc.css({ position: 'absolute', top: top - feat_offset, height: $win.height() - newEditionInfoHeight, 'overflow-y': 'scroll' }); return $newEditionInfo.css({ position: 'absolute', top: top - feat_offset - newEditionInfoHeight, width: $source.width() }); } } else { $toc.css({ height: "", position: 'static' }); $newEditionInfo.css({ position: 'static' }); return $inner.css({ height: "" }); } })); }; mobileReady = function() { var breadcrumb, toc; breadcrumb = $('#breadcrumb'); return toc = $('[data-toc="true"]'); }; loadTables = function() { var allTables, ie8, url; ie8 = $.browser.msie && ($.browser.version > 7) && ($.browser.version < 9); allTables = $('.table-wrapper, .informaltable-wrapper'); url = "" + baseUrl + "export/excel" + (location.pathname.replace('/browse', '')) + "/"; return allTables.each(function(i, el) { var $el, addTable, table; $el = $(el); table = $el.find('table'); addTable = function() { var controls_div; controls_div = $('
\ \ table icon\ Export Data\ Export to Excel\
'); return table.after(controls_div); }; if (!ie8) { if ((table.find('thead tr').length === 1) && (table.find('thead tr th').length > 1) && (table.find('img').length === 0) && (table.find('td[rowspan]').length === 0) && (table.find('td[colspan]').length === 0)) { return addTable(); } } else { if ((table.find('thead tr').length === 1) && (table.find('thead tr th').length > 1) && (table.find('img').length === 0)) { return addTable(); } } }); }; window.aeCurrStyles = function() { var bar, i, iframe, sel; bar = $('.mercury-style-select .mercury-select-options'); sel = $('
Selected row
').prependTo(bar); iframe = $('#mercury_iframe').get(0); i = iframe.contentDocument || iframe.contentWindow.document; return sel.click(function(e) { var $node, node, tr; node = i.getSelection().anchorNode; $node = $(node); if ($node.length === 0) { console.log("no selection"); return; } tr = $node.closest("tr"); return tr.toggleClass("selected"); }); }; window.fixFlash = function(isShowing) { if ($.browser.msie) { return $('object,embed')[isShowing ? "hide" : "show"](); } }; window.decodeParams = function(url) { var json, param_str; param_str = url.split("?")[1]; if (param_str.charAt(0) === "&") { param_str = param_str.substr(1); } json = '{"' + decodeURI(param_str.replace(new RegExp('&', 'g'), "\",\"").replace(new RegExp('=', 'g'), "\":\"")) + '"}'; return $.parseJSON(json); }; once = function(cb) { var fired; fired = false; return function() { if (fired) { return; } fired = true; return cb(); }; }; onceAfter = function(amount, cb) { var timer_id; timer_id = -1; return function() { if (timer_id !== -1) { clearTimeout(timer_id); } return timer_id = setTimeout(function() { cb.apply(this, arguments); return timer_id = -1; }, amount); }; }; videos = { updateOrientation: function() { var $obj, aspectRatio, contentElWidth, elContent, elContentStyle, obj, videoEl, videoObjects, videoWrapperEl, _i, _len; videoObjects = $('video'); for (_i = 0, _len = videoObjects.length; _i < _len; _i++) { obj = videoObjects[_i]; $obj = $(obj); videoEl = $('#' + $obj.attr('id')); videoWrapperEl = videoEl.parent(); elContent = $('.panel')[0]; if (elContent) { elContentStyle = elContent.currentStyle || window.getComputedStyle(elContent); contentElWidth = elContent.offsetWidth - (parseFloat(elContentStyle.paddingLeft) + parseFloat(elContentStyle.paddingRight)); } else { contentElWidth = videoEl.width(); } aspectRatio = videoEl.height() / videoEl.width(); videoEl.css({ width: contentElWidth + 'px', height: contentElWidth * aspectRatio + 'px' }); videoWrapperEl.css({ width: contentElWidth + 'px', height: contentElWidth * aspectRatio + 'px' }); } }, init: function() { var obj, outer, videoDataObj, _i, _len, _ref, _results; this.find(); if (this.objects.length === 0) { return; } if ($('body').hasClass('fragr-enabled')) { return; } _ref = this.objects; _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { obj = _ref[_i]; obj = $(obj); videoDataObj = obj.closest('.informalfigure-wrapper'); outer = $(this.markup(videoDataObj.attr('data-type'), videoDataObj.attr('data-action'), videoDataObj.attr('data-parent-book-title') + '/' + videoDataObj.attr('data-title'))); outer.insertAfter(obj); this.bind(outer, obj, obj.parent()); _results.push(obj.remove()); } return _results; }, find: function() { return this.objects = $('.mediaobject video.BrightcoveExperience'); }, findCurrentVideoPlayers: function() { return this.videoObjects = $('video'); }, markup: function(category, action, label) { return '
\
\ video icon\ Video\ Click to load video\
\
'; }, resizeVideoPlayer: function(videoEl, videoWrapperEl, videoWidth, videoHeight) { var aspectRatio, contentElWidth, elContent, elContentStyle; elContent = $('.panel')[0]; if (elContent) { elContentStyle = elContent.currentStyle || window.getComputedStyle(elContent); contentElWidth = elContent.offsetWidth - (parseFloat(elContentStyle.paddingLeft) + parseFloat(elContentStyle.paddingRight)); } else { contentElWidth = videoWidth; } aspectRatio = videoHeight / videoWidth; videoWrapperEl.css({ width: contentElWidth + 'px', height: contentElWidth * aspectRatio + 'px' }); }, bind: function(outer, obj) { var that, topLevelEl, _this = this; that = this; topLevelEl = $(outer).parent().parent(); return outer.on('click', '.video-toggle-btn', function() { return _this.load(once(function() { window.brightcove = true; outer.before(obj); bc(obj[0]); outer.remove(); return videojs(obj[0]).on('loadedmetadata', function() { var myPlayer, videoEl, videoHeight, videoWidth, videoWrapperEl; myPlayer = this; videoWidth = myPlayer.videoWidth(); videoHeight = myPlayer.videoHeight(); if (0 === videoWidth || 0 === videoHeight) { videoWidth = myPlayer.width(); videoHeight = myPlayer.height(); } if (0 === videoWidth || 0 === videoHeight) { videoWidth = maximumVideoWidth; videoHeight = maximumVideoWidth * 0.75; } videoEl = topLevelEl.find('video').first(); videoWrapperEl = videoEl.parent(); videoWrapperEl.removeAttr("style"); videoWrapperEl.parent().removeAttr("style"); if (0 !== videoWidth && 0 !== videoHeight) { that.resizeVideoPlayer(videoEl, videoWrapperEl, videoWidth, videoHeight); } }); })); }); }, load: function(cb) { return yepnope({ test: window.brightcove != null, nope: '//players.brightcove.net/1377104850001/default_default/index.min.js', complete: function() { return cb(); } }); } }; aeReady = function() { var appendDimensions, baseUrl, browserSizeSpan, check, checkCookie, checkExistingLabels, checkExistingRenameLabels, cookies, createFormLabel, createFormRenameLabel, enableAnnotations, entryLabels, err, flash, getBrowserDimensions, getParameterByName, getScreenResolution, img, javaScript, lbls, lightbox_img, ln, marcFrom, marcTo, popoverShowing, popupContent, popupHelpPanels, regLink, remove_searches, remove_stars, screenResolutionSpan, scrollAll, scrollToAnnotation, searchBox, searchBoxPlaceholder, searchTerm, starredList, topArrow, waypointObj, waypointObjFooter, win, _i, _len, _ref; videos.init(); if (document.addEventListener) { document.addEventListener('orientationchange', videos.updateOrientation); } searchBox = $('[name="q"]'); searchBoxPlaceholder = searchBox.attr('placeholder'); searchBox.focus(function(e) { if (searchBox.val() === searchBoxPlaceholder) { return searchBox.val(''); } }); searchBox.closest('form').on('submit', function(e) { if ($.trim(searchBox.val()) !== $.trim(searchBoxPlaceholder)) { return 1; } else { searchBox.val(""); return 0; } }); baseUrl = window.baseUrl = $("body").data("baseurl"); win = $(window); topArrow = $("#top-arrow"); $("#hero-panel").tabs(); yepnope([ { test: Modernizr.input.placeholder, nope: baseUrl + "static/js/libs/jquery.placeholder.min.js", callback: function() { return $("#search-bar #q").placeholder(); } }, { test: $(".table").length > 0, yep: baseUrl + "static/js/libs/table2CSV/table2CSV.js" }, { test: $(".twitter-timeline").length > 0, yep: "//platform.twitter.com/widgets.js" }, { test: $("#register-form,.validate-form,.enable-chzn").length > 0, yep: baseUrl + "static/js/forms.js", callback: function() { return $(function() { $.metadata.setType("html5"); $("#register-form,.validate-form").each(function() { return $(this).validate({ meta: "validate" }); }); return $('.enable-chzn').chosen(); }); } } ]); if ((navigator.userAgent.match(/iPad/i) === null) && ($("#can-annotate").length === 1)) { LOG("anotations"); yepnope([ { test: window.JSON, nope: "" + baseUrl + "static/js/libs/JSON.js" }, { test: window.getSelection, nope: "" + baseUrl + "static/js/libs/annotateit/iefix.js" }, { test: (navigator.userAgent.match(/iPad/i) === null) && ($("#can-annotate").length === 1), yep: "" + baseUrl + "static/js/libs/annotateit/annotator-full.js", callback: function() { return $(function() { if (!isMob()) { return createInteractiveGraphCopyButtons(); } }); } } ]); } $('graphobject[sipp2\\:functionality="NONE"]').parent().find('.interactive-graph-toggle-outer').remove(); $('.interactive-graph-toggle-btn').on('click', function(e) { var $btn, go, graph, mediaobject, wrap; $btn = $(this); wrap = $btn.parent(); graph = wrap.next(); mediaobject = $btn.closest('.mediaobject'); go = once(function() { new Graph(graph); wrap.remove(); return mediaobject.css('display', 'block'); }); if (!(typeof Graph !== "undefined" && Graph !== null)) { return yepnope({ load: { raph: baseUrl + "static/js/libs/raphael-2.0.2.js", graph: baseUrl + "static/js/graph.coffee.js" }, callback: { graph: go } }); } else { return go(); } }); $('#q').autocomplete({ source: function(request, response) { $.getJSON(baseUrl + '/autocomplete?', { term: request.term }, function(data) { response(data); }); }, minLength: 2, focus: function(event, ui) { if (ui.item.source !== 'dictionary') { $(this).val(''); event.preventDefault(); } }, select: function(event, ui) { event.preventDefault(); if (ui.item.uri && ui.item.uri !== '') { window.location.href = ui.item.uri; } }, open: function(event, ui) { return $('.ui-menu-title').removeClass('ui-menu-item'); } }).data('ui-autocomplete')._renderItem = function(ul, item) { var isTitle, resultItem; resultItem = ''; isTitle = false; if (item.uri && item.uri !== '') { if (item.source === 'dictionary') { resultItem += '' + item.label; } else { resultItem += '' + item.label; } } else { resultItem += '' + item.label + ''; isTitle = true; } if (item.type && item.type !== '') { resultItem += ', ' + item.type + ''; } if (item.source && item.source !== '' && item.source !== 'title' && item.source !== 'dictionary') { resultItem += '
' + item.source + ''; } resultItem += ''; if (isTitle) { return $('
  • ').data('ui-autocomplete-item', item).append(resultItem).appendTo(ul); } else { return $('
  • ').data('ui-autocomplete-item', item).append(resultItem).appendTo(ul); } }; $("#n-signin a, #entry-signin, #entry-signout, #n-personalise a, .btn-login").colorbox({ inline: true, width: 300, height: 500, close: "×" }); $('.lightbox').colorbox({ inline: true, width: 300, height: 410, close: "×", onComplete: function() { var form; form = $('form[action$="loginP13n"]'); return form.on('keypress', 'input', function(e) { if (e.keyCode === 13) { return form.submit(); } }); } }); $("a.download-button").colorbox({ inline: true, width: isMob() ? window.innerWidth : 640, close: "×" }); $(".download-button").on("click", function(e) { var downloadUrl; e.preventDefault(); downloadUrl = $(this).attr('data-download-link'); return $("#download-panel-form").attr("action", downloadUrl); }); $("#has-email").on("change", function(e) { if ($(this).is(":checked")) { $(".email-update-section").show(); } else { $(".email-update-section").hide(); } return $.colorbox.resize(); }); $("#n-signout a, a.signout").colorbox({ inline: true, width: 300, height: 200, close: "×" }, $('.popup-help-panel').live("click", function(e) { if (!$('body').hasClass('fragr-enabled')) { e.preventDefault(); return $(this).colorbox({ open: true, href: function() { return $(this).attr("href") + " .popup-help-panel-content"; }, width: isMob() ? window.innerWidth - 50 : 700, height: isMob() ? "" : 600, close: "×" }); } })); if ($('body').hasClass('page-entry') && ($('#p13n-error').length > 0)) { $('body').append('
    Your log in attempt has failed, try again?
    ').addClass('display-warning'); } regLink = $('#register-lightbox,.register-lightbox'); ln = "" + (regLink.attr('href')) + " #actual-form"; if (!isMob()) { regLink.live("click", function(e) { e.preventDefault(); return $(this).colorbox({ open: true, href: ln, width: 760, close: "×", onComplete: function() { return yepnope({ load: baseUrl + "static/js/forms.js", callback: function() { return $(function() { $.metadata.setType("html5"); return $("#register-form,.validate-form").validate({ meta: "validate" }); }); } }); } }); }); } $('.close-cbox').on('click', function(e) { e.preventDefault(); return $.colorbox.close(); }); $(".content a").map(function(i, el) { var $el; $el = $(el); return $el.attr("href", el.href); }); $(".opt-print").not(".opt-login").click(function(e) { e.preventDefault(); if (window.annotations && confirm("We need to turn annotations off to print this page in your browser. Would you like to continue?\n\n(Selecting OK will turn Annotations off and you will need to select Print again)")) { enableAnnotations(false); } if (!window.annotations) { return window.print(); } }); lbls = { POST: ['createLabelForItem', '+'], DELETE: ['deleteLabel', '-'] }; popupContent = $('.popup-help-panels-content'); entryLabels = $(".lbl-form input[type=checkbox]").live('click', function(e) { var $this, action, checkbox, checked, form, form2, hidden, hidden2, method, promise, _this = this; e.preventDefault(); $this = $(this); checkbox = $('#' + this.id, popupContent); checked = $this.is(':checked'); form = checkbox.closest('form'); form2 = $(this).closest('form'); action = form.get(0).action; hidden = $('[name=_method]', form); hidden2 = $('[name=_method]', form2); method = hidden.val(); return promise = $.ajax({ type: method, url: action }).success(function() { var a, key, new_method, new_path, new_sign, old_path, old_sign, val; alert('Label applied/updated/removed.'); for (key in lbls) { val = lbls[key]; if (key !== method) { new_method = key; new_path = val[0]; new_sign = val[1]; } else { old_path = val[0]; old_sign = val[1]; } } a = form[0].action.replace(old_path, new_path); form[0].action = a; form2[0].action = a; hidden.val(new_method); hidden2.val(new_method); checkbox.attr('checked', checked); return $this.attr('checked', checked); }); }); $('.rem-label').click(function(e) { var _this = this; e.preventDefault(); if (!confirm('Are you sure you would like to remove this label?')) { return false; } return $.post(this.action, { serializedSearch: $(this).find('[type=hidden]').val() }).success(function() { return window.location = '/youraccount/retrieveAllLabels'; }); }); starredList = $('body').hasClass("page-starred-items"); $('.star').on('click', function(e) { var h, t, t2, u, _this = this; e.preventDefault(); h = $(this).attr('href'); t = $(this).data('title'); t2 = $(this).data('undotitle'); u = $(this).data('undouri'); return $.get(h).success(function() { var o; $(_this).toggleClass('selected'); $(_this).attr('href', u); $(_this).data('title', t2); $(_this).data('undotitle', t); $(_this).data('undouri', h); if (starredList && !($(_this).hasClass('selected'))) { $(_this).closest('.result-item').hide("slow"); } if ($(_this).data("bs") != null) { o = $(_this).data("bs"); o.title = t2; $(_this).popover("destroy"); return $(_this).popover(o); } }); }); $("#annotation-tabs").tabs(); remove_stars = $('#remove-all-stars').on("click", function(e) { e.preventDefault(); if (!confirm('Are you sure you would like to remove every starred item?')) { return; } $('.star.selected').click(); $('#source .starred-items-link').text('Starred items (0)'); return $('#main').append('

    You have no starred items.

    '); }); remove_searches = $('#remove-all-searches').on("click", function(e) { e.preventDefault(); if (!confirm('Are you sure you would like to remove all saved searches?')) { return; } $('.rem-saved-search').click(); $('#source .saved-searches-link').text('Saved searches (0)'); return $('#main').append('

    You have no saved searches.

    '); }); $('.del-search').on("submit", function(e) { var _this = this; e.preventDefault(); return $.post(this.action, { serializedSearch: $(this).find('[type=hidden]').val() }).success(function() { return $(_this).closest('tr').hide("slow", function() { return $(this).remove(); }); }); }); $('.save-form').on("submit", function(e) { var _this = this; e.preventDefault(); return $.post(this.action, $(this).serialize()).success(function() { return window.location = window.location; }); }); lightbox_img = function(img) { var conf, hide, imgTag, lightboxWrapper, show, title; if ($(img).hasClass('ae-graph-img')) { return; } if ($(img).width() > 570) { imgTag = $("magnify-glass").css({ opacity: 0.3 }); conf = { href: img.src, initialWidth: $(img).data('width') || img.width, initialHeight: $(img).data('height') || img.height, innerWidth: Math.round(($(img).data('width') || img.width) * 1.25), innerHeight: Math.round(($(img).data('height') || img.height) * 1.25), scalePhotos: true, photo: true, close: "To close this image, press ESC or click here" }; lightboxWrapper = $(img).wrap("
    ").parent(); lightboxWrapper.colorbox(conf); title = lightboxWrapper.closest('.figure').next('.title'); if (title.length) { imgTag.appendTo(title).colorbox(conf); } else { lightboxWrapper.append(imgTag); } $(img).addClass("magnify fix-width"); show = function() { return imgTag.css({ opacity: 1 }); }; hide = function() { return imgTag.css({ opacity: .3 }); }; $(img).hover(show, hide); return imgTag.hover(show, hide); } }; if (!isMob()) { createCurrMapCopyButtons(); createVideoCopyButtons(); if (!((navigator.userAgent.match(/iPad/i) === null) && ($("#can-annotate").length === 1))) { createInteractiveGraphCopyButtons(); } } _ref = $(".content img"); for (_i = 0, _len = _ref.length; _i < _len; _i++) { img = _ref[_i]; if ($(img).next().is("graphobject")) { continue; } if (img.complete != null) { lightbox_img(img); } else { $(img).load(function() { return lightbox_img(img); }); } } topArrow.hide(); win.scroll(onceAfter(250, function() { if (win.scrollTop() > 50) { return topArrow.show(); } else { return topArrow.hide(); } })); topArrow.find('a').on('click', function(e) { e.preventDefault(); return $('html,body').animate({ scrollTop: 0 }, 250); }); if (isMob()) { mobileReady(); $("#masthead .dd").click(function(e) { var $i, $this, $ul; e.preventDefault(); $this = $(this); $ul = $this.next("ul").toggle(); $i = $this.find("i"); return $i.html(($ul.is(":visible") ? "▲" : "▼")); }); $('.m-jumpto').css('visibility', 'visible'); $("#supplimental-jumpto").change(function(e) { return window.location = $(this).val(); }); } else { createFloatingToc(); } oldIE() && $(".curr-map tbody tr:even").addClass("even"); loadTables(); $('.folder').on("click", function(e) { var li, link, req, subj; li = $(this).parent(); li.toggleClass("ft-open"); link = $('a', this).attr("href"); subj = decodeURIComponent(link.split("subject=")[1].split("&")[0].replace(/\+/g, ' ')); return req = $.get("" + baseUrl + "set-subject-expanded", { subject: subj, expanded: li.hasClass("ft-open") }); }); $(".filetree,.other-tree").on("click", ".more-link,.less-link", function(e) { var id, req, tree; e.preventDefault(); tree = $(this).closest(".hiddentree"); tree.toggleClass("viewing-more"); id = tree[0].id; return req = $.get("" + baseUrl + "set-filter-more", { filter: id, expanded: tree.hasClass("viewing-more") }); }); if (oldIE()) { $('.filetree li:nth-child(n+6)').not('.more-li,.less-li').addClass('filetree-toggle'); } getParameterByName = function(name) { var regex, regexS, results; name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); regexS = "[\\?&]" + name + "=([^&#]*)"; regex = new RegExp(regexS); results = regex.exec(window.location.search); if (results == null) { return ""; } else { return decodeURIComponent(results[1].replace(/\+/g, " ")); } }; searchTerm = getParameterByName("q"); if (searchTerm) { $(".article").highlight(searchTerm.replace(/\"/g, "")); } $('.email-alert').on("click", function(e) { var $this, checked, d, form, req, searchAlert, url; e.preventDefault(); $this = $(this); form = $this.parent(); searchAlert = $('[name=searchAlert]', form); checked = $this.is(":checked"); url = form.attr("action"); d = form.serialize(); req = $.post(url, d); return req.success(function() { var msg, nope_msg, yep_msg; yep_msg = 'You will now be notified by email whenever the content for this search changes in the future.'; nope_msg = 'Email alerts have now been turned off for this search.'; if (checked) { msg = yep_msg; } else { msg = nope_msg; } alert(msg); $this.attr("checked", checked); return searchAlert.val(checked ? "" : "on"); }); }); err = $("#errLabelName"); checkExistingLabels = function(lbl) { var b; lbls = $('.label-link'); b = false; lbls.each(function(i, el) { if ($(el).text().toLowerCase() === lbl.toLowerCase()) { return b = true; } }); return b; }; createFormLabel = $("#f-create-label").on("submit", function(e) { var lbl, lblv; e.preventDefault(); lbl = $("#labelName"); lblv = lbl.val(); if (lblv === null) { lblv = ""; } else { lblv = lblv.replace(/^\s+|\s+$/g, ""); } lbl.val(lblv); if (lblv.length === 0) { err.text("Please enter a label"); return; } if (checkExistingLabels(lblv)) { err.text("That label has already been added"); return; } if (lblv.indexOf('/') !== -1) { err.text("Labels cannot contain slashes"); return; } err.text(""); createFormLabel.attr("action", createFormLabel.attr("action") + lblv); return createFormLabel.get(0).submit(); }); checkExistingRenameLabels = function(lbl) { var b; lbls = $('.label-link'); b = false; lbls.each(function() { if ($(this).attr("id").toLowerCase() === lbl.toLowerCase()) { return b = true; } }); return b; }; createFormRenameLabel = $("#rename-label-form-ya").on("submit", function(e) { var lbl, lblv; e.preventDefault(); lbl = $("#newLabelName"); lblv = lbl.val(); if (lblv === null) { lblv = ""; } else { lblv = lblv.replace(/^\s+|\s+$/g, ""); } lbl.val(lblv); if (lblv.length === 0) { err.text("Please enter a label"); return; } if (checkExistingRenameLabels(lblv)) { err.text("That label has already been added"); return; } err.text(""); return createFormRenameLabel.get(0).submit(); }); $('#annotations-on').click(function(e) { e.preventDefault(); return enableAnnotations(false); }); $('#annotations-off').click(function(e) { e.preventDefault(); return enableAnnotations(true); }); enableAnnotations = function(enabled) { return $.post('/youraccount/enableAnnotations', { 'enabled': enabled }).success(function() { return location.reload(); }); }; scrollToAnnotation = function() { var index, lastIndex, quote, url; url = '' + unescape(decodeURIComponent(window.location)); index = url.indexOf('?quote='); lastIndex = url.indexOf(" ", index); quote = '' + url.substring(index + 7, lastIndex); return setTimeout(function() { return $('.annotator-hl').each(function() { var html, match; html = '' + this.innerHTML; match = html.indexOf(quote) !== -1; if (match) { return $("html,body").animate({ scrollTop: $(this).offset().top }, "slow"); } }); }, 2000); }; scrollAll = function() { return scrollToAnnotation(); }; scrollAll(); marcFrom = $("#date-from.datepicker").datepicker({ onSelect: function(selectedDate) { return marcTo.datepicker("option", "minDate", selectedDate); } }); marcTo = $("#date-to.datepicker").datepicker({ onSelect: function(selectedDate) { return marcFrom.datepicker("option", "maxDate", selectedDate); } }); $('#n-signin').click(function() { return setTimeout(function() { return $('#sgkLoginForm *:input[type!=hidden]:first').focus(); }, 500); }); if ($("#hide-search-filter").length === 1) { $("#featured").hide(); } $('.table-wrapper,.informaltable-wrapper').each(function() { if (this.scrollWidth > this.clientWidth || $(this).find('img[data-width]').length > 0) { $(this).addClass('new-win-btn'); $(this).after(''); return $(this.nextSibling).click({ table: this }, function(event) { var html, newdoc, table, title; table = $(event.data.table).clone(); table.find('.table_controls').remove(); title = $(table).find('div.title').text(); newdoc = window.open().document; html = "" + title + ""; $('link[rel="stylesheet"]').each(function() { return html += ""; }); html += ""; html += "
    " + (table.html().replace(/width=/g, 'w=').replace(/height=/g, 'h=')) + "
    "; return newdoc.writeln(html); }); } }); popoverShowing = false; popupHelpPanels = $('#options a.opt-label,.entry-article-head .star'); popupHelpPanels.each(function(i, el) { var o; o = { trigger: "manual", placement: "bottom", html: true, content: function() { var content; content = $('#' + $(this).data('contentid')).html(); if ($.trim(content) !== "") { content = "
    " + content + "
    "; } return "" + content; } }; $(el).popover(o); return $(el).data("bs", o); }); popupHelpPanels.hover(function() { var popover; if (isMob() && $('body').hasClass('personalized') && ($(this).hasClass('star') || $(this).hasClass('pdf-download') || $(this).hasClass('opt-print'))) { return; } $('.popover').remove(); $(this).popover('show'); popoverShowing = true; popover = $('.popover'); return popover.hover(function() { return popoverShowing = true; }, function() { popoverShowing = false; return $('.popover').remove(); }); }, function() { var _this = this; popoverShowing = false; return setTimeout(function() { if (!popoverShowing) { return $(_this).popover('hide'); } }, 250); }); $('.popup-lightbox').live("click", function(e) { e.preventDefault(); return $.colorbox({ href: "#p13n-login-panel", inline: true, open: true, width: 300, height: 410, close: "×" }); }); $('.pdf-download').on("click", function(e) { e.preventDefault(); return $('#pdf-download-form').submit(); }); /* troubleshooter */ javaScript = document.getElementById('js-status'); browserSizeSpan = void 0; screenResolutionSpan = void 0; getBrowserDimensions = function() { var height, width; height = $(window).height(); width = $(window).width(); return [width, height]; }; getScreenResolution = function() { var height, width; height = screen.height; width = screen.width; return [width, height]; }; appendDimensions = function() { var browserDimensions, browserHeight, browserWidth, screenHeight, screenResolution, screenWidth; if (browserSizeSpan) { browserDimensions = getBrowserDimensions(); browserWidth = browserDimensions[0]; browserHeight = browserDimensions[1]; browserSizeSpan.value = browserWidth + ' x ' + browserHeight; } if (screenResolutionSpan) { screenResolution = getScreenResolution(); screenWidth = screenResolution[0]; screenHeight = screenResolution[1]; screenResolutionSpan.value = screenWidth + ' x ' + screenHeight; } }; checkCookie = function() { var ret; document.cookie = 'cookietest=1'; ret = document.cookie.indexOf('cookietest=') !== -1; document.cookie = 'cookietest=1; expires=Thu, 01-Jan-1970 00:00:01 GMT'; return ret; }; check = checkCookie(); if (javaScript) { $('#js-status-value').removeAttr('hidden'); $('#js-browser-size-value').removeAttr('hidden'); $('#js-screen-resolution-value').removeAttr('hidden'); $('#js-flash-value').removeAttr('hidden'); $('#js-cookies-value').removeAttr('hidden'); $('#js-status-value').attr('value', 'Enabled'); cookies = document.getElementById('js-cookies-value'); flash = document.getElementById('js-flash-value'); browserSizeSpan = document.getElementById('js-browser-size-value'); screenResolutionSpan = document.getElementById('js-screen-resolution-value'); if (check) { cookies.value = "Enabled"; } else { cookies.value = "Disabled"; } if (flash) { yepnope({ load: "static/js/libs/flash-detect.js", callback: function() { var flashDetectParser; flashDetectParser = new FlashDetect; if (!flashDetectParser.installed) { flash.value = 'Disabled'; } else { flash.value = flashDetectParser.major; } } }); } } appendDimensions(); waypointObj = document.getElementById('js-scroll-trigger'); waypointObjFooter = document.getElementById('page-footer-container'); if (waypointObj && waypointObjFooter) { if ($('.content').height() > $('.js-page-contents').height() && $('.toc li').length > 3) { yepnope({ load: baseUrl + "static/js/libs/waypoint.js", callback: function() { var waypoint; waypoint = new Waypoint({ element: waypointObj, handler: function(direction) { if (direction === 'down') { $('.js-page-contents').addClass('pos-fixed'); } else { $('.js-page-contents').removeClass('pos-fixed'); } } }); waypoint = new Waypoint({ element: waypointObjFooter, handler: function(direction) { if (direction === 'down') { $('.js-page-contents').addClass('pos-ab'); } else { $('.js-page-contents').removeClass('pos-ab'); } }, offset: '100%' }); } }); } } $(window).on('resize', function() { appendDimensions(); }); }; $(aeReady); }).call(this);