PageSourceSearch

https://static.biedronka.pl/js/biedronka.js?v=1106124

js biedronka.pl collected 2026-10-01 12:07:47 UTC 21,684 bytes, 695 lines download raw bytes

1$(function () {
2  $("li.ico-shopping-cart span.small-circle").hide();
3  $("li.ico-login span.small-circle").hide();
4  $(".user-login-link").hide();
5  // one full request for all basic data
6  $.ajax({
7    url: apiBaseUrl + "api/index/userdata",
8    dataType: "json",
9    xhrFields: {
10      withCredentials: true,
11    },
12    crossDomain: true,
13    success: function (data) {
14      if (data.result == 0) {
15        $("li.ico-login a.login-link").attr("href", data.url).html(data.label);
16
17        if (data.logged_in == 1) {
18          $("li.ico-login span.small-circle").show();
19          // shoppinglist status
20          if (data.shopping_list_items > 0) {
21            $("li.ico-shopping-cart span.small-circle").html(
22              data.shopping_list_items
23            );
24            $("li.ico-shopping-cart span.small-circle").show();
25          } else {
26            $("li.ico-shopping-cart span.small-circle").remove();
27          }
28        } else {
29          // removing cart status
30          $("li.ico-shopping-cart span.small-circle").remove();
31          $("li.ico-login ul.user-actions").remove();
32          $("li.ico-login span.small-circle").remove();
33        }
34
35        // flash messages
36        $("div#container div.inner").eq(0).prepend($(data.flash));
37        // dialogbox
38        if (data.dialogbox) {
39          $.each(data.dialogbox, function (index, msg) {
40            message(msg, false);
41          });
42        }
43        // events
44        if (data.events) {
45          // check GTM events
46          if (data.events.gtm) {
47            $.each(data.events.gtm, function (index, eventName) {
48              pushEvent(eventName);
49            });
50          }
51        }
52      }
53    },
54  });
55
56  // form error events
57  if ($("p.required.error").length > 0) {
58    $("p.required.error").each(function (index, element) {
59      // this points to error placeholder
60      var $placeholder = $(this);
61      var $errors = $placeholder.find("span.error");
62      var $label = $placeholder.next();
63      var $input = $("#" + $label.attr("for"));
64      $input.on("focus", function () {
65        $errors.stop(true, true).fadeIn("medium");
66      });
67      $input.on("blur", function () {
68        $errors.stop(true, true).fadeOut("medium");
69      });
70    });
71  }
72  // navigation items image/description
73  $("nav#mainnav li li a[data-promoted=1]").each(function (index, element) {
74    var $element = $(element);
75    var $parent = $element.parents("ul").eq(0);
76    if (!$parent.parent().hasClass("submenuplaceholder")) {
77      var $placeholder = $('<span class="submenuplaceholder"></span>');
78      $parent.parent().append($placeholder);
79      $placeholder.append($parent);
80      if ($element.data("image") != "" || $element.data("description") != "") {
81        var $sideview = $(
82          '<span class="sideview visible-desktop"><a></a></span>'
83        );
84        var $link = $sideview.find("a");
85        $link.attr("href", $element.attr("href"));
86        if ($element.data("image") != "") {
87          var $img = $('<img src="' + $element.data("image") + '"/>');
88          $link.append($img);
89        }
90        if ($element.data("description") != "") {
91          var $desc = $(
92            '<span class="description">' +
93              $element.data("description") +
94              "</span>"
95          );
96          $link.append($desc);
97        }
98        $placeholder.append($sideview);
99        $element.parent().addClass("promoted");
100      }
101    }
102  });
103
104  // prepend dynamic window for video player
105  $('<div id="videoPlayerLayer"><div id="videoPlayer"></div></div>')
106    .prependTo("body")
107    .hide();
108
109  // play videos on christmass layer
110  $(".box-3-2 .video-list a.play").on("click", function (e) {
111    e.preventDefault();
112    videoPlayer($(this).data("file"), $(this).data("image"));
113  });
114  var cookieOptions = {
115    path: "/",
116    expires: 7,
117  };
118  if (
119    $.cookie("mobile-tooltip-count") == undefined ||
120    $.cookie("mobile-tooltip-count") < 5
121  ) {
122    $(".mobile-tooltip").show();
123    var counter = 0;
124    if ($.cookie("mobile-tooltip-count") != undefined) {
125      var counter = parseInt($.cookie("mobile-tooltip-count"));
126    }
127    counter++;
128    $.cookie("mobile-tooltip-count", counter, cookieOptions);
129  }
130  // location selector interactions
131  $("#dcContainer area").on("click", function (e) {
132    e.preventDefault();
133    e.stopPropagation();
134    if ($(this).data("mapId") != undefined) {
135      $(".map-active span").removeClass("active");
136      $(".map-active div").removeClass("active");
137      part = ".map-active span." + $(this).data("location");
138      $(part).addClass("active");
139      pointer = ".map-active div.pointer-" + $(this).data("location");
140      $(pointer).addClass("active");
141    }
142  });
143  $("#dcContainer area").mouseover(function () {
144    part = ".map-active span." + $(this).data("location");
145    $(part).css("display", "block");
146  });
147  $("#dcContainer area").mouseleave(function () {
148    part = ".map-active span." + $(this).data("location");
149    $(part).css("display", "none");
150  });
151  $("#dcContainer #changeLocation").on("click", function () {
152    localiseSC(null, null, true);
153  });
154  $("#dcContainer .saveLocation").on("click", function (e) {
155    e.preventDefault();
156    var shipping = $(this).parent().find("select#shop").val();
157    if (shipping != "") {
158      $("#dcContainer").trigger("saveShipping", shipping);
159    }
160  });
161  $("#dcContainer .close").on("click", function (e) {
162    $("#dcContainer #dcUI").slideUp();
163    if ($.cookie("dc") != undefined) {
164      $("#dcContainer #changeLocation").slideDown();
165    }
166  });
167
168  //close banner
169  if ($(".mobile-banner").length > 0) {
170    $(".mobile-banner .close").on("click", function (e) {
171      e.preventDefault();
172      $(".mobile-banner").hide();
173      $("#dashboard, #mainnav ").css("margin-top", 0);
174    });
175    if ($.cookie("mobile-shown-new") != "yes") {
176      /*
177		    if (/Android/i.test(navigator.userAgent)){
178		    	$('.mobile-banner a.link').attr('href','https://play.google.com/store/apps/details?id=pl.biedronka');
179		    } else if (/iPhone|iPad|iPod/i.test(navigator.userAgent)){
180		    	$('.mobile-banner a.link').attr('href','https://itunes.apple.com/pl/app/twoja-biedronka/id946080889');
181		    }*/
182      $.cookie("mobile-shown-new", "yes", {
183        path: "/",
184        expires: 3,
185      });
186    } else {
187      $(".mobile-banner").hide();
188      $("#dashboard, #mainnav ").css("margin-top", 0);
189    }
190  }
191
192  // For GTM dataLayer logging
193  $(".event-button").click((e) => {
194    let obj = {};
195    e.currentTarget.value.split("|").forEach((part) => {
196      let [key, value] = part.split("=");
197      obj[key] = value;
198    });
199
200    if (dataLayer) {
201      dataLayer.push({
202        event: "download_ebook",
203        ebook: obj,
204        eventCallback: function () {
205          window.open(obj.link, obj.target || '_self');
206        },
207      });
208    } else {
209      window.open(obj.link, obj.target || '_self');
210    }
211  });
212});
213
214/* moved to biedronka_cookie.js
215 * $(window).on('load',function() {
216	// cookie policy
217	var options = {
218		path : '/',
219		expires : 365
220	};
221	if ($.cookie('confirmed-new') != 'yes') {
222		var $content = $('<div id="cookiepopupdiv" style="display: block;"><div id="innerdiv"><div id="cookie"></div><div style="cursor:pointer" id="dontShowMessage"></div><span><p class="text">'
223				+ t('cookie_policy_text')
224				+ '</p></span></div></div>');
225		$content.hide();
226		$content.find('div#dontShowMessage').on('click',
227				function() {
228					$.cookie('confirmed-new', 'yes', options);
229					$(this).parent().parent().fadeOut();
230				});
231		$content.prependTo($('body'));
232		$content.fadeIn();
233	}
234});*/
235function closestShopFromGroup(groupId, dcShop, textValue) {
236  if (textValue === null || textValue === "" || textValue === undefined) {
237    textValue = "shop_not_in_group";
238  }
239  var textValueWhole = '<p class="dialog_text">' + t(textValue) + "</p>";
240  var searchValueNode =
241    '<div id="dcShopSearch' +
242    dcShop +
243    '" class="search">' +
244    t("searching") +
245    "...</div>";
246  message(textValueWhole + searchValueNode);
247  $.getJSON(
248    apiBaseUrl + "api/shop/closestshopfromgroup",
249    { group: groupId, shop: dcShop },
250    function (data) {
251      if (data.result == 0) {
252        if (data.shop == false) {
253          $("#dcShopSearch" + dcShop).text(t("No shop found in given group"));
254        } else {
255          var shopName = data.shop.city;
256          if (data.shop.street != "" && data.shop.street != null) {
257            shopName += ", " + data.shop.street;
258            if (
259              data.shop.street_number != "" &&
260              data.shop.street_number != null
261            ) {
262              shopName += " " + data.shop.street_number;
263            }
264          }
265          var language = window.location.pathname.substr(1).split("/")[0];
266          var url =
267            "/" +
268            language +
269            "/sklepy/shop,id," +
270            data.shop.id +
271            ",name," +
272            slugify(shopName);
273          $("#dcShopSearch" + dcShop).text("");
274          $("#dcShopSearch" + dcShop).append(
275            $('<a href="' + url + '">' + shopName + "</a>")
276          );
277        }
278      } else {
279        $("#dcShopSearch" + dcShop).text(t(data.error));
280      }
281    }
282  );
283}
284function pushEvent(eventName) {
285  dataLayer.push({ event: eventName });
286}
287function blacklistValid(groupName, phraseValue, callback, errorCallback) {
288  $.getJSON(
289    apiBaseUrl + "api/blacklist/check",
290    {
291      group: groupName,
292      phrase: phraseValue,
293    },
294    function (data) {
295      if (data.result == 0) {
296        if (data.valid == 1) {
297          if (typeof callback == "function") {
298            callback();
299          }
300        }
301      } else if (typeof errorCallback == "function") {
302        errorCallback(data);
303      }
304    }
305  );
306}
307
308function videoPlayer(videoUrl, imageUrl) {
309  var eventPushed = false;
310  if (
311    /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
312      navigator.userAgent
313    )
314  ) {
315    // mobile browser redirecting to video file
316    window.location = videoUrl;
317  } else {
318    jwplayer("videoPlayer").setup({
319      file: videoUrl,
320      image: imageUrl,
321      width: 640,
322      height: 380,
323      events: {
324        onTime: function (event) {
325          if (event.position >= 5 && eventPushed == false) {
326            pushEvent("video 5s watched");
327            eventPushed = true;
328          }
329        },
330      },
331    });
332    $("#videoPlayerLayer").bPopup({
333      onClose: function () {
334        jwplayer("videoPlayer").stop();
335      },
336    });
337  }
338}
339
340function message(message, translate) {
341  if (translate !== false) {
342    message = t(message);
343  }
344  $('<div class="message">' + message + "</div>").dialog({
345    modal: true,
346    buttons: {
347      close: {
348        click: function () {
349          $(this).dialog("close");
350        },
351        text: t("close"),
352      },
353    },
354  });
355}
356function slugify(str) {
357  str = str.replace(/^\s+|\s+$/g, ""); // trim
358  str = str.toLowerCase();
359  var from = "ążźćłńóę";
360  var to = "azzclnoe";
361  for (var i = 0, l = from.length; i < l; i++) {
362    str = str.replace(new RegExp(from.charAt(i), "g"), to.charAt(i));
363  }
364  str = str
365    .replace(/[^a-z0-9 -]/g, "") // remove invalid chars
366    .replace(/\s+/g, "-") // collapse whitespace and replace by -
367    .replace(/-+/g, "-"); // collapse dashes
368
369  return str;
370}
371function localiseSC(name, callback, forceSelect) {
372  var shipping = $.cookie("dc");
373  var container = $("#dcContainer");
374  if (typeof container.data("callbackStack") != "object") {
375    container.data("callbackStack", {});
376  }
377  if (typeof name == "string" && typeof callback == "function") {
378    container.data("callbackStack")[name] = callback;
379  }
380  var notifyCallback = function (shipping) {
381    $.each(container.data("callbackStack"), function (key, callb) {
382      if (typeof callb == "function") {
383        callb(shipping);
384      }
385    });
386  };
387  if (shipping != undefined && forceSelect != true) {
388    notifyCallback(shipping);
389    $("#changeLocation").show();
390  } else {
391    $("#dcContainer area").on("click", function (e) {
392      e.preventDefault();
393      e.stopPropagation();
394      if ($(this).data("mapId") != undefined) {
395        $("#dcContainer").data("province", $(this).data("mapId"));
396        loadSelector();
397      }
398    });
399    var nameFromShop = function (shop) {
400      var displayName = shop.city;
401      if (shop.street != null) {
402        displayName += " " + shop.street;
403      }
404      if (shop.street_number != null) {
405        displayName += " " + shop.street_number;
406      }
407      return displayName;
408    };
409    var checkHistory = function () {
410      var historyPlaceHolder = $("#shopHistory");
411      historyPlaceHolder.parent().find(".history-loader").show();
412      historyPlaceHolder.hide();
413      var historyList = historyPlaceHolder.find("ul.previous");
414      historyList.find("li").remove();
415      if ($.cookie("dc_history") != undefined) {
416        $.getJSON(
417          apiBaseUrl + "api/shop/history",
418          { history: $.cookie("dc_history") },
419          function (data) {
420            if (data.result == 0) {
421              var dc = $.cookie("dc");
422              if (dc in data.items) {
423                historyPlaceHolder
424                  .find(".currentLocation")
425                  .text(nameFromShop(data.items[dc]));
426              } else {
427                historyPlaceHolder.find(".currentLocation").text(t("Not set"));
428              }
429              historyList.find("li").remove();
430              $.each(data.items, function (index, shop) {
431                var option = $("<li>" + nameFromShop(shop) + "</li>");
432                option.data("dc", shop.shop_dc_id + "-" + shop.shop_number);
433                option.on("click", function () {
434                  $("#dcContainer").trigger("saveShipping", $(this).data("dc"));
435                });
436                historyList.append(option);
437              });
438
439              historyPlaceHolder.parent().find(".history-loader").hide();
440              historyPlaceHolder.show();
441            }
442          }
443        );
444      } else {
445        historyPlaceHolder.parent().find(".history-loader").hide();
446        historyPlaceHolder.find(".currentLocation").text(t("Not set"));
447        historyList.append($("<li>" + t("No previous location") + "</li>"));
448        historyPlaceHolder.show();
449      }
450    };
451    var runCallback = function (e, arg) {
452      notifyCallback(arg);
453      $.cookie("dc", arg, {
454        path: "/",
455        expires: 365,
456      });
457      var history = [];
458      if ($.cookie("dc_history") != undefined) {
459        history = $.cookie("dc_history").split(",");
460      }
461      if (history.indexOf(arg) == -1) {
462        history.push(arg);
463      }
464      if (history.length > 5) {
465        history.shift();
466      }
467      $.cookie("dc_history", history.join(","), {
468        path: "/",
469        expires: 365,
470      });
471      $("#changeLocation").slideDown();
472      $(this).find("#dcUI").slideUp();
473    };
474    var createSelect = function (items) {
475      var selectPlaceholder = $('<div id="cityShopPlaceholder"></div>');
476      var scSelect = $('<select id="city"></select>');
477      selectPlaceholder.append(scSelect);
478      scSelect.append($('<option value="">' + t("choose") + "</option>"));
479      var currentProvince = $("#dcContainer").data("province");
480      $.each(items, function (index, city) {
481        if (
482          currentProvince == undefined ||
483          city.province.indexOf(parseInt(currentProvince)) != -1
484        ) {
485          var option = $(
486            '<option value="' + city.slug + '">' + city.city + "</option>"
487          );
488          option.data("dc", city.dc);
489          option.data("province", city.province);
490          scSelect.append(option);
491        }
492      });
493      scSelect.on("change", function () {
494        if (selectPlaceholder.find("select#shop").length > 0) {
495          selectPlaceholder.find("select#shop").next().remove();
496          selectPlaceholder.find("select#shop").remove();
497        }
498        var loader = $(
499          '<img class="loader" src="' +
500            staticBaseUrl +
501            '/img/ajax-loader.gif"/>'
502        );
503        selectPlaceholder.append(loader);
504        console.log($(this).val());
505        console.log($(this).data("province"));
506        $.getJSON(
507          apiBaseUrl + "api/shop/cityshopsbyslug",
508          { slug: $(this).val(), province: $("#dcContainer").data("province") },
509          function (data) {
510            if (data.result == 0) {
511              var shopSelect = $('<select id="shop"></select>');
512              $.each(data.items, function (index, shop) {
513                var displayName = nameFromShop(shop);
514                shopSelect.append(
515                  $(
516                    '<option value="' +
517                      (shop.shop_dc_id + "-" + shop.shop_number) +
518                      '">' +
519                      displayName +
520                      "</option>"
521                  )
522                );
523              });
524              loader.remove();
525              selectPlaceholder.append(shopSelect);
526              shopSelect.customSelect();
527            }
528          }
529        );
530      });
531      return selectPlaceholder;
532    };
533    var buildSelector = function (items) {
534      var scContainer = $("#dcContainer");
535      if (scContainer.length > 0) {
536        scContainer.on("saveShipping", runCallback);
537        var top = scContainer.find("#cityShopPlaceholder").parent();
538        top.find("#cityShopPlaceholder").remove();
539        top.prepend(createSelect(items));
540        scContainer.find("select#city").customSelect();
541      }
542      return scContainer;
543    };
544    var initSelector = function (items) {
545      var scContainer = buildSelector(items);
546      if (scContainer.length > 0) {
547        $(".map-active span").removeClass("active");
548        scContainer.find("#dcUI").slideDown();
549        $("#changeLocation").slideUp();
550        checkHistory();
551      }
552    };
553    var parseData = function (data) {
554      if (data.result == 0) {
555        initSelector(data.items);
556        window.dcity = data.items;
557      }
558    };
559    var loadSelector = function () {
560      if (window.dcity == undefined) {
561        $.getJSON(apiBaseUrl + "api/shop/shippingcenter", parseData);
562      } else {
563        initSelector(window.dcity);
564      }
565    };
566    loadSelector();
567  }
568}
569
570//new dashboard handle
571$(document).ready(function() {
572
573  dashboardHandle();
574});
575
576const dashboardHandle = () => {
577  const $dashboard = $('#dashboard-new');
578  if (!$dashboard.length) {
579    return;
580  }
581
582  const $navDesktop = $dashboard.find('.desktop-nav-bar');
583  const $navMobile = $dashboard.find('.menu-category-mobile');
584  const $menuMobile = $dashboard.find('.menu-main-mobile');
585  const $searchBtnDesktop = $navDesktop.find('.search-btn-submit');
586  const $formDesktop = $searchBtnDesktop.closest('form');
587  const $formDesktopInput = $formDesktop.find('input');
588  const $animatedBtn = $navDesktop.find('.btn-animation');
589
590  $searchBtnDesktop.on('click', function (e) {
591    e.preventDefault();
592
593    const isActive = $formDesktop.hasClass('active');
594
595    if (isActive) {
596      const inputValue = $.trim($formDesktopInput.val());
597
598      if (!inputValue) {
599        $formDesktop.removeClass('active');
600        $(document).off('keydown.navSearch'); // wyłączenie ESC
601
602        $animatedBtn.removeClass('search-active');
603        return;
604      }
605
606      $formDesktop.submit();
607    } else {
608      $formDesktop.addClass('active');
609      $formDesktopInput.focus();
610
611      $animatedBtn.addClass('search-active');
612
613      // dodajemy ESC tylko raz
614      $(document).off('keydown.navSearch').on('keydown.navSearch', function(e) {
615        if (e.key === 'Escape') {
616          $formDesktop.removeClass('active');
617          $formDesktopInput.val('');
618          $(document).off('keydown.navSearch');
619        }
620      });
621    }
622  });
623
624  const createPromotedElements = $element => {
625    const $container = $element.closest('.dropdown-box');
626    const $imagesContainer = $container.find('.dropdown-images');
627
628    const $sideview = $(`
629      <span class="dropdown-img">
630        <a></a>
631      </span>
632    `);
633
634    const image = $element.data("image");
635    const description = $element.data("description");
636
637    // Jeśli brak promocji (brak image i brak description) — koniec
638    if (!image && !description) return;
639
640    const $link = $sideview.find("a");
641    $link.attr("href", $element.attr("href"));
642
643    // Obrazek
644    if (image) {
645      $link.append(`<img src="${image}" alt="">`);
646    }
647
648    // Opis
649    if (description) {
650      $link.append(`<span class="description">${description}</span>`);
651    }
652
653    $element.closest('li').addClass('promoted');
654
655    // Dodaj sideview
656    $imagesContainer.append($sideview);
657  }
658
659  $navMobile.find('a[data-promoted="1"]').each(function () {
660    const $element = $(this);
661    createPromotedElements($element);
662  });
663  $navDesktop.find('a[data-promoted="1"]').each(function () {
664    const $element = $(this);
665    createPromotedElements($element);
666  });
667
668  $menuMobile.find('.menu-default').on('click', function () {
669    const $navBtn = $(this);
670    const $navHamburger = $navBtn.find('.hamburger-dashboard');
671    const $menuCategory = $menuMobile.find('.menu-category-mobile');
672    const isOpened = $menuCategory.hasClass('opened');
673
674    if (isOpened) {
675      $navHamburger.removeClass('active');
676      $menuCategory.removeClass('opened');
677    } else {
678      $navHamburger.addClass('active')
679      $menuCategory.addClass('opened');
680    }
681  });
682
683  $menuMobile.find('.has-children').on('click', function (e) {
684    e.preventDefault();
685    const $parent = $(this).closest('.has-children');
686
687    const isOpened = $parent.hasClass('opened');
688
689    if (isOpened) {
690      $parent.removeClass('opened');
691    } else {
692      $parent.addClass('opened');
693    }
694  });
695}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.