2c892bfceac34248d0a852be3158b475cd0da919
[civicrm-core.git] / js / crm.ajax.js
1 // https://civicrm.org/licensing
2 /**
3 * @see https://docs.civicrm.org/dev/en/latest/api/interfaces/#ajax
4 * @see https://docs.civicrm.org/dev/en/latest/framework/ajax/
5 */
6 (function($, CRM, _, undefined) {
7 /**
8 * @param string path
9 * @param string|object query
10 * @param string mode - optionally specify "front" or "back"
11 */
12 var tplURL;
13 CRM.url = function (path, query, mode) {
14 if (typeof path === 'object') {
15 tplURL = path;
16 return path;
17 }
18 if (!tplURL) {
19 CRM.console('error', 'Error: CRM.url called before initialization');
20 }
21 if (!mode) {
22 mode = CRM.config && CRM.config.isFrontend ? 'front' : 'back';
23 }
24 query = query || '';
25 var url, frag, hash = '';
26 if (path.indexOf('#') > -1) {
27 hash = '#' + path.split('#')[1];
28 path = path.split('#')[0];
29 }
30 frag = path.split('?');
31 // Remove basepage as it can be changed on some CMS eg. WordPress frontend.
32 frag[0] = frag[0].replace('civicrm/', '/');
33 // Encode url path only if slashes in placeholder were also encoded
34 if (tplURL[mode].indexOf('/crmajax-placeholder-url-path') >= 0) {
35 url = tplURL[mode].replace('/crmajax-placeholder-url-path', frag[0]);
36 } else {
37 url = tplURL[mode].replace('%2Fcrmajax-placeholder-url-path', encodeURIComponent(frag[0]));
38 }
39
40 if (_.isEmpty(query)) {
41 url = url.replace(/[?&]civicrm-placeholder-url-query=1/, '');
42 } else {
43 url = url.replace('civicrm-placeholder-url-query=1', typeof query === 'string' ? query : $.param(query));
44 }
45 if (frag[1]) {
46 url += (url.indexOf('?') < 0 ? '?' : '&') + frag[1];
47 }
48 return url + hash;
49 };
50
51 $.fn.crmURL = function () {
52 return this.each(function() {
53 if (this.href) {
54 this.href = CRM.url(this.href);
55 }
56 });
57 };
58
59 // result is an array, but in js, an array is also an object
60 // Assign all the metadata properties to it, mirroring the results arrayObject in php
61 function arrayObject(data) {
62 var result = data.values || [];
63 if (_.isArray(result)) {
64 delete(data.values);
65 _.assign(result, data);
66 }
67 return result;
68 }
69
70 // https://docs.civicrm.org/dev/en/latest/api/interfaces/#ajax
71 CRM.api4 = function(entity, action, params, index) {
72 return new Promise(function(resolve, reject) {
73 if (typeof entity === 'string') {
74 $.post(CRM.url('civicrm/ajax/api4/' + entity + '/' + action), {
75 params: JSON.stringify(params),
76 index: index
77 })
78 .done(function (data) {
79 resolve(arrayObject(data));
80 })
81 .fail(function (data) {
82 reject(data.responseJSON);
83 });
84 } else {
85 $.post(CRM.url('civicrm/ajax/api4'), {
86 calls: JSON.stringify(entity)
87 })
88 .done(function(data) {
89 _.each(data, function(item, key) {
90 data[key] = arrayObject(item);
91 });
92 resolve(data);
93 })
94 .fail(function (data) {
95 reject(data.responseJSON);
96 });
97 }
98 });
99 };
100
101 /**
102 * AJAX api
103 * @link https://docs.civicrm.org/dev/en/latest/api/interfaces/#ajax
104 */
105 CRM.api3 = function(entity, action, params, status) {
106 if (typeof(entity) === 'string') {
107 params = {
108 entity: entity,
109 action: action.toLowerCase(),
110 json: JSON.stringify(params || {})
111 };
112 } else {
113 params = {
114 entity: 'api3',
115 action: 'call',
116 json: JSON.stringify(entity)
117 };
118 status = action;
119 }
120 var ajax = $.ajax({
121 url: CRM.url('civicrm/ajax/rest'),
122 dataType: 'json',
123 data: params,
124 type: params.action.indexOf('get') === 0 ? 'GET' : 'POST'
125 });
126 if (status) {
127 // Default status messages
128 if (status === true) {
129 status = {success: params.action === 'delete' ? ts('Removed') : ts('Saved')};
130 if (params.action.indexOf('get') === 0) {
131 status.start = ts('Loading...');
132 status.success = null;
133 }
134 }
135 var messages = status === true ? {} : status;
136 CRM.status(status, ajax);
137 }
138 return ajax;
139 };
140
141 /**
142 * @deprecated
143 * AJAX api
144 */
145 CRM.api = function(entity, action, params, options) {
146 // Default settings
147 var settings = {
148 context: null,
149 success: function(result, settings) {
150 return true;
151 },
152 error: function(result, settings) {
153 $().crmError(result.error_message, ts('Error'));
154 return false;
155 },
156 callBack: function(result, settings) {
157 if (result.is_error == 1) {
158 return settings.error.call(this, result, settings);
159 }
160 return settings.success.call(this, result, settings);
161 },
162 ajaxURL: 'civicrm/ajax/rest'
163 };
164 action = action.toLowerCase();
165 // Default success handler
166 switch (action) {
167 case "update":
168 case "create":
169 case "setvalue":
170 case "replace":
171 settings.success = function() {
172 CRM.status(ts('Saved'));
173 return true;
174 };
175 break;
176 case "delete":
177 settings.success = function() {
178 CRM.status(ts('Removed'));
179 return true;
180 };
181 }
182 params = {
183 entity: entity,
184 action: action,
185 json: JSON.stringify(params)
186 };
187 // Pass copy of settings into closure to preserve its value during multiple requests
188 (function(stg) {
189 $.ajax({
190 url: stg.ajaxURL.indexOf('http') === 0 ? stg.ajaxURL : CRM.url(stg.ajaxURL),
191 dataType: 'json',
192 data: params,
193 type: action.indexOf('get') < 0 ? 'POST' : 'GET',
194 success: function(result) {
195 stg.callBack.call(stg.context, result, stg);
196 }
197 });
198 })($.extend({}, settings, options));
199 };
200
201 $.widget('civi.crmSnippet', {
202 options: {
203 url: null,
204 block: true,
205 post: null,
206 crmForm: null
207 },
208 _originalContent: null,
209 _originalUrl: null,
210 isOriginalUrl: function() {
211 var
212 args = {},
213 same = true,
214 newUrl = this._formatUrl(this.options.url),
215 oldUrl = this._formatUrl(this._originalUrl);
216 // Compare path
217 if (newUrl.split('?')[0] !== oldUrl.split('?')[0]) {
218 return false;
219 }
220 // Compare arguments
221 $.each((newUrl.split('?')[1] || '').split('&'), function(k, v) {
222 var arg = v.split('=');
223 args[arg[0]] = arg[1];
224 });
225 $.each((oldUrl.split('?')[1] || '').split('&'), function(k, v) {
226 var arg = v.split('=');
227 if (args[arg[0]] !== undefined && arg[1] !== args[arg[0]]) {
228 same = false;
229 }
230 });
231 return same;
232 },
233 resetUrl: function() {
234 this.options.url = this._originalUrl;
235 },
236 _create: function() {
237 this.element.addClass('crm-ajax-container');
238 if (!this.element.is('.crm-container *')) {
239 this.element.addClass('crm-container');
240 }
241 this._handleOrderLinks();
242 // Set default if not supplied
243 this.options.url = this.options.url || document.location.href;
244 this._originalUrl = this.options.url;
245 },
246 _onFailure: function(data, status) {
247 var msg, title = ts('Network Error');
248 if (this.options.block) this.element.unblock();
249 this.element.trigger('crmAjaxFail', data);
250 switch (status) {
251 case 'Forbidden':
252 title = ts('Access Denied');
253 msg = ts('Ensure you are still logged in and have permission to access this feature.');
254 break;
255 default:
256 msg = ts('Unable to reach the server. Please refresh this page in your browser and try again.');
257 }
258 CRM.alert(msg, title, 'error');
259 },
260 _onError: function(data) {
261 this.element.attr('data-unsaved-changes', 'false').trigger('crmAjaxError', data);
262 if (this.options.crmForm && this.options.crmForm.autoClose && this.element.data('uiDialog')) {
263 this.element.dialog('close');
264 }
265 },
266 _formatUrl: function(url, snippetType) {
267 // Strip hash
268 url = url.split('#')[0];
269 // Add snippet argument to url
270 if (snippetType) {
271 if (url.search(/[&?]snippet=/) < 0) {
272 url += (url.indexOf('?') < 0 ? '?' : '&') + 'snippet=' + snippetType;
273 } else {
274 url = url.replace(/snippet=[^&]*/, 'snippet=' + snippetType);
275 }
276 if (snippetType === 'json' && CRM.angular) {
277 url += '&crmAngularModules=' + CRM.angular.modules.join();
278 }
279 }
280 return url;
281 },
282 // Hack to deal with civicrm legacy sort functionality
283 _handleOrderLinks: function() {
284 var that = this;
285 $('a.crm-weight-arrow', that.element).click(function(e) {
286 if (that.options.block) that.element.block();
287 $.getJSON(that._formatUrl(this.href, 'json')).done(function() {
288 that.refresh();
289 });
290 e.stopImmediatePropagation();
291 return false;
292 });
293 },
294 _ajax: function(url) {
295 if (!this.options.post || !this.isOriginalUrl()) {
296 return $.getJSON(url);
297 }
298 return $.post({
299 url: url,
300 dataType: 'json',
301 data: this.options.post
302 });
303 },
304 refresh: function() {
305 var that = this;
306 var url = this._formatUrl(this.options.url, 'json');
307 if (this.options.crmForm) $('form', this.element).ajaxFormUnbind();
308 if (this.options.block) this.element.block();
309 this._ajax(url).then(function(data) {
310 if (data.status === 'redirect') {
311 that.options.url = data.userContext;
312 return that.refresh();
313 }
314 if (that.options.block) that.element.unblock();
315 if (!$.isPlainObject(data)) {
316 that._onFailure(data);
317 return;
318 }
319 if (data.status === 'error') {
320 that._onError(data);
321 return;
322 }
323 data.url = url;
324 that.element.trigger('crmUnload').trigger('crmBeforeLoad', data);
325 that._beforeRemovingContent();
326 that.element.html(data.content);
327 that._handleOrderLinks();
328 that.element.trigger('crmLoad', data);
329 if (that.options.crmForm) that.element.trigger('crmFormLoad', data);
330 // This is only needed by forms that load via ajax but submit without ajax, e.g. configure contribution page tabs
331 // TODO: remove this when those forms have been converted to use ajax submit
332 if (data.status === 'form_error' && $.isPlainObject(data.errors)) {
333 that.element.trigger('crmFormError', data);
334 $.each(data.errors, function(formElement, msg) {
335 $('[name="'+formElement+'"]', that.element).crmError(msg);
336 });
337 }
338 }, function(data, msg, status) {
339 that._onFailure(data, status);
340 });
341 },
342 // Perform any cleanup needed before removing/replacing content
343 _beforeRemovingContent: function() {
344 var that = this;
345 // Save original content to be restored if widget is destroyed
346 if (this._originalContent === null) {
347 $('.blockUI', this.element).remove();
348 this._originalContent = this.element.contents().detach();
349 }
350 if (this.options.crmForm) $('form', this.element).ajaxFormUnbind();
351 },
352 _destroy: function() {
353 this.element.removeClass('crm-ajax-container').trigger('crmUnload');
354 this._beforeRemovingContent();
355 if (this._originalContent !== null) {
356 this.element.empty().append(this._originalContent);
357 }
358 }
359 });
360
361 var dialogCount = 0,
362 exclude = '[href^=#], [href^=javascript], [onclick], .no-popup, .cancel';
363
364 CRM.loadPage = function(url, options) {
365 var settings = {
366 target: '#crm-ajax-dialog-' + (dialogCount++),
367 dialog: (options && options.target) ? false : {}
368 };
369 if (options) $.extend(true, settings, options);
370 settings.url = url;
371 // Create new dialog
372 if (settings.dialog) {
373 settings.dialog = CRM.utils.adjustDialogDefaults(settings.dialog);
374 $('<div id="' + settings.target.substring(1) + '"></div>')
375 .dialog(settings.dialog)
376 .parent().find('.ui-dialog-titlebar')
377 .append($('<a class="crm-dialog-titlebar-print ui-dialog-titlebar-close" title="'+ts('Print window')+'" target="_blank" style="right:3.8em;"/>')
378 .button({icons: {primary: 'fa-print'}, text: false}));
379 }
380 // Add handlers to new or existing dialog
381 if ($(settings.target).data('uiDialog')) {
382 $(settings.target)
383 .on('dialogclose', function() {
384 if (settings.dialog && $(this).attr('data-unsaved-changes') !== 'true') {
385 $(this).crmSnippet('destroy').dialog('destroy').remove();
386 }
387 })
388 .on('crmLoad', function(e, data) {
389 // Set title
390 if (e.target === $(settings.target)[0] && data && !settings.dialog.title && data.title) {
391 $(this).dialog('option', 'title', data.title);
392 }
393 // Update print url
394 $(this).parent().find('a.crm-dialog-titlebar-print').attr('href', $(this).data('civiCrmSnippet')._formatUrl($(this).crmSnippet('option', 'url'), '2'));
395 });
396 }
397 $(settings.target).crmSnippet(settings).crmSnippet('refresh');
398 return $(settings.target);
399 };
400 CRM.loadForm = function(url, options) {
401 var formErrors = [], settings = {
402 crmForm: {
403 ajaxForm: {},
404 autoClose: true,
405 validate: true,
406 refreshAction: ['next_new', 'submit_savenext', 'upload_new'],
407 cancelButton: '.cancel',
408 openInline: 'a.open-inline, a.button, a.action-item, a.open-inline-noreturn',
409 onCancel: function(event) {}
410 }
411 };
412 // Move options that belong to crmForm. Others will be passed through to crmSnippet
413 if (options) $.each(options, function(key, value) {
414 if (typeof(settings.crmForm[key]) !== 'undefined') {
415 settings.crmForm[key] = value;
416 }
417 else {
418 settings[key] = value;
419 }
420 });
421
422 var widget = CRM.loadPage(url, settings).off('.crmForm');
423
424 // CRM-14353 - Warn of unsaved changes for all forms except those which have opted out
425 function cancelAction() {
426 var dirty = CRM.utils.initialValueChanged($('form:not([data-warn-changes=false])', widget));
427 widget.attr('data-unsaved-changes', dirty ? 'true' : 'false');
428 if (dirty) {
429 var id = widget.attr('id') + '-unsaved-alert',
430 title = widget.dialog('option', 'title'),
431 alert = CRM.alert('<p>' + ts('%1 has not been saved.', {1: title}) + '</p><p><a href="#" id="' + id + '">' + ts('Restore') + '</a></p>', ts('Unsaved Changes'), 'alert unsaved-dialog', {expires: 60000});
432 $('#' + id).button({icons: {primary: 'fa-undo'}}).click(function(e) {
433 widget.attr('data-unsaved-changes', 'false').dialog('open');
434 e.preventDefault();
435 });
436 }
437 }
438
439 if (widget.data('uiDialog')) widget.on('dialogbeforeclose', function(e) {
440 // CRM-14353 - Warn unsaved changes if user clicks close button or presses "esc"
441 if (e.originalEvent) {
442 cancelAction();
443 }
444 });
445
446 widget.on('crmFormLoad.crmForm', function(event, data) {
447 var $el = $(this).attr('data-unsaved-changes', 'false'),
448 settings = $el.crmSnippet('option', 'crmForm');
449 if (settings.cancelButton) $(settings.cancelButton, this).click(function(e) {
450 e.preventDefault();
451 var returnVal = settings.onCancel.call($el, e);
452 if (returnVal !== false) {
453 $el.trigger('crmFormCancel', e);
454 if ($el.data('uiDialog') && settings.autoClose) {
455 cancelAction();
456 $el.dialog('close');
457 }
458 else if (!settings.autoClose) {
459 $el.crmSnippet('resetUrl').crmSnippet('refresh');
460 }
461 }
462 });
463 if (settings.validate) {
464 $("form", this).crmValidate();
465 }
466 $("form:not('[data-no-ajax-submit=true]')", this).ajaxForm($.extend({
467 url: data.url.replace(/reset=1[&]?/, ''),
468 dataType: 'json',
469 success: function(response) {
470 if (response.content === undefined) {
471 $el.trigger('crmFormSuccess', response);
472 // Reset form for e.g. "save and new"
473 if (response.userContext && (response.status === 'redirect' || (settings.refreshAction && $.inArray(response.buttonName, settings.refreshAction) >= 0))) {
474 // Force reset of original url
475 $el.data('civiCrmSnippet')._originalUrl = response.userContext;
476 $el.crmSnippet('resetUrl').crmSnippet('refresh');
477 }
478 // Close if we are on the original url or the action was "delete" (in which case returning to view may be inappropriate)
479 else if ($el.data('uiDialog') && (settings.autoClose || response.action === 8)) {
480 $el.dialog('close');
481 }
482 else if (settings.autoClose === false) {
483 $el.crmSnippet('resetUrl').crmSnippet('refresh');
484 }
485 }
486 else {
487 if ($el.crmSnippet('option', 'block')) $el.unblock();
488 response.url = data.url;
489 $el.html(response.content).trigger('crmLoad', response).trigger('crmFormLoad', response);
490 if (response.status === 'form_error') {
491 formErrors = [];
492 $el.trigger('crmFormError', response);
493 $.each(response.errors || [], function(formElement, msg) {
494 formErrors.push($('[name="'+formElement+'"]', $el).crmError(msg));
495 });
496 }
497 }
498 },
499 beforeSubmit: function(submission) {
500 $.each(formErrors, function() {
501 if (this && this.close) this.close();
502 });
503 if ($el.crmSnippet('option', 'block')) $el.block();
504 $el.trigger('crmFormSubmit', submission);
505 }
506 }, settings.ajaxForm));
507 if (settings.openInline) {
508 settings.autoClose = $el.crmSnippet('isOriginalUrl');
509 $(this).off('.openInline').on('click.openInline', settings.openInline, function(e) {
510 if ($(this).is(exclude + ', .crm-popup, [target=crm-popup]')) {
511 return;
512 }
513 if ($(this).hasClass('open-inline-noreturn')) {
514 // Force reset of original url
515 $el.data('civiCrmSnippet')._originalUrl = $(this).attr('href');
516 }
517 $el.crmSnippet('option', 'url', $(this).attr('href')).crmSnippet('refresh');
518 e.preventDefault();
519 });
520 }
521 if ($el.data('uiDialog')) {
522 // Show form buttons as part of the dialog
523 var buttonContainers = '.crm-submit-buttons, .action-link',
524 buttons = [],
525 added = [];
526 $(buttonContainers, $el).find('.crm-form-submit, .crm-form-xbutton, a.button, button').each(function() {
527 var $el = $(this),
528 label = $el.is('input') ? $el.attr('value') : $el.text(),
529 identifier = $el.attr('name') || $el.attr('href');
530 $el.attr('tabindex', '-1');
531 if (!identifier || identifier === '#' || $.inArray(identifier, added) < 0) {
532 var $icon = $el.find('.icon, .crm-i'),
533 button = {'data-identifier': identifier, text: label, click: function() {
534 $el[0].click();
535 }};
536 if ($icon.length) {
537 button.icons = {primary: $icon.attr('class')};
538 } else {
539 var action = $el.attr('crm-icon') || ($el.hasClass('cancel') ? 'fa-times' : 'fa-check');
540 button.icons = {primary: action};
541 }
542 buttons.push(button);
543 added.push(identifier);
544 }
545 // display:none causes the form to not submit when pressing "enter"
546 $el.parents(buttonContainers).css({height: 0, padding: 0, margin: 0, overflow: 'hidden'}).attr('aria-hidden', 'true');
547 });
548 $el.dialog('option', 'buttons', buttons);
549 }
550 // Allow a button to prevent ajax submit
551 $('input[data-no-ajax-submit=true], button[data-no-ajax-submit=true]').click(function() {
552 $(this).closest('form').ajaxFormUnbind();
553 });
554 // For convenience, focus the first field
555 $('input[type=text], textarea, select', this).filter(':visible').first().not('.dateplugin').focus();
556 });
557 return widget;
558 };
559 /**
560 * Handler for jQuery click event e.g. $('a').click(CRM.popup);
561 */
562 CRM.popup = function(e) {
563 var $el = $(this).first(),
564 url = $el.attr('href'),
565 popup = $el.data('popup-type') === 'page' ? CRM.loadPage : CRM.loadForm,
566 settings = $el.data('popup-settings') || {},
567 formData = false;
568 settings.dialog = settings.dialog || {};
569 if (e.isDefaultPrevented() || !CRM.config.ajaxPopupsEnabled || !url || $el.is(exclude + ', .open-inline, .open-inline-noreturn')) {
570 return;
571 }
572 // Sized based on css class
573 if ($el.hasClass('small-popup')) {
574 settings.dialog.width = 400;
575 settings.dialog.height = 300;
576 }
577 else if ($el.hasClass('medium-popup')) {
578 settings.dialog.width = settings.dialog.height = '50%';
579 }
580 var dialog = popup(url, settings);
581 // Trigger events from the dialog on the original link element
582 $el.trigger('crmPopupOpen', [dialog]);
583 // Listen for success events and buffer them so we only trigger once
584 dialog.on('crmFormSuccess.crmPopup crmPopupFormSuccess.crmPopup', function(e, data) {
585 formData = data;
586 });
587 dialog.on('dialogclose.crmPopup', function(e, data) {
588 if (formData) {
589 $el.trigger('crmPopupFormSuccess', [dialog, formData]);
590 }
591 $el.trigger('crmPopupClose', [dialog, data]);
592 });
593 e.preventDefault();
594 };
595 /**
596 * An event callback for CRM.popup or a standalone function to refresh the content around a given element
597 * @param e {event|selector}
598 */
599 CRM.refreshParent = function(e) {
600 // Use e.target if input smells like an event, otherwise assume it's a jQuery selector
601 var $el = (e.stopPropagation && e.target) ? $(e.target) : $(e),
602 $table = $el.closest('.dataTable');
603 // Call native refresh method on ajax datatables
604 if ($table.length && $.fn.DataTable.fnIsDataTable($table[0]) && $table.dataTable().fnSettings().sAjaxSource) {
605 // Refresh ALL datatables - needed for contact relationship tab
606 $.each($.fn.dataTable.fnTables(), function() {
607 if ($(this).dataTable().fnSettings().sAjaxSource) $(this).unblock().dataTable().fnDraw();
608 });
609 }
610 // Otherwise refresh the nearest crmSnippet
611 else {
612 $el.closest('.crm-ajax-container, #crm-main-content-wrapper').crmSnippet().crmSnippet('refresh');
613 }
614 };
615
616 $(function($) {
617 $('body')
618 .on('click', 'a.crm-popup, a[target=crm-popup]', CRM.popup)
619 // Close unsaved dialog messages
620 .on('dialogopen', function(e) {
621 $('.alert.unsaved-dialog .ui-notify-cross', '#crm-notification-container').click();
622 })
623 // Destroy old unsaved dialog
624 .on('dialogcreate', function(e) {
625 $('.ui-dialog-content.crm-ajax-container:hidden[data-unsaved-changes=true]').crmSnippet('destroy').dialog('destroy').remove();
626 })
627 // Ensure wysiwyg content is updated prior to ajax submit
628 .on('form-pre-serialize', function(e) {
629 $('.crm-wysiwyg-enabled', e.target).each(function() {
630 CRM.wysiwyg.updateElement(this);
631 });
632 })
633 // Auto-resize dialogs when loading content
634 .on('crmLoad dialogopen', 'div.ui-dialog.ui-resizable.crm-container', function(e) {
635 var
636 $wrapper = $(this),
637 $dialog = $wrapper.children('.ui-dialog-content');
638 // small delay to allow contents to render
639 window.setTimeout(function() {
640 var currentHeight = $wrapper.outerHeight(),
641 padding = currentHeight - $dialog.height(),
642 newHeight = $dialog.prop('scrollHeight') + padding,
643 menuHeight = $('#civicrm-menu').outerHeight();
644 if ($('body').hasClass('crm-menubar-below-cms-menu')) {
645 menuHeight += $('#civicrm-menu').offset().top;
646 }
647 var maxHeight = $(window).height() - menuHeight;
648 newHeight = newHeight > maxHeight ? maxHeight : newHeight;
649 if (newHeight > (currentHeight + 15)) {
650 $dialog.dialog('option', {
651 position: {my: 'center', at: 'center center+' + (menuHeight / 2), of: window},
652 height: newHeight
653 });
654 }
655 }, 500);
656 });
657 });
658
659 }(jQuery, CRM, _));