rails_admin 0.6.5 → 0.6.6
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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/rails_admin/bootstrap/bootstrap-affix.js +99 -74
- data/app/assets/javascripts/rails_admin/bootstrap/bootstrap-alert.js +48 -55
- data/app/assets/javascripts/rails_admin/bootstrap/bootstrap-button.js +70 -65
- data/app/assets/javascripts/rails_admin/bootstrap/bootstrap-carousel.js +163 -147
- data/app/assets/javascripts/rails_admin/bootstrap/bootstrap-collapse.js +117 -114
- data/app/assets/javascripts/rails_admin/bootstrap/bootstrap-dropdown.js +89 -107
- data/app/assets/javascripts/rails_admin/bootstrap/bootstrap-modal.js +208 -175
- data/app/assets/javascripts/rails_admin/bootstrap/bootstrap-popover.js +77 -78
- data/app/assets/javascripts/rails_admin/bootstrap/bootstrap-scrollspy.js +137 -129
- data/app/assets/javascripts/rails_admin/bootstrap/bootstrap-tab.js +85 -101
- data/app/assets/javascripts/rails_admin/bootstrap/bootstrap-tooltip.js +364 -268
- data/app/assets/javascripts/rails_admin/bootstrap/bootstrap-transition.js +51 -52
- data/app/assets/javascripts/rails_admin/bootstrap/bootstrap-typeahead.js +1782 -335
- data/app/assets/javascripts/rails_admin/ra.filter-box.js +1 -1
- data/app/assets/javascripts/rails_admin/ra.filtering-multiselect.js +3 -3
- data/app/assets/javascripts/rails_admin/ra.filtering-select.js +1 -1
- data/app/assets/javascripts/rails_admin/ra.remote-form.js +6 -2
- data/app/assets/stylesheets/rails_admin/base/theming.scss +34 -14
- data/app/assets/stylesheets/rails_admin/bootstrap/_alerts.scss +47 -58
- data/app/assets/stylesheets/rails_admin/bootstrap/_badges.scss +57 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/_breadcrumbs.scss +12 -10
- data/app/assets/stylesheets/rails_admin/bootstrap/_button-groups.scss +163 -152
- data/app/assets/stylesheets/rails_admin/bootstrap/_buttons.scss +98 -169
- data/app/assets/stylesheets/rails_admin/bootstrap/_carousel.scss +151 -66
- data/app/assets/stylesheets/rails_admin/bootstrap/_close.scss +11 -8
- data/app/assets/stylesheets/rails_admin/bootstrap/_code.scss +36 -29
- data/app/assets/stylesheets/rails_admin/bootstrap/_component-animations.scss +16 -3
- data/app/assets/stylesheets/rails_admin/bootstrap/_dropdowns.scss +115 -148
- data/app/assets/stylesheets/rails_admin/bootstrap/_forms.scss +396 -547
- data/app/assets/stylesheets/rails_admin/bootstrap/_glyphicons.scss +237 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/_grid.scss +74 -11
- data/app/assets/stylesheets/rails_admin/bootstrap/_input-groups.scss +166 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/_jumbotron.scss +48 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/_labels.scss +66 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/_list-group.scss +131 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/_media.scss +8 -7
- data/app/assets/stylesheets/rails_admin/bootstrap/_mixins.scss +36 -693
- data/app/assets/stylesheets/rails_admin/bootstrap/_modals.scss +108 -53
- data/app/assets/stylesheets/rails_admin/bootstrap/_navbar.scss +545 -383
- data/app/assets/stylesheets/rails_admin/bootstrap/_navs.scss +191 -358
- data/app/assets/stylesheets/rails_admin/bootstrap/_normalize.scss +425 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/_pager.scss +45 -33
- data/app/assets/stylesheets/rails_admin/bootstrap/_pagination.scss +70 -105
- data/app/assets/stylesheets/rails_admin/bootstrap/_panels.scss +243 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/_popovers.scss +61 -61
- data/app/assets/stylesheets/rails_admin/bootstrap/_print.scss +101 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/_progress-bars.scss +56 -73
- data/app/assets/stylesheets/rails_admin/bootstrap/_responsive-embed.scss +34 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/_responsive-utilities.scss +150 -50
- data/app/assets/stylesheets/rails_admin/bootstrap/_scaffolding.scss +120 -23
- data/app/assets/stylesheets/rails_admin/bootstrap/_tables.scss +168 -170
- data/app/assets/stylesheets/rails_admin/bootstrap/_theme.scss +258 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/_thumbnails.scss +27 -42
- data/app/assets/stylesheets/rails_admin/bootstrap/_tooltip.scss +49 -24
- data/app/assets/stylesheets/rails_admin/bootstrap/_type.scss +200 -143
- data/app/assets/stylesheets/rails_admin/bootstrap/_utilities.scss +33 -21
- data/app/assets/stylesheets/rails_admin/bootstrap/_variables.scss +764 -215
- data/app/assets/stylesheets/rails_admin/bootstrap/_wells.scss +7 -7
- data/app/assets/stylesheets/rails_admin/bootstrap/bootstrap.scss +47 -60
- data/app/assets/stylesheets/rails_admin/bootstrap/mixins/_alerts.scss +14 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/mixins/_background-variant.scss +11 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/mixins/_border-radius.scss +18 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/mixins/_buttons.scss +50 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/mixins/_center-block.scss +7 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/mixins/_clearfix.scss +22 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/mixins/_forms.scss +84 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/mixins/_gradients.scss +58 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/mixins/_grid-framework.scss +81 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/mixins/_grid.scss +122 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/mixins/_hide-text.scss +21 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/mixins/_image.scss +34 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/mixins/_labels.scss +12 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/mixins/_list-group.scss +31 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/mixins/_nav-divider.scss +10 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/mixins/_nav-vertical-align.scss +9 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/mixins/_opacity.scss +8 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/mixins/_pagination.scss +23 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/mixins/_panels.scss +24 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/mixins/_progress-bar.scss +10 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/mixins/_reset-filter.scss +8 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/mixins/_resize.scss +6 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/mixins/_responsive-visibility.scss +21 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/mixins/_size.scss +10 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/mixins/_tab-focus.scss +9 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/mixins/_table-row.scss +28 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/mixins/_text-emphasis.scss +11 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/mixins/_text-overflow.scss +8 -0
- data/app/assets/stylesheets/rails_admin/bootstrap/mixins/_vendor-prefixes.scss +219 -0
- data/app/assets/stylesheets/rails_admin/ra.calendar-additions.scss +17 -0
- data/app/assets/stylesheets/rails_admin/rails_admin.scss.erb +9 -5
- data/app/helpers/rails_admin/application_helper.rb +20 -19
- data/app/helpers/rails_admin/form_builder.rb +14 -11
- data/app/views/kaminari/twitter-bootstrap/_paginator.html.haml +8 -9
- data/app/views/layouts/rails_admin/_navigation.html.haml +5 -5
- data/app/views/layouts/rails_admin/_secondary_navigation.html.haml +1 -1
- data/app/views/layouts/rails_admin/application.html.haml +9 -8
- data/app/views/layouts/rails_admin/pjax.html.haml +4 -3
- data/app/views/rails_admin/main/_form_datetime.html.haml +2 -1
- data/app/views/rails_admin/main/_form_field.html.haml +1 -1
- data/app/views/rails_admin/main/_form_text.html.haml +1 -1
- data/app/views/rails_admin/main/_submit_buttons.html.haml +1 -0
- data/app/views/rails_admin/main/dashboard.html.haml +1 -1
- data/app/views/rails_admin/main/export.html.haml +19 -16
- data/app/views/rails_admin/main/index.html.haml +11 -7
- data/app/views/rails_admin/main/show.html.haml +1 -1
- data/lib/rails_admin/adapters/active_record.rb +2 -2
- data/lib/rails_admin/adapters/mongoid/property.rb +1 -1
- data/lib/rails_admin/config/actions/bulk_delete.rb +0 -1
- data/lib/rails_admin/config/actions/edit.rb +0 -2
- data/lib/rails_admin/config/actions/export.rb +0 -2
- data/lib/rails_admin/config/actions/index.rb +0 -3
- data/lib/rails_admin/config/actions/new.rb +0 -2
- data/lib/rails_admin/config/configurable.rb +1 -1
- data/lib/rails_admin/config/fields/base.rb +9 -0
- data/lib/rails_admin/config/fields/factories/enum.rb +2 -3
- data/lib/rails_admin/config/fields/types/polymorphic_association.rb +4 -0
- data/lib/rails_admin/config/model.rb +2 -1
- data/lib/rails_admin/extensions/paper_trail/auditing_adapter.rb +2 -2
- data/lib/rails_admin/support/csv_converter.rb +22 -42
- data/lib/rails_admin/version.rb +1 -1
- metadata +59 -18
- data/app/assets/stylesheets/rails_admin/bootstrap/_accordion.scss +0 -34
- data/app/assets/stylesheets/rails_admin/bootstrap/_hero-unit.scss +0 -25
- data/app/assets/stylesheets/rails_admin/bootstrap/_labels-badges.scss +0 -83
- data/app/assets/stylesheets/rails_admin/bootstrap/_layouts.scss +0 -16
- data/app/assets/stylesheets/rails_admin/bootstrap/_reset.scss +0 -216
- data/app/assets/stylesheets/rails_admin/bootstrap/_responsive-1200px-min.scss +0 -28
- data/app/assets/stylesheets/rails_admin/bootstrap/_responsive-767px-max.scss +0 -193
- data/app/assets/stylesheets/rails_admin/bootstrap/_responsive-768px-979px.scss +0 -19
- data/app/assets/stylesheets/rails_admin/bootstrap/_responsive-navbar.scss +0 -189
- data/app/assets/stylesheets/rails_admin/bootstrap/_sprites.scss +0 -197
- data/app/assets/stylesheets/rails_admin/bootstrap/responsive.scss +0 -48
@@ -1,155 +1,137 @@
|
|
1
|
-
/*
|
2
|
-
*
|
3
|
-
* http://getbootstrap.com/
|
4
|
-
*
|
5
|
-
* Copyright
|
6
|
-
*
|
7
|
-
*
|
8
|
-
* you may not use this file except in compliance with the License.
|
9
|
-
* You may obtain a copy of the License at
|
10
|
-
*
|
11
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
*
|
13
|
-
* Unless required by applicable law or agreed to in writing, software
|
14
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
* See the License for the specific language governing permissions and
|
17
|
-
* limitations under the License.
|
18
|
-
* ============================================================ */
|
19
|
-
|
20
|
-
|
21
|
-
!function ($) {
|
22
|
-
|
23
|
-
"use strict"; // jshint ;_;
|
24
|
-
|
25
|
-
|
26
|
-
/* DROPDOWN CLASS DEFINITION
|
27
|
-
* ========================= */
|
28
|
-
|
29
|
-
var toggle = '[data-toggle=dropdown]'
|
30
|
-
, Dropdown = function (element) {
|
31
|
-
var $el = $(element).on('click.dropdown.data-api', this.toggle)
|
32
|
-
$('html').on('click.dropdown.data-api', function () {
|
33
|
-
$el.parent().removeClass('open')
|
34
|
-
})
|
35
|
-
}
|
1
|
+
/* ========================================================================
|
2
|
+
* Bootstrap: dropdown.js v3.2.0
|
3
|
+
* http://getbootstrap.com/javascript/#dropdowns
|
4
|
+
* ========================================================================
|
5
|
+
* Copyright 2011-2014 Twitter, Inc.
|
6
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
7
|
+
* ======================================================================== */
|
36
8
|
|
37
|
-
Dropdown.prototype = {
|
38
9
|
|
39
|
-
|
10
|
+
+function ($) {
|
11
|
+
'use strict';
|
40
12
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
13
|
+
// DROPDOWN CLASS DEFINITION
|
14
|
+
// =========================
|
15
|
+
|
16
|
+
var backdrop = '.dropdown-backdrop'
|
17
|
+
var toggle = '[data-toggle="dropdown"]'
|
18
|
+
var Dropdown = function (element) {
|
19
|
+
$(element).on('click.bs.dropdown', this.toggle)
|
20
|
+
}
|
21
|
+
|
22
|
+
Dropdown.VERSION = '3.2.0'
|
45
23
|
|
46
|
-
|
24
|
+
Dropdown.prototype.toggle = function (e) {
|
25
|
+
var $this = $(this)
|
47
26
|
|
48
|
-
|
27
|
+
if ($this.is('.disabled, :disabled')) return
|
49
28
|
|
50
|
-
|
29
|
+
var $parent = getParent($this)
|
30
|
+
var isActive = $parent.hasClass('open')
|
51
31
|
|
52
|
-
|
32
|
+
clearMenus()
|
53
33
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
}
|
59
|
-
$parent.toggleClass('open')
|
34
|
+
if (!isActive) {
|
35
|
+
if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
|
36
|
+
// if mobile we use a backdrop because click events don't delegate
|
37
|
+
$('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus)
|
60
38
|
}
|
61
39
|
|
62
|
-
|
40
|
+
var relatedTarget = { relatedTarget: this }
|
41
|
+
$parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget))
|
63
42
|
|
64
|
-
return
|
65
|
-
}
|
43
|
+
if (e.isDefaultPrevented()) return
|
66
44
|
|
67
|
-
|
68
|
-
var $this
|
69
|
-
, $items
|
70
|
-
, $active
|
71
|
-
, $parent
|
72
|
-
, isActive
|
73
|
-
, index
|
45
|
+
$this.trigger('focus')
|
74
46
|
|
75
|
-
|
47
|
+
$parent
|
48
|
+
.toggleClass('open')
|
49
|
+
.trigger('shown.bs.dropdown', relatedTarget)
|
50
|
+
}
|
76
51
|
|
77
|
-
|
52
|
+
return false
|
53
|
+
}
|
78
54
|
|
79
|
-
|
80
|
-
|
55
|
+
Dropdown.prototype.keydown = function (e) {
|
56
|
+
if (!/(38|40|27)/.test(e.keyCode)) return
|
81
57
|
|
82
|
-
|
58
|
+
var $this = $(this)
|
83
59
|
|
84
|
-
|
60
|
+
e.preventDefault()
|
61
|
+
e.stopPropagation()
|
85
62
|
|
86
|
-
|
63
|
+
if ($this.is('.disabled, :disabled')) return
|
87
64
|
|
88
|
-
|
89
|
-
|
90
|
-
return $this.click()
|
91
|
-
}
|
65
|
+
var $parent = getParent($this)
|
66
|
+
var isActive = $parent.hasClass('open')
|
92
67
|
|
93
|
-
|
68
|
+
if (!isActive || (isActive && e.keyCode == 27)) {
|
69
|
+
if (e.which == 27) $parent.find(toggle).trigger('focus')
|
70
|
+
return $this.trigger('click')
|
71
|
+
}
|
94
72
|
|
95
|
-
|
73
|
+
var desc = ' li:not(.divider):visible a'
|
74
|
+
var $items = $parent.find('[role="menu"]' + desc + ', [role="listbox"]' + desc)
|
96
75
|
|
97
|
-
|
76
|
+
if (!$items.length) return
|
98
77
|
|
99
|
-
|
100
|
-
if (e.keyCode == 40 && index < $items.length - 1) index++ // down
|
101
|
-
if (!~index) index = 0
|
78
|
+
var index = $items.index($items.filter(':focus'))
|
102
79
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
}
|
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
|
107
83
|
|
84
|
+
$items.eq(index).trigger('focus')
|
108
85
|
}
|
109
86
|
|
110
|
-
function clearMenus() {
|
111
|
-
|
87
|
+
function clearMenus(e) {
|
88
|
+
if (e && e.which === 3) return
|
89
|
+
$(backdrop).remove()
|
112
90
|
$(toggle).each(function () {
|
113
|
-
getParent($(this))
|
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)
|
114
97
|
})
|
115
98
|
}
|
116
99
|
|
117
100
|
function getParent($this) {
|
118
101
|
var selector = $this.attr('data-target')
|
119
|
-
, $parent
|
120
102
|
|
121
103
|
if (!selector) {
|
122
104
|
selector = $this.attr('href')
|
123
|
-
selector = selector &&
|
105
|
+
selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
|
124
106
|
}
|
125
107
|
|
126
|
-
$parent = selector && $(selector)
|
108
|
+
var $parent = selector && $(selector)
|
127
109
|
|
128
|
-
|
129
|
-
|
130
|
-
return $parent
|
110
|
+
return $parent && $parent.length ? $parent : $this.parent()
|
131
111
|
}
|
132
112
|
|
133
113
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
var old = $.fn.dropdown
|
114
|
+
// DROPDOWN PLUGIN DEFINITION
|
115
|
+
// ==========================
|
138
116
|
|
139
|
-
|
117
|
+
function Plugin(option) {
|
140
118
|
return this.each(function () {
|
141
119
|
var $this = $(this)
|
142
|
-
|
143
|
-
|
120
|
+
var data = $this.data('bs.dropdown')
|
121
|
+
|
122
|
+
if (!data) $this.data('bs.dropdown', (data = new Dropdown(this)))
|
144
123
|
if (typeof option == 'string') data[option].call($this)
|
145
124
|
})
|
146
125
|
}
|
147
126
|
|
127
|
+
var old = $.fn.dropdown
|
128
|
+
|
129
|
+
$.fn.dropdown = Plugin
|
148
130
|
$.fn.dropdown.Constructor = Dropdown
|
149
131
|
|
150
132
|
|
151
|
-
|
152
|
-
|
133
|
+
// DROPDOWN NO CONFLICT
|
134
|
+
// ====================
|
153
135
|
|
154
136
|
$.fn.dropdown.noConflict = function () {
|
155
137
|
$.fn.dropdown = old
|
@@ -157,13 +139,13 @@
|
|
157
139
|
}
|
158
140
|
|
159
141
|
|
160
|
-
|
161
|
-
|
142
|
+
// APPLY TO STANDARD DROPDOWN ELEMENTS
|
143
|
+
// ===================================
|
162
144
|
|
163
145
|
$(document)
|
164
|
-
.on('click.dropdown.data-api', clearMenus)
|
165
|
-
.on('click.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
|
166
|
-
.on('click.dropdown.data-api'
|
167
|
-
.on('keydown.dropdown.data-api', toggle + ', [role=menu]'
|
146
|
+
.on('click.bs.dropdown.data-api', clearMenus)
|
147
|
+
.on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
|
148
|
+
.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)
|
168
150
|
|
169
|
-
}(
|
151
|
+
}(jQuery);
|
@@ -1,224 +1,255 @@
|
|
1
|
-
/*
|
2
|
-
*
|
3
|
-
* http://getbootstrap.com/
|
4
|
-
*
|
5
|
-
* Copyright
|
6
|
-
*
|
7
|
-
*
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
* See the License for the specific language governing permissions and
|
17
|
-
* limitations under the License.
|
18
|
-
* ========================================================= */
|
19
|
-
|
20
|
-
|
21
|
-
!function ($) {
|
22
|
-
|
23
|
-
"use strict"; // jshint ;_;
|
24
|
-
|
25
|
-
|
26
|
-
/* MODAL CLASS DEFINITION
|
27
|
-
* ====================== */
|
1
|
+
/* ========================================================================
|
2
|
+
* Bootstrap: modal.js v3.2.0
|
3
|
+
* http://getbootstrap.com/javascript/#modals
|
4
|
+
* ========================================================================
|
5
|
+
* Copyright 2011-2014 Twitter, Inc.
|
6
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
|
7
|
+
* ======================================================================== */
|
8
|
+
|
9
|
+
|
10
|
+
+function ($) {
|
11
|
+
'use strict';
|
12
|
+
|
13
|
+
// MODAL CLASS DEFINITION
|
14
|
+
// ======================
|
28
15
|
|
29
16
|
var Modal = function (element, options) {
|
30
|
-
this.options
|
31
|
-
this.$
|
32
|
-
|
33
|
-
this
|
17
|
+
this.options = options
|
18
|
+
this.$body = $(document.body)
|
19
|
+
this.$element = $(element)
|
20
|
+
this.$backdrop =
|
21
|
+
this.isShown = null
|
22
|
+
this.scrollbarWidth = 0
|
23
|
+
|
24
|
+
if (this.options.remote) {
|
25
|
+
this.$element
|
26
|
+
.find('.modal-content')
|
27
|
+
.load(this.options.remote, $.proxy(function () {
|
28
|
+
this.$element.trigger('loaded.bs.modal')
|
29
|
+
}, this))
|
30
|
+
}
|
34
31
|
}
|
35
32
|
|
36
|
-
Modal.
|
33
|
+
Modal.VERSION = '3.2.0'
|
37
34
|
|
38
|
-
|
35
|
+
Modal.DEFAULTS = {
|
36
|
+
backdrop: true,
|
37
|
+
keyboard: true,
|
38
|
+
show: true
|
39
|
+
}
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
41
|
+
Modal.prototype.toggle = function (_relatedTarget) {
|
42
|
+
return this.isShown ? this.hide() : this.show(_relatedTarget)
|
43
|
+
}
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
45
|
+
Modal.prototype.show = function (_relatedTarget) {
|
46
|
+
var that = this
|
47
|
+
var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
|
47
48
|
|
48
|
-
|
49
|
+
this.$element.trigger(e)
|
49
50
|
|
50
|
-
|
51
|
+
if (this.isShown || e.isDefaultPrevented()) return
|
51
52
|
|
52
|
-
|
53
|
+
this.isShown = true
|
53
54
|
|
54
|
-
|
55
|
+
this.checkScrollbar()
|
56
|
+
this.$body.addClass('modal-open')
|
55
57
|
|
56
|
-
|
57
|
-
|
58
|
+
this.setScrollbar()
|
59
|
+
this.escape()
|
58
60
|
|
59
|
-
|
60
|
-
that.$element.appendTo(document.body) //don't move modals dom position
|
61
|
-
}
|
61
|
+
this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
|
62
62
|
|
63
|
-
|
63
|
+
this.backdrop(function () {
|
64
|
+
var transition = $.support.transition && that.$element.hasClass('fade')
|
64
65
|
|
65
|
-
|
66
|
-
|
67
|
-
|
66
|
+
if (!that.$element.parent().length) {
|
67
|
+
that.$element.appendTo(that.$body) // don't move modals dom position
|
68
|
+
}
|
68
69
|
|
69
|
-
|
70
|
-
|
71
|
-
|
70
|
+
that.$element
|
71
|
+
.show()
|
72
|
+
.scrollTop(0)
|
72
73
|
|
73
|
-
|
74
|
+
if (transition) {
|
75
|
+
that.$element[0].offsetWidth // force reflow
|
76
|
+
}
|
74
77
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
+
that.$element
|
79
|
+
.addClass('in')
|
80
|
+
.attr('aria-hidden', false)
|
78
81
|
|
79
|
-
|
80
|
-
|
82
|
+
that.enforceFocus()
|
83
|
+
|
84
|
+
var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })
|
81
85
|
|
82
|
-
|
83
|
-
|
86
|
+
transition ?
|
87
|
+
that.$element.find('.modal-dialog') // wait for modal to slide in
|
88
|
+
.one('bsTransitionEnd', function () {
|
89
|
+
that.$element.trigger('focus').trigger(e)
|
90
|
+
})
|
91
|
+
.emulateTransitionEnd(300) :
|
92
|
+
that.$element.trigger('focus').trigger(e)
|
93
|
+
})
|
94
|
+
}
|
84
95
|
|
85
|
-
|
96
|
+
Modal.prototype.hide = function (e) {
|
97
|
+
if (e) e.preventDefault()
|
86
98
|
|
87
|
-
|
99
|
+
e = $.Event('hide.bs.modal')
|
88
100
|
|
89
|
-
|
101
|
+
this.$element.trigger(e)
|
90
102
|
|
91
|
-
|
103
|
+
if (!this.isShown || e.isDefaultPrevented()) return
|
92
104
|
|
93
|
-
|
105
|
+
this.isShown = false
|
94
106
|
|
95
|
-
|
107
|
+
this.$body.removeClass('modal-open')
|
96
108
|
|
97
|
-
|
109
|
+
this.resetScrollbar()
|
110
|
+
this.escape()
|
98
111
|
|
99
|
-
|
100
|
-
.removeClass('in')
|
101
|
-
.attr('aria-hidden', true)
|
112
|
+
$(document).off('focusin.bs.modal')
|
102
113
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
114
|
+
this.$element
|
115
|
+
.removeClass('in')
|
116
|
+
.attr('aria-hidden', true)
|
117
|
+
.off('click.dismiss.bs.modal')
|
107
118
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
})
|
115
|
-
}
|
119
|
+
$.support.transition && this.$element.hasClass('fade') ?
|
120
|
+
this.$element
|
121
|
+
.one('bsTransitionEnd', $.proxy(this.hideModal, this))
|
122
|
+
.emulateTransitionEnd(300) :
|
123
|
+
this.hideModal()
|
124
|
+
}
|
116
125
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
} else if (!this.isShown) {
|
124
|
-
this.$element.off('keyup.dismiss.modal')
|
126
|
+
Modal.prototype.enforceFocus = function () {
|
127
|
+
$(document)
|
128
|
+
.off('focusin.bs.modal') // guard against infinite focus loop
|
129
|
+
.on('focusin.bs.modal', $.proxy(function (e) {
|
130
|
+
if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
|
131
|
+
this.$element.trigger('focus')
|
125
132
|
}
|
126
|
-
}
|
127
|
-
|
128
|
-
, hideWithTransition: function () {
|
129
|
-
var that = this
|
130
|
-
, timeout = setTimeout(function () {
|
131
|
-
that.$element.off($.support.transition.end)
|
132
|
-
that.hideModal()
|
133
|
-
}, 500)
|
134
|
-
|
135
|
-
this.$element.one($.support.transition.end, function () {
|
136
|
-
clearTimeout(timeout)
|
137
|
-
that.hideModal()
|
138
|
-
})
|
139
|
-
}
|
133
|
+
}, this))
|
134
|
+
}
|
140
135
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
this.
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
136
|
+
Modal.prototype.escape = function () {
|
137
|
+
if (this.isShown && this.options.keyboard) {
|
138
|
+
this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) {
|
139
|
+
e.which == 27 && this.hide()
|
140
|
+
}, this))
|
141
|
+
} else if (!this.isShown) {
|
142
|
+
this.$element.off('keyup.dismiss.bs.modal')
|
143
|
+
}
|
144
|
+
}
|
149
145
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
146
|
+
Modal.prototype.hideModal = function () {
|
147
|
+
var that = this
|
148
|
+
this.$element.hide()
|
149
|
+
this.backdrop(function () {
|
150
|
+
that.$element.trigger('hidden.bs.modal')
|
151
|
+
})
|
152
|
+
}
|
154
153
|
|
155
|
-
|
156
|
-
|
157
|
-
|
154
|
+
Modal.prototype.removeBackdrop = function () {
|
155
|
+
this.$backdrop && this.$backdrop.remove()
|
156
|
+
this.$backdrop = null
|
157
|
+
}
|
158
158
|
|
159
|
-
|
160
|
-
|
159
|
+
Modal.prototype.backdrop = function (callback) {
|
160
|
+
var that = this
|
161
|
+
var animate = this.$element.hasClass('fade') ? 'fade' : ''
|
161
162
|
|
162
|
-
|
163
|
-
|
163
|
+
if (this.isShown && this.options.backdrop) {
|
164
|
+
var doAnimate = $.support.transition && animate
|
164
165
|
|
165
|
-
|
166
|
-
|
167
|
-
$.proxy(this.$element[0].focus, this.$element[0])
|
168
|
-
: $.proxy(this.hide, this)
|
169
|
-
)
|
166
|
+
this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
|
167
|
+
.appendTo(this.$body)
|
170
168
|
|
171
|
-
|
169
|
+
this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) {
|
170
|
+
if (e.target !== e.currentTarget) return
|
171
|
+
this.options.backdrop == 'static'
|
172
|
+
? this.$element[0].focus.call(this.$element[0])
|
173
|
+
: this.hide.call(this)
|
174
|
+
}, this))
|
172
175
|
|
173
|
-
|
176
|
+
if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
|
174
177
|
|
175
|
-
|
178
|
+
this.$backdrop.addClass('in')
|
176
179
|
|
177
|
-
|
178
|
-
this.$backdrop.one($.support.transition.end, callback) :
|
179
|
-
callback()
|
180
|
+
if (!callback) return
|
180
181
|
|
181
|
-
|
182
|
-
|
182
|
+
doAnimate ?
|
183
|
+
this.$backdrop
|
184
|
+
.one('bsTransitionEnd', callback)
|
185
|
+
.emulateTransitionEnd(150) :
|
186
|
+
callback()
|
183
187
|
|
184
|
-
|
185
|
-
|
186
|
-
callback()
|
188
|
+
} else if (!this.isShown && this.$backdrop) {
|
189
|
+
this.$backdrop.removeClass('in')
|
187
190
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
+
var callbackRemove = function () {
|
192
|
+
that.removeBackdrop()
|
193
|
+
callback && callback()
|
191
194
|
}
|
195
|
+
$.support.transition && this.$element.hasClass('fade') ?
|
196
|
+
this.$backdrop
|
197
|
+
.one('bsTransitionEnd', callbackRemove)
|
198
|
+
.emulateTransitionEnd(150) :
|
199
|
+
callbackRemove()
|
200
|
+
|
201
|
+
} else if (callback) {
|
202
|
+
callback()
|
203
|
+
}
|
204
|
+
}
|
205
|
+
|
206
|
+
Modal.prototype.checkScrollbar = function () {
|
207
|
+
if (document.body.clientWidth >= window.innerWidth) return
|
208
|
+
this.scrollbarWidth = this.scrollbarWidth || this.measureScrollbar()
|
192
209
|
}
|
193
210
|
|
211
|
+
Modal.prototype.setScrollbar = function () {
|
212
|
+
var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)
|
213
|
+
if (this.scrollbarWidth) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)
|
214
|
+
}
|
194
215
|
|
195
|
-
|
196
|
-
|
216
|
+
Modal.prototype.resetScrollbar = function () {
|
217
|
+
this.$body.css('padding-right', '')
|
218
|
+
}
|
219
|
+
|
220
|
+
Modal.prototype.measureScrollbar = function () { // thx walsh
|
221
|
+
var scrollDiv = document.createElement('div')
|
222
|
+
scrollDiv.className = 'modal-scrollbar-measure'
|
223
|
+
this.$body.append(scrollDiv)
|
224
|
+
var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
|
225
|
+
this.$body[0].removeChild(scrollDiv)
|
226
|
+
return scrollbarWidth
|
227
|
+
}
|
197
228
|
|
198
|
-
var old = $.fn.modal
|
199
229
|
|
200
|
-
|
230
|
+
// MODAL PLUGIN DEFINITION
|
231
|
+
// =======================
|
232
|
+
|
233
|
+
function Plugin(option, _relatedTarget) {
|
201
234
|
return this.each(function () {
|
202
|
-
var $this
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
if (
|
207
|
-
|
235
|
+
var $this = $(this)
|
236
|
+
var data = $this.data('bs.modal')
|
237
|
+
var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
|
238
|
+
|
239
|
+
if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
|
240
|
+
if (typeof option == 'string') data[option](_relatedTarget)
|
241
|
+
else if (options.show) data.show(_relatedTarget)
|
208
242
|
})
|
209
243
|
}
|
210
244
|
|
211
|
-
$.fn.modal
|
212
|
-
backdrop: true
|
213
|
-
, keyboard: true
|
214
|
-
, show: true
|
215
|
-
}
|
245
|
+
var old = $.fn.modal
|
216
246
|
|
247
|
+
$.fn.modal = Plugin
|
217
248
|
$.fn.modal.Constructor = Modal
|
218
249
|
|
219
250
|
|
220
|
-
|
221
|
-
|
251
|
+
// MODAL NO CONFLICT
|
252
|
+
// =================
|
222
253
|
|
223
254
|
$.fn.modal.noConflict = function () {
|
224
255
|
$.fn.modal = old
|
@@ -226,22 +257,24 @@
|
|
226
257
|
}
|
227
258
|
|
228
259
|
|
229
|
-
|
230
|
-
|
260
|
+
// MODAL DATA-API
|
261
|
+
// ==============
|
231
262
|
|
232
|
-
$(document).on('click.modal.data-api', '[data-toggle="modal"]', function (e) {
|
233
|
-
var $this
|
234
|
-
|
235
|
-
|
236
|
-
|
263
|
+
$(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())
|
237
268
|
|
238
|
-
e.preventDefault()
|
269
|
+
if ($this.is('a')) e.preventDefault()
|
239
270
|
|
240
|
-
$target
|
241
|
-
.
|
242
|
-
.one('
|
243
|
-
$this.
|
271
|
+
$target.one('show.bs.modal', function (showEvent) {
|
272
|
+
if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown
|
273
|
+
$target.one('hidden.bs.modal', function () {
|
274
|
+
$this.is(':visible') && $this.trigger('focus')
|
244
275
|
})
|
276
|
+
})
|
277
|
+
Plugin.call($target, option, this)
|
245
278
|
})
|
246
279
|
|
247
|
-
}(
|
280
|
+
}(jQuery);
|