Skip to content

Commit 696fa33

Browse files
committed
Generating bootobx.locales.js from locale files
Added grunt task for generating bootbox.locale.js from files found in locales directory. Moved bootbox.locales.js to dist directory. Normalized locale codes to IANA identifiers where possible.
1 parent 6c7aded commit 696fa33

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+634
-1276
lines changed

Gruntfile.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@ module.exports = function (grunt) {
22
'use strict';
33
grunt.initConfig({
44
concat: {
5-
options: {
6-
separator: ';',
5+
locales: {
6+
src: ['templates/umd-header.txt', 'locales/**/*.js', 'templates/umd-footer.txt'],
7+
dest: 'dist/bootbox.locales.js'
78
},
8-
dist: {
9-
src: ['bootbox.js', 'bootbox.locales.js'],
10-
dest: 'bootbox.all.js',
9+
10+
all : {
11+
options: {
12+
separator: ';'
13+
},
14+
dist: {
15+
src: ['bootbox.js', 'dist/bootbox.locales.js'],
16+
dest: 'dist/bootbox.all.js',
17+
}
1118
}
1219
},
1320

@@ -23,8 +30,8 @@ module.exports = function (grunt) {
2330
my_target: {
2431
files: {
2532
'dist/bootbox.min.js': ['bootbox.js'],
26-
'dist/bootbox.locales.min.js': ['bootbox.locales.js'],
27-
'dist/bootbox.all.min.js': ['bootbox.all.js']
33+
'dist/bootbox.locales.min.js': ['dist/bootbox.locales.js'],
34+
'dist/bootbox.all.min.js': ['dist/bootbox.all.js']
2835
}
2936
}
3037
},
@@ -34,7 +41,7 @@ module.exports = function (grunt) {
3441
jshintrc: '.jshintrc',
3542
force: true
3643
},
37-
all: ['bootbox.js', 'bootbox.locales.js']
44+
all: ['bootbox.js', 'dist/bootbox.locales.js']
3845
},
3946

4047
karma: {

bootbox.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
exports.VERSION = VERSION;
2727

2828
let locales = {
29-
en : {
29+
'en' : {
3030
OK : 'OK',
3131
CANCEL : 'Cancel',
3232
CONFIRM : 'OK'
@@ -413,16 +413,25 @@
413413
// Bootbox event listeners; used to decouple some behaviours from their respective triggers
414414

415415
if (options.backdrop === true) {
416+
let startedOnBody = false;
417+
418+
// Prevents the event from propagating to the backdrop, when something inside the dialog is clicked
419+
dialog.on('mousedown', '.modal-content', function(e){
420+
e.stopPropagation();
421+
422+
startedOnBody = true;
423+
});
424+
416425
// A boolean true/false according to the Bootstrap docs should show a dialog the user can dismiss by clicking on the background.
417426
// We always only ever pass static/false to the actual $.modal function because with "true" we can't trap this event (the .modal-backdrop swallows it).
418427
// However, we still want to sort-of respect true and invoke the escape mechanism instead
419428
dialog.on('click.dismiss.bs.modal', function (e) {
420-
// @NOTE: the target varies in >= 3.3.x releases since the modal backdrop moved *inside* the outer dialog rather than *alongside* it
421-
if (dialog.children('.modal-backdrop').length) {
422-
e.currentTarget = dialog.children('.modal-backdrop').get(0);
423-
}
429+
// // @NOTE: the target varies in >= 3.3.x releases since the modal backdrop moved *inside* the outer dialog rather than *alongside* it
430+
// if (dialog.children('.modal-backdrop').length) {
431+
// e.currentTarget = dialog.children('.modal-backdrop').get(0);
432+
// }
424433

425-
if (e.target !== e.currentTarget) {
434+
if (startedOnBody || e.target !== e.currentTarget) {
426435
return;
427436
}
428437

0 commit comments

Comments
 (0)