rails_admin_live_edit 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -1
- data/app/views/live_edit/_ra_live_editor.html.haml +160 -0
- data/lib/rails_admin_live_edit/version.rb +1 -1
- metadata +3 -23
- data/vendor/assets/javascripts/rmodal.js/LICENSE +0 -21
- data/vendor/assets/javascripts/rmodal.js/README.md +0 -57
- data/vendor/assets/javascripts/rmodal.js/bower.json +0 -28
- data/vendor/assets/javascripts/rmodal.js/dist/rmodal-no-bootstrap.css +0 -37
- data/vendor/assets/javascripts/rmodal.js/dist/rmodal.css +0 -14
- data/vendor/assets/javascripts/rmodal.js/dist/rmodal.js +0 -201
- data/vendor/assets/javascripts/rmodal.js/dist/rmodal.js.map +0 -1
- data/vendor/assets/javascripts/rmodal.js/dist/rmodal.min.js +0 -2
- data/vendor/assets/javascripts/rmodal.js/dist/rmodal.min.js.map +0 -1
- data/vendor/assets/javascripts/rmodal.js/gulpfile.js +0 -99
- data/vendor/assets/javascripts/rmodal.js/index.html +0 -111
- data/vendor/assets/javascripts/rmodal.js/index.js +0 -193
- data/vendor/assets/javascripts/rmodal.js/index.js.map +0 -1
- data/vendor/assets/javascripts/rmodal.js/karma.conf.js +0 -66
- data/vendor/assets/javascripts/rmodal.js/logo.png +0 -0
- data/vendor/assets/javascripts/rmodal.js/package.json +0 -59
- data/vendor/assets/javascripts/rmodal.js/src/rmodal-no-bootstrap.css +0 -37
- data/vendor/assets/javascripts/rmodal.js/src/rmodal.css +0 -14
- data/vendor/assets/javascripts/rmodal.js/src/rmodal.js +0 -188
- data/vendor/assets/javascripts/rmodal.js/test/rmodal.test.js +0 -636
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14e886581a48a09af1d6a3c621824d6eccafc914
|
4
|
+
data.tar.gz: bbb2a0508237a45fc700cdddc61c3cefa67d2f00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3be3b11ffa82e9c41fef2f07acb70865bba510ed4e5367c80ed2030180fc763c9dc10577da187dd82580b88e7a3a252fd26a1042101f1af26b795d0769f6b8d
|
7
|
+
data.tar.gz: f94b8d583b2e32f3d29719902bcfce7f1f87ac6df5dbd6c10ab13250faf26d7f478789c58325bb760a95db1bb2e4285dc19d6561d760a51c59b3ac8ff9656966
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# RailsAdminLiveEdit
|
1
|
+
# RailsAdminLiveEdit [](https://badge.fury.io/rb/rails_admin_live_edit)
|
2
2
|
|
3
3
|
A [rails_admin](https://github.com/sferik/rails_admin) plugin to edit site contents from the frontend.
|
4
4
|
|
@@ -14,6 +14,10 @@ If the user is logged in in rails_admin and is viewing an editable page an edit
|
|
14
14
|
|
15
15
|
- Edit or create *app/assets/javascripts/rails_admin/custom/ui.js* and add: `//= require rails_admin/plugins/live_edit/ui.js`
|
16
16
|
|
17
|
+
## Preview
|
18
|
+
|
19
|
+

|
20
|
+
|
17
21
|
## Contributors
|
18
22
|
|
19
23
|
- [Mattia Roccoberton](http://blocknot.es) - creator, maintainer
|
@@ -97,6 +97,166 @@
|
|
97
97
|
= link_to t('live_edit.button.admin'), rails_admin_path, class: 'btn2 ra-le-button'
|
98
98
|
|
99
99
|
:javascript
|
100
|
+
// >>> rmodal.js >>>
|
101
|
+
(function (global, factory) {
|
102
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
103
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
104
|
+
(global.RModal = factory());
|
105
|
+
}(this, (function () {
|
106
|
+
var is = function (obj, type) { return Object.prototype.toString.call(obj).toLowerCase() === ("[object " + type + "]"); };
|
107
|
+
var addClass = function (el, cls) {
|
108
|
+
var arr = el.className
|
109
|
+
.split(/\s+/)
|
110
|
+
.filter(function (c) { return !!c && c == cls; });
|
111
|
+
if (!arr.length) {
|
112
|
+
el.className += " " + cls;
|
113
|
+
}
|
114
|
+
};
|
115
|
+
var removeClass = function (el, cls) {
|
116
|
+
el.className = el.className
|
117
|
+
.split(/\s+/)
|
118
|
+
.filter(function (c) { return !!c && c != cls; })
|
119
|
+
.join(' ');
|
120
|
+
};
|
121
|
+
var RModal = function RModal(el, opts) {
|
122
|
+
var this$1 = this;
|
123
|
+
this.opened = false;
|
124
|
+
this.opts = {
|
125
|
+
bodyClass: 'modal-open'
|
126
|
+
, dialogClass: 'modal-dialog'
|
127
|
+
, dialogOpenClass: 'bounceInDown'
|
128
|
+
, dialogCloseClass: 'bounceOutUp'
|
129
|
+
, focus: true
|
130
|
+
, focusElements: [
|
131
|
+
'a[href]', 'area[href]', 'input:not([disabled]):not([type=hidden])'
|
132
|
+
, 'button:not([disabled])', 'select:not([disabled])'
|
133
|
+
, 'textarea:not([disabled])', 'iframe', 'object', 'embed'
|
134
|
+
, '*[tabindex]', '*[contenteditable]'
|
135
|
+
]
|
136
|
+
, escapeClose: true
|
137
|
+
, content: null
|
138
|
+
, closeTimeout: 500
|
139
|
+
};
|
140
|
+
Object.keys(opts || {})
|
141
|
+
.forEach(function (key) {
|
142
|
+
/* istanbul ignore else */
|
143
|
+
if (opts[key] !== undefined) {
|
144
|
+
this$1.opts[key] = opts[key];
|
145
|
+
}
|
146
|
+
});
|
147
|
+
this.overlay = el;
|
148
|
+
this.dialog = el.querySelector(("." + (this.opts.dialogClass)));
|
149
|
+
|
150
|
+
if (this.opts.content) {
|
151
|
+
this.content(this.opts.content);
|
152
|
+
}
|
153
|
+
};
|
154
|
+
RModal.prototype.open = function open (content) {
|
155
|
+
var this$1 = this;
|
156
|
+
this.content(content);
|
157
|
+
if (!is(this.opts.beforeOpen, 'function')) {
|
158
|
+
return this._doOpen();
|
159
|
+
}
|
160
|
+
this.opts.beforeOpen(function () {
|
161
|
+
this$1._doOpen();
|
162
|
+
});
|
163
|
+
};
|
164
|
+
RModal.prototype._doOpen = function _doOpen () {
|
165
|
+
addClass(document.body, this.opts.bodyClass);
|
166
|
+
removeClass(this.dialog, this.opts.dialogCloseClass);
|
167
|
+
addClass(this.dialog, this.opts.dialogOpenClass);
|
168
|
+
this.overlay.style.display = 'block';
|
169
|
+
if (this.opts.focus) {
|
170
|
+
this.focusOutElement = document.activeElement;
|
171
|
+
this.focus();
|
172
|
+
}
|
173
|
+
if (is(this.opts.afterOpen, 'function')) {
|
174
|
+
this.opts.afterOpen();
|
175
|
+
}
|
176
|
+
this.opened = true;
|
177
|
+
};
|
178
|
+
RModal.prototype.close = function close () {
|
179
|
+
var this$1 = this;
|
180
|
+
if (!is(this.opts.beforeClose, 'function')) {
|
181
|
+
return this._doClose();
|
182
|
+
}
|
183
|
+
this.opts.beforeClose(function () {
|
184
|
+
this$1._doClose();
|
185
|
+
});
|
186
|
+
};
|
187
|
+
RModal.prototype._doClose = function _doClose () {
|
188
|
+
var this$1 = this;
|
189
|
+
removeClass(this.dialog, this.opts.dialogOpenClass);
|
190
|
+
addClass(this.dialog, this.opts.dialogCloseClass);
|
191
|
+
removeClass(document.body, this.opts.bodyClass);
|
192
|
+
if (this.opts.focus) {
|
193
|
+
this.focus(this.focusOutElement);
|
194
|
+
}
|
195
|
+
if (is(this.opts.afterClose, 'function')) {
|
196
|
+
this.opts.afterClose();
|
197
|
+
}
|
198
|
+
this.opened = false;
|
199
|
+
setTimeout(function () {
|
200
|
+
this$1.overlay.style.display = 'none';
|
201
|
+
}, this.opts.closeTimeout);
|
202
|
+
};
|
203
|
+
RModal.prototype.content = function content (html) {
|
204
|
+
if (html === undefined) {
|
205
|
+
return this.dialog.innerHTML;
|
206
|
+
}
|
207
|
+
this.dialog.innerHTML = html;
|
208
|
+
};
|
209
|
+
RModal.prototype.elements = function elements (selector, fallback) {
|
210
|
+
fallback = fallback || window.navigator.appVersion.indexOf('MSIE 9.0') > -1;
|
211
|
+
selector = is(selector, 'array') ? selector.join(',') : selector;
|
212
|
+
return [].filter.call(
|
213
|
+
this.dialog.querySelectorAll(selector)
|
214
|
+
, function (element) {
|
215
|
+
if (fallback) {
|
216
|
+
var style = window.getComputedStyle(element);
|
217
|
+
return style.display !== 'none' && style.visibility !== 'hidden';
|
218
|
+
}
|
219
|
+
return element.offsetParent !== null;
|
220
|
+
}
|
221
|
+
);
|
222
|
+
};
|
223
|
+
RModal.prototype.focus = function focus (el) {
|
224
|
+
el = el || this.elements(this.opts.focusElements)[0] || this.dialog.firstChild;
|
225
|
+
if (el && is(el.focus, 'function')) {
|
226
|
+
el.focus();
|
227
|
+
}
|
228
|
+
};
|
229
|
+
RModal.prototype.keydown = function keydown (ev) {
|
230
|
+
if (this.opts.escapeClose && ev.which == 27) {
|
231
|
+
this.close();
|
232
|
+
}
|
233
|
+
function stopEvent() {
|
234
|
+
ev.preventDefault();
|
235
|
+
ev.stopPropagation();
|
236
|
+
}
|
237
|
+
if (this.opened && ev.which == 9 && this.dialog.contains(ev.target)) {
|
238
|
+
var elements = this.elements(this.opts.focusElements)
|
239
|
+
, first = elements[0]
|
240
|
+
, last = elements[elements.length - 1];
|
241
|
+
if (first == last) {
|
242
|
+
stopEvent();
|
243
|
+
}
|
244
|
+
else if (ev.target == first && ev.shiftKey) {
|
245
|
+
stopEvent();
|
246
|
+
last.focus();
|
247
|
+
}
|
248
|
+
else if (ev.target == last && !ev.shiftKey) {
|
249
|
+
stopEvent();
|
250
|
+
first.focus();
|
251
|
+
}
|
252
|
+
}
|
253
|
+
};
|
254
|
+
RModal.prototype.version = '1.0.24';
|
255
|
+
RModal.version = '1.0.24';
|
256
|
+
return RModal;
|
257
|
+
})));
|
258
|
+
// <<< rmodal.js <<<
|
259
|
+
|
100
260
|
window.onload = function() {
|
101
261
|
var modal = new RModal(document.getElementById('ra-le-modal'), {
|
102
262
|
beforeOpen: function(next) {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_admin_live_edit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mattia Roccoberton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A rails_admin plugin to edit site contents from the frontend
|
14
14
|
email:
|
@@ -25,27 +25,7 @@ files:
|
|
25
25
|
- lib/rails_admin_live_edit/engine.rb
|
26
26
|
- lib/rails_admin_live_edit/version.rb
|
27
27
|
- vendor/assets/javascripts/rails_admin/plugins/live_edit/ui.js
|
28
|
-
|
29
|
-
- vendor/assets/javascripts/rmodal.js/README.md
|
30
|
-
- vendor/assets/javascripts/rmodal.js/bower.json
|
31
|
-
- vendor/assets/javascripts/rmodal.js/dist/rmodal-no-bootstrap.css
|
32
|
-
- vendor/assets/javascripts/rmodal.js/dist/rmodal.css
|
33
|
-
- vendor/assets/javascripts/rmodal.js/dist/rmodal.js
|
34
|
-
- vendor/assets/javascripts/rmodal.js/dist/rmodal.js.map
|
35
|
-
- vendor/assets/javascripts/rmodal.js/dist/rmodal.min.js
|
36
|
-
- vendor/assets/javascripts/rmodal.js/dist/rmodal.min.js.map
|
37
|
-
- vendor/assets/javascripts/rmodal.js/gulpfile.js
|
38
|
-
- vendor/assets/javascripts/rmodal.js/index.html
|
39
|
-
- vendor/assets/javascripts/rmodal.js/index.js
|
40
|
-
- vendor/assets/javascripts/rmodal.js/index.js.map
|
41
|
-
- vendor/assets/javascripts/rmodal.js/karma.conf.js
|
42
|
-
- vendor/assets/javascripts/rmodal.js/logo.png
|
43
|
-
- vendor/assets/javascripts/rmodal.js/package.json
|
44
|
-
- vendor/assets/javascripts/rmodal.js/src/rmodal-no-bootstrap.css
|
45
|
-
- vendor/assets/javascripts/rmodal.js/src/rmodal.css
|
46
|
-
- vendor/assets/javascripts/rmodal.js/src/rmodal.js
|
47
|
-
- vendor/assets/javascripts/rmodal.js/test/rmodal.test.js
|
48
|
-
homepage: http://blocknot.es
|
28
|
+
homepage: https://github.com/blocknotes/rails_admin_live_edit
|
49
29
|
licenses:
|
50
30
|
- MIT
|
51
31
|
metadata: {}
|
@@ -1,21 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2015 Iskren Slavov
|
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 all
|
13
|
-
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 THE
|
21
|
-
SOFTWARE.
|
@@ -1,57 +0,0 @@
|
|
1
|
-
[](https://www.npmjs.com/package/rmodal)
|
2
|
-
[](https://travis-ci.org/zewish/rmodal.js)
|
3
|
-
[](https://coveralls.io/github/zewish/rmodal.js?branch=master)
|
4
|
-
[](https://david-dm.org/zewish/rmodal.js)
|
5
|
-
[](https://www.npmjs.com/package/rmodal)
|
6
|
-
|
7
|
-
1.2 KB modal dialog box, with no dependencies
|
8
|
-
|
9
|
-
<br />
|
10
|
-
[](https://github.com/zewish/rmodal.js)
|
11
|
-
|
12
|
-
- A simple and fast modal dialog
|
13
|
-
- Plain JavaScript only - no dependencies
|
14
|
-
- All browsers supported (IE9+)
|
15
|
-
- Less than 1.2 KB when gzipped and minified
|
16
|
-
- Bootstrap and Animate.css friendly
|
17
|
-
- Supports CommonJS, AMD or globals
|
18
|
-
|
19
|
-
|
20
|
-
Demo
|
21
|
-
----
|
22
|
-
http://plnkr.co/edit/XXFKwHHcZD4Ecjh8twaW?p=preview
|
23
|
-
|
24
|
-
|
25
|
-
Documentation
|
26
|
-
-------------
|
27
|
-
http://rmodal.js.org/
|
28
|
-
|
29
|
-
|
30
|
-
Installation
|
31
|
-
------------
|
32
|
-
```
|
33
|
-
$ npm install rmodal --save
|
34
|
-
# or
|
35
|
-
$ bower install rmodal --save
|
36
|
-
```
|
37
|
-
|
38
|
-
|
39
|
-
Development
|
40
|
-
-----------
|
41
|
-
```
|
42
|
-
$ npm install
|
43
|
-
$ npm install -g gulp
|
44
|
-
```
|
45
|
-
|
46
|
-
Development: build
|
47
|
-
------------------
|
48
|
-
```
|
49
|
-
$ gulp build
|
50
|
-
```
|
51
|
-
|
52
|
-
|
53
|
-
Development: test
|
54
|
-
-----------------
|
55
|
-
```
|
56
|
-
$ gulp lint test
|
57
|
-
```
|
@@ -1,28 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"name": "rmodal",
|
3
|
-
"main": "rmodal.js",
|
4
|
-
"version": "1.0.24",
|
5
|
-
"authors": [
|
6
|
-
"Iskren Slavov <iskren.s@gmail.com>"
|
7
|
-
],
|
8
|
-
"description": "A simple modal dialog with no external dependencies. IE9+ supported.",
|
9
|
-
"keywords": [
|
10
|
-
"modal",
|
11
|
-
"dialog",
|
12
|
-
"javascript",
|
13
|
-
"simple",
|
14
|
-
"plain",
|
15
|
-
"browser",
|
16
|
-
"browserify"
|
17
|
-
],
|
18
|
-
"dependencies": {},
|
19
|
-
"license": "MIT",
|
20
|
-
"homepage": "http://rmodal.js.org/",
|
21
|
-
"ignore": [
|
22
|
-
"**/.*",
|
23
|
-
"node_modules",
|
24
|
-
"bower_components",
|
25
|
-
"test",
|
26
|
-
"tests"
|
27
|
-
]
|
28
|
-
}
|
@@ -1,37 +0,0 @@
|
|
1
|
-
body {
|
2
|
-
padding: 0;
|
3
|
-
margin: 0;
|
4
|
-
}
|
5
|
-
|
6
|
-
body.modal-open {
|
7
|
-
overflow-x: hidden;
|
8
|
-
overflow-y: auto;
|
9
|
-
}
|
10
|
-
|
11
|
-
.modal {
|
12
|
-
display: none;
|
13
|
-
background: rgba(0, 0, 0, .30);
|
14
|
-
z-index: 999;
|
15
|
-
padding: 30px 0;
|
16
|
-
|
17
|
-
position: fixed;
|
18
|
-
top: 0;
|
19
|
-
left: 0;
|
20
|
-
right: 0;
|
21
|
-
bottom: 0;
|
22
|
-
|
23
|
-
overflow-x: hidden;
|
24
|
-
overflow-y: auto;
|
25
|
-
}
|
26
|
-
|
27
|
-
.modal .modal-dialog {
|
28
|
-
position: relative;
|
29
|
-
margin: 30px auto;
|
30
|
-
width: 1100px;
|
31
|
-
border-radius: 6px;
|
32
|
-
-webkit-box-shadow: 0 3px 9px rgba(0, 0, 0, .5);
|
33
|
-
box-shadow: 0 3px 9px rgba(0, 0, 0, .5);
|
34
|
-
|
35
|
-
background: #fff;
|
36
|
-
margin: 0 auto;
|
37
|
-
}
|
@@ -1,14 +0,0 @@
|
|
1
|
-
.modal {
|
2
|
-
display: none;
|
3
|
-
background: rgba(0, 0, 0, .30);
|
4
|
-
z-index: 999;
|
5
|
-
}
|
6
|
-
|
7
|
-
.modal .modal-dialog {
|
8
|
-
position: relative;
|
9
|
-
margin: 30px auto;
|
10
|
-
width: 1100px;
|
11
|
-
border-radius: 6px;
|
12
|
-
-webkit-box-shadow: 0 3px 9px rgba(0, 0, 0, .5);
|
13
|
-
box-shadow: 0 3px 9px rgba(0, 0, 0, .5);
|
14
|
-
}
|
@@ -1,201 +0,0 @@
|
|
1
|
-
(function (global, factory) {
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
3
|
-
typeof define === 'function' && define.amd ? define(factory) :
|
4
|
-
(global.RModal = factory());
|
5
|
-
}(this, (function () {
|
6
|
-
|
7
|
-
var is = function (obj, type) { return Object.prototype.toString.call(obj).toLowerCase() === ("[object " + type + "]"); };
|
8
|
-
|
9
|
-
var addClass = function (el, cls) {
|
10
|
-
var arr = el.className
|
11
|
-
.split(/\s+/)
|
12
|
-
.filter(function (c) { return !!c && c == cls; });
|
13
|
-
|
14
|
-
if (!arr.length) {
|
15
|
-
el.className += " " + cls;
|
16
|
-
}
|
17
|
-
};
|
18
|
-
|
19
|
-
var removeClass = function (el, cls) {
|
20
|
-
el.className = el.className
|
21
|
-
.split(/\s+/)
|
22
|
-
.filter(function (c) { return !!c && c != cls; })
|
23
|
-
.join(' ');
|
24
|
-
};
|
25
|
-
|
26
|
-
var RModal = function RModal(el, opts) {
|
27
|
-
var this$1 = this;
|
28
|
-
|
29
|
-
this.opened = false;
|
30
|
-
|
31
|
-
this.opts = {
|
32
|
-
bodyClass: 'modal-open'
|
33
|
-
, dialogClass: 'modal-dialog'
|
34
|
-
, dialogOpenClass: 'bounceInDown'
|
35
|
-
, dialogCloseClass: 'bounceOutUp'
|
36
|
-
|
37
|
-
, focus: true
|
38
|
-
, focusElements: [
|
39
|
-
'a[href]', 'area[href]', 'input:not([disabled]):not([type=hidden])'
|
40
|
-
, 'button:not([disabled])', 'select:not([disabled])'
|
41
|
-
, 'textarea:not([disabled])', 'iframe', 'object', 'embed'
|
42
|
-
, '*[tabindex]', '*[contenteditable]'
|
43
|
-
]
|
44
|
-
|
45
|
-
, escapeClose: true
|
46
|
-
, content: null
|
47
|
-
, closeTimeout: 500
|
48
|
-
};
|
49
|
-
|
50
|
-
Object.keys(opts || {})
|
51
|
-
.forEach(function (key) {
|
52
|
-
/* istanbul ignore else */
|
53
|
-
if (opts[key] !== undefined) {
|
54
|
-
this$1.opts[key] = opts[key];
|
55
|
-
}
|
56
|
-
});
|
57
|
-
|
58
|
-
this.overlay = el;
|
59
|
-
this.dialog = el.querySelector(("." + (this.opts.dialogClass)));
|
60
|
-
|
61
|
-
if (this.opts.content) {
|
62
|
-
this.content(this.opts.content);
|
63
|
-
}
|
64
|
-
};
|
65
|
-
|
66
|
-
RModal.prototype.open = function open (content) {
|
67
|
-
var this$1 = this;
|
68
|
-
|
69
|
-
this.content(content);
|
70
|
-
|
71
|
-
if (!is(this.opts.beforeOpen, 'function')) {
|
72
|
-
return this._doOpen();
|
73
|
-
}
|
74
|
-
|
75
|
-
this.opts.beforeOpen(function () {
|
76
|
-
this$1._doOpen();
|
77
|
-
});
|
78
|
-
};
|
79
|
-
|
80
|
-
RModal.prototype._doOpen = function _doOpen () {
|
81
|
-
addClass(document.body, this.opts.bodyClass);
|
82
|
-
|
83
|
-
removeClass(this.dialog, this.opts.dialogCloseClass);
|
84
|
-
addClass(this.dialog, this.opts.dialogOpenClass);
|
85
|
-
|
86
|
-
this.overlay.style.display = 'block';
|
87
|
-
|
88
|
-
if (this.opts.focus) {
|
89
|
-
this.focusOutElement = document.activeElement;
|
90
|
-
this.focus();
|
91
|
-
}
|
92
|
-
|
93
|
-
if (is(this.opts.afterOpen, 'function')) {
|
94
|
-
this.opts.afterOpen();
|
95
|
-
}
|
96
|
-
this.opened = true;
|
97
|
-
};
|
98
|
-
|
99
|
-
RModal.prototype.close = function close () {
|
100
|
-
var this$1 = this;
|
101
|
-
|
102
|
-
if (!is(this.opts.beforeClose, 'function')) {
|
103
|
-
return this._doClose();
|
104
|
-
}
|
105
|
-
|
106
|
-
this.opts.beforeClose(function () {
|
107
|
-
this$1._doClose();
|
108
|
-
});
|
109
|
-
};
|
110
|
-
|
111
|
-
RModal.prototype._doClose = function _doClose () {
|
112
|
-
var this$1 = this;
|
113
|
-
|
114
|
-
removeClass(this.dialog, this.opts.dialogOpenClass);
|
115
|
-
addClass(this.dialog, this.opts.dialogCloseClass);
|
116
|
-
|
117
|
-
removeClass(document.body, this.opts.bodyClass);
|
118
|
-
|
119
|
-
if (this.opts.focus) {
|
120
|
-
this.focus(this.focusOutElement);
|
121
|
-
}
|
122
|
-
|
123
|
-
if (is(this.opts.afterClose, 'function')) {
|
124
|
-
this.opts.afterClose();
|
125
|
-
}
|
126
|
-
|
127
|
-
this.opened = false;
|
128
|
-
setTimeout(function () {
|
129
|
-
this$1.overlay.style.display = 'none';
|
130
|
-
}, this.opts.closeTimeout);
|
131
|
-
};
|
132
|
-
|
133
|
-
RModal.prototype.content = function content (html) {
|
134
|
-
if (html === undefined) {
|
135
|
-
return this.dialog.innerHTML;
|
136
|
-
}
|
137
|
-
|
138
|
-
this.dialog.innerHTML = html;
|
139
|
-
};
|
140
|
-
|
141
|
-
RModal.prototype.elements = function elements (selector, fallback) {
|
142
|
-
fallback = fallback || window.navigator.appVersion.indexOf('MSIE 9.0') > -1;
|
143
|
-
selector = is(selector, 'array') ? selector.join(',') : selector;
|
144
|
-
|
145
|
-
return [].filter.call(
|
146
|
-
this.dialog.querySelectorAll(selector)
|
147
|
-
, function (element) {
|
148
|
-
if (fallback) {
|
149
|
-
var style = window.getComputedStyle(element);
|
150
|
-
return style.display !== 'none' && style.visibility !== 'hidden';
|
151
|
-
}
|
152
|
-
|
153
|
-
return element.offsetParent !== null;
|
154
|
-
}
|
155
|
-
);
|
156
|
-
};
|
157
|
-
|
158
|
-
RModal.prototype.focus = function focus (el) {
|
159
|
-
el = el || this.elements(this.opts.focusElements)[0] || this.dialog.firstChild;
|
160
|
-
|
161
|
-
if (el && is(el.focus, 'function')) {
|
162
|
-
el.focus();
|
163
|
-
}
|
164
|
-
};
|
165
|
-
|
166
|
-
RModal.prototype.keydown = function keydown (ev) {
|
167
|
-
if (this.opts.escapeClose && ev.which == 27) {
|
168
|
-
this.close();
|
169
|
-
}
|
170
|
-
|
171
|
-
function stopEvent() {
|
172
|
-
ev.preventDefault();
|
173
|
-
ev.stopPropagation();
|
174
|
-
}
|
175
|
-
|
176
|
-
if (this.opened && ev.which == 9 && this.dialog.contains(ev.target)) {
|
177
|
-
var elements = this.elements(this.opts.focusElements)
|
178
|
-
, first = elements[0]
|
179
|
-
, last = elements[elements.length - 1];
|
180
|
-
|
181
|
-
if (first == last) {
|
182
|
-
stopEvent();
|
183
|
-
}
|
184
|
-
else if (ev.target == first && ev.shiftKey) {
|
185
|
-
stopEvent();
|
186
|
-
last.focus();
|
187
|
-
}
|
188
|
-
else if (ev.target == last && !ev.shiftKey) {
|
189
|
-
stopEvent();
|
190
|
-
first.focus();
|
191
|
-
}
|
192
|
-
}
|
193
|
-
};
|
194
|
-
|
195
|
-
RModal.prototype.version = '1.0.24';
|
196
|
-
RModal.version = '1.0.24';
|
197
|
-
|
198
|
-
return RModal;
|
199
|
-
|
200
|
-
})));
|
201
|
-
//# sourceMappingURL=rmodal.js.map
|