X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/ajouter.php?a=blobdiff_plain;f=resources%2Fsrc%2Fjquery%2Fjquery.confirmable.js;h=7931c8147fac3bbdf031d95e97b9ff20977759a7;hb=2231d4e859628fc4d2fb63a7a752ead5b91ffef2;hp=4b80d953230e481de461e3ee79ebbb01a6c3e0e6;hpb=222727927abfe04a3116e4f7671e7628b14fe661;p=lhc%2Fweb%2Fwiklou.git
diff --git a/resources/src/jquery/jquery.confirmable.js b/resources/src/jquery/jquery.confirmable.js
index 4b80d95323..7931c8147f 100644
--- a/resources/src/jquery/jquery.confirmable.js
+++ b/resources/src/jquery/jquery.confirmable.js
@@ -12,6 +12,7 @@
return data;
};
+ // eslint-disable-next-line valid-jsdoc
/**
* Enable inline confirmation for given clickable element (like `` or ``).
*
@@ -36,9 +37,12 @@
* @param {Function} [options.handler] Callback to fire when the action is confirmed (user clicks
* the 'Yes' button).
* @param {string} [options.i18n] Text to use for interface elements.
+ * @param {string} [options.i18n.space] Word separator to place between the three text messages.
* @param {string} [options.i18n.confirm] Text to use for the confirmation question.
* @param {string} [options.i18n.yes] Text to use for the 'Yes' button.
* @param {string} [options.i18n.no] Text to use for the 'No' button.
+ * @param {string} [options.i18n.yesTitle] Title text to use for the 'Yes' button.
+ * @param {string} [options.i18n.noTitle] Title text to use for the 'No' button.
*
* @chainable
*/
@@ -107,6 +111,9 @@
if ( options.handler ) {
$buttonYes.on( options.events, options.handler );
}
+ if ( options.i18n.yesTitle ) {
+ $buttonYes.attr( 'title', options.i18n.yesTitle );
+ }
$buttonYes = options.buttonCallback( $buttonYes, 'yes' );
// Clone it without any events and prevent default action to represent the 'No' button.
@@ -119,6 +126,11 @@
$interface.css( 'width', 0 );
e.preventDefault();
} );
+ if ( options.i18n.noTitle ) {
+ $buttonNo.attr( 'title', options.i18n.noTitle );
+ } else {
+ $buttonNo.removeAttr( 'title' );
+ }
$buttonNo = options.buttonCallback( $buttonNo, 'no' );
// Prevent memory leaks
@@ -126,7 +138,7 @@
$interface = $( '' )
.addClass( 'jquery-confirmable-interface' )
- .append( $text, $buttonYes, $buttonNo );
+ .append( $text, options.i18n.space, $buttonYes, options.i18n.space, $buttonNo );
$interface = options.wrapperCallback( $interface );
// Render offscreen to measure real width
@@ -160,9 +172,12 @@
buttonCallback: identity,
handler: null,
i18n: {
+ space: ' ',
confirm: 'Are you sure?',
yes: 'Yes',
- no: 'No'
+ no: 'No',
+ yesTitle: undefined,
+ noTitle: undefined
}
};
}( jQuery ) );