PageSourceSearch

https://shop.zoo.dk/assets/standard-shop/scripts/security-2f1237d60075f2eac6907473c449e837.js

js zoo.dk collected 2026-09-24 20:53:22 UTC 4,734 bytes, 228 lines download raw bytes

1/* global common, modal */
2/* exported security */
3
4/**
5 * Methods related to log in and customer account.
6 */
7const security = {
8
9	/**
10	 * Return to this URL after successful login or creation.
11	 *
12	 * @var {string}
13	 */
14	returnTo: '',
15
16	/**
17	 * Show a "login or create account"-modal.
18	 *
19	 * @returns {JQuery}
20	 */
21	showLoginOrCreateAccount: function() {
22		return modal.create('login_or_create_account', {
23			url: '/security/loginOrCreateAccount',
24			buttons: ['security.button.show_login_primary', 'security.button.show_create_account_primary']
25		});
26	},
27
28	/**
29	 * Create the "login"-modal (without showing it).
30	 *
31	 * @returns {JQuery}
32	 */
33	createLoginModal: function() {
34		return modal.create('login', {
35			url: '/security/login',
36			data: {
37				returnTo: this.returnTo
38			},
39			buttons: ['security.button.show_request_reset_password', 'button.cancel', 'button.login_submit'],
40			focus: true,
41			reload: false,
42			show: false
43		});
44	},
45
46	/**
47	 * Show the login form modal.
48	 */
49	showLogin: function() {
50		modal.show(this.createLoginModal());
51	},
52
53	/**
54	 * Submit the login form.
55	 *
56	 * @param {HTMLFormElement} form
57	 */
58	submitLogin: function(form) {
59		if (form.reportValidity() === false) {
60			return;
61		}
62		common.ajaxFormSubmitter({
63			form: form
64		});
65	},
66
67	/**
68	 * Submit the "request reset password"-form.
69	 *
70	 * @param {HTMLFormElement} form
71	 */
72	submitRequestResetPassword: function(form) {
73		if (form.reportValidity() === false) {
74			return;
75		}
76		common.ajaxFormSubmitter({
77			form: form,
78			success: function(response) {
79				modal.hide(form);
80			},
81			notSuccess: function(response) {
82				if (response.content !== null) {
83					modal.get(form).find('.modal-body').html(response.content);
84				}
85			}
86		});
87	},
88
89	/**
90	 * Create the "create account"-modal (without showing it).
91	 *
92	 * @returns {JQuery}
93	 */
94	createCreateAccount: function() {
95		return modal.create('createAccount', {
96			url: '/security/createAccount',
97			data: {
98				returnTo: this.returnTo
99			},
100			buttons: ['button.cancel', 'button.create_submit'],
101			focus: true,
102			reload: true,
103			show: false
104		});
105	},
106
107	/**
108	 * Show the create account modal.
109	 */
110	showCreateAccount: function() {
111		modal.show(this.createCreateAccount());
112	},
113
114	/**
115	 * Submit the "create account"-form.
116	 *
117	 * @param {HTMLFormElement} form
118	 */
119	submitCreateAccount: function(form) {
120		if (form.reportValidity() === false) {
121			return;
122		}
123		common.ajaxFormSubmitter({
124			form: form,
125			success: function(response) {
126				if (response.data.validationRequired) {
127					modal.hide('#createAccount', function() {
128						modal.createAlert({
129							body: response.content
130						});
131					});
132				}
133			}
134		});
135	},
136
137	/**
138	 * Create the "request reset password"-modal (without showing it).
139	 *
140	 * @param {string} [username]
141	 * @returns {JQuery}
142	 */
143	createRequestResetPassword: function(username) {
144		return modal.create('requestResetPassword', {
145			url: '/security/requestResetPassword',
146			data: {
147				username: username
148			},
149			buttons: ['security.button.show_login', 'button.cancel', 'button.send_submit'],
150			focus: true,
151			reload: false,
152			show: false
153		});
154	},
155
156	/**
157	 * Show the "request reset password" modal.
158	 *
159	 * @param {string} [username]
160	 */
161	showRequestResetPassword: function(username) {
162		modal.show(this.createRequestResetPassword(username));
163	},
164
165	/**
166	 * Hide the current modal and show the "login"-modal.
167	 */
168	toggleToLogin: function() {
169		modal.toggleTo(this.createLoginModal());
170	},
171
172	/**
173	 * Hide the current modal and show the "create account"-modal.
174	 */
175	toggleToCreateAccount: function() {
176		modal.toggleTo(this.createCreateAccount());
177	},
178
179	/**
180	 * Hide the current modal and show the "request reset password"-modal.
181	 */
182	toggleToRequestResetPassword: function() {
183		modal.toggleTo(this.createRequestResetPassword());
184	},
185
186	/**
187	 * Handle form for transferring orders from an auto-generated customer to a regular customer.
188	 *
189	 * @param {HTMLFormElement} form
190	 */
191	submitTransferOrder: function(form) {
192		if ( ! form.reportValidity()) {
193			return;
194		}
195		common.ajaxFormSubmitter({
196			form: form,
197			success: function() {
198				$('#transfer-order-container').remove();
199				$('#transfer-order-success').show();
200			}
201		});
202	},
203
204	/**
205	 * Handle form for upgrading an auto-generated customer to a regular customer.
206	 *
207	 * @param {HTMLFormElement} form
208	 */
209	submitUpgradeCustomer: function(form) {
210		if ( ! form.reportValidity()) {
211			return;
212		}
213		common.ajaxFormSubmitter({
214			form: form,
215			success: function(response) {
216				if (response.data.validationRequired) {
217					modal.createAlert({
218						body: response.content
219					});
220				}
221				$('#upgrade-customer-container').remove();
222				$('#upgrade-customer-success').show();
223			}
224		});
225	}
226
227
228};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.