boostrap_modal_rails 0.1.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 +7 -0
- data/.DS_Store +0 -0
- data/.gitignore +9 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +66 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/boostrap_modal_rails.gemspec +22 -0
- data/lib/boostrap_modal_rails/version.rb +3 -0
- data/lib/boostrap_modal_rails.rb +5 -0
- data/vendor/.DS_Store +0 -0
- data/vendor/assets/.DS_Store +0 -0
- data/vendor/assets/css/bootstrap-modal-bs3patch.css +45 -0
- data/vendor/assets/css/bootstrap-modal.css +214 -0
- data/vendor/assets/img/ajax-loader.gif +0 -0
- data/vendor/assets/js/bootstrap-modal.js +378 -0
- data/vendor/assets/js/bootstrap-modalmanager.js +423 -0
- metadata +92 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 09400afd84286c1a99d39df1ce31903b0cc27a90
|
4
|
+
data.tar.gz: c02bd589bd8354d80e3a59d11304d3d111403965
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 188d7786f76435a7c4def305d1d12aa4924d3a603f180e14bce95b5e70c15fcd9d570d6346cdcfb83736b5cd43d1c4c4a27c952eb29512c3b69701757db7447f
|
7
|
+
data.tar.gz: 7cac9a44d4686cc4619fe752b9b10f29689e3141753eafe32b878a9af70d154ae71a2fc6a0675e1177ba7374bfff31c57ce947c7c9b88f938fc0c95b53b285ac
|
data/.DS_Store
ADDED
Binary file
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Peter Le
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# BoostrapModalRails
|
2
|
+
|
3
|
+
Rails Asset Gem for the default [Bootstrap Modal](https://github.com/jschr/bootstrap-modal) class by [Jordan Schroter](https://github.com/jschr)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add these lines to your application's `Gemfile`:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
|
11
|
+
### Rails 3 or previous
|
12
|
+
|
13
|
+
group :assets do
|
14
|
+
gem 'bootstrap-modal-rails'
|
15
|
+
end
|
16
|
+
|
17
|
+
### Rails 4
|
18
|
+
|
19
|
+
gem 'bootstrap-modal-rails'
|
20
|
+
|
21
|
+
```
|
22
|
+
|
23
|
+
And then execute:
|
24
|
+
|
25
|
+
```bash
|
26
|
+
$ bundle install
|
27
|
+
```
|
28
|
+
|
29
|
+
Or install it yourself as:
|
30
|
+
|
31
|
+
```bash
|
32
|
+
$ gem install bootstrap-modal-rails
|
33
|
+
```
|
34
|
+
|
35
|
+
## Usage
|
36
|
+
|
37
|
+
### Stylesheets
|
38
|
+
|
39
|
+
```sass
|
40
|
+
//=require tree .
|
41
|
+
//=require bootstrap-modal
|
42
|
+
```
|
43
|
+
|
44
|
+
Or if you are using Rails 4
|
45
|
+
|
46
|
+
```sass
|
47
|
+
*= require tree .
|
48
|
+
*= require bootstrap-modal-bs3patch
|
49
|
+
*= require bootstrap-modal
|
50
|
+
```
|
51
|
+
|
52
|
+
### Javascripts
|
53
|
+
|
54
|
+
coffeescript
|
55
|
+
```coffeescript
|
56
|
+
#= require bootstrap-modal
|
57
|
+
#= require bootstrap-modalmanager
|
58
|
+
```
|
59
|
+
|
60
|
+
javascript
|
61
|
+
```javascript
|
62
|
+
//= require bootstrap-modal
|
63
|
+
//= require bootstrap-modalmanager
|
64
|
+
```
|
65
|
+
|
66
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "boostrap_modal_rails"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'boostrap_modal_rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "boostrap_modal_rails"
|
8
|
+
spec.version = BoostrapModalRails::VERSION
|
9
|
+
spec.authors = ["Peter Le"]
|
10
|
+
spec.email = ["peter@peterkle.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Wrapper for boostrap-model library <https://github.com/jschr/bootstrap-modal>}
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.bindir = "exe"
|
17
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
end
|
data/vendor/.DS_Store
ADDED
Binary file
|
Binary file
|
@@ -0,0 +1,45 @@
|
|
1
|
+
/*!
|
2
|
+
* Bootstrap Modal
|
3
|
+
*
|
4
|
+
* Copyright Jordan Schroter
|
5
|
+
* Licensed under the Apache License v2.0
|
6
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
*
|
8
|
+
* Boostrap 3 patch for for bootstrap-modal. Include BEFORE bootstrap-modal.css!
|
9
|
+
*/
|
10
|
+
|
11
|
+
body.modal-open,
|
12
|
+
.modal-open .navbar-fixed-top,
|
13
|
+
.modal-open .navbar-fixed-bottom {
|
14
|
+
margin-right: 0;
|
15
|
+
}
|
16
|
+
|
17
|
+
.modal {
|
18
|
+
left: 50%;
|
19
|
+
bottom: auto;
|
20
|
+
right: auto;
|
21
|
+
z-index: 1050;
|
22
|
+
padding: 0;
|
23
|
+
width: 500px;
|
24
|
+
margin-left: -250px;
|
25
|
+
background-color: #ffffff;
|
26
|
+
border: 1px solid #999999;
|
27
|
+
border: 1px solid rgba(0, 0, 0, 0.2);
|
28
|
+
border-radius: 6px;
|
29
|
+
-webkit-box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5);
|
30
|
+
box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5);
|
31
|
+
background-clip: padding-box;
|
32
|
+
}
|
33
|
+
|
34
|
+
.modal.container {
|
35
|
+
max-width: none;
|
36
|
+
}
|
37
|
+
|
38
|
+
.modal-backdrop {
|
39
|
+
position: fixed;
|
40
|
+
top: 0;
|
41
|
+
right: 0;
|
42
|
+
bottom: 0;
|
43
|
+
left: 0;
|
44
|
+
z-index: 1040;
|
45
|
+
}
|
@@ -0,0 +1,214 @@
|
|
1
|
+
/*!
|
2
|
+
* Bootstrap Modal
|
3
|
+
*
|
4
|
+
* Copyright Jordan Schroter
|
5
|
+
* Licensed under the Apache License v2.0
|
6
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
*
|
8
|
+
*/
|
9
|
+
|
10
|
+
.modal-open {
|
11
|
+
overflow: hidden;
|
12
|
+
}
|
13
|
+
|
14
|
+
|
15
|
+
/* add a scroll bar to stop page from jerking around */
|
16
|
+
.modal-open.page-overflow .page-container,
|
17
|
+
.modal-open.page-overflow .page-container .navbar-fixed-top,
|
18
|
+
.modal-open.page-overflow .page-container .navbar-fixed-bottom,
|
19
|
+
.modal-open.page-overflow .modal-scrollable {
|
20
|
+
overflow-y: scroll;
|
21
|
+
}
|
22
|
+
|
23
|
+
@media (max-width: 979px) {
|
24
|
+
.modal-open.page-overflow .page-container .navbar-fixed-top,
|
25
|
+
.modal-open.page-overflow .page-container .navbar-fixed-bottom {
|
26
|
+
overflow-y: visible;
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
|
31
|
+
.modal-scrollable {
|
32
|
+
position: fixed;
|
33
|
+
top: 0;
|
34
|
+
bottom: 0;
|
35
|
+
left: 0;
|
36
|
+
right: 0;
|
37
|
+
overflow: auto;
|
38
|
+
}
|
39
|
+
|
40
|
+
.modal {
|
41
|
+
outline: none;
|
42
|
+
position: absolute;
|
43
|
+
margin-top: 0;
|
44
|
+
top: 50%;
|
45
|
+
overflow: visible; /* allow content to popup out (i.e tooltips) */
|
46
|
+
}
|
47
|
+
|
48
|
+
.modal.fade {
|
49
|
+
top: -100%;
|
50
|
+
-webkit-transition: opacity 0.3s linear, top 0.3s ease-out, bottom 0.3s ease-out, margin-top 0.3s ease-out;
|
51
|
+
-moz-transition: opacity 0.3s linear, top 0.3s ease-out, bottom 0.3s ease-out, margin-top 0.3s ease-out;
|
52
|
+
-o-transition: opacity 0.3s linear, top 0.3s ease-out, bottom 0.3s ease-out, margin-top 0.3s ease-out;
|
53
|
+
transition: opacity 0.3s linear, top 0.3s ease-out, bottom 0.3s ease-out, margin-top 0.3s ease-out;
|
54
|
+
}
|
55
|
+
|
56
|
+
.modal.fade.in {
|
57
|
+
top: 50%;
|
58
|
+
}
|
59
|
+
|
60
|
+
.modal-body {
|
61
|
+
max-height: none;
|
62
|
+
overflow: visible;
|
63
|
+
}
|
64
|
+
|
65
|
+
.modal.modal-absolute {
|
66
|
+
position: absolute;
|
67
|
+
z-index: 950;
|
68
|
+
}
|
69
|
+
|
70
|
+
.modal .loading-mask {
|
71
|
+
position: absolute;
|
72
|
+
top: 0;
|
73
|
+
bottom: 0;
|
74
|
+
left: 0;
|
75
|
+
right: 0;
|
76
|
+
background: #fff;
|
77
|
+
border-radius: 6px;
|
78
|
+
}
|
79
|
+
|
80
|
+
.modal-backdrop.modal-absolute{
|
81
|
+
position: absolute;
|
82
|
+
z-index: 940;
|
83
|
+
}
|
84
|
+
|
85
|
+
.modal-backdrop,
|
86
|
+
.modal-backdrop.fade.in{
|
87
|
+
opacity: 0.7;
|
88
|
+
filter: alpha(opacity=70);
|
89
|
+
background: #fff;
|
90
|
+
}
|
91
|
+
|
92
|
+
.modal.container {
|
93
|
+
width: 940px;
|
94
|
+
margin-left: -470px;
|
95
|
+
}
|
96
|
+
|
97
|
+
/* Modal Overflow */
|
98
|
+
|
99
|
+
.modal-overflow.modal {
|
100
|
+
top: 1%;
|
101
|
+
}
|
102
|
+
|
103
|
+
.modal-overflow.modal.fade {
|
104
|
+
top: -100%;
|
105
|
+
}
|
106
|
+
|
107
|
+
.modal-overflow.modal.fade.in {
|
108
|
+
top: 1%;
|
109
|
+
}
|
110
|
+
|
111
|
+
.modal-overflow .modal-body {
|
112
|
+
overflow: auto;
|
113
|
+
-webkit-overflow-scrolling: touch;
|
114
|
+
}
|
115
|
+
|
116
|
+
/* Responsive */
|
117
|
+
|
118
|
+
@media (min-width: 1200px) {
|
119
|
+
.modal.container {
|
120
|
+
width: 1170px;
|
121
|
+
margin-left: -585px;
|
122
|
+
}
|
123
|
+
}
|
124
|
+
|
125
|
+
@media (max-width: 979px) {
|
126
|
+
.modal,
|
127
|
+
.modal.container,
|
128
|
+
.modal.modal-overflow {
|
129
|
+
top: 1%;
|
130
|
+
right: 1%;
|
131
|
+
left: 1%;
|
132
|
+
bottom: auto;
|
133
|
+
width: auto !important;
|
134
|
+
height: auto !important;
|
135
|
+
margin: 0 !important;
|
136
|
+
padding: 0 !important;
|
137
|
+
}
|
138
|
+
|
139
|
+
.modal.fade.in,
|
140
|
+
.modal.container.fade.in,
|
141
|
+
.modal.modal-overflow.fade.in {
|
142
|
+
top: 1%;
|
143
|
+
bottom: auto;
|
144
|
+
}
|
145
|
+
|
146
|
+
.modal-body,
|
147
|
+
.modal-overflow .modal-body {
|
148
|
+
position: static;
|
149
|
+
margin: 0;
|
150
|
+
height: auto !important;
|
151
|
+
max-height: none !important;
|
152
|
+
overflow: visible !important;
|
153
|
+
}
|
154
|
+
|
155
|
+
.modal-footer,
|
156
|
+
.modal-overflow .modal-footer {
|
157
|
+
position: static;
|
158
|
+
}
|
159
|
+
}
|
160
|
+
|
161
|
+
.loading-spinner {
|
162
|
+
position: absolute;
|
163
|
+
top: 50%;
|
164
|
+
left: 50%;
|
165
|
+
margin: -12px 0 0 -12px;
|
166
|
+
}
|
167
|
+
|
168
|
+
/*
|
169
|
+
Animate.css - http://daneden.me/animate
|
170
|
+
Licensed under the ☺ license (http://licence.visualidiot.com/)
|
171
|
+
|
172
|
+
Copyright (c) 2012 Dan Eden*/
|
173
|
+
|
174
|
+
.animated {
|
175
|
+
-webkit-animation-duration: 1s;
|
176
|
+
-moz-animation-duration: 1s;
|
177
|
+
-o-animation-duration: 1s;
|
178
|
+
animation-duration: 1s;
|
179
|
+
-webkit-animation-fill-mode: both;
|
180
|
+
-moz-animation-fill-mode: both;
|
181
|
+
-o-animation-fill-mode: both;
|
182
|
+
animation-fill-mode: both;
|
183
|
+
}
|
184
|
+
|
185
|
+
@-webkit-keyframes shake {
|
186
|
+
0%, 100% {-webkit-transform: translateX(0);}
|
187
|
+
10%, 30%, 50%, 70%, 90% {-webkit-transform: translateX(-10px);}
|
188
|
+
20%, 40%, 60%, 80% {-webkit-transform: translateX(10px);}
|
189
|
+
}
|
190
|
+
|
191
|
+
@-moz-keyframes shake {
|
192
|
+
0%, 100% {-moz-transform: translateX(0);}
|
193
|
+
10%, 30%, 50%, 70%, 90% {-moz-transform: translateX(-10px);}
|
194
|
+
20%, 40%, 60%, 80% {-moz-transform: translateX(10px);}
|
195
|
+
}
|
196
|
+
|
197
|
+
@-o-keyframes shake {
|
198
|
+
0%, 100% {-o-transform: translateX(0);}
|
199
|
+
10%, 30%, 50%, 70%, 90% {-o-transform: translateX(-10px);}
|
200
|
+
20%, 40%, 60%, 80% {-o-transform: translateX(10px);}
|
201
|
+
}
|
202
|
+
|
203
|
+
@keyframes shake {
|
204
|
+
0%, 100% {transform: translateX(0);}
|
205
|
+
10%, 30%, 50%, 70%, 90% {transform: translateX(-10px);}
|
206
|
+
20%, 40%, 60%, 80% {transform: translateX(10px);}
|
207
|
+
}
|
208
|
+
|
209
|
+
.shake {
|
210
|
+
-webkit-animation-name: shake;
|
211
|
+
-moz-animation-name: shake;
|
212
|
+
-o-animation-name: shake;
|
213
|
+
animation-name: shake;
|
214
|
+
}
|
Binary file
|
@@ -0,0 +1,378 @@
|
|
1
|
+
/* ===========================================================
|
2
|
+
* bootstrap-modal.js v2.2.5
|
3
|
+
* ===========================================================
|
4
|
+
* Copyright 2012 Jordan Schroter
|
5
|
+
*
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
* you may not use this file except in compliance with the License.
|
8
|
+
* You may obtain a copy of the License at
|
9
|
+
*
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
*
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
* See the License for the specific language governing permissions and
|
16
|
+
* limitations under the License.
|
17
|
+
* ========================================================== */
|
18
|
+
|
19
|
+
|
20
|
+
!function ($) {
|
21
|
+
|
22
|
+
"use strict"; // jshint ;_;
|
23
|
+
|
24
|
+
/* MODAL CLASS DEFINITION
|
25
|
+
* ====================== */
|
26
|
+
|
27
|
+
var Modal = function (element, options) {
|
28
|
+
this.init(element, options);
|
29
|
+
};
|
30
|
+
|
31
|
+
Modal.prototype = {
|
32
|
+
|
33
|
+
constructor: Modal,
|
34
|
+
|
35
|
+
init: function (element, options) {
|
36
|
+
var that = this;
|
37
|
+
|
38
|
+
this.options = options;
|
39
|
+
|
40
|
+
this.$element = $(element)
|
41
|
+
.delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this));
|
42
|
+
|
43
|
+
this.options.remote && this.$element.find('.modal-body').load(this.options.remote, function () {
|
44
|
+
var e = $.Event('loaded');
|
45
|
+
that.$element.trigger(e);
|
46
|
+
});
|
47
|
+
|
48
|
+
var manager = typeof this.options.manager === 'function' ?
|
49
|
+
this.options.manager.call(this) : this.options.manager;
|
50
|
+
|
51
|
+
manager = manager.appendModal ?
|
52
|
+
manager : $(manager).modalmanager().data('modalmanager');
|
53
|
+
|
54
|
+
manager.appendModal(this);
|
55
|
+
},
|
56
|
+
|
57
|
+
toggle: function () {
|
58
|
+
return this[!this.isShown ? 'show' : 'hide']();
|
59
|
+
},
|
60
|
+
|
61
|
+
show: function () {
|
62
|
+
var e = $.Event('show');
|
63
|
+
|
64
|
+
if (this.isShown) return;
|
65
|
+
|
66
|
+
this.$element.trigger(e);
|
67
|
+
|
68
|
+
if (e.isDefaultPrevented()) return;
|
69
|
+
|
70
|
+
this.escape();
|
71
|
+
|
72
|
+
this.tab();
|
73
|
+
|
74
|
+
this.options.loading && this.loading();
|
75
|
+
},
|
76
|
+
|
77
|
+
hide: function (e) {
|
78
|
+
e && e.preventDefault();
|
79
|
+
|
80
|
+
e = $.Event('hide');
|
81
|
+
|
82
|
+
this.$element.trigger(e);
|
83
|
+
|
84
|
+
if (!this.isShown || e.isDefaultPrevented()) return;
|
85
|
+
|
86
|
+
this.isShown = false;
|
87
|
+
|
88
|
+
this.escape();
|
89
|
+
|
90
|
+
this.tab();
|
91
|
+
|
92
|
+
this.isLoading && this.loading();
|
93
|
+
|
94
|
+
$(document).off('focusin.modal');
|
95
|
+
|
96
|
+
this.$element
|
97
|
+
.removeClass('in')
|
98
|
+
.removeClass('animated')
|
99
|
+
.removeClass(this.options.attentionAnimation)
|
100
|
+
.removeClass('modal-overflow')
|
101
|
+
.attr('aria-hidden', true);
|
102
|
+
|
103
|
+
$.support.transition && this.$element.hasClass('fade') ?
|
104
|
+
this.hideWithTransition() :
|
105
|
+
this.hideModal();
|
106
|
+
},
|
107
|
+
|
108
|
+
layout: function () {
|
109
|
+
var prop = this.options.height ? 'height' : 'max-height',
|
110
|
+
value = this.options.height || this.options.maxHeight;
|
111
|
+
|
112
|
+
if (this.options.width){
|
113
|
+
this.$element.css('width', this.options.width);
|
114
|
+
|
115
|
+
var that = this;
|
116
|
+
this.$element.css('margin-left', function () {
|
117
|
+
if (/%/ig.test(that.options.width)){
|
118
|
+
return -(parseInt(that.options.width) / 2) + '%';
|
119
|
+
} else {
|
120
|
+
return -($(this).width() / 2) + 'px';
|
121
|
+
}
|
122
|
+
});
|
123
|
+
} else {
|
124
|
+
this.$element.css('width', '');
|
125
|
+
this.$element.css('margin-left', '');
|
126
|
+
}
|
127
|
+
|
128
|
+
this.$element.find('.modal-body')
|
129
|
+
.css('overflow', '')
|
130
|
+
.css(prop, '');
|
131
|
+
|
132
|
+
if (value){
|
133
|
+
this.$element.find('.modal-body')
|
134
|
+
.css('overflow', 'auto')
|
135
|
+
.css(prop, value);
|
136
|
+
}
|
137
|
+
|
138
|
+
var modalOverflow = $(window).height() - 10 < this.$element.height();
|
139
|
+
|
140
|
+
if (modalOverflow || this.options.modalOverflow) {
|
141
|
+
this.$element
|
142
|
+
.css('margin-top', 0)
|
143
|
+
.addClass('modal-overflow');
|
144
|
+
} else {
|
145
|
+
this.$element
|
146
|
+
.css('margin-top', 0 - this.$element.height() / 2)
|
147
|
+
.removeClass('modal-overflow');
|
148
|
+
}
|
149
|
+
},
|
150
|
+
|
151
|
+
tab: function () {
|
152
|
+
var that = this;
|
153
|
+
|
154
|
+
if (this.isShown && this.options.consumeTab) {
|
155
|
+
this.$element.on('keydown.tabindex.modal', '[data-tabindex]', function (e) {
|
156
|
+
if (e.keyCode && e.keyCode == 9){
|
157
|
+
var elements = [],
|
158
|
+
tabindex = Number($(this).data('tabindex'));
|
159
|
+
|
160
|
+
that.$element.find('[data-tabindex]:enabled:visible:not([readonly])').each(function (ev) {
|
161
|
+
elements.push(Number($(this).data('tabindex')));
|
162
|
+
});
|
163
|
+
elements.sort(function(a,b){return a-b});
|
164
|
+
|
165
|
+
var arrayPos = $.inArray(tabindex, elements);
|
166
|
+
if (!e.shiftKey){
|
167
|
+
arrayPos < elements.length-1 ?
|
168
|
+
that.$element.find('[data-tabindex='+elements[arrayPos+1]+']').focus() :
|
169
|
+
that.$element.find('[data-tabindex='+elements[0]+']').focus();
|
170
|
+
} else {
|
171
|
+
arrayPos == 0 ?
|
172
|
+
that.$element.find('[data-tabindex='+elements[elements.length-1]+']').focus() :
|
173
|
+
that.$element.find('[data-tabindex='+elements[arrayPos-1]+']').focus();
|
174
|
+
}
|
175
|
+
|
176
|
+
e.preventDefault();
|
177
|
+
}
|
178
|
+
});
|
179
|
+
} else if (!this.isShown) {
|
180
|
+
this.$element.off('keydown.tabindex.modal');
|
181
|
+
}
|
182
|
+
},
|
183
|
+
|
184
|
+
escape: function () {
|
185
|
+
var that = this;
|
186
|
+
if (this.isShown && this.options.keyboard) {
|
187
|
+
if (!this.$element.attr('tabindex')) this.$element.attr('tabindex', -1);
|
188
|
+
|
189
|
+
this.$element.on('keyup.dismiss.modal', function (e) {
|
190
|
+
e.which == 27 && that.hide();
|
191
|
+
});
|
192
|
+
} else if (!this.isShown) {
|
193
|
+
this.$element.off('keyup.dismiss.modal')
|
194
|
+
}
|
195
|
+
},
|
196
|
+
|
197
|
+
hideWithTransition: function () {
|
198
|
+
var that = this
|
199
|
+
, timeout = setTimeout(function () {
|
200
|
+
that.$element.off($.support.transition.end);
|
201
|
+
that.hideModal();
|
202
|
+
}, 500);
|
203
|
+
|
204
|
+
this.$element.one($.support.transition.end, function () {
|
205
|
+
clearTimeout(timeout);
|
206
|
+
that.hideModal();
|
207
|
+
});
|
208
|
+
},
|
209
|
+
|
210
|
+
hideModal: function () {
|
211
|
+
var prop = this.options.height ? 'height' : 'max-height';
|
212
|
+
var value = this.options.height || this.options.maxHeight;
|
213
|
+
|
214
|
+
if (value){
|
215
|
+
this.$element.find('.modal-body')
|
216
|
+
.css('overflow', '')
|
217
|
+
.css(prop, '');
|
218
|
+
}
|
219
|
+
|
220
|
+
this.$element
|
221
|
+
.hide()
|
222
|
+
.trigger('hidden');
|
223
|
+
},
|
224
|
+
|
225
|
+
removeLoading: function () {
|
226
|
+
this.$loading.remove();
|
227
|
+
this.$loading = null;
|
228
|
+
this.isLoading = false;
|
229
|
+
},
|
230
|
+
|
231
|
+
loading: function (callback) {
|
232
|
+
callback = callback || function () {};
|
233
|
+
|
234
|
+
var animate = this.$element.hasClass('fade') ? 'fade' : '';
|
235
|
+
|
236
|
+
if (!this.isLoading) {
|
237
|
+
var doAnimate = $.support.transition && animate;
|
238
|
+
|
239
|
+
this.$loading = $('<div class="loading-mask ' + animate + '">')
|
240
|
+
.append(this.options.spinner)
|
241
|
+
.appendTo(this.$element);
|
242
|
+
|
243
|
+
if (doAnimate) this.$loading[0].offsetWidth; // force reflow
|
244
|
+
|
245
|
+
this.$loading.addClass('in');
|
246
|
+
|
247
|
+
this.isLoading = true;
|
248
|
+
|
249
|
+
doAnimate ?
|
250
|
+
this.$loading.one($.support.transition.end, callback) :
|
251
|
+
callback();
|
252
|
+
|
253
|
+
} else if (this.isLoading && this.$loading) {
|
254
|
+
this.$loading.removeClass('in');
|
255
|
+
|
256
|
+
var that = this;
|
257
|
+
$.support.transition && this.$element.hasClass('fade')?
|
258
|
+
this.$loading.one($.support.transition.end, function () { that.removeLoading() }) :
|
259
|
+
that.removeLoading();
|
260
|
+
|
261
|
+
} else if (callback) {
|
262
|
+
callback(this.isLoading);
|
263
|
+
}
|
264
|
+
},
|
265
|
+
|
266
|
+
focus: function () {
|
267
|
+
var $focusElem = this.$element.find(this.options.focusOn);
|
268
|
+
|
269
|
+
$focusElem = $focusElem.length ? $focusElem : this.$element;
|
270
|
+
|
271
|
+
$focusElem.focus();
|
272
|
+
},
|
273
|
+
|
274
|
+
attention: function (){
|
275
|
+
// NOTE: transitionEnd with keyframes causes odd behaviour
|
276
|
+
|
277
|
+
if (this.options.attentionAnimation){
|
278
|
+
this.$element
|
279
|
+
.removeClass('animated')
|
280
|
+
.removeClass(this.options.attentionAnimation);
|
281
|
+
|
282
|
+
var that = this;
|
283
|
+
|
284
|
+
setTimeout(function () {
|
285
|
+
that.$element
|
286
|
+
.addClass('animated')
|
287
|
+
.addClass(that.options.attentionAnimation);
|
288
|
+
}, 0);
|
289
|
+
}
|
290
|
+
|
291
|
+
|
292
|
+
this.focus();
|
293
|
+
},
|
294
|
+
|
295
|
+
|
296
|
+
destroy: function () {
|
297
|
+
var e = $.Event('destroy');
|
298
|
+
|
299
|
+
this.$element.trigger(e);
|
300
|
+
|
301
|
+
if (e.isDefaultPrevented()) return;
|
302
|
+
|
303
|
+
this.$element
|
304
|
+
.off('.modal')
|
305
|
+
.removeData('modal')
|
306
|
+
.removeClass('in')
|
307
|
+
.attr('aria-hidden', true);
|
308
|
+
|
309
|
+
if (this.$parent !== this.$element.parent()) {
|
310
|
+
this.$element.appendTo(this.$parent);
|
311
|
+
} else if (!this.$parent.length) {
|
312
|
+
// modal is not part of the DOM so remove it.
|
313
|
+
this.$element.remove();
|
314
|
+
this.$element = null;
|
315
|
+
}
|
316
|
+
|
317
|
+
this.$element.trigger('destroyed');
|
318
|
+
}
|
319
|
+
};
|
320
|
+
|
321
|
+
|
322
|
+
/* MODAL PLUGIN DEFINITION
|
323
|
+
* ======================= */
|
324
|
+
|
325
|
+
$.fn.modal = function (option, args) {
|
326
|
+
return this.each(function () {
|
327
|
+
var $this = $(this),
|
328
|
+
data = $this.data('modal'),
|
329
|
+
options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option);
|
330
|
+
|
331
|
+
if (!data) $this.data('modal', (data = new Modal(this, options)));
|
332
|
+
if (typeof option == 'string') data[option].apply(data, [].concat(args));
|
333
|
+
else if (options.show) data.show()
|
334
|
+
})
|
335
|
+
};
|
336
|
+
|
337
|
+
$.fn.modal.defaults = {
|
338
|
+
keyboard: true,
|
339
|
+
backdrop: true,
|
340
|
+
loading: false,
|
341
|
+
show: true,
|
342
|
+
width: null,
|
343
|
+
height: null,
|
344
|
+
maxHeight: null,
|
345
|
+
modalOverflow: false,
|
346
|
+
consumeTab: true,
|
347
|
+
focusOn: null,
|
348
|
+
replace: false,
|
349
|
+
resize: false,
|
350
|
+
attentionAnimation: 'shake',
|
351
|
+
manager: 'body',
|
352
|
+
spinner: '<div class="loading-spinner" style="width: 200px; margin-left: -100px;"><div class="progress progress-striped active"><div class="bar" style="width: 100%;"></div></div></div>',
|
353
|
+
backdropTemplate: '<div class="modal-backdrop" />'
|
354
|
+
};
|
355
|
+
|
356
|
+
$.fn.modal.Constructor = Modal;
|
357
|
+
|
358
|
+
|
359
|
+
/* MODAL DATA-API
|
360
|
+
* ============== */
|
361
|
+
|
362
|
+
$(function () {
|
363
|
+
$(document).off('click.modal').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) {
|
364
|
+
var $this = $(this),
|
365
|
+
href = $this.attr('href'),
|
366
|
+
$target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))), //strip for ie7
|
367
|
+
option = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data());
|
368
|
+
|
369
|
+
e.preventDefault();
|
370
|
+
$target
|
371
|
+
.modal(option)
|
372
|
+
.one('hide', function () {
|
373
|
+
$this.focus();
|
374
|
+
})
|
375
|
+
});
|
376
|
+
});
|
377
|
+
|
378
|
+
}(window.jQuery);
|
@@ -0,0 +1,423 @@
|
|
1
|
+
/* ===========================================================
|
2
|
+
* bootstrap-modalmanager.js v2.2.5
|
3
|
+
* ===========================================================
|
4
|
+
* Copyright 2012 Jordan Schroter.
|
5
|
+
*
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
* you may not use this file except in compliance with the License.
|
8
|
+
* You may obtain a copy of the License at
|
9
|
+
*
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
*
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
* See the License for the specific language governing permissions and
|
16
|
+
* limitations under the License.
|
17
|
+
* ========================================================== */
|
18
|
+
|
19
|
+
!function ($) {
|
20
|
+
|
21
|
+
"use strict"; // jshint ;_;
|
22
|
+
|
23
|
+
/* MODAL MANAGER CLASS DEFINITION
|
24
|
+
* ====================== */
|
25
|
+
|
26
|
+
var ModalManager = function (element, options) {
|
27
|
+
this.init(element, options);
|
28
|
+
};
|
29
|
+
|
30
|
+
ModalManager.prototype = {
|
31
|
+
|
32
|
+
constructor: ModalManager,
|
33
|
+
|
34
|
+
init: function (element, options) {
|
35
|
+
this.$element = $(element);
|
36
|
+
this.options = $.extend({}, $.fn.modalmanager.defaults, this.$element.data(), typeof options == 'object' && options);
|
37
|
+
this.stack = [];
|
38
|
+
this.backdropCount = 0;
|
39
|
+
|
40
|
+
if (this.options.resize) {
|
41
|
+
var resizeTimeout,
|
42
|
+
that = this;
|
43
|
+
|
44
|
+
$(window).on('resize.modal', function(){
|
45
|
+
resizeTimeout && clearTimeout(resizeTimeout);
|
46
|
+
resizeTimeout = setTimeout(function(){
|
47
|
+
for (var i = 0; i < that.stack.length; i++){
|
48
|
+
that.stack[i].isShown && that.stack[i].layout();
|
49
|
+
}
|
50
|
+
}, 10);
|
51
|
+
});
|
52
|
+
}
|
53
|
+
},
|
54
|
+
|
55
|
+
createModal: function (element, options) {
|
56
|
+
$(element).modal($.extend({ manager: this }, options));
|
57
|
+
},
|
58
|
+
|
59
|
+
appendModal: function (modal) {
|
60
|
+
this.stack.push(modal);
|
61
|
+
|
62
|
+
var that = this;
|
63
|
+
|
64
|
+
modal.$element.on('show.modalmanager', targetIsSelf(function (e) {
|
65
|
+
|
66
|
+
var showModal = function(){
|
67
|
+
modal.isShown = true;
|
68
|
+
|
69
|
+
var transition = $.support.transition && modal.$element.hasClass('fade');
|
70
|
+
|
71
|
+
that.$element
|
72
|
+
.toggleClass('modal-open', that.hasOpenModal())
|
73
|
+
.toggleClass('page-overflow', $(window).height() < that.$element.height());
|
74
|
+
|
75
|
+
modal.$parent = modal.$element.parent();
|
76
|
+
|
77
|
+
modal.$container = that.createContainer(modal);
|
78
|
+
|
79
|
+
modal.$element.appendTo(modal.$container);
|
80
|
+
|
81
|
+
that.backdrop(modal, function () {
|
82
|
+
modal.$element.show();
|
83
|
+
|
84
|
+
if (transition) {
|
85
|
+
//modal.$element[0].style.display = 'run-in';
|
86
|
+
modal.$element[0].offsetWidth;
|
87
|
+
//modal.$element.one($.support.transition.end, function () { modal.$element[0].style.display = 'block' });
|
88
|
+
}
|
89
|
+
|
90
|
+
modal.layout();
|
91
|
+
|
92
|
+
modal.$element
|
93
|
+
.addClass('in')
|
94
|
+
.attr('aria-hidden', false);
|
95
|
+
|
96
|
+
var complete = function () {
|
97
|
+
that.setFocus();
|
98
|
+
modal.$element.trigger('shown');
|
99
|
+
};
|
100
|
+
|
101
|
+
transition ?
|
102
|
+
modal.$element.one($.support.transition.end, complete) :
|
103
|
+
complete();
|
104
|
+
});
|
105
|
+
};
|
106
|
+
|
107
|
+
modal.options.replace ?
|
108
|
+
that.replace(showModal) :
|
109
|
+
showModal();
|
110
|
+
}));
|
111
|
+
|
112
|
+
modal.$element.on('hidden.modalmanager', targetIsSelf(function (e) {
|
113
|
+
that.backdrop(modal);
|
114
|
+
// handle the case when a modal may have been removed from the dom before this callback executes
|
115
|
+
if (!modal.$element.parent().length) {
|
116
|
+
that.destroyModal(modal);
|
117
|
+
} else if (modal.$backdrop){
|
118
|
+
var transition = $.support.transition && modal.$element.hasClass('fade');
|
119
|
+
|
120
|
+
// trigger a relayout due to firebox's buggy transition end event
|
121
|
+
if (transition) { modal.$element[0].offsetWidth; }
|
122
|
+
$.support.transition && modal.$element.hasClass('fade') ?
|
123
|
+
modal.$backdrop.one($.support.transition.end, function () { modal.destroy(); }) :
|
124
|
+
modal.destroy();
|
125
|
+
} else {
|
126
|
+
modal.destroy();
|
127
|
+
}
|
128
|
+
|
129
|
+
}));
|
130
|
+
|
131
|
+
modal.$element.on('destroyed.modalmanager', targetIsSelf(function (e) {
|
132
|
+
that.destroyModal(modal);
|
133
|
+
}));
|
134
|
+
},
|
135
|
+
|
136
|
+
getOpenModals: function () {
|
137
|
+
var openModals = [];
|
138
|
+
for (var i = 0; i < this.stack.length; i++){
|
139
|
+
if (this.stack[i].isShown) openModals.push(this.stack[i]);
|
140
|
+
}
|
141
|
+
|
142
|
+
return openModals;
|
143
|
+
},
|
144
|
+
|
145
|
+
hasOpenModal: function () {
|
146
|
+
return this.getOpenModals().length > 0;
|
147
|
+
},
|
148
|
+
|
149
|
+
setFocus: function () {
|
150
|
+
var topModal;
|
151
|
+
|
152
|
+
for (var i = 0; i < this.stack.length; i++){
|
153
|
+
if (this.stack[i].isShown) topModal = this.stack[i];
|
154
|
+
}
|
155
|
+
|
156
|
+
if (!topModal) return;
|
157
|
+
|
158
|
+
topModal.focus();
|
159
|
+
},
|
160
|
+
|
161
|
+
destroyModal: function (modal) {
|
162
|
+
modal.$element.off('.modalmanager');
|
163
|
+
if (modal.$backdrop) this.removeBackdrop(modal);
|
164
|
+
this.stack.splice(this.getIndexOfModal(modal), 1);
|
165
|
+
|
166
|
+
var hasOpenModal = this.hasOpenModal();
|
167
|
+
|
168
|
+
this.$element.toggleClass('modal-open', hasOpenModal);
|
169
|
+
|
170
|
+
if (!hasOpenModal){
|
171
|
+
this.$element.removeClass('page-overflow');
|
172
|
+
}
|
173
|
+
|
174
|
+
this.removeContainer(modal);
|
175
|
+
|
176
|
+
this.setFocus();
|
177
|
+
},
|
178
|
+
|
179
|
+
getModalAt: function (index) {
|
180
|
+
return this.stack[index];
|
181
|
+
},
|
182
|
+
|
183
|
+
getIndexOfModal: function (modal) {
|
184
|
+
for (var i = 0; i < this.stack.length; i++){
|
185
|
+
if (modal === this.stack[i]) return i;
|
186
|
+
}
|
187
|
+
},
|
188
|
+
|
189
|
+
replace: function (callback) {
|
190
|
+
var topModal;
|
191
|
+
|
192
|
+
for (var i = 0; i < this.stack.length; i++){
|
193
|
+
if (this.stack[i].isShown) topModal = this.stack[i];
|
194
|
+
}
|
195
|
+
|
196
|
+
if (topModal) {
|
197
|
+
this.$backdropHandle = topModal.$backdrop;
|
198
|
+
topModal.$backdrop = null;
|
199
|
+
|
200
|
+
callback && topModal.$element.one('hidden',
|
201
|
+
targetIsSelf( $.proxy(callback, this) ));
|
202
|
+
|
203
|
+
topModal.hide();
|
204
|
+
} else if (callback) {
|
205
|
+
callback();
|
206
|
+
}
|
207
|
+
},
|
208
|
+
|
209
|
+
removeBackdrop: function (modal) {
|
210
|
+
modal.$backdrop.remove();
|
211
|
+
modal.$backdrop = null;
|
212
|
+
},
|
213
|
+
|
214
|
+
createBackdrop: function (animate, tmpl) {
|
215
|
+
var $backdrop;
|
216
|
+
|
217
|
+
if (!this.$backdropHandle) {
|
218
|
+
$backdrop = $(tmpl)
|
219
|
+
.addClass(animate)
|
220
|
+
.appendTo(this.$element);
|
221
|
+
} else {
|
222
|
+
$backdrop = this.$backdropHandle;
|
223
|
+
$backdrop.off('.modalmanager');
|
224
|
+
this.$backdropHandle = null;
|
225
|
+
this.isLoading && this.removeSpinner();
|
226
|
+
}
|
227
|
+
|
228
|
+
return $backdrop;
|
229
|
+
},
|
230
|
+
|
231
|
+
removeContainer: function (modal) {
|
232
|
+
modal.$container.remove();
|
233
|
+
modal.$container = null;
|
234
|
+
},
|
235
|
+
|
236
|
+
createContainer: function (modal) {
|
237
|
+
var $container;
|
238
|
+
|
239
|
+
$container = $('<div class="modal-scrollable">')
|
240
|
+
.css('z-index', getzIndex('modal', this.getOpenModals().length))
|
241
|
+
.appendTo(this.$element);
|
242
|
+
|
243
|
+
if (modal && modal.options.backdrop != 'static') {
|
244
|
+
$container.on('click.modal', targetIsSelf(function (e) {
|
245
|
+
modal.hide();
|
246
|
+
}));
|
247
|
+
} else if (modal) {
|
248
|
+
$container.on('click.modal', targetIsSelf(function (e) {
|
249
|
+
modal.attention();
|
250
|
+
}));
|
251
|
+
}
|
252
|
+
|
253
|
+
return $container;
|
254
|
+
|
255
|
+
},
|
256
|
+
|
257
|
+
backdrop: function (modal, callback) {
|
258
|
+
var animate = modal.$element.hasClass('fade') ? 'fade' : '',
|
259
|
+
showBackdrop = modal.options.backdrop &&
|
260
|
+
this.backdropCount < this.options.backdropLimit;
|
261
|
+
|
262
|
+
if (modal.isShown && showBackdrop) {
|
263
|
+
var doAnimate = $.support.transition && animate && !this.$backdropHandle;
|
264
|
+
|
265
|
+
modal.$backdrop = this.createBackdrop(animate, modal.options.backdropTemplate);
|
266
|
+
|
267
|
+
modal.$backdrop.css('z-index', getzIndex( 'backdrop', this.getOpenModals().length ));
|
268
|
+
|
269
|
+
if (doAnimate) modal.$backdrop[0].offsetWidth; // force reflow
|
270
|
+
|
271
|
+
modal.$backdrop.addClass('in');
|
272
|
+
|
273
|
+
this.backdropCount += 1;
|
274
|
+
|
275
|
+
doAnimate ?
|
276
|
+
modal.$backdrop.one($.support.transition.end, callback) :
|
277
|
+
callback();
|
278
|
+
|
279
|
+
} else if (!modal.isShown && modal.$backdrop) {
|
280
|
+
modal.$backdrop.removeClass('in');
|
281
|
+
|
282
|
+
this.backdropCount -= 1;
|
283
|
+
|
284
|
+
var that = this;
|
285
|
+
|
286
|
+
$.support.transition && modal.$element.hasClass('fade')?
|
287
|
+
modal.$backdrop.one($.support.transition.end, function () { that.removeBackdrop(modal) }) :
|
288
|
+
that.removeBackdrop(modal);
|
289
|
+
|
290
|
+
} else if (callback) {
|
291
|
+
callback();
|
292
|
+
}
|
293
|
+
},
|
294
|
+
|
295
|
+
removeSpinner: function(){
|
296
|
+
this.$spinner && this.$spinner.remove();
|
297
|
+
this.$spinner = null;
|
298
|
+
this.isLoading = false;
|
299
|
+
},
|
300
|
+
|
301
|
+
removeLoading: function () {
|
302
|
+
this.$backdropHandle && this.$backdropHandle.remove();
|
303
|
+
this.$backdropHandle = null;
|
304
|
+
this.removeSpinner();
|
305
|
+
},
|
306
|
+
|
307
|
+
loading: function (callback) {
|
308
|
+
callback = callback || function () { };
|
309
|
+
|
310
|
+
this.$element
|
311
|
+
.toggleClass('modal-open', !this.isLoading || this.hasOpenModal())
|
312
|
+
.toggleClass('page-overflow', $(window).height() < this.$element.height());
|
313
|
+
|
314
|
+
if (!this.isLoading) {
|
315
|
+
|
316
|
+
this.$backdropHandle = this.createBackdrop('fade', this.options.backdropTemplate);
|
317
|
+
|
318
|
+
this.$backdropHandle[0].offsetWidth; // force reflow
|
319
|
+
|
320
|
+
var openModals = this.getOpenModals();
|
321
|
+
|
322
|
+
this.$backdropHandle
|
323
|
+
.css('z-index', getzIndex('backdrop', openModals.length + 1))
|
324
|
+
.addClass('in');
|
325
|
+
|
326
|
+
var $spinner = $(this.options.spinner)
|
327
|
+
.css('z-index', getzIndex('modal', openModals.length + 1))
|
328
|
+
.appendTo(this.$element)
|
329
|
+
.addClass('in');
|
330
|
+
|
331
|
+
this.$spinner = $(this.createContainer())
|
332
|
+
.append($spinner)
|
333
|
+
.on('click.modalmanager', $.proxy(this.loading, this));
|
334
|
+
|
335
|
+
this.isLoading = true;
|
336
|
+
|
337
|
+
$.support.transition ?
|
338
|
+
this.$backdropHandle.one($.support.transition.end, callback) :
|
339
|
+
callback();
|
340
|
+
|
341
|
+
} else if (this.isLoading && this.$backdropHandle) {
|
342
|
+
this.$backdropHandle.removeClass('in');
|
343
|
+
|
344
|
+
var that = this;
|
345
|
+
$.support.transition ?
|
346
|
+
this.$backdropHandle.one($.support.transition.end, function () { that.removeLoading() }) :
|
347
|
+
that.removeLoading();
|
348
|
+
|
349
|
+
} else if (callback) {
|
350
|
+
callback(this.isLoading);
|
351
|
+
}
|
352
|
+
}
|
353
|
+
};
|
354
|
+
|
355
|
+
/* PRIVATE METHODS
|
356
|
+
* ======================= */
|
357
|
+
|
358
|
+
// computes and caches the zindexes
|
359
|
+
var getzIndex = (function () {
|
360
|
+
var zIndexFactor,
|
361
|
+
baseIndex = {};
|
362
|
+
|
363
|
+
return function (type, pos) {
|
364
|
+
|
365
|
+
if (typeof zIndexFactor === 'undefined'){
|
366
|
+
var $baseModal = $('<div class="modal hide" />').appendTo('body'),
|
367
|
+
$baseBackdrop = $('<div class="modal-backdrop hide" />').appendTo('body');
|
368
|
+
|
369
|
+
baseIndex['modal'] = +$baseModal.css('z-index');
|
370
|
+
baseIndex['backdrop'] = +$baseBackdrop.css('z-index');
|
371
|
+
zIndexFactor = baseIndex['modal'] - baseIndex['backdrop'];
|
372
|
+
|
373
|
+
$baseModal.remove();
|
374
|
+
$baseBackdrop.remove();
|
375
|
+
$baseBackdrop = $baseModal = null;
|
376
|
+
}
|
377
|
+
|
378
|
+
return baseIndex[type] + (zIndexFactor * pos);
|
379
|
+
|
380
|
+
}
|
381
|
+
}());
|
382
|
+
|
383
|
+
// make sure the event target is the modal itself in order to prevent
|
384
|
+
// other components such as tabsfrom triggering the modal manager.
|
385
|
+
// if Boostsrap namespaced events, this would not be needed.
|
386
|
+
function targetIsSelf(callback){
|
387
|
+
return function (e) {
|
388
|
+
if (e && this === e.target){
|
389
|
+
return callback.apply(this, arguments);
|
390
|
+
}
|
391
|
+
}
|
392
|
+
}
|
393
|
+
|
394
|
+
|
395
|
+
/* MODAL MANAGER PLUGIN DEFINITION
|
396
|
+
* ======================= */
|
397
|
+
|
398
|
+
$.fn.modalmanager = function (option, args) {
|
399
|
+
return this.each(function () {
|
400
|
+
var $this = $(this),
|
401
|
+
data = $this.data('modalmanager');
|
402
|
+
|
403
|
+
if (!data) $this.data('modalmanager', (data = new ModalManager(this, option)));
|
404
|
+
if (typeof option === 'string') data[option].apply(data, [].concat(args))
|
405
|
+
})
|
406
|
+
};
|
407
|
+
|
408
|
+
$.fn.modalmanager.defaults = {
|
409
|
+
backdropLimit: 999,
|
410
|
+
resize: true,
|
411
|
+
spinner: '<div class="loading-spinner fade" style="width: 200px; margin-left: -100px;"><div class="progress progress-striped active"><div class="bar" style="width: 100%;"></div></div></div>',
|
412
|
+
backdropTemplate: '<div class="modal-backdrop" />'
|
413
|
+
};
|
414
|
+
|
415
|
+
$.fn.modalmanager.Constructor = ModalManager
|
416
|
+
|
417
|
+
// ModalManager handles the modal-open class so we need
|
418
|
+
// to remove conflicting bootstrap 3 event handlers
|
419
|
+
$(function () {
|
420
|
+
$(document).off('show.bs.modal').off('hidden.bs.modal');
|
421
|
+
});
|
422
|
+
|
423
|
+
}(jQuery);
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: boostrap_modal_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Peter Le
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- peter@peterkle.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".DS_Store"
|
49
|
+
- ".gitignore"
|
50
|
+
- ".travis.yml"
|
51
|
+
- CODE_OF_CONDUCT.md
|
52
|
+
- Gemfile
|
53
|
+
- LICENSE.txt
|
54
|
+
- README.md
|
55
|
+
- Rakefile
|
56
|
+
- bin/console
|
57
|
+
- bin/setup
|
58
|
+
- boostrap_modal_rails.gemspec
|
59
|
+
- lib/boostrap_modal_rails.rb
|
60
|
+
- lib/boostrap_modal_rails/version.rb
|
61
|
+
- vendor/.DS_Store
|
62
|
+
- vendor/assets/.DS_Store
|
63
|
+
- vendor/assets/css/bootstrap-modal-bs3patch.css
|
64
|
+
- vendor/assets/css/bootstrap-modal.css
|
65
|
+
- vendor/assets/img/ajax-loader.gif
|
66
|
+
- vendor/assets/js/bootstrap-modal.js
|
67
|
+
- vendor/assets/js/bootstrap-modalmanager.js
|
68
|
+
homepage:
|
69
|
+
licenses:
|
70
|
+
- MIT
|
71
|
+
metadata: {}
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
requirements: []
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 2.4.8
|
89
|
+
signing_key:
|
90
|
+
specification_version: 4
|
91
|
+
summary: Wrapper for boostrap-model library <https://github.com/jschr/bootstrap-modal>
|
92
|
+
test_files: []
|