/* Minification failed. Returning unminified contents. (12460,212-213): run-time error JS1010: Expected identifier: . (12460,212-213): run-time error JS1195: Expected expression: . */ angular.module('customFilters', []) .filter('strikeThroughIfDiscounted', function () { return function (input, discountedAmount) { if (discountedAmount.FinalAmount === 0) { return input; } else { if (discountedAmount.FinalAmount < discountedAmount.RegularAmount) { return '' + discountedAmount.FormattedRegularAmount + ' ' + discountedAmount.FormattedFinalAmount; } else { return discountedAmount.FormattedFinalAmount; } } }; }) .filter('strikeThroughIfDiscountedForDaMembers', function() { return function(input, discountedAmount) { if (discountedAmount.FinalAmount === 0 && discountedAmount.ShowStrikethroughForDaMembers) { return discountedAmount.Description + ' - ' + discountedAmount.FormattedRegularAmount + ' ' + discountedAmount.FormattedFinalAmount; }; return input; } }) .filter('removeWhiteSpace', function () { return function (input) { if (input) { return input.replace(/[\s]/g, ''); } } }); angular.module("customDirectives", []) .filter('allowassafehtml', ['$sce', function ($sce) { return $sce.trustAsHtml; }]) .directive("alertBox", function () { return { restrict: 'E', template: '
{{ item.Title }}

{{ item.SubTitle }}

{{item.Message }}

{{item.HelpLinkTitle}} {{item.HelpLinkTitle}}
' }; }) .directive('ngCopyToClipboard', function () { return { restrict: 'A', scope: { text: "=", beforecopytooltiptext: "@", }, template: '
{{ beforecopytooltiptext }}
', link: function (scope, elem, attrs) { elem.click(function () { if (attrs.ngCopyToClipboard) { var $temp_input = $(""); $("body").append($temp_input); $temp_input.val(attrs.ngCopyToClipboard).select(); var successful = document.execCommand("copy"); var barcodespan = $("#barcodespan")[0]; var msg = successful ? barcodespan.getAttribute('aftercopytooltiptext-success') : barcodespan.getAttribute('aftercopytooltiptext-failed'); var tooltip = $("#barcodetooltip")[0]; tooltip.innerHTML = msg; $temp_input.remove(); $('a').mouseout(function () { tooltip.innerHTML = barcodespan.getAttribute('beforecopytooltiptext'); }); } }); } }; }) .directive("daRewards", ["advantageFactory", "applyRemainingBalanceService", function (advantageFactory, applyRemainingBalanceService) { var controller = [ '$scope', '$cookies', function ($scope, $cookies) { var lwp = Dell.Transactional.buildLightweightProfile(); $scope.AmountCannotExceedYourRewards = false; $scope.NoRewardsAvailable = false; $scope.RewardsException = false; $scope.rewardsAlertType = ""; $scope.showRewardsAlertMessage = false; $scope.rewardsAlertFired = false; $scope.rewardsRequest = { "ProfileId": $cookies.profile !== undefined ? $cookies.profile : $cookies.Profile, "Country": lwp.c, "Language": lwp.l, "Segment": lwp.s, "CustomerSet": lwp.cs, "Region": lwp.r, "IncludeProductMessaging": false, "IncludeProductGroupMessaging": false, "RewardsAccountSettings": { "IncludeAccountNumberAndPin": true, "IncludeAccountBalance": true, "IncludeRedeemableBalance": true, "IncludeExpiringBalance": true, "IncludePendingBalance": false, "IncludeRewardsHistory": false, "BypassCache": true, "OrderTotal": $scope.orderTotalAmount }, "CurrencyFormattingCultureName": lwp.l + '-' + lwp.c.toUpperCase(), "RewardsAccountMessages": [ { "Library": "Responsive_Messaging", "Key": "dell_advantage_rewards_account_balance_messaging" }, { "Library": "Responsive_Messaging", "Key": "dell_advantage_rewards_account_expiring_balance_messaging" } ] }; $scope.formatRewards = function (amount) { if (!amount) return ""; return applyRemainingBalanceService.convertToCulturedPriceString(amount, $scope.currencyFormatSettings.decimal); }; // Replaces token with price from CMS $scope.parseAppliedRewards = function () { var youAppliedRewardsLabel = ""; if ($scope.rewardsViewModel && $scope.rewardsViewModel.YouAppliedRewardsLabel) { var formattedRewardsAppliedAmount = $scope.formatRewards($scope.rewardsAmountApplied); youAppliedRewardsLabel = $scope.rewardsViewModel.YouAppliedRewardsLabel.replace(/\${1:\w*}/i, $scope.currencySymbolLabel + formattedRewardsAppliedAmount); } return youAppliedRewardsLabel; }; // Closes the warning message $scope.removeRewardsAlertMessage = function (e) { $scope.AmountCannotExceedYourRewards = false; $scope.rewardsAlertType = ""; $scope.showRewardsAlertMessage = false; }; $scope.removeInfoAlertMessage = function () { $scope.showRewardsAppliedMessage = true; }; function showDaAlert(alertType) { $scope.NoRewardsAvailable = false; $scope.RewardsException = false; $scope.rewardsAlertFired = true; var showInAlert = true; switch (alertType) { case "NoRewardsAvailable": $scope.NoRewardsAvailable = true; showInAlert = false; break; case "RewardsException": $scope.RewardsException = true; break; default: $scope.RewardsException = true; } if (showInAlert) { $scope.rewardsAlertType = ""; $scope.showRewardsValidationMessage = false; $scope.showRewardsAlertMessage = true; } } function rewardsInit(response) { //console.info(response); if (!response || !response.RewardsAccount || response.RewardsAccount === null || !response.RewardsAccount.IsValid || !response.RewardsAccount.RewardsAccountMessages || response.RewardsAccount.RewardsAccountMessages.length === 0) { console.log("DaRewards request is malformed"); showDaAlert("RewardsException"); return; } // Message if account balance is 0 or negative if (response.RewardsAccount.AccountBalance <= 0) { showDaAlert("NoRewardsAvailable"); return; } var rewardsObj = response.RewardsAccount, accountMessages = rewardsObj.RewardsAccountMessages; // Text output // In case we can't count on the order of the messages, verify by key. for (var i = 0; i < accountMessages.length; i++) { for (var k in accountMessages[i]) { if (accountMessages[i].hasOwnProperty(k)) { if (k === "Key" && accountMessages[i][k] === "dell_advantage_rewards_account_balance_messaging") { $scope.availableRewards = accountMessages[i].Value; } if (k === "Key" && accountMessages[i][k] === "dell_advantage_rewards_account_expiring_balance_messaging") { $scope.expiringBalance = accountMessages[i].Value; } } } } if ($scope.rewardsPayment) { $scope.rewardsAvailableBalance = rewardsObj.RedeemableBalance; $scope.rewardsPayment.Amount = rewardsObj.RedeemableBalance; $scope.redeemableRate = rewardsObj.RedeemableRate; if ($scope.isRewardsApplied) { $scope.rewardsPayment.Amount = $scope.rewardsAmountApplied; } $scope.rewardsPayment.CardNumber = rewardsObj.AccountNumber; $scope.rewardsPayment.CardIdentificationNumber = rewardsObj.AccountPin; $scope.rewardsAmountFormatted = applyRemainingBalanceService.convertToCulturedPriceString($scope.rewardsPayment.Amount.toFixed($scope.currencyFormatSettings.precision), $scope.currencyFormatSettings.decimal); $scope.rewardsPayment.EpsilonId = response.RewardsAccount.EpsilonId; $scope.rewardsPayment.FormattedMaxLimit = applyRemainingBalanceService.convertToCulturedPriceString(rewardsObj.AccountBalance, $scope.currencyFormatSettings.decimal); } $scope.disableDFSRewards(); } if ($scope.canApplyDaReward()) { var daRewardsElement = $("da-rewards"); if ($scope.isRewardsApplied) { daRewardsElement.removeClass("stp-loading").addClass("stp-loaded"); } advantageFactory.getProgram($scope.rewardsRequest) .then(function (response) { daRewardsElement.removeClass("stp-loading").addClass("stp-loaded"); // console.info(response); rewardsInit(response); }, function (errorMessage) { console.log("Advantage Factory has an error:", errorMessage); showDaAlert("RewardsException"); }); } } ]; return { restrict: 'E', template: '

{{rewardsViewModel.RewardsTitleLabel}}

{{rewardsViewModel.ChangeLabel}}

{{rewardsValidationMessage}} {{rewardsViewModel.RewardsExceptionMessage}}

{{rewardsViewModel.RewardsNoAvailableMessage}}

{{rewardsViewModel.LoadingLabel}}
{{availableRewards}} {{expiringBalance}}

{{parseAppliedRewards()}}

{{currencySymbolLabel}} {{currencySymbolLabel}}

{{rewardsViewModel.AdditionalRewardsAvailableLabel}}

{{cannotApplyRewardsMessage}}

{{rewardsViewModel.NoAdditionalPymntLabel}}

', controller: controller, link: function (scope, element, attrs) { if (attrs.showCurrencyToLeft) { scope.showCurrencySymbolToLeft = (attrs.showCurrencyToLeft === "true") ? true : false; } else { scope.showCurrencySymbolToLeft = true; } if (attrs.currencySymbol) { scope.currencySymbolLabel = attrs.currencySymbol; } function validateRewards() { scope.rewardsValidationMessage = ""; scope.showRewardsAlertMessage = false; scope.showRewardsValidationMessage = true; if (scope.rewardsPayment.Amount > scope.rewardsAvailableBalance) { scope.rewardsValidationMessage = scope.rewardsViewModel.AmountCannotExceedYourRewardsLabel; } else if (scope.rewardsPayment.Amount <= 0) { scope.rewardsValidationMessage = scope.rewardsViewModel.RewardsAppliedCannotBeZeroOrLessLabel; } else { scope.showRewardsValidationMessage = false; } if (scope.showRewardsValidationMessage) { scope.rewardsAlertType = ""; scope.showRewardsAlertMessage = true; return false; } return true; } var applyBtn = element.find("#applyRewards"); applyBtn.on("click", function (e) { e.preventDefault(); var decimalSymbol = scope.currencyFormatSettings['decimal']; (function () { //dell metrics. var usedRewards = parseInt(applyRemainingBalanceService.convertToDecimalPrice(scope.rewardsAmountFormatted, decimalSymbol)), totalRewards = parseInt(scope.rewardsAvailableBalance); // For metrics if (usedRewards > 0) { scope.continueDellMetricsJson['btnname'] = 'rewardapplied'; scope.continueDellMetricsJson['totalrewardapplied'] = (usedRewards === totalRewards) ? 'true' : ''; } })(); var rewardsAmountAs2PlaceDecimal = applyRemainingBalanceService.convertToDecimalPrice(scope.rewardsAmountFormatted, decimalSymbol, scope.currencyFormatSettings['precision']); scope.rewardsAmountFormatted = applyRemainingBalanceService.convertToCulturedPriceString(rewardsAmountAs2PlaceDecimal, decimalSymbol); scope.applyRewards(rewardsAmountAs2PlaceDecimal, validateRewards); }); scope.$watch('isRewardsApplied', function (newValue, oldValue) { if (newValue === true) { scope.showRewardsAppliedMessage = true; if (scope.rewardsAmountApplied < scope.rewardsAvailableBalance) { scope.showRewardsAppliedMessage = false; } } scope.showInput = !newValue; scope.canApplyRewards = !newValue; if (newValue === false && scope.DataModel.AppliedPayments.length === scope.DataModel.NumberOfAllowedPayments) { scope.canApplyRewards = false; scope.cannotApplyRewardsMessage = scope.rewardsViewModel.RewardsCannotApplyBeyondAllowedSplitLabel; } }); scope.$watch('rewardsAmountFormatted', function (newValue, oldValue) { var arr = String(newValue).split(""); var decValue = scope.currencyFormatSettings.decimal; if (!newValue || arr.length === 0 || (arr.length === 1 && arr[0] === decValue)) return; var newRewardsAmount = applyRemainingBalanceService.convertToDecimalPrice(newValue, scope.currencyFormatSettings.decimal); if (isNaN(newRewardsAmount)) { scope.rewardsAmountFormatted = oldValue; } }); } }; } ]) .directive("groupAlerts", function () { return { restrict: 'E', template: '
{{ alert.Title }}

{{ alert.SubTitle }}

  • {{message.Message}}
' }; }) .directive("showHideSpecs", ["contentsService", "featureService", function (contentsService, featureService) { return { restrict: 'E', template: ' | {{CartCompareButtonTitle}} ', link: function (scope, element, attrs) { var trigger = element.find(".stp-show-spec-trigger"), dropdownWrap = element.find(".stp-drop-down-wrap"), slider = element.find(".stp-drop-down-slider"); scope.specsCollection = []; // If specs are rendered at runtime (IOW it's not dynamically set on click) if (attrs.hasOwnProperty("specs") && scope.specs !== "" && scope.specsAreDynamic !== "true") { scope.specsCollection = JSON.parse(attrs.specs); } trigger.on("click", function () { // If specs are dyanmically set make service call if (attrs.specsAreDynamic === "true" && slider.text().trim().length === 0) { contentsService.GetSpecsForItem(attrs.itemId).then(function (response) { scope.specsCollection = response.data; // Give angular time to fill the ng-if (needed for the height animation) setTimeout(function () { triggerDropdown(); }, 200); }); } else { triggerDropdown(); } var btoEolFeatureTrackingEnabled = featureService.IsEnabled("EnableBtoEolFeatureTracking"); if (attrs && attrs.btoEolSpecs && attrs.btoEolSpecs === "true") { if (typeof _detector !== "undefined"){ _detector.triggerCustomEvent("viewbtoeolfullspecs", "CartPage"); } if (btoEolFeatureTrackingEnabled) { if (typeof dellmetrics_trackvalue !== 'undefined') { dellmetrics_trackvalue("viewbtoeolfullspecs"); } } } else { if (btoEolFeatureTrackingEnabled) { if (typeof dellmetrics_trackvalue !== 'undefined') { dellmetrics_trackvalue("viewfullspecs"); } } } }); // Handles the animation and toggling state of dropdown function triggerDropdown() { // Give dropdown wrap height for animation dropdownWrap.height(slider.outerHeight()); // Dropdown is expanded if (element.hasClass("stp-expand")) { element.removeClass("stp-expand"); dropdownWrap.addClass("stp-zero-height"); } else { // Dropdown is closed element.addClass("stp-expand"); dropdownWrap.removeClass("stp-zero-height"); } } } }; }]) .directive("showHideLongDescription", ["contentsService", function (contentsService) { return { restrict: 'E', template: ' ', link: function (scope, element, attrs) { var trigger = element.find(".stp-show-spec-trigger"), dropdownWrap = element.find(".stp-drop-down-wrap"), slider = element.find(".stp-drop-down-slider"); trigger.on("click", function () { // If specs are dyanmically set make service call collapseandexpandPanel(); }); collapseandexpandPanel(); function collapseandexpandPanel() { if (slider.text().trim().length === 0) { slider.text(attrs.description); setTimeout(function () { triggerDropdown(); }, 200); } else { triggerDropdown(); } } // Handles the animation and toggling state of dropdown function triggerDropdown() { // Give dropdown wrap height for animation dropdownWrap.height(slider.outerHeight()); // Dropdown is expanded if (element.hasClass("stp-expand")) { element.removeClass("stp-expand"); dropdownWrap.addClass("stp-zero-height"); } else { // Dropdown is closed element.addClass("stp-expand"); dropdownWrap.removeClass("stp-zero-height"); } } } }; }]) .directive("savedForLaterList", function () { return { restrict: 'E', template: '

{{netViewModel.CartItem.SavedItemsListTitle}} ()

{{netViewModel.CartItem.BundledTitleLabel}} {{item.Description}}
{{netViewModel.CartItem.ItemQuantityLabel}} {{item.QuantityWithSubItems}} {{item.Quantity}}
{{item.TotalAmountWithSubItems}} {{item.TotalAmount}} {{item.UnitPriceAmount}}

{{netViewModel.CartItem.SupportNoCostEMITitle}}

{{netViewModel.CartItem.SupportNoCostEMIDescription}}

{{subscription.SkuDescription}} - {{subscription.SkuPrice}}/{{subscription.Cadence}} {{netViewModel.CartItem.WarrantySubscriptionShowPerSubscription}}

{{subscription.ItemWarrantySubscriptionInfo}}

{{netViewModel.CartItem.SupportNoCostEMITitle}}

{{netViewModel.CartItem.SupportNoCostEMIDescription}}

{{netViewModel.CartItem.ShowMoreSavedItemsLabel}} {{netViewModel.CartItem.ShowLessSavedItemsLabel}} ' }; }) .directive("removedCartItems", ["featureService", function (featureService) { return { restrict: 'E', template: '

  • {{stopSellSkuDescriptions}}
{{item.Description}}
{{netViewModel.CartItem.ItemTotalLabel}}
{{item.SubTotalAmount}}
', scope: { removedItems: '=', allowSaveForLater: '=', netViewModel: '=', saveForLaterClick: '=', configureBtoEolItemClick: '=' }, link: function (scope, element, attrs) { var rcItem = $(element), deleteBtn = rcItem.find(".stp-remove-deleted-item"); if (attrs) { scope.isCartRecommendation = attrs.type === "persistentcart"; } scope.EnableNewEolCartPageDesign = featureService.IsEnabled("EnableNewEolCartPageDesign"); scope.ShowAlternateProductImage = featureService.IsEnabled("ShowAlternateProductImage"); rcItem.on("click", ".stp-remove-deleted-item", function (e) { e.preventDefault(); rcItem.remove(); }); } }; }]) .directive("ngFloatingDiv", ["$timeout", function (timeout) { return function (scope, element, attrs) { var baseWindow = $(window); var baseDocument = $(document); var elem = $(element); var parentPanel = elem.parent(); //elem.data('fix-width-to'); var hasRun = false; var pageHeight = baseDocument.height(); var sidebarTopMargin = -20; var sidebarBottomMargin = 40; var cartSummaryRightRailElement = $("#cart-summary-right"); var getSidebarWidth = function () { var sidebarNavWidth = $(parentPanel).width() - parseInt(elem.css('marginLeft'), 10) - parseInt(elem.css('marginRight'), 10) - parseInt(elem.css('borderLeftWidth'), 10) - parseInt(elem.css('borderRightWidth'), 10); return sidebarNavWidth; }; var getSidebarHeight = function () { var newHeight = parseInt(elem.css('padding-bottom')), childDivHeightSum = 0; elem.find('>div').each(function () { var $this = $(this); childDivHeightSum += $this.outerHeight(); newHeight += ($this.outerHeight() + parseInt($this.css('margin-top')) + parseInt($this.css('margin-bottom'))); }); return [newHeight, childDivHeightSum]; }; var adjustOffsets = function () { var offsetTop = Math.round(cartSummaryRightRailElement.prevAll("section").offset().top + sidebarTopMargin); var offsetBot = Math.round(baseDocument.height() - $("footer").offset().top + sidebarBottomMargin); elem.affix({ offset: { top: offsetTop, bottom: offsetBot } }); // explicitly override the bootstrap affix offset data, because by default, it doesn't re-instatiate if (elem.data('bs.affix')) { elem.data('bs.affix').options.offset.top = offsetTop; elem.data('bs.affix').options.offset.bottom = offsetBot; } }; var fixSidebar = function () { if (window.innerWidth >= '992') { var sidebarWidth = getSidebarWidth(), sidebarHeightObj = getSidebarHeight(), sidebarHeight = sidebarHeightObj[0], sidebarDivHeights = sidebarHeightObj[1]; if (sidebarWidth > 0 && sidebarDivHeights > 0) { if (cartSummaryRightRailElement.prevAll("section").height() > sidebarHeight + sidebarBottomMargin) { adjustOffsets(); } } else if (elem.is(':visible')) { fixSidebar(); } } }; baseWindow.on('scroll', function () { if (!hasRun) { fixSidebar(); hasRun = true; } else if (pageHeight !== baseDocument.height()) { pageHeight = baseDocument.height(); fixSidebar(); } }).on('resize', function () { fixSidebar(); }); var timerFixSidebar = timeout(fixSidebar, 500); scope.$on("$destroy", function (event) { timeout.cancel(timerFixSidebar); }); }; }]).directive("ngMakeElementSticky", ["featureService", "cartSummaryRightRailPopupService", function (featureService, cartSummaryRightRailPopupService) { return { restrict: 'A', link: function (scope, element, attrs) { var baseWindow = $(window); var ftEnabled = featureService.IsEnabled("EnableStickyCartTitle"); if (ftEnabled && scope.DataModel) { if (scope.DataModel.WorkFlow) { var isOnCartPage = cartSummaryRightRailPopupService.isOnCartPage(scope.DataModel.WorkFlow); } var cartItems = scope.DataModel.CartItems && scope.DataModel.CartItems.length; if (isOnCartPage && cartItems > 0) { var topClass = attrs.ngMakeElementSticky, offsetTop = element.offset().top, offsetLeft = element.offset().left, offsetRight = 0; if (element && element.length > 0) offsetRight = baseWindow.width() - (element.offset().left + element[0].offsetWidth); else offsetRight = offsetLeft; } } baseWindow.on('scroll', function () { if (ftEnabled && isOnCartPage && cartItems > 0) { if (baseWindow.scrollTop() >= offsetTop) { element.addClass(topClass); element.css({ "left": offsetLeft, "right": offsetRight }); } else { element.removeClass(topClass); } if (element.offset().top + element.height() >= $('#footer').offset().top) { element.removeClass(topClass); } } }) } }; }]).directive("ngPopOver", function () { return function (scope, element, attrs) { $(element) .popover({ html: true }) .click(function (e) { $('.popover, [data-dismiss="popover"]').click(function () { e.preventDefault(); if ($(this).hasClass('in')) { $(element).popover('toggle'); } }); e.preventDefault(); }); }; }) .directive("ngPopOverWithToolTip", function () { return function (scope, element, attrs) { var options = { html: true }; if (scope.item !== undefined) { if (scope.item.HelpLinkTitle) { options.title = scope.item.HelpLinkTitle + ''; } if (scope.item.ToolTipHelpContent) { options.content = scope.item.ToolTipHelpContent; } } $(element).popover(options) .click(function (e) { $('[data-dismiss="popover"]').click(function () { e.preventDefault(); $(this).parents('.popover').prev().popover('hide'); }); e.preventDefault(); }); }; }) .directive("ngModal", function () { return function (scope, element, attrs) { var resizeTimer = null; var modalWindow = $(window); var resizeModal = function (modal) { var $modal = $(modal), //$('.modal:visible'), $modalBody = $modal.find('.modal-body'), $modalFooter = $modal.find('.modal-footer'); var maxHeight = modalWindow.height() - $modal.offset().top + modalWindow.scrollTop() - $modalFooter.height() - parseInt($modalFooter.css('marginTop'), 10) - parseInt($modalFooter.css('paddingTop'), 10) - parseInt($modal.css('paddingBottom'), 10); $modalBody.animate({ 'maxHeight': maxHeight }, 200); }; var createResizeTimer = function (elem, milliSecs) { if (resizeTimer !== null) window.clearTimeout(resizeTimer); resizeTimer = window.setTimeout(function () { resizeModal(elem); }, milliSecs); }; $(element).on('show.bs.modal', function (e) { $("body").addClass("modal-open"); createResizeTimer(this, 400); }).on('hidden.bs.modal', function (e) { $("body").removeClass("modal-open"); }); modalWindow.resize(function () { if ($('.modal:visible').length > 0) { createResizeTimer('.modal:visible', 200); } }); }; }) .directive("ngSlimmage", ["featureService", function (featureService) { return { restrict: 'A', link: function (scope, element, attrs) { var updateSlimmage = function () { window.slimmage.adjustImageSrc(element[0], attrs.ngSlimmage); if (!element.attr('src')) { element.attr('src', attrs["ngSlimmage"]); } if (featureService.IsEnabled("ShowCatalogImageForConfigItem")) { var src = element.attr('src'); var index = src.indexOf('&'); if (index > -1 && src.indexOf('?') === -1) { var arr = src.split(""); arr.splice(index, 1, '?'); element.attr('src', arr.join("")); } } }; updateSlimmage(); $('#removeConfirmationModal').on('hidden', function () { var slimUrl = attrs.ngSlimmage, slimIndex = slimUrl.lastIndexOf('/'), slimName = slimUrl.substr(slimIndex).toLowerCase(); var srcUrl = element.attr('src'), srcIndex = srcUrl.lastIndexOf('/'), srcName = srcUrl.substr(srcIndex).toLowerCase(); if (slimName != srcName) { element.removeAttr('data-pixel-width'); updateSlimmage(); } }); } }; }]) .directive("ngDiscountExpand", function () { return { restrict: 'A', link: function (scope, element, attrs) { var iconLink = element.children("#itemDiscountIcon"); iconLink.addClass("icon-ui-triangledown"); //scope.$parent.item.itemDiscountIcon = ; element.click(function (eventObj) { var divToWorkOn = eventObj.target.tagName === "SPAN" ? $(eventObj.target).parent().siblings('div.totalDiscountDiv') : $(eventObj.target).siblings('div.totalDiscountDiv'); if (divToWorkOn.is(':visible')) { divToWorkOn.removeClass("visible-xs"); divToWorkOn.addClass("hidden-xs"); iconLink.removeClass("icon-ui-triangledown"); iconLink.removeClass("icon-ui-triangleup"); iconLink.addClass("icon-ui-triangledown"); //scope.$parent.item.itemDiscountIcon = "icon-ui-triangledown"; } else { divToWorkOn.removeClass("hidden-xs"); divToWorkOn.addClass("visible-xs"); iconLink.removeClass("icon-ui-triangledown"); iconLink.removeClass("icon-ui-triangleup"); iconLink.addClass("icon-ui-triangleup"); } eventObj.preventDefault(); return false; }); } }; }) .directive("ngDiscountModal", function () { return { restrict: 'A', link: function (scope, element, attrs) { $(element).on("click", function (event) { scope.$root.selectedItemDiscount = scope.item; scope.$root.$apply(); $('#discountModal').modal(true); event.preventDefault(); }); } }; }) .directive("ngFinanceModal", function () { return { restrict: 'A', link: function (scope, element, attrs) { $(element).on("click", function (event) { //scope.$root.selectedItemDiscount = scope.item; /* scope.$root.$apply();*/ $('#financeModal').modal(true); /* event.preventDefault();*/ }); } }; }) .directive('pressEnter', function () { return function (scope, element, attrs) { element.bind("keydown keypress", function (event) { if (event.which === 13) { scope.$apply(function () { scope.$eval(attrs.pressEnter); }); event.preventDefault(); } }); }; }) .directive("ngCouponModal", function () { return { restrict: 'A', link: function (scope, element, attrs) { $(element).on("click", function (event) { scope.$root.selectedItemDiscount = scope.item; scope.$root.$apply(); $('#couponModal').modal(true); event.preventDefault(); }); } }; }) .directive("ngThresholdModal", function () { return { restrict: 'A', link: function (scope, element, attrs) { $(element).on("click", function (event) { scope.$root.threshold = scope.DataModel.CartSummary.MessagingDataModel; scope.$root.$apply(); $('#fianceThresholdModal').modal(true); event.preventDefault(); }); } }; }) .directive("ngAddClass", function () { return { restrict: 'A', link: function (scope, element, attrs) { $(element).on("click", function (event) { event.preventDefault(); var baseElement = $(element); $(baseElement.data('open')).removeAttr('style').removeClass('off').addClass('in'); $(baseElement.data('close')).removeAttr('style').removeClass('in').addClass('off'); $("a[href=" + baseElement.data('open') + "]").removeClass('collapsed'); $("a[href=" + baseElement.data('close') + "]").addClass('collapsed'); }); } }; }) .directive("ngScrollToBtnAndTrigger", function () { return { restrict: 'A', link: function (scope, element, attrs) { var elem = $(element); elem.on("click", function (event) { event.preventDefault(); var dataTarget = elem.data('target'); scope.scrollToBtnAndTrigger(dataTarget, false); }); } }; }) .directive("ngAddAdditionalPaymentsBtn", function () { return { restrict: 'A', link: function (scope, element, attrs) { var elem = $(element); elem.on("click", function (event) { event.preventDefault(); if ((scope.DataModel.AppliedPayments.length > 0 && !scope.IsPendingPayment)) { $('html, body').animate({ scrollTop: $('.addAddlPayment').parent().offset().top }, 500); } }); } }; }) .directive("ngValidationErrorsSummary", function () { return { priority: 100, template: '
  • {{validationError.extractedErrorMessage}}
  • ' }; }) .directive("ngScrollToAndFocus", function () { return { restrict: 'A', link: function (scope, element, attrs) { element.on("click", function (event) { event.preventDefault(); var dataTarget = element.data('target'); $('html, body').animate({ scrollTop: $(dataTarget + ":visible").offset().top - 10 // 10 px pad }, 500); $(dataTarget).focus(); }); } }; }) .directive("ngScrollToAndExpand", function () { return { restrict: 'A', link: function (scope, element, attrs) { var scrollToId = element.data('scroll-target'), expandId = attrs.ngScrollToAndExpand; element.off('click').on('click', function () { $('html, body').animate({ scrollTop: $(scrollToId).offset().top }, 500, function () { $(expandId).collapse('show'); $('[data-target="' + expandId + '"]').removeClass('collapsed'); }); }); } }; }) .directive("ngApplyRemainingBalance", ["$timeout", "applyRemainingBalanceService", "ccRewardsService", "featureService", function (timeout, applyRemainingBalanceService, ccRewardsService, featureService) { return { priority: 100, restrict: 'A', template: '{{label.labelMsg}}', link: function (scope, element, attrs) { var showMessaging = function () { scope.currencyFormatSettings = scope.currencyFormatSettings || { precision: 2, decimal: '.' }; var pendingTotal = +applyRemainingBalanceService.calculatePendingTotal(scope.currencyFormatSettings), // '+' forces this to be treated as a number orderTotal = +applyRemainingBalanceService.getOrderTotal(scope), diff = applyRemainingBalanceService.jsMathAdd([orderTotal, -pendingTotal], scope.currencyFormatSettings['precision']); $('.overAvailCredit').addClass('ng-hide'); $('.arbMsg').find('a').addClass('ng-hide'); if ($('input.amount-field:visible').length > 1) { $('.editable-amount').each(function () { var maxLimitField = $(this).find('input[name="item.MaxLimit"]'), availableCredit = +applyRemainingBalanceService.getAvailableCredit(maxLimitField), amountField = $(this).find('input.amount-field'), fieldAmount = applyRemainingBalanceService.convertToDecimalPrice(amountField.val(), scope.currencyFormatSettings['decimal']), fieldAmountPlusDiff = applyRemainingBalanceService.jsMathAdd([diff, fieldAmount], scope.currencyFormatSettings['precision']); if (availableCredit > 0) { if (fieldAmount <= availableCredit) { if (fieldAmountPlusDiff <= availableCredit) { if (pendingTotal < orderTotal) { $(this).find('a.addBalance').removeClass('ng-hide'); } else if (pendingTotal > orderTotal && fieldAmount > 0) { $(this).find('a.subExtra').removeClass('ng-hide'); } } else if (fieldAmountPlusDiff > availableCredit && fieldAmount !== availableCredit) { $(this).find('a.useAvailCredit').removeClass('ng-hide'); } } else if (fieldAmount > availableCredit) { $(this).parent().find('.overAvailCredit').removeClass('ng-hide'); $(this).find('a.useAllCredit').removeClass('ng-hide'); } else if (fieldAmount > orderTotal) { $(this).find('a.subExtra').removeClass('ng-hide'); } } else if (pendingTotal < orderTotal) { $(this).find('a.addBalance').removeClass('ng-hide'); } else if (fieldAmount > 0 && (pendingTotal > orderTotal)) { $(this).find('a.subExtra').removeClass('ng-hide'); } }); } }; var editableAmountElement = element.closest('.editable-amount'); editableAmountElement.find('input.amount-field') .on('click', function () { if ($(this).val() === '0') { $(this).select(); } }); editableAmountElement.off('blur change', '.amount-field') .on('blur change', '.amount-field', function () { showMessaging(); if (featureService.IsEnabled("EnableCreditCardPayWithPoints")) { var amountField = editableAmountElement.find('input.amount-field'); applyRemainingBalanceService.updateDataModelAmount(scope, amountField.val()); scope.$root.$apply(function() { ccRewardsService.HandleAppliedRewardsForSplitPay(scope); }); } }); editableAmountElement.off('click', 'a.subExtra, a.addBalance') .on('click', 'a.subExtra, a.addBalance', function () { var amountField = editableAmountElement.find('input.amount-field'), newAmount = applyRemainingBalanceService.updateAmount(scope, amountField.val()).toFixed(scope.currencyFormatSettings['precision']).toString(); applyRemainingBalanceService.updateDataModelAmount(scope, newAmount); amountField.trigger('change'); showMessaging(); }); editableAmountElement.off('click', 'a.useAvailCredit, a.useAllCredit') .on('click', 'a.useAvailCredit, a.useAllCredit', function () { var maxLimitField = $(this).closest('.editable-amount').find('input[name="item.MaxLimit"]'), availableCredit = applyRemainingBalanceService.getAvailableCredit(maxLimitField).toFixed(scope.currencyFormatSettings['precision']).toString(); applyRemainingBalanceService.updateDataModelAmount(scope, availableCredit); editableAmountElement.find('input.amount-field').trigger('change'); showMessaging(); }); var timer = timeout(showMessaging, 500); scope.$on("$destroy", function (event) { timeout.cancel(timer); }); } }; }]) /* ngMoreLess Directive shows more or less action for a list\string. ------------------------------------- Attributes: collection: ---pass collection (array of object) text: --------pass string(string) limit: -----pass integer to limit no of list items/characters to be shown(list/string) keyToDisplay -----pass name of property to be displayed in the list.(list) isList-------pass bool, true for list type, false for string type(list/string) moreLabel----------pass label for more text lessLabel---------pas lael for less text */ .directive("ngMoreLess",["featureService", function (featureService) { return { restrict: 'A', scope: { collection: "=", text: "=", limit: "=", keyToDisplay: "@", imageToDisplay: "@", isList: "=", moreLabel: "@", lessLabel: "@", showEditItem: "=", editItem:"&editItemAttr" }, template: '
    ' + '
    ' + '
  • ' + '
    ' + '
    {{item[keyToDisplay]}}
    ' + '
  • ' + '
  • ' + '
    ' + '
    {{item[keyToDisplay]}}
    ' + '
  • ' + '
    ' + '{{lessLabel}}' + '{{moreLabel}}', link: function (scope, element) { var ftEnabled = featureService.IsEnabled("EnableEditForItemDescriptionAndImage"); scope.edit = function () { if (ftEnabled && scope.showEditItem) { scope.editItem(); } } if (ftEnabled && scope.showEditItem) { element.find(".textDiv").toggleClass("cursorPointer") .attr('tabIndex', 0) .attr("role", "link") .bind("keydown keypress", function (event) { if (event.which === 13) { scope.editItem(); }; }); } if (scope.isList) { if (scope.collection.length > scope.limit) { element.children().last().toggleClass("ng-hide"); } } else { var text = typeof scope.text == 'undefined' ? "" : scope.text; if (text.length > scope.limit) { element.children().last().toggleClass("ng-hide"); var indexOfWhiteSpace = text.lastIndexOf(" ", scope.limit); var textA = text.substring(0, indexOfWhiteSpace); var textB = text.substring(indexOfWhiteSpace); element.find(".textDiv").html('' + textA + '...' + textB + ''); } else { element.find(".textDiv").html(text); } } element.children('a.moreLess').off().on('click', function (eventObj) { var hiddenElement = element.find('.hiddenElement'); hiddenElement.toggleClass("ng-hide"); }); } }; }]) .directive("ngAddHtml", ["$compile", function (compile) { return { restrict: 'A', link: function (scope, element, attrs) { var dataTesttIdPart = attrs.ngChildDataTestid ? (' data-testid="' + attrs.ngChildDataTestid + '"') : ''; element.html(compile('
    ' + attrs.ngAddHtml + '
    ')(scope)); } }; }]) .directive("ngAdjustDropdown", function () { return { restrict: 'A', link: function (scope, element, attrs) { // when dropdown meets edge of window, move it to the left var dropdown = $(element).find('.dropdown-menu'), initDropdownLeft = dropdown.css('left'), initDropdownRight = dropdown.css('right'), resizeTimer = null; var fixDropdownX = function () { dropdown.css({ 'left': initDropdownLeft, 'right': initDropdownRight }); var dropdownWidth = Math.ceil(dropdown.outerWidth()), containerWidth = Math.ceil(element.outerWidth()); if (dropdownWidth > containerWidth) { dropdownWidth = containerWidth; // ensure the dropdown never goes past the left of the screen } var dropdownLeft = Math.ceil(dropdown.offset().left), dropdownRight = dropdownLeft + dropdownWidth, containerLeft = Math.ceil(element.offset().left), containerRight = containerLeft + containerWidth; if (dropdownRight > containerRight) { var newDropdownLeft = containerRight - dropdownRight; dropdown.css({ 'left': newDropdownLeft, 'right': initDropdownRight }); } }; $(element).find('.dropdown-menu').parent().on('shown.bs.dropdown', function () { fixDropdownX(); }); var createFixDropdownTimer = function (milliSecs) { if (resizeTimer !== null) window.clearTimeout(resizeTimer); resizeTimer = window.setTimeout(function () { fixDropdownX(); }, milliSecs); }; $(window).resize(function () { if ($('.dropdown-menu:visible').length > 0) { createFixDropdownTimer(200); } }); } }; }) .directive("ngHrefTargetBlank", function () { return { restrict: 'A', compile: function (element) { var elems = (element.prop("tagName") === 'A') ? element : element.find('a'); elems.attr("target", "_blank"); } }; }) .directive("ngHrefTargetSelf", function () { return { restrict: 'A', compile: function (element) { var elems = (element.prop("tagName") === 'A') ? element : element.find('a'); elems.attr("target", "_self"); } }; }) .directive("ngValidatecpfcnpj", ["cpfcnpjValidationService", function (cpfcnpjValidationService) { return { restrict: 'A', require: 'ngModel', link: function (scope, element, attrs, ngModel) { element.bind('blur', function (e) { var status = cpfcnpjValidationService.ValidateCpfCnpj(element); // set the validity. ngModel.$setValidity('cpfcnpj', status); }); } }; }]) .directive("ngPostalcodeaddress", ["postalAddressValidationService", "featureService", function (postalAddressValidationService, featureService) { return { priority: 100, restrict: 'A', scope: false, link: function (scope, iElement, attrs) { iElement.on("blur", function () { if (featureService.IsEnabled("EnableReceitaZipCodeFederalNotification")) { waitForToolTip(1000); } if (featureService.IsEnabled("GoogleAutoCompleteEnabled")) { postalAddressValidationService.GetValidateShippingAddress(iElement, scope, attrs.sourceContact); } else { if (!featureService.IsEnabled("GoogleAutoCompleteEnabled")) { postalAddressValidationService.GetAddressByPostalCode(iElement, scope, attrs.sourceContact); } if (featureService.IsEnabled("SuframaBenefits")) { postalAddressValidationService.GetAddressByPostalCode(iElement, scope, attrs.sourceContact); } } }); if (featureService.IsEnabled("EnableReceitaZipCodeFederalNotification")) { var waitForToolTip = function dellayForTooltip(milliseconds) { const date = Date.now(); var currentDate = null; do { currentDate = Date.now(); } while (currentDate - date < milliseconds); } } } }; }]).directive("ngValidateaustralianbusinessnumber", function () { return { restrict: 'A', require: 'ngModel', link: function (scope, element, attrs, ngModel) { element.bind('blur', function (e) { var result = true; if (element[0].attributes['ng-validateaustralianbusinessnumber'].value.toLowerCase() == "true") { var abn = element[0].value; if (abn) { var weights = [10, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]; abn = abn.replaceAll(/[^\d]/, ''); if (abn.length === 11) { var sum = 0, weight, digit; for (var index = 0; index <= weights.length - 1; index++) { weight = weights[index]; digit = abn[index] - (index ? 0 : 1); sum += weight * digit; } result = sum % 89 === 0; } else { result = false; } } } ngModel.$setValidity('australianbusinessnumber', result); }); } }; }).directive("ngPhoneformatvalidate", ["phoneNumberValidationService", function (phoneNumberValidationService) { return { restrict: 'A', link: function (scope, element, attrs) { element.bind("blur", function () { phoneNumberValidationService.ValidateAndFormatPhoneNumber(element, attrs.sourceContact, attrs.phoneType); }); } }; }]) .directive("ngPostalcodeformat", function ($parse) { return { restrict: 'A', template: "
  • {{code.replace(regex, '$1-$2')}}
  • ", scope: { code: '=ngPostalcodeformat' }, replace: true, link: function (scope, element, attrs) { scope.regex = /^(\d{3})(\d{4})$/; } }; }).directive("ngBillofentryvalidate", ["billOfEntryValidationService", function (billOfEntryValidationService) { return { restrict: 'A', link: function (scope, element, attrs) { element.bind("blur", function () { billOfEntryValidationService.ValidateBillOfEntry(element); }); } }; }]).directive('dacomDynamicUrl', function () { return { restrict: 'A', link: function postLink(scope, element, attrs) { element.attr('src', scope.DataModel.DacomDataModel.DacomUrl); } }; }).directive('maskingInfo', function () { return { restrict: 'A', template: "
  • {{code}}
  • ", scope: { code: '=maskingInfo' }, replace: true, link: function (scope, element, attrs) { var maskedInfo = scope.code.replace(/(\B[\S])\B/g, "*"); scope.code = maskedInfo; } }; }).directive('ngRepeatClickHandler', function () { return { compile: function (element, attr) { return function link(scope, element, attr) { element.on('click', function (event) { scope.$apply(function () { scope.$eval(attr.ngRepeatClickHandler, { $event: event }); }); }); }; } }; }).directive("ngValidatePanNumber", function () { return { restrict: 'A', require: 'ngModel', link: function (scope, element, attrs, ngModel) { element.bind('blur', function (e) { var result = true; var pan = element[0].value; if (pan) { if (pan.length === 10) { var regex = "/^([A-Za-z]{5}\d{4}[A-Za-z]{1})/"; if (pan.match(regex)) result = false; } } ngModel.$setValidity('pannumber', result); }); } }; }).directive("ngValidateCompanyExtraFields", function () { return { restrict: 'A', link: function (scope, element, attrs) { scope.$watch(function (scope) { return scope.DataModel.IsZeroSegmentOrderForHome }, function (isOrderForHome) { if (isOrderForHome) { element.removeClass("ng-required"); document.getElementById(attrs.id).required = false; if ($(attrs.id)[0] != undefined && $(attrs.id)[0].classList != undefined) { $(attrs.id)[0].classList.remove("requiredField"); $(attrs.id)[0].classList.add("stp-hide-asterisk"); } } else { element.addClass("ng-required"); document.getElementById(attrs.id).required = true; if ($('label[for="' + attrs.id + '"]')[0] != undefined && $('label[for="' + attrs.id + '"]')[0].classList != undefined) { $('label[for="' + attrs.id + '"]')[0].classList.add("requiredField"); $('label[for="' + attrs.id + '"]')[0].classList.remove("stp-hide-asterisk"); } } scope.DataModel.ShippingContact.ZerosegmentValidation = isOrderForHome; scope.DataModel.BillingContact.ZerosegmentValidation = isOrderForHome; } ); } }; }).directive("ngItemLevelEdd", function () { return { restrict: 'A', link: function (scope, element, attrs) { var selectedDate = scope.EstimatedDeliveryDateDataModel.SelectedEstimatedDeliveryDate; if (selectedDate && scope.EstimatedDeliveryDateDataModel.EstimatedDeliveryDates.length > 0 && scope.EstimatedDeliveryDateDataModel.EstimatedDeliveryDates[0] !== selectedDate) { scope.EstimatedDeliveryDateDataModel.disableselectedShiftTimeDropdown = false; } else { scope.EstimatedDeliveryDateDataModel.disableselectedShiftTimeDropdown = true; } if (selectedDate && scope.EstimatedDeliveryDateDataModel.EstimatedDeliveryDates.length > 0 && (!scope.EstimatedDeliveryDateDataModel.EstimatedDeliveryDates.indexOf(selectedDate) > -1)) { scope.EstimatedDeliveryDateDataModel.SelectedEstimatedDeliveryDate = scope.EstimatedDeliveryDateDataModel.EstimatedDeliveryDates[0]; scope.EstimatedDeliveryDateDataModel.SelectedShiftTime = scope.deliveryShifts[0].Value; scope.EstimatedDeliveryDateDataModel.disableselectedShiftTimeDropdown = true; } } }; }).directive("ngValidateissuebank", function () { return { restrict: 'A', require: 'ngModel', link: function (scope, element, attrs, ngModel) { var cardType = scope.$parent.item.CardTypeCode; scope.DataModel.SavedCardTypeCode = cardType; } } }).directive('contenteditable', ['$sce', function ($sce) { return { restrict: 'A', // only activate on element attribute require: '?ngModel', // get a hold of NgModelController link: function (scope, element, attrs, ngModel) { if (!ngModel) return; // do nothing if no ng-model // Specify how UI should be updated ngModel.$render = function () { element.html($sce.getTrustedHtml(ngModel.$viewValue || '')); read(); // initialize }; // Listen for change events to enable binding element.on('blur keyup change', function () { scope.$evalAsync(read); }); // Write data to the model function read() { var html = element.html(); // When we clear the content editable the browser leaves a
    behind // If strip-br attribute is provided then we strip this out if (attrs.stripBr && html == '
    ') { html = ''; } ngModel.$setViewValue(html); } } }; }]).directive('ngBindHtmlCompile', ["$compile",function ($compile) { return { restrict: 'A', replace: true, link: function (scope, element, attrs) { scope.$watch(attrs.ngBindHtmlCompile, function (html) { $compile(element.html(html && html.toString()).contents())(scope); }, true); } }; }]).directive('ngDisplayRatings', function () { return { restrict: 'A', replace: true, link: function (scope, element, attrs) { scope.ShowHideRatingsSection(element); } }; }).directive("ngPostalcodeforstateandcity", ["postalAddressValidationService", "featureService", function (postalAddressValidationService, featureService) { return { priority: 100, restrict: 'A', scope: false, link: function (scope, iElement, attrs) { iElement.on("blur", function () { if (!featureService.IsEnabled("GoogleAutoCompleteEnabled")) { if (featureService.IsEnabled("StateandCityfromPostalcode")) { postalAddressValidationService.GetStateAndCityByPostalCode(iElement, scope, attrs.sourceContact, null); } } else { if (attrs.sourceContact == "ShippingContact" && scope.DataModel.ShippingContact.PostalCode) { scope.ValidateShippingAddress(iElement[0].value, true); } } }); } }; }]).directive("ngCityaddresschange", ["featureService", function (featureService) { return { priority: 100, restrict: 'A', scope: false, link: function (scope, iElement, attrs) { iElement.on("blur", function () { if (featureService.IsEnabled("SuframaBenefits")) { scope.ValidateSuframaStatesWithCity(true); } }); } }; }]).directive("ngAllowOnlyNumber", function () { return { restrict: 'A', link: function (scope, element) { function isNumberKey(event) { var charCode = (event.which) ? event.which : event.keyCode; if (charCode === 46) { return false; } if (charCode !== 46 && charCode > 31 && charCode !== 190 && charCode !== 188 && (charCode < 48 || charCode > 57)) return false; return true; } element.on("keypress", function (event) { if (isNumberKey(event)) { return true; } return false; }); } }; }).directive("ngAllowOnlyAlphaNumeric", function () { return { restrict: 'A', link: function (scope, element) { function isSpecialCharKey(event) { var charCode = (event.which) ? event.which : event.keyCode; return ((charCode > 64 && charCode < 91) || (charCode > 96 && charCode < 123) || charCode == 8 || charCode == 32 || (charCode >= 48 && charCode <= 57)); } element.on("keypress", function (event) { if (isSpecialCharKey(event)) { return true; } return false; }); } }; }).directive('ngBindHtmlUnsafe', function ($parse, $compile) { return function ($scope, $element, $attrs) { var compile = function (newHTML) { newHTML = $compile(newHTML)($scope); $element.html('').append(newHTML); }; var htmlName = $attrs.ngBindHtmlUnsafe; $scope.$watch(htmlName, function (newHTML) { if (!newHTML) return; compile(newHTML); }); }; }).directive("ngAutocompletebypostalcode", ["googleAutocompleteService", "featureService", "$timeout", function (googleAutocompleteService, featureService, timeout) { if (featureService.IsEnabled("GoogleAutoCompleteEnabled")) { return { priority: 100, restrict: 'A', link: function (scope, iElement, attrs) { iElement.on("focus", googleAutocompleteService.geolocate), $('#' + iElement[0].id).typeahead({ hint: false, highlight: true, minLength: 3 }, { name: "states", displayKey: "value", async: true, limit: 10, source: googleAutocompleteService.getPlacePredictionsByPostalCode, templates: { header: '
    Suggestions
    ', footer: '', notFound: '
    No Result Found
    ' } }).bind('typeahead:select', function (ev, suggestion) { googleAutocompleteService.fillAddressFieldsByPostalCode(suggestion.place_id, ev, attrs, $(this)); }), // Note: autocomplete is bydefault set as off(when set from cshtml) which causes chrome to show the addresses which are stored in browser (Bug in chrome as well) iElement.attr("autocomplete", "nofill"); } }; } }]); ; 'use strict'; angular.module('globalErrors', []).config(['$provide', '$httpProvider', '$compileProvider', function ($provide, $httpProvider, $compileProvider) { var elementsList = $(); var showMessage = function (content, time) { $.each(elementsList, function (i, val) { val.empty(); }); $('
    ') .addClass('alert') .addClass('error') .appendTo(elementsList) .html('

    ' + content + '

    '); }; var isJson = function (inputValue) { try { if (inputValue instanceof Object) { return true; } else { var returnObjType = (typeof JSON.parse(inputValue)); if (returnObjType === "int" || returnObjType === "string") { return false; } else { return true; } } } catch (e) { return false; } }; $provide.factory('globalErrorsInterceptor', ['$q', '$rootScope', 'cartJsLoggingService','initService', function ($q, $rootScope, cartJsLoggingService,initService) { var hideMessageAfter = 20000; return { 'responseError': function (errorResponse) { if ($rootScope.SuppressGlobalAjaxErrorHandler === true) { return $q.reject(errorResponse); } var errorMessage = isJson(errorResponse.data) ? errorResponse.data.Message : errorResponse.data, alertMessage = ''; var data = initService.Get(); if (data.netViewModel.CartSummaryViewModel) { var errorSentence = data.netViewModel.CartSummaryViewModel.HttpErrorMessage; if (errorSentence) { var errorMessages = errorSentence.split("|"); var index, len; var errResponseStatusString = errorResponse.status.toString(); len = errorMessages.length; for (index = 0; index < len; index++) { var fullErrorMessage = errorMessages[index]; var errorMsg = fullErrorMessage.split(":"); if (errorMsg[0] == errResponseStatusString) { alertMessage = errorMsg[1]; break; } } } } if (alertMessage) { showMessage(alertMessage, hideMessageAfter); cartJsLoggingService.logCustomMessage(alertMessage); } return $q.reject(errorResponse); } }; } ]); $httpProvider.interceptors.push('globalErrorsInterceptor'); $compileProvider.directive('appMessages', function () { var directiveDefinitionObject = { link: function (scope, element, attrs) { elementsList.push($(element)); } }; return directiveDefinitionObject; }); }]);; (function () { var logoAnchor = $("a[data-stp-dell-logo]"); // Use commented line below to test without attribute. //var logoAnchor = $(".navbar-brand a"); if (logoAnchor) { logoAnchor.on("click", function (e) { //Ensure there's a modal on the page if ($("#dellLogoModal").length === 0) { return; } e.preventDefault(); $("#dellLogoModal").modal('show'); }); } }());; /*All cart constants goes here...*/ angular.module('Dell.STP.Cart.Common',[]).constant('cartConstants', { TaxCategory: { CPF : "cpf", CNPJ : "cnpj", CNPJTaxFree : "cnpj_tf" }, ContactType: { ShippingContact: "ShippingContact" }, FeatureToggles: { GetAddressByPostalCodeAvs: "GetAddressByPostalCodeAvs", HideValidationSummaryInShippingPage: "HideValidationSummaryInShippingPage", IovationFirstPartyScript: "IovationFirstPartyScript", ShowSplitPayAsTabs: "ShowSplitPayAsTabs", BuyAutoPilotEnabled: "BuyAutoPilotEnabled", ShowRatingsAndReviews: "ShowRatingsAndReviews", ShowThreeStepProgressBar: "ShowThreeStepProgressBar", ExpressCheckoutWithFinance: "ExpressCheckoutWithFinance", EnableBuyZeroSegment: "EnableBuyZeroSegment" }, PayCode: { bitCoin: "BC", payPal: "PY", dellBusinessCreditNew: "OO", dellBusinessCreditExisting: "OP", purchaseOrder: "PO", wireTransfer: "WT", bankTransfer: "BT", financingAndLease: "FL", electronicFundsTransfer: "EFT", dellAdvantageRewards: "EL", boleto: "CH", payPalCredit: "PD", payWithMyBank : "PB", dellPrefferedAccountNew: "PN", dellPrefferedAccountExisting: "PP", creditCard: "CC", postPay: "ACCT", boletoGpg: "AB", pcaasPayNew: "LO", pcaasPayExisting: "LP", gPay: "GP", aPay: "AP" }, DaIncompatiblePaycodes: [ "BC", //bitCoin "PO", //purchaseOrder, "CH", //boleto, // not sure why this was added, need to check if brazil/boleto is required for DA flows "PB", //payWithMyBank, "GP", //Gpay "AP", //Apay ], CompanyStatus: { BEFORE: "FR", AFTER: "BK" }, DacomMessage: "dacom_message", LocationSource: { User: "user", Authenticated: "authenticated", Unauthenticated: "unauthenticated" }, Regex: { OnlyDigitsBeforeDecimal: /[^0-9\.]+/g }, FREE: "FREE", ClientAlertIds: { paymentProcessorError: '5' }, ErrorSeverity: { error: 0, warning: 1, info: 2 }, ErrorCodes: { googlePayErrorCode: '1512', applePayErrorCode: '1513', payWithMyBankError: '1514', expressCheckoutError: '1515', eolItemsAlertMessageError: '1516', googleAutoCompleteError: '1517', threeDSSecureError: '1518', CartContentError: '1519' }, Info: { ThreeDS: '100', ShippingContact: '105', BillingContact: '106', ReviewPage: '107', CartContentPage: '109' }, Warning: { ThreeDS: '101', ShippingContact: '102', BillingContact: '103', ReviewPage: '108', CartContentPage: '110' } });; 'use strict'; angular.module('globalTracker', []).config(['$httpProvider', function ($httpProvider) { $httpProvider.interceptors.push(['$q',function ($q) { return { request: function (config) { if (!(config.tracker)) { config.tracker = 'globalTracker'; } return $q.when(config); } }; }]); }]);; (function($) { // @todo Document this. $.extend($,{ placeholder: { browser_supported: function() { return this._supported !== undefined ? this._supported : ( this._supported = !!('placeholder' in $('')[0]) ); }, shim: function(opts) { var config = { color: '#888', cls: 'placeholder', selector: 'input[placeholder], textarea[placeholder]' }; $.extend(config,opts); !this.browser_supported() && $(config.selector)._placeholder_shim(config); } }}); $.extend($.fn,{ _placeholder_shim: function(config) { function calcPositionCss(target) { var op = $(target).offsetParent().offset(); var ot = $(target).offset(); return { top: ot.top - op.top, left: ot.left - op.left, width: $(target).width() }; } return this.each(function() { var $this = $(this); if( $this.data('placeholder') ) { var $ol = $this.data('placeholder'); $ol.css(calcPositionCss($this)); return true; } var possible_line_height = {}; if( !$this.is('textarea') && $this.css('height') != 'auto') { possible_line_height = { lineHeight: $this.css('height'), whiteSpace: 'nowrap' }; } var ol = $('