rails_admin 2.1.1 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rails_admin might be problematic. Click here for more details.

Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/rails_admin/jquery.migrate.js +3 -0
  3. data/app/assets/javascripts/rails_admin/ra.filter-box.js +1 -4
  4. data/app/assets/javascripts/rails_admin/ra.nested-form-hooks.js +3 -3
  5. data/app/assets/javascripts/rails_admin/ra.widgets.js +1 -1
  6. data/app/assets/javascripts/rails_admin/rails_admin.js +2 -1
  7. data/app/assets/javascripts/rails_admin/ui.js +2 -2
  8. data/app/helpers/rails_admin/form_builder.rb +2 -0
  9. data/lib/rails_admin/extensions/paper_trail/auditing_adapter.rb +1 -1
  10. data/lib/rails_admin/version.rb +2 -2
  11. data/vendor/assets/javascripts/rails_admin/bootstrap-datetimepicker.js +317 -150
  12. data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-affix.js +50 -28
  13. data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-alert.js +10 -7
  14. data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-button.js +35 -20
  15. data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-carousel.js +48 -25
  16. data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-collapse.js +70 -28
  17. data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-dropdown.js +56 -42
  18. data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-modal.js +118 -40
  19. data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-popover.js +26 -16
  20. data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-scrollspy.js +29 -27
  21. data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-tab.js +46 -19
  22. data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-tooltip.js +280 -60
  23. data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-transition.js +5 -5
  24. data/vendor/assets/javascripts/rails_admin/jquery.pjax.js +317 -160
  25. data/vendor/assets/javascripts/rails_admin/moment-with-locales.js +11210 -9290
  26. metadata +3 -3
  27. data/config/initializers/devise_patch.rb +0 -9
@@ -1,8 +1,8 @@
1
1
  /* ========================================================================
2
- * Bootstrap: dropdown.js v3.2.0
3
- * http://getbootstrap.com/javascript/#dropdowns
2
+ * Bootstrap: dropdown.js v3.4.1
3
+ * https://getbootstrap.com/docs/3.4/javascript/#dropdowns
4
4
  * ========================================================================
5
- * Copyright 2011-2014 Twitter, Inc.
5
+ * Copyright 2011-2019 Twitter, Inc.
6
6
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
7
7
  * ======================================================================== */
8
8
 
@@ -19,7 +19,41 @@
19
19
  $(element).on('click.bs.dropdown', this.toggle)
20
20
  }
21
21
 
22
- Dropdown.VERSION = '3.2.0'
22
+ Dropdown.VERSION = '3.4.1'
23
+
24
+ function getParent($this) {
25
+ var selector = $this.attr('data-target')
26
+
27
+ if (!selector) {
28
+ selector = $this.attr('href')
29
+ selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
30
+ }
31
+
32
+ var $parent = selector !== '#' ? $(document).find(selector) : null
33
+
34
+ return $parent && $parent.length ? $parent : $this.parent()
35
+ }
36
+
37
+ function clearMenus(e) {
38
+ if (e && e.which === 3) return
39
+ $(backdrop).remove()
40
+ $(toggle).each(function () {
41
+ var $this = $(this)
42
+ var $parent = getParent($this)
43
+ var relatedTarget = { relatedTarget: this }
44
+
45
+ if (!$parent.hasClass('open')) return
46
+
47
+ if (e && e.type == 'click' && /input|textarea/i.test(e.target.tagName) && $.contains($parent[0], e.target)) return
48
+
49
+ $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
50
+
51
+ if (e.isDefaultPrevented()) return
52
+
53
+ $this.attr('aria-expanded', 'false')
54
+ $parent.removeClass('open').trigger($.Event('hidden.bs.dropdown', relatedTarget))
55
+ })
56
+ }
23
57
 
