jquery - Banner not closing and staying closed with link -
hey guys have banner developed mootools library. banner appears on smartphones can see via chrome dev tools using toggle device mode. here link banner
my issue banner has "do not show again" link , not working.
this part of code using. using cookie. can let me know why not firing off. i've looked , looked , can't figure out.
/* not show window again */ window.addeventlistener('load', function() { if ($('#appnotice')) { var appnoticecloseelems = $$('.appnoticeclose'), appnoticecloseperm = $$('.appnoticecloseperm'), appnotice = $('#appnotice'), appnoticeheight = appnotice.height(), appnoticepaddingtop = math.abs(appnoticeheight.toint() - 5000), bypassappnotice = cookie.read('bypassappnotice'); appnotice.css('padding-top', appnoticepaddingtop); function appnoticeopen() { console.log('appnoticeopen'); appnotice.css('display','block'); } function appnoticeclose() { console.log('appnoticeclose'); appnotice.css('display','none'); } appnoticecloseelems.each(function(el, index) { $(el).click(function(){ console.log('appnoticeclose'); var bypassappnotice = cookie.write('bypassappnotice', 'true'); appnoticeclose(); }); }); appnoticecloseperm.each(function(el, index) { el.click(function(){ console.log('appnoticecloseperm'); var bypassappnotice = cookie.write('bypassappnotice', 'true', { duration: 120 }); appnoticeclose(); }); }); } if (bypassappnotice != 'true') { /* detect smartphone */ var mobile = (/android/i.test(navigator.useragent.tolowercase())); if (mobile) { var useragent = navigator.useragent.tolowercase(); if ((useragent.search("android") > -1) && (useragent.search("mobile") > -1)) var element = document.getelementbyid("apppage").style.display = "none"; var element = document.getelementbyid("googleplaybadge") .innerhtml = "<a href='https://play.google.com/store/apps/details?id=com.fiserv.touchbankingasp&hl=en' target='_blank'><img src='https://developer.android.com/images/brand/en_generic_rgb_wo_60.png'></a>"; } var mobile = (/iphone/i.test(navigator.useragent.tolowercase())); if (mobile) { var useragent = navigator.useragent.tolowercase(); if ((useragent.search("iphone") > -1) && (useragent.search("mobile") > -1)) var element = document.getelementbyid("apppage").style.display = "none"; var element = document.getelementbyid("appstorebadge") .innerhtml = "<a href='https://itunes.apple.com/us/app/touchbanking/id386678211?mt=8' target='_blank'><img src='http://linkmaker.itunes.apple.com/images/badges/en-us/badge_appstore-lrg.png'></a>"; } } }); /* dismiss window ones */ function hideshow(which) { if (!document.getelementbyid) return if (which.style.display == "block") which.style.display = "none" else which.style.display = "block" } };
if possible, rid of 1 of 2 libraries (jquery / mootools). if not possible, @ least use jquery.noconflict(), in mootools avoid $ sign or use or use the dollar safe mode. besides unnecessarily gib footprint makes hard understand happens here. e.g. el.click - in vanilla js triggers click on element, if el simple dom element - same mootools, because mootools elements still elements (which appreciate btw) - in jquery might $(el) somthing el.addeventlistener('click', ..), latter in mootools el.addevent()
so $$('.appnoticeclose') returns - mootools elements or jquery objects, makes big difference. there might race condition in library loaded last.
Comments
Post a Comment