').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 = $("").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 += "