function removeHash(){ var scrollV, scrollH, loc = window.location; if ("replaceState" in history) history.replaceState("", document.title, loc.pathname + loc.search); else { // Prevent scrolling by storing the page's current scroll offset scrollV = document.body.scrollTop; scrollH = document.body.scrollLeft; loc.hash = ""; // Restore the scroll offset, should be flicker free document.body.scrollTop = scrollV; document.body.scrollLeft = scrollH; } } /* test edit */ function isEmail(address) { address = typeof address !== 'undefined' ? address : ""; var pos = address.lastIndexOf("@"); return pos > 0 && (address.lastIndexOf(".") > pos) && (address.length - pos > 4); } function createCookie(name, value, days) { var expires; if (days) { var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); expires = "; expires=" + date.toGMTString(); } else { expires = ""; } document.cookie = encodeURIComponent(name) + "=" + encodeURIComponent(value) + expires + "; path=/"; } function readCookie(name) { var nameEQ = encodeURIComponent(name) + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) === ' ') c = c.substring(1, c.length); if (c.indexOf(nameEQ) === 0) return decodeURIComponent(c.substring(nameEQ.length, c.length)); } return null; } function eraseCookie(name) { createCookie(name, "", -1); } function osf_pad_time(digit) { digit = String(digit); if (digit.length == 1) { digit = '0' + digit; } return digit; } function osf_format_time(duration) { var formatted_time = ""; var hours = Math.floor(duration / 3600); var mins = Math.floor((duration - (hours * 3600)) / 60); var secs = Math.floor((duration - (hours * 3600) - (mins * 60))); if (hours) { formatted_time = hours + ':' + osf_pad_time(mins) + ':' + osf_pad_time(secs); } else if (mins | secs) { formatted_time = mins + ':' + osf_pad_time(secs); } return formatted_time; } function test_a_or_b(){ var abtest = new Array(); abtest[0] = 'A'; abtest[1] = 'B'; var whichtest=Math.floor(Math.random()*(abtest.length)); return abtest[whichtest]; } if (typeof String.prototype.startsWith != 'function') { String.prototype.startsWith = function (str){ return this.slice(0, str.length) == str; }; } if (typeof String.prototype.endsWith != 'function') { String.prototype.endsWith = function(searchString, position) { var subjectString = this.toString(); if (position === undefined || position > subjectString.length) { position = subjectString.length; } position -= searchString.length; var lastIndex = subjectString.indexOf(searchString, position); return lastIndex !== -1 && lastIndex === position; }; } if (typeof String.prototype.capitalizeFirstLetter != 'function') { String.prototype.capitalizeFirstLetter = function() { return this.charAt(0).toUpperCase() + this.slice(1); } } function extractParamFromUri(uri, paramName) { if (!uri) { return; } var regex = new RegExp('[\\?]' + paramName + '=([^]*)'); var params = regex.exec(uri); if (params != null) { return unescape(params[1]); } return; } function get_bitly_url(long_url){ var short_url = ''; var bityurl = "https://api-ssl.bitly.com/v3/shorten"; jQuery.ajax({ url: bityurl, dataType: 'json', data: { "access_token": "5874f408c9a6900323ea3b13a5a4f3a59073a748", "longUrl": long_url }, cache: true }) .done(function(data) { var short_url = data.data.url; jQuery('button.social-twitter').attr('data-short-url', short_url); return short_url; }) .fail(function( jqxhr, textStatus, error ) { var err = textStatus + ', ' + error; console.log( "Request bit.ly url failed: " + err); }); } function trim(stringToTrim) { return stringToTrim.replace(/^\s+|\s+$/g,""); } function encodeURIpretty(s) { var pretty_uri = s; pretty_uri = pretty_uri.split(' ').join('-'); pretty_uri = pretty_uri.replace('&', 'and'); pretty_uri = pretty_uri.replace(/[^a-z0-9-]/gi,'').toLowerCase(); pretty_uri = encodeURIComponent(pretty_uri); return pretty_uri; } function setIFrameSrc(id, url) { var originalFrame = document.getElementById(id); var newFrame = document.createElement("iframe"); newFrame.id = originalFrame.getAttribute("id"); newFrame.frameborder = 0; newFrame.allowfullscreen = ''; newFrame.src = url; var parent = originalFrame.parentNode; parent.replaceChild(newFrame, originalFrame); } function get_prod_url(){ var full_url = 'https://www.opensocietyfoundations.org' + window.location.pathname; return full_url; } function get_prod_url_ssl(){ var full_url = 'https://www.opensocietyfoundations.org' + window.location.pathname; return full_url; } // generic add to segment routine function subscribe_email_segment(mid, segment) { var dataString = 'mid=' + encodeURIComponent(mid) + '&segment=' + encodeURIComponent(segment); jQuery.ajax({ type: "POST", context: this, url: "//apps.opensocietyfoundations.org/subscribe_super/", data: dataString, success: function(data) { console.log('Subscribed to ' + segment); }, error: function(xhr,err){ console.log("readyState: "+xhr.readyState+"\nstatus: "+xhr.status); console.log(xhr.responseText); } }); return false; } // Add to segment if subscriber is on Roma or Drug Policy content function add_to_email_segment(){ var subscriber_mid = readCookie('email_subscriber'); if(subscriber_mid) { var $content_topics = jQuery(".group_learn_more .field-type-taxonomy-term-reference"); if($content_topics.length){ $content_topics.each(function( index ) { var content_topic = jQuery(this).text(); if(jQuery.inArray(content_topic, ['Roma']) != -1) { subscribe_email_segment(subscriber_mid, 'roma'); } if(jQuery.inArray(content_topic, ['Drug Policy Reform', 'Harm Reduction', 'Drug Policy Reform in the United States']) != -1) { subscribe_email_segment(subscriber_mid, 'drug_policy'); } }) } } } /** * Wrapping function for ga social events so we can debug */ function gaTrackSocial(aCat, aAct, aFile) { if (typeof ga != "undefined"){ ga('send', 'social', aCat, aAct, aFile); } else { console.log("ga('send', 'social', '" + aCat + "', '" + aAct + "', '" + aFile + "'"); } } /** * Wrapping function for ga events so we can debug */ function gaTrackEvent(aCat, aAct, aFile, nonInteraction) { nonInteraction = typeof nonInteraction !== 'undefined' ? 1 : 0; aFile = typeof aFile !== 'undefined' ? aFile : "0"; aAct = typeof aAct !== 'undefined' ? aAct : "0"; if (typeof ga != "undefined"){ ga('send', { 'hitType': 'event', 'eventCategory': aCat.toString(), 'eventAction': aAct.toString(), 'eventLabel': aFile.toString(), 'nonInteraction': nonInteraction }); } else { console.log("ga('send', {'hitType': 'event', 'eventCategory': '" + aCat + "', 'eventAction': '" + aAct + "', 'eventLabel': '" + aFile + "', 'nonInteraction': " + nonInteraction + "});"); } } /** * Wrapping function for ga pageviews so we can debug */ function gaTrackPage(page_url) { page_url = typeof page_url === 'undefined' ? location.pathname : page_url; if (typeof ga != "undefined"){ ga('send', { 'hitType': 'pageview', 'page': page_url }); } else { console.log("ga('send', {'hitType': 'pageview', 'page': '" + page_url + "'});"); } } function trackOutboundLink(url) { if (typeof ga != "undefined"){ ga('send', 'event', 'outbound', 'click', url, {'hitCallback': function () { document.location = url; } }); } else { console.log("ga('send', 'event', 'outbound', 'click', '"+ url +"')"); setTimeout(function(){ document.location = url; }, 2000); } } // Extend contains: to be case-insensitive jQuery.expr[':'].contains = function(a, i, m) { return jQuery(a).text().toUpperCase() .indexOf(m[3].toUpperCase()) >= 0; }; // set up variable to hold scroll_depth toggle var osf_scroll_track = 1; // set up variable to hold our ab test toggle var abt = test_a_or_b(); jQuery(document).ready(function($){ // // MOVE BLOCKS AROUND // // Change social buttons if Hungarian $('body.osf_multilingual_hu button.social-facebook span.text-button-social').html(Drupal.t("Share")); $('body.osf_multilingual_hu button.social-linkedin span.text-button-social').html(Drupal.t("Share")); $('body.osf_multilingual_hu button.social-republish span.text-button-social').html(Drupal.t("Republish")); // Change Home link if Hungarian $('body.osf_multilingual_hu #section-header .branding').attr('href','/hu'); $('body.osf_multilingual_hu #section-footer a.logo').attr('href','/hu'); if (typeof enquire !== 'undefined' && !$('.osf_multilingual_hu').length) { // NAVBURGER SUBNAV if ($('.hamburger .menu').length) { $('.region-menu-inner .navigation').after('
'); $('.hamburger .menu').appendTo('#navburger-subnav'); enquire.register("screen and (min-width:680px)", { match: function(){ $('#navburger-subnav').hide(); }, unmatch: function(){ $('#navburger-subnav').show(); } }); } if ($('.more .menu').length) { $('.region-menu-inner .navigation').after(''); $('.more .menu').appendTo('#navburger-subnav'); enquire.register("screen and (min-width:680px)", { match: function(){ $('#navburger-subnav').hide(); }, unmatch: function(){ $('#navburger-subnav').show(); } }); } // NEWSLETTER SIGNUP BLOCK if (!$('.grants-landing').length) { // save newsletter signup placement (so we can put it back) var newsletterParent; newsletterParent = $('.entity-boxes-newsletter-box').parent(); // newsletter signup at mobile enquire.register("screen and (max-width:679px)", { setup: function(){ // add newsletter signup menu if ($('.entity-boxes-newsletter-box').length || $('.homepage-newsletter-block').length) { $('#zone-menu').after(''); } else { $('#toggle-signup-menu').remove(); } }, match: function(){ $('.entity-boxes-newsletter-box').appendTo('#zone-signup-menu'); $('.homepage-newsletter-block').appendTo('#zone-signup-menu'); } }); // newsletter signup at tablet (different pages behave differently // tablet on voices posts, events, publications, grants, (is that all?) move signup to title area if ($('.node-type-blog-entry').length || $('.node-type-work-product').length || $('.node-type-event').length || $('.node-type-grant').length || $('.node-type-section-front').length || $('.node-type-litigation').length || $('.node-type-news').length || $('.page-search').length || $('.page-termsearch').length || $('.node-type-profile.context-employment').length) { enquire.register("screen and (min-width:680px) and (max-width:819px)", { setup: function(){ $('.region-page-title-region .views-field-title').before(''); }, match: function(){ $('.entity-boxes-newsletter-box').prependTo('#signup-in-title'); $('.homepage-newsletter-block').appendTo('#zone-menu .region-menu-inner'); $('#zone-signup-menu').attr('style', ''); } }); // tablet on contact page } else if ($('.global-contact-page').length) { enquire.register("screen and (min-width:680px) and (max-width:819px)", { setup: function(){ $('.region-page-title-region .block-title').before(''); }, match: function(){ $('.entity-boxes-newsletter-box').prependTo('#signup-in-title'); $('#zone-signup-menu').attr('style', ''); } }); // tablet on work, writing ,appearances page } else if ($('.page-work-writing-appearances').length) { enquire.register("screen and (min-width:680px) and (max-width:819px)", { setup: function(){ $('#region-content .view-header').before(''); }, match: function(){ $('.entity-boxes-newsletter-box').prependTo('#signup-in-title'); $('#zone-signup-menu').attr('style', ''); } }); // tablet on everything else (landing, etc) } else { enquire.register("screen and (min-width:680px) and (max-width:819px)", { match: function(){ var parentsThatNeedPrepend = ['block-boxes-newsletter-general']; if (parentsThatNeedPrepend.indexOf(newsletterParent.attr('id')) !== false) { $('.entity-boxes-newsletter-box').prependTo(newsletterParent); } else { $('.entity-boxes-newsletter-box').appendTo(newsletterParent); } $('#zone-signup-menu').attr('style', ''); } }); } // newsletter signup at desktops enquire.register("screen and (min-width:820px)", { match: function(){ var parentsThatNeedPrepend = ['block-boxes-newsletter-general']; if (parentsThatNeedPrepend.indexOf(newsletterParent.attr('id')) !== false) { $('.entity-boxes-newsletter-box').prependTo(newsletterParent); } else { $('.entity-boxes-newsletter-box').appendTo(newsletterParent); } $('.homepage-newsletter-block').appendTo('#zone-menu .region-menu-inner'); $('#zone-signup-menu').attr('style', ''); } }); } // END NEWSLETTER SIGNUP BLOCK // SEARCH FIELD & SOCIAL ICONS enquire.register("screen and (max-width:679px)", { setup: function(){ // add search menu $('#zone-menu').after(''); }, match: function(){ $('#block-boxes-header-social').appendTo('#zone-menu'); $('#block-osf-search-global-site-search').prependTo('#zone-search-menu'); $('#block-boxes-global-language-title-en').prependTo('#region-branding .region-branding-inner'); }, unmatch: function(){ $('#block-boxes-header-social').prependTo('.region-user-first-inner'); $('#block-osf-search-global-site-search').prependTo('.region-user-first-inner'); $('#block-boxes-global-language-title-en').prependTo('.region-user-first-inner'); $('#zone-menu').attr('style', ''); $('#zone-search-menu').attr('style', ''); } }); // AUTHORS BLOCK if ($('#block-views-blog-blocks-block-3').length) { enquire.register("screen and (max-width:819px)", { setup: function(){ $('.group_learn_more').after(''); $('#block-boxes-newsletter-general').after(''); }, match: function(){ $('#block-views-blog-blocks-block-3').appendTo('#author-inline'); }, unmatch: function(){ $('#block-views-blog-blocks-block-3').appendTo($('#author-parent')); } }); } // GRANTS LANDING - CONNECT WITH US BLOCK if ($('.grants-landing .connect-with-us').length) { enquire.register("screen and (max-width:819px)", { match: function(){ $('.connect-with-us').prependTo('.region-sidebar-first-inner'); }, unmatch: function(){ $('.connect-with-us').prependTo($('.region-sidebar-second-inner')); } }); } // Hide Facebook Video player for small devices and show a message. if($('iframe[src^="https://www.facebook.com/plugins/video"]').length && $('.event-current').length){ enquire.register("screen and (max-width:679px)", { match: function(){ $('iframe[src^="https://www.facebook.com/plugins/video"]').hide(); $('.views-field-field-featured-media-free-form').css({'background-color':'#E7E7E7', 'position':'relative'}); $('.views-field-field-featured-media-free-form').prepend(''); }, unmatch: function(){ if($('.fb_live_message').length){ $('.fb_live_message').remove(); } $('iframe[src^="https://www.facebook.com/plugins/video"]').show(); $('.views-field-field-featured-media-free-form').css('background-color','#FFF'); } }); } } else if (typeof enquire !== 'undefined' && $('.osf_multilingual_hu').length) { // HUNGARIAN PAGES // SEARCH FIELD & SOCIAL ICONS enquire.register("screen and (max-width:679px)", { setup: function(){ // add search menu $('#zone-menu').after(''); }, match: function(){ $('#block-osf-search-global-site-search').prependTo('#zone-search-menu'); $('#block-boxes-global-languge-toggle').prependTo('#region-branding .region-branding-inner'); }, unmatch: function(){ $('#block-osf-search-global-site-search').prependTo('.region-user-first-inner'); $('#block-boxes-global-languge-toggle').prependTo('.region-user-first-inner'); $('#zone-search-menu').attr('style', ''); } }); } // // END MOVE BLOCKS AROUND // // lefthand nav menu flyout var leftmenulink = $('.sidebar-link'), leftwrap = $('#zone-content-wrapper'); leftmenulink.click(function() { leftwrap.toggleClass('active'); // Enable swipe navigation. $('#zone-content-wrapper.active').swipe( { swipeLeft:function(event, direction, distance, duration, fingerCount) { //console.log("You swiped " + direction ); leftwrap.removeClass('active'); }, fingers:'all', allowPageScroll:'vertical', threshold:20 // excludedElements:$.fn.swipe.defaults.excludedElements+", .rotator-pager" }); return false; }); // set cookie for email subscribers var utm_medium = extractParamFromUri(document.URL,'utm_medium'); var utm_medium = (typeof utm_medium !== 'undefined') ? utm_medium : null; var utm_content = extractParamFromUri(document.URL,'utm_content'); var utm_content = (typeof utm_content !== 'undefined') ? utm_content : null; var utm_campaign = extractParamFromUri(document.URL,'utm_campaign'); var utm_campaign = (typeof utm_campaign !== 'undefined') ? utm_campaign : null; if(utm_medium == 'email'){ createCookie('email_subscriber', utm_content, 365); } // if email_campaign cookie exists, compare with current campaign, // if these values are different we know this is their second visit and // we add them to super user segments on visit to super user topics var old_campaign = readCookie('email_campaign'); if(old_campaign && utm_campaign){ if(old_campaign != utm_campaign){ createCookie('email_campaign_repeat', utm_campaign, 365); } } else if(utm_campaign) { createCookie('email_campaign', utm_campaign, 365); } if ($(".block-boxes-page-tools").length) { var social_mobile_header = ''; $('header').prepend(social_mobile_header); //Use floating social header on mobile window.show_header = true; enquire.register("screen and (max-width:480px)", { match: function () { $(window).on("scroll.header", function() { if ($(this).scrollTop() > 50){ $('#social-mobile-header').addClass('mobile-header-show') if (window.show_header === true) { $('#social-mobile-header').trigger('mobileSocialHeader'); window.show_header = false; } } else { $('#social-mobile-header').removeClass('mobile-header-show'); } }); }, unmatch: function () { $(window).off("scroll.header"); $('#social-mobile-header').removeClass('mobile-header-show'); } }); } // show cookie notice to EU visitors. The cc (country code) meta tag is added by a CloudFlare worker if ($('meta[property=cc]').length) { var country_code = $('meta[property=cc]').attr("content"); var eu_country_codes = ['AT', 'BE', 'BG', 'CH', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HR', 'HU', 'IE', 'IS', 'IT', 'LI', 'LT', 'LU', 'LV', 'MT', 'NL', 'NO', 'PL', 'PT', 'RO', 'SI', 'SK', 'T1']; // T1 for Tor var eu_country = eu_country_codes.includes(country_code); if(eu_country & readCookie('shown_cookie_notice') != 1){ var privacy_notice_html = '' + ''; $('body').append(privacy_notice_html); $('.privacy-container').slideToggle(); $('.btn-close-main').click( function(event) { event.preventDefault(); createCookie('shown_cookie_notice','1',365); $('.privacy-container').slideToggle(); }); } } // email lightbox disabled if (($(".entity-boxes-newsletter-box").length || $("body.front").length) && 1==0) { // toggle display of newsletter signup box var show_email_lightbox = true; // dont' show email popup on Hungarian pages if (window.location.pathname.startsWith('/hu')) { var show_email_lightbox = false; } // add class to body to ease css targeting $("body").addClass("email-lightbox-signup"); // the html for our lightbox signup var email_lightbox_signup = '' + ''; // add box to body, but its hidden by default $('body').append(email_lightbox_signup); // when scrollin swap out some classes to make our // regular newsletter box and lightbox newsletter box toggle visibility $(window).on("scroll.newsletter", function() { if (show_email_lightbox) { var shown_email_lightbox = readCookie('shown_email_lightbox'); if (!shown_email_lightbox) { if ($(this).scrollTop() > 30){ $(".signup-overlay").addClass('signup-overlay-show').fadeIn('fast'); $(".entity-boxes-newsletter-box").addClass('entity-boxes-newsletter-box-hide'); } } } }); // add action to close box $('.email-lightbox-signup .signup-lightbox .close-email-lightbox').click( function(event) { event.preventDefault(); $(".signup-overlay").removeClass('signup-overlay-show').hide(); $(".entity-boxes-newsletter-box").removeClass('entity-boxes-newsletter-box-hide'); show_email_lightbox = false; createCookie('shown_email_lightbox','1',365); }); // add esc keypress $(document).keydown(function(e){ if (e.keyCode == 27) { if ($('.signup-lightbox').is(":visible")) { $('.email-lightbox-signup .signup-lightbox .close-email-lightbox').click(); } } }); $("form#signup-lightbox-form").one( "submit", function(event) { event.preventDefault(); var email = $("form#signup-lightbox-form #email").val(); var dataString = 'email=' + encodeURIComponent(email) + '&type=News' + '&welcome=1' + '&src=email_lightbox'; // disable submit button on click $(this).find(':submit').attr('disabled','disabled'); if(email && isEmail(email)) { $.ajax({ type: "GET", context: this, url: "//apps.opensocietyfoundations.org/subscribe/", data: dataString, success: function(data) { gaTrackPage('/email-updates-thank-you?lightbox=1'); $("form.#signup-lightbox-form, .signup-lightbox-instructions, .signup-welcome").fadeOut( function (event) { $(".signup-lightbox-thanks").fadeIn(); setTimeout(function() { $('.email-lightbox-signup .signup-lightbox .close-email-lightbox').click(); }, 2000); }); }, error: function(xhr,err){ console.log("readyState: "+xhr.readyState+"\nstatus: "+xhr.status); console.log(xhr.responseText); $(this).find(':submit').attr('disabled','enabled'); } }); } return false; }); } $("form#signup-campaign-form").on( "submit", function(event) { event.preventDefault(); var email = $("form#signup-campaign-form #email").val(); var campaign = $("form#signup-campaign-form #campaign").val(); var dataString = 'email=' + encodeURIComponent(email) + '&type=News' + '&welcome=1' + '&src=' + encodeURIComponent(campaign); function displayChange() { setTimeout(function () { $("#signup-lightbox-placeholder").fadeOut( function (event) { $("#signup-lightbox-thanks").fadeIn(); $('form#signup-campaign-form').trigger("reset"); $('form#signup-campaign-form').find(':submit').prop('disabled', false); }); }, 1750); } // disable submit button on click $(this).find(':submit').prop('disabled', true); if($("#signup-lightbox-thanks").is(":visible")){ $("#signup-lightbox-thanks").fadeOut( function (event) { $("#signup-lightbox-placeholder").fadeIn(); }); } else { $("#signup-lightbox-instructions").fadeOut( function (event) { $("#signup-lightbox-placeholder").fadeIn(); }); } if(email && isEmail(email)) { $.ajax({ type: "POST", context: this, url: "//apps.opensocietyfoundations.org/subscribe/", data: dataString, success: function(data) { gaTrackPage('/email-updates-thank-you?campaign=' + encodeURIComponent(campaign)); displayChange(); }, error: function(xhr,err){ console.log("readyState: "+xhr.readyState+"\nstatus: "+xhr.status); console.log(xhr.responseText); $(this).find(':submit').prop('disabled', false); } }); } return false; }); // Use fitvids.js to make embedded videos responsive. $('iframe[src*="youtube"], iframe[src*="vimeo"], iframe[src*="pbs"], iframe[src*="facebook"], iframe[src*="nyt"], iframe[src*="livestream"]').parent().fitVids({ customSelector: "iframe[src*='pbs'], iframe[src*='facebook'], iframe[src*='nyt'], iframe[src*='livestream']"}); // grab our cached likes, plus ones, and tweets if (document.domain=='www.opensocietyfoundations.org' || document.domain=='dev.osfound.org' || document.domain.endsWith('.dev')) { if (jQuery(".block-boxes-page-tools").length) { var current_url = get_prod_url_ssl(); get_bitly_url(current_url); jQuery('button.social-more').click( function(event) { console.log("more click"); event.preventDefault(); jQuery('button.social-more').fadeOut('fast', function() { jQuery('button.social-linkedin').fadeIn('slow'); jQuery('button.social-email').fadeIn('slow'); jQuery('button.social-republish.can-republish').fadeIn('slow'); }); }); jQuery('button.social-facebook, a.facebook_mobile_header').click( function(event) { event.preventDefault(); var s_url_facebook = current_url; var s_options_facebook = 'width=550,height=330,status=no,scrollbars=yes,resizable=yes,location=yes'; var s_link_facebook = 'https://www.facebook.com/sharer.php?u=' + s_url_facebook; window.open(s_link_facebook, '', s_options_facebook); }); jQuery('button.social-twitter, a.twitter_mobile_header').click( function(event) { event.preventDefault(); var s_twitter_options = 'width=600,height=330,status=no,scrollbars=yes,resizable=yes,location=yes'; var s_hash_via = 'opensociety'; var s_short_link = jQuery('button.social-twitter').attr('data-short-url'); var s_msg_twitter = jQuery('meta[property="osf:tweet"]').attr('content'); if(!s_msg_twitter){ var s_msg_twitter = jQuery('meta[property="og:title"]').attr('content'); } var s_link_twitter = 'https://twitter.com/intent/tweet?text=' + encodeURIComponent(s_msg_twitter) + '&url=' + s_short_link + '&via=' + s_hash_via + '&original_referer=' + current_url; window.open(s_link_twitter, '', s_twitter_options); }); jQuery('button.social-google').click( function(event) { event.preventDefault(); var s_url_google = current_url; var s_options_google = 'width=600,height=500,status=no,scrollbars=yes,resizable=yes,location=yes'; var s_link_google = 'https://plus.google.com/share?url=' + s_url_google; window.open(s_link_google, '', s_options_google); }); jQuery('button.social-linkedin').click( function(event) { event.preventDefault(); var s_url_linkedin = current_url; var s_options_linkedin = 'width=600,height=500,status=no,scrollbars=yes,resizable=yes,location=yes'; var s_link_linkedin = 'https://www.linkedin.com/shareArticle?mini=true&url=' + s_url_linkedin; window.open(s_link_linkedin, '', s_options_linkedin); }); } } function attach_email_mailto() { jQuery('button.social-email').unbind("click.email"); jQuery("button.social-email").bind( "click.email", function(event) { event.preventDefault(); if (jQuery('body.toolbar-drawer ul.tabs.primary').length > 0) { jQuery('body.toolbar-drawer ul.tabs.primary').css('z-index', '0'); } var email_url = get_prod_url_ssl(); //var email_subject = jQuery('meta[property="og:title"]').attr('content'); var email_subject = encodeURIComponent(jQuery('title').text().split(' | ')[0]); var email_body = encodeURIComponent(jQuery('meta[property="og:description"]').attr('content')); var mailto_address = "mailto:?subject=" + email_subject + "&body=" + email_body + "%0A%0A" + email_url; gaTrackEvent('email to friend type', 'mailto', document.URL); window.location.href = mailto_address; }); } // depricated, we only use email client version now function attach_email_lightbox() { jQuery('button.social-email').unbind("click.email"); jQuery("button.social-email").bind( "click.email", function(event) { event.preventDefault(); if (jQuery('body.toolbar-drawer ul.tabs.primary').length > 0) { jQuery('body.toolbar-drawer ul.tabs.primary').css('z-index', '0'); } var dd = 'https://apps.opensocietyfoundations.org/sendtofriend/?url=https://www.opensocietyfoundations.org' + window.location.pathname + '&abt=' + abt; gaTrackEvent('email to friend type', 'lightbox', document.URL); jQuery.colorbox({width: "90%", height: "90%", maxWidth: "800px", iframe: true, href: dd}); }); // always show mailto for Hungary pages if ($('.osf_multilingual_hu').length) { attach_email_mailto(); } } // Attach initial mailto: action - mobile first! attach_email_mailto(); /* Multi-Video player styling */ if (jQuery(".vids .first").length > 0) { if (jQuery(".vids .selected").length == 0) { jQuery(".vids .first").addClass("selected"); } jQuery(".vids a").click(function() { jQuery(".vids div").removeClass("selected"); jQuery(this).parent().addClass("selected"); }); } /* Permalinks for multi-video player */ jQuery(".vids a").click(function(){ var new_hash = encodeURIpretty(jQuery(this).text()); window.location.hash = new_hash; }); if(window.location.hash) { jQuery(".vids a").each(function() { var slide_title_hashed = encodeURIpretty('#' + jQuery(this).text()); var window_hash_hashed = encodeURIpretty(decodeURIComponent(window.location.hash)); if(slide_title_hashed == window_hash_hashed){ var new_video_uri = jQuery(this).attr('href'); jQuery('iframe[name="the-video"]').attr('src', new_video_uri); jQuery(".vids div").removeClass("selected"); jQuery(this).parent().addClass("selected"); } }); } /* expanded contact form for org units */ if(window.location.hash && jQuery("body.node-type-org-unit").length) { if(window.location.hash == '#contact'){ jQuery('#block-webform-client-block-40648 fieldset.form-wrapper').removeClass('collapsed'); jQuery('#edit-submitted-your-name').focus(); } } function add_colon_webform_title(label){ var label = jQuery.trim(label); var last_str_label = label.substr(label.length - 1); var puctuation = "?.!"; if(puctuation.indexOf(last_str_label) == -1){ label = label + ':' } return label; } jQuery.each(jQuery("form .webform-component label"), function() { var full_label = jQuery(this).html(); if(jQuery('span', this).length){ required_label = jQuery('span', this)[0].outerHTML; var text_label = jQuery.trim(full_label.replace(required_label, '')); full_label = add_colon_webform_title(text_label) + ' ' + required_label; } else { full_label = add_colon_webform_title(full_label); } jQuery(this).html(full_label); }); jQuery("body.node-type-org-unit #block-webform-client-block-40648 fieldset.form-wrapper a").click(function(event){ event.preventDefault(); if(window.location.hash == ''){ window.location.hash = 'contact'; jQuery('#edit-submitted-your-name').focus(); } else { removeHash(); } }); /* Show more/Show less in content text */ if (jQuery(".show-more").length > 0) { jQuery(".show-more").click(function(){ jQuery(this).addClass("hidden"); jQuery(this).parent().children(".more-hidden").slideDown('fast'); jQuery(this).parent().parent().children(".more-hidden").slideDown('fast'); return false; }); jQuery(".show-less").click(function(){ jQuery(this).parent().parent().children(".more-hidden").slideUp('fast'); jQuery(this).parent().parent().children().children(".more-hidden").slideUp('fast'); jQuery(this).parent().parent().children(".show-more").removeClass("hidden"); jQuery(this).parent().parent().children().children(".show-more").removeClass("hidden"); return false; }); } /* Show more/Show less on topics page */ if (jQuery("#open-info-plus").length > 0) { jQuery("#open-info-plus").click(function(){ jQuery(this).hide(); jQuery("#close-info-plus").show(); jQuery("#info-plus").slideDown(); return false; }); jQuery("#close-info-plus").click(function(){ jQuery(this).hide(); jQuery("#open-info-plus").show(); jQuery("#info-plus").slideUp('fast'); return false; }); } /* Employment Page */ /* profiles scroller */ if (jQuery(".employment-profiles").length > 0) { var scrollerLeft = 0; var profilesCount = 6; jQuery(".button-prev").addClass("is-inactive"); var prevScroll = function () { jQuery(".button-next").removeClass("is-inactive"); // get the profiles width pWidth = jQuery(".employment-profiles").width(); // get the column width cWidth = jQuery("#profiles").width(); // figure out how much to move if (pWidth/cWidth >= profilesCount/2.5) { scrollerLeft += pWidth*(2.02/profilesCount); } else if (pWidth/cWidth >= profilesCount/3.5 && pWidth/cWidth < profilesCount/2.5) { scrollerLeft += pWidth*(3.03/profilesCount); } else { scrollerLeft = 0; } if (scrollerLeft > -40) { scrollerLeft = 0; jQuery(".button-prev").addClass("is-inactive"); } jQuery(".employment-profiles").css("left", (scrollerLeft+"px")); } var nextScroll = function () { jQuery(".button-prev").removeClass("is-inactive"); // get the profiles width pWidth = jQuery(".employment-profiles").width(); // get the column width cWidth = jQuery("#profiles").width(); // figure out how much to move if (pWidth/cWidth >= profilesCount/2.5) { scrollerLeft -= pWidth*(2.02/profilesCount); } else if (pWidth/cWidth >= profilesCount/3.5 && pWidth/cWidth < profilesCount/2.5) { scrollerLeft -= pWidth*(3.03/profilesCount); } else { scrollerLeft = (pWidth-cWidth)*-1; } if (scrollerLeft-40 < (pWidth-cWidth)*-1) { scrollerLeft = (pWidth-cWidth)*-1; jQuery(".button-next").addClass("is-inactive"); } jQuery(".employment-profiles").css("left", (scrollerLeft+"px")); } jQuery(".button-prev").click(function() { prevScroll(); }); jQuery(".button-next").click(function() { nextScroll(); }); $('.employment-profiles').swipe( { swipeLeft:function(event, direction, distance, duration, fingerCount) { //console.log("You swiped " + direction ); nextScroll(); }, swipeRight:function(event, direction, distance, duration, fingerCount) { //console.log("You swiped " + direction ); prevScroll(); }, fingers:'all', allowPageScroll:'vertical', threshold:20, excludedElements: "" }); // workaround to get links to swipe & click $('.employment-profile').swipe( { tap:function(event, direction, distance, duration, fingerCount) { window.location = $(this).attr('href'); }, fingers:'all', allowPageScroll:'vertical', threshold:20, excludedElements: "" }); } /* FELLOWS SCROLLER */ /* profiles scroller */ if ($(".fellow-profiles").length > 0) { // get the class number - need to split cause of multiple class names var profilesCount = 15; $(".fellow-profiles").filter(function() { var classNames = this.className.split(" "); for (var i=0; iPlease try one of the following tips to improve your results:
\ • Check your spelling and try your search again
\
• Use fewer or alternate terms to conduct your search
\
• Use the navigation at the top of the site to browse for the information
Please try one of the following tips to improve your results:
\• Check your spelling and try your search again.
\
• Use fewer or alternate terms to conduct your search.');
}
}
});