{"version":3,"file":"bulkeditor.min.js","sources":["bulkeditor.ts"],"sourcesContent":["/// <reference path=\"eXpress.ts\" />\r\nnamespace eXpress.core.bulkeditor {\r\n\tenum PrintSortBy {\r\n\t\tDateTaken = 0,\r\n\t\tDateAdded = 1,\r\n\t\tName = 2\r\n\t}\r\n\r\n\texport interface IBulkEditorDependencies {\r\n\t\torderService: services.OrderService;\r\n\t\tcontentService: services.ContentService;\r\n\t\taccountService: services.AccountService;\r\n\t}\r\n\r\n\texport class DisplayList {\r\n\t\tpublic label: string | null;\r\n\t\tpublic quantity: number;\r\n\t}\r\n\r\n\texport interface IBulkEditorGetAllProductsResult {\r\n\t\tproducts: Product[];\r\n\t\ttranslations: eXpress.core.KeyValuePair<string>[];\r\n\t\tbulkSequenceShapes: string[];\r\n\t}\r\n\r\n\texport class Product {\r\n\t\tpublic readonly code: string;\r\n\t\tpublic readonly attributes: eXpress.core.KeyValuePair<string>[];\r\n\t\tpublic attributesDict: eXpress.core.Map<string>;\r\n\t\tpublic readonly options: eXpress.core.KeyValuePair<string[]>[];\r\n\t\tpublic optionsDict: eXpress.core.Map<string[]>;\r\n\t}\r\n\r\n\texport class CartItem extends core.mediastore.PhotoReference {\r\n\t\tpublic createdForced: Date;\r\n\t\tpublic dateModifiedParent: Date;\r\n\t\tpublic datePictureTaken: Date;\r\n\t\tpublic fileSize: number;\r\n\t\tpublic oldFileSystem: boolean;\r\n\t\tpublic originalFileName: string;\r\n\t\tpublic originalHeight: number;\r\n\t\tpublic originalWidth: number;\r\n\t\tpublic products: CartItemProduct[];\r\n\t\tpublic applyAllFailed: boolean;\r\n\t\tpublic photoCounter: number;\r\n\t\tpublic thumbUrl: string;\r\n\t\tpublic mediumUrl: string;\r\n\t}\r\n\r\n\texport class CartItemProduct {\r\n\t\tconstructor(productCode: string, quantity: number) {\r\n\t\t\tthis.productCode = productCode;\r\n\t\t\tthis.quantity = quantity;\r\n\t\t}\r\n\r\n\t\tpublic productCode: string;\r\n\t\tpublic quantity: number;\r\n\t\tpublic border: string | null;\r\n\t\tpublic colorEffect: string | null;\r\n\t\tpublic paper: string | null;\r\n\t\tpublic cartItemId: string;\r\n\t}\r\n\r\n\texport class BulkEditorApp extends CustomHtmlElementsApp {\r\n\t\tprivate context: core.IAppContext;\r\n\t\tprivate services: services.Services;\r\n\t\tprivate orderService: services.OrderService;\r\n\t\tprivate contentService: services.ContentService;\r\n\t\tprivate accountService: services.AccountService;\r\n\t\tprivate pageContext: any;\r\n\t\tprivate readonly productCategoryGroupCode: string;\r\n\t\tprivate readonly parentProductCategoryCode: string;\r\n\t\tprivate fromcart: boolean;\r\n\r\n\t\tprivate defaultProductCode: string;\r\n\t\tprivate defaultTheme: string;\r\n\t\tprivate defaultQuantity: number;\r\n\t\tprivate defaultOptions: string[];\r\n\r\n\t\tprivate availableProducts: Product[];\r\n\t\tprivate availableFormats: string[];\r\n\t\tprivate availableShapes: string[];\r\n\t\tprivate availableBorders: string[];\r\n\t\tprivate availablePapers: string[];\r\n\t\tprivate availableColorEffects: string[];\r\n\r\n\t\tprivate translations: Map<string>;\r\n\t\tprivate bulkSequenceShapes: string[];\r\n\r\n\t\tprivate currentItems: CartItem[];\r\n\r\n\t\tprivate editItem: CartItem;\r\n\t\tprivate croppingIsActive: boolean;\r\n\r\n\t\tprivate contentManager: eXpress.core.ContentManager;\r\n\t\tprivate importer: eXpress.core.Importer;\r\n\t\tprivate loginManager: eXpress.core.LoginManager;\r\n\r\n\t\tprivate hadItemsInBasket: boolean;\r\n\t\tprivate formIsDirty: boolean;\r\n\t\tprivate header: JQuery;\r\n\r\n\t\tprivate $sorting: JQuery;\r\n\t\tprivate defaultSortBy: PrintSortBy;\r\n\t\tprivate defaultSortOrder: SortOrder;\r\n\r\n\t\tprivate progressPoup: ProgressPopup;\r\n\r\n\t\tprivate initialScreenWidth: number;\r\n\r\n\t\tconstructor(deps: IBulkEditorDependencies, services: eXpress.services.Services, context: core.IAppContext, pageContext: any) {\r\n\t\t\tsuper();\r\n\r\n\t\t\tthis.context = context;\r\n\t\t\tthis.services = services;\r\n\t\t\tthis.orderService = deps.orderService;\r\n\t\t\tthis.contentService = deps.contentService;\r\n\t\t\tthis.accountService = deps.accountService;\r\n\t\t\tthis.pageContext = pageContext;\r\n\r\n\t\t\tthis.$sorting = $(\".multiselect.multiselect-sorting\");\r\n\t\t\tconst enforcedSort = eXpress.utils.getQueryStringParameter(\"sort\", undefined, false);\r\n\t\t\tconst enforcedOrder = eXpress.utils.getQueryStringParameter(\"order\", undefined, false);\r\n\t\t\tif (enforcedSort) {\r\n\t\t\t\tthis.defaultSortBy = PrintSortBy[enforcedSort];\r\n\t\t\t} else {\r\n\t\t\t\tthis.defaultSortBy = PrintSortBy.DateAdded;\r\n\t\t\t}\r\n\t\t\tif (enforcedOrder) {\r\n\t\t\t\tthis.defaultSortOrder = SortOrder[enforcedOrder];\r\n\t\t\t} else {\r\n\t\t\t\tthis.defaultSortOrder = SortOrder.Ascending;\r\n\t\t\t}\r\n\t\t\tthis.setSelectedSortingInUI(this.defaultSortBy, this.defaultSortOrder);\r\n\r\n\t\t\tconst oldHeader = $('.editor-header');\r\n\t\t\tthis.header = oldHeader.length > 0 ? oldHeader : $('.o-small-header');\r\n\r\n\t\t\t// loads initial filters\r\n\t\t\tthis.productCategoryGroupCode = eXpress.utils.getQueryStringParameter(\"pcg\", undefined, true).toLowerCase();\r\n\r\n\t\t\tthis.parentProductCategoryCode = this.productCategoryGroupCode;\r\n\t\t\tif (this.parentProductCategoryCode.indexOf(\".\") > -1)\r\n\t\t\t\tthis.parentProductCategoryCode = this.parentProductCategoryCode.substr(0, this.parentProductCategoryCode.indexOf(\".\"));\r\n\r\n\t\t\tthis.defaultProductCode = eXpress.utils.getQueryStringParameter(\"pvc\", undefined, true).toLowerCase();\r\n\t\t\tthis.defaultTheme = eXpress.utils.getQueryStringParameter(\"theme\", undefined, false);\r\n\t\t\tif (this.defaultTheme) this.defaultTheme = this.defaultTheme.toLowerCase();\r\n\r\n\t\t\tthis.fromcart = !!eXpress.utils.getQueryStringParameter(\"fromcart\") || false;\r\n\t\t\tif (eXpress.utils.getQueryStringParameter(\"options\"))\r\n\t\t\t\tthis.defaultOptions = eXpress.utils.getQueryStringParameter(\"options\").toLowerCase().split(',');\r\n\t\t\tthis.defaultQuantity = parseInt(eXpress.utils.getQueryStringParameter(\"quantity\") || \"1\", 10);\r\n\r\n\t\t\tthis.contentManager = new ContentManager(this.contentService, GetCookie(\"slbls\").toLowerCase() === \"true\");\r\n\r\n\t\t\tconst importerDependencies = {\r\n\t\t\t\tproductCategory: this.parentProductCategoryCode,\r\n\t\t\t\tcontentManager: this.contentManager,\r\n\t\t\t\tuploadService: this.services.uploadService,\r\n\t\t\t\tstorageService: this.services.storageService,\r\n\t\t\t\tprocessSelectedPhotosAsync: this.processSelectedPhotosAsync.bind(this)\r\n\t\t\t} as eXpress.core.IImporterDependencies;\r\n\t\t\tthis.importer = new Importer(importerDependencies);\r\n\r\n\t\t\tthis.loginManager = new LoginManager(this.accountService);\r\n\t\t}\r\n\r\n\t\tpublic start(): void {\r\n\t\t\t// This page requires authentication ... it can be long gone when we load the javascript (clear cookies etc) -> check on it\r\n\t\t\tconst isAuthenticated = utils.isAuthenticationCheck(GetCookie(\"accid\"));\r\n\t\t\tif (!isAuthenticated) {\r\n\t\t\t\tdocument.location.reload();\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tthis.initProducts();\r\n\t\t\tthis.addHandlers();\r\n\t\t\tthis.clear();\r\n\t\t\tthis.registerNavigateAwayQuestion();\r\n\r\n\t\t\tthis.loginManager.start(this.context.accountType);\r\n\t\t}\r\n\r\n\t\tprivate clear(): void {\r\n\t\t\t$('.filter-sorting').removeClass('hidden');\r\n\t\t\t$('.accept-filter').remove();\r\n\t\t}\r\n\r\n\t\tprivate redirectTo404(): JQueryPromise<unknown> {\r\n\t\t\twindow.location.href = `${window.location.origin}/404`;\r\n\t\t\tsetTimeout(() => {\r\n\t\t\t\treturn;\r\n\t\t\t}, 1000);\r\n\t\t\treturn $.Deferred().resolve();\r\n\t\t}\r\n\r\n\t\tprivate initProducts(): void {\r\n\t\t\tthis.currentItems = [];\r\n\r\n\t\t\tcore.showLoadingDialogAsync(this.contentService.bulkEditorGetAllProductsAsync(core.context.pointOfSaleId,\r\n\t\t\t\tcore.context.languageCode,\r\n\t\t\t\tthis.productCategoryGroupCode,\r\n\t\t\t\tthis.defaultProductCode).then((res) => {\r\n\r\n\t\t\t\t\tif (!res) {\r\n\t\t\t\t\t\tcore.showLoadingDialogAsync(this.redirectTo404());\r\n\t\t\t\t\t\treturn;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tthis.translations = utils.convertKeyValuePairToMap(res.translations);\r\n\t\t\t\t\tthis.bulkSequenceShapes = res.bulkSequenceShapes;\r\n\t\t\t\t\tthis.availableProducts = res.products;\r\n\t\t\t\t\tthis.availableProducts.forEach((availableProduct) => {\r\n\t\t\t\t\t\tavailableProduct.attributesDict = utils.convertKeyValuePairToMap(availableProduct.attributes);\r\n\t\t\t\t\t\tavailableProduct.optionsDict = utils.convertKeyValuePairToMap(availableProduct.options);\r\n\t\t\t\t\t});\r\n\t\t\t\t\tthis.initAvailableLists();\r\n\t\t\t\t\tthis.initApplyAll();\r\n\t\t\t\t\tconst initExistingCartItemsPromise = this.initExistingCartItemsAsync();\r\n\t\t\t\t\tconst initExistingMyPhotoItemsPromise = this.initExistingMyPhotoItemsAsync();\r\n\r\n\t\t\t\t\treturn $.when(initExistingCartItemsPromise, initExistingMyPhotoItemsPromise).then(async () => {\r\n\t\t\t\t\t\tif (this.currentItems.length === 0)\r\n\t\t\t\t\t\t\tawait this.openAddDialogAsync();\r\n\t\t\t\t\t});\r\n\r\n\t\t\t\t}));\r\n\t\t}\r\n\r\n\t\tprivate initApplyAll(): void {\r\n\t\t\tconst $container = $('.multiselect-wrapper').detach();\r\n\t\t\tconst $template = $container.find('.multiselect').detach();\r\n\r\n\t\t\tthis.initApplyAllMultiselect($template, $container, this.availableColorEffects, 'coloreffect');\r\n\t\t\tthis.initApplyAllMultiselect($template, $container, this.availableBorders, 'border');\r\n\t\t\tthis.initApplyAllMultiselect($template, $container, this.availablePapers, 'paper');\r\n\t\t\tthis.initApplyAllMultiselect($template, $container, this.availableShapes, 'shape');\r\n\t\t\tthis.initApplyAllMultiselect($template, $container, this.availableFormats, 'format');\r\n\t\t\tthis.initApplyAllMultiselect($template, $container, null, 'quantity');\r\n\r\n\t\t\t$('.filter-choice-multiselect').append($container);\r\n\t\t}\r\n\r\n\t\tprivate initApplyAllMultiselect($template: JQuery, $container: JQuery, list: string[] | null, code: string): void {\r\n\t\t\tif (list && list.length <= 1)\r\n\t\t\t\treturn;\r\n\r\n\t\t\tconst $new = $template.clone();\r\n\t\t\t$new.addClass(code);\r\n\t\t\t$new.attr('data-code', code);\r\n\r\n\t\t\tconst $subContainer = $new.find('.selectbox-choices').detach();\r\n\t\t\tconst $subTemplate = $subContainer.find('label');\r\n\t\t\t$subContainer.empty();\r\n\t\t\tlet maxLength = 100;\r\n\t\t\tif (list)\r\n\t\t\t\tmaxLength = list.length;\r\n\t\t\tfor (let i = 0; i < maxLength; i++) {\r\n\t\t\t\tconst $subNew = $subTemplate.clone();\r\n\t\t\t\tlet label = (i + 1).toString();\r\n\t\t\t\tif (list) {\r\n\t\t\t\t\tlabel = this.translations[code + '.' + list[i]];\r\n\t\t\t\t\tif (!label)\r\n\t\t\t\t\t\tlabel = code + list[i];\r\n\t\t\t\t\t$subNew.attr('data-code', list[i]);\r\n\t\t\t\t} else {\r\n\t\t\t\t\t$subNew.attr('data-code', label);\r\n\t\t\t\t}\r\n\t\t\t\t$subNew.html(label);\r\n\t\t\t\t$subContainer.append($subNew);\r\n\t\t\t}\r\n\r\n\t\t\t$new.append($subContainer);\r\n\t\t\t$container.prepend($new);\r\n\t\t}\r\n\r\n\t\t// Returns true if all items in the form are excatly the same\r\n\t\tprivate initApplyAllTitle(): boolean {\r\n\t\t\t/* This will set the visual cue for the apply all dropdown\r\n\t\t\t\tThe rule: For one dropdown, if ALL items in the form are the same, set the selecte value\r\n\t\t\t\tIf not, set the label.\r\n\t\t\t*/\r\n\t\t\tlet labelQuantity: string | null = null;\r\n\t\t\tlet labelFormat: string | null = null;\r\n\t\t\tlet labelShape: string | null = null;\r\n\t\t\tlet labelPaper: string | null = null;\r\n\t\t\tlet labelBorder: string | null = null;\r\n\t\t\tlet labelColorEffect: string | null = null;\r\n\t\t\tlet shouldInit = true;\r\n\t\t\tlet allItemsAreTheSame = true;\r\n\t\t\tif (this.currentItems && this.currentItems.length > 0) {\r\n\t\t\t\tthis.currentItems.forEach(item => {\r\n\t\t\t\t\titem.products.forEach(product => {\r\n\t\t\t\t\t\tconst availableProduct = eXpress.utils.findFirstOrError(this.availableProducts, p => p.code === product.productCode);\r\n\t\t\t\t\t\tif (shouldInit) {\r\n\t\t\t\t\t\t\tshouldInit = false;\r\n\r\n\t\t\t\t\t\t\tlabelQuantity = (product.quantity || 1).toString();\r\n\r\n\t\t\t\t\t\t\tlabelFormat = this.translations['format.' + availableProduct.attributesDict['format']];\r\n\t\t\t\t\t\t\tlabelShape = this.translations['shape.' + availableProduct.attributesDict['shape']];\r\n\t\t\t\t\t\t\tlabelPaper = this.translations['paper.' + (product.paper ? product.paper : 'default')];\r\n\t\t\t\t\t\t\tlabelBorder = this.translations['border.' + (product.border ? product.border : 'default')];\r\n\t\t\t\t\t\t\tlabelColorEffect = this.translations['coloreffect.' + (product.colorEffect ? product.colorEffect : 'default')];\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\t// Check the difference between the current label and the one we have\r\n\t\t\t\t\t\t\tif (labelQuantity === null || labelQuantity !== product.quantity.toString()) {\r\n\t\t\t\t\t\t\t\t// Comment Stef remark labelQuantity = this.pageContext.labelQuantity;\r\n\t\t\t\t\t\t\t\tlabelQuantity = '&nbsp;';\r\n\t\t\t\t\t\t\t\tallItemsAreTheSame = false;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tif (labelFormat !== this.translations['format.' + availableProduct.attributesDict['format']]) {\r\n\t\t\t\t\t\t\t\t// Comment Stef remark labelFormat = this.pageContext.labelFormat;\r\n\t\t\t\t\t\t\t\tlabelFormat = '&nbsp;';\r\n\t\t\t\t\t\t\t\tallItemsAreTheSame = false;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tif (labelShape !== this.translations['shape.' + availableProduct.attributesDict['shape']]) {\r\n\t\t\t\t\t\t\t\t// Comment Stef remark labelShape = this.pageContext.labelShape;\r\n\t\t\t\t\t\t\t\tlabelShape = '&nbsp;';\r\n\t\t\t\t\t\t\t\tallItemsAreTheSame = false;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tif (labelPaper !== this.translations['paper.' + (product.paper ? product.paper : 'default')]) {\r\n\t\t\t\t\t\t\t\t// Comment Stef remark labelPaper = this.pageContext.labelPaper;\r\n\t\t\t\t\t\t\t\tlabelPaper = '&nbsp;';\r\n\t\t\t\t\t\t\t\tallItemsAreTheSame = false;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tif (labelBorder !== this.translations['border.' + (product.border ? product.border : 'default')]) {\r\n\t\t\t\t\t\t\t\t// Comment Stef remark labelBorder = this.pageContext.labelBorder;\r\n\t\t\t\t\t\t\t\tlabelBorder = '&nbsp;';\r\n\t\t\t\t\t\t\t\tallItemsAreTheSame = false;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tif (labelColorEffect !== this.translations['coloreffect.' + (product.colorEffect ? product.colorEffect : 'default')]) {\r\n\t\t\t\t\t\t\t\t// Comment Stef remark labelColorEffect = this.pageContext.labelColorEffect;\r\n\t\t\t\t\t\t\t\tlabelColorEffect = '&nbsp;';\r\n\t\t\t\t\t\t\t\tallItemsAreTheSame = false;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t});\r\n\t\t\t\t});\r\n\t\t\t} else {\r\n\t\t\t\tlabelQuantity = this.pageContext.labelQuantity;\r\n\t\t\t\tlabelFormat = this.pageContext.labelFormat;\r\n\t\t\t\tlabelShape = this.pageContext.labelShape;\r\n\t\t\t\tlabelPaper = this.pageContext.labelPaper;\r\n\t\t\t\tlabelBorder = this.pageContext.labelBorder;\r\n\t\t\t\tlabelColorEffect = this.pageContext.labelColorEffect;\r\n\t\t\t}\r\n\r\n\t\t\t$('.filter-container .multiselect.quantity .selectBox span.label').html(labelQuantity || \"\");\r\n\t\t\t$('.filter-container .multiselect.format .selectBox span.label').html(labelFormat || \"\");\r\n\t\t\t$('.filter-container .multiselect.shape .selectBox span.label').html(labelShape || \"\");\r\n\t\t\t$('.filter-container .multiselect.paper .selectBox span.label').html(labelPaper || \"\");\r\n\t\t\t$('.filter-container .multiselect.border .selectBox span.label').html(labelBorder || \"\");\r\n\t\t\t$('.filter-container .multiselect.coloreffect .selectBox span.label').html(labelColorEffect || \"\");\r\n\r\n\t\t\t// Set the info message  info-all-photos\r\n\t\t\tlet infoLabel = '';\r\n\t\t\tif (!allItemsAreTheSame)\r\n\t\t\t\tinfoLabel += this.pageContext.labelMultipleItems;\r\n\t\t\tinfoLabel += this.pageContext.labelApplyAll.replace('{0}', this.currentItems.length);\r\n\r\n\t\t\t$('.info-all-photos').html(infoLabel);\r\n\r\n\t\t\treturn allItemsAreTheSame;\r\n\t\t}\r\n\r\n\t\tprivate initExistingMyPhotoItemsAsync(): JQueryPromise<void> {\r\n\t\t\t// We either have photoids and one folderId or no photoIds and one or more folderids\r\n\t\t\tconst strFolderIds = this.pageContext.folderids;\r\n\t\t\tconst strPhotoIds = this.pageContext.photoids;\r\n\t\t\tconst useDeselected = this.pageContext.useDeselected;\r\n\t\t\tconst isSelectAllActive = this.pageContext.isSelectAllActive;\r\n\t\t\tconst limit = this.pageContext.limit;\r\n\r\n\t\t\tif (strPhotoIds) {\r\n\t\t\t\treturn this.addNewItemsByPhotoIdsAsync(strFolderIds.split(\",\")[0], strPhotoIds.split(\",\"), useDeselected, isSelectAllActive);\r\n\t\t\t}\r\n\t\t\telse if (strFolderIds) {\r\n\t\t\t\treturn this.addNewItemsByFolderIdsAsync(strFolderIds.split(\",\"), useDeselected, limit);\r\n\t\t\t}\r\n\t\t\treturn $.Deferred<void>().resolve().promise();\r\n\t\t}\r\n\r\n\t\tprivate initExistingCartItemsAsync(): JQueryPromise<void> {\r\n\t\t\tif ((!pageContext.cartId || pageContext.cartId === eXpress.core.emptyGuid) && !this.pageContext.defId) {\r\n\t\t\t\tthis.displayTotals();\r\n\t\t\t\tthis.initApplyAllTitle();\r\n\t\t\t\treturn $.Deferred<void>().resolve().promise();\r\n\t\t\t}\r\n\r\n\t\t\twindow.ShowLoadingDialog();\r\n\t\t\treturn this.orderService.bulkEditorGetCartItemsAsync(core.context.pointOfSaleId, GetCookie(\"accid\"), pageContext.cartId, this.defaultProductCode, this.pageContext.defId)\r\n\t\t\t\t.then(res => {\r\n\t\t\t\t\tres.forEach((item) => {\r\n\t\t\t\t\t\tthis.currentItems.push(item);\r\n\t\t\t\t\t});\r\n\r\n\t\t\t\t\tif (this.currentItems.length > 0)\r\n\t\t\t\t\t\tthis.hadItemsInBasket = true;\r\n\t\t\t\t\tthis.sortAndDisplayItems(this.defaultSortBy, this.defaultSortOrder);\r\n\t\t\t\t\tthis.initApplyAllTitle();\r\n\t\t\t\t\tthis.initBasketButton();\r\n\t\t\t\t\twindow.HideLoadingDialog();\r\n\t\t\t\t});\r\n\t\t}\r\n\r\n\t\tprivate initBasketButton() {\r\n\t\t\tif (this.hadItemsInBasket)\r\n\t\t\t\t$('.content-container .add-prints .button span.label').html(this.pageContext.labelUpdateBasket);\r\n\t\t\t$('.editor-header .add-prints span.label').html(this.pageContext.labelUpdateBasket);\r\n\t\t}\r\n\r\n\t\tprivate openAddDialogAsync = async () => {\r\n\t\t\tthis.importer.openAsync();\r\n\t\t};\r\n\r\n\t\tprivate processSelectedPhotosAsync = async (data: IPhotoImport | null): Promise<void> => {\r\n\t\t\tconst photos = await this.assureSmartphotoPhotosAsync(data);\r\n\t\t\tif (photos.length)\r\n\t\t\t\tthis.addNewItems(photos);\r\n\t\t};\r\n\r\n\t\tprivate assureSmartphotoPhotosAsync = async (data: IPhotoImport | null): Promise<Photo[]> => {\r\n\t\t\tif (!data)\r\n\t\t\t\treturn $.Deferred<Photo[]>().resolve([]).promise();\r\n\r\n\t\t\tconst photos = data.selection;\r\n\t\t\tif (!photos)\r\n\t\t\t\treturn $.Deferred<Photo[]>().resolve([]).promise();\r\n\r\n\t\t\t// photos already eXpress? => no need to convert, just return them\r\n\t\t\tif (data.storeType == StoreType.eXpress)\r\n\t\t\t\treturn $.Deferred<Photo[]>().resolve(photos as Photo[]).promise();\r\n\r\n\r\n\t\t\treturn core.showLoadingDialogAsync(ProgressPopup.createDialogAsync())\r\n\t\t\t\t.then(async $popup => {\r\n\t\t\t\t\tthis.progressPoup = new ProgressPopup($popup);\r\n\r\n\t\t\t\t\tawait this.progressPoup.setProgressDialogContentAsync(this.contentManager, \"Label.UploadProgressDialog.Counter\", photos.length);\r\n\r\n\t\t\t\t\tconst downloadedPhotos = await this.getDownloader(this.progressPoup)\r\n\t\t\t\t\t\t.addToQueueAsync(photos as partners.PartnerPhoto[]);\r\n\r\n\t\t\t\t\treturn [...downloadedPhotos];\r\n\t\t\t\t});\r\n\t\t};\r\n\r\n\t\tprivate getDownloader = (popup: ProgressPopup): Downloader => {\r\n\t\t\treturn new Downloader(new eXpress.services.DownloadService(this.context.apiHostUrl, this.parentProductCategoryCode), \"prints\", popup);\r\n\t\t};\r\n\r\n\t\tprivate addNewItems(photos: ISmartphotoPhoto[]): void {\r\n\t\t\tconst availableProduct = eXpress.utils.findFirstOrError(this.availableProducts, p => p.code === this.defaultProductCode);\r\n\t\t\tthis.formIsDirty = true;\r\n\t\t\tfor (let i = 0; i < photos.length; i++) {\r\n\t\t\t\tconst photo = photos[i];\r\n\t\t\t\tconst cartItem = new CartItem();\r\n\t\t\t\tcartItem.id = photo.fileId;\r\n\t\t\t\tcartItem.photoCounter = this.getFreePhotoCounter(cartItem.id);\r\n\t\t\t\tcartItem.photoId = photo.fileId;\r\n\t\t\t\tcartItem.originalWidth = photo.width;\r\n\t\t\t\tcartItem.originalHeight = photo.height;\r\n\t\t\t\tcartItem.datePictureTaken = photo.dateTaken ? photo.dateTaken : new Date();\r\n\t\t\t\tcartItem.createdForced = new Date();\r\n\t\t\t\tcartItem.fileSize = photo.fileSize;\r\n\t\t\t\tcartItem.originalFileName = photo.originalFilename;\r\n\t\t\t\tcartItem.dateModifiedParent = new Date();\r\n\t\t\t\tcartItem.thumbUrl = photo.thumbUrl;\r\n\t\t\t\tcartItem.mediumUrl = photo.mediumUrl;\r\n\r\n\t\t\t\tcartItem.manipulations = new mediastore.Manipulations();\r\n\t\t\t\tcartItem.manipulations.rotate90 = photo.rotate90;\r\n\t\t\t\tcartItem.manipulations.colorEffect = null;\r\n\t\t\t\tcartItem.manipulations.height = 0;\r\n\t\t\t\tcartItem.manipulations.width = 0;\r\n\t\t\t\tcartItem.manipulations.top = 0;\r\n\t\t\t\tcartItem.manipulations.left = 0;\r\n\r\n\t\t\t\t// Create 1 product for the newly added item\r\n\t\t\t\tcartItem.products = [];\r\n\r\n\t\t\t\tconst product = new CartItemProduct(this.defaultProductCode, this.defaultQuantity);\r\n\t\t\t\tcartItem.products.push(product);\r\n\r\n\t\t\t\t// We add the default options\r\n\t\t\t\tif (this.defaultOptions && this.defaultOptions.length > 0)\r\n\t\t\t\t\tthis.addNewItemAddAvailabeOptions(availableProduct, cartItem, product, this.defaultOptions);\r\n\r\n\t\t\t\tthis.currentItems.push(cartItem);\r\n\r\n\t\t\t\tthis.changeManipulationsForOneItem(cartItem, 'shape', availableProduct.attributesDict['shape']);\r\n\t\t\t}\r\n\r\n\t\t\tthis.sortAndDisplayItems(this.defaultSortBy, this.defaultSortOrder);\r\n\t\t\tconst allitemsAreTheSame = this.initApplyAllTitle();\r\n\t\t\tthis.toggleApplyAll(true);\r\n\r\n\t\t\tthis.showDialogAfterAddedItems(photos.length, availableProduct, allitemsAreTheSame);\r\n\t\t}\r\n\r\n\t\tprivate addNewItemAddAvailabeOptions(availableProduct: Product, item: CartItem, product: CartItemProduct, optionList: string[]) {\r\n\t\t\tconst availablePaper = this.getAvailableOption(availableProduct, 'paper', optionList);\r\n\t\t\tif (availablePaper)\r\n\t\t\t\tproduct.paper = availablePaper;\r\n\t\t\tconst availableBorder = this.getAvailableOption(availableProduct, 'border', optionList);\r\n\t\t\tif (availableBorder)\r\n\t\t\t\tproduct.border = availableBorder;\r\n\t\t\tconst availableColorEffect = this.getAvailableOption(availableProduct, 'coloreffect', optionList);\r\n\t\t\tif (availableColorEffect) {\r\n\t\t\t\tproduct.colorEffect = availableColorEffect;\r\n\t\t\t\t// Special case, thumb needs to change to bw or speia !\r\n\t\t\t\tthis.changeManipulationsForOneItem(item, 'coloreffect', availableColorEffect);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tprivate getAvailableOption(availableProduct: Product, category: string, optionList: string[]) {\r\n\t\t\tconst available = availableProduct.optionsDict[category];\r\n\t\t\tlet result: string | null = null;\r\n\t\t\tif (available && available.length > 0) {\r\n\t\t\t\tavailable.forEach(a => {\r\n\t\t\t\t\tif (optionList.indexOf(a) > -1)\r\n\t\t\t\t\t\tresult = a;\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t\treturn result;\r\n\t\t}\r\n\r\n\t\tprivate showDialogAfterAddedItems(count: number, product: Product, allitemsAreTheSame: boolean) {\r\n\t\t\tif (!product.attributesDict['showinbulk'])\r\n\t\t\t\treturn;\r\n\r\n\t\t\tconst labelFormat = this.translations['format.' + product.attributesDict['format']];\r\n\t\t\tconst labelShape = this.translations['shape.' + product.attributesDict['shape']];\r\n\r\n\t\t\t// Set for options by default but not yet implemented\r\n\t\t\tlet keyPaper = 'paper.default';\r\n\t\t\tlet keyBorder = 'border.default';\r\n\t\t\tlet keyColoreffect = 'coloreffect.default';\r\n\t\t\tif (this.defaultOptions && this.defaultOptions.length > 0) {\r\n\t\t\t\tconst tempPaper = this.getAvailableOption(product, 'paper', this.defaultOptions);\r\n\t\t\t\tif (tempPaper)\r\n\t\t\t\t\tkeyPaper = 'paper.' + tempPaper;\r\n\t\t\t\tconst tempBorder = this.getAvailableOption(product, 'border', this.defaultOptions);\r\n\t\t\t\tif (tempBorder)\r\n\t\t\t\t\tkeyBorder = 'border.' + tempBorder;\r\n\t\t\t\tconst tempColoreffect = this.getAvailableOption(product, 'coloreffect', this.defaultOptions);\r\n\t\t\t\tif (tempColoreffect)\r\n\t\t\t\t\tkeyColoreffect = 'coloreffect.' + tempColoreffect;\r\n\t\t\t}\r\n\r\n\t\t\tconst labelPaper = this.translations[keyPaper];\r\n\t\t\tconst labelBorder = this.translations[keyBorder];\r\n\t\t\tconst labelColorEffect = this.translations[keyColoreffect];\r\n\r\n\t\t\tlet labelWarningAfterAddedItems = '';\r\n\t\t\tif (!allitemsAreTheSame)\r\n\t\t\t\tlabelWarningAfterAddedItems = this.pageContext.labelWarningAfterAddedItems;\r\n\r\n\t\t\twindow.ShowContentDialog({\r\n\t\t\t\taction: 'BulkEditorInfo',\r\n\t\t\t\tlabel: 'ResponsivePrintForm.Import.UploadedPhotos.Info',\r\n\t\t\t\tdialogId: 'infoAfterAdd',\r\n\t\t\t\tokContentKey: 'Label.OkButtonText',\r\n\t\t\t\tcloseOnWrapper: true,\r\n\t\t\t\tforceRefresh: true,\r\n\t\t\t\tdata: {\r\n\t\t\t\t\t'labelFormat': encodeURIComponent(labelFormat),\r\n\t\t\t\t\t'labelShape': encodeURIComponent(labelShape),\r\n\t\t\t\t\t'labelPaper': encodeURIComponent(labelPaper),\r\n\t\t\t\t\t'labelBorder': encodeURIComponent(labelBorder),\r\n\t\t\t\t\t'labelColorEffect': encodeURIComponent(labelColorEffect),\r\n\t\t\t\t\t'count': count,\r\n\t\t\t\t\t'labelWarningAfterAddedItems': encodeURIComponent(labelWarningAfterAddedItems)\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tprivate addNewItemsByPhotoIdsAsync(folderId: string, photoIds: string[], useDeselected: boolean, isSelectAllActive: boolean): JQueryPromise<void> {\r\n\t\t\tif (photoIds.length > 0) {\r\n\t\t\t\tthis.formIsDirty = true;\r\n\t\t\t\treturn core.showLoadingDialogAsync(this.services.storageService.getPhotosAsync(core.context.pointOfSaleId, GetCookie(\"accid\"), folderId, photoIds, useDeselected, isSelectAllActive).then((photos) => {\r\n\t\t\t\t\tthis.addNewItems(photos);\r\n\t\t\t\t}));\r\n\t\t\t}\r\n\r\n\t\t\treturn $.Deferred<void>().resolve().promise();\r\n\t\t}\r\n\r\n\t\tprivate addNewItemsByFolderIdsAsync(folderIds: string[], useDeselected: boolean, limit: number): JQueryPromise<void> {\r\n\t\t\tif (folderIds.length > 0) {\r\n\t\t\t\tthis.formIsDirty = true;\r\n\t\t\t\treturn core.showLoadingDialogAsync(this.services.storageService.getPhotosByFoldersAsync(core.context.pointOfSaleId, GetCookie(\"accid\"), folderIds, useDeselected, limit).then((photos) => {\r\n\t\t\t\t\tthis.addNewItems(photos);\r\n\t\t\t\t}));\r\n\t\t\t}\r\n\r\n\t\t\treturn $.Deferred<void>().resolve().promise();\r\n\t\t}\r\n\r\n\t\tprivate displayItems(): void {\r\n\t\t\tconst $container = $('.prints-editor');\r\n\t\t\tconst printItemContainerForMeasurement = $container.find('.item.print.portrait.add-photo');\r\n\t\t\tconst printItemContainerWidth = printItemContainerForMeasurement.find('div.item-container').outerWidth();\r\n\t\t\tconst printItemMaxSize = parseInt(printItemContainerForMeasurement.find('img').css(\"maxHeight\"), 10);\r\n\r\n\t\t\t$container.detach();\r\n\t\t\tconst $template = $container.find('.item-template');\r\n\r\n\t\t\tfor (let i = 0; i < this.currentItems.length; i++) {\r\n\t\t\t\tconst currentItem = this.currentItems[i];\r\n\t\t\t\tlet $new = $template.clone().show();\r\n\t\t\t\t$new = this.fillOneItem($new, currentItem, printItemContainerWidth, printItemMaxSize);\r\n\t\t\t\t$container.append($new);\r\n\t\t\t}\r\n\t\t\t$('.content .content-container .top-content-container').after($container);\r\n\r\n\t\t\tthis.pageContext.lazyload.update(); // We have changed URLs of images -> reset the lazyloader to reload those\r\n\t\t\tthis.displayTotals();\r\n\t\t}\r\n\r\n\t\tprivate displayTotals(): void {\r\n\t\t\tconst totalOrdered = this.getTotalQuantity();\r\n\r\n\t\t\tlet label = this.pageContext.labelPhotoCount.toString();\r\n\t\t\t$('.photos-amount').html(label.replace('{0}', this.currentItems.length.toString()));\r\n\r\n\t\t\tif (totalOrdered === 1)\r\n\t\t\t\tlabel = this.pageContext.labelPrintsCountOne.toString();\r\n\t\t\telse\r\n\t\t\t\tlabel = this.pageContext.labelPrintsCount.toString();\r\n\t\t\t$('.prints-amount .label-total strong').html(utils.formatString(label, totalOrdered.toString()));\r\n\r\n\t\t\tif (this.currentItems.length > 0) {\r\n\t\t\t\tthis.orderService.GetBulkPriceAsync(this.context.pointOfSaleId,\r\n\t\t\t\t\tthis.context.languageCode,\r\n\t\t\t\t\tthis.currentItems,\r\n\t\t\t\t\tthis.pageContext.promoCode).then((res: any) => {\r\n\t\t\t\t\t\tconst $tooltip = $('.prints-amount .top-info-container');\r\n\t\t\t\t\t\tthis.fillTotalTooltip($tooltip, res.GetBulkPriceResult);\r\n\t\t\t\t\t});\r\n\t\t\t} else {\r\n\t\t\t\tthis.header.find('.technical-price').show().find('.technical-amount').html(\"-\");\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tprivate fillOneItem($html: JQuery, item: CartItem, printItemContainerWidth = 0, printItemMaxSize = 0): JQuery {\r\n\t\t\t// Specify classes & attributes for the top container\r\n\t\t\t$html.attr('id', `bulkItem_${item.photoId}_${item.photoCounter}`);\r\n\t\t\t$html.attr('fileId', item.photoId);\r\n\t\t\t$html.attr('photoCounter', item.photoCounter);\r\n\t\t\t$html.removeClass('item-template').addClass('print');\r\n\r\n\t\t\tthis.refreshOneItem($html, item, printItemContainerWidth, printItemMaxSize);\r\n\r\n\t\t\treturn $html;\r\n\t\t}\r\n\r\n\t\tprivate refreshOneItem($html: JQuery, item: CartItem, printItemContainerWidth = 0, printItemMaxSize = 0, resetImages = true): void {\r\n\t\t\t// Refresh the image\r\n\t\t\t$html.removeClass(\"portrait landscape square\");\r\n\t\t\t$html.addClass(core.mediastore.itemGetOrientation(item));\r\n\r\n\t\t\t$html.toggleClass('warning', !this.checkMinResolution(item));\r\n\r\n\t\t\tconst $imgClient = $html.find('.img-container img.client-manipulation');\r\n\t\t\tconst $img = $html.find('.img-container img.server-rendering');\r\n\t\t\tif (this.getWhiteBorderType(item) !== WhiteBorderType.None) {\r\n\t\t\t\tif (resetImages) {\r\n\t\t\t\t\t$img.attr('src', '');\r\n\t\t\t\t\t$img.attr('data-src', bulkeditor.fillOneItemUrl(item, this.context.ecomApiUrl, this.getWhiteBorderType(item), false, false));\r\n\t\t\t\t\tif (window.LazyLoad) window.LazyLoad.resetStatus($img[0]);\r\n\t\t\t\t\t// also remove classes loaded and enterd sins the library won't do it\r\n\t\t\t\t\t$img[0].classList.remove('entered');\r\n\t\t\t\t\t$img[0].classList.remove('loaded');\r\n\t\t\t\t}\r\n\r\n\t\t\t\t$imgClient.parent().css('display', 'none');\r\n\t\t\t\t$img.css('display', '');\r\n\t\t\t} else {\r\n\t\t\t\tthis.fillOneItemRawUrl($imgClient, item, printItemContainerWidth, printItemMaxSize, resetImages);\r\n\t\t\t\t$img.css('display', 'none');\r\n\t\t\t\t$imgClient.parent().css('display', '');\r\n\t\t\t}\r\n\r\n\t\t\t// Fill the amount data\r\n\t\t\tconst $domAmount = $html.find('.info-wrapper .amount');\r\n\t\t\t$domAmount.html(this.getQuantityForOneItem(item).toString());\r\n\r\n\t\t\t// Fill the format data\r\n\t\t\tif (item.products.length > 1)\r\n\t\t\t\t$html.find('.format-in-tile').html(this.pageContext.labelMultipleFormats);\r\n\t\t\telse {\r\n\t\t\t\tconst availableProduct = eXpress.utils.findFirstOrError(this.availableProducts, p => p.code === item.products[0].productCode);\r\n\t\t\t\tconst labelFormat = this.translations['format.' + availableProduct.attributesDict['format']];\r\n\t\t\t\t$html.find('.format-in-tile').html(labelFormat);\r\n\t\t\t}\r\n\r\n\t\t}\r\n\r\n\t\tprivate checkMinResolution(item: CartItem): boolean {\r\n\t\t\tlet longestSide = item.manipulations.width > item.manipulations.height ? item.manipulations.width : item.manipulations.height;\r\n\t\t\tif (longestSide <= 0)\r\n\t\t\t\tlongestSide = item.originalWidth > item.originalHeight ? item.originalWidth : item.originalHeight;\r\n\r\n\t\t\tlet qualityOk = true;\r\n\t\t\titem.products.forEach(product => {\r\n\t\t\t\tconst actualProduct = eXpress.utils.findFirst(this.availableProducts, p => p.code === product.productCode);\r\n\t\t\t\tif (actualProduct)\r\n\t\t\t\t\tif (parseInt((actualProduct.attributesDict[\"minimumwidth\"] || \"0\"), 10) > longestSide)\r\n\t\t\t\t\t\tqualityOk = false;\r\n\t\t\t});\r\n\t\t\treturn qualityOk;\r\n\t\t}\r\n\r\n\t\tprivate displayOneItem($previousItem: JQuery, item: CartItem): void {\r\n\t\t\tconst $container = $('.prints-editor');\r\n\t\t\tconst $template = $container.find('.item-template');\r\n\t\t\tlet $new = $template.clone().show();\r\n\t\t\t$new = this.fillOneItem($new, item);\r\n\t\t\t$new.insertAfter($previousItem);\r\n\t\t}\r\n\r\n\t\tprivate getWhiteBorderType(item: CartItem): WhiteBorderType {\r\n\t\t\tconst firstProduct = eXpress.utils.findFirst(this.availableProducts, p => p.code === item.products[0].productCode);\r\n\t\t\tif (!firstProduct)\r\n\t\t\t\treturn WhiteBorderType.None;\r\n\r\n\t\t\tif (item.products[0].border === 'printsborderwhite3mm')\r\n\t\t\t\treturn WhiteBorderType.Normal3mm;\r\n\t\t\telse if (firstProduct.attributesDict['printsborder'] && firstProduct.attributesDict['printsborder'].toLowerCase() === 'retro')\r\n\t\t\t\treturn WhiteBorderType.Retro;\r\n\t\t\telse\r\n\t\t\t\treturn WhiteBorderType.None;\r\n\t\t}\r\n\r\n\t\tprivate fillOneItemRawUrl($img: JQuery, item: CartItem, printItemContainerWidth = 0, imageLongest = 0, resetImages = true) {\r\n\t\t\t// Crop in CSS first, then rotation (like the manipulations on server)\r\n\t\t\tlet scaleRatio = 0;\r\n\r\n\t\t\tconst itemManipulationsWidth = item.manipulations.width > 0 ? item.manipulations.width : item.originalWidth;\r\n\t\t\tconst itemManipulationsHeight = item.manipulations.height > 0 ? item.manipulations.height : item.originalHeight;\r\n\r\n\t\t\tconst imageRatio = itemManipulationsWidth / itemManipulationsHeight;\r\n\t\t\tlet imageMediumLongest = 0;\r\n\t\t\tlet imageWidth = 0;\r\n\t\t\tlet imageHeight = 0;\r\n\t\t\tconst $clipImageDiv = $img.parent(\"div.clip-image\");\r\n\r\n\t\t\tif (printItemContainerWidth === 0 || imageLongest === 0) {\r\n\t\t\t\tconst $container = $('.prints-editor');\r\n\t\t\t\tconst printItemContainerForMeasurement = $container.find('.item.print.portrait.add-photo');\r\n\t\t\t\tprintItemContainerWidth = printItemContainerForMeasurement.find('div.item-container').outerWidth() || 0;\r\n\t\t\t\timageLongest = parseInt(printItemContainerForMeasurement.find('img').css(\"maxHeight\"), 10);\r\n\t\t\t}\r\n\r\n\t\t\t// set imageMediumLongest (= dimension of longest side of medium image (= image from server to clip on)\r\n\t\t\tif (imageRatio > 1)\r\n\t\t\t\timageMediumLongest = itemManipulationsWidth;\r\n\t\t\telse\r\n\t\t\t\timageMediumLongest = itemManipulationsHeight;\r\n\r\n\t\t\t// set corresponding scaleRatio\r\n\t\t\tscaleRatio = imageLongest / imageMediumLongest;\r\n\r\n\t\t\t// calculate clipping on medium image\r\n\t\t\tconst clipTop = item.manipulations.top * scaleRatio;\r\n\t\t\tconst clipRight = (item.originalWidth - item.manipulations.left - itemManipulationsWidth) * scaleRatio;\r\n\t\t\tconst clipBottom = (item.originalHeight - item.manipulations.top - itemManipulationsHeight) * scaleRatio;\r\n\t\t\tconst clipLeft = item.manipulations.left * scaleRatio;\r\n\r\n\t\t\t// dimensions of imageDiv = dimensions of manipulated image on screen\r\n\t\t\tif (imageRatio > 1) {\r\n\t\t\t\timageWidth = imageLongest;\r\n\t\t\t\timageHeight = imageLongest / imageRatio;\r\n\t\t\t} else {\r\n\t\t\t\timageWidth = imageLongest * imageRatio;\r\n\t\t\t\timageHeight = imageLongest;\r\n\t\t\t}\r\n\r\n\t\t\t// set clipping css\r\n\t\t\t// Set width and height on clipping div for clipping Bottom and Right\r\n\t\t\t$clipImageDiv.css('width', Math.round(imageWidth).toFixed(0));\r\n\t\t\t$clipImageDiv.css('height', Math.round(imageHeight).toFixed(0));\r\n\t\t\t$clipImageDiv.css('overflow', 'hidden');\r\n\r\n\t\t\t// Set Margin on Image for clipping Top and Left. Syntax Margin(T,R,B,L)\r\n\t\t\t$img.css('width', Math.round(imageWidth + clipLeft + clipRight).toFixed(0));\r\n\t\t\t$img.css('height', Math.round(imageHeight + clipBottom + clipTop).toFixed(0));\r\n\t\t\t$img.css('margin', \"-\" + Math.round(clipTop).toFixed(0) + \"px 0px 0px -\" + Math.round(clipLeft).toFixed(0) + \"px\");\r\n\r\n\t\t\t// Place image on the correct place ...\r\n\t\t\tconst marginToCenter = (printItemContainerWidth - imageWidth) / 2 - 20; // 20px padding on img-wrapper\r\n\t\t\t$clipImageDiv.css('margin', \"0px 0px 0px \" + Math.round(marginToCenter).toFixed(0) + \"px\");\r\n\r\n\t\t\t// Rotate\r\n\t\t\t$clipImageDiv.css('transform', 'rotate(' + item.manipulations.rotate90 + 'deg)');\r\n\t\t\t$clipImageDiv.css('-webkit-transform', 'rotate(' + item.manipulations.rotate90 + 'deg)');\r\n\r\n\t\t\t// ColorEffect needs be be rendered on server ... once\r\n\t\t\tif ((item.manipulations.colorEffect && item.manipulations.colorEffect.toLowerCase() !== 'none')\r\n\t\t\t\t|| item.mediumUrl.toLowerCase().indexOf(\"photohandler.ashx\") > -1\r\n\t\t\t\t|| item.mediumUrl.toLowerCase().indexOf(\"/transforms?\") > -1) {\r\n\t\t\t\titem.mediumUrl = fillOneItemUrl(item, this.context.ecomApiUrl, this.getWhiteBorderType(item));\r\n\t\t\t}\r\n\r\n\t\t\tif (resetImages) {\r\n\t\t\t\t$img.attr('src', '');\r\n\t\t\t\t$img.attr('data-src', item.mediumUrl);\r\n\t\t\t\tif (window.LazyLoad) window.LazyLoad.resetStatus($img[0]);\r\n\t\t\t\t$img[0].classList.remove('entered');\r\n\t\t\t\t$img[0].classList.remove('loaded');\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tprivate fillTotalTooltip($tooltip: JQuery, $result: any) {\r\n\t\t\tconst $list = $('.prints-amount .price-detail-list');\r\n\t\t\tconst $price = this.header.find('.technical-price').show().find('.technical-amount');\r\n\r\n\t\t\t// Update the actual price\r\n\t\t\t$price.html(utils.displayPrice($result.Price.Amount, true, false, this.pageContext));\r\n\r\n\t\t\t// Update the detailed table below the price\r\n\t\t\tconst $container = $list.find('.price-detail-list-container').detach();\r\n\t\t\tconst $template = $container.find('.price-detail-list-template').first().removeClass('product');\r\n\t\t\t$container.empty();\r\n\r\n\t\t\tfor (let i = 0; i < $result.PriceItems.length; i++) {\r\n\t\t\t\tconst $new = $template.clone();\r\n\t\t\t\t$new.find('.price-detail-description').html($result.PriceItems[i].Description);\r\n\t\t\t\t$new.find('.price-detail-calculation').html($result.PriceItems[i].CalculationDescription);\r\n\t\t\t\t$new.find('.price-detail-result').html($result.PriceItems[i].ItemTotal);\r\n\t\t\t\tif ($result.PriceItems[i].Type)\r\n\t\t\t\t\t$new.addClass($result.PriceItems[i].Type);\r\n\t\t\t\t$container.append($new);\r\n\t\t\t}\r\n\r\n\t\t\t$list.append($container);\r\n\t\t}\r\n\r\n\t\t//\t\t\t\tthis.initApplyAllMultiselect($template, $container, this.availableColorEffects, 'coloreffect');\r\n\t\t//this.initApplyAllMultiselect($template, $container, this.availableBorders, 'border');\r\n\t\t//this.initApplyAllMultiselect($template, $container, this.availablePapers, 'paper');\r\n\t\t//this.initApplyAllMultiselect($template, $container, this.availableShapes, 'shape');\r\n\t\t//this.initApplyAllMultiselect($template, $container, this.availableFormats, 'format');\r\n\r\n\t\tprivate fillOneItemTooltip($domItem: JQuery, $tooltip: JQuery) {\r\n\t\t\tconst photoId = $domItem.attr('fileid') || \"\";\r\n\t\t\tconst photoCounter = +($domItem.attr('photocounter') || 0);\r\n\t\t\tconst item = this.getItemByPhotoIdAndCounter(photoId, photoCounter);\r\n\r\n\t\t\tconst firstProduct = eXpress.utils.findFirstOrError(this.availableProducts, p => p.code === item.products[0].productCode);\r\n\r\n\t\t\t// Shape is part of the product, so just display it\r\n\t\t\tif (this.availableShapes.length > 1)\r\n\t\t\t\t$tooltip.find('.tooltip-shape label').html(this.translations['shape.' + firstProduct.attributesDict['shape']]);\r\n\t\t\telse\r\n\t\t\t\t$tooltip.find('table.shape').hide();\r\n\r\n\t\t\t// Paper, border and coloreffect are options that can be on or off\r\n\t\t\tconst paper = item.products[0].paper ? item.products[0].paper : 'default';\r\n\t\t\tconst border = item.products[0].border ? item.products[0].border : 'default';\r\n\t\t\tconst colloreffect = item.products[0].colorEffect ? item.products[0].colorEffect : 'default';\r\n\r\n\t\t\tif (this.availablePapers.length > 1)\r\n\t\t\t\t$tooltip.find('.tooltip-paper label').html(this.translations['paper.' + paper]);\r\n\t\t\telse\r\n\t\t\t\t$tooltip.find('table.paper').hide();\r\n\t\t\tif (this.availableBorders.length > 1)\r\n\t\t\t\t$tooltip.find('.tooltip-border label').html(this.translations['border.' + border]);\r\n\t\t\telse\r\n\t\t\t\t$tooltip.find('table.border').hide();\r\n\t\t\tif (this.availableColorEffects.length > 1)\r\n\t\t\t\t$tooltip.find('.tooltip-coloreffect label').html(this.translations['coloreffect.' + colloreffect]);\r\n\t\t\telse\r\n\t\t\t\t$tooltip.find('table.coloreffect').hide();\r\n\r\n\t\t\t// Format is based on the product, but multiple are possible\r\n\t\t\tconst $template = $tooltip.find('.tooltip-format-template');\r\n\t\t\tconst $container = $template.parent();\r\n\t\t\tconst $parent = $container.parent();\r\n\t\t\t$container.detach();\r\n\t\t\t$container.find('.tooltip-format').not('.tooltip-format-template').remove();\r\n\t\t\tfor (let i = 0; i < item.products.length; i++) {\r\n\t\t\t\tconst product = eXpress.utils.findFirstOrError(this.availableProducts, p => p.code === item.products[i].productCode);\r\n\t\t\t\tconst $new = $template.clone().removeClass('tooltip-format-template').show();\r\n\t\t\t\t$new.find('label').html(item.products[i].quantity + ' x ' + this.translations['format.' + product.attributesDict['format']]);\r\n\t\t\t\t$container.append($new);\r\n\t\t\t}\r\n\t\t\t$parent.append($container);\r\n\t\t}\r\n\r\n\t\tprivate deleteItem($domItem: JQuery): void {\r\n\t\t\tthis.formIsDirty = true;\r\n\r\n\t\t\tconst photoId = $domItem.attr('fileid');\r\n\t\t\tconst photoCounter = $domItem.attr('photocounter');\r\n\r\n\t\t\t// Remove from the list of items\r\n\t\t\teXpress.utils.removeItem(this.currentItems, i => i.photoId === photoId && i.photoCounter.toString() === photoCounter);\r\n\r\n\t\t\t// Remove from the DOM\r\n\t\t\t$domItem.remove();\r\n\r\n\t\t\tthis.displayTotals();\r\n\t\t\tthis.initApplyAllTitle();\r\n\t\t}\r\n\r\n\t\tprivate getItemsByPhotoId(photoId: string): CartItem[] {\r\n\t\t\treturn this.currentItems.filter(item => item.photoId === photoId);\r\n\t\t}\r\n\r\n\t\tprivate getItemByPhotoIdAndCounter(photoId: string, photoCounter: number): CartItem {\r\n\t\t\tconst result = this.currentItems.filter(function (currentItem) {\r\n\t\t\t\tif (currentItem.photoId === photoId && currentItem.photoCounter === photoCounter)\r\n\t\t\t\t\treturn true;\r\n\t\t\t});\r\n\r\n\t\t\tif (result.length === 0)\r\n\t\t\t\tthrow new Error(\"No cart item found by photo id and counter\");\r\n\r\n\t\t\treturn result[0];\r\n\t\t}\r\n\r\n\t\tprivate getProductByAttributes(format: string | null, shape: string | null, border: string | null, colorEffect: string | null, paper: string | null): Product | null {\r\n\t\t\tfor (let i = 0; i < this.availableProducts.length; i++) {\r\n\t\t\t\tconst product = this.availableProducts[i];\r\n\t\t\t\tconst aFormatKVP = eXpress.utils.findFirst(product.attributes, lv => lv.Key === 'format');\r\n\t\t\t\tconst aFormat = aFormatKVP ? aFormatKVP.Value : null;\r\n\t\t\t\tif (format !== aFormat)\r\n\t\t\t\t\tcontinue;\r\n\t\t\t\tconst aShapeKVP = eXpress.utils.findFirst(product.attributes, lv => lv.Key === 'shape');\r\n\t\t\t\tconst aShape = aShapeKVP ? aShapeKVP.Value : null;\r\n\t\t\t\tif (shape !== aShape)\r\n\t\t\t\t\tcontinue;\r\n\t\t\t\tif (border && border !== 'default') {\r\n\t\t\t\t\tconst aBorder = this.getListValueArrayByCode(product.options, 'border');\r\n\t\t\t\t\tif (aBorder === null || aBorder.indexOf(border) < 0)\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t}\r\n\t\t\t\tif (colorEffect && colorEffect !== 'default') {\r\n\t\t\t\t\tconst aColorEffect = this.getListValueArrayByCode(product.options, 'coloreffect');\r\n\t\t\t\t\tif (aColorEffect === null || aColorEffect.indexOf(colorEffect) < 0)\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t}\r\n\t\t\t\tif (paper && paper !== 'default') {\r\n\t\t\t\t\tconst aPaper = this.getListValueArrayByCode(product.options, 'paper');\r\n\t\t\t\t\tif (aPaper === null || aPaper.indexOf(paper) < 0)\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t}\r\n\t\t\t\treturn product;\r\n\t\t\t}\r\n\r\n\t\t\treturn null;\r\n\t\t}\r\n\r\n\t\tprivate getListValueArrayByCode(list: eXpress.core.KeyValuePair<string[]>[], code: string): string[] | null {\r\n\t\t\tif (!list)\r\n\t\t\t\treturn null;\r\n\r\n\t\t\tfor (let i = 0; i < list.length; i++) {\r\n\t\t\t\tif (list[i].Key === code)\r\n\t\t\t\t\treturn list[i].Value;\r\n\t\t\t}\r\n\r\n\t\t\treturn null;\r\n\t\t}\r\n\r\n\t\tprivate getFreePhotoCounter(photoId: string): number {\r\n\t\t\tconst items = this.getItemsByPhotoId(photoId);\r\n\t\t\tlet counter = 0;\r\n\t\t\titems.forEach((item) => {\r\n\t\t\t\tif (item.photoCounter > counter)\r\n\t\t\t\t\tcounter = item.photoCounter;\r\n\t\t\t});\r\n\t\t\tcounter++;\r\n\t\t\treturn counter;\r\n\t\t}\r\n\r\n\t\tprivate copyItem($domItem: JQuery): void {\r\n\t\t\tthis.formIsDirty = true;\r\n\r\n\t\t\tconst photoId = $domItem.attr('fileid') || \"\";\r\n\t\t\tconst photoCounter = $domItem.attr('photocounter');\r\n\r\n\t\t\t// Insert into the list of existing items\r\n\t\t\tconst existing = this.currentItems.filter(currentItem => currentItem.photoId === photoId && currentItem.photoCounter.toString() === photoCounter);\r\n\r\n\t\t\tif (existing.length > 0) {\r\n\t\t\t\tconst itemToAdd = utils.clone(existing[0]);\r\n\t\t\t\titemToAdd.photoCounter = this.getFreePhotoCounter(photoId);\r\n\t\t\t\titemToAdd.id = eXpress.core.emptyGuid;\r\n\t\t\t\tthis.currentItems.push(itemToAdd);\r\n\r\n\t\t\t\t// Insert into the DOM\r\n\t\t\t\tthis.displayOneItem($domItem, itemToAdd);\r\n\r\n\t\t\t\tthis.pageContext.lazyload.update();\r\n\t\t\t}\r\n\r\n\t\t\tthis.displayTotals();\r\n\t\t}\r\n\r\n\t\tprivate deleteAll() {\r\n\t\t\twindow.ShowContentDialog({\r\n\t\t\t\tlabel: 'ResponsivePrintForm.DeleteAllPhotos',\r\n\t\t\t\tokContentKey: 'Label.DeleteButtonText',\r\n\t\t\t\tcancelContentKey: 'Label.KeepButtonText',\r\n\t\t\t\tcssClass: 'rspdialog',\r\n\t\t\t\tdialogId: 'deleteAll',\r\n\t\t\t\tokFunction: () => {\r\n\t\t\t\t\tthis.formIsDirty = true;\r\n\r\n\t\t\t\t\t// in the object\r\n\t\t\t\t\tthis.currentItems = [];\r\n\r\n\t\t\t\t\t// in the DOM\r\n\t\t\t\t\t$('.prints-editor .item').not('.item-template').not('.add-photo').remove();\r\n\r\n\t\t\t\t\t// Reset the totals\r\n\t\t\t\t\tthis.displayTotals();\r\n\r\n\t\t\t\t\tthis.initApplyAllTitle();\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tprivate applyAll(index: string, value: string) {\r\n\t\t\t// ApplyAll has 2 runs: 1 test if I can apply to all, 2 actually apply to all\r\n\r\n\t\t\tlet errorCount = 0;\r\n\t\t\tconst errorList: DisplayList[] = [];\r\n\r\n\t\t\tswitch (index) {\r\n\t\t\t\tcase 'quantity':\r\n\t\t\t\t\terrorCount = 0; // Quantities can always be changed\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'format':\r\n\t\t\t\t\terrorCount = this.applyAllFormat(value, true, errorList);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tdefault:\r\n\t\t\t\t\terrorCount = this.applyAllRest(value, index, true, errorList);\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tif (errorCount === 0) {\r\n\t\t\t\tthis.applyAllConfirmed(index, value);\r\n\t\t\t} else {\r\n\t\t\t\t// There are errors, we list them to the user\r\n\t\t\t\tconst changeTo = this.translations[index + '.' + value];\r\n\r\n\t\t\t\tlet list = '';\r\n\t\t\t\terrorList.forEach((err) => {\r\n\t\t\t\t\tlet label = this.pageContext.labelApplyAllWarningLine;\r\n\t\t\t\t\tlabel = label.replace('{0}', changeTo);\r\n\t\t\t\t\tlabel = label.replace('{1}', err.label);\r\n\t\t\t\t\tlabel = label.replace('{2}', err.quantity.toString());\r\n\t\t\t\t\tlist += label;\r\n\t\t\t\t});\r\n\t\t\t\tconst replacements = `${errorCount}|${this.currentItems.length}|${changeTo}|${list}`;\r\n\r\n\t\t\t\twindow.ShowContentDialog({\r\n\t\t\t\t\tlabel: 'ResponsivePrintForm.ApplyAll.Warning',\r\n\t\t\t\t\tdialogId: 'applyAllWarning',\r\n\t\t\t\t\tokContentKey: 'Label.OkButtonText',\r\n\t\t\t\t\tcancelContentKey: 'Label.CancelButtonText',\r\n\t\t\t\t\tcssClass: 'rspdialog',\r\n\t\t\t\t\treplacements: replacements,\r\n\t\t\t\t\tokFunction: () => {\r\n\t\t\t\t\t\tthis.applyAllConfirmed(index, value);\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\t\t\t}\r\n\r\n\t\t\tthis.pageContext.lazyload.update(); // We have changed URLs of images -> reset the lazyloader to reload those\r\n\t\t\tthis.formIsDirty = true;\r\n\t\t}\r\n\r\n\t\tprivate applyAllConfirmed(index: string, value: string) {\r\n\t\t\tthis.formIsDirty = true;\r\n\t\t\tswitch (index) {\r\n\t\t\t\tcase 'quantity':\r\n\t\t\t\t\tthis.applyAllQuantity(parseInt(value, 10));\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'format':\r\n\t\t\t\t\tthis.applyAllFormat(value, false, null);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tthis.applyAllRest(value, index, false, null);\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tthis.initApplyAllTitle();\r\n\t\t\tthis.displayTotals();\r\n\t\t}\r\n\r\n\t\tprivate applyAllQuantity(value: number) {\r\n\t\t\t// Change the actual items\r\n\t\t\tthis.currentItems.forEach((currentItem) => {\r\n\t\t\t\tcurrentItem.products.forEach((product) => {\r\n\t\t\t\t\tproduct.quantity = value;\r\n\t\t\t\t});\r\n\r\n\t\t\t\t// Change the dom\r\n\t\t\t\tconst id = `bulkItem_${currentItem.photoId}_${currentItem.photoCounter}`;\r\n\r\n\t\t\t\tlet amount = 0;\r\n\t\t\t\tcurrentItem.products.forEach(product => amount += product.quantity);\r\n\t\t\t\t$('.prints-editor .item[id=\"' + id + '\"] .info-wrapper .amount').html(this.getQuantityForOneItem(currentItem).toString());\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tprivate getQuantityForOneItem(item: CartItem, predicate?: (product: CartItemProduct) => boolean): number {\r\n\t\t\tlet total = 0;\r\n\t\t\titem.products.forEach(product => {\r\n\t\t\t\tif (!predicate || predicate(product)) total += product.quantity;\r\n\t\t\t});\r\n\t\t\treturn total;\r\n\t\t}\r\n\r\n\t\tprivate getTotalQuantity(predicate?: (product: CartItemProduct) => boolean): number {\r\n\t\t\tlet total = 0;\r\n\t\t\tthis.currentItems.forEach(item => {\r\n\t\t\t\ttotal += this.getQuantityForOneItem(item, predicate);\r\n\t\t\t});\r\n\t\t\treturn total;\r\n\t\t}\r\n\r\n\t\tprivate applyAllFormat(format: string, dryRun: boolean, errorList: DisplayList[] | null): number {\r\n\t\t\tlet errorCount = 0;\r\n\r\n\t\t\t// Format is a special case, after an apply all, only 1 product should remain with the quantity set to the sum of all formats\r\n\t\t\t// We will keep the first product & remove all others\r\n\t\t\tthis.currentItems.forEach((currentItem) => {\r\n\t\t\t\tif (dryRun)\r\n\t\t\t\t\tcurrentItem.applyAllFailed = false;\r\n\r\n\t\t\t\tconst firstProduct = currentItem.products[0];\r\n\t\t\t\tconst availableProduct = eXpress.utils.findFirstOrError(this.availableProducts, p => p.code === firstProduct.productCode);\r\n\r\n\t\t\t\tconst shapeKVP = eXpress.utils.findFirst(availableProduct.attributes, lv => lv.Key === 'shape');\r\n\t\t\t\tconst shape = shapeKVP ? shapeKVP.Value : null;\r\n\t\t\t\tconst border = firstProduct.border;\r\n\t\t\t\tconst colorEffect = firstProduct.colorEffect;\r\n\t\t\t\tconst paper = firstProduct.paper;\r\n\r\n\t\t\t\tconst newProduct = this.getProductByAttributes(format, shape, border, colorEffect, paper);\r\n\t\t\t\tif (newProduct) {\r\n\t\t\t\t\tif (!dryRun) {\r\n\t\t\t\t\t\tfirstProduct.productCode = newProduct.code;\r\n\t\t\t\t\t\tfirstProduct.quantity = this.getQuantityForOneItem(currentItem);\r\n\r\n\t\t\t\t\t\t// Remove all others\r\n\t\t\t\t\t\tcurrentItem.products.splice(1);\r\n\r\n\t\t\t\t\t\t// Change the DOM\r\n\t\t\t\t\t\tconst id = '#bulkItem_' + currentItem.photoId + '_' + currentItem.photoCounter;\r\n\t\t\t\t\t\tthis.refreshOneItem($(id), currentItem);\r\n\t\t\t\t\t}\r\n\t\t\t\t} else {\r\n\t\t\t\t\terrorCount++;\r\n\t\t\t\t\tcurrentItem.applyAllFailed = true;\r\n\t\t\t\t\tthis.applyAllFindMissingProduct('format', format, shape, border, colorEffect, paper, errorList);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t\treturn errorCount;\r\n\t\t}\r\n\r\n\t\tprivate applyAllFindMissingProduct(whatIsChanging: string, format: string | null, shape: string | null, border: string | null, colorEffect: string | null, paper: string | null, errorList: DisplayList[] | null): void {\r\n\t\t\tlet label: string | null = null;\r\n\r\n\t\t\t// The product we wanted does not exist. This can be:\r\n\t\t\t// 1) Because the format/shape isn't available\r\n\t\t\t// 2) Because the option isn't available: border, colorEffect, paper\r\n\r\n\t\t\tconst product = this.getProductByAttributes(format, shape, null, null, null);\r\n\t\t\tif (whatIsChanging === 'format' || whatIsChanging === 'shape') {\r\n\t\t\t\t// First we check the format\r\n\t\t\t\tif (product === null) {\r\n\t\t\t\t\t// Only happens when changing shape or format !\r\n\t\t\t\t\tif (whatIsChanging === 'format')\r\n\t\t\t\t\t\tlabel = this.translations['shape.' + shape];\r\n\t\t\t\t\telse\r\n\t\t\t\t\t\tlabel = this.translations['format.' + format];\r\n\t\t\t\t} else {\r\n\t\t\t\t\t// It's not the format/shape, so an option must be missing!\r\n\t\t\t\t\tif (border) {\r\n\t\t\t\t\t\tconst aBorder = this.getListValueArrayByCode(product.options, 'border');\r\n\t\t\t\t\t\tif (aBorder === null || aBorder.indexOf(border) < 0)\r\n\t\t\t\t\t\t\tlabel = this.translations['border.' + border];\r\n\t\t\t\t\t} else if (colorEffect) {\r\n\t\t\t\t\t\tconst aColorEffect = this.getListValueArrayByCode(product.options, 'coloreffect');\r\n\t\t\t\t\t\tif (aColorEffect === null || aColorEffect.indexOf(colorEffect) < 0)\r\n\t\t\t\t\t\t\tlabel = this.translations['coloreffect.' + colorEffect];\r\n\t\t\t\t\t} else if (paper) {\r\n\t\t\t\t\t\tconst aPaper = this.getListValueArrayByCode(product.options, 'paper');\r\n\t\t\t\t\t\tif (aPaper === null || (border && aPaper.indexOf(border) < 0))\r\n\t\t\t\t\t\t\tlabel = this.translations['paper.' + paper];\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\t// We know for sure that the option - product combo is missing, report te product\r\n\t\t\t\tlabel = this.translations['format.' + format] + ' - ' + this.translations['shape.' + shape];\r\n\t\t\t}\r\n\r\n\t\t\tif (errorList !== null) {\r\n\t\t\t\tconst existing = eXpress.utils.findFirst(errorList, (err) => err.label === label);\r\n\t\t\t\tif (!existing) {\r\n\t\t\t\t\tconst error = new DisplayList();\r\n\t\t\t\t\terror.label = label;\r\n\t\t\t\t\terror.quantity = 1;\r\n\t\t\t\t\terrorList.push(error);\r\n\t\t\t\t} else\r\n\t\t\t\t\texisting.quantity++;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tprivate applyAllRest(value: string | null, category: string, dryRun: boolean, errorList: DisplayList[] | null): number {\r\n\t\t\tlet errorCount = 0;\r\n\r\n\t\t\t// If value = default we should null it\r\n\t\t\tif (value === 'default')\r\n\t\t\t\tvalue = null;\r\n\r\n\t\t\t// Change the actual items\r\n\t\t\tthis.currentItems.forEach((currentItem) => {\r\n\t\t\t\tif (dryRun)\r\n\t\t\t\t\tcurrentItem.applyAllFailed = false;\r\n\t\t\t\tcurrentItem.products.forEach((product) => {\r\n\t\t\t\t\tconst availableProduct = eXpress.utils.findFirstOrError(this.availableProducts, p => p.code === product.productCode);\r\n\t\t\t\t\tconst formatKVP = eXpress.utils.findFirst(availableProduct.attributes, lv => lv.Key === 'format');\r\n\t\t\t\t\tconst format = category === 'format' ? value : (formatKVP ? formatKVP.Value : null);\r\n\t\t\t\t\tconst shapeKVP = eXpress.utils.findFirst(availableProduct.attributes, lv => lv.Key === 'shape');\r\n\t\t\t\t\tconst shape = category === 'shape' ? value : (shapeKVP ? shapeKVP.Value : null);\r\n\r\n\t\t\t\t\tconst border = (category === 'border' ? value : product.border);\r\n\t\t\t\t\tconst colorEffect = (category === 'coloreffect' ? value : product.colorEffect);\r\n\t\t\t\t\tconst paper = (category === 'paper' ? value : product.paper);\r\n\r\n\t\t\t\t\tconst newProduct = this.getProductByAttributes(format, shape, border, colorEffect, paper);\r\n\t\t\t\t\tif (newProduct) {\r\n\t\t\t\t\t\tif (!dryRun && !currentItem.applyAllFailed) {\r\n\t\t\t\t\t\t\t// Change the item in JS\r\n\t\t\t\t\t\t\tif (category === 'shape') {\r\n\t\t\t\t\t\t\t\t// Shape & format -> product code changes\r\n\t\t\t\t\t\t\t\tproduct.productCode = newProduct.code;\r\n\t\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\t\t// Border coloreffect & paper -> just some options are turned off or on\r\n\t\t\t\t\t\t\t\tswitch (category) {\r\n\t\t\t\t\t\t\t\t\tcase 'border':\r\n\t\t\t\t\t\t\t\t\t\tproduct.border = value;\r\n\t\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t\tcase 'coloreffect':\r\n\t\t\t\t\t\t\t\t\t\tproduct.colorEffect = value;\r\n\t\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t\tcase 'paper':\r\n\t\t\t\t\t\t\t\t\t\tproduct.paper = value;\r\n\t\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t\tdefault:\r\n\t\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tcurrentItem.applyAllFailed = true;\r\n\t\t\t\t\t\tthis.applyAllFindMissingProduct(category, format, shape, border, colorEffect, paper, errorList);\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\r\n\t\t\t\tif (currentItem.applyAllFailed) {\r\n\t\t\t\t\terrorCount++;\r\n\t\t\t\t} else {\r\n\t\t\t\t\tif (!dryRun) {\r\n\t\t\t\t\t\tthis.changeManipulationsForOneItem(currentItem, category, value);\r\n\r\n\t\t\t\t\t\t// Change the DOM\r\n\t\t\t\t\t\tconst id = ('#bulkItem_' + currentItem.photoId + '_' + currentItem.photoCounter);\r\n\t\t\t\t\t\tthis.refreshOneItem($(id), currentItem);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t});\r\n\r\n\t\t\treturn errorCount;\r\n\t\t}\r\n\r\n\t\tprivate changeOptionForOneItem(item: CartItem, category, value) {\r\n\t\t\titem.products.forEach((product) => {\r\n\t\t\t\tswitch (category) {\r\n\t\t\t\t\tcase 'border':\r\n\t\t\t\t\t\tproduct.border = value;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'coloreffect':\r\n\t\t\t\t\t\tproduct.colorEffect = value;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'paper':\r\n\t\t\t\t\t\tproduct.paper = value;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tdefault:\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tprivate changeShapeForOneItem(item: CartItem, shape: string) {\r\n\t\t\titem.products.forEach((product) => {\r\n\t\t\t\tconst currentProduct = eXpress.utils.findFirstOrError(this.availableProducts, p => p.code === product.productCode);\r\n\t\t\t\tconst newProduct = this.getProductByAttributes(currentProduct.attributesDict['format'], shape, item.products[0].border, item.products[0].colorEffect, item.products[0].paper);\r\n\t\t\t\tif (newProduct) {\r\n\t\t\t\t\tproduct.productCode = newProduct.code;\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tprivate changeManipulationsForOneItem(item: CartItem, category, value) {\r\n\t\t\tif (category === 'coloreffect') {\r\n\t\t\t\t// We need to create a manipulations effect\r\n\t\t\t\tswitch (value) {\r\n\t\t\t\t\tcase null:\r\n\t\t\t\t\tcase 'default':\r\n\t\t\t\t\t\titem.manipulations.colorEffect = null;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'printscoloreffectbw':\r\n\t\t\t\t\t\titem.manipulations.colorEffect = 'BlackAndWhite';\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'printscoloreffectsepia':\r\n\t\t\t\t\t\titem.manipulations.colorEffect = 'Sepia';\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tdefault:\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t} else if (category === 'shape') {\r\n\t\t\t\tif (value === 'autosize') {\r\n\t\t\t\t\t// RESET for autosize\r\n\t\t\t\t\titem.manipulations.top = 0;\r\n\t\t\t\t\titem.manipulations.left = 0;\r\n\t\t\t\t\titem.manipulations.width = item.originalWidth;\r\n\t\t\t\t\titem.manipulations.height = item.originalHeight;\r\n\r\n\t\t\t\t\t// We need to recalculate the max crop\r\n\t\t\t\t\tconst firstProduct = eXpress.utils.findFirstOrError(this.availableProducts, p => p.code === item.products[0].productCode);\r\n\t\t\t\t\tconst maxRatio = firstProduct.attributesDict['maximumratio'];\r\n\t\t\t\t\tif (maxRatio) {\r\n\t\t\t\t\t\tlet wantedRatio = parseFloat(maxRatio);\r\n\t\t\t\t\t\tif (wantedRatio > 1)\r\n\t\t\t\t\t\t\twantedRatio = 1 / wantedRatio;\r\n\t\t\t\t\t\tlet currentRatio = (item.manipulations.width > 0 ? item.manipulations.width : item.originalWidth) / (item.manipulations.height > 0 ? item.manipulations.height : item.originalHeight);\r\n\t\t\t\t\t\tif (currentRatio > 1)\r\n\t\t\t\t\t\t\tcurrentRatio = 1 / currentRatio;\r\n\t\t\t\t\t\tif (currentRatio < wantedRatio) {\r\n\t\t\t\t\t\t\tconst newCrop = eXpress.utils.calculateCrop(item.originalWidth, item.originalHeight, wantedRatio);\r\n\t\t\t\t\t\t\titem.manipulations.top = newCrop.Top;\r\n\t\t\t\t\t\t\titem.manipulations.left = newCrop.Left;\r\n\t\t\t\t\t\t\titem.manipulations.width = newCrop.Width;\r\n\t\t\t\t\t\t\titem.manipulations.height = newCrop.Height;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t} else {\r\n\r\n\t\t\t\t\t// We need to recalculate the crop !\r\n\t\t\t\t\tconst wantedRatio = this.calculateWantedRatio(value);\r\n\t\t\t\t\tlet currentRatio = (item.manipulations.width > 0 ? item.manipulations.width : item.originalWidth) / (item.manipulations.height > 0 ? item.manipulations.height : item.originalHeight);\r\n\t\t\t\t\tif (currentRatio > 1)\r\n\t\t\t\t\t\tcurrentRatio = 1 / currentRatio;\r\n\t\t\t\t\t// Don't exact compare ... we are fine with a minor diff\r\n\t\t\t\t\tconst allowedDifference = (wantedRatio === 1) ? 0 : 0.001;\r\n\t\t\t\t\tif (Math.abs(wantedRatio - currentRatio) > allowedDifference) {\r\n\t\t\t\t\t\tconst newCrop = eXpress.utils.calculateCrop(item.originalWidth, item.originalHeight, wantedRatio);\r\n\t\t\t\t\t\titem.manipulations.top = newCrop.Top;\r\n\t\t\t\t\t\titem.manipulations.left = newCrop.Left;\r\n\t\t\t\t\t\titem.manipulations.width = newCrop.Width;\r\n\t\t\t\t\t\titem.manipulations.height = newCrop.Height;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tprivate calculateWantedRatio(shape: string): number {\r\n\t\t\tconst split = shape.split('x');\r\n\t\t\tlet wantedRatio = parseFloat(split[1]) / parseFloat(split[0]);\r\n\t\t\tif (wantedRatio > 1)\r\n\t\t\t\twantedRatio = 1 / wantedRatio;\r\n\t\t\treturn wantedRatio;\r\n\t\t}\r\n\r\n\t\tprivate updateShoppingBasket() {\r\n\t\t\tconst lowResCount = this.countLowResolutionItems();\r\n\t\t\tif (lowResCount > 0) {\r\n\t\t\t\twindow.ShowContentDialog({\r\n\t\t\t\t\tlabel: 'ResponsivePrintForm.ImageQualityMessage',\r\n\t\t\t\t\tokContentKey: 'Label.OkButtonText',\r\n\t\t\t\t\tcancelContentKey: 'Label.CancelButtonText',\r\n\t\t\t\t\tcssClass: 'rspdialog',\r\n\t\t\t\t\treplacements: lowResCount,\r\n\t\t\t\t\tdialogId: 'lowQuality',\r\n\t\t\t\t\tokFunction: () => {\r\n\t\t\t\t\t\tthis.updateShoppingBasketConfirm();\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\t\t\t} else\r\n\t\t\t\tthis.updateShoppingBasketConfirm();\r\n\t\t}\r\n\r\n\t\tprivate updateShoppingBasketConfirm(): void {\r\n\t\t\tcore.showLoadingDialogAsync(this.orderService.bulkEditorUpdateShoppingBasketAsync(core.context.pointOfSaleId,\r\n\t\t\t\tGetCookie(\"accid\"),\r\n\t\t\t\tpageContext.cartId,\r\n\t\t\t\tthis.defaultProductCode,\r\n\t\t\t\tthis.defaultTheme,\r\n\t\t\t\tthis.currentItems,\r\n\t\t\t\tthis.fromcart\r\n\t\t\t).then((res) => {\r\n\t\t\t\tthis.formIsDirty = false;\r\n\t\t\t\tdocument.location.href = res.BulkEditorUpdateShoppingBasketResult;\r\n\t\t\t}));\r\n\t\t}\r\n\r\n\t\tprivate countLowResolutionItems(): number {\r\n\t\t\treturn this.currentItems.filter((item) => {\r\n\t\t\t\treturn !this.checkMinResolution(item);\r\n\t\t\t}).length;\r\n\t\t}\r\n\r\n\t\tprivate toggleApplyAll(forceOpen = false) {\r\n\t\t\tif (forceOpen) {\r\n\t\t\t\t$('.top-content-container').addClass('filters-open');\r\n\t\t\t} else {\r\n\t\t\t\t$('.top-content-container').toggleClass('filters-open');\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tprivate applyFilter($target) {\r\n\t\t\tconst d = $.Deferred();\r\n\r\n\t\t\tsetTimeout(() => {\r\n\t\t\t\tconst $multiselect = $target.closest('.multiselect');\r\n\t\t\t\tthis.applyAll($multiselect.attr('data-code') || \"\", $target.attr('data-code') || \"\");\r\n\t\t\t\tthis.closeAllDropdowns();\r\n\t\t\t\td.resolve();\r\n\t\t\t}, 150); // this is to show the loading dialog first and then the processing begins\r\n\r\n\t\t\treturn d.promise();\r\n\t\t}\r\n\r\n\t\tprivate refreshCurrentItems() {\r\n\t\t\tconst def = $.Deferred();\r\n\r\n\t\t\tsetTimeout(() => {\r\n\t\t\t\tthis.currentItems.forEach((currentItem) => {\r\n\t\t\t\t\tconst id = '#bulkItem_' + currentItem.photoId + '_' + currentItem.photoCounter;\r\n\t\t\t\t\tthis.refreshOneItem($(id), currentItem, 0, 0, false);\r\n\t\t\t\t});\r\n\t\t\t\tdef.resolve();\r\n\t\t\t}, 150);\r\n\r\n\t\t\treturn def.promise();\r\n\t\t}\r\n\r\n\t\tprotected addHandlers(): void {\r\n\t\t\tsuper.addHandlers();\r\n\r\n\t\t\t// Apply all\r\n\t\t\t$('.filter-container').on('click', '.multiselect .selectbox-choices label', (e) => {\r\n\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\te.stopPropagation();\r\n\r\n\t\t\t\t// loadingscreen while waiting\r\n\t\t\t\tcore.showLoadingDialogAsync(this.applyFilter($(e.currentTarget)), this.currentItems.length > 100 ? 0 : 500); // if more then 100 images showloadingdialog direct else after 500ms\r\n\t\t\t});\r\n\r\n\t\t\tlet timeout;\r\n\t\t\t$(window).resize((e) => {\r\n\t\t\t\tif (this.initialScreenWidth === window.outerWidth) return;\r\n\t\t\t\tthis.initialScreenWidth = window.outerWidth;\r\n\r\n\t\t\t\tclearTimeout(timeout);\r\n\t\t\t\ttimeout = setTimeout(() => {\r\n\t\t\t\t\tcore.showLoadingDialogAsync(this.refreshCurrentItems(), this.currentItems.length > 100 ? 0 : 500);\r\n\t\t\t\t}, 250);\r\n\t\t\t});\r\n\r\n\t\t\t$('.edit-all').on('click', (e) => {\r\n\t\t\t\tthis.toggleApplyAll();\r\n\t\t\t});\r\n\r\n\t\t\t$('.minimize-edit').on('click', (e) => {\r\n\t\t\t\tthis.toggleApplyAll();\r\n\t\t\t});\r\n\r\n\t\t\t// Delete button + overlay\r\n\t\t\t$('.content-container').on('click', '.prints-editor .item .icon-delete', (e) => {\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\te.stopPropagation();\r\n\r\n\t\t\t\tconst $target = $(e.currentTarget);\r\n\t\t\t\tconst $item = $target.closest('.item');\r\n\t\t\t\t$item.toggleClass('delete-enabled');\r\n\t\t\t});\r\n\r\n\t\t\t$('.content-container').on('click', '.prints-editor .item .delete-container .secondary', (e) => {\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\te.stopPropagation();\r\n\r\n\t\t\t\tconst $target = $(e.currentTarget);\r\n\t\t\t\tconst $item = $target.closest('.item');\r\n\t\t\t\t$item.toggleClass('delete-enabled');\r\n\t\t\t});\r\n\r\n\t\t\t$('.content-container').on('click', '.prints-editor .item .delete-container .main', (e) => {\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\te.stopPropagation();\r\n\r\n\t\t\t\tconst $target = $(e.currentTarget);\r\n\t\t\t\tconst $item = $target.closest('.item');\r\n\t\t\t\tthis.deleteItem($item);\r\n\t\t\t});\r\n\r\n\t\t\t// Copy button + overlay\r\n\t\t\t$('.content-container').on('click', '.prints-editor .item .icon-copy', (e) => {\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\te.stopPropagation();\r\n\r\n\t\t\t\tconst $target = $(e.currentTarget);\r\n\t\t\t\tconst $item = $target.closest('.item');\r\n\t\t\t\t$item.toggleClass('copy-enabled');\r\n\t\t\t});\r\n\r\n\t\t\t$('.content-container').on('click', '.prints-editor .item .copy-container .secondary', (e) => {\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\te.stopPropagation();\r\n\r\n\t\t\t\tconst $target = $(e.currentTarget);\r\n\t\t\t\tconst $item = $target.closest('.item');\r\n\t\t\t\t$item.toggleClass('copy-enabled');\r\n\t\t\t});\r\n\r\n\t\t\t$('.content-container').on('click', '.prints-editor .item .copy-container .main', (e) => {\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\te.stopPropagation();\r\n\r\n\t\t\t\tconst $target = $(e.currentTarget);\r\n\t\t\t\tconst $item = $target.closest('.item');\r\n\t\t\t\tthis.copyItem($item);\r\n\t\t\t\t$item.toggleClass('copy-enabled');\r\n\t\t\t});\r\n\r\n\t\t\t// The total icon info\r\n\t\t\t$('.content-container').on('click', '.prints-amount .icon-info', (e) => {\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\te.stopPropagation();\r\n\r\n\t\t\t\t// Toggle the clicked one\r\n\t\t\t\tconst $tooltip = $('.prints-amount .top-info-container');\r\n\t\t\t\tif (!$tooltip.hasClass('open')) {\r\n\t\t\t\t\t// Close all others\r\n\t\t\t\t\tthis.closeAllDropdowns();\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (this.currentItems.length > 0)\r\n\t\t\t\t\t$tooltip.toggleClass('open');\r\n\t\t\t});\r\n\r\n\t\t\t$('.content-container').on('click', '.prints-amount .delete-button', (e) => {\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\te.stopPropagation();\r\n\r\n\t\t\t\t// Toggle the clicked one\r\n\t\t\t\tthis.deleteAll();\r\n\t\t\t});\r\n\r\n\t\t\t// The info icon + overlay\r\n\t\t\t$('.content-container').on('click', '.prints-editor .item .info-wrapper .icon-info', (e) => {\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\te.stopPropagation();\r\n\r\n\t\t\t\t// Toggle the clicked one\r\n\t\t\t\tconst $target = $(e.currentTarget);\r\n\t\t\t\tconst $parent = $target.parent();\r\n\t\t\t\tconst $tooltip = $parent.find('.bottom-center');\r\n\t\t\t\tconst $item = $target.closest('.item');\r\n\t\t\t\tif (!$tooltip.hasClass('open')) {\r\n\t\t\t\t\t// Close all others\r\n\t\t\t\t\tthis.closeAllDropdowns();\r\n\t\t\t\t\tthis.fillOneItemTooltip($item, $tooltip);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t$tooltip.toggleClass('open');\r\n\t\t\t});\r\n\r\n\t\t\t$('.content-container').on('click', '.prints-editor .item .info-wrapper .bottom-center', (e) => {\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\te.stopPropagation();\r\n\t\t\t});\r\n\r\n\t\t\t$('.content-container').on('click', '.prints-editor .item .info-wrapper .tooltip .close', (e) => {\r\n\t\t\t\tconst $target = $(e.currentTarget);\r\n\t\t\t\tconst $tooltip = $target.closest('.bottom-center');\r\n\t\t\t\t$tooltip.toggleClass('open');\r\n\t\t\t});\r\n\r\n\t\t\t// Add to shopping basket\r\n\t\t\t$('.technical-to-basket').on('click', (e) => {\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\te.stopPropagation();\r\n\t\t\t\tthis.updateShoppingBasket();\r\n\t\t\t}).show().removeClass(\"u-hide\");\r\n\r\n\t\t\t// Adding photos\r\n\t\t\t$('.content-container').on('click', '.add-photo', async () => {\r\n\t\t\t\tawait this.openAddDialogAsync();\r\n\t\t\t});\r\n\r\n\t\t\t// The edit dialog and all buttons concerning the edit\r\n\t\t\t$('.content-container').on('click', '.prints-editor .item.print:not(.add-photo)', (e) => {\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\te.stopPropagation();\r\n\r\n\t\t\t\tconst $target = $(e.currentTarget);\r\n\t\t\t\tconst $item = $target.closest('.item');\r\n\r\n\t\t\t\tthis.openEditDialog($item);\r\n\t\t\t});\r\n\r\n\t\t\t$('body').on('click', '#ActionDialog .preview-container .action.info, #ActionDialog .panel-container.photo-info-panel', (e) => {\r\n\t\t\t\t$('.dialog-body').toggleClass('panel-open');\r\n\t\t\t});\r\n\r\n\t\t\t// Save & cancel changes\r\n\t\t\t$('body').on('click', '#ActionDialog .exit-button, #ActionDialog .dialog-body .buttons-container button', (e) => {\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\te.stopPropagation();\r\n\r\n\t\t\t\tconst $target = $(e.currentTarget);\r\n\r\n\t\t\t\tconst saveChanges = $target.hasClass('button-check');\r\n\r\n\t\t\t\tthis.closeEditDialog(saveChanges);\r\n\t\t\t});\r\n\r\n\t\t\t// The format tab actual logic\r\n\t\t\t$('body').on('click', '#ActionDialog .tools-container .tool-body.format .counter', (e) => {\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\te.stopPropagation();\r\n\r\n\t\t\t\tconst $target = $(e.currentTarget);\r\n\t\t\t\tconst $format = $target.closest('.format-item');\r\n\t\t\t\tconst format = $format.attr('data-code')!;\r\n\r\n\t\t\t\tconst amount = $target.hasClass('counter-minus') ? -1 : 1;\r\n\r\n\t\t\t\tthis.updateOneItemQuantityPlusMin(this.editItem, format, amount);\r\n\t\t\t});\r\n\r\n\t\t\t// Prevent input other than numbers\r\n\t\t\t$('body').on(\"keypress\", '#ActionDialog .tools-container .tool-body.format .quantity-input', function (event) {\r\n\t\t\t\twindow.PreventInvalidInput($(this), /^[0-9]\\d*$/, event);\r\n\t\t\t});\r\n\r\n\t\t\t// Prevent copy - paste of text, if not a valid number, revert to old value from cartItemProduct\r\n\t\t\t$('body').on('keyup', '#ActionDialog .tools-container .tool-body.format .quantity-input', (e) => {\r\n\t\t\t\tconst $target = $(e.currentTarget);\r\n\t\t\t\tconst $format = $target.closest('.format-item');\r\n\t\t\t\tconst format = $format.attr('data-code')!;\r\n\t\t\t\tconst newValue = +($target.val() || 0);\r\n\r\n\t\t\t\tif (this.validateQuantity(newValue))\r\n\t\t\t\t\tthis.updateOneItemQuantityFixed(this.editItem, format, newValue);\r\n\t\t\t\telse {\r\n\t\t\t\t\tconst filtered = this.editItem.products.filter(e => e.productCode.indexOf(format) >= 0);\r\n\t\t\t\t\tif (!$.isEmptyObject(filtered))\r\n\t\t\t\t\t\t$target.val(filtered[0].quantity);\r\n\t\t\t\t\telse\r\n\t\t\t\t\t\t$target.val(0);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t\t$('body').on('keyup', '#ActionDialog .tools-container .tool-body.format .quantity-input', (e) => {\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\te.stopPropagation();\r\n\r\n\t\t\t\tconst $target = $(e.currentTarget);\r\n\t\t\t\tconst $format = $target.closest('.format-item');\r\n\t\t\t\tconst format = $format.attr('data-code') || '';\r\n\r\n\t\t\t\tconst amount = +($target.val() || 0);\r\n\t\t\t\tthis.updateOneItemQuantityFixed(this.editItem, format, amount);\r\n\r\n\t\t\t});\r\n\r\n\t\t\t// The shape tab actual logic\r\n\t\t\t$('body').on('click', '#ActionDialog .tools-container .tool-body.shape .option-list span.option:not(.active):not(.disabled)', (e) => {\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\te.stopPropagation();\r\n\r\n\t\t\t\tconst $target = $(e.currentTarget);\r\n\t\t\t\tconst shape = $target.attr('data-code') || '';\r\n\r\n\t\t\t\tthis.updateOneItemShape(this.editItem, shape);\r\n\t\t\t});\r\n\r\n\t\t\t// The paper actual logic\r\n\t\t\t$('body').on('click', '#ActionDialog .tools-container .tool-body.finish div.paper .option-list span.option:not(.active):not(.disabled)', (e) => {\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\te.stopPropagation();\r\n\r\n\t\t\t\tconst $target = $(e.currentTarget);\r\n\t\t\t\tconst paper = $target.attr('data-code') || '';\r\n\r\n\t\t\t\tthis.updateOneItemOption(this.editItem, 'paper', paper);\r\n\t\t\t\t// Set to active\r\n\t\t\t\t$('#ActionDialog .tools-container .tool-body.finish div.paper .option-list span').removeClass('active').filter('[data-code=\"' + paper + '\"]').addClass('active');\r\n\t\t\t});\r\n\r\n\t\t\t// The border actual logic\r\n\t\t\t$('body').on('click', '#ActionDialog .tools-container .tool-body.finish div.border .option-list span.option:not(.active):not(.disabled)', (e) => {\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\te.stopPropagation();\r\n\r\n\t\t\t\tconst $target = $(e.currentTarget);\r\n\t\t\t\tconst border = $target.attr('data-code') || '';\r\n\r\n\t\t\t\tthis.updateOneItemOption(this.editItem, 'border', border);\r\n\t\t\t\t// Set to active\r\n\t\t\t\t$('#ActionDialog .tools-container .tool-body.finish div.border .option-list span').removeClass('active').filter('[data-code=\"' + border + '\"]').addClass('active');\r\n\t\t\t});\r\n\r\n\t\t\t$('body').on('click', '#ActionDialog .tools-container .tool-body .option-item h4', (e) => {\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\te.stopPropagation();\r\n\r\n\t\t\t\tconst $target = $(e.currentTarget);\r\n\t\t\t\t$target.closest(\".option-item\").addClass(\"active\");\r\n\t\t\t});\r\n\r\n\t\t\t$('body').on('click', '#ActionDialog .tools-container .tool-body .action-close', (e) => {\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\te.stopPropagation();\r\n\r\n\t\t\t\tconst $target = $(e.currentTarget);\r\n\t\t\t\t$target.closest(\".option-item\").removeClass(\"active\");\r\n\t\t\t});\r\n\r\n\t\t\t// The coloreffect actual logic\r\n\t\t\t$('body').on('click', '#ActionDialog .tools-container .tool-body.effect .option-list div:not(.active):not(.disabled)', (e) => {\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\te.stopPropagation();\r\n\r\n\t\t\t\tconst $target = $(e.currentTarget);\r\n\t\t\t\tconst coloreffect = $target.attr('data-code') || '';\r\n\r\n\t\t\t\tthis.updateOneItemOption(this.editItem, 'coloreffect', coloreffect);\r\n\t\t\t\t// Set to active\r\n\t\t\t\t$('#ActionDialog .tools-container .tool-body.effect .option-list div').removeClass('active').filter('[data-code=\"' + coloreffect + '\"]').addClass('active');\r\n\t\t\t});\r\n\r\n\t\t\t$('body').on('click', '#ActionDialog .tools-container .toolbuttons button:not(.active)', (e) => {\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\te.stopPropagation();\r\n\r\n\t\t\t\tconst $target = $(e.currentTarget);\r\n\t\t\t\tthis.editDialogSwitchTab($target.attr('class') || '');\r\n\t\t\t});\r\n\r\n\t\t\t// The edit tab\r\n\t\t\t$('body').on('click', '#ActionDialog .tools-container .tool-body.edit .rotate-90', (e) => {\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\te.stopPropagation();\r\n\r\n\t\t\t\tconst $target = $(e.currentTarget);\r\n\r\n\t\t\t\tthis.updateOneItemRotate90($target.hasClass('rotate-right') ? 90 : -90);\r\n\t\t\t});\r\n\r\n\t\t\t$('body').on('click', '#ActionDialog .tools-container .tool-body.edit .option-list span:not(.active)', (e) => {\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\te.stopPropagation();\r\n\r\n\t\t\t\tconst $target = $(e.currentTarget);\r\n\r\n\t\t\t\t$('#ActionDialog .tools-container .tool-body.edit .option-list span').removeClass('active');\r\n\t\t\t\t$target.addClass('active');\r\n\r\n\t\t\t\tif ($target.hasClass('crop')) {\r\n\t\t\t\t\tthis.initEditDialogEdit(this.editItem);\r\n\t\t\t\t} else if ($target.hasClass('rotate')) {\r\n\t\t\t\t\tthis.resetCroppingImage(this.editItem);\r\n\t\t\t\t\tthis.initEditDialogRotate90(this.editItem);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tthis.resetCroppingImage(this.editItem);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t\t$('body').on('click', '#ActionDialog .tools-container .tool-body.edit .div-rotate .button-container .action-close', (e) => {\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\te.stopPropagation();\r\n\r\n\t\t\t\t$('#ActionDialog .tools-container .tool-body.edit .div-rotate').removeClass('active');\r\n\t\t\t});\r\n\r\n\t\t\t// sorting\r\n\t\t\tthis.$sorting.on(\"click\", \"label\", (e) => this.sortEvent(e));\r\n\t\t}\r\n\r\n\t\tprivate sortEvent(event: JQuery.ClickEvent) {\r\n\t\t\tconst $label = $(event.currentTarget);\r\n\t\t\tif ($label.hasClass(\"checked\"))\r\n\t\t\t\treturn;\r\n\r\n\t\t\tconst methodChunks = ($label.attr(\"data-sp-filter-tag\") || '').split('-');\r\n\t\t\tconst sortOrder = SortOrder[methodChunks[1]];\r\n\t\t\tconst sortBy = PrintSortBy[methodChunks[0]];\r\n\r\n\t\t\tthis.sortAndDisplayItems(sortBy, sortOrder);\r\n\t\t}\r\n\r\n\t\tprivate openEditDialog($domItem: JQuery) {\r\n\t\t\tthis.closeAllDropdowns();\r\n\t\t\twindow.ShowActionDialog({\r\n\t\t\t\taction: 'BulkEditorEdit',\r\n\t\t\t\tcssClass: \"rspdialog dialog-fullscreen dialog-photo-edit dialog-no-header dialog-no-footer \" + utils.makeCssClass(this.productCategoryGroupCode),\r\n\t\t\t\topenFunction: (e) => {\r\n\t\t\t\t\tconst photoId = $domItem.attr('fileid') || '';\r\n\t\t\t\t\tconst photoCounter = +($domItem.attr('photocounter') || 0);\r\n\t\t\t\t\tconst item = this.getItemByPhotoIdAndCounter(photoId, photoCounter);\r\n\r\n\t\t\t\t\tthis.initEditDialog(item);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tprivate initEditDialog(item: CartItem) {\r\n\t\t\tthis.croppingIsActive = false;\r\n\r\n\t\t\t// Store the current edit item for future actions\r\n\t\t\tthis.editItem = utils.clone(item);\r\n\r\n\t\t\t// Set the URL of the image\r\n\t\t\tconst $previewContainer = $('.preview-container');\r\n\t\t\tconst $img = $previewContainer.find('.img-wrapper img');\r\n\t\t\t$img.attr('src', bulkeditor.fillOneItemUrl(item, this.context.ecomApiUrl, this.getWhiteBorderType(item), false, false));\r\n\r\n\t\t\t// Set the data of the image\r\n\t\t\t$('.photo-title-container').html(item.originalFileName);\r\n\t\t\tconst $panel = $('.photo-info-panel');\r\n\t\t\t$panel.find('.storage-data').hide();\r\n\t\t\t$panel.find('.filename').html(item.originalFileName);\r\n\t\t\tif (item.fileSize) {\r\n\t\t\t\t$panel.find('.filesize').html((Math.round((item.fileSize / 1024) * 100) / 100).toFixed(2) + \"KB\");\r\n\t\t\t\t$panel.find('.filesize').parent().removeClass('u-hide');\r\n\t\t\t} else {\r\n\t\t\t\t$panel.find('.filesize').parent().addClass('u-hide');\r\n\t\t\t}\r\n\r\n\t\t\t$panel.find('.resolution').html(item.originalWidth.toString() + \"x\" + item.originalHeight.toString());\r\n\t\t\t$panel.find('.datetaken').html(item.datePictureTaken.toLocaleDateString() + \"-\" + item.datePictureTaken.toLocaleTimeString());\r\n\r\n\t\t\tif (!this.checkMinResolution(item)) {\r\n\t\t\t\t$previewContainer.find('.warning').show();\r\n\t\t\t}\r\n\r\n\t\t\tconst $buttons = $('.tools-container .toolbuttons');\r\n\t\t\t// Disable some tabs based on availability\r\n\t\t\tif (this.availableShapes.length <= 1)\r\n\t\t\t\t$buttons.find('.shape').hide();\r\n\t\t\tif (this.availablePapers.length <= 1 && this.availableBorders.length <= 1)\r\n\t\t\t\t$buttons.find('.finish').hide();\r\n\t\t\tif (this.availableColorEffects.length <= 1)\r\n\t\t\t\t$buttons.find('.effect').hide();\r\n\r\n\r\n\t\t\t// By default, no tab is selected, on mobile this is OK, but on desktop we want the format tab\r\n\t\t\t$buttons.find('button:visible').first().addClass('active');\r\n\t\t\tif ($('.tools-container .toolbuttons .gallery').is(\":visible\")) {\r\n\t\t\t\tthis.editDialogSetActiveClass('gallery');\r\n\t\t\t} else {\r\n\t\t\t\tthis.initEditDialogFormat(this.editItem);\r\n\t\t\t\tthis.editDialogSetActiveClass('format');\r\n\t\t\t\t$('.tools-container .tool-body.format').show();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tprivate initEditDialogFormat(item: CartItem) {\r\n\t\t\tconst $table = $('.tools-container .tool-body.format table');\r\n\t\t\tconst $container = $table.find('tbody').detach();\r\n\t\t\tconst $template = $container.find('.format-item-template');\r\n\t\t\t$container.find('.format-item').remove(); // Removes all existing ones\r\n\r\n\t\t\tthis.availableFormats.forEach((format) => {\r\n\t\t\t\tconst $new = $template.clone().removeClass('format-item-template').addClass('format-item').show();\r\n\r\n\t\t\t\t$new.find('.size').html(this.translations['format.' + format]);\r\n\r\n\t\t\t\tconst quantity = this.getQuantityForOneItem(item, (product) => {\r\n\t\t\t\t\tconst availableProduct = eXpress.utils.findFirstOrError(this.availableProducts, p => p.code === product.productCode);\r\n\t\t\t\t\treturn (availableProduct.attributesDict['format'] === format);\r\n\t\t\t\t});\r\n\t\t\t\t$new.find('.quantity-input').val(quantity);\r\n\r\n\t\t\t\t$new.attr('data-code', format);\r\n\r\n\t\t\t\t// Mark it as disabled?\r\n\t\t\t\tconst firstProduct = eXpress.utils.findFirstOrError(this.availableProducts, p => p.code === item.products[0].productCode);\r\n\t\t\t\tconst newProduct = this.getProductByAttributes(format, firstProduct.attributesDict['shape'], item.products[0].border, item.products[0].colorEffect, item.products[0].paper);\r\n\t\t\t\tif (!newProduct)\r\n\t\t\t\t\t$new.addClass(\"disabled\");\r\n\r\n\t\t\t\t$container.append($new);\r\n\t\t\t});\r\n\r\n\t\t\t$table.append($container);\r\n\t\t}\r\n\r\n\t\tprivate initEditDialogShape(item: CartItem) {\r\n\t\t\tconst $div = $('.tools-container .tool-body.shape');\r\n\t\t\tconst $container = $div.find('.option-list').detach();\r\n\t\t\tconst $template = $container.find('.shape-item-template');\r\n\t\t\t$container.find('.shape-item').remove(); // Removes all existing ones\r\n\r\n\t\t\tconst firstProduct = eXpress.utils.findFirstOrError(this.availableProducts, p => p.code === item.products[0].productCode);\r\n\t\t\tconst activeShape = firstProduct.attributesDict['shape'];\r\n\t\t\tthis.availableShapes.forEach((shape) => {\r\n\t\t\t\tconst $new = $template.clone().removeClass('shape-item-template').addClass('shape-item').css('display', ''); // Why not show? it will add display: inline and it should be cleared\r\n\r\n\t\t\t\t$new.html(this.translations['shape.' + shape]);\r\n\r\n\t\t\t\t// Mark the active one as active\r\n\t\t\t\tif (shape === activeShape)\r\n\t\t\t\t\t$new.addClass('active');\r\n\t\t\t\t$new.addClass(utils.makeCssClass('shape-' + shape));\r\n\t\t\t\t$new.attr('data-code', shape);\r\n\r\n\t\t\t\t// Mark it as disabled?\r\n\t\t\t\t// All products alternatives should be there\r\n\t\t\t\tlet disabled = false;\r\n\t\t\t\titem.products.forEach((product) => {\r\n\t\t\t\t\tconst availableProduct = eXpress.utils.findFirstOrError(this.availableProducts, p => p.code === product.productCode);\r\n\t\t\t\t\tconst newProduct = this.getProductByAttributes(availableProduct.attributesDict['format'], shape, item.products[0].border, item.products[0].colorEffect, item.products[0].paper);\r\n\t\t\t\t\tif (!newProduct)\r\n\t\t\t\t\t\tdisabled = true;\r\n\t\t\t\t});\r\n\t\t\t\tif (disabled)\r\n\t\t\t\t\t$new.addClass(\"disabled\");\r\n\r\n\t\t\t\t$container.append($new);\r\n\t\t\t});\r\n\r\n\t\t\t$div.append($container);\r\n\t\t}\r\n\r\n\t\tprivate initEditDialogPaperBorderOrColorEffect(item: CartItem, $html: JQuery, category: string, active: string, list: string[]) {\r\n\t\t\tif (list.length === 1) {\r\n\t\t\t\t$html.closest('.option-item').remove();\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tconst $container = $html.find('.option-list').detach();\r\n\t\t\tconst $template = $container.find('.' + category + '-item-template');\r\n\t\t\tconst $close = $container.find('.action-close');\r\n\t\t\t$container.find('.' + category + '-item').remove(); // Removes all existing ones\r\n\r\n\t\t\tlist.forEach((x) => {\r\n\t\t\t\tconst $new = $template.clone().removeClass(category + '-item-template').addClass(category + '-item').css('display', ''); // Why not show? it will add display: inline and it should be cleared\r\n\r\n\t\t\t\tif (category === 'coloreffect')\r\n\t\t\t\t\t$new.append(this.translations[category + '.' + x]);\r\n\t\t\t\telse\r\n\t\t\t\t\t$new.html(this.translations[category + '.' + x]);\r\n\r\n\t\t\t\t// Mark the active one as active\r\n\t\t\t\tif (x === active)\r\n\t\t\t\t\t$new.addClass('active');\r\n\t\t\t\t$new.addClass(utils.makeCssClass(category + '-' + x));\r\n\t\t\t\t$new.attr('data-code', x);\r\n\r\n\t\t\t\t// Mark it as disabled?\r\n\t\t\t\t// All products alternatives should be there (default is always allowed)\r\n\t\t\t\tif (x !== 'default') {\r\n\t\t\t\t\tlet disabled = false;\r\n\t\t\t\t\titem.products.forEach((product) => {\r\n\t\t\t\t\t\tconst availableProduct = eXpress.utils.findFirstOrError(this.availableProducts, p => p.code === product.productCode);\r\n\t\t\t\t\t\tconst border = category === 'border' ? x : item.products[0].border;\r\n\t\t\t\t\t\tconst coloreffect = category === 'coloreffect' ? x : item.products[0].colorEffect;\r\n\t\t\t\t\t\tconst paper = category === 'paper' ? x : item.products[0].paper;\r\n\r\n\t\t\t\t\t\tconst newProduct = this.getProductByAttributes(availableProduct.attributesDict['format'], availableProduct.attributesDict['shape'], border, coloreffect, paper);\r\n\t\t\t\t\t\tif (!newProduct)\r\n\t\t\t\t\t\t\tdisabled = true;\r\n\t\t\t\t\t});\r\n\t\t\t\t\tif (disabled)\r\n\t\t\t\t\t\t$new.addClass(\"disabled\");\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Sometimes, there is a close button, append behind it !\r\n\t\t\t\tif ($close.length > 0)\r\n\t\t\t\t\t$close.before($new);\r\n\t\t\t\telse\r\n\t\t\t\t\t$container.append($new);\r\n\t\t\t});\r\n\r\n\t\t\t$html.append($container);\r\n\t\t}\r\n\r\n\t\tprivate initEditDialogPaper(item: CartItem) {\r\n\t\t\tconst $div = $('.tools-container .tool-body.finish .paper');\r\n\t\t\tconst active = item.products[0].paper ? item.products[0].paper : 'default';\r\n\t\t\tthis.initEditDialogPaperBorderOrColorEffect(item, $div, 'paper', active, this.availablePapers);\r\n\t\t}\r\n\r\n\t\tprivate initEditDialogBorder(item: CartItem) {\r\n\t\t\tconst $div = $('.tools-container .tool-body.finish .border');\r\n\t\t\tconst active = item.products[0].border ? item.products[0].border : 'default';\r\n\t\t\tthis.initEditDialogPaperBorderOrColorEffect(item, $div, 'border', active, this.availableBorders);\r\n\t\t}\r\n\r\n\t\tprivate initEditDialogColorEffect(item: CartItem) {\r\n\t\t\tthis.cropperDestroy();\r\n\t\t\tconst $div = $('.tools-container .tool-body.effect');\r\n\t\t\tconst active = item.products[0].colorEffect ? item.products[0].colorEffect : 'default';\r\n\t\t\tthis.initEditDialogPaperBorderOrColorEffect(item, $div, 'coloreffect', active, this.availableColorEffects);\r\n\t\t}\r\n\r\n\t\tprivate initEditDialogEdit(item: CartItem) {\r\n\t\t\t// Set the URL of the image (no cropping & no white borders !)\r\n\t\t\tconst $img = $('.preview-container .img-wrapper img');\r\n\t\t\t$img.on(\"load\", (e) => {\r\n\t\t\t\tthis.initEditDialogEditContinue();\r\n\t\t\t});\r\n\r\n\t\t\t$img.attr('src', bulkeditor.fillOneItemUrl(item, this.context.ecomApiUrl, this.getWhiteBorderType(item), true, false));\r\n\t\t\tthis.croppingIsActive = true;\r\n\t\t}\r\n\r\n\t\tprivate initEditDialogEditContinue() {\r\n\t\t\t/* tslint:disable:max-line-length */\r\n\t\t\tconst style = $('<style id=\"toRemove\">.dialog-content.dialog-photo-edit .preview-container .img-wrapper .jcrop-holder img { max-height: none; max-width: none; transform: none; } .jcrop-holder{direction:ltr;text-align:left;display:inline-block}.jcrop-vline,.jcrop-hline{background:#fff url(\"Jcrop.gif\");font-size:0;position:absolute}.jcrop-vline{height:100%;width:1px!important}.jcrop-vline.right{right:0}.jcrop-hline{height:1px!important;width:100%}.jcrop-hline.bottom{bottom:0}.jcrop-tracker{height:100%;width:100%;-webkit-tap-highlight-color:transparent;-webkit-touch-callout:none;-webkit-user-select:none}.jcrop-handle{background-color:#333;border:1px #eee solid;width:7px;height:7px;font-size:1px}.jcrop-handle.ord-n{left:50%;margin-left:-4px;margin-top:-4px;top:0}.jcrop-handle.ord-s{bottom:0;left:50%;margin-bottom:-4px;margin-left:-4px}.jcrop-handle.ord-e{margin-right:-4px;margin-top:-4px;right:0;top:50%}.jcrop-handle.ord-w{left:0;margin-left:-4px;margin-top:-4px;top:50%}.jcrop-handle.ord-nw{left:0;margin-left:-4px;margin-top:-4px;top:0}.jcrop-handle.ord-ne{margin-right:-4px;margin-top:-4px;right:0;top:0}.jcrop-handle.ord-se{bottom:0;margin-bottom:-4px;margin-right:-4px;right:0}.jcrop-handle.ord-sw{bottom:0;left:0;margin-bottom:-4px;margin-left:-4px}.jcrop-dragbar.ord-n,.jcrop-dragbar.ord-s{height:7px;width:100%}.jcrop-dragbar.ord-e,.jcrop-dragbar.ord-w{height:100%;width:7px}.jcrop-dragbar.ord-n{margin-top:-4px}.jcrop-dragbar.ord-s{bottom:0;margin-bottom:-4px}.jcrop-dragbar.ord-e{margin-right:-4px;right:0}.jcrop-dragbar.ord-w{margin-left:-4px}.jcrop-light .jcrop-vline,.jcrop-light .jcrop-hline{background:#fff;filter:alpha(opacity=70)!important;opacity:.7!important}.jcrop-light .jcrop-handle{-moz-border-radius:3px;-webkit-border-radius:3px;background-color:#000;border-color:#fff;border-radius:3px}.jcrop-dark .jcrop-vline,.jcrop-dark .jcrop-hline{background:#000;filter:alpha(opacity=70)!important;opacity:.7!important}.jcrop-dark .jcrop-handle{-moz-border-radius:3px;-webkit-border-radius:3px;background-color:#fff;border-color:#000;border-radius:3px}.solid-line .jcrop-vline,.solid-line .jcrop-hline{background:#fff}.jcrop-holder img,img.jcrop-preview{max-width:none}</style>');\r\n\t\t\t/* tslint:disable:max-line-length */\r\n\t\t\t$('html > head').append(style);\r\n\r\n\t\t\tconst $img = $('.preview-container .img-wrapper img');\r\n\t\t\tthis.cropperInit(this.editItem, $img);\r\n\r\n\t\t\t// Set the button to active\r\n\t\t\t$('.tools-container .tool-body.edit .option').removeClass('active').filter('.crop').addClass('active');\r\n\r\n\t\t\t$('#ActionDialog .tools-container .tool-body.edit .div-crop').addClass('active');\r\n\t\t\t$('#ActionDialog .tools-container .tool-body.edit .div-rotate').removeClass('active');\r\n\t\t\t$('#ActionDialog .tools-container .tool-body.edit .div-red-eyes').removeClass('active');\r\n\t\t}\r\n\r\n\t\tprivate initEditDialogRotate90(item: CartItem) {\r\n\t\t\t$('#ActionDialog .tools-container .tool-body.edit .div-crop').removeClass('active');\r\n\t\t\t$('#ActionDialog .tools-container .tool-body.edit .div-rotate').addClass('active');\r\n\t\t\t$('#ActionDialog .tools-container .tool-body.edit .div-red-eyes').removeClass('active');\r\n\t\t}\r\n\r\n\t\tprivate cropperRatio(item: CartItem, $img: JQuery): number {\r\n\t\t\tconst imageWidth = $img.width()!;\r\n\t\t\tlet originalWidth = item.originalWidth;\r\n\t\t\tif (item.manipulations.rotate90 === 90 || item.manipulations.rotate90 === 270)\r\n\t\t\t\toriginalWidth = item.originalHeight;\r\n\r\n\t\t\treturn originalWidth / imageWidth;\r\n\t\t}\r\n\r\n\t\tprivate cropperSelect(item: CartItem, ratio: number): number[] {\r\n\t\t\tlet top = 0;\r\n\t\t\tlet left = 0;\r\n\t\t\tlet width = item.originalWidth;\r\n\t\t\tlet height = item.originalHeight;\r\n\t\t\tif (item.manipulations != null) {\r\n\t\t\t\tif (item.manipulations.top !== 0 || item.manipulations.left !== 0 || item.manipulations.width !== 0 || item.manipulations.height !== 0) {\r\n\t\t\t\t\ttop = item.manipulations.top;\r\n\t\t\t\t\tleft = item.manipulations.left;\r\n\t\t\t\t\twidth = item.manipulations.width;\r\n\t\t\t\t\theight = item.manipulations.height;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tlet originalTopLeftX, originalTopLeftY, originalBottomRightX, originalBottomRightY;\r\n\t\t\tif (item.manipulations == null || item.manipulations.rotate90 === 0) {\r\n\t\t\t\toriginalTopLeftX = left;\r\n\t\t\t\toriginalTopLeftY = top;\r\n\t\t\t\toriginalBottomRightX = width + left;\r\n\t\t\t\toriginalBottomRightY = height + top;\r\n\t\t\t} else if (item.manipulations.rotate90 === 90) {\r\n\t\t\t\toriginalTopLeftX = item.originalHeight - height - top;\r\n\t\t\t\toriginalTopLeftY = left;\r\n\t\t\t\toriginalBottomRightX = item.originalHeight - top;\r\n\t\t\t\toriginalBottomRightY = width + left;\r\n\t\t\t} else if (item.manipulations.rotate90 === 180) {\r\n\t\t\t\toriginalTopLeftX = item.originalWidth - left;\r\n\t\t\t\toriginalTopLeftY = item.originalHeight - height - top;\r\n\t\t\t\toriginalBottomRightX = item.originalWidth - width - left;\r\n\t\t\t\toriginalBottomRightY = item.originalHeight - top;\r\n\t\t\t} else if (item.manipulations.rotate90 === 270) {\r\n\t\t\t\toriginalTopLeftX = top;\r\n\t\t\t\toriginalTopLeftY = item.originalWidth - width - left;\r\n\t\t\t\toriginalBottomRightX = height + top;\r\n\t\t\t\toriginalBottomRightY = item.originalWidth - left;\r\n\t\t\t}\r\n\r\n\t\t\treturn [originalTopLeftX / ratio, originalTopLeftY / ratio, originalBottomRightX / ratio, originalBottomRightY / ratio];\r\n\t\t}\r\n\r\n\t\tprivate cropperInit(item: CartItem, $img: JQuery) {\r\n\r\n\t\t\tconst ratio = this.cropperRatio(item, $img);\r\n\r\n\t\t\tconst firstProduct = eXpress.utils.findFirstOrError(this.availableProducts, p => p.code === item.products[0].productCode);\r\n\t\t\tlet aspectRatio = 0;\r\n\t\t\tlet aspectRatioIsLimit = false;\r\n\t\t\tif (firstProduct.attributesDict['shape'] !== 'autosize') {\r\n\t\t\t\taspectRatio = this.calculateWantedRatio(firstProduct.attributesDict['shape']);\r\n\t\t\t\tif (mediastore.itemGetOrientation(item) === 'landscape')\r\n\t\t\t\t\taspectRatio = 1 / aspectRatio;\r\n\t\t\t} else {\r\n\t\t\t\tif (firstProduct.attributesDict['maximumratio'])\r\n\t\t\t\t\taspectRatio = parseFloat(firstProduct.attributesDict['maximumratio']);\r\n\t\t\t\taspectRatioIsLimit = true;\r\n\t\t\t}\r\n\t\t\tconst initialCrop = this.cropperSelect(item, ratio);\r\n\t\t\tconst options = {\r\n\t\t\t\tonSelect: (data) => {\r\n\t\t\t\t\tthis.cropperSet(data);\r\n\t\t\t\t},\r\n\t\t\t\tminSize: [20, 20],\r\n\t\t\t\tsetSelect: initialCrop,\r\n\t\t\t\taspectRatio: aspectRatio,\r\n\t\t\t\taspectRatioIsLimit: aspectRatioIsLimit,\r\n\t\t\t\tbgColor: \"white\",\r\n\t\t\t\tbgOpacity: 1\r\n\t\t\t};\r\n\r\n\r\n\t\t\t$img.Jcrop(options);\r\n\t\t}\r\n\r\n\t\tprivate cropperSet(cropResult: any) {\r\n\t\t\t// Click outside the crop area\r\n\t\t\tif (cropResult.w === 0 && cropResult.h === 0)\r\n\t\t\t\treturn;\r\n\r\n\t\t\tconst $img = $('#editImage');\r\n\r\n\t\t\tconst ratio = this.cropperRatio(this.editItem, $img);\r\n\r\n\t\t\tif (this.editItem.manipulations == null)\r\n\t\t\t\tthis.editItem.manipulations = new mediastore.Manipulations();\r\n\r\n\r\n\t\t\tif (this.editItem.manipulations.rotate90 === 0) {\r\n\t\t\t\tthis.editItem.manipulations.top = Math.round(cropResult.y * ratio);\r\n\t\t\t\tthis.editItem.manipulations.left = Math.round(cropResult.x * ratio);\r\n\t\t\t\tthis.editItem.manipulations.width = Math.round(cropResult.w * ratio);\r\n\t\t\t\tthis.editItem.manipulations.height = Math.round(cropResult.h * ratio);\r\n\t\t\t} else if (this.editItem.manipulations.rotate90 === 90) {\r\n\t\t\t\tthis.editItem.manipulations.top = this.editItem.originalHeight - Math.round((cropResult.x + cropResult.w) * ratio);\r\n\t\t\t\tthis.editItem.manipulations.left = Math.round(cropResult.y * ratio);\r\n\t\t\t\tthis.editItem.manipulations.width = Math.round(cropResult.h * ratio);\r\n\t\t\t\tthis.editItem.manipulations.height = Math.round(cropResult.w * ratio);\r\n\t\t\t} else if (this.editItem.manipulations.rotate90 === 180) {\r\n\t\t\t\tthis.editItem.manipulations.top = this.editItem.originalHeight - Math.round((cropResult.y + cropResult.h) * ratio);\r\n\t\t\t\tthis.editItem.manipulations.left = this.editItem.originalWidth - Math.round((cropResult.x + cropResult.w) * ratio);\r\n\t\t\t\tthis.editItem.manipulations.width = Math.round(cropResult.w * ratio);\r\n\t\t\t\tthis.editItem.manipulations.height = Math.round(cropResult.h * ratio);\r\n\t\t\t} else if (this.editItem.manipulations.rotate90 === 270) {\r\n\t\t\t\tthis.editItem.manipulations.top = Math.round(cropResult.x * ratio);\r\n\t\t\t\tthis.editItem.manipulations.left = this.editItem.originalWidth - Math.round((cropResult.y + cropResult.h) * ratio);\r\n\t\t\t\tthis.editItem.manipulations.width = Math.round(cropResult.h * ratio);\r\n\t\t\t\tthis.editItem.manipulations.height = Math.round(cropResult.w * ratio);\r\n\t\t\t}\r\n\r\n\t\t\tconst $previewContainer = $('.preview-container');\r\n\t\t\t$previewContainer.find('.warning').toggle(!this.checkMinResolution(this.editItem));\r\n\t\t}\r\n\r\n\t\tprivate cropperDestroy() {\r\n\t\t\tconst $jcropDiv = $(\".jcrop-holder\");\r\n\t\t\tconst $img = $('#editImage');\r\n\r\n\t\t\t$img.unbind('load');\r\n\t\t\tif ($jcropDiv.length > 0) {\r\n\t\t\t\t$jcropDiv.remove();\r\n\t\t\t\t$img.css('display', '');\r\n\t\t\t\t$img.css('visibility', '');\r\n\t\t\t\t$img.css('width', '');\r\n\t\t\t\t$img.css('height', '');\r\n\t\t\t\t$img.removeData('Jcrop');\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tprivate validateQuantity(quantity: number): boolean {\r\n\t\t\tif (isNaN(quantity))\r\n\t\t\t\treturn false;\r\n\t\t\tif (quantity < 0 || quantity > 999)\r\n\t\t\t\treturn false;\r\n\r\n\t\t\treturn true;\r\n\t\t}\r\n\r\n\t\tprivate updateOneItemQuantityPlusMin(item: CartItem, format: string, amount: number) {\r\n\t\t\tif (amount < 0 && this.getQuantityForOneItem(item) + amount <= 0) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tthis.updateOneItemQuantity(item, format, amount, true);\r\n\t\t}\r\n\r\n\t\tprivate updateOneItemQuantityFixed(item: CartItem, format: string, amount: number) {\r\n\t\t\tthis.updateOneItemQuantity(item, format, amount, false);\r\n\t\t}\r\n\r\n\t\tprivate updateOneItemQuantity(item: CartItem, format: string, amount: number, add: boolean) {\r\n\t\t\tthis.formIsDirty = true;\r\n\r\n\t\t\tlet addNewProduct = true;\r\n\t\t\tlet counter = -1;\r\n\t\t\tlet removeProduct = -1;\r\n\t\t\titem.products.forEach((product) => {\r\n\t\t\t\tcounter++;\r\n\t\t\t\tconst availableProduct = eXpress.utils.findFirstOrError(this.availableProducts, p => p.code === product.productCode);\r\n\t\t\t\tif (availableProduct.attributesDict['format'] === format) {\r\n\t\t\t\t\tif (add) {\r\n\t\t\t\t\t\tif (product.quantity + amount <= 999)\r\n\t\t\t\t\t\t\tproduct.quantity += amount;\r\n\t\t\t\t\t} else\r\n\t\t\t\t\t\tproduct.quantity = amount;\r\n\r\n\t\t\t\t\tif (product.quantity <= 0) {\r\n\t\t\t\t\t\t// We need to remove the item but at least 1 should remain !!!\r\n\t\t\t\t\t\tif (this.getQuantityForOneItem(item) > 0)\r\n\t\t\t\t\t\t\tremoveProduct = counter;\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\tproduct.quantity = 1;\r\n\t\t\t\t\t}\r\n\t\t\t\t\taddNewProduct = false;\r\n\r\n\t\t\t\t\t// Update the DOM of the edit dialog\r\n\t\t\t\t\t$('.tools-container .format .format-item[data-code=\"' + format + '\"] .quantity-input').val(product.quantity);\r\n\r\n\t\t\t\t\tconst $previewContainer = $('.preview-container');\r\n\t\t\t\t\t$previewContainer.find('.warning').toggle(!this.checkMinResolution(item));\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t\tif (removeProduct > -1) {\r\n\t\t\t\titem.products.splice(removeProduct, 1);\r\n\t\t\t}\r\n\r\n\t\t\tif (addNewProduct && amount > 0) {\r\n\t\t\t\tconst firstProduct = eXpress.utils.findFirstOrError(this.availableProducts, p => p.code === item.products[0].productCode);\r\n\r\n\t\t\t\tconst newProduct = this.getProductByAttributes(format, firstProduct.attributesDict['shape'], item.products[0].border, item.products[0].colorEffect, item.products[0].paper);\r\n\t\t\t\tif (newProduct != null) {\r\n\t\t\t\t\tconst product = new CartItemProduct(newProduct.code, amount);\r\n\t\t\t\t\tproduct.paper = item.products[0].paper;\r\n\t\t\t\t\tproduct.border = item.products[0].border;\r\n\t\t\t\t\tproduct.colorEffect = item.products[0].colorEffect;\r\n\t\t\t\t\titem.products.push(product);\r\n\r\n\t\t\t\t\t// Update the DOM of the edit dialog\r\n\t\t\t\t\t$('.tools-container .format .format-item[data-code=\"' + format + '\"] .quantity-input').val(product.quantity);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tconst $previewContainer = $('.preview-container');\r\n\t\t\t$previewContainer.find('.warning').toggle(!this.checkMinResolution(item));\r\n\t\t}\r\n\r\n\t\tprivate updateOneItemShape(item: CartItem, shape: string) {\r\n\t\t\tthis.formIsDirty = true;\r\n\r\n\t\t\tthis.changeShapeForOneItem(item, shape);\r\n\t\t\tthis.changeManipulationsForOneItem(item, 'shape', shape);\r\n\r\n\t\t\t// Set to active\r\n\t\t\t$('#ActionDialog .tools-container .tool-body.shape .option-list span').removeClass('active').filter('[data-code=\"' + shape + '\"]').addClass('active');\r\n\r\n\t\t\tconst $previewContainer = $('.preview-container');\r\n\t\t\t$previewContainer.find('.warning').toggle(!this.checkMinResolution(item));\r\n\r\n\t\t\t// Set the URL of the image\r\n\t\t\tconst $img = $previewContainer.find('.img-wrapper img');\r\n\t\t\t$img.attr('src', bulkeditor.fillOneItemUrl(item, this.context.ecomApiUrl, this.getWhiteBorderType(item), false, false));\r\n\t\t}\r\n\r\n\t\tprivate updateOneItemOption(item: CartItem, category: string, value: string) {\r\n\t\t\tthis.formIsDirty = true;\r\n\r\n\t\t\tthis.changeOptionForOneItem(item, category, value);\r\n\t\t\tif (category === 'coloreffect') {\r\n\t\t\t\tthis.changeManipulationsForOneItem(item, 'coloreffect', value);\r\n\t\t\t}\r\n\t\t\tif (category === 'coloreffect' || category === 'border') {\r\n\t\t\t\t// Set the URL of the image\r\n\t\t\t\tconst $previewContainer = $('.preview-container');\r\n\t\t\t\tconst $img = $previewContainer.find('.img-wrapper img');\r\n\t\t\t\t$img.attr('src', bulkeditor.fillOneItemUrl(item, this.context.ecomApiUrl, this.getWhiteBorderType(item), false, false));\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tprivate closeEditDialog(saveChanges: boolean) {\r\n\t\t\tif (saveChanges) {\r\n\t\t\t\t// Replace the existing item with the one coming from the edit dialog\r\n\t\t\t\tconst existing = this.getItemByPhotoIdAndCounter(this.editItem.photoId, this.editItem.photoCounter);\r\n\t\t\t\tconst index = this.currentItems.indexOf(existing);\r\n\t\t\t\tif (index !== -1) {\r\n\t\t\t\t\tthis.currentItems[index] = this.editItem;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Refresh the last edited item DOM\r\n\t\t\t\tconst id = ('#bulkItem_' + this.editItem.photoId + '_' + this.editItem.photoCounter);\r\n\t\t\t\tthis.refreshOneItem($(id), this.editItem);\r\n\t\t\t\tthis.pageContext.lazyload.update();\r\n\r\n\t\t\t\t// Refresh the totals on the overview\r\n\t\t\t\tthis.displayTotals();\r\n\t\t\t}\r\n\r\n\t\t\t// Refresh the apply all titles\r\n\t\t\tthis.initApplyAllTitle();\r\n\r\n\t\t\twindow.CloseResponsiveDialog('ActionDialog');\r\n\t\t}\r\n\r\n\t\tprivate editDialogSetActiveClass(tab: string) {\r\n\t\t\tconst $body = $('.dialog-body');\r\n\t\t\t$body.removeClass('gallery-active format-active shape-active finish-active effect-active edit-active');\r\n\t\t\t$body.addClass(tab + '-active');\r\n\t\t}\r\n\r\n\t\tprivate editDialogSwitchTab(tab: string) {\r\n\t\t\t// close other tabs\r\n\t\t\t$('.tools-container .toolbuttons button').removeClass('active');\r\n\t\t\t$('.tools-container .tool-body').hide();\r\n\r\n\t\t\tthis.editDialogSetActiveClass(tab);\r\n\r\n\t\t\t// init the selected one\r\n\t\t\tswitch (tab) {\r\n\t\t\t\tcase 'format':\r\n\t\t\t\t\tthis.resetCroppingImage(this.editItem);\r\n\t\t\t\t\tthis.initEditDialogFormat(this.editItem);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'shape':\r\n\t\t\t\t\tthis.resetCroppingImage(this.editItem);\r\n\t\t\t\t\tthis.initEditDialogShape(this.editItem);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'finish':\r\n\t\t\t\t\tthis.resetCroppingImage(this.editItem);\r\n\t\t\t\t\tthis.initEditDialogPaper(this.editItem);\r\n\t\t\t\t\tthis.initEditDialogBorder(this.editItem);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'effect':\r\n\t\t\t\t\tthis.resetCroppingImage(this.editItem);\r\n\t\t\t\t\tthis.initEditDialogColorEffect(this.editItem);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'edit':\r\n\t\t\t\t\tthis.initEditDialogEdit(this.editItem);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tthis.resetCroppingImage(this.editItem);\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\t// open the selected one\r\n\t\t\t$('.tools-container .toolbuttons button.' + tab).addClass('active');\r\n\t\t\t$('.tools-container .tool-body.' + tab).show();\r\n\r\n\t\t}\r\n\r\n\t\tprivate resetCroppingImage(item: CartItem) {\r\n\t\t\tif (this.croppingIsActive) {\r\n\t\t\t\t// Set the URL of the image (no cropping & no white borders !)\r\n\t\t\t\tconst $img = $('.preview-container .img-wrapper img');\r\n\t\t\t\t$img.attr('src', bulkeditor.fillOneItemUrl(item, this.context.ecomApiUrl, this.getWhiteBorderType(item), false, false));\r\n\t\t\t\tthis.croppingIsActive = false;\r\n\r\n\t\t\t\tthis.cropperDestroy();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tprivate updateOneItemRotate90(angle: number) {\r\n\t\t\tthis.formIsDirty = true;\r\n\r\n\t\t\tif (this.editItem.manipulations == null)\r\n\t\t\t\tthis.editItem.manipulations = new mediastore.Manipulations();\r\n\r\n\t\t\tlet rotate = this.editItem.manipulations.rotate90;\r\n\t\t\trotate += angle;\r\n\t\t\tif (rotate >= 360) {\r\n\t\t\t\trotate = rotate % 360;\r\n\t\t\t}\r\n\t\t\tif (rotate < 0) {\r\n\t\t\t\trotate += 360;\r\n\t\t\t}\r\n\t\t\tthis.editItem.manipulations.rotate90 = rotate;\r\n\r\n\t\t\tconst $previewContainer = $('.preview-container');\r\n\r\n\t\t\t// Set the URL of the image\r\n\t\t\tconst $img = $previewContainer.find('.img-wrapper img');\r\n\t\t\t$img.attr('src', bulkeditor.fillOneItemUrl(this.editItem, this.context.ecomApiUrl, this.getWhiteBorderType(this.editItem), false, false));\r\n\t\t}\r\n\r\n\t\tprivate initAvailableLists(): void {\r\n\t\t\tthis.availableFormats = [];\r\n\t\t\tthis.availableShapes = [];\r\n\t\t\tthis.availableBorders = [];\r\n\t\t\tthis.availablePapers = [];\r\n\t\t\tthis.availableColorEffects = [];\r\n\r\n\t\t\t// Warning: Options need a default\r\n\t\t\tthis.availableBorders.push('default');\r\n\t\t\tthis.availablePapers.push('default');\r\n\t\t\tthis.availableColorEffects.push('default');\r\n\r\n\t\t\tthis.availableProducts.forEach((product) => {\r\n\t\t\t\tproduct.attributes.forEach((attribute) => {\r\n\t\t\t\t\tconst value = attribute.Value.toLowerCase();\r\n\t\t\t\t\tif (attribute.Key === 'format')\r\n\t\t\t\t\t\tif (this.availableFormats.indexOf(value) < 0)\r\n\t\t\t\t\t\t\tthis.availableFormats.push(value);\r\n\t\t\t\t\tif (attribute.Key === 'shape')\r\n\t\t\t\t\t\tif (this.availableShapes.indexOf(value) < 0) {\r\n\t\t\t\t\t\t\tthis.availableShapes.push(value);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t});\r\n\r\n\t\t\t\tproduct.options.forEach((options) => {\r\n\t\t\t\t\tconst key = options.Key.toLowerCase();\r\n\t\t\t\t\tconst value = options.Value;\r\n\t\t\t\t\tif (key.substr(0, 6) === 'border') {\r\n\t\t\t\t\t\tfor (let i = 0; i < value.length; i++) {\r\n\t\t\t\t\t\t\tif (this.availableBorders.indexOf(value[i].toLowerCase()) < 0)\r\n\t\t\t\t\t\t\t\tthis.availableBorders.push(value[i].toLowerCase());\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t} else if (key.substr(0, 5) === 'paper') {\r\n\t\t\t\t\t\tvalue.forEach(oneValue => {\r\n\t\t\t\t\t\t\tif (this.availablePapers.indexOf(oneValue.toLowerCase()) < 0)\r\n\t\t\t\t\t\t\t\tthis.availablePapers.push(oneValue.toLowerCase());\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t} else if (key.substr(0, 11) === 'coloreffect') {\r\n\t\t\t\t\t\tvalue.forEach(oneValue => {\r\n\t\t\t\t\t\t\tif (this.availableColorEffects.indexOf(oneValue.toLowerCase()) < 0)\r\n\t\t\t\t\t\t\t\tthis.availableColorEffects.push(oneValue.toLowerCase());\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\t\t\t});\r\n\r\n\t\t\t// sort available shapes array like bulksquenceshapes\r\n\t\t\tconst sorting = this.bulkSequenceShapes;\r\n\t\t\tconst knownItems = [] as string[];\r\n\t\t\tlet sorted = [] as string[];\r\n\r\n\t\t\t// Remove duplicates\r\n\t\t\tlet unknownItems = this.availableShapes;\r\n\r\n\t\t\tsorting.forEach(key => {\r\n\t\t\t\tunknownItems = unknownItems.filter(item => {\r\n\t\t\t\t\tif (item === key) {\r\n\t\t\t\t\t\tknownItems.push(item);\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t\t\t// past the 2 arrays together\r\n\t\t\tsorted = knownItems.concat(unknownItems);\r\n\t\t\t// replace the array with the sorted one\r\n\t\t\tthis.availableShapes = sorted;\r\n\t\t\t// Sorting ?\r\n\t\t\tthis.availableFormats.sort((f, g) => {\r\n\t\t\t\treturn (parseInt(f, 10) - parseInt(g, 10));\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tprivate setSelectedSortingInUI(sortBy: PrintSortBy, sortOrder: SortOrder) {\r\n\t\t\tconst method = PrintSortBy[sortBy] + \"-\" + SortOrder[sortOrder];\r\n\t\t\tthis.$sorting.find(\"label\").removeClass(\"checked\");\r\n\t\t\tthis.$sorting.find(\"label[data-sp-filter-tag=\" + method + \"]\").addClass(\"checked\");\r\n\t\t}\r\n\r\n\t\tprivate sortAndDisplayItems(sortBy: PrintSortBy, sortOrder: SortOrder) {\r\n\t\t\tthis.setSelectedSortingInUI(sortBy, sortOrder);\r\n\t\t\tthis.sortItems(sortBy, sortOrder);\r\n\t\t\tthis.clearItems();\r\n\t\t\tthis.displayItems();\r\n\t\t}\r\n\r\n\t\tprivate clearItems() {\r\n\t\t\t$('.prints-editor').find(\".print.item\").not('.add-photo').remove();\r\n\t\t}\r\n\r\n\t\tprivate sortItems(sortBy: PrintSortBy, sortOrder: SortOrder) {\r\n\t\t\tswitch (sortBy) {\r\n\t\t\t\tcase PrintSortBy.DateTaken:\r\n\t\t\t\t\tthis.currentItems = this.currentItems.sort((a, b) => this.compareByDateTaken(a, b));\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase PrintSortBy.Name:\r\n\t\t\t\t\tthis.currentItems = this.currentItems.sort((a, b) => this.compareByName(a, b));\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase PrintSortBy.DateAdded:\r\n\t\t\t\t\tthis.currentItems = this.currentItems.sort((a, b) => this.compareByDateAdded(a, b));\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tif (sortOrder === SortOrder.Descending)\r\n\t\t\t\tthis.currentItems = this.currentItems.reverse();\r\n\t\t}\r\n\r\n\t\tprivate registerNavigateAwayQuestion(): void {\r\n\t\t\t$(window).on('beforeunload', () => this.onBeforeUnload());\r\n\r\n\t\t\t$(document).on(\"click.link\", \"a\", (e: JQueryEventObject) => {\r\n\t\t\t\tif (!this.formIsDirty)\r\n\t\t\t\t\treturn true;\r\n\r\n\t\t\t\tconst $a = $(e.currentTarget);\r\n\t\t\t\tconst href = $a.attr(\"href\")!;\r\n\t\t\t\tconst rel = $a.attr(\"rel\");\r\n\t\t\t\tconst target = $a.attr(\"target\");\r\n\r\n\t\t\t\tif (rel !== 'no' && target !== \"_blank\" && href !== \"#\" && href !== undefined) {\r\n\t\t\t\t\tthis.navigateAwayQuestion(href);\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t} else {\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tprivate onBeforeUnload = () => {\r\n\t\t\tif (!this.formIsDirty)\r\n\t\t\t\treturn;\r\n\r\n\t\t\treturn this.pageContext.labelUnload;\r\n\t\t};\r\n\r\n\t\tprivate navigateAwayQuestion(url: string): void {\r\n\t\t\tlet label = 'ProductEditor.Prints.NavigateAway.Message.AddToCart';\r\n\t\t\tif (this.hadItemsInBasket)\r\n\t\t\t\tlabel = 'ProductEditor.Prints.NavigateAway.Message.UpdateCart';\r\n\r\n\t\t\twindow.ShowContentDialog({\r\n\t\t\t\t'label': label,\r\n\t\t\t\t'dialogId': 'navigateAway',\r\n\t\t\t\t'okContentKey': 'Label.ProductEditor.Prints.NavigateAway.Save',\r\n\t\t\t\t'cancelContentKey': 'Label.ProductEditor.Prints.NavigateAway.Discard',\r\n\t\t\t\t'title': \"Label.ProductEditor.Prints.NavigateAway.Title\",\r\n\t\t\t\t'cssClass': 'notification',\r\n\t\t\t\t'okFunction': () => {\r\n\t\t\t\t\tthis.updateShoppingBasket();\r\n\t\t\t\t},\r\n\t\t\t\t'cancelFunction': () => {\r\n\t\t\t\t\tthis.formIsDirty = false;\r\n\t\t\t\t\twindow.location.href = url;\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\t// comparers\r\n\r\n\t\tprivate compareByName(itemA: CartItem, itemB: CartItem) {\r\n\t\t\tif (itemA.originalFileName.toLowerCase() === itemB.originalFileName.toLowerCase())\r\n\t\t\t\treturn 0;\r\n\r\n\t\t\tif (itemA.originalFileName.toLowerCase() < itemB.originalFileName.toLowerCase())\r\n\t\t\t\treturn -1;\r\n\r\n\t\t\treturn 1;\r\n\t\t}\r\n\r\n\t\tprivate compareByDateTaken(itemA: CartItem, itemB: CartItem) {\r\n\t\t\tif (itemA.datePictureTaken === itemB.datePictureTaken)\r\n\t\t\t\treturn 0;\r\n\r\n\t\t\tif (itemA.datePictureTaken < itemB.datePictureTaken)\r\n\t\t\t\treturn -1;\r\n\r\n\t\t\treturn 1;\r\n\t\t}\r\n\r\n\t\tprivate compareByDateAdded(itemA: CartItem, itemB: CartItem) {\r\n\t\t\tif (itemA.createdForced === itemB.createdForced)\r\n\t\t\t\treturn 0;\r\n\r\n\t\t\tif (itemA.createdForced <\r\n\t\t\t\titemB.createdForced)\r\n\t\t\t\treturn -1;\r\n\r\n\t\t\treturn 1;\r\n\t\t}\r\n\t}\r\n\r\n\tconst services = new eXpress.services.Services(core.context);\r\n\tconst deps = {\r\n\t\torderService: new eXpress.services.OrderService(core.context),\r\n\t\tcontentService: new eXpress.services.ContentService(core.context),\r\n\t\taccountService: new eXpress.services.AccountService(core.context)\r\n\t};\r\n\r\n\tconst app = new BulkEditorApp(deps, services, core.context, pageContext);\r\n\tapp.start();\r\n}\r\n"],"names":["eXpress","core","bulkeditor","PrintSortBy","DisplayList","Product","CartItem","_super","__extends","mediastore","PhotoReference","CartItemProduct","productCode","quantity","this","BulkEditorApp","deps","services","context","pageContext","_this","openAddDialogAsync","__awaiter","importer","openAsync","processSelectedPhotosAsync","data","assureSmartphotoPhotosAsync","photos","_a","sent","length","addNewItems","selection","storeType","StoreType","$","Deferred","resolve","promise","showLoadingDialogAsync","ProgressPopup","createDialogAsync","then","$popup","progressPoup","setProgressDialogContentAsync","contentManager","getDownloader","addToQueueAsync","downloadedPhotos","__spreadArray","popup","Downloader","DownloadService","apiHostUrl","parentProductCategoryCode","onBeforeUnload","formIsDirty","labelUnload","orderService","contentService","accountService","$sorting","enforcedSort","utils","getQueryStringParameter","undefined","enforcedOrder","defaultSortBy","DateAdded","defaultSortOrder","SortOrder","Ascending","setSelectedSortingInUI","oldHeader","header","productCategoryGroupCode","toLowerCase","indexOf","substr","defaultProductCode","defaultTheme","fromcart","defaultOptions","split","defaultQuantity","parseInt","ContentManager","GetCookie","importerDependencies","productCategory","uploadService","storageService","bind","Importer","loginManager","LoginManager","prototype","start","isAuthenticationCheck","initProducts","addHandlers","clear","registerNavigateAwayQuestion","accountType","document","location","reload","removeClass","remove","redirectTo404","window","href","concat","origin","setTimeout","currentItems","bulkEditorGetAllProductsAsync","pointOfSaleId","languageCode","res","translations","convertKeyValuePairToMap","bulkSequenceShapes","availableProducts","products","forEach","availableProduct","attributesDict","attributes","optionsDict","options","initAvailableLists","initApplyAll","initExistingCartItemsPromise","initExistingCartItemsAsync","initExistingMyPhotoItemsPromise","initExistingMyPhotoItemsAsync","when","$container","detach","$template","find","initApplyAllMultiselect","availableColorEffects","availableBorders","availablePapers","availableShapes","availableFormats","append","list","code","$new","clone","addClass","attr","$subContainer","$subTemplate","empty","maxLength","i","$subNew","label","toString","html","prepend","initApplyAllTitle","labelQuantity","labelFormat","labelShape","labelPaper","labelBorder","labelColorEffect","shouldInit","allItemsAreTheSame","item","product","findFirstOrError","p","paper","border","colorEffect","infoLabel","labelMultipleItems","labelApplyAll","replace","strFolderIds","folderids","strPhotoIds","photoids","useDeselected","isSelectAllActive","limit","addNewItemsByPhotoIdsAsync","addNewItemsByFolderIdsAsync","cartId","emptyGuid","defId","ShowLoadingDialog","bulkEditorGetCartItemsAsync","push","hadItemsInBasket","sortAndDisplayItems","initBasketButton","HideLoadingDialog","displayTotals","labelUpdateBasket","photo","cartItem","id","fileId","photoCounter","getFreePhotoCounter","photoId","originalWidth","width","originalHeight","height","datePictureTaken","dateTaken","Date","createdForced","fileSize","originalFileName","originalFilename","dateModifiedParent","thumbUrl","mediumUrl","manipulations","Manipulations","rotate90","top","left","addNewItemAddAvailabeOptions","changeManipulationsForOneItem","allitemsAreTheSame","toggleApplyAll","showDialogAfterAddedItems","optionList","availablePaper","getAvailableOption","availableBorder","availableColorEffect","category","available","result","a","count","keyPaper","keyBorder","keyColoreffect","tempPaper","tempBorder","tempColoreffect","labelWarningAfterAddedItems","ShowContentDialog","action","dialogId","okContentKey","closeOnWrapper","forceRefresh","encodeURIComponent","folderId","photoIds","getPhotosAsync","folderIds","getPhotosByFoldersAsync","displayItems","printItemContainerForMeasurement","printItemContainerWidth","outerWidth","printItemMaxSize","css","currentItem","show","fillOneItem","after","lazyload","update","totalOrdered","getTotalQuantity","labelPhotoCount","labelPrintsCountOne","labelPrintsCount","formatString","GetBulkPriceAsync","promoCode","$tooltip","fillTotalTooltip","GetBulkPriceResult","$html","refreshOneItem","resetImages","itemGetOrientation","toggleClass","checkMinResolution","$imgClient","$img","getWhiteBorderType","WhiteBorderType","None","fillOneItemUrl","ecomApiUrl","LazyLoad","resetStatus","classList","parent","fillOneItemRawUrl","getQuantityForOneItem","labelMultipleFormats","longestSide","qualityOk","actualProduct","findFirst","displayOneItem","$previousItem","insertAfter","firstProduct","Normal3mm","Retro","imageLongest","scaleRatio","itemManipulationsWidth","itemManipulationsHeight","imageRatio","imageWidth","imageHeight","$clipImageDiv","clipTop","clipRight","clipBottom","clipLeft","Math","round","toFixed","marginToCenter","$result","$list","displayPrice","Price","Amount","first","PriceItems","Description","CalculationDescription","ItemTotal","Type","fillOneItemTooltip","$domItem","getItemByPhotoIdAndCounter","hide","colloreffect","$parent","not","this_1","deleteItem","removeItem","getItemsByPhotoId","filter","Error","getProductByAttributes","format","shape","aFormatKVP","lv","Key","Value","aShapeKVP","aBorder","getListValueArrayByCode","aColorEffect","aPaper","items","counter","copyItem","existing","itemToAdd","deleteAll","cancelContentKey","cssClass","okFunction","applyAll","index","value","errorCount","errorList","applyAllFormat","applyAllRest","applyAllConfirmed","changeTo_1","list_1","err","labelApplyAllWarningLine","replacements","applyAllQuantity","amount","predicate","total","dryRun","applyAllFailed","shapeKVP","newProduct","splice","applyAllFindMissingProduct","whatIsChanging","error","formatKVP","changeOptionForOneItem","changeShapeForOneItem","currentProduct","maxRatio","wantedRatio","parseFloat","currentRatio","newCrop","calculateCrop","Top","Left","Width","Height","calculateWantedRatio","allowedDifference","abs","updateShoppingBasket","lowResCount","countLowResolutionItems","updateShoppingBasketConfirm","bulkEditorUpdateShoppingBasketAsync","BulkEditorUpdateShoppingBasketResult","forceOpen","applyFilter","$target","d","$multiselect","closest","closeAllDropdowns","refreshCurrentItems","def","timeout","on","e","preventDefault","stopPropagation","currentTarget","resize","initialScreenWidth","clearTimeout","$item","hasClass","openEditDialog","saveChanges","closeEditDialog","updateOneItemQuantityPlusMin","editItem","event","PreventInvalidInput","newValue","val","validateQuantity","updateOneItemQuantityFixed","filtered","isEmptyObject","updateOneItemShape","updateOneItemOption","coloreffect","editDialogSwitchTab","updateOneItemRotate90","initEditDialogEdit","resetCroppingImage","initEditDialogRotate90","sortEvent","$label","methodChunks","sortOrder","sortBy","ShowActionDialog","makeCssClass","openFunction","initEditDialog","croppingIsActive","$previewContainer","$panel","toLocaleDateString","toLocaleTimeString","$buttons","is","editDialogSetActiveClass","initEditDialogFormat","$table","initEditDialogShape","$div","activeShape","disabled","initEditDialogPaperBorderOrColorEffect","active","$close","x","disabled_1","before","initEditDialogPaper","initEditDialogBorder","initEditDialogColorEffect","cropperDestroy","initEditDialogEditContinue","style","cropperInit","cropperRatio","cropperSelect","ratio","originalTopLeftX","originalTopLeftY","originalBottomRightX","originalBottomRightY","aspectRatio","aspectRatioIsLimit","onSelect","cropperSet","minSize","setSelect","bgColor","bgOpacity","Jcrop","cropResult","w","h","y","toggle","$jcropDiv","unbind","removeData","isNaN","updateOneItemQuantity","add","addNewProduct","removeProduct","CloseResponsiveDialog","tab","$body","angle","rotate","attribute","key","oneValue","sorted","sorting","knownItems","unknownItems","sort","f","g","method","sortItems","clearItems","DateTaken","b","compareByDateTaken","Name","compareByName","compareByDateAdded","Descending","reverse","$a","rel","target","navigateAwayQuestion","url","title","cancelFunction","itemA","itemB","CustomHtmlElementsApp","Services","OrderService","ContentService","AccountService"],"mappings":"IACUA,ygFAAV,SAAUA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