24
58
  Dropdown.prototype.toggle = function (e) {
25
59
  var $this = $(this)
@@ -34,7 +68,10 @@
34
68
  if (!isActive) {
35
69
  if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
36
70
  // if mobile we use a backdrop because click events don't delegate
37
- $('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus)
71
+ $(document.createElement('div'))
72
+ .addClass('dropdown-backdrop')
73
+ .insertAfter($(this))
74
+ .on('click', clearMenus)
38
75
  }
39
76
 
40
77
  var relatedTarget = { relatedTarget: this }
@@ -42,18 +79,20 @@
42
79
 
43
80
  if (e.isDefaultPrevented()) return
44
81
 
45
- $this.trigger('focus')
82
+ $this
83
+ .trigger('focus')
84
+ .attr('aria-expanded', 'true')
46
85
 
47
86
  $parent
48
87
  .toggleClass('open')
49
- .trigger('shown.bs.dropdown', relatedTarget)
88
+ .trigger($.Event('shown.bs.dropdown', relatedTarget))
50
89
  }
51
90
 
52
91
  return false
53
92
  }
54
93
 
55
94
  Dropdown.prototype.keydown = function (e) {
56
- if (!/(38|40|27)/.test(e.keyCode)) return
95
+ if (!/(38|40|27|32)/.test(e.which) || /input|textarea/i.test(e.target.tagName)) return
57
96
 
58
97
  var $this = $(this)
59
98
 
@@ -65,51 +104,25 @@
65
104
  var $parent = getParent($this)
66
105
  var isActive = $parent.hasClass('open')
67
106
 
68
- if (!isActive || (isActive && e.keyCode == 27)) {
107
+ if (!isActive && e.which != 27 || isActive && e.which == 27) {
69
108
  if (e.which == 27) $parent.find(toggle).trigger('focus')
70
109
  return $this.trigger('click')
71
110
  }
72
111
 
73
- var desc = ' li:not(.divider):visible a'
74
- var $items = $parent.find('[role="menu"]' + desc + ', [role="listbox"]' + desc)
112
+ var desc = ' li:not(.disabled):visible a'
113
+ var $items = $parent.find('.dropdown-menu' + desc)
75
114
 
76
115
  if (!$items.length) return
77
116
 
78
- var index = $items.index($items.filter(':focus'))
117
+ var index = $items.index(e.target)
79
118
 
80
- if (e.keyCode == 38 && index > 0) index-- // up
81
- if (e.keyCode == 40 && index < $items.length - 1) index++ // down
82
- if (!~index) index = 0
119
+ if (e.which == 38 && index > 0) index-- // up
120
+ if (e.which == 40 && index < $items.length - 1) index++ // down
121
+ if (!~index) index = 0
83
122
 
84
123
  $items.eq(index).trigger('focus')
85
124
  }
86
125
 
87
- function clearMenus(e) {
88
- if (e && e.which === 3) return
89
- $(backdrop).remove()
90
- $(toggle).each(function () {
91
- var $parent = getParent($(this))
92
- var relatedTarget = { relatedTarget: this }
93
- if (!$parent.hasClass('open')) return
94
- $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
95
- if (e.isDefaultPrevented()) return
96
- $parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
97
- })
98
- }
99
-
100
- function getParent($this) {
101
- var selector = $this.attr('data-target')
102
-
103
- if (!selector) {
104
- selector = $this.attr('href')
105
- selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
106
- }
107
-
108
- var $parent = selector && $(selector)
109
-
110
- return $parent && $parent.length ? $parent : $this.parent()
111
- }
112
-
113
126
 
114
127
  // DROPDOWN PLUGIN DEFINITION
115
128
  // ==========================
@@ -146,6 +159,7 @@
146
159
  .on('click.bs.dropdown.data-api', clearMenus)
147
160
  .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
148
161
  .on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
149
- .on('keydown.bs.dropdown.data-api', toggle + ', [role="menu"], [role="listbox"]', Dropdown.prototype.keydown)
162
+ .on('keydown.bs.dropdown.data-api', toggle, Dropdown.prototype.keydown)
163
+ .on('keydown.bs.dropdown.data-api', '.dropdown-menu', Dropdown.prototype.keydown)
150
164
 
151
165
  }(jQuery);
