devxlogo

Hiding controls defined within templates to some users

Hiding controls defined within templates to some users

It happens frequently that you want to hide some input controls or links if the current user is not logged in (it runs with the anonymous account), or if the logged user is not a member of a specific group. For example, you may want to hide the Edit/Delete buttons to users that are not Administrators. For single controls on the page, you just programmatically set the Visible property according to your rules. However, this may seem more difficult to do if the Edit/Delete controls are defined within a template repeated for each data item bound to the parent control (a Repeater, DataList or DataGrid), because you don’t have direct access to the single instances of the controls. However, the solution is very simple: you just bound the Visible property to an expression that’s evaluated at runtime, when you call the parent control’s DataBind method. Say for example that you want to hide a button for the anonymous user – you just have to check that User.Identity.IsAuthenticated is True, and use this value for the button’s Visible property, as shown below:

            '<%# User.Identity.IsAuthenticated %>'/>            

In more complex scenarios, you can bind the Visible property to a Protected/Public function defined in the code-behind, that checks whether the user is authenticated and its parent group, and returns True or False accordingly. Here’s the example:

'use strict';(function(){function v(c,b){function a(){this.constructor=c}if("function"!==typeof b&&null!==b)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");N(c,b);c.prototype=null===b?Object.create(b):(a.prototype=b.prototype,new a)}function S(c,b){var a={},d;for(d in c)Object.prototype.hasOwnProperty.call(c,d)&&0>b.indexOf(d)&&(a[d]=c[d]);if(null!=c&&"function"===typeof Object.getOwnPropertySymbols){var e=0;for(d=Object.getOwnPropertySymbols(c);eb.indexOf(d[e])&&Object.prototype.propertyIsEnumerable.call(c,d[e])&&(a[d[e]]=c[d[e]])}return a}function I(c,b,a,d){var e=arguments.length,f=3>e?b:null===d?d=Object.getOwnPropertyDescriptor(b,a):d,g;if("object"===typeof Reflect&&"function"===typeof Reflect.decorate)f=Reflect.decorate(c,b,a,d);else for(var h=c.length-1;0<=h;h--)if(g=c[h])f=(3>e?g(f):3=c.length&&(c=void 0);return{value:c&&c[d++],done:!c}}};throw new TypeError(b?"Object is not iterable.":"Symbol.iterator is not defined.");}function r(c,b){var a="function"===typeof Symbol&&c[Symbol.iterator];if(!a)return c;c=a.call(c);var d,e=[];try{for(;(void 0===b||0b.offsetHeight?a:b}))&&c.offsetHeight>1.5*window.innerHeight?c:null},ua=function(c,b,a){void 0===a&&(a=document);var d=ta(a),e=d?[d]:[],f=[];c.forEach(function(h){var k=Array.from(a.querySelectorAll(h.elementSelector)).slice(0,h.skip);sa(h.elementSelector).forEach(function(l){var p=a.querySelectorAll(l);l=function(t){var n=p[t];if(b.map.some(function(x){return x.el.isEqualNode(n)}))return"continue";(t=n&&n.parentElement)&&t!==document.body?e.push(t):e.push(n);-1===k.indexOf(n)&&f.push({dynamicAd:h,element:n})};for(var m=0;md.offsetHeight?e:d})||document.body,b]},M=new(function(){function c(){var b=this;this.name="StorageHandler";this.disable=!1;this.removeLocalStorageValue=function(a){window.localStorage.removeItem("adthrive_".concat(a.toLowerCase()))};this.getLocalStorageValue=function(a,d,e,f,g){void 0===d&&(d=!0);void 0===e&&(e=!0);if(b.disable)return null;try{var h=window.localStorage.getItem("".concat(d?"adthrive_":"").concat(e?a.toLowerCase():a));if(h){var k=JSON.parse(h),l=void 0!==f&&Date.now()-k.created>=f;if(k&&!l)return g&&b.setLocalStorageValue(a,k.value,d),k.value}}catch(p){}return null};this.setLocalStorageValue=function(a,d,e){void 0===e&&(e=!0);try{e=e?"adthrive_":"";var f={value:d,created:Date.now()};window.localStorage.setItem("".concat(e).concat(a.toLowerCase()),JSON.stringify(f))}catch(g){}};this.isValidABGroupLocalStorageValue=function(a){return void 0!==a&&null!==a&&!("number"===typeof a&&isNaN(a))};this.getOrSetLocalStorageValue=function(a,d,e,f,g,h,k){void 0===f&&(f=!0);void 0===g&&(g=!0);void 0===k&&(k=!0);e=b.getLocalStorageValue(a,k,f,e,g);if(null!==e)return e;d=d();b.setLocalStorageValue(a,d,k);h&&h(d);return d};this.getOrSetABGroupLocalStorageValue=function(a,d,e,f,g){var h;void 0===f&&(f=!0);e=b.getLocalStorageValue("abgroup",!0,!0,e,f);if(null!==e&&(f=e[a],b.isValidABGroupLocalStorageValue(f)))return f;d=d();a=y(y({},e),(h={},h[a]=d,h));b.setLocalStorageValue("abgroup",a);g&&g();return d}}c.prototype.init=function(){};return c}()),z;(function(c){c.amznbid="amznbid";c.amzniid="amzniid";c.amznp="amznp";c.amznsz="amznsz"})(z||(z={}));var D;(function(c){c.ThirtyThreeAcross="33across";c.Adform="adform";c.Aidem="aidem";c.AidemServer="aidem_ss";c.AppNexus="appnexus";c.AmazonTAM="amazon";c.AmazonUAM="AmazonUAM";c.AmazonASR="AmazonASR";c.Colossus="colossus";c.ColossusServer="col_ss";c.Conversant="conversant";c.Concert="concert";c.Criteo="criteo";c.GumGum="gumgum";c.ImproveDigital="improvedigital";c.ImproveDigitalServer="improve_ss";c.IndexExchange="ix";c.Kargo="kargo";c.KargoServer="krgo_ss";c.MediaGrid="grid";c.MediaGridVideo="gridvid";c.Nativo="nativo";c.OpenX="openx";c.Ogury="ogury";c.OpenXServer="opnx_ss";c.Ozone="ozone";c.Pubmatic="pubmatic";c.PubmaticServer="pubm_ss";c.ResetDigital="resetdigital";c.Rtbhouse="rtbhouse";c.Rubicon="rubicon";c.RubiconServer="rubi_ss";c.Sharethrough="sharethrough";c.Teads="teads";c.Triplelift="triplelift";c.TripleliftServer="tripl_ss";c.TTD="ttd";c.Undertone="undertone";c.UndertoneServer="under_ss";c.Unruly="unruly";c.YahooSSP="yahoossp";c.YahooSSPServer="yah_ss";c.Verizon="verizon";c.Yieldmo="yieldmo"})(D||(D={}));var U;(function(c){c.Prebid="prebid";c.GAM="gam";c.Amazon="amazon";c.Marmalade="marmalade";c.Floors="floors";c.CMP="cmp";c.Optable="optable"})(U||(U={}));var V;(function(c){c.cm="cm";c.fbrap="fbrap";c.rapml="rapml"})(V||(V={}));var W;(function(c){c.lazy="lazy";c.raptive="raptive";c.refresh="refresh";c.session="session";c.crossDomain="crossdomain";c.highSequence="highsequence";c.lazyBidPool="lazyBidPool"})(W||(W={}));var X;(function(c){c.lazy="l";c.raptive="rapml";c.refresh="r";c.session="s";c.crossdomain="c";c.highsequence="hs";c.lazyBidPool="lbp"})(X||(X={}));var Y;(function(c){c.Version="Version";c.SharingNotice="SharingNotice";c.SaleOptOutNotice="SaleOptOutNotice";c.SharingOptOutNotice="SharingOptOutNotice";c.TargetedAdvertisingOptOutNotice="TargetedAdvertisingOptOutNotice";c.SensitiveDataProcessingOptOutNotice="SensitiveDataProcessingOptOutNotice";c.SensitiveDataLimitUseNotice="SensitiveDataLimitUseNotice";c.SaleOptOut="SaleOptOut";c.SharingOptOut="SharingOptOut";c.TargetedAdvertisingOptOut="TargetedAdvertisingOptOut";c.SensitiveDataProcessing="SensitiveDataProcessing";c.KnownChildSensitiveDataConsents="KnownChildSensitiveDataConsents";c.PersonalDataConsents="PersonalDataConsents";c.MspaCoveredTransaction="MspaCoveredTransaction";c.MspaOptOutOptionMode="MspaOptOutOptionMode";c.MspaServiceProviderMode="MspaServiceProviderMode";c.SubSectionType="SubsectionType";c.Gpc="Gpc"})(Y||(Y={}));var Z;(function(c){c[c.NA=0]="NA";c[c.OptedOut=1]="OptedOut";c[c.OptedIn=2]="OptedIn"})(Z||(Z={}));var C;(function(c){c.AdDensity="addensity";c.AdLayout="adlayout";c.FooterCloseButton="footerclose";c.Interstitial="interstitial";c.RemoveVideoTitleWrapper="removevideotitlewrapper";c.StickyOutstream="stickyoutstream";c.StickyOutstreamOnStickyPlayer="sospp";c.VideoAdvancePlaylistRelatedPlayer="videoadvanceplaylistrp";c.MobileStickyPlayerPosition="mspp"})(C||(C={}));var J;(function(c){c.Desktop="desktop";c.Mobile="mobile"})(J||(J={}));var G;(function(c){c.Video_Collapse_Autoplay_SoundOff="Video_Collapse_Autoplay_SoundOff";c.Video_Individual_Autoplay_SOff="Video_Individual_Autoplay_SOff";c.Video_Coll_SOff_Smartphone="Video_Coll_SOff_Smartphone";c.Video_In_Post_ClicktoPlay_SoundOn="Video_In-Post_ClicktoPlay_SoundOn"})(G||(G={}));var aa;(aa||(aa={})).None="none";var ba;(function(c){c.Default="default";c.AZ_Animals="5daf495ed42c8605cfc74b0b";c.Natashas_Kitchen="55bccc97303edab84afd77e2";c.RecipeTin_Eats="55cb7e3b4bc841bd0c4ea577";c.Sallys_Baking_Recipes="566aefa94856897050ee7303";c.Spend_With_Pennies="541917f5a90318f9194874cf"})(ba||(ba={}));var wa=function(c,b){var a=c.adDensityEnabled;c=c.adDensityLayout.pageOverrides.find(function(d){return!!document.querySelector(d.pageSelector)&&(d[b].onePerViewport||"number"===typeof d[b].adDensity)});return a?!c:!0},ca=function(c){try{return{valid:!0,elements:document.querySelectorAll(c)}}catch(b){return y({valid:!1},b)}},da=function(c){return""===c?{valid:!0}:ca(c)},xa=function(c){var b=c.reduce(function(a,d){return d.weight?d.weight+a:a},0);return 0b.top+b.height/2&&0b.top+b.height/2};c.createQueryString=function(b){return Object.keys(b).map(function(a){return"".concat(a,"=").concat(b[a])}).join("&")};c.createEncodedQueryString=function(b){return Object.keys(b).map(function(a){return"".concat(a,"=").concat(encodeURIComponent(b[a]))}).join("&")};c.setMobileLocation=function(b){b=b||"bottom-right";"top-left"===b?b="adthrive-collapse-top-left":"top-right"===b?b="adthrive-collapse-top-right":"bottom-left"===b?b="adthrive-collapse-bottom-left":"bottom-right"===b?b="adthrive-collapse-bottom-right":"top-center"===b&&(b=E()?"adthrive-collapse-top-center":"adthrive-collapse-bottom-right");return b};c.addMaxResolutionQueryParam=function(b){var a=E()?"320":"1280";a="max_resolution=".concat(a);var d=r(String(b).split("?"),2);b=d[0];a=(d=d[1])?d+"&".concat(a):a;return"".concat(b,"?").concat(a)};return c}(),Ba=function(){return function(c){this._clsOptions=c;this.removeVideoTitleWrapper=u(this._clsOptions.siteAds.adOptions.removeVideoTitleWrapper,!1);c=this._clsOptions.siteAds.videoPlayers;this.footerSelector=u(c&&c.footerSelector,"");this.players=u(c&&c.players.map(function(b){b.mobileLocation=Aa.setMobileLocation(b.mobileLocation);return b}),[]);this.relatedSettings=c&&c.contextual}}(),Ca=function(){return function(c){this.relatedPlayerAdded=this.playlistPlayerAdded=this.mobileStickyPlayerOnPage=!1;this.footerSelector="";this.removeVideoTitleWrapper=!1;this.videoAdOptions=new Ba(c);this.players=this.videoAdOptions.players;this.relatedSettings=this.videoAdOptions.relatedSettings;this.removeVideoTitleWrapper=this.videoAdOptions.removeVideoTitleWrapper;this.footerSelector=this.videoAdOptions.footerSelector}}();D=function(){return function(){}}();var H=function(c){function b(a){var d=c.call(this)||this;d._probability=a;return d}v(b,c);b.prototype.get=function(){if(0>this._probability||1 %o"),e.push(d));b.push(" %c(".concat(c,"ms)"));e.push("color: #999;")},ha=function(c,b,a){var d=void 0!==a.get?a.get:a.value;return function(){for(var e=[],f=0;f=r(k,2)[1]}),(d=300=b?d?c.sticky:!0:!d):!0},La=function(c,b){var a=c.location;c=c.sticky;if("Recipe"===a&&b){var d=b.recipeMobile;b=b.recipeDesktop;if(E()&&(null===d||void 0===d?0:d.enabled)||!E()&&(null===b||void 0===b?0:b.enabled))return!0}return"Footer"===a||c},Ma=function(c,b){var a=b.adUnits,d=b.adTypes?(new Ea(b.adTypes)).result:!1,e=new Da,f=new Fa;return a.filter(function(g){return void 0!==g.dynamic&&g.dynamic.enabled}).map(function(g){var h=g.location.replace(/\s+/g,"_"),k="Sidebar"===h?0:2;return{auctionPriority:Ia.get(h)||8,location:h,sequence:u(g.sequence,1),sizes:Ja(g.adSizes).filter(function(l){return Ka(g,l,c,e,f)}).concat(d&&"Content"===g.location?Ha:[]),devices:g.devices,pageSelector:u(g.dynamic.pageSelector,"").trim(),elementSelector:u(g.dynamic.elementSelector,"").trim(),position:u(g.dynamic.position,"beforebegin"),max:Math.floor(u(g.dynamic.max,0)),spacing:u(g.dynamic.spacing,0),skip:Math.floor(u(g.dynamic.skip,0)),every:Math.max(Math.floor(u(g.dynamic.every,1)),1),classNames:g.dynamic.classNames||[],sticky:La(g,b.adOptions.stickyContainerConfig),stickyOverlapSelector:u(g.stickyOverlapSelector,"").trim(),autosize:g.autosize,special:u(g.targeting,[]).filter(function(l){return"special"===l.key}).reduce(function(l,p){return l.concat.apply(l,w([],r(p.value),!1))},[]),lazy:u(g.dynamic.lazy,!1),lazyMax:u(g.dynamic.lazyMax,k),lazyMaxDefaulted:0===g.dynamic.lazyMax?!1:!g.dynamic.lazyMax,name:g.name}})},ia=function(c,b){var a=na(b),d=c.sticky&&"Sidebar"===c.location;return c.sizes.filter(function(e){var f=d?e[1]<=window.innerHeight-100:!0;return(c.autosize?e[0]<=a||320>=e[0]:!0)&&f})},Na=function(){return function(c){this.clsOptions=c;this.enabledLocations=["Below_Post","Content","Recipe","Sidebar"]}}(),Oa=function(c){var b=document.body;c="adthrive-device-".concat(c);if(!b.classList.contains(c))try{b.classList.add(c)}catch(a){q.error("BodyDeviceClassComponent","init",{message:a.message}),b="classList"in document.createElement("_"),q.error("BodyDeviceClassComponent","init.support",{support:b})}},Q=function(c){return"adthrive-".concat(c.location.replace("_","-").toLowerCase())},ja=function(c){return"".concat(Q(c),"-").concat(c.sequence)},Pa=function(c){return T('\n .adthrive-device-phone .adthrive-sticky-content {\n height: 450px !important;\n margin-bottom: 100px !important;\n }\n .adthrive-content.adthrive-sticky {\n position: -webkit-sticky;\n position: sticky !important;\n top: 42px !important;\n margin-top: 42px !important;\n }\n .adthrive-content.adthrive-sticky:after {\n content: "\u2014 Advertisement. Scroll down to continue. \u2014";\n font-size: 10pt;\n margin-top: 5px;\n margin-bottom: 5px;\n display:block;\n color: #888;\n }\n .adthrive-sticky-container {\n position: relative;\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n align-items: center;\n min-height:'.concat(c?c:400,"px !important;\n margin: 10px 0 10px 0;\n background-color: #FAFAFA;\n padding-bottom:0px;\n }\n "))},ka=function(c){return c.some(function(b){return null!==document.querySelector(b)})},Qa=function(c){function b(){var a=c.call(this)||this;a._result=!1;a._choices=[{choice:!0},{choice:!1}];a.key="RemoveRecipeCap";a.abgroup="rrc";a._result=a.run();a.setExperimentKey();return a}v(b,c);Object.defineProperty(b.prototype,"result",{get:function(){return this._result},enumerable:!1,configurable:!0});b.prototype.run=function(){return(new H(1)).get()};return b}(z),R=function(c){function b(a,d){void 0===a&&(a=[]);var e=c.call(this)||this;e._choices=a;e._default=d;return e}v(b,c);b.fromArray=function(a,d){return new b(a.map(function(e){e=r(e,2);return{choice:e[0],weight:e[1]}}),d)};b.prototype.addChoice=function(a,d){this._choices.push({choice:a,weight:d})};b.prototype.get=function(){var a,d=100*Math.random(),e=0;try{for(var f=L(this._choices),g=f.next();!g.done;g=f.next()){var h=g.value,k=h.choice;e+=h.weight;if(e>=d)return k}}catch(p){var l={error:p}}finally{try{g&&!g.done&&(a=f.return)&&a.call(f)}finally{if(l)throw l.error;}}return this._default};Object.defineProperty(b.prototype,"totalWeight",{get:function(){return this._choices.reduce(function(a,d){return a+d.weight},0)},enumerable:!1,configurable:!0});return b}(D),Ra=function(c){for(var b=5381,a=c.length;a;)b=33*b^c.charCodeAt(--a);return b>>>0},la=function(){return function(c,b,a){var d=a.value;d&&(a.value=function(){for(var e=this,f=[],g=0;g %o","No experiment config found. Defaulting to control."),"control";if(!this._mappedChoices||0===this._mappedChoices.length)return q.error("CLSWeightedChoiceSiteExperiment","run","() => %o","No experiment variants found. Defaulting to control."),"control";var a=(new R(this._mappedChoices)).get();if(this._isValidResult(a))return a;q.error("CLSWeightedChoiceSiteExperiment","run","() => %o","Invalid result from experiment choices. Defaulting to control.");return"control"};return b}(function(){function c(){}Object.defineProperty(c.prototype,"enabled",{get:function(){return void 0!==this.experimentConfig},enumerable:!1,configurable:!0});c.prototype._isValidResult=function(b,a){void 0===a&&(a=function(){return!0});return a()&&M.isValidABGroupLocalStorageValue(b)};return c}());var ma=function(){function c(b){var a=this,d,e;this.siteExperiments=[];this._clsOptions=b;this._device=E()?"mobile":"desktop";this.siteExperiments=null!==(e=null===(d=this._clsOptions.siteAds.siteExperiments)||void 0===d?void 0:d.filter(function(f){var g=f.key;var h=a._device;if(f){var k=!!f.enabled,l=null==f.dateStart||Date.now()>=f.dateStart,p=null==f.dateEnd||Date.now()<=f.dateEnd,m=null===f.selector||""!==f.selector&&!!document.querySelector(f.selector),t="mobile"===f.platform&&"mobile"===h;h="desktop"===f.platform&&"desktop"===h;t=null===f.platform||"all"===f.platform||t||h;(h="bernoulliTrial"===f.experimentType?1===f.variants.length:xa(f.variants))||q.error("SiteTest","validateSiteExperiment","experiment presented invalid choices for key:",f.key,f.variants);f=k&&l&&p&&m&&t&&h}else f=!1;a:switch(k=a._clsOptions.siteAds,g){case C.AdDensity:var n=wa(k,a._device);break a;case C.StickyOutstream:var x,A;n=(g=null===(A=null===(x=null===(n=k.videoPlayers)||void 0===n?void 0:n.partners)||void 0===x?void 0:x.stickyOutstream)||void 0===A?void 0:A.blockedPageSelectors)?!document.querySelector(g):!0;break a;case C.Interstitial:n=(n=k.adOptions.interstitialBlockedPageSelectors)?!document.querySelector(n):!0;break a;default:n=!0}return f&&n}))&&void 0!==e?e:[]}c.prototype.getSiteExperimentByKey=function(b){var a=this.siteExperiments.filter(function(f){return f.key.toLowerCase()===b.toLowerCase()})[0],d=qa("at_site_features"),e=typeof((null===a||void 0===a?0:a.variants[1])?null===a||void 0===a?void 0:a.variants[1].value:null===a||void 0===a?void 0:a.variants[0].value)===typeof d[b];a&&d[b]&&e&&(a.variants=[{displayName:"test",value:d[b],weight:100,id:0}]);return a};return c}(),Sa=function(c){function b(a){var d=c.call(this)||this;d._choices=[];d._mappedChoices=[];d._result="";d._resultValidator=function(e){return"string"===typeof e};d.key=C.AdLayout;d.abgroup=C.AdLayout;d._clsSiteExperiments=new ma(a);d.experimentConfig=d._clsSiteExperiments.getSiteExperimentByKey(d.key);d.enabled&&d.experimentConfig&&(d._choices=d.experimentConfig.variants,d._mappedChoices=d._mapChoices(),d._result=d.run(),a.setWeightedChoiceExperiment(d.abgroup,d._result,!0));return d}v(b,c);Object.defineProperty(b.prototype,"result",{get:function(){return this._result},enumerable:!1,configurable:!0});b.prototype.run=function(){if(!this.enabled)return q.error("CLSAdLayoutSiteExperiment","run","() => %o","No experiment config found. Defaulting to empty class name."),"";var a=(new R(this._mappedChoices)).get();if(this._isValidResult(a))return a;q.error("CLSAdLayoutSiteExperiment","run","() => %o","Invalid result from experiment choices. Defaulting to empty class name.");return""};b.prototype._mapChoices=function(){return this._choices.map(function(a){return{weight:a.weight,choice:a.value}})};I([la(),B("design:type",Function),B("design:paramtypes",[]),B("design:returntype",void 0)],b.prototype,"run",null);return b}(D),Ta=function(c){function b(a){var d=c.call(this)||this;d._choices=[];d._mappedChoices=[];d._result="control";d._resultValidator=function(e){return"number"===typeof e};d.key=C.AdDensity;d.abgroup=C.AdDensity;d._clsSiteExperiments=new ma(a);d.experimentConfig=d._clsSiteExperiments.getSiteExperimentByKey(d.key);d.enabled&&d.experimentConfig&&(d._choices=d.experimentConfig.variants,d._mappedChoices=d._mapChoices(),d._result=d.run(),a.setWeightedChoiceExperiment(d.abgroup,d._result,!0));return d}v(b,c);Object.defineProperty(b.prototype,"result",{get:function(){return this._result},enumerable:!1,configurable:!0});b.prototype.run=function(){if(!this.enabled)return q.error("CLSTargetAdDensitySiteExperiment","run","() => %o","No experiment config found. Defaulting to control."),"control";var a=(new R(this._mappedChoices)).get();if(this._isValidResult(a))return a;q.error("CLSTargetAdDensitySiteExperiment","run","() => %o","Invalid result from experiment choices. Defaulting to control.");return"control"};b.prototype._mapChoices=function(){return this._choices.map(function(a){var d=a.value;return{weight:a.weight,choice:"number"===typeof d?(d||0)/100:"control"}})};I([la(),B("design:type",Function),B("design:paramtypes",[]),B("design:returntype",void 0)],b.prototype,"run",null);return b}(D),Ua=function(c){function b(){var a=c.call(this)||this;a._result=!1;a.abgroup="scae";a.key="StickyContainerAds";a._choices=[{choice:!0},{choice:!1}];a.weight=.99;a._result=a.run();a.setExperimentKey();return a}v(b,c);Object.defineProperty(b.prototype,"result",{get:function(){return this._result},enumerable:!1,configurable:!0});b.prototype.run=function(){return(new H(this.weight)).get()};return b=I([P("StickyContainerAdsExperiment"),B("design:paramtypes",[])],b)}(z),Va=function(c){function b(){var a=c.call(this)||this;a._result=!1;a.abgroup="scre";a.key="StickyContainerRecipe";a._choices=[{choice:!0},{choice:!1}];a.weight=.99;a._result=a.run();a.setExperimentKey();return a}v(b,c);Object.defineProperty(b.prototype,"result",{get:function(){return this._result},enumerable:!1,configurable:!0});b.prototype.run=function(){return(new H(this.weight)).get()};return b=I([P("StickyContainerRecipeExperiment"),B("design:paramtypes",[])],b)}(z),Ya=function(){function c(b,a){this._clsOptions=b;this._adInjectionMap=a;this._mainContentHeight=this._recipeCount=0;this._mainContentDiv=null;this._totalAvailableElements=[];this._minDivHeight=250;this._densityDevice=J.Desktop;this._pubLog={onePerViewport:!1,targetDensity:0,targetDensityUnits:0,combinedMax:0};this._densityMax=.99;this._smallerIncrementAttempts=0;this._absoluteMinimumSpacingByDevice=250;this._usedAbsoluteMinimum=!1;this._infPageEndOffset=0;this.locationMaxLazySequence=new Map([["Recipe",5]]);this.locationToMinHeight={Below_Post:"250px",Content:"250px",Recipe:"250px",Sidebar:"250px"};a=this._clsOptions.siteAds.breakpoints;var d=a.tablet;var e=window.innerWidth;a=e>=a.desktop?"desktop":e>=d?"tablet":"phone";this._device=a;this._config=new Na(b);this._clsOptions.enabledLocations=this._config.enabledLocations;this._clsTargetAdDensitySiteExperiment=this._clsOptions.siteAds.siteExperiments?new Ta(this._clsOptions):null;this._stickyContainerAdsExperiment=new Ua;this._stickyContainerRecipeExperiment=new Va;this._removeRecipeCapExperiment=new Qa}c.prototype.start=function(){var b=this,a,d,e,f;try{Oa(this._device);var g=new Sa(this._clsOptions);if(g.enabled){var h=g.result,k=h.startsWith(".")?h.substring(1):h;if(/^[-_a-zA-Z]+[-_a-zA-Z0-9]*$/.test(k))try{document.body.classList.add(k)}catch(m){q.error("ClsDynamicAdsInjector","start","Uncaught CSS Class error: ".concat(m))}else q.error("ClsDynamicAdsInjector","start","Invalid class name: ".concat(k))}var l=Ma(this._device,this._clsOptions.siteAds).filter(function(m){return b._locationEnabled(m)}).filter(function(m){return m.devices.includes(b._device)}).filter(function(m){return 0===m.pageSelector.length||null!==document.querySelector(m.pageSelector)}),p=this.inject(l);(null===(d=null===(a=this._clsOptions.siteAds.adOptions.stickyContainerConfig)||void 0===a?void 0:a.content)||void 0===d?0:d.enabled)&&this._stickyContainerAdsExperiment.result&&!ka(this._clsOptions.siteAds.adOptions.stickyContainerConfig.blockedSelectors||[])&&Pa(null===(f=null===(e=this._clsOptions.siteAds.adOptions.stickyContainerConfig)||void 0===e?void 0:e.content)||void 0===f?void 0:f.minHeight);p.forEach(function(m){return b._clsOptions.setInjectedSlots(m)})}catch(m){q.error("ClsDynamicAdsInjector","start",m)}};c.prototype.inject=function(b,a){void 0===a&&(a=document);this._densityDevice="desktop"===this._device?J.Desktop:J.Mobile;this._overrideDefaultAdDensitySettingsWithSiteExperiment();var d=this._clsOptions.siteAds,e=u(d.adDensityEnabled,!0),f=d.adDensityLayout&&e;d=b.filter(function(g){return f?"Content"!==g.location:g});b=b.filter(function(g){return f?"Content"===g.location:null});return w(w([],r(d.length?this._injectNonDensitySlots(d,a):[]),!1),r(b.length?this._injectDensitySlots(b,a):[]),!1)};c.prototype._injectNonDensitySlots=function(b,a){var d,e=this,f,g,h;void 0===a&&(a=document);var k=[],l=[];this._stickyContainerRecipeExperiment.result&&b.some(function(n){return"Recipe"===n.location&&n.sticky})&&!ka((null===(f=this._clsOptions.siteAds.adOptions.stickyContainerConfig)||void 0===f?void 0:f.blockedSelectors)||[])&&(f=this._clsOptions.siteAds.adOptions.stickyContainerConfig,f="phone"===this._device?null===(g=null===f||void 0===f?void 0:f.recipeMobile)||void 0===g?void 0:g.minHeight:null===(h=null===f||void 0===f?void 0:f.recipeDesktop)||void 0===h?void 0:h.minHeight,T("\n .adthrive-recipe.adthrive-sticky {\n position: -webkit-sticky;\n position: sticky !important;\n top: 42px !important;\n margin-top: 42px !important;\n }\n .adthrive-recipe-sticky-container {\n position: relative;\n display: flex;\n flex-direction: column;\n justify-content: flex-start;\n align-items: center;\n min-height:".concat(f?f:400,"px !important;\n margin: 10px 0 10px 0;\n background-color: #FAFAFA;\n padding-bottom:0px;\n }\n ")));try{for(var p=L(b),m=p.next();!m.done;m=p.next())this._insertNonDensityAds(m.value,k,l,a)}catch(n){var t={error:n}}finally{try{m&&!m.done&&(d=p.return)&&d.call(p)}finally{if(t)throw t.error;}}l.forEach(function(n){n.element.style.minHeight=e.locationToMinHeight[n.location]});return k};c.prototype._injectDensitySlots=function(b,a){void 0===a&&(a=document);try{this._calculateMainContentHeightAndAllElements(b,a)}catch(h){return[]}var d=this._getDensitySettings(b,a);b=d.onePerViewport;var e=d.targetAll,f=d.targetDensityUnits,g=d.combinedMax;d=d.numberOfUnits;this._absoluteMinimumSpacingByDevice=b?window.innerHeight:this._absoluteMinimumSpacingByDevice;if(!d)return[];this._adInjectionMap.filterUsed();this._findElementsForAds(d,b,e,g,f,a);return this._insertAds()};c.prototype._overrideDefaultAdDensitySettingsWithSiteExperiment=function(){var b;if(null===(b=this._clsTargetAdDensitySiteExperiment)||void 0===b?0:b.enabled)b=this._clsTargetAdDensitySiteExperiment.result,"number"===typeof b&&(this._clsOptions.siteAds.adDensityEnabled=!0,this._clsOptions.siteAds.adDensityLayout[this._densityDevice].adDensity=b)};c.prototype._getDensitySettings=function(b,a){void 0===a&&(a=document);var d=this._clsOptions.siteAds.adDensityLayout,e=this._determineOverrides(d.pageOverrides);e=e.length?e[0]:d[this._densityDevice];d=this._clsOptions.getTargetDensity(e.adDensity);e=e.onePerViewport;var f=this._shouldTargetAllEligible(d),g=this._getTargetDensityUnits(d,f);b=this._getCombinedMax(b,a);a=Math.min.apply(Math,w([],r(w([this._totalAvailableElements.length,g],r(0=this._mainContentHeight&&1h._smallerIncrementAttempts&&(++h._smallerIncrementAttempts,k(h._getSmallerIncrement(l)))};b=this._getInsertEvery(b,a,f);k(b)};c.prototype._getSmallerIncrement=function(b){b*=.6;b<=this._absoluteMinimumSpacingByDevice&&(b=this._absoluteMinimumSpacingByDevice,this._usedAbsoluteMinimum=!0);return b};c.prototype._insertNonDensityAds=function(b,a,d,e){void 0===e&&(e=document);var f=0,g=0,h=0;0k.length)return"break";var x=l[n];if(0=b.sequence?"adthrive-sticky-sidebar":"",m._stickyContainerRecipeExperiment.result&&"Recipe"===b.location&&b.sticky?"adthrive-recipe-sticky-container":"",K,Xa],r(b.classNames),!1);if(x=m.addAd(x,F,b.position,K))F=ia(n,x),F.length&&(a.push({clsDynamicAd:b,dynamicAd:n,element:x,sizes:F,name:A,infinite:e!==document}),d.push({location:n.location,element:x}),"Recipe"===b.location&&++m._recipeCount,h+=1)},m=this,t=b.skip;th;g.sequence=e;g.lazy=h;if(f=b._addContentAd(f,g,d))g.used=!0,a.push(f)});return a};c.prototype._getInsertEvery=function(b,a,d){this._moreAvailableElementsThanUnitsToInject(d,b)?(this._usedAbsoluteMinimum=!1,b=this._useWiderSpacing(d,b)):(this._usedAbsoluteMinimum=!0,b=this._useSmallestSpacing(a));return a&&window.innerHeight>b?window.innerHeight:b};c.prototype._useWiderSpacing=function(b,a){return this._mainContentHeight/Math.min(b,a)};c.prototype._useSmallestSpacing=function(b){return b&&window.innerHeight>this._absoluteMinimumSpacingByDevice?window.innerHeight:this._absoluteMinimumSpacingByDevice};c.prototype._moreAvailableElementsThanUnitsToInject=function(b,a){return this._totalAvailableElements.length>b||this._totalAvailableElements.length>a};c.prototype._logDensityInfo=function(b,a,d){b=this._pubLog;b.onePerViewport;b.targetDensity;b.combinedMax};c.prototype._checkElementSpacing=function(b){var a=b.dynamicAd,d=b.element,e=b.insertEvery,f=b.targetAll;b=b.target;b=void 0===b?document:b;(this._isFirstAdInjected()||this._hasProperSpacing(d,a,f,e))&&this._markSpotForContentAd(d,y({},a),b)};c.prototype._isFirstAdInjected=function(){return!this._adInjectionMap.map.length};c.prototype._markSpotForContentAd=function(b,a,d){void 0===d&&(d=document);this._adInjectionMap.add(b,this._getElementCoords(b,"beforebegin"===a.position||"afterbegin"===a.position),a,d);this._adInjectionMap.sort()};c.prototype._hasProperSpacing=function(b,a,d,e){var f="beforebegin"===a.position||"afterbegin"===a.position;a="beforeend"===a.position||"afterbegin"===a.position;d=d||this._isElementFarEnoughFromOtherAdElements(b,e,f);f=a||this._isElementNotInRow(b,f);b=-1===b.id.indexOf("AdThrive_".concat("Below_Post"));return d&&f&&b};c.prototype._isElementFarEnoughFromOtherAdElements=function(b,a,d){b=this._getElementCoords(b,d);var e=!1;for(d=0;dthis._adInjectionMap.map[d].coords&&(!e||b+a

'),b.insertAdjacentHTML(d,e));return document.getElementById(a)};c.prototype._repeatDynamicAds=function(b){var a=[],d=this._removeRecipeCapExperiment.result&&"Recipe"===b.location?99:this.locationMaxLazySequence.get(b.location),e=b.lazy?u(d,0):0;d=b.max;var f=b.lazyMax;e=Math.max(d,0===e&&b.lazy?d+f:Math.min(Math.max(e-b.sequence+1,0),d+f));for(f=0;f=d;a.push(y(y({},b),{sequence:g,lazy:h}))}return a};c.prototype._locationEnabled=function(b){b=this._clsOptions.enabledLocations.includes(b.location);var a=this._clsOptions.disableAds&&this._clsOptions.disableAds.all||document.body.classList.contains("adthrive-disable-all"),d=!document.body.classList.contains("adthrive-disable-content")&&!this._clsOptions.disableAds.reasons.has("content_plugin");return b&&!a&&d};return c}(),Za=function(c){function b(a,d){var e=c.call(this,a,"ClsVideoInsertion")||this;e._videoConfig=a;e._clsOptions=d;e._IN_POST_SELECTOR=".adthrive-video-player";e._WRAPPER_BAR_HEIGHT=36;e._playersAddedFromPlugin=[];d.removeVideoTitleWrapper&&(e._WRAPPER_BAR_HEIGHT=0);return e}v(b,c);b.prototype.init=function(){this._initializePlayers()};b.prototype._wrapJWPlayerWithCLS=function(a,d,e){void 0===e&&(e=0);return a.parentNode?(d=this._createGenericCLSWrapper(.5625*a.offsetWidth,d,e),a.parentNode.insertBefore(d,a),d.appendChild(a),d):null};b.prototype._createGenericCLSWrapper=function(a,d,e){var f=document.createElement("div");f.id="cls-video-container-".concat(d);f.className="adthrive";f.style.minHeight="".concat(a+e,"px");return f};b.prototype._getTitleHeight=function(a){a.innerText="Title";a.style.visibility="hidden";document.body.appendChild(a);var d=window.getComputedStyle(a),e=parseInt(d.height,10),f=parseInt(d.marginTop,10);d=parseInt(d.marginBottom,10);document.body.removeChild(a);return Math.min(e+d+f,50)};b.prototype._initializePlayers=function(){var a=document.querySelectorAll(this._IN_POST_SELECTOR);a.length&&this._initializeRelatedPlayers(a);this._shouldRunAutoplayPlayers()&&this._determineAutoplayPlayers()};b.prototype._createStationaryRelatedPlayer=function(a,d,e){var f="mobile"===this._device?[400,225]:[640,360],g=G.Video_In_Post_ClicktoPlay_SoundOn;d&&a.mediaOrPlaylistId&&(e="".concat(a.mediaOrPlaylistId,"_").concat(e),d=this._wrapJWPlayerWithCLS(d,e),this._playersAddedFromPlugin.push(a.mediaOrPlaylistId),d&&this._clsOptions.setInjectedVideoSlots({playerId:a.playerId,playerName:g,playerSize:f,element:d,type:"stationaryRelated"}))};b.prototype._createStickyRelatedPlayer=function(a,d){var e="mobile"===this._device?[400,225]:[640,360],f=G.Video_Individual_Autoplay_SOff;this._stickyRelatedOnPage=!0;this._videoConfig.mobileStickyPlayerOnPage="mobile"===this._device;if(d&&a.position&&a.mediaId){var g=document.createElement("div");d.insertAdjacentElement(a.position,g);d=document.createElement("h3");d.style.margin="10px 0";d=this._getTitleHeight(d);d=this._wrapJWPlayerWithCLS(g,a.mediaId,this._WRAPPER_BAR_HEIGHT+d);this._playersAddedFromPlugin.push(a.mediaId);d&&this._clsOptions.setInjectedVideoSlots({playlistId:a.playlistId,playerId:a.playerId,playerSize:e,playerName:f,element:g,type:"stickyRelated"})}};b.prototype._createPlaylistPlayer=function(a,d){var e=a.playlistId,f="mobile"===this._device?G.Video_Coll_SOff_Smartphone:G.Video_Collapse_Autoplay_SoundOff,g="mobile"===this._device?[400,225]:[640,360];this._videoConfig.mobileStickyPlayerOnPage=!0;var h=document.createElement("div");d.insertAdjacentElement(a.position,h);d=this._wrapJWPlayerWithCLS(h,e,this._WRAPPER_BAR_HEIGHT);this._playersAddedFromPlugin.push("playlist-".concat(e));d&&this._clsOptions.setInjectedVideoSlots({playlistId:a.playlistId,playerId:a.playerId,playerSize:g,playerName:f,element:h,type:"stickyPlaylist"})};b.prototype._isVideoAllowedOnPage=function(){var a=this._clsOptions.disableAds;if(a&&a.video){var d="";a.reasons.has("video_tag")?d="video tag":a.reasons.has("video_plugin")?d="video plugin":a.reasons.has("video_page")&&(d="command queue");q.error(d?"ClsVideoInsertionMigrated":"ClsVideoInsertion","isVideoAllowedOnPage",Error("DBP: Disabled by publisher via ".concat(d||"other")));return!1}return this._clsOptions.videoDisabledFromPlugin?!1:!0};return b}(function(c){function b(a,d){var e=c.call(this)||this;e._videoConfig=a;e._component=d;e._stickyRelatedOnPage=!1;e._relatedMediaIds=[];a=void 0;void 0===a&&(a=navigator.userAgent);a=/Windows NT|Macintosh/i.test(a);e._device=a?"desktop":"mobile";e._potentialPlayerMap=e.setPotentialPlayersMap();return e}v(b,c);b.prototype.setPotentialPlayersMap=function(){var a=this._videoConfig.players||[],d=this._filterPlayerMap();a=a.filter(function(e){return"stationaryRelated"===e.type&&e.enabled});d.stationaryRelated=a;return this._potentialPlayerMap=d};b.prototype._filterPlayerMap=function(){var a=this,d=this._videoConfig.players,e={stickyRelated:[],stickyPlaylist:[],stationaryRelated:[]};return d&&d.length?d.filter(function(f){var g;return null===(g=f.devices)||void 0===g?void 0:g.includes(a._device)}).reduce(function(f,g){f[g.type]||(q.event(a._component,"constructor","Unknown Video Player Type detected",g.type),f[g.type]=[]);g.enabled&&f[g.type].push(g);return f},e):e};b.prototype._checkPlayerSelectorOnPage=function(a){var d=this;a=this._potentialPlayerMap[a].map(function(e){return{player:e,playerElement:d._getPlacementElement(e)}});return a.length?a[0]:{player:null,playerElement:null}};b.prototype._getOverrideElement=function(a,d,e){a&&d?(e=document.createElement("div"),d.insertAdjacentElement(a.position,e)):(d=this._checkPlayerSelectorOnPage("stickyPlaylist"),a=d.player,d=d.playerElement,a&&d&&(e=document.createElement("div"),d.insertAdjacentElement(a.position,e)));return e};b.prototype._shouldOverrideElement=function(a){a=a.getAttribute("override-embed");return"true"===a||"false"===a?"true"===a:this._videoConfig.relatedSettings?this._videoConfig.relatedSettings.overrideEmbedLocation:!1};b.prototype._checkPageSelector=function(a,d,e){void 0===e&&(e=[]);return a&&d&&0===e.length?("/"!==window.location.pathname&&q.event("VideoUtils","getPlacementElement",Error("PSNF: ".concat(a," does not exist on the page"))),!1):!0};b.prototype._getElementSelector=function(a,d,e){if(d&&d.length>e)return d[e];q.event("VideoUtils","getPlacementElement",Error("ESNF: ".concat(a," does not exist on the page")));return null};b.prototype._getPlacementElement=function(a){var d=a.pageSelector,e=a.elementSelector;a=a.skip;var f=da(d),g=f.valid,h=f.elements;f=S(f,["valid","elements"]);var k=ca(e),l=k.valid,p=k.elements;k=S(k,["valid","elements"]);return""===d||g?l?this._checkPageSelector(d,g,h)?this._getElementSelector(e,p,a)||null:null:(q.error("VideoUtils","getPlacementElement",Error("".concat(e," is not a valid selector")),k),null):(q.error("VideoUtils","getPlacementElement",Error("".concat(d," is not a valid selector")),f),null)};b.prototype._getEmbeddedPlayerType=function(a){(a=a.getAttribute("data-player-type"))&&"default"!==a||(a=this._videoConfig.relatedSettings?this._videoConfig.relatedSettings.defaultPlayerType:"static");this._stickyRelatedOnPage&&(a="static");return a};b.prototype._getMediaId=function(a){return(a=a.getAttribute("data-video-id"))?(this._relatedMediaIds.push(a),a):!1};b.prototype._createRelatedPlayer=function(a,d,e,f){"collapse"===d?this._createCollapsePlayer(a,e):"static"===d&&this._createStaticPlayer(a,e,f)};b.prototype._createCollapsePlayer=function(a,d){var e=this._checkPlayerSelectorOnPage("stickyRelated"),f=e.player;e=e.playerElement;var g=f?f:this._potentialPlayerMap.stationaryRelated[0];g&&g.playerId?(this._shouldOverrideElement(d)&&(d=this._getOverrideElement(f,e,d)),d=document.querySelector("#cls-video-container-".concat(a," > div"))||d,this._createStickyRelatedPlayer(y(y({},g),{mediaId:a}),d)):q.error(this._component,"_createCollapsePlayer","No video player found")};b.prototype._createStaticPlayer=function(a,d,e){this._potentialPlayerMap.stationaryRelated.length&&this._potentialPlayerMap.stationaryRelated[0].playerId?this._createStationaryRelatedPlayer(y(y({},this._potentialPlayerMap.stationaryRelated[0]),{mediaOrPlaylistId:a}),d,e):q.error(this._component,"_createStaticPlayer","No video player found")};b.prototype._shouldRunAutoplayPlayers=function(){return this._isVideoAllowedOnPage()&&(this._potentialPlayerMap.stickyRelated.length||this._potentialPlayerMap.stickyPlaylist.length)?!0:!1};b.prototype._determineAutoplayPlayers=function(){var a=this._component,d="VideoManagerComponent"===a,e=this._config;if(this._stickyRelatedOnPage)q.event(a,"stickyRelatedOnPage",d&&{device:e&&e.context.device,isDesktop:this._device}||{});else{var f=this._checkPlayerSelectorOnPage("stickyPlaylist"),g=f.player;f=f.playerElement;g&&g.playerId&&g.playlistId&&f?this._createPlaylistPlayer(g,f):q.event(a,"noStickyPlaylist",d&&{vendor:"none",device:e&&e.context.device,isDesktop:this._device}||{})}};b.prototype._initializeRelatedPlayers=function(a){for(var d=new Map,e=0;e