var Newsletter = { instance: false, init: function() { var scripts = document.getElementsByTagName("script"); for (var i in scripts) { if (scripts[i].src.match(/newsletter\.js$/gi)) { this.instance = scripts[i]; break; } } this.instance.parentNode.insertBefore(this.canvas(), this.instance); if(typeof jQuery == "undefined"){ this.instance.parentNode.insertBefore(this.jquery(), this.instance); setTimeout(function(){Newsletter.checkrun();},100); }else{ this.run(); } }, checkrun: function() { if(typeof jQuery == "undefined"){ setTimeout(function(){Newsletter.checkrun();},100); }else{ this.run(); } }, run: function() { $('#canvas').css("display","none"); $('#canvas').css({ border: '1px solid #ccc', backgroundColor: '#fff', borderRadius: '10px', OBorderRadius: '10px', MozBorderRadius: '10px', WebkitBorderRadius: '10px', margin: '10px auto', maxWidth: '178px', padding: '10px', textAlign: 'center', cursor: 'pointer' }); $('#canvas').html('ROBIN WOOD NewsletterHier eintragen!'); $('#canvashead').css({ display: 'block', fontWeight: 'bold', fontSize: '24px', color: '#180' }); $('#canvastext').css({ display: 'block', fontWeight: 'normal', fontSize: '18px', color: '#222', textDecoration: 'none' }); $('#canvas').click(function(){Newsletter.box()}); $('#canvas').fadeIn(); }, canvas: function() { var canvas = document.createElement('div'); canvas.setAttribute('id', 'canvas'); return canvas; }, iframe: function() { var iframe = document.createElement('iframe'); iframe.setAttribute('id', 'nliframe'); iframe.setAttribute('src', 'http://www.robinwood.de/newsletter/frame/bestellen'); iframe.setAttribute('width', '760'); iframe.setAttribute('height', ($(window).height()-140)); iframe.setAttribute('frameBorder', 0); iframe.setAttribute('scrolling', 'auto'); iframe.setAttribute('border', 0); iframe.setAttribute('marginHeight', 0); iframe.setAttribute('marginWidth', 0); iframe.setAttribute('marginHeight', 0); iframe.setAttribute('allowTransparency', 'true'); return iframe; }, jquery: function() { var jquery = document.createElement('script'); jquery.setAttribute('type', 'text/javascript'); jquery.setAttribute('src', 'http://www.robinwood.de/newsletter/assets/js/jquery/jquery-1.4.2.min.js'); return jquery; }, box: function() { $("body").append( $('
').css({ display: 'none', position: 'fixed', left: '0px', right: '0px', top: '0px', bottom: '0px', opacity: '0.9', backgroundColor: '#000', zIndex: '99999' }).fadeIn() ); $("body").append( $('
').css({ display: 'none', position: 'fixed', width: '760px', padding: '10px 20px', height: ($(window).height()-140), left: Math.floor(($(window).width()-800)/2), top: '50px', opacity: '1', backgroundColor: '#fff', OBorderRadius: '10px', MozBorderRadius: '10px', WebkitBorderRadius: '10px', borderRadius: '10px', border: '1px solid #eee', OBoxShadow: '0px 0px 10px #000', MozBoxShadow: '0px 0px 10px #000', WebkitBoxShadow: '0px 0px 10px #000', boxShadow: '0px 0px 10px #000', zIndex: '99999' }).html(this.iframe()).fadeIn() ); $("body").append( $('').css({ display: 'none', position: 'fixed', width: '25px', height: '25px', padding: '0px', right: (Math.floor(($(window).width()-800)/2)-10), top: '40px', opacity: '1', background: 'transparent url(http://www.robinwood.de/newsletter/assets/images/close.png) top left no-repeat' , zIndex: '99999' }).fadeIn() ); }, remove: function() { $('#nlframe').fadeOut('slow',function(){$('#nlframe').remove();}); $('#nlblack').fadeOut('slow',function(){$('#nlblack').remove();}); $('#nlclose').fadeOut('slow',function(){$('#nlclose').remove();}); } /*, /* render: function() { var data = this.assembleDataString(); switch(this.getParam('im', 'default')) { case 'replace': this.replaceWith(this.instance, this.createIframe(data, this.useCompact)); break; default: this.instance.parentNode.insertBefore(this.createIframe(data, this.useCompact), this.instance); } }, replaceWith: function (old, content) { if (typeof content == 'string') { if ('outerHTML' in document.documentElement) { old.outerHTML = content; } else { var range = document.createRange(); range.selectNode(old); content = range.createContextualFragment(content); old.parentNode.replaceChild(content, old); } } old.parentNode.replaceChild(content, old); }*/ }; window.onload = function(){ Newsletter.init(); };