PageSourceSearch

https://www.somsenteret.no/dist/js/main.9614a246623044d548c8.js

js somsenteret.no collected 2026-09-25 02:01:58 UTC 47,632 bytes, 1,335 lines download raw bytes

vendor: 9,315 bytes, lines 1-371
1(self["webpackChunkmcweb3"] = self["webpackChunkmcweb3"] || []).push([[792],{
2
3/***/ 3526:
4/***/ (function() {
5
6mcWeb.shipment = new function () {}();
7mcWeb.shipment.events = {
8  reloadShipment: "mcWeb.shipment.reloadShipment",
9  onChangedShipment: "mcWeb.shipment.onChangedShipment",
10  onSelectedShipment: "mcWeb.shipment.onSelectedShipment",
11  onSelectedShipmentForCustomerRefresh: "mcWeb.shipment.onSelectedShipmentForCustomerRefresh"
12};
13
14/***/ }),
15
16/***/ 5477:
17/***/ (function() {
18
19mcWeb.cartsmall = new function () {}();
20mcWeb.cartsmall.events = {
21  onChangedQuantityCartSmall: "mcWeb.cartsmall.onChangedQuantityCartSmall",
22  onUpdateCart: "mcWeb.cartsmall.events.onUpdateCart",
23  onUpdateCartForceLoad: "mcWeb.cartsmall.events.onUpdateCartForceLoad",
24  onChangeVat: "mcWeb.cartsmall.events.onChangeVat",
25  onShowNewItemInCart: "mcWeb.cartsmall.events.onShowNewItemInCart",
26  onShowNewItemInCartText: "mcWeb.cartsmall.events.onShowNewItemInCartText",
27  onHideNewItemInCart: "mcWeb.cartsmall.events.onHideNewItemInCart",
28  onChangeFav: "mcWeb.cartsmall.events.onChangeFav",
29  onCartItemRemoved: "mcWeb.cartsmall.events.onCartItemRemoved",
30  onGotoSelectedCart: "mcWeb.cartsmall.events.onGotoSelectedCart",
31  onIsCartChanged: "mcWeb.cartsmall.events.onIsCartChanged"
32};
33
34/***/ }),
35
36/***/ 6132:
37/***/ (function(__unused_webpack_module, __unused_webpack___webpack_exports__, __webpack_require__) {
38
39"use strict";
40
41;// ./node_modules/promise-polyfill/src/finally.js
42/**
43 * @this {Promise}
44 */
45function finallyConstructor(callback) {
46  var constructor = this.constructor;
47  return this.then(
48    function(value) {
49      // @ts-ignore
50      return constructor.resolve(callback()).then(function() {
51        return value;
52      });
53    },
54    function(reason) {
55      // @ts-ignore
56      return constructor.resolve(callback()).then(function() {
57        // @ts-ignore
58        return constructor.reject(reason);
59      });
60    }
61  );
62}
63
64/* harmony default export */ var src_finally = (finallyConstructor);
65
66;// ./node_modules/promise-polyfill/src/allSettled.js
67function allSettled(arr) {
68  var P = this;
69  return new P(function(resolve, reject) {
70    if (!(arr && typeof arr.length !== 'undefined')) {
71      return reject(
72        new TypeError(
73          typeof arr +
74            ' ' +
75            arr +
76            ' is not iterable(cannot read property Symbol(Symbol.iterator))'
77        )
78      );
79    }
80    var args = Array.prototype.slice.call(arr);
81    if (args.length === 0) return resolve([]);
82    var remaining = args.length;
83
84    function res(i, val) {
85      if (val && (typeof val === 'object' || typeof val === 'function')) {
86        var then = val.then;
87        if (typeof then === 'function') {
88          then.call(
89            val,
90            function(val) {
91              res(i, val);
92            },
93            function(e) {
94              args[i] = { status: 'rejected', reason: e };
95              if (--remaining === 0) {
96                resolve(args);
97              }
98            }
99          );
100          return;
101        }
102      }
103      args[i] = { status: 'fulfilled', value: val };
104      if (--remaining === 0) {
105        resolve(args);
106      }
107    }
108
109    for (var i = 0; i < args.length; i++) {
110      res(i, args[i]);
111    }
112  });
113}
114
115/* harmony default export */ var src_allSettled = (allSettled);
116
117;// ./node_modules/promise-polyfill/src/any.js
118/**
119 * @constructor
120 */
121function AggregateError(errors, message) {
122  (this.name = 'AggregateError'), (this.errors = errors);
123  this.message = message || '';
124}
125AggregateError.prototype = Error.prototype;
126
127function any(arr) {
128  var P = this;
129  return new P(function(resolve, reject) {
130    if (!(arr && typeof arr.length !== 'undefined')) {
131      return reject(new TypeError('Promise.any accepts an array'));
132    }
133
134    var args = Array.prototype.slice.call(arr);
135    if (args.length === 0) return reject();
136
137    var rejectionReasons = [];
138    for (var i = 0; i < args.length; i++) {
139      try {
140        P.resolve(args[i])
141          .then(resolve)
142          .catch(function(error) {
143            rejectionReasons.push(error);
144            if (rejectionReasons.length === args.length) {
145              reject(
146                new AggregateError(
147                  rejectionReasons,
148                  'All promises were rejected'
149                )
150              );
151            }
152          });
153      } catch (ex) {
154        reject(ex);
155      }
156    }
157  });
158}
159
160/* harmony default export */ var src_any = (any);
161
162;// ./node_modules/promise-polyfill/src/index.js
163
164
165
166
167// Store setTimeout reference so promise-polyfill will be unaffected by
168// other code modifying setTimeout (like sinon.useFakeTimers())
169var setTimeoutFunc = setTimeout;
170
171function isArray(x) {
172  return Boolean(x && typeof x.length !== 'undefined');
173}
174
175function noop() {}
176
177// Polyfill for Function.prototype.bind
178function bind(fn, thisArg) {
179  return function() {
180    fn.apply(thisArg, arguments);
181  };
182}
183
184/**
185 * @constructor
186 * @param {Function} fn
187 */
188function Promise(fn) {
189  if (!(this instanceof Promise))
190    throw new TypeError('Promises must be constructed via new');
191  if (typeof fn !== 'function') throw new TypeError('not a function');
192  /** @type {!number} */
193  this._state = 0;
194  /** @type {!boolean} */
195  this._handled = false;
196  /** @type {Promise|undefined} */
197  this._value = undefined;
198  /** @type {!Array<!Function>} */
199  this._deferreds = [];
200
201  doResolve(fn, this);
202}
203
204function handle(self, deferred) {
205  while (self._state === 3) {
206    self = self._value;
207  }
208  if (self._state === 0) {
209    self._deferreds.push(deferred);
210    return;
211  }
212  self._handled = true;
213  Promise._immediateFn(function() {
214    var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected;
215    if (cb === null) {
216      (self._state === 1 ? resolve : reject)(deferred.promise, self._value);
217      return;
218    }
219    var ret;
220    try {
221      ret = cb(self._value);
222    } catch (e) {
223      reject(deferred.promise, e);
224      return;
225    }
226    resolve(deferred.promise, ret);
227  });
228}
229
230function resolve(self, newValue) {
231  try {
232    // Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure
233    if (newValue === self)
234      throw new TypeError('A promise cannot be resolved with itself.');
235    if (
236      newValue &&
237      (typeof newValue === 'object' || typeof newValue === 'function')
238    ) {
239      var then = newValue.then;
240      if (newValue instanceof Promise) {
241        self._state = 3;
242        self._value = newValue;
243        finale(self);
244        return;
245      } else if (typeof then === 'function') {
246        doResolve(bind(then, newValue), self);
247        return;
248      }
249    }
250    self._state = 1;
251    self._value = newValue;
252    finale(self);
253  } catch (e) {
254    reject(self, e);
255  }
256}
257
258function reject(self, newValue) {
259  self._state = 2;
260  self._value = newValue;
261  finale(self);
262}
263
264function finale(self) {
265  if (self._state === 2 && self._deferreds.length === 0) {
266    Promise._immediateFn(function() {
267      if (!self._handled) {
268        Promise._unhandledRejectionFn(self._value);
269      }
270    });
271  }
272
273  for (var i = 0, len = self._deferreds.length; i < len; i++) {
274    handle(self, self._deferreds[i]);
275  }
276  self._deferreds = null;
277}
278
279/**
280 * @constructor
281 */
282function Handler(onFulfilled, onRejected, promise) {
283  this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null;
284  this.onRejected = typeof onRejected === 'function' ? onRejected : null;
285  this.promise = promise;
286}
287
288/**
289 * Take a potentially misbehaving resolver function and make sure
290 * onFulfilled and onRejected are only called once.
291 *
292 * Makes no guarantees about asynchrony.
293 */
294function doResolve(fn, self) {
295  var done = false;
296  try {
297    fn(
298      function(value) {
299        if (done) return;
300        done = true;
301        resolve(self, value);
302      },
303      function(reason) {
304        if (done) return;
305        done = true;
306        reject(self, reason);
307      }
308    );
309  } catch (ex) {
310    if (done) return;
311    done = true;
312    reject(self, ex);
313  }
314}
315
316Promise.prototype['catch'] = function(onRejected) {
317  return this.then(null, onRejected);
318};
319
320Promise.prototype.then = function(onFulfilled, onRejected) {
321  // @ts-ignore
322  var prom = new this.constructor(noop);
323
324  handle(this, new Handler(onFulfilled, onRejected, prom));
325  return prom;
326};
327
328Promise.prototype['finally'] = src_finally;
329
330Promise.all = function(arr) {
331  return new Promise(function(resolve, reject) {
332    if (!isArray(arr)) {
333      return reject(new TypeError('Promise.all accepts an array'));
334    }
335
336    var args = Array.prototype.slice.call(arr);
337    if (args.length === 0) return resolve([]);
338    var remaining = args.length;
339
340    function res(i, val) {
341      try {
342        if (val && (typeof val === 'object' || typeof val === 'function')) {
343          var then = val.then;
344          if (typeof then === 'function') {
345            then.call(
346              val,
347              function(val) {
348                res(i, val);
349              },
350              reject
351            );
352            return;
353          }
354        }
355        args[i] = val;
356        if (--remaining === 0) {
357          resolve(args);
358        }
359      } catch (ex) {
360        reject(ex);
361      }
362    }
363
364    for (var i = 0; i < args.length; i++) {
365      res(i, args[i]);
366    }
367  });
368};
369
370Promise.any = src_any;
371
372Promise.allSettled = src_allSettled;
373
374Promise.resolve = function(value) {
375  if (value && typeof value === 'object' && value.constructor === Promise) {
376    return value;
377  }
378
379  return new Promise(function(resolve) {
380    resolve(value);
381  });
382};
383
384Promise.reject = function(value) {
385  return new Promise(function(resolve, reject) {
386    reject(value);
387  });
388};
389
390Promise.race = function(arr) {
391  return new Promise(function(resolve, reject) {
392    if (!isArray(arr)) {
393      return reject(new TypeError('Promise.race accepts an array'));
394    }
395
396    for (var i = 0, len = arr.length; i < len; i++) {
397      Promise.resolve(arr[i]).then(resolve, reject);
398    }
399  });
400};
401
402// Use polyfill for setImmediate for performance gains
403Promise._immediateFn =
404  // @ts-ignore
405  (typeof setImmediate === 'function' &&
406    function(fn) {
407      // @ts-ignore
408      setImmediate(fn);
409    }) ||
410  function(fn) {
411    setTimeoutFunc(fn, 0);
412  };
413
414Promise._unhandledRejectionFn = function _unhandledRejectionFn(err) {
415  if (typeof console !== 'undefined' && console) {
416    console.warn('Possible Unhandled Promise Rejection:', err); // eslint-disable-line no-console
417  }
418};
419
420/* harmony default export */ var src = (Promise);
421
422;// ./node_modules/promise-polyfill/src/polyfill.js
423
424
425
426
427
428/** @suppress {undefinedVars} */
429var globalNS = (function() {
430  // the only reliable means to get the global object is
431  // `Function('return this')()`
432  // However, this causes CSP violations in Chrome apps.
433  if (typeof self !== 'undefined') {
434    return self;
435  }
436  if (typeof window !== 'undefined') {
437    return window;
438  }
439  if (typeof __webpack_require__.g !== 'undefined') {
440    return __webpack_require__.g;
441  }
442  throw new Error('unable to locate global object');
443})();
444
445// Expose the polyfill if Promise is undefined or set to a
446// non-function value. The latter can be due to a named HTMLElement
447// being exposed by browsers for legacy reasons.
448// https://github.com/taylorhakes/promise-polyfill/issues/114
449if (typeof globalNS['Promise'] !== 'function') {
450  globalNS['Promise'] = src;
451} else {
452  if (!globalNS.Promise.prototype['finally']) {
453    globalNS.Promise.prototype['finally'] = src_finally;
454  }
455  if (!globalNS.Promise.allSettled) {
456    globalNS.Promise.allSettled = src_allSettled;
457  }
458  if (!globalNS.Promise.any) {
459    globalNS.Promise.any = src_any;
460  }
461}
462
463// EXTERNAL MODULE: ./Scripts4.0/ajax-render-engine.js
464var ajax_render_engine = __webpack_require__(3477);
465;// ./Scripts4.0/d4-main.js
466
467
468document.addEventListener('DOMContentLoaded', function () {
469  if (jQuery("body.d4-loading-awaits-knockout").length <= 0) {
470    ajax_render_engine/* AjaxRenderingEngine */.X.load();
471  } else {
472    //the individual page takes control of starting the loading
473    PubSub.subscribe(ajax_render_engine/* AjaxRenderingEngineEventTypes */.A.onKnockoutRenderingCompleted, function (message, options) {
474      ajax_render_engine/* AjaxRenderingEngine */.X.load();
475    });
476  }
477  PubSub.subscribe(ajax_render_engine/* AjaxRenderingEngineEventTypes */.A.onNewAreasShown, function (message, options) {
478    ajax_render_engine/* AjaxRenderingEngine */.X.updateVariantMatrix(options);
479  });
480  PubSub.subscribe(ajax_render_engine/* AjaxRenderingEngineEventTypes */.A.onFieldsRefresh, function (message, options) {
481    ajax_render_engine/* AjaxRenderingEngine */.X.reloadFields(options.parentId);
482  });
483  PubSub.subscribe(ajax_render_engine/* AjaxRenderingEngineEventTypes */.A.onPopupReady, function (message, options) {
484    if (options !== undefined && options !== null && options.dataToApply !== undefined && options.dataToApply !== null) {
485      for (var i = 0; i < options.dataToApply.Data.length; i++) {
486        var data = options.dataToApply.Data[i];
487        ajax_render_engine/* AjaxRenderingEngine */.X.refineInsertedContent(data.targetField, data);
488      }
489    }
490  });
491});
492
493/***/ }),
494
495/***/ 6330:
496/***/ (function() {
497
498mcWeb.payments = new function () {}();
499mcWeb.payments.events = {
500  onShowUpdateIcon: "mcWeb.payments.onShowUpdateIcon",
501  onHideUpdateIcon: "mcWeb.payments.onHideUpdateIcon",
502  reloadPayments: "mcWeb.payments.reloadPayments",
503  focusFirstName: "mcWeb.payments.paymentsfocusFirstName",
504  updateOrgNr: "mcWeb.payments.updateOrgNr",
505  processPaymentMethods: "mcWeb.payments.processPaymentMethods",
506  onSelectedPayment: "mcWeb.payments.onSelectedPayment",
507  updateKco: "mcWeb.payments.events.updateKco"
508};
509
510/***/ }),
511
512/***/ 6570:
513/***/ (function() {
514
515mcWeb.cart = new function () {}();
516mcWeb.cart.events = {
517  hasCartItems: "mcWeb.cart.events.hasCartItems",
518  onChangedCart: "mcWeb.cart.events.onChangedCart",
519  onChangedQuantityCart: "mcWeb.cart.events.onChangedQuantityCart",
520  focusDiscoutCode: "mcWeb.cart.events.focusDiscoutCode",
521  cartGuid: "mcWeb.cart.events.cartGuid",
522  onChangeCollectedDelivery: "mcWeb.cart.events.onChangeCollectedDelivery",
523  onShowNewItemInCart: "mcWeb.cart.events.onShowNewItemInCart",
524  onShowNewItemInCartText: "mcWeb.cart.events.onShowNewItemInCartText",
525  onHideNewItemInCart: "mcWeb.cart.events.onHideNewItemInCart",
526  onRequestSendt: "mcWeb.cart.events.onRequestSendt",
527  onPopupForProductAssembly: "mcWeb.cart.events.onPopupForProductAssembly"
528};
529
530/***/ }),
531
532/***/ 6872:
533/***/ (function() {
534
535mcWeb.receipt = new function () {
536  this.events = {};
537  this.vm = function (id) {
538    var $ = jQuery;
539    var self = this;
540    this.id = "#" + id;
541    this.langService = new LanguageService();
542    this.expressCustomer = ko.observable(false);
543    this.showCheckoutConfirmation = ko.observable(false);
544    this.showReceiptInformation = ko.observable(true);
545    this.showSantanderPayeverApproved = ko.observable(false);
546    this.showSantanderPayeverManual = ko.observable(false);
547    this.showNordeaFinancingResult = ko.observable(false);
548    this.nordeaFinancingText = ko.observable('');
549    this.load = function (data, settings) {
550      if (data.ExpressCustomer) self.expressCustomer(true);
551      self.showCheckoutConfirmation(false);
552      self.GetCheckoutConfirmationSnippet();
553      self.showSantanderPayeverApproved(false);
554      self.showSantanderPayeverManual(false);
555      self.GetSantanderPayeverApplicationResult();
556      self.GetLatestNordeaFinancingApplicationResult();
557    };
558    this.GetSantanderPayeverApplicationResult = function () {
559      var serviceLocal = new WebApiService("Payment");
560      serviceLocal.GetAction("GetSantanderPayeverApplicationResult", null).then(function (result) {
561        if (result == null || result.length < 1) {
562          return;
563        }
564        var currentPaymentMethod = result.CurrentPaymentMethod;
565        if (currentPaymentMethod !== "SantanderPayever") return;
566        var json = JSON.parse(result.ExtraInfoJson);
567        if (json.Status == "APPROVED") {
568          self.showSantanderPayeverApproved(true);
569          self.showReceiptInformation(false);
570        } else if (json.Status == "MANUAL") {
571          self.showSantanderPayeverManual(true);
572          self.showReceiptInformation(false);
573        }
574      });
575    };
576    this.GetLatestNordeaFinancingApplicationResult = function () {
577      var serviceLocal = new WebApiService("Payment");
578      serviceLocal.GetAction("GetLatestNordeaFinancingApplicationResult", null).then(function (result) {
579        if (result == null || result.length < 1) {
580          return;
581        }
582        var currentPaymentMethod = result.CurrentPaymentMethod;
583        if (currentPaymentMethod !== "NordeaFinancing") return;
584        if (result.Msg !== null && result.Msg.length > 0) {
585          self.showNordeaFinancingResult(true);
586          self.nordeaFinancingText(result.Msg);
587          self.showReceiptInformation(false);
588        } else {
589          self.showNordeaFinancingResult(false);
590          self.showReceiptInformation(true);
591        }
592      });
593    };
594    this.GetCheckoutConfirmationSnippet = function () {
595      var serviceLocal = new WebApiService("Payment");
596      serviceLocal.GetAction("GetCheckoutConfirmationSnippet", null).then(function (result) {
597        if (result === null || result.length < 1 || result.Snippet.length === 0) {
598          return;
599        }
600        if (result.UseSoftlog) {
601          if (result.CustomerEmail !== mcWeb.currentUser.getUser()) mcWeb.currentUser.setUser(result.CustomerEmail);
602        }
603        self.showCheckoutConfirmation(true);
604        $("#klarna-confirmation-snippet").html(result.Snippet);
605      });
606    };
607    this.OnClickSendOrder = function () {
608      var btnOrderEl = $("#McPaymentAddOrderbottom");
609      var serviceLocal = new WebApiService("Payment");
610      btnOrderEl.removeClass("btn-primary");
611      btnOrderEl.addClass("btn-default disabled");
612      serviceLocal.GetAction("GetConfirmationUrl", null).then(function (result) {
613        if (result === null || result.length < 1) {
614          console.log("Error parsing confirmation url");
615          btnOrderEl.removeClass("btn-default disabled");
616          btnOrderEl.addClass("btn-primary");
617          return;
618        }
619        window.location.href = result;
620      });
621    };
622  };
623}();
624
625/***/ }),
626
627/***/ 9477:
628/***/ (function() {
629
630mcWeb.cartsmall = jQuery.extend(true, mcWeb.cartsmall, new function () {
631  this.vm = function (id) {
632    var $ = jQuery;
633    var self = this;
634    if ($('.body-checkout').length > 0) {
635      self.load = function (data, settings) {};
636      return; //skipp
637    }
638
639    self.id = "#" + id;
640    self.service = new WebApiService("Cart");
641    self.popoverNode = null;
642    self.popoverOpen = ko.observable(false);
643    self.priceTotal = ko.observable();
644    self.priceTotalInkVat = ko.observable();
645    self.priceTotalProducts = ko.observable();
646    self.priceTotalProductsInkVat = ko.observable();
647    self.priceTotalInkVatExShipping = ko.observable();
648    self.priceTotalExVatExShipping = ko.observable();
649    self.summaryPreGiftcardsInkMva = ko.observable();
650    self.summaryPreGiftcardsEksMva = ko.observable();
651    self.giftcardsTotal = ko.observable();
652    self.giftVoucherUsedValue = ko.observable('');
653    self.giftVoucherUsedValueExVat = ko.observable('');
654    self.priceTotalInkCarrier = ko.observable();
655    self.priceTotalInkCarrierInkVat = ko.observable();
656    self.vatTotal = ko.observable(0);
657    self.vatTotalInkCarrier = ko.observable();
658    self.hasCart = ko.observable();
659    self.cartName = ko.observable();
660    self.displayDate = ko.observable();
661    self.itemCount = ko.observable();
662    self.favoriteCount = ko.observable(0);
663    self.cartItems = ko.observableArray();
664    self.orderbooks = ko.observableArray();
665    self.showPriceDisplayControls = false;
666    self.chkPriceIncExVat = ko.observable();
667    self.chkShowVeilPris = false;
668    self.chkHideCustomerPice = false;
669    self.isLoggedIn = ko.observable();
670    self.showPriceIncExVat = false;
671    self.showRemoveButton = false;
672    self.showCart = ko.observable(true);
673    self.showRemoveCart = ko.observable(false);
674    self.OrderbookDate = ko.observable('');
675    self.OrderbookActive = ko.observable(false);
676    self.showGoToCart = false;
677    self.showGoToCheckout = false;
678    self.showExternalCheckout = false;
679
680    //Removed in 2016 design (code is used by old design)
681    self.addToCartNotifier = ko.observable(false);
682    self.addToCartNotifierText = ko.observable('');
683    self.addToCartNotifierIsActive = ko.observable(false);
684    //End removed
685
686    self.showLeasingCosts = ko.observable(false);
687    self.doNotShowLeasingCosts = ko.pureComputed(function () {
688      return !self.showLeasingCosts() || self.LeasingTermAmountExVat().length <= 0;
689    });
690    self.LeasingTermAmountExVat = ko.observable('');
691    self.smallCartFees = false;
692    self.isVisible = ko.observable(false);
693    self.isCartItemsSet = ko.observable(false);
694    self.favoriteCartUrl = '';
695    self.offerCartUrl = '';
696    self.isSoftLog = null;
697    self.decimalsQuantity = 0;
698    self.popupTime = 2500;
699    self.showOrderbookSummary = ko.observable(false);
700    self.smallCartItemTemplate = ko.computed(function () {
701      if (self.showLeasingCosts()) return 'cartsmallitem-leasing-template';
702      return 'cartsmallitem-template';
703    });
704    self.smallCartContentId = ko.observable('small-cart-content');
705    self.invoiceFee = ko.observable();
706    self.invoiceFeeInkVat = ko.observable();
707    self.invoiceFeeAndShipping = ko.observable();
708    self.invoiceFeeAndShippingInkVat = ko.observable();
709    self.SummarySumCostReductionIncVat = ko.observable();
710    self.summarySumAfterCostReductionsIncVat = ko.observable();
711    self.disableIncExVatChange = false;
712    self.offerCount = ko.observable(0);
713    self.cartHashCode = null;
714    self.guId = null;
715    $(document).ready(function () {
716      self.popupMsg = $('#NewItemInCartNotifier');
717      self.popupMsgWait = self.popupMsg.find('.pop-wait');
718      self.popupMsgSuccess = self.popupMsg.find('.pop-success');
719      self.popupMsgError = self.popupMsg.find('.pop-error');
720      self.popupMsgText = self.popupMsg.find('.cart-popup-text');
721    });
722    self.numberOfItemsToShow = ko.observable(0);
723    self.cartItemsToShow = ko.computed(function () {
724      var items = [];
725      var itemsToShow = self.cartItems().length;
726      if (self.numberOfItemsToShow() > 0) itemsToShow = Math.min(self.cartItems().length, self.numberOfItemsToShow());
727      for (var i = 0; i < itemsToShow; i++) {
728        items.push(self.cartItems()[i]);
729      }
730      return items;
731    });
732    PubSub.subscribe(mcWeb.cart.events.onChangedCart, function (message, data) {
733      self.load(data);
734    });
735
736    /*Quantity Small Cart changed*/
737    PubSub.subscribe(mcWeb.cart.events.onChangedQuantityCart, function (message, data) {
738      var product = null;
739      for (var i = 0; i < self.cartItems().length; i++) {
740        if (self.cartItems()[i].ProductId === data.ProductId) {
741          product = self.cartItems()[i];
742          break;
743        }
744      }
745      if (product !== null) {
746        self.resultQuantity(data.result, product, data.newQuantity);
747      } else {
748        self.load();
749      }
750    });
751    PubSub.subscribe(mcWeb.cartsmall.events.onUpdateCartForceLoad, function (message, data) {
752      self.load(data, null, true);
753    });
754    PubSub.subscribe(mcWeb.cartsmall.events.onUpdateCart, function (message, data) {
755      self.load(data);
756    });
757    PubSub.subscribe(mcWeb.cartsmall.events.onIsCartChanged, function (message) {
758      var param = {
759        guId: self.guId,
760        cartHashCode: self.cartHashCode
761      };
762      self.service.GetAction("IsCartChanged", param).then(function (result) {
763        if (result === true) {
764          self.load(null, null, true);
765        }
766      });
767    });
768    PubSub.subscribe(mcWeb.cartsmall.events.onChangeVat, function (message, inkVat) {
769      try {
770        //Warning changeing VAT reload page!!!
771
772        if (inkVat === null) return;
773        if (self.chkPriceIncExVat() === inkVat)
774          //No change
775          return;
776        self.chkPriceIncExVat(inkVat);
777        self.setVat(inkVat);
778      } catch (e) {
779        console.log("CartSmallView - Ex: " + e);
780      }
781    });
782    self.doShowActiveCart = function () {
783      self.smallCartContentId('small-cart-content');
784      self.showOrderbookSummary(false);
785      window.StorageService.localStorage.setItem('orderbook.cartivew', 'active-cart');
786    };
787    self.doShowOrderbookSummary = function () {
788      self.showOrderbookSummary(true);
789      self.smallCartContentId('small-cart-orderbook-content');
790      window.StorageService.localStorage.setItem('orderbook.cartivew', 'summary');
791      mcWeb.orderbookManager.showOrderbookSummaryInline('.popover #small-cart-orderbook-summary');
792    };
793    self.doRedirectToOrderOverviw = function () {
794      window.location.href = "/orderbookoverview";
795    };
796    self.load = function (data, settings, forceLoad) {
797      self.showSmallCartAmount();
798
799      //Settings
800      if (settings) {
801        self.showGoToCart = settings.ShowGoToCart;
802        self.showGoToCheckout = settings.ShowGoToCheckout;
803        self.showExternalCheckout = settings.ShowExternalCheckout;
804        self.showPriceIncExVat = settings.ShowPriceIncExVat;
805        self.showRemoveButton = settings.ShowRemoveButton;
806        self.showPriceDisplayControls = settings.ShowPriceDisplayControls;
807        self.chkShowVeilPris = settings.ShowVeilPrisValue;
808        self.chkHideCustomerPice = settings.HideCustomerPriceValue;
809        self.favoriteCartUrl = settings.FavoriteCartUrl;
810        self.offerCartUrl = settings.OfferCartUrl;
811        self.isLoggedIn(settings.IsLoggedIn);
812        self.numberOfItemsToShow(settings.SmallCartItemsToShow);
813        self.decimalsQuantity = settings.DecimalsQuantity;
814        self.popupTime = settings.PopupTime;
815        self.disableIncExVatChange = settings.DisableIncExVatChange;
816        self.smallCartFees = settings.SmallCartFees;
817        self.showIncVatCheckbox = settings.ShowIncVatCheckbox;
818      }
819
820      //If empty, try to load data with ajax
821      if (!data) {
822        self.isVisible(false);
823        var param = {
824          cartName: null,
825          useVat: self.chkPriceIncExVat(),
826          hasCarrier: false,
827          guid: getCartIdFromSessionStorage(),
828          favGuid: mcWeb.cartsmall.getFavoriteGuid(),
829          forceLoad: forceLoad
830        };
831        self.service.GetAction("LoadCart", param).then(function (result) {
832          if (result !== null) {
833            self.load(result);
834          } else self.isVisible(true);
835        });
836        return;
837      }
838      if (data.CartName !== null) self.cartName(data.CartName);
839      if (data.DisplayDate != null) self.displayDate(data.DisplayDate);
840      if (data.Orderbooks !== null) {
841        self.orderbooks(data.Orderbooks);
842        var cartView = window.StorageService.localStorage.getItem('orderbook.cartivew');
843        if (cartView === 'summary') {
844          self.doShowOrderbookSummary();
845        } else {
846          self.doShowActiveCart();
847        }
848      }
849      //todo: fiks det slik at vi viser ordrebok sammendraget når vi ikke har noen ordrebøker men vi er i ordrebok shopppen og ikke kan vise vanlig handlevogn
850      //vi har en setting vi må se på (OrderbookIncludesDefaultCart) og hvorvidt ordrebokshoppen er aktiv.
851      if ((data.Orderbooks == null || data.Orderbooks.length === 0) && data.OrderbookActive != null && data.OrderbookActive === true) {
852        self.doShowOrderbookSummary();
853        window.StorageService.localStorage.setItem('orderbook.cartivew', 'summary');
854      }
855      self.OrderbookActive(data.OrderbookActive);
856      self.OrderbookIncludesDefaultCart = data.OrderbookIncludesDefaultCart;
857      self.hasCart(data.HasCart);
858      self.itemCount(mc.format.asCulture(data.ItemCount, self.decimalsQuantity));
859      self.favoriteCount(data.FavoriteCount);
860      PubSub.publish(mcWeb.cartsmall.events.onChangeFav, self.favoriteCount());
861      self.priceTotal(data.PriceTotal);
862      self.priceTotalInkVat(data.PriceTotalInkVat);
863      self.priceTotalProducts(data.PriceTotalProducts);
864      self.priceTotalProductsInkVat(data.PriceTotalProductsInkVat);
865      self.summaryPreGiftcardsInkMva(data.SummaryPreGiftcardsInkMva);
866      self.summaryPreGiftcardsEksMva(data.SummaryPreGiftcardsEksMva);
867      self.giftcardsTotal(data.GiftcardsTotal);
868      self.giftVoucherUsedValue(data.GiftVoucherUsedValue);
869      self.giftVoucherUsedValueExVat(data.GiftVoucherUsedValueExVat);
870      self.priceTotalInkVatExShipping(data.PriceTotalInkVatExShipping);
871      self.priceTotalExVatExShipping(data.PriceTotalExVatExShipping);
872      self.priceTotalInkCarrier(data.PriceTotalInkCarrier);
873      self.priceTotalInkCarrierInkVat(data.PriceTotalInkCarrierInkVat);
874      self.vatTotal(data.VatTotal);
875      self.vatTotalInkCarrier(data.VatTotalInkCarrier);
876      self.invoiceFee(data.InvoiceFee);
877      self.invoiceFeeInkVat(data.InvoiceFeeInkVat);
878      self.invoiceFeeAndShipping(data.InvoiceFeeAndShipping);
879      self.invoiceFeeAndShippingInkVat(data.InvoiceFeeAndShippingInkVat);
880      self.offerCount(data.OfferCount);
881      if (data.SummarySumCostReductionIncVat == null) self.SummarySumCostReductionIncVat('');else self.SummarySumCostReductionIncVat(data.SummarySumCostReductionIncVat);
882      if (data.SummarySumAfterCostReductionIncVat == null) self.summarySumAfterCostReductionsIncVat('');else {
883        if (data.SummarySumAfterCostReductionIncVat == '' && data.SummarySumCostReductionIncVat == '') {
884          self.summarySumAfterCostReductionsIncVat('');
885        } else {
886          self.summarySumAfterCostReductionsIncVat(data.SummarySumAfterCostReductionIncVat);
887          self.priceTotalProductsInkVat(data.SummarySumAfterCostReductionIncVat);
888        }
889      }
890
891      //Removed in 2016 design (code is used by old design)
892      self.addToCartNotifier(data.AddToCartNotifier);
893      self.addToCartNotifierText(data.AddToCartNotifierText !== null ? data.AddToCartNotifierText : '');
894      //End removed
895
896      self.chkPriceIncExVat(data.IncVat);
897      self.isLoggedIn(data.IsLoggedIn);
898      if (data.OrderbookDate == null) self.OrderbookDate('');else self.OrderbookDate(data.OrderbookDate);
899      mcWeb.cartsmall.setFavoriteGuid(data.FavoriteGuid, self.isLoggedIn());
900      self.cartHashCode = data.CartHashCode;
901      self.guId = data.GuId;
902      if (data.ShowLeasingCosts !== null) self.showLeasingCosts(data.ShowLeasingCosts);
903      if (data.LeasingTermAmountExVat !== null) self.LeasingTermAmountExVat(data.LeasingTermAmountExVat);else self.LeasingTermAmountExVat('');
904      if (self.hasCart()) {
905        ko.utils.arrayForEach(data.CartItems, function (item) {
906          if (!ko.isObservable(item.Quantity)) item.Quantity = ko.observable(mc.format.asCulture(item.Quantity, self.decimalsQuantity));
907          if (!ko.isObservable(item.QuantityMinimum)) item.QuantityMinimum = ko.observable(item.QuantityMinimum);
908          if (!ko.isObservable(item.Price1)) item.Price1 = ko.observable(item.Price1);
909          if (!ko.isObservable(item.Price2)) item.Price2 = ko.observable(item.Price2);
910          if (!ko.isObservable(item.LinePriceAfterDiscount)) item.LinePriceAfterDiscount = ko.observable(item.LinePriceAfterDiscount);
911          if (!ko.isObservable(item.LeasingItemCost)) {
912            item.LeasingItemCost = ko.observable(item.LeasingItemCost);
913          }
914          if (!ko.isObservable(item.LeasingTotalCost)) {
915            item.LeasingTotalCost = ko.observable(item.LeasingTotalCost);
916          }
917          if (!ko.isObservable(item.CostReductionIncVat)) {
918            if (item.CostReductionIncVat == null) item.CostReductionIncVat = ko.observable('');else item.CostReductionIncVat = ko.observable(item.CostReductionIncVat);
919          }
920          if (!ko.isObservable(item.AmountAfterReductionIncVat)) {
921            if (item.AmountAfterReductionIncVat == null) item.AmountAfterReductionIncVat = ko.observable('');else item.AmountAfterReductionIncVat = ko.observable(item.AmountAfterReductionIncVat);
922          }
923        });
924      }
925      self.isVisible(true);
926      self.cartItems(data.CartItems);
927      self.isCartItemsSet(true);
928
929      //Removed in 2016 design (code is used by old design)
930      if (self.addToCartNotifier()) {
931        self.ShowNewItemInCartNotifier();
932      }
933      //End removed
934    };
935
936    var getCartIdFromSessionStorage = function getCartIdFromSessionStorage() {
937      try {
938        var guid = window.StorageService.sessionStorage.getItem('sCartId');
939        if (guid === null || guid.length < 30) return null;
940        window.StorageService.sessionStorage.removeItem('sCartId'); //reset
941        return guid;
942      } catch (e) {
943        // IOS/etc. Private Mode
944        return null;
945      }
946    };
947    self.setVat = function (incVat) {
948      var data = {
949        cartName: null,
950        useVat: incVat,
951        vatChange: true,
952        hasCarrier: false
953      };
954      self.service.GetAction("LoadCart", data).then(function (result) {
955        if (self.isCheckoutPage() || self.isCartPage()) {
956          PubSub.publish(mcWeb.cart.events.onChangedCart, result);
957        } else {
958          location.reload(true);
959        }
960      });
961    };
962    self.setVeil = function (showVeil) {
963      var data = {
964        showVeilPris: showVeil
965      };
966      self.service.GetAction("ShowVeilPris", data).then(function (result) {
967        location.reload(true);
968      });
969    };
970    self.setHideCustomerPrice = function (hideCustomerPrice) {
971      var data = {
972        hideCustomerPrice: hideCustomerPrice
973      };
974      self.service.GetAction("HideCustomerPrice", data).then(function (result) {
975        location.reload(true);
976      });
977    };
978    this.onClose = function () {
979      if (self.popoverNode !== null) {
980        self.popoverNode.popover('hide');
981        self.popoverOpen(false);
982      }
983    };
984    this.onClickRemove = function (product) {
985      self.updateQuantity(product, 0);
986    };
987    this.updateQuantity = function (product, newQuantity) {
988      var data = {
989        plid: product.ProductId,
990        quantity: newQuantity,
991        cartName: null
992      };
993      self.service.GetAction("UpdateCartItem", data).then(function (result) {
994        if (result === null) {
995          PubSub.publish(mcWeb.cartsmall.events.onCartItemRemoved);
996          return;
997        }
998        PubSub.publish(mcWeb.events.freeShippingTxt.onUpdateFreeShipping);
999        var pubObject = new Object();
1000        pubObject.result = result;
1001        pubObject.newQuantity = newQuantity;
1002        pubObject.ProductId = product.ProductId;
1003        self.resultQuantity(result, product, newQuantity);
1004        PubSub.publish(mcWeb.cartsmall.events.onChangedQuantityCartSmall, pubObject);
1005      });
1006    };
1007    this.resultQuantity = function (result, product, newQuantity) {
1008      self.hasCart(result.HasCart);
1009      self.itemCount(mc.format.asCulture(result.ItemCount, self.decimalsQuantity));
1010      self.favoriteCount(result.FavoriteCount);
1011      PubSub.publish(mcWeb.cartsmall.events.onChangeFav, self.favoriteCount());
1012      if (result.PriceTotal) {
1013        self.priceTotal(result.PriceTotal);
1014        self.priceTotalInkVat(result.PriceTotalInkVat);
1015        self.priceTotalProducts(result.PriceTotalExVatExShipping);
1016        self.priceTotalProductsInkVat(result.PriceTotalInkVatExShipping);
1017        self.priceTotalInkCarrier(result.PriceTotalInkCarrier);
1018        self.priceTotalInkCarrierInkVat(result.PriceTotalInkCarrierInkVat);
1019        self.priceTotalInkVatExShipping(result.PriceTotalInkVatExShipping);
1020        self.priceTotalExVatExShipping(result.PriceTotalExVatExShipping);
1021        self.giftVoucherUsedValue(result.GiftVoucherUsedValue);
1022        self.giftVoucherUsedValueExVat(result.GiftVoucherUsedValueExVat);
1023      }
1024      if (result.VatTotal) {
1025        self.vatTotal(result.VatTotal);
1026        self.vatTotalInkCarrier(result.VatTotalInkCarrier);
1027      }
1028      if (result.ShowLeasingCosts !== null) self.showLeasingCosts(result.ShowLeasingCosts);
1029      if (result.LeasingTermAmountExVat !== null) self.LeasingTermAmountExVat(result.LeasingTermAmountExVat);else self.LeasingTermAmountExVat('');
1030      if (!self.hasCart()) {
1031        if (self.popoverNode !== null) {
1032          self.popoverNode.popover('hide');
1033          self.popoverOpen(false);
1034        }
1035        self.cartItems.removeAll();
1036        PubSub.publish(mcWeb.cart.events.hasCartItems, self.hasCart());
1037      } else if (result.CartItems === null || result.CartItems.length < 1) {
1038        self.cartItems.remove(product);
1039      } else {
1040        if (result.CartItems !== null) {
1041          product.Quantity(result.CartItems[0].Quantity);
1042          product.Price1(result.CartItems[0].Price1);
1043          product.Price2(result.CartItems[0].Price2);
1044          product.LinePriceAfterDiscount(result.CartItems[0].LinePriceAfterDiscount);
1045        }
1046      }
1047      if (document.activeElement) document.activeElement.blur();
1048      if (result.RequireFullRefresh) {
1049        PubSub.publish(mcWeb.cart.events.onChangedCart);
1050        if (mcWeb.ajaxRenderEngine != undefined) PubSub.publish(mcWeb.ajaxRenderEngine.events.onPriceRefreshRequested, null);else location.reload(true);
1051      } else if (jQuery("body.login-type-Mport").length > 0) {
1052        if (mcWeb.ajaxRenderEngine != undefined) PubSub.publish(mcWeb.ajaxRenderEngine.events.onPriceRefreshRequested, null);
1053      }
1054    };
1055    this.onClickVat = function () {
1056      self.setVat(self.chkPriceIncExVat());
1057      return true; //Need this on Checkbox
1058    };
1059
1060    this.onClickVeil = function () {
1061      self.setVeil(self.chkShowVeilPris);
1062      return true; //Need this on Checkbox
1063    };
1064
1065    this.onClickHideCustomerPrice = function () {
1066      self.setHideCustomerPrice(self.chkHideCustomerPice);
1067      return true; //Need this on Checkbox
1068    };
1069
1070    this.onClickProductLink = function (product) {
1071      window.location.href = product.ProductLink;
1072    };
1073    this.onClickGoToCart = function () {
1074      try {
1075        self.updateIcon(true);
1076        self.service.GetAction("GoToCart", "").then(function (result) {
1077          self.updateIcon(false);
1078          if (result === null) return;
1079          window.location.href = result; //"http://" + location.hostname;			
1080        });
1081      } catch (e) {
1082        self.updateIcon(false);
1083      }
1084    };
1085    this.onSelectCart = function (item) {
1086      self.onSelectCartByName(item.Name);
1087    };
1088    this.onSelectCartByName = function (name) {
1089      var data = {
1090        ActiveCartName: name
1091      };
1092      self.service.PostAction("SetActiveCartName", data).then(function (result) {
1093        PubSub.publish(mcWeb.cart.events.onChangedCart, null);
1094      });
1095    };
1096    this.onGoToCart = function () {
1097      //not yet tested!
1098      try {
1099        var data = {
1100          cartName: self.cartName()
1101        };
1102        self.updateIcon(true);
1103        self.service.GetAction("GoToCart", data).then(function (result) {
1104          self.updateIcon(false);
1105          if (result === null) return;
1106          if (window.location.pathname !== result) window.location.href = result; //"http://" + location.hostname;			
1107        });
1108      } catch (e) {
1109        self.updateIcon(false);
1110      }
1111    };
1112    this.onClickGoToCheckout = function () {
1113      try {
1114        var data = {
1115          cartName: self.cartName,
1116          source: 'standard'
1117        };
1118        self.updateIcon(true);
1119        var action = "GoToCheckOut";
1120        self.service.GetAction(action, data).then(function (result) {
1121          self.updateIcon(false);
1122          if (result === null) return;
1123          window.location.href = result; //"http://" + location.hostname;			
1124        });
1125      } catch (e) {
1126        self.updateIcon(false);
1127      }
1128    };
1129    self.getContent = function () {
1130      return "<div id='" + self.conId + self.kn + "'>" + $('#' + self.conId).html() + "</div>";
1131    };
1132    ko.bindingHandlers.popover = {
1133      init: function init(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
1134        var node = $(element);
1135        self.popoverNode = node;
1136        var option = ko.utils.unwrapObservable(valueAccessor());
1137        var conId = option.contentid,
1138          titId = option.titleid,
1139          kn = "-kn";
1140        self.conId = conId;
1141        self.kn = kn;
1142        var contentkn = "<div id='" + conId + kn + "'>" + $('#' + conId).html() + "</div>";
1143        var titlekn = "<div id='" + titId + kn + "'>" + $('#' + titId).html() + "</div>";
1144        this.togglePopover = function () {
1145          node.popover('toggle');
1146          if (mcWeb.MegaMenuResponsive !== undefined) {
1147            mcWeb.MegaMenuResponsive.setOverlay(false);
1148          }
1149          var conEl = document.getElementById(conId + kn);
1150          var titEl = document.getElementById(titId + kn);
1151          if (conEl !== undefined && conEl !== null) ko.cleanNode(conEl);
1152          ko.cleanNode(titEl);
1153          ko.applyBindings(viewModel, conEl);
1154          ko.applyBindings(viewModel, titEl);
1155        };
1156        var pop = node.popover({
1157          title: titlekn,
1158          content: self.getContent,
1159          html: option.html,
1160          trigger: 'manual',
1161          sanitize: false,
1162          //container: 'body', // Using this duplicates nodes in DOM. Not ideal.
1163          placement: function placement(context) {
1164            var con = jQuery(context);
1165            con.addClass(option.contentClass);
1166            var module = $('body.mc-inline-editor');
1167            if (module.length > 0) return 'bottom';
1168            con.on('mouseleave', function () {
1169              node.popover('hide');
1170              self.popoverOpen(false);
1171              return true;
1172            });
1173            return 'bottom';
1174          }
1175        });
1176        self.mouseleaveCartSmall = function (event) {
1177          if (!$(event.target).closest('.cart-small-popover').length) {
1178            if (pop.is(":visible")) {
1179              node.popover('hide');
1180              self.popoverOpen(false);
1181              event.stopPropagation();
1182              return false;
1183            }
1184          }
1185          return true;
1186        };
1187        pop.on('shown.bs.popover', function () {
1188          $(document).bind('click touchstart', self.mouseleaveCartSmall);
1189        });
1190        pop.on('hide.bs.popover', function () {
1191          $(document).unbind('click touchstart', self.mouseleaveCartSmall);
1192        });
1193        node.click(function () {
1194          if (mcWeb.responsive.getScreenSize() === 'xs') {
1195            //self.onClickGoToCart();
1196            self.onClickGoToCheckout();
1197            return;
1198          }
1199          if (self.showOrderbookSummary()) {
1200            self.doShowOrderbookSummary();
1201          }
1202          togglePopover();
1203          self.popoverOpen(!self.popoverOpen());
1204          if (mcWeb.inlineEditor) mcWeb.inlineEditor.init(true);
1205        });
1206      }
1207    };
1208    this.updateIcon = function (show) {
1209      var update = $('#UpdateIcon');
1210      if (update.length < 1) return;
1211      if (show) update.show();else update.hide();
1212    };
1213    this.showSmallCartAmount = function () {
1214      if (!self.isCheckoutPage() && mcWeb.responsive.isMedium()) {
1215        $(".cart-small-product-txt").show();
1216      }
1217    };
1218    this.isCheckoutPage = function () {
1219      return $(".body-checkout").length > 0 ? true : false;
1220    };
1221    this.isCartPage = function () {
1222      return $(".body-cart").length > 0 ? true : false;
1223    };
1224    this.ShowNewItemInCartNotifier = function () {
1225      var panel = $('.cart-popup-panel');
1226      if (panel.length > 0 && !self.addToCartNotifierIsActive()) {
1227        $('body').append(panel);
1228        self.addToCartNotifierIsActive(true);
1229        panel.fadeIn(500);
1230        panel.delay(1500);
1231        panel.fadeOut(1000);
1232        self.service.GetAction("HasShownAddToCartNotifier").then(function () {
1233          self.addToCartNotifierIsActive(false);
1234        });
1235      }
1236    };
1237    this.switchToLeasing = function () {
1238      self.service.GetAction("SwitchToLeasing").then(function (result) {
1239        if (result) PubSub.publish(mcWeb.cartsmall.events.onUpdateCart, null);
1240      });
1241    };
1242    this.switchToPayNow = function () {
1243      self.service.GetAction("SwitchToPayNow").then(function (result) {
1244        if (result) PubSub.publish(mcWeb.cartsmall.events.onUpdateCart, null);
1245      });
1246    };
1247    PubSub.subscribe(mcWeb.login.events.onIsloggedIn, function (message, isLoggedIn) {
1248      self.isLoggedIn(isLoggedIn);
1249    });
1250
1251    /// Data = {status: true/false, msg: 'Ny vare...'}
1252    PubSub.subscribe(mcWeb.cartsmall.events.onShowNewItemInCartText, function (message, data) {
1253      self.popupMsgWait.hide();
1254      self.popupMsgText.show();
1255      if (data.status === true) {
1256        self.popupMsgSuccess.show();
1257      } else {
1258        self.popupMsg.addClass("notifier-error");
1259        self.popupMsgError.show();
1260      }
1261      self.popupMsgText.html(data.msg);
1262      self.popupMsg.fadeIn();
1263      if (data.popupTime !== undefined && data.popupTime !== null) {
1264        self.popupTime = data.popupTime;
1265      }
1266      setTimeout(function () {
1267        PubSub.publish(mcWeb.cartsmall.events.onHideNewItemInCart);
1268      }, self.popupTime);
1269    });
1270    var isRunningPop = false;
1271    PubSub.subscribe(mcWeb.cartsmall.events.onShowNewItemInCart, function (message) {
1272      if (isRunningPop === true) {
1273        return;
1274      }
1275      isRunningPop = true;
1276      self.popupMsgText.hide();
1277      self.popupMsgWait.show();
1278      self.popupMsg.fadeIn();
1279      //IMPORTAN - Use "mcWeb.cartsmall.events.onShowNewItemInCartText" after this!
1280    });
1281
1282    PubSub.subscribe(mcWeb.cartsmall.events.onHideNewItemInCart, function () {
1283      var popupTime = mc.format.asNumber(self.popupTime, 1, 1000);
1284      var dif = mc.format.asNumber(0.3, 2, 0.3);
1285      var value = popupTime * dif;
1286      var time = mc.format.asNumber(value, 1, 1000);
1287      self.popupMsg.fadeOut(time, function () {
1288        self.popupMsgSuccess.hide();
1289        self.popupMsgError.hide();
1290        self.popupMsg.removeClass("notifier-error");
1291      });
1292      isRunningPop = false;
1293    });
1294    PubSub.subscribe(mcWeb.cartsmall.events.onGotoSelectedCart, function (message, name) {
1295      self.onSelectCartByName(name);
1296      self.onGoToCart();
1297    });
1298  };
1299  this.setFavoriteGuid = function (favoriteGuid, isLoggedIn) {
1300    try {
1301      if (favoriteGuid === null || favoriteGuid.length < 30) {
1302        window.StorageService.localStorage.removeItem('sFavCartId');
1303      } else {
1304        var sFavCartId = isLoggedIn ? favoriteGuid + ";l" : favoriteGuid;
1305        window.StorageService.localStorage.setItem('sFavCartId', sFavCartId);
1306      }
1307    } catch (e) {
1308      // IOS/etc. Private Mode
1309      console.log('CartSmallView.setFavoriteGuid - ex: ' + e);
1310    }
1311  };
1312  this.getFavoriteGuid = function () {
1313    try {
1314      var sFavCartId = window.StorageService.localStorage.getItem('sFavCartId');
1315      if (sFavCartId === null || sFavCartId.length < 30) return null;
1316      window.StorageService.localStorage.removeItem('sFavCartId'); //reset
1317      return sFavCartId;
1318    } catch (e) {
1319      // IOS/etc. Private Mode
1320      console.log('CartSmallView.getFavoriteGuid - ex: ' + e);
1321    }
1322    return null;
1323  };
1324}());
1325
1326/***/ })
1327
1328},
1329/******/ function(__webpack_require__) { // webpackRuntimeModules
1330/******/ var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); }
1331/******/ __webpack_require__.O(0, [313], function() { return __webpack_exec__(6132), __webpack_exec__(6570), __webpack_exec__(5477), __webpack_exec__(3526), __webpack_exec__(6330), __webpack_exec__(9477), __webpack_exec__(6872); });
1332/******/ var __webpack_exports__ = __webpack_require__.O();
1333/******/ }
1334]);
1335//# sourceMappingURL=main.9614a246623044d548c8.js.map

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.