@@ -1,8 +1,8 @@
1
1
  /* ========================================================================
2
- * Bootstrap: modal.js v3.2.0
3
- * http://getbootstrap.com/javascript/#modals
2
+ * Bootstrap: modal.js v3.4.1
3
+ * https://getbootstrap.com/docs/3.4/javascript/#modals
4
4
  * ========================================================================
5
- * Copyright 2011-2014 Twitter, Inc.
5
+ * Copyright 2011-2019 Twitter, Inc.
6
6
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
7
7
  * ======================================================================== */
8
8
 
@@ -14,12 +14,16 @@
14
14
  // ======================
15
15
 
16
16
  var Modal = function (element, options) {
17
- this.options = options
18
- this.$body = $(document.body)
19
- this.$element = $(element)
20
- this.$backdrop =
21
- this.isShown = null
17
+ this.options = options
18
+ this.$body = $(document.body)
19
+ this.$element = $(element)
20
+ this.$dialog = this.$element.find('.modal-dialog')
21
+ this.$backdrop = null
22
+ this.isShown = null
23
+ this.originalBodyPad = null
22
24
  this.scrollbarWidth = 0
25
+ this.ignoreBackdropClick = false
26
+ this.fixedContent = '.navbar-fixed-top, .navbar-fixed-bottom'
23
27
 
24
28
  if (this.options.remote) {
25
29
  this.$element
@@ -30,7 +34,10 @@
30
34
  }
31
35
  }
32
36
 
33
- Modal.VERSION = '3.2.0'
37
+ Modal.VERSION = '3.4.1'
38
+
39
+ Modal.TRANSITION_DURATION = 300
40
+ Modal.BACKDROP_TRANSITION_DURATION = 150
34
41
 
35
42
  Modal.DEFAULTS = {
36
43
  backdrop: true,
@@ -44,7 +51,7 @@
44
51
 
45
52
  Modal.prototype.show = function (_relatedTarget) {
46
53
  var that = this
47
- var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
54
+ var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
48
55
 
49
56
  this.$element.trigger(e)
50
57
 
@@ -53,13 +60,20 @@
53
60
  this.isShown = true
54
61
 
55
62
  this.checkScrollbar()
63
+ this.setScrollbar()
56
64
  this.$body.addClass('modal-open')
57
65
 
58
- this.setScrollbar()
59
66
  this.escape()
67
+ this.resize()
60
68
 
61
69
  this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
62
70
 
71
+ this.$dialog.on('mousedown.dismiss.bs.modal', function () {
72
+ that.$element.one('mouseup.dismiss.bs.modal', function (e) {
73
+ if ($(e.target).is(that.$element)) that.ignoreBackdropClick = true
74
+ })
75
+ })
76
+
63
77
  this.backdrop(function () {
64
78
  var transition = $.support.transition && that.$element.hasClass('fade')
65
79
 
@@ -71,24 +85,24 @@
71
85
  .show()
72
86
  .scrollTop(0)
73
87
 
88
+ that.adjustDialog()
89
+
74
90
  if (transition) {
75
91
  that.$element[0].offsetWidth // force reflow
76
92
  }
77
93
 
78
- that.$element
79
- .addClass('in')
80
- .attr('aria-hidden', false)
94
+ that.$element.addClass('in')
81
95
 
82
96
  that.enforceFocus()
83
97
 
84
98
  var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })
85
99
 
86
100
  transition ?
87
- that.$element.find('.modal-dialog') // wait for modal to slide in
101
+ that.$dialog // wait for modal to slide in
88
102
  .one('bsTransitionEnd', function () {
89
103
  that.$element.trigger('focus').trigger(e)
90
104
  })
91
- .emulateTransitionEnd(300) :
105
+ .emulateTransitionEnd(Modal.TRANSITION_DURATION) :
92
106
  that.$element.trigger('focus').trigger(e)
93
107
  })
94
108
  }
@@ -104,22 +118,22 @@
104
118
 
105
119
  this.isShown = false
106
120
 
107
- this.$body.removeClass('modal-open')
108
-
109
- this.resetScrollbar()
110
121
  this.escape()
122
+ this.resize()
111
123
 
112
124
  $(document).off('focusin.bs.modal')
113
125
 
114
126
  this.$element
115
127
  .removeClass('in')
116
- .attr('aria-hidden', true)
117
128
  .off('click.dismiss.bs.modal')
129
+ .off('mouseup.dismiss.bs.modal')
130
+
131
+ this.$dialog.off('mousedown.dismiss.bs.modal')
118
132
 
119
133
  $.support.transition && this.$element.hasClass('fade') ?
120
134
  this.$element
121
135
  .one('bsTransitionEnd', $.proxy(this.hideModal, this))
122
- .emulateTransitionEnd(300) :
136
+ .emulateTransitionEnd(Modal.TRANSITION_DURATION) :
123
137
  this.hideModal()
124
138
  }
125
139
 
@@ -127,7 +141,9 @@
127
141
  $(document)
128
142
  .off('focusin.bs.modal') // guard against infinite focus loop
129
143
  .on('focusin.bs.modal', $.proxy(function (e) {
130
- if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
144
+ if (document !== e.target &&
145
+ this.$element[0] !== e.target &&
146
+ !this.$element.has(e.target).length) {
131
147
  this.$element.trigger('focus')
132
148
  }
133
149
  }, this))
@@ -135,11 +151,19 @@
135
151
 
136
152
  Modal.prototype.escape = function () {
137
153
  if (this.isShown && this.options.keyboard) {
138
- this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) {
154
+ this.$element.on('keydown.dismiss.bs.modal', $.proxy(function (e) {
139
155
  e.which == 27 && this.hide()
140
156
  }, this))
141
157
  } else if (!this.isShown) {
142
- this.$element.off('keyup.dismiss.bs.modal')
158
+ this.$element.off('keydown.dismiss.bs.modal')
159
+ }
160
+ }
161
+
162
+ Modal.prototype.resize = function () {
163
+ if (this.isShown) {
164
+ $(window).on('resize.bs.modal', $.proxy(this.handleUpdate, this))
165
+ } else {
166
+ $(window).off('resize.bs.modal')
143
167
  }
144
168
  }
145
169
 
@@ -147,6 +171,9 @@
147
171
  var that = this
148
172
  this.$element.hide()
149
173
  this.backdrop(function () {
174
+ that.$body.removeClass('modal-open')
175
+ that.resetAdjustments()
176
+ that.resetScrollbar()
150
177
  that.$element.trigger('hidden.bs.modal')
151
178
  })
152
179
  }
@@ -163,14 +190,19 @@
163
190
  if (this.isShown && this.options.backdrop) {
164
191
  var doAnimate = $.support.transition && animate
165
192
 
166
- this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
193
+ this.$backdrop = $(document.createElement('div'))
194
+ .addClass('modal-backdrop ' + animate)
167
195
  .appendTo(this.$body)
168
196
 
169
197
  this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) {
198
+ if (this.ignoreBackdropClick) {
199
+ this.ignoreBackdropClick = false
200
+ return
201
+ }
170
202
  if (e.target !== e.currentTarget) return
171
203
  this.options.backdrop == 'static'
172
- ? this.$element[0].focus.call(this.$element[0])
173
- : this.hide.call(this)
204
+ ? this.$element[0].focus()
205
+ : this.hide()
174
206
  }, this))
175
207
 
176
208
  if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
@@ -182,7 +214,7 @@
182
214
  doAnimate ?
183
215
  this.$backdrop
184
216
  .one('bsTransitionEnd', callback)
185
- .emulateTransitionEnd(150) :
217
+ .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :
186
218
  callback()
187
219
 
188
220
  } else if (!this.isShown && this.$backdrop) {
@@ -195,7 +227,7 @@
195
227
  $.support.transition && this.$element.hasClass('fade') ?
196
228
  this.$backdrop
197
229
  .one('bsTransitionEnd', callbackRemove)
198
- .emulateTransitionEnd(150) :
230
+ .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :
199
231
  callbackRemove()
200
232
 
201
233
  } else if (callback) {
@@ -203,18 +235,61 @@
203
235
  }
204
236
  }
205
237
 
