// (c) 2012+ Altruja GmbH. See https://altruja.de for more information. function altruja() { } (function () { function main() { //// Globally (within the embed script) accessible variables //// Configuration - never overwrite these var default_eid = 'cgxf'; var boost_eid = ''; var links = {"wwez":"https://bh-b.de/de/ueber-uns/spenden/index.php","biez":"https://bh-b.de/de/ueber-uns/spenden/index.php","aw27":"https://bh-b.de/de/ueber-uns/spenden/index.php","cgxf":"https://bh-b.de/de/ueber-uns/spenden/index.php","o14y":"https://bh-b.de/de/ueber-uns/spenden/index.php","znwm":"https:\/\/altruja.de\/neuer-spendenanlass-4492\/","zsai":"https:\/\/altruja.de\/neues-spendenformular-2518\/","imhx":"https:\/\/altruja.de\/neues-spendenformular-2550\/","ilvm":"https://bh-b.de/de/ueber-uns/spenden/index.php","g1y0":"https://bh-b.de/de/ueber-uns/spenden/index.php","ny4b":"https://bh-b.de/de/ueber-uns/spenden/index.php","qlfm":"https://bh-b.de/de/ueber-uns/spenden/index.php"}; var slugs = {"wwez":"neuer-spendenanlass-3264","biez":"neues-spendenformular-1917","aw27":"neue-firmenspendenseite-275","cgxf":"neues-spendenformular-1918","o14y":"neues-kampagnentool-287","znwm":"neuer-spendenanlass-4492","zsai":"neues-spendenformular-2518","imhx":"neues-spendenformular-2550","ilvm":"neues-kampagnentool-951","g1y0":"neues-spendenformular-3180","ny4b":"stiftung-nieder-ramstaedter-diakonif","qlfm":"stiftung-nieder-ramstaedter-diakonig"}; var wideParents = []; var default_slug = slugs[default_eid]; var default_link = links[default_eid]; var placeholders = {"page":"ALTRUJA-PAGE","button":"ALTRUJA-BUTTON"}; var buttonTemplate = ''; //// Micro-Frameworks // Provide domready mini-framework, and have it call 'ready' function var domready; // Hack for context var define = function(definition) { domready = definition(); altruja.domready = domready; } define.amd = {}; /*! * domready (c) Dustin Diaz 2014 - License MIT */ !function(e,t){typeof module!="undefined"?module.exports=t():typeof define=="function"&&typeof define.amd=="object"?define(t):this[e]=t()}("domready",function(){var e=[],t,n=document,r=n.documentElement.doScroll,i="DOMContentLoaded",s=(r?/^loaded|^c/:/^loaded|^i|^c/).test(n.readyState);return s||n.addEventListener(i,t=function(){n.removeEventListener(i,t),s=1;while(t=e.shift())t()}),function(t){s?setTimeout(t,0):e.push(t)}}); define = undefined; // use Bean event library /*! * Bean - copyright (c) Jacob Thornton 2011-2012 * https://github.com/fat/bean * MIT license */ (function(e,t,n){typeof module!="undefined"&&module.exports?module.exports=n():typeof define=="function"&&define.amd?define(n):t[e]=n()})("bean",this,function(e,t){e=e||"bean",t=t||this;var n=window,r=t[e],i=/[^\.]*(?=\..*)\.|.*/,s=/\..*/,o="addEventListener",u="removeEventListener",a=document||{},f=a.documentElement||{},l=f[o],c=l?o:"attachEvent",h={},p=Array.prototype.slice,d=function(e,t){return e.split(t||" ")},v=function(e){return typeof e=="string"},m=function(e){return typeof e=="function"},g="click dblclick mouseup mousedown contextmenu mousewheel mousemultiwheel DOMMouseScroll mouseover mouseout mousemove selectstart selectend keydown keypress keyup orientationchange focus blur change reset select submit load unload beforeunload resize move DOMContentLoaded readystatechange message error abort scroll ",y="show input invalid touchstart touchmove touchend touchcancel gesturestart gesturechange gestureend textinput readystatechange pageshow pagehide popstate hashchange offline online afterprint beforeprint dragstart dragenter dragover dragleave drag drop dragend loadstart progress suspend emptied stalled loadmetadata loadeddata canplay canplaythrough playing waiting seeking seeked ended durationchange timeupdate play pause ratechange volumechange cuechange checking noupdate downloading cached updateready obsolete ",b=function(e,t,n){for(n=0;n0){t=d(t);for(f=t.length;f--;)D(e,t[f],n);return e}u=r&&t.replace(s,""),u&&w[u]&&(u=w[u].base);if(!t||r){if(a=r&&t.replace(i,""))a=d(a,".");O(e,u,n,a)}else if(m(t))O(e,null,t);else for(o in t)t.hasOwnProperty(o)&&D(e,o,t[o]);return e},P=function(e,t,n,r){var o,u,a,f,l,v,g;if(n===undefined&&typeof t=="object"){for(u in t)t.hasOwnProperty(u)&&P.call(this,e,u,t[u]);return}m(n)?(l=p.call(arguments,3),r=o=n):(o=r,l=p.call(arguments,4),r=M(n,o,N)),a=d(t),this===h&&(r=A(D,e,t,r,o));for(f=a.length;f--;)g=T.put(v=new x(e,a[f].replace(s,""),r,o,d(a[f].replace(i,""),"."),l,!1)),v[c]&&g&&L(e,v.eventType,!0,v.customType);return e},H=function(e,t,n,r){return P.apply(null,v(n)?[e,n,t,r].concat(arguments.length>3?p.call(arguments,5):[]):p.call(arguments))},B=function(){return P.apply(h,arguments)},j=function(e,t,n){var r=d(t),o,u,a,f,l;for(o=r.length;o--;){t=r[o].replace(s,"");if(f=r[o].replace(i,""))f=d(f,".");if(!f&&!n&&e[c])_(b[t],t,e);else{l=T.get(e,t,null,!1),n=[!1].concat(n);for(u=0,a=l.length;uo.length?(n--,a[t]=a[t]||n):null===o[0][0]&&(o[0][0]=t),r.checkModuleLoaded()},e.prototype.onLoad=function(t,e){var a=this,o=t.currentTarget||t.srcElement;"load"!==t.type&&"complete"!=o.readyState||(o.setAttribute("data-loaded",!0),a.onModuleLoaded(o.getAttribute("data-module"),o.getAttribute("data-count")),o.attachEvent?o.detachEvent("onreadystatechange",e):o.removeEventListener("load",e))},e.prototype.watchCss=function(t){for(var e=this,a=document.styleSheets,o=a.length,n=t.href.split("//").pop();o--;)if(-1!=a[o].href.indexOf(n))return t.setAttribute("data-loaded",!0),void e.onModuleLoaded(t.getAttribute("data-module"),t.getAttribute("data-count"));setTimeout(function(){e.watchCss.call(e,t)})},e.prototype.attachEvents=function(t,e){var a=this,o=function(){var t=Array.prototype.slice.call(arguments);t.push(o),a.onLoad.apply(a,t)};e?t.attachEvent?t.attachEvent("onreadystatechange",o):t.addEventListener("load",o,!0):a.watchCss(t)},e.prototype.checkExists=function(t,e){var a=!1;return this.each(document.getElementsByTagName(e?"script":"link"),function(e){return e.getAttribute("data-module")&&e.getAttribute("data-module")===t?(a=e,!1):void 0}),a},e.prototype.create=function(t,e,a){var o=this;setTimeout(function(){var c=o.checkExists.call(o,t,a);c||(n++,c=document.createElement(a?"script":"link"),a?(c.async=!0,c.type="text/javascript",c.src=e):(c.media="all",c.href=e,c.rel="stylesheet"),c.setAttribute("data-id",o.getId(t)),c.setAttribute("data-module",t),c.setAttribute("data-count",n),c.setAttribute("data-loaded",!1),r?r.parentNode.insertBefore(c,r):i.appendChild(c),o.attachEvents.call(o,c,a))},0)},e.prototype.parseFiles=function(t){var e,o=t.push?t[0]:t,n=t.push?t[1]:t;return a[o]?void this.checkModuleLoaded():(-1!=n.indexOf("//")||/\.js/.test(n)||/^http/.test(n)||(n=n.replace(/\./g,"/"),n+=".js"),e="js"==n.split(".").pop(),void this.create.call(this,o,n,e))},t.include=t.require=t.define=function(t,a,o){return new e(t,a,o)}}(this);; var define = this.define, include = this.include, require = this.require; // IE detector var ie = (function() { var undef, v = 3, div = document.createElement('div'), all = div.getElementsByTagName('i'); while ( div.innerHTML = '', all[0] ); if (document.documentMode) { var mode = document.documentMode; if (mode <= 8) { v = mode; } } return v > 4 ? v : undef; })(); // Document height function docHeight() { var body = document.body, html = document.documentElement; var height = Math.max( body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight ); return height; } // Window height function windowHeight() { return "innerHeight" in window ? window.innerHeight : document.documentElement.offsetHeight; } // Window width function windowWidth() { return "innerWidth" in window ? window.innerWidth : document.documentElement.offsetWidth; } // hide flash objects on page, and iframes function hideFlash() { var i,j,tags,els; tags = ['object', 'embed', 'iframe']; for (i in tags) { els = document.getElementsByTagName(tags[i]); for (j = 0; j < els.length; j++) { if (els[j].id == "234kjh") { continue; } var el = els[j]; el.parentNode.removeChild(el); } } } var isPhone = false; (function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4)))isPhone = true})(navigator.userAgent||navigator.vendor||window.opera); // Functions that build DOM objects mapped // by placeholder, accepting a standard set of // options var snippets = {}; snippets.button = function (options) { options.inplace = true; return makeButton(options); }; snippets.page = function (options) { var fragment, container; fragment = document.createDocumentFragment(); container = makeIframe(options); fragment.appendChild(container); return fragment; }; // JavaScript based media-query like hiding behavior var hiddenForSmallScreen = []; function hideForSmallScreen(element) { hiddenForSmallScreen.push(element); hideIfSmallScreen(); } function hideIfSmallScreen() { var isSmallScreen = windowWidth() < 1100; for (var i = 0; i < hiddenForSmallScreen.length; i++) { var element = hiddenForSmallScreen[i]; element.style.visibility = isSmallScreen ? 'hidden' : 'visible'; } } bean.on(window, 'load', hideIfSmallScreen); bean.on(window, 'resize', hideIfSmallScreen); //// Actions - these get called depending on the logic in the route function, which gets called by the controller // The point is to have some JavaScript MVC, when we are injecting whole pages into the user web site. // So use an action to display a whole page of content depending on the location, // that will not normally be displayed alongside the content of other actions. // Just add code to the end of this script for more generic functionality. var actions = (function (parameters) { this.none = function (parameters) { }; this.button = function (parameters) { replaced(function (count) { if (count.page > 0) { return; } if (null != document.getElementById('234kjh')) { return; } if (count.button > 0) { return; } var button = makeButton({ position: parameters.position, slug: default_slug, link: makeLink('') }); hideForSmallScreen(button); document.body.appendChild(button); }); }; this.page = function (parameters) { domready(hideFlash); bean.on(window, 'load', hideFlash); var overlay = makeOverlay(parameters); var resize_height = 0; bean.on(window, 'resize', function () { overlay.adapt(resize_height); }); bean.on(window, 'ef.msg.resize', function (e) { overlay.adapt(e.data.height); }); document.body.appendChild(overlay); overlay.content.appendChild(makeIframe(parameters)); console.log("insertiframe"); snippets['button'] = function () {return makeButtonSpacer()}; snippets['page'] = function () {return document.createTextNode('')}; }; return this; }).call({}); //// Controller - Picks the appropriate action to take and executes it function controller() { var parameters = route(); actions[parameters.action](parameters); } //// Controller utility functions function destroy(callback) { function select() { return document.getElementsByClassName('ef-234kjh') } var els; while ((els = select()).length) { var el = els[0]; function finish () { if (el.destroy) { el.destroy(); } else { el.parentNode.removeChild(el); } } finish(); } } function reroute() { destroy(function () { }); controller(); } // Determines whether a legacy script code is present on the page function hasLegacy() { var scripts = document.getElementsByTagName('script'); for (var i = 0; i < scripts.length; i++) { if (scripts[i].src && scripts[i].src.indexOf('altruja.de/js/embed.js') > 0) { return true; } } return false; } function containsParam(param) { var loc = document.location.href.indexOf('?'); if (loc > 0) { loc = document.location.href.indexOf(param+'=', loc); if (loc > 0) { // URL contains ? and ef-page=, must be a page link return true; } } return false; } function isPage() { return containsParam('ef-page'); } function isBoost() { return containsParam('ef-boost'); } var noTeaser = ["website-start.de"]; function teaserBlacklisted() { var url = window.location.href; for (i = 0; i < noTeaser.length; i++) { if (null !== url.match(noTeaser[i])) { return true; } } return false; } function route() { //dbg//console/g.log(1); if (hasLegacy()) { return { action: 'none' }; } //dbg//console/g.log(2); if (isPage()) { return { action: 'page', contents: '', eid: default_eid, width: 'slim' }; } //dbg//console/g.log(3); //dbg//console/g.log(6); return { action: 'button', position: 0 }; return {action: 'none'}; // By default, do nothing } //// DOM Utility functions // Prepares an injected div for use in the customer site // These will always be absolute // resets as many properties as possible function prepDiv(el) { el.style.border="none"; el.style.padding="0"; el.style.margin="0"; el.style.background="transparent"; el.style.backgroundImage="none"; el.style.textAlign="left"; el.style.fontSize="12px"; el.style.fontFamily="Arial,Helvetica"; el.style.display="block"; el.style.left="auto"; el.style.right="auto"; el.style.top="auto"; el.style.bottom="auto"; el.style.position="absolute"; return el; } // Creates a universal button // 0=top right // 1=top left // 2=bottom left; // 3=buttom right; function makeButton(options) { var el = document.createElement('div'); prepDiv(el); el.style.zIndex=2147483647 // 2 ^ 31 - 1, highest unsigned int //el.style.width="300px"; //el.style.height="300px"; switch(options.position) { case 1: el.style.right="5px"; el.style.top="5px"; break; /* // TODO case 2: el.style.right="5px"; el.style.bottom="5px"; break; case 3: el.style.left="5px"; el.style.bottom="5px"; break; */ case 0: default: el.style.right="15px"; el.style.top="15px"; break; } el.innerHTML = buttonTemplate.replace('LINK', options.link).replace('SLUG', options.slug); if (options.inplace) { el = el.firstChild; } return el; } // Keep content in place when opening overlay function makeButtonSpacer() { var el = document.createElement('div'); el.innerHTML=buttonTemplate; el.style.height = el.firstChild.style.height; el.style.width = el.firstChild.style.width; el.removeChild(el.firstChild); return el; } function makeLink(link) { var base = window.location.href; var loc; loc=base.indexOf('ef-page='); if (loc > 0) { base = base.substring(0,loc-1); } loc=base.indexOf('ef-boost='); if (loc > 0) { base = base.substring(0,loc-1); } if ( ! link && link !== '') { return base; } var delimiter = base.indexOf('?') == -1 ? '?' : '&'; return base + delimiter + 'ef-page=1' + (link ? ('&'+link) : ''); } function offset(element) { var t=0; var l=0; do { t += element.offsetTop || 0; l += element.offsetLeft || 0; element = element.offsetParent; } while(element); return {left: l, top: t}; } function makeOverlay(parameters) { var zIndexBase=2147483647; var link = makeLink(); var height = document.getElementsByTagName('body')[0].scrollHeight; var overlay = prepDiv(document.createElement('div')); overlay.style.width='100%'; overlay.style.height=height+'px'; overlay.style.top=0; overlay.style.left=0; overlay.style.zIndex = zIndexBase; overlay.id='ef-overlay'; var shade = prepDiv(document.createElement('div')); shade.style.width='100%'; shade.style.height='100%'; shade.style.backgroundColor = 'black'; shade.style.opacity=0.5; shade.style.filter="alpha(opacity=50)"; shade.style.zIndex=zIndexBase; shade.style.position="fixed"; if (ie) { shade.style.position = "absolute"; } shade.style.left = 0; shade.style.top = 0; shade.id='ef-shade'; overlay.appendChild(shade); var content = prepDiv(document.createElement('div')); content.style.width=parameters.width=='slim' ? '600px' : 'calc(100% - 60px)'; if (content.style.maxWidth) { content.style.maxWidth=parameters.width=='slim' ? 'auto' : '1200px'; } content.style.zIndex=zIndexBase; content.style.position="relative"; content.style.marginTop="18px"; content.style.marginBottom="18px"; content.style.marginLeft="auto"; content.style.marginRight="auto"; content.style.paddingTop="18px"; content.style.paddingRight="12px"; content.style.paddingBottom="18px"; content.style.paddingLeft="12px"; content.style.backgroundColor="white"; content.style.boxShadow="3px 3px 20px #000"; content.id='ef-content'; if (ie) { content.style.border = '1px #000000 solid'; content.style.position = "absolute"; content.style.left="50%"; content.style.marginLeft="-300px"; // slim only content.style.right="auto"; content.style.top="10px"; } overlay.appendChild(content); var close = prepDiv(document.createElement('a')); close.style.width='30px'; close.style.height='30px'; close.style.backgroundPosition='-40px 0'; close.style.backgroundImage='url(https://altruja.de/a/trancybox/trancybox.png)'; close.style.right='-15px'; close.style.top='-15px'; close.style.zIndex=zIndexBase; close.style.outline='none'; close.href=link; close.id='ef-close'; content.appendChild(close); function adapt(height) { var adapt_height = Math.max(height + 95, windowHeight()); overlay.style.height = adapt_height + 'px'; shade.style.height = (adapt_height + 36) + 'px'; bean.fire(document.body, 'ef.adapt', {height:adapt_height}); } overlay.adapt = adapt; overlay.content = content; return overlay; } //// Event handlers // Window onload function load() { } function find() { } //// Event utility functions // Execute when replacements have been made, // or immediately if already the case var replacement_complete = false; var replacement_count = { page: 0, button: 0 }; function replaced(callback) { if (replacement_complete) { return callback(replacement_count); } bean.on(window, 'ef.replaced', function (e) { callback(replacement_count); }); } //// DOM utility functions var tick = 10, ticks = 0, maxticks = 10; //var isiPad = navigator.userAgent.match(/iPad/i) != null; //if (ie || isiPad) { // tick = 200; //} function waitForBody (callback) { if (document.body) { window.setTimeout(callback, 0); } window.setTimeout(waitForBody, tick); } // Source: http://stackoverflow.com/questions/2579666/getelementsbytagname-equivalent-for-textnodes function eachNode(callback, complete, root) { var node = root; while(true) { callback(node); if (node.hasChildNodes()) { node = node.firstChild; } else { while(node.nextSibling == null && node != root) { node = node.parentNode; } if (root == node) { return complete(); } else { node = node.nextSibling; } } } } //// Initialization (kick off the code) // Run the function called load when window is loaded (window.addEventListener?function (callback) {window.addEventListener('load', callback)}:function (callback){window.attachEvent('onload', callback)})(load); // Kick off the controller controller(); //// End of MVC-portion dedicated to full pages content insertion. //// From here on is arbitrary code again with no specific structure requirements. //// domready(foo) is equivalent mini framework to $(document).ready(foo) //// First time run // Placeholder replacement function extractEid(part) { if (0 == part.search(/-[a-zA-Z0-9]{4}/)) { return part.substr(1,4).toLowerCase(); } return null; } function makeSnippet(placeholder, eid,lang) { options = { eid: eid, link: makeLink(slugs[eid]), slug: slugs[eid], lang: lang }; return snippets[placeholder](options); } function makeFragment(placeholder, parts, nullify) { var options, snippet; fragment = document.createDocumentFragment(); fragment.appendChild(document.createTextNode(parts[0])); n = parts.length; for (i = 1; i < n; i = i + 1) { argument = parts[i]; var lang = null; if (0 == argument.search(/-[a-zA-Z0-9]{4}/)) { eid = argument.substr(1,4).toLowerCase(); parts[i] = argument = argument.substr(5); if (0 == argument.search(/-[a-zA-Z]{2}/)) { lang = argument.substr(1,2).toLowerCase(); parts[i] = argument = argument.substr(3); } } else { eid = default_eid; } if (nullify) { snippet = document.createTextNode(''); } else { snippet = makeSnippet(placeholder, eid, lang); } fragment.appendChild(snippet); fragment.appendChild(document.createTextNode(parts[i])); } return fragment; } var pageElements = [], pagePartses = [], buttonElements = [], buttonPartses = [] ; function replaceNode(element) { var value, parts, eid, options, i, n, fragment, argument; switch(element.nodeType) { case 3: // text case 8: // comment break; default: return; } for (key in placeholders) { value = placeholders[key]; parts = element.nodeValue.replace(/^\s+|\s+$/g, '').split(value); // ie8 does not do trim if (parts.length > 1) { element.nodeValue = ''; var placeholder = value.split('-')[1].toLowerCase(); switch(placeholder) { case 'page': pageElements.push(element); pagePartses.push(parts); //var fragment = makeFragment("page", parts, true); //element.parentNode.replaceChild(fragment, element); //replacement_count["page"]++; break; case 'button': buttonElements.push(element); buttonPartses.push(parts); break; } } } } function findWideParent(element) { var width = 0, minWidth = 897; while (width < minWidth && element != document.body) { element = element.parentNode; try { width = element.clientWidth || width; } catch (e) { } } return element; } function replacementsComplete() { var i, n, element, fragment, page; page = pageElements.length > 0; n = buttonElements.length; for (i = 0; i < n; i++) { element = buttonElements[i]; fragment = makeFragment("button", buttonPartses[i], page == true); element.parentNode.replaceChild(fragment, element); replacement_count["button"]++; } n = pageElements.length; for (i = 0; i < n; i++) { element = pageElements[i]; if (-1 != wideParents.indexOf(extractEid(pagePartses[i][1]))) { var wideParent = findWideParent(element); while (wideParent.firstChild) { wideParent.removeChild(wideParent.firstChild); } element = document.createTextNode(''); wideParent.appendChild(element); } fragment = makeFragment("page", pagePartses[i]); element.parentNode.replaceChild(fragment, element); replacement_count["page"]++; } // treat old script tags like placeholders as fallback var scripts = document.getElementsByTagName('script'); n = scripts.length; var src; for(i=0; i < n; i++) { element = scripts[i]; src = element.src; if (-1 != src.indexOf("altruja.de/js/embed.js")) { var eid = src.substr(src.indexOf("eid=")+4, 4).toLowerCase(); if (element.parentNode==document.head) { element = document.createElement('div'); document.body.appendChild(element); } element.parentNode.replaceChild(makeSnippet("page", eid), element); break; } } replacement_complete = true; bean.fire(window, 'ef.replaced', {count: replacement_count}); } function replacePlaceholders() { eachNode(replaceNode, replacementsComplete, document.body); } // One: Replace as quickly as possible if (false == ie) { waitForBody(replacePlaceholders); } // Two: Clean up any that may have gone missing // (mostl likely when user has invasive browser plugins // site has blocking script tags. IE<9 not supported.) domready(replacePlaceholders); // Make backlink subtle fast var backlink = null; function subtleBacklink(backlink) { if (!backlink) { backlink = document.getElementById('ef-bl-x7jn2nd9j'); if (null == backlink) { return window.setTimeout(function () { subtleBacklink(null); }, 10); } } backlink.style.position = 'absolute'; backlink.style.display = 'block'; backlink.style.zIndex = 2147483647; backlink.style.bottom = 'auto'; backlink.style.left = 'auto'; backlink.style.top = 'auto'; backlink.style.right = 'auto'; backlink.style.bottom = 'auto'; backlink.style.top = (docHeight()-20)+'px'; } subtleBacklink(); domready(function () { subtleBacklink(backlink); }); bean.on(window, 'load', function () { subtleBacklink(backlink); }); bean.on(document.body, 'ef.adapt', function () { subtleBacklink(backlink); }); function debounce(func, wait, immediate) { var timeout; return function() { var context = this, args = arguments; clearTimeout(timeout); timeout = setTimeout(function() { timeout = null; if (!immediate) func.apply(context, args); }, wait); if (immediate && !timeout) func.apply(context, args); }; } bean.on(window, 'ef.msg.resize', debounce(function (e, data) { bean.fire(window, 'ef.msg.resize-debounced', [e, data]); }, 150)); bean.on(window, 'message', function (e) { var data; try { data = (JSON.parse || JSON.decode /*mootools support*/)(e.data); } catch (x) { // Ignore non-json messages, they are not ours return; } if (data.ns != 'ef') { return; } delete data.ns; var name = data.name; delete data.name; e.data = data; bean.fire(window, 'ef.msg.'+name, [e, data]); }); bean.on(window, 'ef.msg.param', function (e, data) { var url; if (data.dir == 'add') { url = addParam(window.location.href, data.param, data.value); } else { url = removeParam(window.location.href, data.param); } history.replaceState({}, null, url); if (pageElements.length > 0) { // pages that contain donation forms (other iframes); window.location.reload(); } else { // regular case reroute(); } }); var pageFrame = null; bean.on(window, 'scroll', function (e) { if (pageFrame == null) { pageFrame = document.getElementById('234kjh'); if (pageFrame == null) { return; } } var top = Math.max(0, window.pageYOffset - pageFrame.offsetTop); pageFrame.contentWindow.postMessage('{"ns":"ef","name":"scroll","top":"'+top+'"}', '*'); }); function addParam(url, param, value) { if (-1 == url.indexOf(param)) { url = url + (-1 == url.indexOf('?') ? '?' : '&') + param + '=' + value; } else { url = url.replace(new RegExp(param + '=[^&]+'), param+'='+value); } return url; } function removeParam(url, param) { if (-1 != url.indexOf(param)) { url = url.replace(new RegExp('[&?]?'+param+'=?[^&]*'), ''); if (url.indexOf('?') == -1 && url.indexOf('&') != -1) { url = url.replace('&', '?'); } } return url; } function extend(a, b){ for(var key in b) if(b.hasOwnProperty(key)) a[key] = b[key]; return a; } function makeIframe(options) { var params = gatherIframeParams(); var container = document.createElement('div'); container.id='ef-container-234kjh'; container.className='ef-234kjh'; container.style.width = '100%'; container.style.margin = '0'; container.style.padding = '0'; container.style.backgroundImage = 'url(//em.altruja.de/images/ajax-loader-anybg.gif)'; container.style.backgroundRepeat = 'no-repeat'; container.style.backgroundPosition = 'center 10px'; container.style.height = '38px'; var iframe = document.createElement('iframe'); var qs = params.qs; if (qs) { qs = '?' + qs; } if (options.lang) { qs = (qs?'&':'?') + 'lang=' + options.lang; } iframe.src='https://em.altruja.de/SLUG'.replace('SLUG', params.path || slugs[options.eid]) + qs ; iframe.width='100%'; iframe.height='0'; iframe.id='234kjh'; iframe.name='234kjh'; iframe.border='0'; iframe.frameBorder='0'; iframe.margin='0'; iframe.padding='0'; iframe.scrolling='no'; iframe.allowtransparency='true'; iframe.style.position='relative'; iframe.style.zIndex='201'; iframe.style.width = '100%'; iframe.style.margin = '0px'; iframe.style.padding = '0px'; iframe.style.border = 'none'; iframe.style.height = '1px' iframe.adapt = function (height) { iframe.style.height = height + 'px'; }; bean.on(window, 'ef.msg.resize', function (e, data) { iframe.adapt(data.height); }); bean.one(window, 'ef.msg.resize', function (e, data) { container.style.height=null; container.style.background="none"; }); bean.on(window, 'popstate', function (e) { var state = e.state; console.log(state); if (state && state.ns == 'ef' && state.path) { skipPush = true; iframe.src = 'https://em.altruja.de' + state.path; } }); if (document.documentMode) { if (document.documentMode < 8) { container.style.height=null; container.style.background="none"; iframe.adapt(1000); } } bean.on(window, 'ef.msg.request-url', function (e) { e.source.postMessage('{"ns":"ef","name":"url","url":"'+params.base+'"}', "*"); }); var skipPush = false; bean.on(window, 'ef.msg.url', function (e, data) { var params = gatherIframeParams(); var url = params.base + (data.url==''? '' : (params.delim + data.url.substr(1))); if (skipPush == false && history.replaceState && data.url != '') { history.replaceState(null, null, url); } skipPush = false; }); function scrollToFrameTop() { var iframeTop = offset(iframe).top; if (iframeTop <= 217) { window.scrollTo(0,0); } else { setTimeout(function () { window.scrollTo(0, iframeTop - 37); }, 100); } } var topFrameFirstLoad = true; bean.on(window, 'ef.msg.load', function (e, data) { //console.log("load " + (topFrameFirstLoad ? "first" : "")); if (topFrameFirstLoad) { topFrameFirstLoad = false; return; } scrollToFrameTop(); }); container.iframe = iframe; container.appendChild(iframe); return container; } function gatherIframeParams(container) { // formerly in embed.js init var dlh = document.location.href; var p = dlh.indexOf('#'); if (p != -1) { dlh = dlh.substr(0, p); } var parts = dlh.split('?'); var base = parts.shift(); var path = parts.join('?'); var delim = ''; var qs = ''; if(path.indexOf('=') != -1) { if(path.indexOf('&') != -1) { var parts = dlh.split('&'); path = parts.pop(); base = parts.join('&'); if(path.indexOf('=') != -1) { base = base +'&'+ path; path = ''; } } else { path= ''; base = dlh; } } if(path.indexOf('=') != -1) { path = ''; } delim = base.indexOf('?') == -1 ? '?' : '&'; path = decodeURIComponent(path); if( document.location.hash.indexOf('=') >0 ){ qs = document.location.hash.substr(1); if (window.history) { window.history.replaceState(null, null, window.location.pathname + window.location.search); } else { document.location.hash=''; } } return {base:base,qs:qs,path:path,delim:delim}; } } function init() { if (document.body) { main.call(altruja); } else { window.setTimeout(init, 100); } } init(); })();