(function() { 'use strict'; function classReg(cl) { return new RegExp('(\\s|^)'+ cl +'(\\s|$)'); } function hasClass(el, cl) { return el.className.match(classReg(cl)); } function addClass(el, cl) { if (!hasClass(el, cl)) { el.className += ' ' + cl; } } function removeClass(el, cl) { if (hasClass(el, cl)) { el.className = el.className.replace(classReg(cl), ''); } } function extend(obj1, obj2) { var obj = {}; for (var key in obj1) { obj[key] = obj2[key] === undefined ? obj1[key] : obj2[key]; } return obj; } var melde = function(el, opts) { this.melde = el, this.triggerBtn = document.querySelectorAll('[data-trigger-melde="' + this.melde.id + '"]'), this.closeBtn = this.melde.querySelectorAll('[data-close-melde]'), this.body = document.body, this.defaults = { activeClass: 'melde--active', bodyClass: 'melde-is-active', overlay: true, overlayClass: 'melde__overlay', openCallback: null, closeCallback: null }, this.opts = extend(this.defaults, opts); }; melde.prototype = { init: function() { this.meldeTriggering(); }, meldeTriggering: function() { var self = this; for (var i = 0; i < self.triggerBtn.length; i++) { self.triggerBtn[i].addEventListener('click', self.openmelde.bind(this)); } }, openmelde: function() { var self = this; if (self.opts.overlay) { self.appendOverlay(); } addClass(self.melde, self.opts.activeClass); addClass(self.body, self.opts.bodyClass); for (var i = 0; i < self.closeBtn.length; i++) { self.closeBtn[i].addEventListener('click', this.closemelde.bind(this)); } if (self.opts.openCallback) { self.opts.openCallback.call(self); } setTimeout(function() { self.closeBtn[0].focus(); }, 500); }, closemelde: function() { var self = this; removeClass(self.melde, self.opts.activeClass); removeClass(self.body, self.opts.bodyClass); for (var i = 0; i < self.closeBtn.length; i++) { self.closeBtn[i].removeEventListener('click', this.closemelde.bind(this)); } if (self.opts.overlay) { self.removeOverlay(); } if (self.opts.closeCallback) { self.opts.closeCallback.call(self); } }, appendOverlay: function() { var self = this; self.overlay = document.createElement('div'); self.overlay.className = self.opts.overlayClass; self.melde.appendChild(self.overlay); }, removeOverlay: function() { var self = this; setTimeout(function() { self.overlay.remove(); }, 500); } }; window.melde = melde; })(); var meldeEl_342898 = document.getElementById('melde_342898'); var meldeInst = new melde(meldeEl_342898, { openCallback: function() { console.log('Callback for when melde is open.'); }, closeCallback: function() { console.log('Callback for when melde is closed.'); } }); meldeInst.init(); var xmlhttp342898 = new getXMLObject(); function ajaxNewspost_342898() { if(xmlhttp342898) { var melde_message = document.getElementById("melde_message_342898").value; var melde_id = encodeURIComponent(document.getElementById("melde_id_342898").value); xmlhttp342898.open("POST","../meldung_send.php",true); xmlhttp342898.onreadystatechange = handleServerResponse342898; xmlhttp342898.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); xmlhttp342898.send("message=" + melde_message + "&melde_id=" + melde_id); } } function handleServerResponse342898() { if (xmlhttp342898.readyState == 4) { if(xmlhttp342898.status == 200) { document.getElementById("melde_message_342898").value=''; } else { alert("Upsal! Da hat es jetzt irgendwo ein Problem geben! Probier es einfach nochmal!"); } } } var meldeEl_342899 = document.getElementById('melde_342899'); var meldeInst = new melde(meldeEl_342899, { openCallback: function() { console.log('Callback for when melde is open.'); }, closeCallback: function() { console.log('Callback for when melde is closed.'); } }); meldeInst.init(); var xmlhttp342899 = new getXMLObject(); function ajaxNewspost_342899() { if(xmlhttp342899) { var melde_message = document.getElementById("melde_message_342899").value; var melde_id = encodeURIComponent(document.getElementById("melde_id_342899").value); xmlhttp342899.open("POST","../meldung_send.php",true); xmlhttp342899.onreadystatechange = handleServerResponse342899; xmlhttp342899.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); xmlhttp342899.send("message=" + melde_message + "&melde_id=" + melde_id); } } function handleServerResponse342899() { if (xmlhttp342899.readyState == 4) { if(xmlhttp342899.status == 200) { document.getElementById("melde_message_342899").value=''; } else { alert("Upsal! Da hat es jetzt irgendwo ein Problem geben! Probier es einfach nochmal!"); } } } var meldeEl_342900 = document.getElementById('melde_342900'); var meldeInst = new melde(meldeEl_342900, { openCallback: function() { console.log('Callback for when melde is open.'); }, closeCallback: function() { console.log('Callback for when melde is closed.'); } }); meldeInst.init(); var xmlhttp342900 = new getXMLObject(); function ajaxNewspost_342900() { if(xmlhttp342900) { var melde_message = document.getElementById("melde_message_342900").value; var melde_id = encodeURIComponent(document.getElementById("melde_id_342900").value); xmlhttp342900.open("POST","../meldung_send.php",true); xmlhttp342900.onreadystatechange = handleServerResponse342900; xmlhttp342900.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); xmlhttp342900.send("message=" + melde_message + "&melde_id=" + melde_id); } } function handleServerResponse342900() { if (xmlhttp342900.readyState == 4) { if(xmlhttp342900.status == 200) { document.getElementById("melde_message_342900").value=''; } else { alert("Upsal! Da hat es jetzt irgendwo ein Problem geben! Probier es einfach nochmal!"); } } } var meldeEl_342905 = document.getElementById('melde_342905'); var meldeInst = new melde(meldeEl_342905, { openCallback: function() { console.log('Callback for when melde is open.'); }, closeCallback: function() { console.log('Callback for when melde is closed.'); } }); meldeInst.init(); var xmlhttp342905 = new getXMLObject(); function ajaxNewspost_342905() { if(xmlhttp342905) { var melde_message = document.getElementById("melde_message_342905").value; var melde_id = encodeURIComponent(document.getElementById("melde_id_342905").value); xmlhttp342905.open("POST","../meldung_send.php",true); xmlhttp342905.onreadystatechange = handleServerResponse342905; xmlhttp342905.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); xmlhttp342905.send("message=" + melde_message + "&melde_id=" + melde_id); } } function handleServerResponse342905() { if (xmlhttp342905.readyState == 4) { if(xmlhttp342905.status == 200) { document.getElementById("melde_message_342905").value=''; } else { alert("Upsal! Da hat es jetzt irgendwo ein Problem geben! Probier es einfach nochmal!"); } } }