238
+ // these following methods are used to handle overflowing modals
239
+
240
+ Modal.prototype.handleUpdate = function () {
241
+ this.adjustDialog()
242
+ }
243
+
244
+ Modal.prototype.adjustDialog = function () {
245
+ var modalIsOverflowing = this.$element[0].scrollHeight > document.documentElement.clientHeight
246
+
247
+ this.$element.css({
248
+ paddingLeft: !this.bodyIsOverflowing && modalIsOverflowing ? this.scrollbarWidth : '',
249
+ paddingRight: this.bodyIsOverflowing && !modalIsOverflowing ? this.scrollbarWidth : ''
250
+ })
251
+ }
252
+
253
+ Modal.prototype.resetAdjustments = function () {
254
+ this.$element.css({
255
+ paddingLeft: '',
256
+ paddingRight: ''
257
+ })
258
+ }
259
+
206
260
  Modal.prototype.checkScrollbar = function () {
207
- if (document.body.clientWidth >= window.innerWidth) return
208
- this.scrollbarWidth = this.scrollbarWidth || this.measureScrollbar()
261
+ var fullWindowWidth = window.innerWidth
262
+ if (!fullWindowWidth) { // workaround for missing window.innerWidth in IE8
263
+ var documentElementRect = document.documentElement.getBoundingClientRect()
264
+ fullWindowWidth = documentElementRect.right - Math.abs(documentElementRect.left)
265
+ }
266
+ this.bodyIsOverflowing = document.body.clientWidth < fullWindowWidth
267
+ this.scrollbarWidth = this.measureScrollbar()
209
268
  }
210
269
 
211
270
  Modal.prototype.setScrollbar = function () {
212
271
  var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)
213
- if (this.scrollbarWidth) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)
272
+ this.originalBodyPad = document.body.style.paddingRight || ''
273
+ var scrollbarWidth = this.scrollbarWidth
274
+ if (this.bodyIsOverflowing) {
275
+ this.$body.css('padding-right', bodyPad + scrollbarWidth)
276
+ $(this.fixedContent).each(function (index, element) {
277
+ var actualPadding = element.style.paddingRight
278
+ var calculatedPadding = $(element).css('padding-right')
279
+ $(element)
280
+ .data('padding-right', actualPadding)
281
+ .css('padding-right', parseFloat(calculatedPadding) + scrollbarWidth + 'px')
282
+ })
283
+ }
214
284
  }
215
285
 
216
286
  Modal.prototype.resetScrollbar = function () {
217
- this.$body.css('padding-right', '')
287
+ this.$body.css('padding-right', this.originalBodyPad)
288
+ $(this.fixedContent).each(function (index, element) {
289
+ var padding = $(element).data('padding-right')
290
+ $(element).removeData('padding-right')
291
+ element.style.paddingRight = padding ? padding : ''
292
+ })
218
293
  }
219
294
 
220
295
  Modal.prototype.measureScrollbar = function () { // thx walsh
@@ -232,8 +307,8 @@
232
307
 
233
308
  function Plugin(option, _relatedTarget) {
234
309
  return this.each(function () {
235
- var $this = $(this)
236
- var data = $this.data('bs.modal')
310
+ var $this = $(this)
311
+ var data = $this.data('bs.modal')
237
312
  var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
238
313
 
239
314
  if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
@@ -244,7 +319,7 @@
244
319
 
245
320
  var old = $.fn.modal
246
321
 
247
- $.fn.modal = Plugin
322
+ $.fn.modal = Plugin
248
323
  $.fn.modal.Constructor = Modal
249
324
 
250
325
 
@@ -261,10 +336,13 @@
261
336
  // ==============
262
337
 
263
338
  $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) {
264
- var $this = $(this)
265
- var href = $this.attr('href')
266
- var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) // strip for ie7
267
- var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
339
+ var $this = $(this)
340
+ var href = $this.attr('href')
341
+ var target = $this.attr('data-target') ||
342
+ (href && href.replace(/.*(?=#[^\s]+$)/, '')) // strip for ie7
343
+
344
+ var $target = $(document).find(target)
345
+ var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
268
346
 
269
347
  if ($this.is('a')) e.preventDefault()
270
348