Lagervarer bestilt inden kl. 12 - Afsendes samme dag. Salg kun til erhverv   Gratis levering ved køb over 1.500 kr. - Levering 1-3 dage   Nememballage.dk er en del af KD Emballage. Dansk leverandør af emballage

Error executing template "Designs/Nememballage/eCom/ProductCatalog/ProductViewList.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_db5da9b93f804b51ad98d04a7c6fa7eb.Execute() in D:\web\kde.dk\Website\Files\Templates\Designs\Nememballage\eCom\ProductCatalog\ProductViewList.cshtml:line 469
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @using Dynamicweb.Rendering 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 @using System.Linq; 4 @inherits ViewModelTemplate<ProductListViewModel> 5 6 @using Dynamicweb.Rendering 7 @using Dynamicweb.Ecommerce.ProductCatalog 8 @using System; 9 @using System.Collections.Generic; 10 @using System.Linq; 11 12 @helper HelperRenderProductList(IList<ProductViewModel> products, string groupCategoryname = "") 13 { 14 int webshopPageId = GetPageIdByNavigationTag("Shop"); 15 16 for (int i = 0; i < products.Count; i++) 17 { 18 var productApi = new Dynamicweb.Ecommerce.Products.ProductService().GetProductById(products[i].Id, "", products[i].LanguageId); 19 if (productApi == null) 20 { 21 continue; 22 } 23 24 var group = productApi.GetDefaultGroupByShopId("SHOP2"); 25 var title = new Website.Helpers.Product().GetTitle(products[i]); 26 var resizedImage = VestjyskMarketing.Helpers.ImageHelper.ResizeImage(products[i].DefaultImage.Value, 600, 500); 27 if (group == null) 28 { 29 continue; 30 } 31 32 33 string productLink = "/Default.aspx?ID=" + webshopPageId + "&amp;GroupID=" + group.Id + "&amp;ProductID=" + products[i].Id; 34 double productPrice = new Website.Helpers.Prices().GetCheapestPrice("", products[i].Number, true); 35 FieldValueViewModel hideBuy; 36 FieldValueViewModel oldprice; 37 FieldValueViewModel environmentLogoEnable; 38 products[i].ProductFields.TryGetValue("HideBuy", out hideBuy); 39 products[i].ProductFields.TryGetValue("Gl_salgspris", out oldprice); 40 products[i].ProductFields.TryGetValue("MiljoeVenligtValg", out environmentLogoEnable); 41 42 //get height, lenght and width productinfoL: 190 MM B: 100 MM H: 70 MM 43 List<Tuple<string, string>> dimensionsList = new Website.Helpers.Product().GetProductFieldsDimensions(products[i]); 44 45 string fscLogo = VestjyskMarketing.Helpers.ImageHelper.ResizeImage("/Files/Images/Logoer/FSC_Logo.png", 50, 50,6); 46 bool fscApproved = new Website.Helpers.Product().GetProductCategoryField("FSC_godkendt", products[i]) == "True" ? true : false; 47 48 <div class="productlist__item bg-light"> 49 <div class="row no-gutters"> 50 <div class="col-lg-3 col-xl-2 productlist__item__image" style="background-image: url(@resizedImage);"> 51 52 </div> 53 <div class="col-lg-5 col-xl-6"> 54 <div class="productlist__item__content"> 55 <h2><a href="@productLink" title="@Translate(" Gå til:") @title">@title</a></h2> 56 @if (dimensionsList.Count > 0) 57 { 58 <div class="productlist__item__fields text-primary font-weight-bold"> 59 @foreach (var dimension in dimensionsList) 60 { 61 <span> 62 @dimension.Item1.Substring(0, 1): @dimension.Item2 63 @if (dimension.Item1.ToLower().Contains("(m)")) 64 { 65 <text>M</text> 66 } 67 else 68 { 69 <text>MM</text> 70 } 71 </span> 72 } 73 </div> 74 } 75 <div class="productlist__item__number font-weight-bold">@Translate("Varenummer"): @products[i].Number</div> 76 77 @if (fscApproved) 78 { 79 <a class="productlist-miljø-link" href="Default.aspx?ID=@GetPageIdByNavigationTag("environmentpage")"> 80 <img src="@fscLogo" class="img-fluid productlist__item__fsc " alt="FSC logo" title="FSC Godkendt" /> 81 </a> 82 } 83 @if (Dynamicweb.Core.Converter.ToBoolean(environmentLogoEnable.Value)) 84 { 85 string environmentLogo = VestjyskMarketing.Helpers.ImageHelper.ResizeImage("/Files/Images/Logoer/Nem_Logo_miljø_FINAL.png", 50, 50,6); 86 <a class="productlist-miljø-link" href="Default.aspx?ID=@GetPageIdByNavigationTag("environmentpage")"> 87 <img src="@environmentLogo" class="img-fluid productlist__item__fsc " alt="Miljøvenligt valg" title="Miljøvenligt valg" /> 88 </a> 89 } 90 </div> 91 </div> 92 <div class="col-lg-4 text-right"> 93 <div class="productlist__item__price__container "> 94 @if (Convert.ToBoolean(hideBuy.Value) == false) 95 { 96 <div class="productlist__item__price"> 97 98 Priser fra&nbsp; &nbsp;<span class="productlist__item__price__highlight">@string.Format("{0:0.00}", productPrice) DKK</span> 99 <div class="productlist__item__price__vat">eksl. moms</div> 100 @if (Dynamicweb.Core.Converter.ToDecimal(oldprice.Value) > 0) 101 { 102 <span class="productlist__item__oldprice">@string.Format("{0:0.00}", oldprice.Value) DKK</span> 103 } 104 </div> 105 } 106 <a class="btn btn-outline-primary rounded-pill btn-round btn-block" href="@productLink" title="@Translate(" Gå til:") @products[i].Title ">Se produkt</a> 107 </div> 108 </div> 109 </div> 110 </div> 111 } 112 } 113 114 @helper HelperRenderProductSpotList(List<ProductViewModel> products) 115 { 116 int webshopPageId = GetPageIdByNavigationTag("Shop"); 117 118 119 <div class="row"> 120 121 @foreach (var product in products) 122 { 123 var productApi = new Dynamicweb.Ecommerce.Products.ProductService().GetProductById(product.Id, "", product.LanguageId); 124 if (productApi == null) 125 { 126 continue; 127 } 128 129 var resizedImage = VestjyskMarketing.Helpers.ImageHelper.ResizeImage(product.DefaultImage.Value, 433, 353); 130 string productLink = "/Default.aspx?ID=" + webshopPageId + "&amp;GroupID=" + product.PrimaryOrDefaultGroup.Id + "&amp;ProductID=" + product.Id; 131 string productPrice = new Website.Helpers.Prices().GetOnePiecePrice("", productApi.Number, Convert.ToInt32(productApi.PurchaseMinimumQuantity), true, false, true); 132 FieldValueViewModel hideBuy; 133 product.ProductFields.TryGetValue("HideBuy", out hideBuy); 134 135 <div class="col-12 col-lg-6 col-xl-3 px-0 px-lg-2 mb-5 mb-lg-3"> 136 <div class="productlist-spot__item"> 137 <div class="row h-100"> 138 <div class="col-3 col-lg-12"> 139 <div class="productlist-spot__item__img" style="background-image: url(@resizedImage)"></div> 140 </div> 141 <div class="col-9 col-lg-12"> 142 <div class="productlist-spot__item__description"> 143 <p class="productlist-spot__item__title"><a href="@productLink" title="@Translate(" Gå til:") @product.Title ">@product.Title</a></p> 144 <p class="productlist-spot__item__number">Varenummer: @product.Number</p> 145 </div> 146 </div> 147 148 <div class="col-12 mt-auto "> 149 <div class="productlist-spot__item__content"> 150 <div class="row"> 151 <div class="col-7 p-0 pl-4 pl-lg-0 pr-lg-3"> 152 @if (Convert.ToBoolean(hideBuy.Value) == false) 153 { 154 <p class="productlist-spot__item__price">Priser fra <br /> <strong> @productPrice DDK</strong></p> 155 <p class="productlist-spot__item__tax">ekskl. moms</p> 156 } 157 158 </div> 159 <div class="col-5 d-flex justify-content-end pr-2 p-0 p-lg-2"> 160 <a class="btn btn-round align-self-end rounded-pill productlist-spot__item__link " href="@productLink" title="@Translate(" Gå til:") @product.Title">Se produkt</a> 161 </div> 162 </div> 163 </div> 164 </div> 165 </div> 166 </div> 167 </div> 168 } 169 </div> 170 171 } 172 173 174 @using Dynamicweb.Rendering 175 @using Dynamicweb.Ecommerce.ProductCatalog 176 @using System; 177 @using System.Linq; 178 @inherits ViewModelTemplate<ProductListViewModel> 179 180 181 @helper RenderFacetRange(FacetGroupViewModel facetGroup, FacetViewModel facetItem) 182 { 183 var queryParameter = facetItem.QueryParameter; 184 var queryParameterSelected = Dynamicweb.Context.Current.Request.QueryString[queryParameter]; 185 186 int rangeStart = 0; 187 int rangeEnd = Dynamicweb.Core.Converter.ToInt32(facetItem.MaximumFacetValue); 188 189 if (rangeEnd > 0) 190 { 191 int rangeStartSelected = rangeStart; 192 int rangeEndSelected = rangeEnd; 193 int queryParameterSelectedActive = 0; 194 if (queryParameterSelected != null) 195 { 196 queryParameterSelectedActive = 1; 197 rangeStartSelected = Dynamicweb.Core.Converter.ToInt32(queryParameterSelected.Split(',')[0]); 198 rangeEndSelected = Dynamicweb.Core.Converter.ToInt32(queryParameterSelected.Split(',')[1]); 199 } 200 201 <div class="productlist__filter__facetgroup"> 202 <div class="row"> 203 <div class="col text-uppercase font-weight-bold">@facetItem.Name:</div> 204 <div class="col text-right"> 205 <span id="slider-@queryParameter-value-min"></span> - 206 <span id="slider-@queryParameter-value-max"></span> 207 </div> 208 </div> 209 <div class="slider" data-update="slider-@queryParameter" data-start="@rangeStart" data-end="@rangeEnd" data-selected-start="@rangeStartSelected" data-selected-end="@rangeEndSelected"></div> 210 <input type="hidden" name="@queryParameter" id="slider-@queryParameter-input-min" value="@rangeStartSelected" /> 211 <input type="hidden" name="@queryParameter" id="slider-@queryParameter-input-max" value="@rangeEndSelected" /> 212 <input type="hidden" id="slider-@queryParameter-active" value="@queryParameterSelectedActive" /> 213 </div> 214 } 215 } 216 217 @helper RenderFacetCheckboxes(FacetGroupViewModel facetGroup, FacetViewModel facetItem) 218 { 219 var queryParameter = facetItem.QueryParameter; 220 221 if (queryParameter == "Color" || queryParameter == "Tapetype") 222 { 223 facetItem.Options = facetItem.Options.OrderByDescending(x => x.Count); 224 } 225 226 <div class="productlist__filter__facetgroup"> 227 <div class="text-uppercase font-weight-bold">@facetItem.Name:</div> 228 <div class="productlist__filter__checkboxes"> 229 @foreach (var facetOption in facetItem.Options) 230 { 231 var label = queryParameter == "Color" ? Translate(facetOption.Label) : facetOption.Label; 232 var name = facetOption.Name; 233 var value = facetOption.Value; 234 var count = facetOption.Count; 235 var selected = facetOption.Selected ? "checked" : ""; 236 var disabled = count <= 0 ? "disabled" : ""; 237 238 <div class="productlist__filter__checkboxes__item"> 239 <input class="styled-checkbox" type="checkbox" id="@queryParameter-@value" value="@value" name="@queryParameter" @selected @disabled> 240 <label for="@queryParameter-@value">@label (@(count))</label> 241 </div> 242 } 243 </div> 244 245 @if (facetItem.OptionActiveCount > 2) 246 { 247 <button class="reset-button font-weight-bold js-show-allfilters"><i class="fas fa-plus"></i> Se alle</button> 248 } 249 250 </div> 251 } 252 253 @helper RenderFacets(ProductListViewModel model) 254 { 255 var facetsUsed = Dynamicweb.Core.Converter.ToString(Model.Group?.GroupFields.Where(x => x.SystemName.Equals("FacetsUsed")).Select(x => x.Value).FirstOrDefault()).Split(',').ToList(); 256 257 //for topgroups 258 if (string.IsNullOrEmpty(facetsUsed[0])) 259 { 260 string groupIds = Dynamicweb.Context.Current.Request["GroupID"] ?? ""; 261 if (!string.IsNullOrEmpty(groupIds)) 262 { 263 string groupId = groupIds.Split(',')[0]; 264 var group = Dynamicweb.Ecommerce.Products.Group.GetGroupById(groupId); 265 if (group != null && group.IsTopGroup) 266 { 267 268 facetsUsed = Dynamicweb.Core.Converter.ToString(group.ProductGroupFieldValues.GetProductGroupFieldValue("FacetsUsed").Value).Split(',').ToList(); 269 } 270 } 271 } 272 273 <form id="js-productlist-filter"> 274 275 <div class="text-right d-xl-none"> 276 <button class="reset-button productlist__filter__close js-filter-trigger" title="Luk"><i class="fa fa-times"></i></button> 277 </div> 278 279 <div class="row"> 280 <div class="col"> 281 <div class="h2 font-weight-bold">Filtré</div> 282 </div> 283 <div class="col text-right"> 284 <button class="btn btn-sm btn-primary rounded-pill productlist__filter__reset"><span class="fas fa-times"></span> Nulstil</button> 285 </div> 286 </div> 287 288 @foreach (var facetGroup in model.FacetGroups) 289 { 290 foreach (var facetItem in facetGroup.Facets) 291 { 292 var optionActiveCount = facetItem.OptionActiveCount; 293 var facetOptionResultTotalCount = facetItem.OptionResultTotalCount; 294 var template = facetItem.RenderType; 295 296 if (optionActiveCount > 0 && facetOptionResultTotalCount > 0 && facetsUsed.Contains(facetItem.FacetField)) 297 { 298 switch (template) 299 { 300 case "Range": 301 @RenderFacetRange(facetGroup, facetItem) 302 break; 303 304 default: 305 @RenderFacetCheckboxes(facetGroup, facetItem) 306 break; 307 } 308 309 } 310 } 311 } 312 313 <button class="btn btn-primary rounded-pill d-xl-none js-filter-trigger mt-3 mb-3">Anvend</button> 314 315 </form> 316 317 318 319 320 321 } 322 323 324 325 @{ 326 var product = new Dynamicweb.Ecommerce.Products.Product(); //@fake for breadcrumb. Dumb hack; 327 int webshopPageId = GetPageIdByNavigationTag("Shop"); 328 string groupId = Dynamicweb.Context.Current.Request["GroupID"] ?? ""; 329 string groupIdQueryParameter = string.IsNullOrEmpty(groupId) 330 ? string.Empty 331 : "&GroupID=" + Dynamicweb.Context.Current.Request["GroupID"]; 332 333 if (!String.IsNullOrEmpty(groupId)) 334 { 335 var group = Dynamicweb.Ecommerce.Products.Group.GetGroupById(groupId); 336 if (group != null && group.IsTopGroup) 337 { 338 foreach (var subgroup in group.Subgroups) 339 { 340 groupIdQueryParameter += "," + subgroup.Id; 341 } 342 } 343 } 344 345 string sortGroup = Dynamicweb.Core.Converter.ToString(Model.Group?.GroupFields.Where(x => x.SystemName.Equals("SortGroup")).Select(x => x.Value).FirstOrDefault()); 346 string sortGroupParameter = string.IsNullOrEmpty(sortGroup) 347 ? string.Empty 348 : "&SortBy=" + sortGroup + "&SortOrder=ASC"; 349 350 string search = Dynamicweb.Context.Current.Request["Search"] ?? ""; 351 string searchQueryParameter = string.IsNullOrEmpty(search) 352 ? string.Empty 353 : "&Search=" + Dynamicweb.Context.Current.Request["Search"]; 354 355 string currentPageLink = "/Default.aspx?ID=" + Pageview.Page.ID + groupIdQueryParameter; 356 357 int productCatalogId = GetPageIdByNavigationTag("ProductsFeed"); 358 string feedPageUrl = "/Default.aspx?ID=" + productCatalogId + groupIdQueryParameter + searchQueryParameter + sortGroupParameter; 359 360 361 } 362 363 <input id="js_page_number" type="hidden" value="1" /> 364 <div id="ecom-container" style="position: relative;"> 365 <div class="productlist"> 366 <div class="container-fluid p-0"> 367 <div class="row no-gutters"> 368 <div class="col-3 d-none d-xl-block" id="ecom-filter-parent"> 369 <div class="productlist__filter" id="ecom-filter"> 370 </div> 371 </div> 372 373 <div class="col col-xl-9 bg-gray-theme"> 374 375 376 <div class="productlist__content"> 377 @{ 378 string groupIdBreadcrumb = Dynamicweb.Context.Current.Request["GroupID"] ?? ""; 379 string productIdBreadcrumb = Dynamicweb.Context.Current.Request["ProductID"] ?? ""; 380 var listBreadcrumbGroups = new List<Dynamicweb.Ecommerce.Products.Group>(); 381 var shop = Dynamicweb.Ecommerce.Services.Shops.GetShop("SHOP2"); 382 if (shop != null) 383 { 384 var topLevelGroups = shop.TopLevelGroups; 385 386 foreach (var topLevelGroup in topLevelGroups) 387 { 388 if (topLevelGroup.Id == groupIdBreadcrumb) 389 { 390 listBreadcrumbGroups.Add(topLevelGroup); 391 392 } 393 else 394 { 395 if (topLevelGroup.HasChildGroups) 396 { 397 foreach (var subgroup in topLevelGroup.Subgroups) 398 { 399 if (subgroup.Id == groupIdBreadcrumb) 400 { 401 listBreadcrumbGroups.Add(subgroup); 402 foreach (var parentGroup in subgroup.ParentGroups) 403 { 404 listBreadcrumbGroups.Insert(0, parentGroup); 405 } 406 } 407 } 408 } 409 } 410 } 411 } 412 } 413 414 <nav> 415 <ol class="breadcrumb"> 416 @if (String.IsNullOrEmpty(productIdBreadcrumb)) 417 { 418 <li class="breadcrumb__content__item js-breadcrumb-on-mobile d-lg-none"> 419 <a href="/"><i class="fal fa-chevron-left"> <span></span></i></a> 420 </li> 421 } 422 423 <li class="breadcrumb__content__item js-breadcrumb-off-mobile"> 424 <a href="/">Forside <span>|</span></a> 425 </li> 426 @* <li class="breadcrumb__content__item js-breadcrumb-off-mobile"> *@ 427 @* <a href="/webshop">Webshop <span>|</span></a> *@ 428 @* </li> *@ 429 430 431 @foreach (var groupBreadcrumb in listBreadcrumbGroups) 432 { 433 string activeClass = groupBreadcrumb.Id == groupIdBreadcrumb && String.IsNullOrEmpty(productIdBreadcrumb) ? "active d-block" : ""; ; 434 435 <li class="breadcrumb__content__item "> 436 <a href="/Default.aspx?ID=@Pageview.ID&GroupID=@groupBreadcrumb.Id" class="@activeClass js-breadcrumb-off-mobile"> 437 @groupBreadcrumb.Name 438 @if (groupBreadcrumb.Subgroups.Count > 0 || !String.IsNullOrEmpty(productIdBreadcrumb)) 439 { 440 <span>|</span> 441 } 442 </a> 443 </li> 444 } 445 446 447 @if (!String.IsNullOrEmpty(productIdBreadcrumb)) 448 { 449 string titleBreadcrumb = new Website.Helpers.Product().GetTitle(product); 450 <li class="breadcrumb__content__item js-breadcrumb-on-mobile d-lg-none"> 451 <a href="/Default.aspx?ID=@Pageview.ID&GroupID=@groupIdBreadcrumb"><i class="fal fa-chevron-left"> <span></span></i></a> 452 </li> 453 <li class="breadcrumb__content__item"> 454 <a href="/Default.aspx?ID=@Pageview.ID&GroupID=@groupIdBreadcrumb&ProductID=@productIdBreadcrumb" class="active"> 455 @titleBreadcrumb 456 </a> 457 </li> 458 } 459 460 </ol> 461 </nav> 462 <div class="productlist__group bg-light"> 463 <button class="productlist__filter__trigger reset-button d-xl-none js-filter-trigger"> 464 <i class="fas fa-sliders-h"></i> 465 <div>Filtré</div> 466 </button> 467 @if (!String.IsNullOrEmpty(groupId)) 468 { 469 @Model.Group.Description 470 471 List<FieldValueViewModel> seoDescription = new List<FieldValueViewModel>(); 472 seoDescription = (List<FieldValueViewModel>)Model.Group.GroupFields; 473 var seoDescriptiontext = ""; 474 foreach (var item in seoDescription) 475 { 476 if (item.SystemName == "BottomDescription") 477 { 478 seoDescriptiontext = @item.Value.ToString(); 479 } 480 } 481 482 if (seoDescriptiontext != "") 483 { 484 <div class="js-seotext-foldout hidden-seotext"> 485 @seoDescriptiontext 486 </div> 487 <a class="js-read-more"><p>Læs mere</p></a> 488 } 489 } 490 else if (Pageview.Page.ID == webshopPageId) 491 { 492 <h1>Søgeside</h1> 493 if (!String.IsNullOrEmpty(search)) 494 { 495 <h2 class="font-weight-bold">Viser resultater for "@search"</h2> 496 } 497 498 } 499 </div> 500 501 <div id="ecom-productlist"> 502 503 </div> 504 505 </div> 506 </div> 507 </div> 508 </div> 509 </div> 510 <div class="productlist__loader"></div> 511 </div> 512 513 @SnippetStart("JavaScriptBottom") 514 <script> 515 $(function () { 516 517 var $win = $(window); 518 var itemsLoaded = true; 519 var $productsListPageContainer = $('#ecom-container'); 520 var $productsContainer = $('#ecom-productlist'); 521 var $filterContainer = $('#ecom-filter'); 522 var urlAjax = "@feedPageUrl"; 523 524 var appendLoader = '<div class="productlist__loader__append text-center">'; 525 appendLoader += ' <span class="fas fa-spinner fa-pulse"></span>'; 526 appendLoader += ' </div>'; 527 528 $('.js-seotext-foldout').hide('fast'); 529 530 $('body').on('click', '.productlist__filter__reset', function (e) { 531 e.preventDefault(); 532 var urlBasic = "@feedPageUrl"; 533 GetAjax(urlBasic,1,false); 534 }); 535 536 $('body').on('click', '.js-show-allfilters', function (e) { 537 e.preventDefault(); 538 $(this).prev().toggleClass('selected'); 539 if ($(this).prev().hasClass('selected')) { 540 $(this).html("<i class='fas fa-minus'></i> Se mindre"); 541 } 542 else { 543 $(this).html("<i class='fas fa-plus'></i> Se alle"); 544 } 545 546 }); 547 548 $('body').on('click', '.js-filter-trigger', function (e) { 549 e.preventDefault(); 550 $('.productlist__filter').toggleClass('fixed'); 551 $('#ecom-filter-parent').toggleClass('d-none'); 552 $('body').toggleClass('noscroll'); 553 }); 554 555 $('.js-read-more').on('click', function (e) { 556 if ($('.js-seotext-foldout').hasClass("hidden-seotext")) { 557 $('.js-seotext-foldout').show('fast'); 558 $('.js-seotext-foldout').removeClass("hidden-seotext"); 559 $(this).children("p").text(" Læs mindre"); 560 } 561 else { 562 $('.js-seotext-foldout').hide('fast'); 563 $('.js-seotext-foldout').addClass("hidden-seotext"); 564 $(this).children("p").text("Læs mere "); 565 } 566 }); 567 568 569 function triggerFixed() { 570 var width = $(window).width(); 571 var activeateScroll = width > 1024 ? false : true; 572 if (!activeateScroll) { 573 return; 574 } 575 576 var distanceToTop = $(document).scrollTop(); 577 var trigger = $('.productlist__filter__trigger'); 578 if (distanceToTop > 135) { 579 trigger.addClass('fixed'); 580 } 581 else { 582 trigger.removeClass('fixed'); 583 } 584 } 585 586 triggerFixed(); 587 $(window).scroll(function () { 588 triggerFixed(); 589 }); 590 $(window).resize(function () { 591 triggerFixed(); 592 }); 593 window.addEventListener("orientationchange", function () { 594 triggerFixed(); 595 }); 596 597 $('body').on('click', '.productlist__filter input', function () { 598 var filters = GetFilters(); 599 GetAjax(filters,1, false); 600 }); 601 602 $('#js_page_number').val(1); 603 GetAjax("@feedPageUrl", 1, false); 604 605 $win.scroll(function () { 606 var windowBottom = $win.scrollTop() + $win.height(); 607 var itemsContainerBottom = $productsListPageContainer.offset().top + $productsListPageContainer.outerHeight(); 608 var pageNumber = $('#js_page_number').val(); 609 610 if (windowBottom >= itemsContainerBottom && itemsLoaded) { 611 itemsLoaded = false; 612 pageNumber++; 613 614 $('#js_page_number').val(pageNumber); 615 $("#ecom-append").append(appendLoader); 616 $('.productlist__loader__wrapper').show(); 617 618 var url = GetFilters(url); 619 620 GetAjax(url, pageNumber, true); 621 } 622 }); 623 624 function GetAjax(url, pageNumber, appendData) { 625 626 //nake sure it is boolean 627 if (typeof (appendData) == "undefined") { 628 appendData = false; 629 } 630 631 if (!appendData) { 632 $productsListPageContainer.find('.productlist__loader').show(); 633 } 634 635 //reset pagenum 636 if (pageNumber == 1) { 637 $('#js_page_number').val(1); 638 } 639 640 var urlAjax = url; 641 url = url + "&PageNum=" + pageNumber; 642 if (appendData) { 643 url = url + "&AppendData=1"; 644 } 645 646 $('#js__products__counter__container').hide(); 647 $.ajax({ 648 url: url, 649 success: function (result) { 650 651 if (appendData) { 652 $('.productlist__loader__append').remove(); 653 $('#ecom-append').append(result); 654 } else { 655 656 var filterHtml = $(result).find('#ecom-filter-ajax').html(); 657 var productlistHtml = $(result).find('#ecom-productlist-ajax').html(); 658 $productsContainer.html(productlistHtml); 659 $filterContainer.html(filterHtml); 660 661 $productsListPageContainer.find('.productlist__loader').hide(); 662 663 Array.prototype.forEach.call(document.querySelectorAll('.slider'), createSlider); 664 } 665 666 var $scrollStop = $(result).find('#js_scroll_stop'); 667 if ($scrollStop.length == 0) { 668 itemsLoaded = true; 669 } 670 } 671 }); 672 } 673 674 function GetFilters() { 675 var urlBasic = "@feedPageUrl"; 676 var formData = $("#js-productlist-filter").find(":input:not(:hidden)").serialize(); 677 Array.prototype.forEach.call(document.querySelectorAll('.slider'), function (elSlider) { 678 var element = getDataFacet(elSlider, 'update'); 679 var activeSliderId = element + "-active"; 680 681 if (document.getElementById(activeSliderId).value == "1") { 682 var minInputId = element + "-input-min"; 683 var maxInputId = element + "-input-max"; 684 685 if (formData) { 686 formData = formData + "&"; 687 } 688 formData = formData + document.getElementById(minInputId).getAttribute('name') + "=" + parseInt(document.getElementById(minInputId).value); 689 formData = formData + "&" + document.getElementById(maxInputId).getAttribute('name') + "=" + parseInt(document.getElementById(maxInputId).value); 690 } 691 }); 692 693 return urlBasic + '&' + formData; 694 } 695 696 function getDataFacet(element, key) { 697 return element.getAttribute('data-' + key); 698 } 699 700 function createSlider(slider) { 701 noUiSlider.create(slider, { 702 start: [Number(getDataFacet(slider, 'selected-start')), Number(getDataFacet(slider, 'selected-end'))], 703 connect: true, 704 tooltips: true, 705 step: 10, 706 707 format: wNumb({ 708 decimals: 0, 709 suffix: ' mm' 710 }), 711 712 range: { 713 'min': Number(getDataFacet(slider, 'start')), 714 'max': Number(getDataFacet(slider, 'end')) 715 } 716 }); 717 718 slider.noUiSlider.on("update", function (values, handle) { 719 var element = getDataFacet(slider, 'update'); 720 if (handle) { 721 var minInputId = element + "-input-max"; 722 var minSpanId = element + "-value-max"; 723 document.getElementById(minInputId).value = parseInt(values[handle]); 724 document.getElementById(minSpanId).innerHTML = values[handle]; 725 } else { 726 var maxInputId = element + "-input-min"; 727 var maxSpanId = element + "-value-min"; 728 document.getElementById(maxInputId).value = parseInt(values[handle]); 729 document.getElementById(maxSpanId).innerHTML = values[handle]; 730 } 731 }); 732 733 slider.noUiSlider.on("change", function (values, handle) { 734 var element = getDataFacet(slider, 'update'); 735 var activeSliderId = element + "-active"; 736 document.getElementById(activeSliderId).value = 1; 737 738 var filters = GetFilters(); 739 GetAjax(filters, 1, false); 740 }); 741 742 743 744 } 745 }); 746 747 748 </script> 749 @SnippetEnd("JavaScriptBottom") 750