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C,CAAC,CAAC;QACP,CAAC;QAAA,CAAC;IACN,CAAC,EA3Fa,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QA2FnC","file":"dateTimePickerServices.js","sourcesContent":["import * as moment from \"moment\";\nimport * as localisationHelper from \"localisationHelper\";\n\n// Types\nimport Moment = moment.Moment;\n\n// Enums\nimport { DateTimeWorkflowStates } from \"Content/ts/Shared/Controls/DateTime/Services/workflowStates\";\n\n// Models\nimport { TimeConfiguration } from \"Content/ts/Models/Shared/DateTime/timePickerConfiguration\";\nimport { DateTimeConfiguration } from \"Content/ts/Models/Shared/DateTime/dateTimePickerConfiguration\";\nimport { DateConfiguration, DatePickerLibraryEvents } from \"Content/ts/Models/Shared/DateTime/datePickerConfiguration\";\n\nexport const Deps = {\n LocalisationHelper: localisationHelper\n};\n\nexport module DateTimePickerServices {\n export function HasDateConfigurationProvided(configuration: DateTimeConfiguration): boolean {\n return configuration && configuration.DateConfiguration != null && configuration.DateConfiguration != undefined;\n };\n\n export function HasTimeConfigurationProvided(configuration: DateTimeConfiguration): boolean {\n return configuration && configuration.TimeConfiguration != null && configuration.TimeConfiguration != undefined;\n };\n\n export function ConfigureConfigurationProperties(configuration: DateTimeConfiguration): DateTimeConfiguration {\n // Purpose : If the component hasn't been provided the DateConfiguration (might not be needed due to\n // component state), then ensure the date configuration has been newed up in order to stop\n // functionality breaking under the hood.\n if (!configuration.DateConfiguration) {\n configuration.DateConfiguration = {};\n }\n\n // Purpose : If the component hasn't been provided the TimeConfiguration (might not be needed due to\n // component state), then ensure the date configuration has been newed up in order to stop\n // functionality breaking under the hood.\n if (!configuration.TimeConfiguration) {\n configuration.TimeConfiguration = {};\n }\n\n // Purpose : Rather than the library rendering 2 hidden away clear functions, when using 'DateTimeMode' \n // we have 1 button always displayed on the page. Due to this the library's version of clearing\n // a date is hidden by default in this mode.\n if (configuration.ComponentState == DateTimeWorkflowStates.DateTimeMode) {\n configuration.DateConfiguration.AllowClear = false;\n configuration.TimeConfiguration.AllowClear = false;\n }\n\n return configuration;\n };\n\n export function FormatDateTimeComputedRead(value: KnockoutObservable, hasSetProperty: KnockoutObservable, componentState: DateTimeWorkflowStates): Moment {\n if (!value()) {\n return null;\n }\n\n if (componentState == DateTimeWorkflowStates.DateTimeMode) {\n if (hasSetProperty()) {\n return value();\n }\n\n return null;\n }\n\n return value();\n };\n\n export function ConfigureSharedDateTimeMarkup(element: JQuery, value: KnockoutObservable, icon: string, screenReaderText: string,\r\n expectedMomentFormat: string): void {\r\n const dateTimePicker = $(element).data(\"Zebra_DatePicker\") as DatePickerLibraryEvents;\n const elementMarkupOverride =\n `\n ${icon}\n ${screenReaderText}\n `;\n\n element.next().html(elementMarkupOverride);\r\n\r\n value.subscribe((value?: Moment) => {\r\n if (!value) {\r\n // Purpose : The date/time can be cleared out by other means not connected to Zebra (e.g. Clear Filter in a Search UI)\r\n // so this ensures the value is cleared from the picker too.\r\n dateTimePicker.clear_date();\r\n } else {\r\n // Purpose : The date/time can be updated by other means not connected to Zebra (e.g. Online Ticketing Next Session Date)\r\n // so this ensures the value is updated in the picker too.\r\n dateTimePicker.set_date(value.format(expectedMomentFormat))\r\n }\r\n });\n\n ConfigureDateTimeResizeEvents(element, dateTimePicker);\n };\n\n // Purpose : There seems to be an issue with Zebra calculating the 'top' position when handling modals. Tried a number of \n // fixes to address this problem but to no avail and cannot determine if it's Knockout/RequireJS rendering issue \n // or something embedded into Bootstrap.For now this seems to the the best solution which won't take days to resolve\n function ConfigureDateTimeResizeEvents(element: JQuery, dateTimePicker: DatePickerLibraryEvents): void {\n const parentWithModal =\n element.parents(\".modal-body\")[0];\n if (parentWithModal != null && parentWithModal != undefined) {\n element.next().css(\"top\", 8.5);\n }\n\n $(window).resize(() => {\n dateTimePicker.update();\n });\r\n };\n}"]}