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/CartTotal", ["exports"], factory); 17 } else if (typeof exports === "object") { 18 // to support CommonJS 19 factory(exports); 20 } 21 // browser global variable 22 root.CartTotal = factory; 23}(this, function (element) { 24 "use strict"; 25 26 var component = new Component(element); 27 component.Name = "CXA/Feature/CartTotal"; 28 29 component.InExperienceEditorMode = function () { 30 }; 31 32 var _GetMockData = function () { 33 var mockData = { 34 "Lines": [], 35 "Email": "", 36 "Subtotal": "0.00 USD", 37 "TaxTotal": "0.00 USD", 38 "Total": "0.00 USD", 39 "ShippingTotal": "0.00 USD", 40 "TotalAmount": 0, 41 "Shipments": [], 42 "Payments": [], 43 "Parties": [], 44 "AccountingParty": null, 45 "Discount": "0.00 USD", 46 "PromoCodes": [], 47 "Errors": [], 48 "Info": [], 49 "Warnings": [], 50 "HasErrors": false, 51 "HasInfo": false, 52 "HasWarnings": false, 53 "Success": true, 54 "Url": null, 55 "ContentEncoding": null, 56 "ContentType": null, 57 "Data": null, 58 "JsonRequestBehavior": 1, 59 "MaxJsonLength": null, 60 "RecursionLimit": null 61 }; 62 63 return mockData; 64 }; 65 66 component.OnCartUpdated = function (data) { 67 if (data && data.Lines) { 68 component.model.updateModel(data); 69 } else { 70 AjaxService.Post("/api/cxa/MediqCart/MediqGetCart", {}, function (data, success, sender) { 71 if (success && data && data.Success) { 72 component.model.updateModel(data); 73 } 74 }); 75 } 76 }; 77 78 component.StartListening = function () { 79 CartContext.SubscribeHandler(CartContext.CartEvents.CartUpdate, component.OnCartUpdated); 80 }; 81 82 component.Init = function () { 83 if (CXAApplication.IsExperienceEditorMode()) { 84 var mockData = _GetMockData(); 85 component.model = new CartTotalViewModel(mockData); 86 ko.applyBindings(component.model, component.RootElement); 87 } else { 88 component.StartListening(); 89 90 var isShoppingCart = 'false'; 91 if ($('.cxa-shoppingcarttotal-component').length > 0 && $('.cxa-shoppingcarttotal-component').attr('data-component-shoppingCartPage') == "true") { 92 isShoppingCart = 'true'; 93 } 94 95 AjaxService.Post("/api/cxa/MediqCart/MediqGetCart", { isShoppingCart: isShoppingCart}, function (data, success, sender) { 96 if (success && data && data.Success) { 97 component.model = new CartTotalViewModel(data); 98 ko.cleanNode(element); 99 ko.applyBindings(component.model, component.RootElement); 100 } 101 }); 102 } 103 }; 104 105 return component; 106}));
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.