tjadmin 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tjadmin/version.rb +1 -1
  3. data/vendor/assets/font/DXI1ORHCpsQm3Vp6mXoaTXhCUOGz7vYGh680lGh-uXM.woff +0 -0
  4. data/vendor/assets/font/FontAwesome.otf +0 -0
  5. data/vendor/assets/font/cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff +0 -0
  6. data/vendor/assets/font/fontawesome-webfont.eot +0 -0
  7. data/vendor/assets/font/fontawesome-webfont.svg +399 -0
  8. data/vendor/assets/font/fontawesome-webfont.ttf +0 -0
  9. data/vendor/assets/font/fontawesome-webfont.woff +0 -0
  10. data/vendor/assets/javascripts/tjadmin/ace-elements.js +866 -0
  11. data/vendor/assets/javascripts/tjadmin/ace-extra.js +374 -0
  12. data/vendor/assets/javascripts/tjadmin/ace.js +310 -0
  13. data/vendor/assets/javascripts/tjadmin/additional-methods.js +617 -0
  14. data/vendor/assets/javascripts/tjadmin/bootbox.js +660 -0
  15. data/vendor/assets/javascripts/tjadmin/bootstrap-colorpicker.js +540 -0
  16. data/vendor/assets/javascripts/tjadmin/bootstrap-tag.js +206 -0
  17. data/vendor/assets/javascripts/tjadmin/bootstrap-wysiwyg.js +206 -0
  18. data/vendor/assets/javascripts/tjadmin/bootstrap.js +2280 -0
  19. data/vendor/assets/javascripts/tjadmin/chosen.jquery.js +1166 -0
  20. data/vendor/assets/javascripts/tjadmin/date-time/bootstrap-datepicker.js +1016 -0
  21. data/vendor/assets/javascripts/tjadmin/date-time/bootstrap-timepicker.js +888 -0
  22. data/vendor/assets/javascripts/tjadmin/date-time/daterangepicker.js +854 -0
  23. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.bg.js +14 -0
  24. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.ca.js +14 -0
  25. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.cs.js +15 -0
  26. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.da.js +14 -0
  27. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.de.js +16 -0
  28. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.el.js +13 -0
  29. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.es.js +14 -0
  30. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.fi.js +14 -0
  31. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.fr.js +16 -0
  32. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.he.js +15 -0
  33. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.hr.js +13 -0
  34. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.hu.js +16 -0
  35. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.id.js +13 -0
  36. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.is.js +14 -0
  37. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.it.js +16 -0
  38. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.ja.js +15 -0
  39. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.kr.js +13 -0
  40. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.lt.js +16 -0
  41. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.lv.js +16 -0
  42. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.ms.js +14 -0
  43. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.nb.js +14 -0
  44. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.nl.js +14 -0
  45. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.pl.js +15 -0
  46. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.pt-BR.js +14 -0
  47. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.pt.js +14 -0
  48. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.ro.js +15 -0
  49. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.rs-latin.js +14 -0
  50. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.rs.js +14 -0
  51. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.ru.js +14 -0
  52. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.sk.js +15 -0
  53. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.sl.js +14 -0
  54. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.sv.js +14 -0
  55. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.sw.js +15 -0
  56. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.th.js +14 -0
  57. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.tr.js +15 -0
  58. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.uk.js +14 -0
  59. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.zh-CN.js +14 -0
  60. data/vendor/assets/javascripts/tjadmin/date-time/locales/bootstrap-datepicker.zh-TW.js +13 -0
  61. data/vendor/assets/javascripts/tjadmin/date-time/moment.js +1400 -0
  62. data/vendor/assets/javascripts/tjadmin/excanvas.js +1428 -0
  63. data/vendor/assets/javascripts/tjadmin/flot/jquery.flot.js +3061 -0
  64. data/vendor/assets/javascripts/tjadmin/flot/jquery.flot.pie.js +817 -0
  65. data/vendor/assets/javascripts/tjadmin/flot/jquery.flot.resize.js +60 -0
  66. data/vendor/assets/javascripts/tjadmin/fuelux/data/fuelux.tree-sampledata.js +174 -0
  67. data/vendor/assets/javascripts/tjadmin/fuelux/fuelux.spinner.js +201 -0
  68. data/vendor/assets/javascripts/tjadmin/fuelux/fuelux.tree.js +173 -0
  69. data/vendor/assets/javascripts/tjadmin/fuelux/fuelux.wizard.js +172 -0
  70. data/vendor/assets/javascripts/tjadmin/fullcalendar.js +5973 -0
  71. data/vendor/assets/javascripts/tjadmin/jquery-1.10.2.js +9789 -0
  72. data/vendor/assets/javascripts/tjadmin/jquery-2.0.3.js +8829 -0
  73. data/vendor/assets/javascripts/tjadmin/jquery-ui-1.10.3.custom.js +5423 -0
  74. data/vendor/assets/javascripts/tjadmin/jquery.autosize.js +242 -0
  75. data/vendor/assets/javascripts/tjadmin/jquery.colorbox.js +1063 -0
  76. data/vendor/assets/javascripts/tjadmin/jquery.dataTables.js +12099 -0
  77. data/vendor/assets/javascripts/tjadmin/jquery.easy-pie-chart.js +200 -0
  78. data/vendor/assets/javascripts/tjadmin/jquery.gritter.js +418 -0
  79. data/vendor/assets/javascripts/tjadmin/jquery.hotkeys.js +113 -0
  80. data/vendor/assets/javascripts/tjadmin/jquery.inputlimiter.1.3.1.js +172 -0
  81. data/vendor/assets/javascripts/tjadmin/jquery.knob.js +656 -0
  82. data/vendor/assets/javascripts/tjadmin/jquery.maskedinput.js +338 -0
  83. data/vendor/assets/javascripts/tjadmin/jquery.mobile.custom.js +1081 -0
  84. data/vendor/assets/javascripts/tjadmin/jquery.slimscroll.js +448 -0
  85. data/vendor/assets/javascripts/tjadmin/jquery.sparkline.js +3054 -0
  86. data/vendor/assets/javascripts/tjadmin/jquery.ui.touch-punch.js +160 -0
  87. data/vendor/assets/javascripts/tjadmin/jquery.validate.js +1231 -0
  88. data/vendor/assets/javascripts/tjadmin/markdown/bootstrap-markdown.js +993 -0
  89. data/vendor/assets/javascripts/tjadmin/markdown/markdown.js +1616 -0
  90. data/vendor/assets/javascripts/tjadmin/markdown/to-markdown.js +184 -0
  91. data/vendor/assets/javascripts/tjadmin/select2.js +3168 -0
  92. data/vendor/assets/javascripts/tjadmin/spin.js +349 -0
  93. data/vendor/assets/javascripts/tjadmin/x-editable/ace-editable.js +368 -0
  94. data/vendor/assets/javascripts/tjadmin/x-editable/bootstrap-editable.js +6827 -0
  95. data/vendor/assets/javascripts/tjadmin.js +5 -0
  96. data/vendor/assets/stylesheets/tjadmin/ace-fonts.css.scss +13 -0
  97. data/vendor/assets/stylesheets/tjadmin/ace-ie.css +293 -0
  98. data/vendor/assets/stylesheets/tjadmin/ace-responsive.css +1113 -0
  99. data/vendor/assets/stylesheets/tjadmin/ace-skins.css +1301 -0
  100. data/vendor/assets/stylesheets/tjadmin/ace.css +14701 -0
  101. data/vendor/assets/stylesheets/tjadmin/bootstrap-responsive.css +1109 -0
  102. data/vendor/assets/stylesheets/tjadmin/bootstrap.css +6167 -0
  103. data/vendor/assets/stylesheets/tjadmin/chosen.css +430 -0
  104. data/vendor/assets/stylesheets/tjadmin/font-awesome-ie7.css +1203 -0
  105. data/vendor/assets/stylesheets/tjadmin/font-awesome.css +1479 -0
  106. data/vendor/assets/stylesheets/tjadmin/jquery-ui-1.10.3.custom.css +223 -0
  107. data/vendor/assets/stylesheets/tjadmin.css +9 -0
  108. metadata +106 -1
@@ -0,0 +1,660 @@
1
+ /**
2
+ * bootbox.js v3.3.0
3
+ *
4
+ * http://bootboxjs.com/license.txt
5
+ */
6
+ var bootbox = window.bootbox || (function(document, $) {
7
+ /*jshint scripturl:true sub:true */
8
+
9
+ var _locale = 'en',
10
+ _defaultLocale = 'en',
11
+ _animate = true,
12
+ _backdrop = 'static',
13
+ _defaultHref = 'javascript:;',
14
+ _classes = '',
15
+ _btnClasses = {},
16
+ _icons = {},
17
+ /* last var should always be the public object we'll return */
18
+ that = {};
19
+
20
+
21
+ /**
22
+ * public API
23
+ */
24
+ that.setLocale = function(locale) {
25
+ for (var i in _locales) {
26
+ if (i == locale) {
27
+ _locale = locale;
28
+ return;
29
+ }
30
+ }
31
+ throw new Error('Invalid locale: '+locale);
32
+ };
33
+
34
+ that.addLocale = function(locale, translations) {
35
+ if (typeof _locales[locale] === 'undefined') {
36
+ _locales[locale] = {};
37
+ }
38
+ for (var str in translations) {
39
+ _locales[locale][str] = translations[str];
40
+ }
41
+ };
42
+
43
+ that.setIcons = function(icons) {
44
+ _icons = icons;
45
+ if (typeof _icons !== 'object' || _icons === null) {
46
+ _icons = {};
47
+ }
48
+ };
49
+
50
+ that.setBtnClasses = function(btnClasses) {
51
+ _btnClasses = btnClasses;
52
+ if (typeof _btnClasses !== 'object' || _btnClasses === null) {
53
+ _btnClasses = {};
54
+ }
55
+ };
56
+
57
+ that.alert = function(/*str, label, cb*/) {
58
+ var str = "",
59
+ label = _translate('OK'),
60
+ cb = null;
61
+
62
+ switch (arguments.length) {
63
+ case 1:
64
+ // no callback, default button label
65
+ str = arguments[0];
66
+ break;
67
+ case 2:
68
+ // callback *or* custom button label dependent on type
69
+ str = arguments[0];
70
+ if (typeof arguments[1] == 'function') {
71
+ cb = arguments[1];
72
+ } else {
73
+ label = arguments[1];
74
+ }
75
+ break;
76
+ case 3:
77
+ // callback and custom button label
78
+ str = arguments[0];
79
+ label = arguments[1];
80
+ cb = arguments[2];
81
+ break;
82
+ default:
83
+ throw new Error("Incorrect number of arguments: expected 1-3");
84
+ }
85
+
86
+ return that.dialog(str, {
87
+ // only button (ok)
88
+ "label" : label,
89
+ "icon" : _icons.OK,
90
+ "class" : _btnClasses.OK,
91
+ "callback": cb
92
+ }, {
93
+ // ensure that the escape key works; either invoking the user's
94
+ // callback or true to just close the dialog
95
+ "onEscape": cb || true
96
+ });
97
+ };
98
+
99
+ that.confirm = function(/*str, labelCancel, labelOk, cb*/) {
100
+ var str = "",
101
+ labelCancel = _translate('CANCEL'),
102
+ labelOk = _translate('CONFIRM'),
103
+ cb = null;
104
+
105
+ switch (arguments.length) {
106
+ case 1:
107
+ str = arguments[0];
108
+ break;
109
+ case 2:
110
+ str = arguments[0];
111
+ if (typeof arguments[1] == 'function') {
112
+ cb = arguments[1];
113
+ } else {
114
+ labelCancel = arguments[1];
115
+ }
116
+ break;
117
+ case 3:
118
+ str = arguments[0];
119
+ labelCancel = arguments[1];
120
+ if (typeof arguments[2] == 'function') {
121
+ cb = arguments[2];
122
+ } else {
123
+ labelOk = arguments[2];
124
+ }
125
+ break;
126
+ case 4:
127
+ str = arguments[0];
128
+ labelCancel = arguments[1];
129
+ labelOk = arguments[2];
130
+ cb = arguments[3];
131
+ break;
132
+ default:
133
+ throw new Error("Incorrect number of arguments: expected 1-4");
134
+ }
135
+
136
+ var cancelCallback = function() {
137
+ if (typeof cb === 'function') {
138
+ return cb(false);
139
+ }
140
+ };
141
+
142
+ var confirmCallback = function() {
143
+ if (typeof cb === 'function') {
144
+ return cb(true);
145
+ }
146
+ };
147
+
148
+ return that.dialog(str, [{
149
+ // first button (cancel)
150
+ "label" : labelCancel,
151
+ "icon" : _icons.CANCEL,
152
+ "class" : _btnClasses.CANCEL,
153
+ "callback": cancelCallback
154
+ }, {
155
+ // second button (confirm)
156
+ "label" : labelOk,
157
+ "icon" : _icons.CONFIRM,
158
+ "class" : _btnClasses.CONFIRM,
159
+ "callback": confirmCallback
160
+ }], {
161
+ // escape key bindings
162
+ "onEscape": cancelCallback
163
+ });
164
+ };
165
+
166
+ that.prompt = function(/*str, labelCancel, labelOk, cb, defaultVal*/) {
167
+ var str = "",
168
+ labelCancel = _translate('CANCEL'),
169
+ labelOk = _translate('CONFIRM'),
170
+ cb = null,
171
+ defaultVal = "";
172
+
173
+ switch (arguments.length) {
174
+ case 1:
175
+ str = arguments[0];
176
+ break;
177
+ case 2:
178
+ str = arguments[0];
179
+ if (typeof arguments[1] == 'function') {
180
+ cb = arguments[1];
181
+ } else {
182
+ labelCancel = arguments[1];
183
+ }
184
+ break;
185
+ case 3:
186
+ str = arguments[0];
187
+ labelCancel = arguments[1];
188
+ if (typeof arguments[2] == 'function') {
189
+ cb = arguments[2];
190
+ } else {
191
+ labelOk = arguments[2];
192
+ }
193
+ break;
194
+ case 4:
195
+ str = arguments[0];
196
+ labelCancel = arguments[1];
197
+ labelOk = arguments[2];
198
+ cb = arguments[3];
199
+ break;
200
+ case 5:
201
+ str = arguments[0];
202
+ labelCancel = arguments[1];
203
+ labelOk = arguments[2];
204
+ cb = arguments[3];
205
+ defaultVal = arguments[4];
206
+ break;
207
+ default:
208
+ throw new Error("Incorrect number of arguments: expected 1-5");
209
+ }
210
+
211
+ var header = str;
212
+
213
+ // let's keep a reference to the form object for later
214
+ var form = $("<form></form>");
215
+ form.append("<input class='input-block-level' autocomplete=off type=text value='" + defaultVal + "' />");
216
+
217
+ var cancelCallback = function() {
218
+ if (typeof cb === 'function') {
219
+ // yep, native prompts dismiss with null, whereas native
220
+ // confirms dismiss with false...
221
+ return cb(null);
222
+ }
223
+ };
224
+
225
+ var confirmCallback = function() {
226
+ if (typeof cb === 'function') {
227
+ return cb(form.find("input[type=text]").val());
228
+ }
229
+ };
230
+
231
+ var div = that.dialog(form, [{
232
+ // first button (cancel)
233
+ "label" : labelCancel,
234
+ "icon" : _icons.CANCEL,
235
+ "class" : _btnClasses.CANCEL,
236
+ "callback": cancelCallback
237
+ }, {
238
+ // second button (confirm)
239
+ "label" : labelOk,
240
+ "icon" : _icons.CONFIRM,
241
+ "class" : _btnClasses.CONFIRM,
242
+ "callback": confirmCallback
243
+ }], {
244
+ // prompts need a few extra options
245
+ "header" : header,
246
+ // explicitly tell dialog NOT to show the dialog...
247
+ "show" : false,
248
+ "onEscape": cancelCallback
249
+ });
250
+
251
+ // ... the reason the prompt needs to be hidden is because we need
252
+ // to bind our own "shown" handler, after creating the modal but
253
+ // before any show(n) events are triggered
254
+ // @see https://github.com/makeusabrew/bootbox/issues/69
255
+
256
+ div.on("shown", function() {
257
+ form.find("input[type=text]").focus();
258
+
259
+ // ensure that submitting the form (e.g. with the enter key)
260
+ // replicates the behaviour of a normal prompt()
261
+ form.on("submit", function(e) {
262
+ e.preventDefault();
263
+ div.find(".btn-primary").click();
264
+ });
265
+ });
266
+
267
+ div.modal("show");
268
+
269
+ return div;
270
+ };
271
+
272
+ that.dialog = function(str, handlers, options) {
273
+ var buttons = "",
274
+ callbacks = [];
275
+
276
+ if (!options) {
277
+ options = {};
278
+ }
279
+
280
+ // check for single object and convert to array if necessary
281
+ if (typeof handlers === 'undefined') {
282
+ handlers = [];
283
+ } else if (typeof handlers.length == 'undefined') {
284
+ handlers = [handlers];
285
+ }
286
+
287
+ var i = handlers.length;
288
+ while (i--) {
289
+ var label = null,
290
+ href = null,
291
+ _class = null,
292
+ icon = '',
293
+ callback = null;
294
+
295
+ if (typeof handlers[i]['label'] == 'undefined' &&
296
+ typeof handlers[i]['class'] == 'undefined' &&
297
+ typeof handlers[i]['callback'] == 'undefined') {
298
+ // if we've got nothing we expect, check for condensed format
299
+
300
+ var propCount = 0, // condensed will only match if this == 1
301
+ property = null; // save the last property we found
302
+
303
+ // be nicer to count the properties without this, but don't think it's possible...
304
+ for (var j in handlers[i]) {
305
+ property = j;
306
+ if (++propCount > 1) {
307
+ // forget it, too many properties
308
+ break;
309
+ }
310
+ }
311
+
312
+ if (propCount == 1 && typeof handlers[i][j] == 'function') {
313
+ // matches condensed format of label -> function
314
+ handlers[i]['label'] = property;
315
+ handlers[i]['callback'] = handlers[i][j];
316
+ }
317
+ }
318
+
319
+ if (typeof handlers[i]['callback']== 'function') {
320
+ callback = handlers[i]['callback'];
321
+ }
322
+
323
+ if (handlers[i]['class']) {
324
+ _class = handlers[i]['class'];
325
+ } else if (i == handlers.length -1 && handlers.length <= 2) {
326
+ // always add a primary to the main option in a two-button dialog
327
+ _class = 'btn-primary';
328
+ }
329
+
330
+ if (handlers[i]['link'] !== true) {
331
+ _class = 'btn ' + _class;
332
+ }
333
+
334
+ if (handlers[i]['label']) {
335
+ label = handlers[i]['label'];
336
+ } else {
337
+ label = "Option "+(i+1);
338
+ }
339
+
340
+ if (handlers[i]['icon']) {
341
+ icon = "<i class='"+handlers[i]['icon']+"'></i> ";
342
+ }
343
+
344
+ if (handlers[i]['href']) {
345
+ href = handlers[i]['href'];
346
+ }
347
+ else {
348
+ href = _defaultHref;
349
+ }
350
+
351
+ buttons = "<a data-handler='"+i+"' class='"+_class+"' href='" + href + "'>"+icon+""+label+"</a>" + buttons;
352
+
353
+ callbacks[i] = callback;
354
+ }
355
+
356
+ // @see https://github.com/makeusabrew/bootbox/issues/46#issuecomment-8235302
357
+ // and https://github.com/twitter/bootstrap/issues/4474
358
+ // for an explanation of the inline overflow: hidden
359
+ // @see https://github.com/twitter/bootstrap/issues/4854
360
+ // for an explanation of tabIndex=-1
361
+
362
+ var parts = ["<div class='bootbox modal' tabindex='-1' style='overflow:hidden;'>"];
363
+
364
+ if (options['header']) {
365
+ var closeButton = '';
366
+ if (typeof options['headerCloseButton'] == 'undefined' || options['headerCloseButton']) {
367
+ closeButton = "<a href='"+_defaultHref+"' class='close'>&times;</a>";
368
+ }
369
+
370
+ parts.push("<div class='modal-header'>"+closeButton+"<h3>"+options['header']+"</h3></div>");
371
+ }
372
+
373
+ // push an empty body into which we'll inject the proper content later
374
+ parts.push("<div class='modal-body'></div>");
375
+
376
+ if (buttons) {
377
+ parts.push("<div class='modal-footer'>"+buttons+"</div>");
378
+ }
379
+
380
+ parts.push("</div>");
381
+
382
+ var div = $(parts.join("\n"));
383
+
384
+ // check whether we should fade in/out
385
+ var shouldFade = (typeof options.animate === 'undefined') ? _animate : options.animate;
386
+
387
+ if (shouldFade) {
388
+ div.addClass("fade");
389
+ }
390
+
391
+ var optionalClasses = (typeof options.classes === 'undefined') ? _classes : options.classes;
392
+ if (optionalClasses) {
393
+ div.addClass(optionalClasses);
394
+ }
395
+
396
+ // now we've built up the div properly we can inject the content whether it was a string or a jQuery object
397
+ div.find(".modal-body").html(str);
398
+
399
+ function onCancel(source) {
400
+ // for now source is unused, but it will be in future
401
+ var hideModal = null;
402
+ if (typeof options.onEscape === 'function') {
403
+ // @see https://github.com/makeusabrew/bootbox/issues/91
404
+ hideModal = options.onEscape();
405
+ }
406
+
407
+ if (hideModal !== false) {
408
+ div.modal('hide');
409
+ }
410
+ }
411
+
412
+ // hook into the modal's keyup trigger to check for the escape key
413
+ div.on('keyup.dismiss.modal', function(e) {
414
+ // any truthy value passed to onEscape will dismiss the dialog
415
+ // as long as the onEscape function (if defined) doesn't prevent it
416
+ if (e.which === 27 && options.onEscape) {
417
+ onCancel('escape');
418
+ }
419
+ });
420
+
421
+ // handle close buttons too
422
+ div.on('click', 'a.close', function(e) {
423
+ e.preventDefault();
424
+ onCancel('close');
425
+ });
426
+
427
+ // well, *if* we have a primary - give the first dom element focus
428
+ div.on('shown', function() {
429
+ div.find("a.btn-primary:first").focus();
430
+ });
431
+
432
+ div.on('hidden', function(e) {
433
+ // @see https://github.com/makeusabrew/bootbox/issues/115
434
+ // allow for the fact hidden events can propagate up from
435
+ // child elements like tooltips
436
+ if (e.target === this) {
437
+ div.remove();
438
+ }
439
+ });
440
+
441
+ // wire up button handlers
442
+ div.on('click', '.modal-footer a', function(e) {
443
+
444
+ var handler = $(this).data("handler"),
445
+ cb = callbacks[handler],
446
+ hideModal = null;
447
+
448
+ // sort of @see https://github.com/makeusabrew/bootbox/pull/68 - heavily adapted
449
+ // if we've got a custom href attribute, all bets are off
450
+ if (typeof handler !== 'undefined' &&
451
+ typeof handlers[handler]['href'] !== 'undefined') {
452
+
453
+ return;
454
+ }
455
+
456
+ e.preventDefault();
457
+
458
+ if (typeof cb === 'function') {
459
+ hideModal = cb(e);
460
+ }
461
+
462
+ // the only way hideModal *will* be false is if a callback exists and
463
+ // returns it as a value. in those situations, don't hide the dialog
464
+ // @see https://github.com/makeusabrew/bootbox/pull/25
465
+ if (hideModal !== false) {
466
+ div.modal("hide");
467
+ }
468
+ });
469
+
470
+ // stick the modal right at the bottom of the main body out of the way
471
+ $("body").append(div);
472
+
473
+ div.modal({
474
+ // unless explicitly overridden take whatever our default backdrop value is
475
+ backdrop : (typeof options.backdrop === 'undefined') ? _backdrop : options.backdrop,
476
+ // ignore bootstrap's keyboard options; we'll handle this ourselves (more fine-grained control)
477
+ keyboard : false,
478
+ // @ see https://github.com/makeusabrew/bootbox/issues/69
479
+ // we *never* want the modal to be shown before we can bind stuff to it
480
+ // this method can also take a 'show' option, but we'll only use that
481
+ // later if we need to
482
+ show : false
483
+ });
484
+
485
+ // @see https://github.com/makeusabrew/bootbox/issues/64
486
+ // @see https://github.com/makeusabrew/bootbox/issues/60
487
+ // ...caused by...
488
+ // @see https://github.com/twitter/bootstrap/issues/4781
489
+ div.on("show", function(e) {
490
+ $(document).off("focusin.modal");
491
+ });
492
+
493
+ if (typeof options.show === 'undefined' || options.show === true) {
494
+ div.modal("show");
495
+ }
496
+
497
+ return div;
498
+ };
499
+
500
+ /**
501
+ * #modal is deprecated in v3; it can still be used but no guarantees are
502
+ * made - have never been truly convinced of its merit but perhaps just
503
+ * needs a tidyup and some TLC
504
+ */
505
+ that.modal = function(/*str, label, options*/) {
506
+ var str;
507
+ var label;
508
+ var options;
509
+
510
+ var defaultOptions = {
511
+ "onEscape": null,
512
+ "keyboard": true,
513
+ "backdrop": _backdrop
514
+ };
515
+
516
+ switch (arguments.length) {
517
+ case 1:
518
+ str = arguments[0];
519
+ break;
520
+ case 2:
521
+ str = arguments[0];
522
+ if (typeof arguments[1] == 'object') {
523
+ options = arguments[1];
524
+ } else {
525
+ label = arguments[1];
526
+ }
527
+ break;
528
+ case 3:
529
+ str = arguments[0];
530
+ label = arguments[1];
531
+ options = arguments[2];
532
+ break;
533
+ default:
534
+ throw new Error("Incorrect number of arguments: expected 1-3");
535
+ }
536
+
537
+ defaultOptions['header'] = label;
538
+
539
+ if (typeof options == 'object') {
540
+ options = $.extend(defaultOptions, options);
541
+ } else {
542
+ options = defaultOptions;
543
+ }
544
+
545
+ return that.dialog(str, [], options);
546
+ };
547
+
548
+
549
+ that.hideAll = function() {
550
+ $(".bootbox").modal("hide");
551
+ };
552
+
553
+ that.animate = function(animate) {
554
+ _animate = animate;
555
+ };
556
+
557
+ that.backdrop = function(backdrop) {
558
+ _backdrop = backdrop;
559
+ };
560
+
561
+ that.classes = function(classes) {
562
+ _classes = classes;
563
+ };
564
+
565
+ /**
566
+ * private API
567
+ */
568
+
569
+ /**
570
+ * standard locales. Please add more according to ISO 639-1 standard. Multiple language variants are
571
+ * unlikely to be required. If this gets too large it can be split out into separate JS files.
572
+ */
573
+ var _locales = {
574
+ 'br' : {
575
+ OK : 'OK',
576
+ CANCEL : 'Cancelar',
577
+ CONFIRM : 'Sim'
578
+ },
579
+ 'da' : {
580
+ OK : 'OK',
581
+ CANCEL : 'Annuller',
582
+ CONFIRM : 'Accepter'
583
+ },
584
+ 'de' : {
585
+ OK : 'OK',
586
+ CANCEL : 'Abbrechen',
587
+ CONFIRM : 'Akzeptieren'
588
+ },
589
+ 'en' : {
590
+ OK : 'OK',
591
+ CANCEL : 'Cancel',
592
+ CONFIRM : 'OK'
593
+ },
594
+ 'es' : {
595
+ OK : 'OK',
596
+ CANCEL : 'Cancelar',
597
+ CONFIRM : 'Aceptar'
598
+ },
599
+ 'fr' : {
600
+ OK : 'OK',
601
+ CANCEL : 'Annuler',
602
+ CONFIRM : 'D\'accord'
603
+ },
604
+ 'it' : {
605
+ OK : 'OK',
606
+ CANCEL : 'Annulla',
607
+ CONFIRM : 'Conferma'
608
+ },
609
+ 'nl' : {
610
+ OK : 'OK',
611
+ CANCEL : 'Annuleren',
612
+ CONFIRM : 'Accepteren'
613
+ },
614
+ 'pl' : {
615
+ OK : 'OK',
616
+ CANCEL : 'Anuluj',
617
+ CONFIRM : 'Potwierdź'
618
+ },
619
+ 'ru' : {
620
+ OK : 'OK',
621
+ CANCEL : 'Отмена',
622
+ CONFIRM : 'Применить'
623
+ },
624
+ 'zh_CN' : {
625
+ OK : 'OK',
626
+ CANCEL : '取消',
627
+ CONFIRM : '确认'
628
+ },
629
+ 'zh_TW' : {
630
+ OK : 'OK',
631
+ CANCEL : '取消',
632
+ CONFIRM : '確認'
633
+ }
634
+ };
635
+
636
+ function _translate(str, locale) {
637
+ // we assume if no target locale is probided then we should take it from current setting
638
+ if (typeof locale === 'undefined') {
639
+ locale = _locale;
640
+ }
641
+ if (typeof _locales[locale][str] === 'string') {
642
+ return _locales[locale][str];
643
+ }
644
+
645
+ // if we couldn't find a lookup then try and fallback to a default translation
646
+
647
+ if (locale != _defaultLocale) {
648
+ return _translate(str, _defaultLocale);
649
+ }
650
+
651
+ // if we can't do anything then bail out with whatever string was passed in - last resort
652
+ return str;
653
+ }
654
+
655
+ return that;
656
+
657
+ }(document, window.jQuery));
658
+
659
+ // @see https://github.com/makeusabrew/bootbox/issues/71
660
+ window.bootbox = bootbox;