bootbox-rails 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/vendor/assets/javascripts/bootbox.js +143 -28
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4db0c69cc34403930e43aecad3b986131cf50ad
|
4
|
+
data.tar.gz: 8c955e6699da555174afb01d486419b583d02078
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c0e132afdb8cb2768d224f53d52d7b133171b3370f160f0a34221dba4de2b3f4a806f8fc549f5641f749d203a78155f53a4af7908e904bec7f441e6cc557371
|
7
|
+
data.tar.gz: 7929a1b72a91871c4d173a4e4a78476d6594a903fbb477b060746d640f72910eb1c3e29dbfb76535f323d0b4769234cd2d77021e32e13c2082b667488016735f
|
@@ -71,8 +71,8 @@
|
|
71
71
|
var defaults = {
|
72
72
|
// default language
|
73
73
|
locale: "en",
|
74
|
-
// show backdrop or not
|
75
|
-
backdrop:
|
74
|
+
// show backdrop or not. Default to static so user has to interact with dialog
|
75
|
+
backdrop: "static",
|
76
76
|
// animate the modal in/out
|
77
77
|
animate: true,
|
78
78
|
// additional class string applied to the top level dialog
|
@@ -105,7 +105,7 @@
|
|
105
105
|
|
106
106
|
// so, if the callback can be invoked and it *explicitly returns false*
|
107
107
|
// then we'll set a flag to keep the dialog active...
|
108
|
-
var preserveDialog = $.isFunction(callback) && callback(e) === false;
|
108
|
+
var preserveDialog = $.isFunction(callback) && callback.call(dialog, e) === false;
|
109
109
|
|
110
110
|
// ... otherwise we'll bin it
|
111
111
|
if (!preserveDialog) {
|
@@ -148,11 +148,6 @@
|
|
148
148
|
options.buttons = {};
|
149
149
|
}
|
150
150
|
|
151
|
-
// we only support Bootstrap's "static" and false backdrop args
|
152
|
-
// supporting true would mean you could dismiss the dialog without
|
153
|
-
// explicitly interacting with it
|
154
|
-
options.backdrop = options.backdrop ? "static" : false;
|
155
|
-
|
156
151
|
buttons = options.buttons;
|
157
152
|
|
158
153
|
total = getKeyLength(buttons);
|
@@ -312,7 +307,7 @@
|
|
312
307
|
*/
|
313
308
|
options.buttons.ok.callback = options.onEscape = function() {
|
314
309
|
if ($.isFunction(options.callback)) {
|
315
|
-
return options.callback();
|
310
|
+
return options.callback.call(this);
|
316
311
|
}
|
317
312
|
return true;
|
318
313
|
};
|
@@ -329,11 +324,11 @@
|
|
329
324
|
* overrides; undo anything the user tried to set they shouldn't have
|
330
325
|
*/
|
331
326
|
options.buttons.cancel.callback = options.onEscape = function() {
|
332
|
-
return options.callback(false);
|
327
|
+
return options.callback.call(this, false);
|
333
328
|
};
|
334
329
|
|
335
330
|
options.buttons.confirm.callback = function() {
|
336
|
-
return options.callback(true);
|
331
|
+
return options.callback.call(this, true);
|
337
332
|
};
|
338
333
|
|
339
334
|
// confirm specific validation
|
@@ -381,21 +376,13 @@
|
|
381
376
|
// it, but we need to make sure we respect a preference not to show it
|
382
377
|
shouldShow = (options.show === undefined) ? true : options.show;
|
383
378
|
|
384
|
-
// check if the browser supports the option.inputType
|
385
|
-
var html5inputs = ["date","time","number"];
|
386
|
-
var i = document.createElement("input");
|
387
|
-
i.setAttribute("type", options.inputType);
|
388
|
-
if(html5inputs[options.inputType]){
|
389
|
-
options.inputType = i.type;
|
390
|
-
}
|
391
|
-
|
392
379
|
/**
|
393
380
|
* overrides; undo anything the user tried to set they shouldn't have
|
394
381
|
*/
|
395
382
|
options.message = form;
|
396
383
|
|
397
384
|
options.buttons.cancel.callback = options.onEscape = function() {
|
398
|
-
return options.callback(null);
|
385
|
+
return options.callback.call(this, null);
|
399
386
|
};
|
400
387
|
|
401
388
|
options.buttons.confirm.callback = function() {
|
@@ -426,7 +413,7 @@
|
|
426
413
|
break;
|
427
414
|
}
|
428
415
|
|
429
|
-
return options.callback(value);
|
416
|
+
return options.callback.call(this, value);
|
430
417
|
};
|
431
418
|
|
432
419
|
options.show = false;
|
@@ -462,6 +449,10 @@
|
|
462
449
|
var groups = {};
|
463
450
|
inputOptions = options.inputOptions || [];
|
464
451
|
|
452
|
+
if (!$.isArray(inputOptions)) {
|
453
|
+
throw new Error("Please pass an array of input options");
|
454
|
+
}
|
455
|
+
|
465
456
|
if (!inputOptions.length) {
|
466
457
|
throw new Error("prompt with select requires options");
|
467
458
|
}
|
@@ -475,7 +466,6 @@
|
|
475
466
|
throw new Error("given options in wrong format");
|
476
467
|
}
|
477
468
|
|
478
|
-
|
479
469
|
// ... but override that element if this option sits in a group
|
480
470
|
|
481
471
|
if (option.group) {
|
@@ -533,14 +523,20 @@
|
|
533
523
|
break;
|
534
524
|
}
|
535
525
|
|
526
|
+
// @TODO provide an attributes option instead
|
527
|
+
// and simply map that as keys: vals
|
536
528
|
if (options.placeholder) {
|
537
529
|
input.attr("placeholder", options.placeholder);
|
538
530
|
}
|
539
531
|
|
540
|
-
if(options.pattern){
|
532
|
+
if (options.pattern) {
|
541
533
|
input.attr("pattern", options.pattern);
|
542
534
|
}
|
543
535
|
|
536
|
+
if (options.maxlength) {
|
537
|
+
input.attr("maxlength", options.maxlength);
|
538
|
+
}
|
539
|
+
|
544
540
|
// now place it in our form
|
545
541
|
form.append(input);
|
546
542
|
|
@@ -560,6 +556,8 @@
|
|
560
556
|
|
561
557
|
// ...and replace it with one focusing our input, if possible
|
562
558
|
dialog.on("shown.bs.modal", function() {
|
559
|
+
// need the closure here since input isn't
|
560
|
+
// an object otherwise
|
563
561
|
input.focus();
|
564
562
|
});
|
565
563
|
|
@@ -582,6 +580,14 @@
|
|
582
580
|
onEscape: options.onEscape
|
583
581
|
};
|
584
582
|
|
583
|
+
if ($.fn.modal === undefined) {
|
584
|
+
throw new Error(
|
585
|
+
"$.fn.modal is not defined; please double check you have included " +
|
586
|
+
"the Bootstrap JavaScript library. See http://getbootstrap.com/javascript/ " +
|
587
|
+
"for more details."
|
588
|
+
);
|
589
|
+
}
|
590
|
+
|
585
591
|
each(buttons, function(key, button) {
|
586
592
|
|
587
593
|
// @TODO I don't like this string appending to itself; bit dirty. Needs reworking
|
@@ -603,9 +609,7 @@
|
|
603
609
|
|
604
610
|
if (options.size === "large") {
|
605
611
|
innerDialog.addClass("modal-lg");
|
606
|
-
}
|
607
|
-
|
608
|
-
if (options.size === "small") {
|
612
|
+
} else if (options.size === "small") {
|
609
613
|
innerDialog.addClass("modal-sm");
|
610
614
|
}
|
611
615
|
|
@@ -669,6 +673,30 @@
|
|
669
673
|
* respective triggers
|
670
674
|
*/
|
671
675
|
|
676
|
+
if (options.backdrop !== "static") {
|
677
|
+
// A boolean true/false according to the Bootstrap docs
|
678
|
+
// should show a dialog the user can dismiss by clicking on
|
679
|
+
// the background.
|
680
|
+
// We always only ever pass static/false to the actual
|
681
|
+
// $.modal function because with `true` we can't trap
|
682
|
+
// this event (the .modal-backdrop swallows it)
|
683
|
+
// However, we still want to sort of respect true
|
684
|
+
// and invoke the escape mechanism instead
|
685
|
+
dialog.on("click.dismiss.bs.modal", function(e) {
|
686
|
+
// @NOTE: the target varies in >= 3.3.x releases since the modal backdrop
|
687
|
+
// moved *inside* the outer dialog rather than *alongside* it
|
688
|
+
if (dialog.children(".modal-backdrop").length) {
|
689
|
+
e.currentTarget = dialog.children(".modal-backdrop").get(0);
|
690
|
+
}
|
691
|
+
|
692
|
+
if (e.target !== e.currentTarget) {
|
693
|
+
return;
|
694
|
+
}
|
695
|
+
|
696
|
+
dialog.trigger("escape.close.bb");
|
697
|
+
});
|
698
|
+
}
|
699
|
+
|
672
700
|
dialog.on("escape.close.bb", function(e) {
|
673
701
|
if (callbacks.onEscape) {
|
674
702
|
processCallback(e, dialog, callbacks.onEscape);
|
@@ -684,7 +712,6 @@
|
|
684
712
|
var callbackKey = $(this).data("bb-handler");
|
685
713
|
|
686
714
|
processCallback(e, dialog, callbacks[callbackKey]);
|
687
|
-
|
688
715
|
});
|
689
716
|
|
690
717
|
dialog.on("click", ".bootbox-close-button", function(e) {
|
@@ -708,7 +735,7 @@
|
|
708
735
|
$(options.container).append(dialog);
|
709
736
|
|
710
737
|
dialog.modal({
|
711
|
-
backdrop: options.backdrop,
|
738
|
+
backdrop: options.backdrop ? "static": false,
|
712
739
|
keyboard: false,
|
713
740
|
show: false
|
714
741
|
});
|
@@ -757,6 +784,8 @@
|
|
757
784
|
|
758
785
|
exports.hideAll = function() {
|
759
786
|
$(".bootbox").modal("hide");
|
787
|
+
|
788
|
+
return exports;
|
760
789
|
};
|
761
790
|
|
762
791
|
|
@@ -765,11 +794,26 @@
|
|
765
794
|
* unlikely to be required. If this gets too large it can be split out into separate JS files.
|
766
795
|
*/
|
767
796
|
var locales = {
|
797
|
+
ar : {
|
798
|
+
OK : "موافق",
|
799
|
+
CANCEL : "الغاء",
|
800
|
+
CONFIRM : "تأكيد"
|
801
|
+
},
|
802
|
+
bg_BG : {
|
803
|
+
OK : "Ок",
|
804
|
+
CANCEL : "Отказ",
|
805
|
+
CONFIRM : "Потвърждавам"
|
806
|
+
},
|
768
807
|
br : {
|
769
808
|
OK : "OK",
|
770
809
|
CANCEL : "Cancelar",
|
771
810
|
CONFIRM : "Sim"
|
772
811
|
},
|
812
|
+
cs : {
|
813
|
+
OK : "OK",
|
814
|
+
CANCEL : "Zrušit",
|
815
|
+
CONFIRM : "Potvrdit"
|
816
|
+
},
|
773
817
|
da : {
|
774
818
|
OK : "OK",
|
775
819
|
CANCEL : "Annuller",
|
@@ -795,6 +839,16 @@
|
|
795
839
|
CANCEL : "Cancelar",
|
796
840
|
CONFIRM : "Aceptar"
|
797
841
|
},
|
842
|
+
et : {
|
843
|
+
OK : "OK",
|
844
|
+
CANCEL : "Katkesta",
|
845
|
+
CONFIRM : "OK"
|
846
|
+
},
|
847
|
+
fa : {
|
848
|
+
OK : "قبول",
|
849
|
+
CANCEL : "لغو",
|
850
|
+
CONFIRM : "تایید"
|
851
|
+
},
|
798
852
|
fi : {
|
799
853
|
OK : "OK",
|
800
854
|
CANCEL : "Peruuta",
|
@@ -810,11 +864,31 @@
|
|
810
864
|
CANCEL : "ביטול",
|
811
865
|
CONFIRM : "אישור"
|
812
866
|
},
|
867
|
+
hu : {
|
868
|
+
OK : "OK",
|
869
|
+
CANCEL : "Mégsem",
|
870
|
+
CONFIRM : "Megerősít"
|
871
|
+
},
|
872
|
+
hr : {
|
873
|
+
OK : "OK",
|
874
|
+
CANCEL : "Odustani",
|
875
|
+
CONFIRM : "Potvrdi"
|
876
|
+
},
|
877
|
+
id : {
|
878
|
+
OK : "OK",
|
879
|
+
CANCEL : "Batal",
|
880
|
+
CONFIRM : "OK"
|
881
|
+
},
|
813
882
|
it : {
|
814
883
|
OK : "OK",
|
815
884
|
CANCEL : "Annulla",
|
816
885
|
CONFIRM : "Conferma"
|
817
886
|
},
|
887
|
+
ja : {
|
888
|
+
OK : "OK",
|
889
|
+
CANCEL : "キャンセル",
|
890
|
+
CONFIRM : "確認"
|
891
|
+
},
|
818
892
|
lt : {
|
819
893
|
OK : "Gerai",
|
820
894
|
CANCEL : "Atšaukti",
|
@@ -840,16 +914,31 @@
|
|
840
914
|
CANCEL : "Anuluj",
|
841
915
|
CONFIRM : "Potwierdź"
|
842
916
|
},
|
917
|
+
pt : {
|
918
|
+
OK : "OK",
|
919
|
+
CANCEL : "Cancelar",
|
920
|
+
CONFIRM : "Confirmar"
|
921
|
+
},
|
843
922
|
ru : {
|
844
923
|
OK : "OK",
|
845
924
|
CANCEL : "Отмена",
|
846
925
|
CONFIRM : "Применить"
|
847
926
|
},
|
927
|
+
sq : {
|
928
|
+
OK : "OK",
|
929
|
+
CANCEL : "Anulo",
|
930
|
+
CONFIRM : "Prano"
|
931
|
+
},
|
848
932
|
sv : {
|
849
933
|
OK : "OK",
|
850
934
|
CANCEL : "Avbryt",
|
851
935
|
CONFIRM : "OK"
|
852
936
|
},
|
937
|
+
th : {
|
938
|
+
OK : "ตกลง",
|
939
|
+
CANCEL : "ยกเลิก",
|
940
|
+
CONFIRM : "ยืนยัน"
|
941
|
+
},
|
853
942
|
tr : {
|
854
943
|
OK : "Tamam",
|
855
944
|
CANCEL : "İptal",
|
@@ -867,6 +956,32 @@
|
|
867
956
|
}
|
868
957
|
};
|
869
958
|
|
959
|
+
exports.addLocale = function(name, values) {
|
960
|
+
$.each(["OK", "CANCEL", "CONFIRM"], function(_, v) {
|
961
|
+
if (!values[v]) {
|
962
|
+
throw new Error("Please supply a translation for '" + v + "'");
|
963
|
+
}
|
964
|
+
});
|
965
|
+
|
966
|
+
locales[name] = {
|
967
|
+
OK: values.OK,
|
968
|
+
CANCEL: values.CANCEL,
|
969
|
+
CONFIRM: values.CONFIRM
|
970
|
+
};
|
971
|
+
|
972
|
+
return exports;
|
973
|
+
};
|
974
|
+
|
975
|
+
exports.removeLocale = function(name) {
|
976
|
+
delete locales[name];
|
977
|
+
|
978
|
+
return exports;
|
979
|
+
};
|
980
|
+
|
981
|
+
exports.setLocale = function(name) {
|
982
|
+
return exports.setDefaults("locale", name);
|
983
|
+
};
|
984
|
+
|
870
985
|
exports.init = function(_$) {
|
871
986
|
return init(_$ || $);
|
872
987
|
};
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootbox-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kozloff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|