Created
January 29, 2016 17:28
-
-
Save jdcauley/18b3b6586a736a33b20a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function(e) { | |
function t(e) { | |
var t = document.getElementById(e); | |
if (t) { | |
for (var a = t.getElementsByTagName("li"), i = [], s = 0; s < a.length; s++) i.push({ | |
country: a[s].textContent, | |
item: a[s] | |
}); | |
i.sort(function(e, t) { | |
var a = e.country, | |
i = t.country; | |
return a.localeCompare(i) | |
}); | |
for (var n = 0; n < i.length; n++) t.appendChild(i[n].item) | |
} | |
} | |
function a(e) { | |
return e.sort(function(e, t) { | |
var a = e.gsx$country.$t, | |
i = t.gsx$country.$t; | |
return a.localeCompare(i) | |
}), e | |
} | |
function i(e) { | |
var t = e.toLowerCase().trim().replace(/\s+/g, ""); | |
return t | |
} | |
function s() { | |
if (e(".map").toggleClass("map-fade"), e(".site-list, .map-toggle").toggleClass("invisible"), e(g).toggleClass("invisible"), e("html, body").animate({ | |
scrollTop: 0 | |
}, "fast"), e("#info.info, #info-mobile.info-mobile").removeClass("open"), e(g).removeClass("invisible"), e(".intro-text .map-toggle").removeClass("invisible"), e(".browse-toggle").toggleClass("invisible"), e("#info.info .sidebar-section-title-map, .site-filters").addClass("invisible"), isMobile()) { | |
var t = e(this); | |
t.toggleClass("expanded"), t.html(t.hasClass("expanded") ? "HIDE LIST" : "BROWSE IN LIST") | |
} else { | |
var a = e(this); | |
a.toggleClass("expanded"), a.html(a.hasClass("expanded") ? "BROWSE IN MAP" : "BROWSE IN LIST") | |
} | |
} | |
function n() { | |
e(g).toggleClass("invisible"), e("#info.info, #info-mobile.info-mobile").removeClass("open"), e(".site-list").css("height", "110%"), e("html, body").css("height", "auto"), e(".sidebar-content-wrapper").show() | |
} | |
function o(e) { | |
if (e) { | |
var t = '<img class="factsite-logo" src="' + e + '">'; | |
return t | |
} | |
return "" | |
} | |
function l(e) { | |
if (e) { | |
var t = '<h4 class="site-label">AFFILIATED WITH</h4><p>' + e + "</p>"; | |
return t | |
} | |
return "" | |
} | |
function r(e) { | |
if (e) { | |
var t = '<h4 class="site-label">RATING SYSTEM</h4><p>' + e + "</p>"; | |
return t | |
} | |
return "" | |
} | |
function c() { | |
var t = this.siteData; | |
e(".leaflet-marker-icon").removeClass("active-marker"), e(this._icon).addClass("active-marker"), u.panTo([t.lat, t.lng]); | |
var a = '<h2 class="sidebar-section-title-map">GLOBAL<br />FACT-CHECKING SITES</h2><div><a class="view-all back-toggle">BACK</a><h3 class="site-name"><a href="' + t.url + '" target="_blank" />' + t.siteName + '</h3><a href="' + t.url + '" target="_blank">' + o(t.logo) + '</a><p class="site-url"><a href="' + t.url + '" target="_blank">' + t.url + "</a></p><p>" + t.country + "</p><p>" + t.state + "</p>" + l(t.affiliated) + "<p>" + t.active + '</p><h4 class="site-label">STRUCTURE & FUNDING</h4><p>' + t.structure + "</p>" + r(t.rating) + "</div>"; | |
isMobile() ? (d.innerHTML = a, e(".sidebar-outer").hide()) : m.innerHTML = a, e("#info.info, #info-mobile.info-mobile").addClass("open"), e(g).addClass("invisible"), e(".sidebar-section-title-map").removeClass("invisible"), e(".browse-toggle").addClass("invisible"), e(".sidebar-content-wrapper").hide(), e(".view-all").on("click", n), e("html, body").animate({ | |
scrollTop: 0 | |
}, "fast"), isMobile() && infoPaneSizer() | |
} | |
var g = ".intro-text, .post-image, .sidebar-section-title, .logo-int, .sidebar-footer"; | |
e("body").hasClass("page-template-template-purchase-php") && (alphabatizeMenu("europe"), alphabatizeMenu("north-america"), alphabatizeMenu("south-america"), alphabatizeMenu("asia"), alphabatizeMenu("africa")), e(".map-toggle").on("click", s), L.mapbox.accessToken = "pk.eyJ1Ijoibm9tYWNvcmMiLCJhIjoiUDlBLUZEWSJ9.AssshWcTyDzRVIJE-x3P6A"; | |
var m = document.getElementById("info"), | |
d = document.getElementById("info-mobile"), | |
u = new L.mapbox.map("map", "doctoropolis.0134d7a3", { | |
tileLayer: { | |
detectRetina: !0, | |
minZoom: 4, | |
maxZoom: 10 | |
}, | |
worldCopyJump: !0 | |
}).setView([19.159882, -80.188477], 4), | |
p = L.icon({ | |
iconUrl: "../wp-content/themes/reporters/assets/img/icon-marker.png", | |
iconRetinaUrl: "../wp-content/themes/reporters/assets/img/[email protected]", | |
iconSize: [53, 52], | |
iconAnchor: [14, 51], | |
popupAnchor: [0, -40], | |
shadowSize: [0, 0], | |
shadowAnchor: [22, 94], | |
reuseTiles: !0 | |
}); | |
u.scrollWheelZoom.disable(); | |
var f = "https://spreadsheets.google.com/feeds/list/0AhoyrEbZxrAMdDU2RTNlTmUtajFXcVMyVXJHdVRDUnc/1/public/values?alt=json"; | |
e.getJSON(f, function(t) { | |
for (var s = a(t.feed.entry), n = 0; n < s.length; n++) { | |
var o = { | |
continent: s[n].gsx$continent.$t, | |
country: s[n].gsx$country.$t, | |
city: s[n].gsx$city.$t, | |
state: s[n].gsx$state.$t, | |
siteName: s[n].gsx$name.$t, | |
staff: s[n].gsx$totalstaff.$t, | |
structure: s[n].gsx$structureandfunding.$t, | |
active: s[n].gsx$active.$t, | |
url: s[n].gsx$url.$t, | |
lat: s[n].gsx$latitude.$t, | |
lng: s[n].gsx$longitude.$t, | |
affiliated: s[n].gsx$affiliatedwithnewsorganization.$t, | |
rating: s[n].gsx$ratingsystem.$t, | |
logo: s[n].gsx$logo.$t | |
}; | |
if (s[n].gsx$latitude.$t && s[n].gsx$longitude.$t) { | |
var l = L.marker([s[n].gsx$latitude.$t, s[n].gsx$longitude.$t], { | |
icon: p | |
}).addTo(u); | |
l.siteData = o, l.on("click", c).addTo(u); | |
var r = document.createElement("li"); | |
r.siteData = o, r.innerHTML = s[n].gsx$name.$t, r.addEventListener("click", c, !1); | |
var g = i(s[n].gsx$continent.$t), | |
m = i(s[n].gsx$country.$t), | |
d = document.getElementById("js-" + g); | |
if (d) { | |
var f = document.getElementById("js-the-" + m); | |
if (f) e(r).appendTo(f); | |
else { | |
var h = document.createElement("ul"); | |
h.id = "js-the-" + m, h.className = "country-list", e(h).appendTo("#js-" + g); | |
var b = (document.getElementById(g + "-title"), document.createElement("h3")); | |
b.className = "country-title", b.innerHTML = s[n].gsx$country.$t, e(b).appendTo("#js-the-" + m), e(r).appendTo(h) | |
} | |
} | |
} | |
} | |
}).done(function() { | |
e(".country-list").each(function() { | |
var a = e(this).attr("id"); | |
t(a) | |
}) | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment