From c41a2f4b986be6a32aceb9c782468f1250d4dc6d Mon Sep 17 00:00:00 2001
From: Peter Jaszkowiak
Date: Sun, 15 Jan 2017 13:58:56 -0700
Subject: [PATCH] Fixes #5369, bootbox wrapper translates attributes
---
public/vendor/bootbox/wrapper.js | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/public/vendor/bootbox/wrapper.js b/public/vendor/bootbox/wrapper.js
index 8e54e0e7db..429fa9d6c6 100644
--- a/public/vendor/bootbox/wrapper.js
+++ b/public/vendor/bootbox/wrapper.js
@@ -22,8 +22,9 @@ require(['translator'], function (shim) {
var translator = shim.Translator.create();
var dialog = bootbox.dialog;
+ var attrsToTranslate = ['placeholder', 'title', 'value'];
bootbox.dialog = function (options) {
- var show, $elem, nodes, text;
+ var show, $elem, nodes, text, attrNodes, attrText;
show = options.show !== false;
options.show = false;
@@ -36,10 +37,27 @@ require(['translator'], function (shim) {
return node.nodeValue;
}).join(' || ');
- translator.translate(text).then(function (translated) {
+ attrNodes = attrsToTranslate.reduce(function (prev, attr) {
+ return prev.concat(nodes.map.call($elem.find('[' + attr + '*="[["]'), function (el) {
+ return [attr, el];
+ }));
+ }, []);
+ attrText = attrNodes.map(function (node) {
+ return node[1].getAttribute(node[0]);
+ }).join(' || ');
+
+ Promise.all([
+ translator.translate(text),
+ translator.translate(attrText),
+ ]).then(function (ref) {
+ var translated = ref[0];
+ var translatedAttrs = ref[1];
translated.split(' || ').forEach(function (html, i) {
$(nodes[i]).replaceWith(html);
});
+ translatedAttrs.split(' || ').forEach(function (text, i) {
+ attrNodes[i][1].setAttribute(attrNodes[i][0], text);
+ });
if (show) {
$elem.modal('show');
}