{"version":3,"file":"bulkeditor.min.js","sources":["bulkeditor.ts"],"sourcesContent":["/// \r\nnamespace eXpress {\r\n\texport function getUsedPhotoIds() {\r\n\t\treturn eXpress.core.bulkeditor.getUsedPhotoIds();\r\n\t}\r\n\texport function getUsedPhotoNames() {\r\n\t\treturn eXpress.core.bulkeditor.getUsedPhotoNames();\r\n\t}\r\n}\r\nnamespace eXpress.core.bulkeditor {\r\n\timport UploadService = eXpress.services.UploadService;\r\n\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[];\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[];\r\n\t\tpublic attributesDict: eXpress.core.Map;\r\n\t\tpublic readonly options: eXpress.core.KeyValuePair[];\r\n\t\tpublic optionsDict: eXpress.core.Map;\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;\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\tstorageService: this.services.storageService,\r\n\t\t\t\tprocessSelectedPhotosAsync: this.processSelectedPhotosAsync.bind(this),\r\n\t\t\t\tuploadService: this.services.uploadService\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 getUsedPhotoIds(): string[] {\r\n\t\t\treturn this.currentItems.map(x => x.photoId);\r\n\t\t}\r\n\r\n\t\tpublic getUsedPhotoNames(): string[] {\r\n\t\t\treturn this.currentItems.map(x => x.originalFileName);\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 {\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 = ' ';\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 = ' ';\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 = ' ';\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 = ' ';\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 = ' ';\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 = ' ';\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 {\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().resolve().promise();\r\n\t\t}\r\n\r\n\t\tprivate initExistingCartItemsAsync(): JQueryPromise {\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().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 => {\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 => {\r\n\t\t\tif (!data)\r\n\t\t\t\treturn $.Deferred().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().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().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\t\t\t\t\tconst token = await eXpress.services.getToken();\r\n\t\t\t\t\tconst downloadedPhotos = await this.getDownloader(token, 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 = (token: string, popup: ProgressPopup): Downloader => {\r\n\t\t\treturn new Downloader(new eXpress.services.DownloadService(token, this.context.ecomApiUrl, 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 {\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().resolve().promise();\r\n\t\t}\r\n\r\n\t\tprivate addNewItemsByFolderIdsAsync(folderIds: string[], useDeselected: boolean, limit: number): JQueryPromise {\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().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[], 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\tif (value == 'default')\r\n\t\t\t\tvalue = null;\r\n\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 = $('');\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\texport function getUsedPhotoIds(): string[] {\r\n\t\treturn app.getUsedPhotoIds();\r\n\t}\r\n\r\n\texport function getUsedPhotoNames(): string[] {\r\n\t\treturn app.getUsedPhotoNames();\r\n\t}\r\n}\r\n"],"names":["eXpress","getUsedPhotoIds","core","bulkeditor","getUsedPhotoNames","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","getToken","token","getDownloader","addToQueueAsync","downloadedPhotos","__spreadArray","popup","Downloader","DownloadService","ecomApiUrl","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","storageService","bind","uploadService","Importer","loginManager","LoginManager","prototype","currentItems","map","x","photoId","originalFileName","start","isAuthenticationCheck","initProducts","addHandlers","clear","registerNavigateAwayQuestion","accountType","document","location","reload","removeClass","remove","redirectTo404","window","href","concat","origin","setTimeout","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","originalWidth","width","originalHeight","height","datePictureTaken","dateTaken","Date","createdForced","fileSize","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","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","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","app","OrderService","ContentService","AccountService"],"mappings":"IACUA,ygFAAV,SAAUA,SACOA,QAAAC,gBAAhB,SAAgBA,kBACf,OAAOD,QAAQE,KAAKC,WAAWF,iBAC/B,EACeD,QAAAI,kBAAhB,SAAgBA,oBACf,OAAOJ,QAAQE,KAAKC,WAAWC,mBAC/B,CACD,CAPD,CAAUJ,UAAAA,QAOT,CAAA,IACD,SAAUA,SAAQ,IAAAE,MAAK,SAAAC,YAGtB,IAAKE,aAAL,SAAKA,aACJA,YAAAA,YAAA,UAAA,GAAA,YACAA,YAAAA,YAAA,UAAA,GAAA,YACAA,YAAAA,YAAA,KAAA,GAAA,MACA,CAJD,CAAKA,cAAAA,YAIJ,CAAA,IAQD,IAAAC,YAAA,SAAAA,cAGC,EAHYH,WAAAG,wBAWb,IAAAC,QAAA,SAAAA,UAMC,EANYJ,WAAAI,gBAQb,IAAAC,SAAA,SAAAC,QAAA,SAAAD,mEAcC,CAAD,OAd8BE,UAA8BF,SAAAC,QAc3DD,QAAA,CAdD,CAA8BN,KAAKS,WAAWC,gBAAjCT,WAAAK,kBAgBb,IAAAK,gBACC,SAAYA,gBAAAC,YAAqBC,UAChCC,KAAKF,YAAcA,YACnBE,KAAKD,SAAWA,QAChB,EAJWZ,WAAAU,gCAcb,IAAAI,cAAA,SAAAR,QA+CC,SAAAQ,cAAYC,KAA+BC,SAAqCC,QAA2BC,aAA3G,IAAAC,MACCb,mBAuDAO,KA+POM,MAAAC,mBAAqB,WAAA,OAAAC,UAAAF,WAAA,OAAA,GAAA,wDAC5BN,KAAKS,SAASC,uBAGPJ,MAA0BK,2BAAG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