(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_343399 = document.getElementById('melde_343399'); var meldeInst = new melde(meldeEl_343399, { openCallback: function() { console.log('Callback for when melde is open.'); }, closeCallback: function() { console.log('Callback for when melde is closed.'); } }); meldeInst.init(); var xmlhttp343399 = new getXMLObject(); function ajaxNewspost_343399() { if(xmlhttp343399) { var melde_message = document.getElementById("melde_message_343399").value; var melde_id = encodeURIComponent(document.getElementById("melde_id_343399").value); xmlhttp343399.open("POST","../meldung_send.php",true); xmlhttp343399.onreadystatechange = handleServerResponse343399; xmlhttp343399.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); xmlhttp343399.send("message=" + melde_message + "&melde_id=" + melde_id); } } function handleServerResponse343399() { if (xmlhttp343399.readyState == 4) { if(xmlhttp343399.status == 200) { document.getElementById("melde_message_343399").value=''; } else { alert("Upsal! Da hat es jetzt irgendwo ein Problem geben! Probier es einfach nochmal!"); } } } var meldeEl_343440 = document.getElementById('melde_343440'); var meldeInst = new melde(meldeEl_343440, { openCallback: function() { console.log('Callback for when melde is open.'); }, closeCallback: function() { console.log('Callback for when melde is closed.'); } }); meldeInst.init(); var xmlhttp343440 = new getXMLObject(); function ajaxNewspost_343440() { if(xmlhttp343440) { var melde_message = document.getElementById("melde_message_343440").value; var melde_id = encodeURIComponent(document.getElementById("melde_id_343440").value); xmlhttp343440.open("POST","../meldung_send.php",true); xmlhttp343440.onreadystatechange = handleServerResponse343440; xmlhttp343440.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); xmlhttp343440.send("message=" + melde_message + "&melde_id=" + melde_id); } } function handleServerResponse343440() { if (xmlhttp343440.readyState == 4) { if(xmlhttp343440.status == 200) { document.getElementById("melde_message_343440").value=''; } else { alert("Upsal! Da hat es jetzt irgendwo ein Problem geben! Probier es einfach nochmal!"); } } } var meldeEl_343441 = document.getElementById('melde_343441'); var meldeInst = new melde(meldeEl_343441, { openCallback: function() { console.log('Callback for when melde is open.'); }, closeCallback: function() { console.log('Callback for when melde is closed.'); } }); meldeInst.init(); var xmlhttp343441 = new getXMLObject(); function ajaxNewspost_343441() { if(xmlhttp343441) { var melde_message = document.getElementById("melde_message_343441").value; var melde_id = encodeURIComponent(document.getElementById("melde_id_343441").value); xmlhttp343441.open("POST","../meldung_send.php",true); xmlhttp343441.onreadystatechange = handleServerResponse343441; xmlhttp343441.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); xmlhttp343441.send("message=" + melde_message + "&melde_id=" + melde_id); } } function handleServerResponse343441() { if (xmlhttp343441.readyState == 4) { if(xmlhttp343441.status == 200) { document.getElementById("melde_message_343441").value=''; } else { alert("Upsal! Da hat es jetzt irgendwo ein Problem geben! Probier es einfach nochmal!"); } } } var meldeEl_343442 = document.getElementById('melde_343442'); var meldeInst = new melde(meldeEl_343442, { openCallback: function() { console.log('Callback for when melde is open.'); }, closeCallback: function() { console.log('Callback for when melde is closed.'); } }); meldeInst.init(); var xmlhttp343442 = new getXMLObject(); function ajaxNewspost_343442() { if(xmlhttp343442) { var melde_message = document.getElementById("melde_message_343442").value; var melde_id = encodeURIComponent(document.getElementById("melde_id_343442").value); xmlhttp343442.open("POST","../meldung_send.php",true); xmlhttp343442.onreadystatechange = handleServerResponse343442; xmlhttp343442.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); xmlhttp343442.send("message=" + melde_message + "&melde_id=" + melde_id); } } function handleServerResponse343442() { if (xmlhttp343442.readyState == 4) { if(xmlhttp343442.status == 200) { document.getElementById("melde_message_343442").value=''; } else { alert("Upsal! Da hat es jetzt irgendwo ein Problem geben! Probier es einfach nochmal!"); } } }