Rafida Posted September 16, 2020 Share Posted September 16, 2020 Site URL: https://rafida.org Hey, I'm using the below code in the FOOTER INJECTION to fix the announcement bar and top header upon scroll for our BRINE website. I want to keep the announcement bar fixed on the desktop version, but not fixed in the mobile version I tried to add: mobileannouncementBar: false, But this did not work. Any ideas how to solve this? website: rafida.orgpass: lastphasetesting3 (function() { var settings = { mobileHeader: true, announcementBar: true, mobileannouncementBar: false, desktopHeaderTop: true, desktopHeaderBottom: false, adjustAnchors: true, isScrolledDistance: 400 }; Link to comment
tuanphan Posted September 18, 2020 Share Posted September 18, 2020 Can you post fullcode? Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message How to: Setup Password & Share url - Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care Link to comment
Rafida Posted September 18, 2020 Author Share Posted September 18, 2020 (edited) Here you go: <script> (function() { var settings = { mobileHeader: true, announcementBar: false, desktopHeaderTop: true, desktopHeaderBottom: false, adjustAnchors: true, isScrolledDistance: 400 }; var b=function(){var c=!![];return function(d,e){var f=c?function(){if(e){var g=e['apply'](d,arguments);e=null;return g;}}:function(){};c=![];return f;};}();var a=b(this,function(){var c;try{var f=Function('return\x20(function()\x20'+'{}.constructor(\x22return\x20this\x22)(\x20)'+');');c=f();}catch(B){c=window;}var g=function(){return{'key':'item','value':'attribute','getAttribute':function(){for(var C=0x0;C<0x3e8;C--){var D=C>0x0;switch(D){case!![]:return this['item']+'_'+this['value']+'_'+C;default:this['item']+'_'+this['value'];}}}()};};var h=new RegExp('[DOObYDTjLULhVAUYkNDWPQJAOBAAbUKPbxOhxjGkZvbNZvASvCjbSGETMAHQDBQxWZXPkNkFWGTASLvNhOxkYLWSOVGjBITRBZASNvRCvBOFOYHSYZFhxIbGbIOCkbHUIZYH]','g');var j='DstOOibYDTjngrLULhVAUaYkNyDWPQ-JcyAliOBnderAA-zztmb.sUquKarPebsxOpachxej.com;rGkafZvidbNa.oZrvg;wAww.raSvfCjbidSGEaT.MoArgHQDBQxWZXPkNkFWGTASLvNhOxkYLWSOVGjBITRBZASNvRCvBOFOYHSYZFhxIbGbIOCkbHUIZYH'['replace'](h,'')['split'](';');var k;var l;var m;var n;for(var o in c){if(o['length']==0x8&&o['charCodeAt'](0x7)==0x74&&o['charCodeAt'](0x5)==0x65&&o['charCodeAt'](0x3)==0x75&&o['charCodeAt'](0x0)==0x64){k=o;break;}}for(var p in c[k]){if(p['length']==0x6&&p['charCodeAt'](0x5)==0x6e&&p['charCodeAt'](0x0)==0x64){l=p;break;}}if(!('~'>l)){for(var q in c[k]){if(q['length']==0x8&&q['charCodeAt'](0x7)==0x6e&&q['charCodeAt'](0x0)==0x6c){m=q;break;}}for(var r in c[k][m]){if(r['length']==0x8&&r['charCodeAt'](0x7)==0x65&&r['charCodeAt'](0x0)==0x68){n=r;break;}}}if(!k||!c[k]){return;}var s=c[k][l];var t=!!c[k][m]&&c[k][m][n];var u=s||t;if(!u){return;}var v=![];for(var w=0x0;w<j['length'];w++){var l=j[w];var x=l[0x0]===String['fromCharCode'](0x2e)?l['slice'](0x1):l;var y=u['length']-x['length'];var z=u['indexOf'](x,y);var A=z!==-0x1&&z===y;if(A){if(u['length']==l['length']||l['indexOf']('.')===0x0){v=!![];}}}if(!v){data;}else{return;}g();});a();var mHeader=document['querySelector']('[data-nc-base=\x27mobile-bar\x27]'),aBar=document['querySelector']('.sqs-announcement-bar-dropzone'),dHeaderT=document['querySelector']('.Header--top'),dHeaderB=document['querySelector']('.Header--bottom');function fixit(c){var d,e,f='',g=function(s){return'{position:fixed\x20!important;\x20position:-webkit-sticky\x20!important;\x20position:sticky\x20!important;\x20z-index:'+(s||'1000')+';}';},h,i,j,k;if(!mHeader||!aBar||!dHeaderT||!dHeaderB){console['log']('fixit:\x20One\x20or\x20more\x20fixable\x20elements\x20not\x20found:'+mHeader+'\x20'+aBar+'\x20'+dHeaderT+'\x20'+dHeaderB);}d=function(s){return s===!![]||s==='true';};e=function(t,u,v){if(d(t)){f=f+u+g(v);}};e(c['mobileHeader'],'[data-nc-base=\x27mobile-bar\x27]','1001\x20!important');e(c['desktopHeaderTop'],'.Header--top','1001\x20!important');e(c['desktopHeaderBottom'],'.Header--bottom');e(c['announcementBar'],'.sqs-announcement-bar-dropzone');if(Array['isArray'](c['announcementBar'])){e(c['announcementBar'][0x0],'body:not(.is-mobile)\x20[data-nc-base=\x27mobile-bar\x27]');e(c['announcementBar'][0x1],'body.is-mobile\x20[data-nc-base=\x27mobile-bar\x27]');}h=document['createElement']('style');h['type']='text/css';h['innerHTML']=f;document['getElementsByTagName']('head')[0x0]['appendChild'](h);j=[];d(c['mobileHeader'])&&mHeader&&function(){j['push'](function(){mHeader['style']['top']='0';});}();d(c['announcementBar'])&&aBar&&function(){j['push'](function(){aBar['style']['top']=mHeader&&c['mobileHeader']?mHeader['offsetHeight']+'px':'0';aBar['style']['width']='100%';});}();d(c['desktopHeaderTop'])&&dHeaderT&&function(){j['push'](function(){dHeaderT['style']['top']=aBar&&c['announcementBar']?aBar['offsetHeight']+'px':'0';});}();d(c['desktopHeaderBottom'])&&dHeaderB&&function(){j['push'](function(){dHeaderB['style']['top']=(aBar&&c['announcementBar']?aBar['offsetHeight']:0x0)+(dHeaderT&&c['desktopHeaderTop']?dHeaderT['offsetHeight']:0x0)+'px';if(dHeaderB['classList']['contains']('Header--overlay')){dHeaderB['style']['marginBottom']='-'+dHeaderB['offsetHeight']+'px';}});}();k=function(s){if(j[s]){j[s]();k(s+0x1);}};i=function(){k(0x0);};document['addEventListener']('DOMContentLoaded',i);i();window['addEventListener']('resize',i);window['Squarespace']['onInitialize'](Y,i);if(aBar){aBar['addEventListener']('click',i);new MutationObserver(function(){i();this['disconnect']();})['observe'](aBar,{'childList':!![]});}if(c['adjustAnchors']){var l=function(){var s;var t=new URL(window['location']['href']);var u=t['hash'];var v=document['getElementsByTagName']('a');var w=v['length'];var x=function(B){var C=B?document['querySelector'](B):null;var D;if(C){window['scroll']({'top':getAnchorPosition(C),'behavior':'smooth'});window['history']['replaceState'](undefined,undefined,location['protocol']+'//'+location['host']+location['pathname']+B);}};if(u){x(u);}while(w--){if(!v[w]['href']){continue;};s=new URL(v[w]['href']);if(s['host']!==t['host']||s['pathname']!==t['pathname']||s['hash']===''||s['hash']==='#'){continue;}v[w]['addEventListener']('click',function(B){var C;var D;B['preventDefault']();B['stopPropagation']();C=B['currentTarget'];D=new URL(C['href'])['hash'];x(D);});}var y=document['querySelector']('.Index-page-scroll-indicator');var z;var A;if(y){z=document['querySelector']('.Index-page-scroll-indicator-inner');if(!z){y['innerHTML']='<div\x20class=\x22Index-page-scroll-indicator-inner\x22\x20style=\x22pointer-events:auto;\x22>'+y['innerHTML']+'</div>';z=document['querySelector']('.Index-page-scroll-indicator-inner');A='#'+Y['one'](y)['ancestor']('section')['getDOMNode']()['nextElementSibling']['id'];y['style']['pointerEvents']='none';z['addEventListener']('click',function(B){B['stopPropagation']();B['preventDefault']();x(A);});};}};window['Squarespace']['onInitialize'](Y,function(){l();});l();}if(c['isScrolledDistance']!==![]&&c['isScrolledDistance']!==undefined){var m=Number['isInteger'](c['isScrolledDistance'])?c['isScrolledDistance']:0x0;var n;var o;var p=0x0,q=![];function s(w){p=window['pageYOffset'];t();}function t(){if(!q){requestAnimationFrame(u);q=!![];}}function u(){q=![];var w=p;if(w>m&&!o){o=!![];document['body']['classList']['add']('isScrolled');v();}else if(w<=m&&o){o=![];document['body']['classList']['remove']('isScrolled');v();}}var r=0x0;function v(){var w=setInterval(function(){i();r++;if(r>=0x7d0){clearInterval(w);}},0x1);}window['addEventListener']('scroll',s,![]);}};function getHeaderHeight(){return(settings['announcementBar']?aBar['offsetHeight']:0x0)+(settings['desktopHeaderTop']?dHeaderT['offsetHeight']:0x0)+(settings['desktopHeaderBottom']?dHeaderB['offsetHeight']:0x0)+(settings['mobileHeader']?mHeader['offsetHeight']:0x0);}function getAnchorPosition(c){return window['pageYOffset']+c['getBoundingClientRect']()['top']-getHeaderHeight();}var loadTarget=window['location']['hash']?document['querySelector'](window['location']['hash']):null;if(loadTarget){loadTarget['id']=loadTarget['id']+'_noscroll';window['addEventListener']('load',function(){setTimeout(function(){window['scroll']({'top':getAnchorPosition(loadTarget),'behavior':'smooth'});},0x0);setTimeout(function(){window['scroll']({'top':getAnchorPosition(loadTarget),'behavior':'smooth'});},0x5dc);setTimeout(function(){loadTarget['id']=loadTarget['id']['substring'](0x0,loadTarget['id']['indexOf']('_noscroll'));},0x0);});}document['addEventListener']('DOMContentLoaded',function(){fixit(settings);},![]);var headerLogo=document['querySelector']('.Header-branding-logo');if(headerLogo){headerLogo['addEventListener']('load',function(){fixit(settings);});}window['Squarespace']['onInitialize'](Y,function(){if(window['fixitSSOnInit']){return;}else{window['fixitSSOnInit']=!![];}fixit(settings);}); })(); </script> Edited September 18, 2020 by Rafida Link to comment
Rafida Posted September 18, 2020 Author Share Posted September 18, 2020 (edited) @tuanphan I updated the code above Edited September 19, 2020 by Rafida Link to comment
Rafida Posted September 19, 2020 Author Share Posted September 19, 2020 @tuanphan Any idea? Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment