PageSourceSearch

https://mediq.ee/-/media/Base-Themes/Commerce-Components-Theme/Scripts/Cart/cart-promotion.js

js mediq.ee collected 2026-10-08 08:24:42 UTC 2,707 bytes, 70 lines download raw bytes

1// -----------------------------------------------------------------------
2// Copyright 2016 Sitecore Corporation A/S
3// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
4// except in compliance with the License. You may obtain a copy of the License at
5//       http://www.apache.org/licenses/LICENSE-2.0
6//
7// Unless required by applicable law or agreed to in writing, software distributed under the
8// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
9// either express or implied. See the License for the specific language governing permissions
10// and limitations under the License.
11// -------------------------------------------------------------------------------------------
12
13(function (root, factory) {
14  if (typeof define === "function" && define.amd) {
15    // use AMD define funtion to support AMD modules if in use
16    define("CXA/Feature/CartPromotion", ["exports"], factory);
17  } else if (typeof exports === "object") {
18    // to support CommonJS
19    factory(exports);
20  }
21  // browser global variable
22  root.CartPromotion = factory;
23}(this, function (element) {
24  "use strict";
25
26  var component = new Component(element);
27  component.Name = "CXA/Feature/CartPromotion";
28  component.InExperienceEditorMode = function () {
29  };
30
31  component.OnCartUpdated = function (data) {
32    $(component.RootElement).find(".glyphicon")
33      .removeClass("glyphicon-refresh");
34    $(component.RootElement).find(".glyphicon")
35      .removeClass("glyphicon-refresh-animate");
36
37    $(component.RootElement).find(".glyphicon")
38      .removeClass("glyphicon-remove-circle");
39    $(component.RootElement).find(".glyphicon")
40      .addClass("glyphicon-remove-circle");
41
42    AjaxService.Post("/api/cxa/Cart/GetPromoCodes", {}, function (data, success, sender) {
43      if (success && data && data.Success) {
44        component.model.updateModel(data);
45
46        let cartLinesCount = data.Lines ? data.Lines.length : 0;
47        CartContext.UpdateCachedCartCount(cartLinesCount);
48      }
49    });
50  };
51
52  component.StartListening = function () {
53    CartContext.SubscribeHandler(CartContext.CartEvents.CartUpdate, component.OnCartUpdated);
54  };
55
56  component.Init = function () {
57    component.StartListening();
58    AjaxService.Post("/api/cxa/Cart/GetPromoCodes", {}, function (data, success, sender) {
59      if (success && data && data.Success) {
60        component.model = new CartPromotionViewModel(data);
61        ko.applyBindings(component.model, component.RootElement);
62
63        let cartLinesCount = data.Lines ? data.Lines.length : 0;
64        CartContext.UpdateCachedCartCount(cartLinesCount);
65      }
66    });
67  };
68
69  return component;
70}));

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.