@lemonadejs/modal 2.3.1 → 2.3.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.
- package/dist/index.d.ts +6 -4
- package/dist/index.js +45 -37
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -10,8 +10,6 @@ interface Modal {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
interface options {
|
|
13
|
-
/** Close the modal when it loses the focus */
|
|
14
|
-
autoclose?: boolean;
|
|
15
13
|
/** Modal is closed */
|
|
16
14
|
closed?: boolean;
|
|
17
15
|
/** Modal can be closed */
|
|
@@ -38,10 +36,14 @@ interface options {
|
|
|
38
36
|
left?: number;
|
|
39
37
|
/** Load the content from a remote URL */
|
|
40
38
|
url?: string;
|
|
41
|
-
/** Ensures modal will be visible on screen */
|
|
42
|
-
autoadjust?: boolean;
|
|
43
39
|
/** Responsive mode. Default is true */
|
|
44
40
|
responsive?: boolean;
|
|
41
|
+
/** Bring to front on focus */
|
|
42
|
+
layers?: boolean;
|
|
43
|
+
/** Close the modal when it loses the focus */
|
|
44
|
+
'auto-close'?: boolean;
|
|
45
|
+
/** Ensures modal will be visible on screen */
|
|
46
|
+
'auto-adjust'?: boolean;
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
interface instance {
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* pin the modal to the left panel
|
|
3
|
+
*/
|
|
1
4
|
if (!lemonade && typeof (require) === 'function') {
|
|
2
5
|
var lemonade = require('lemonadejs');
|
|
3
6
|
}
|
|
@@ -133,10 +136,43 @@ if (!lemonade && typeof (require) === 'function') {
|
|
|
133
136
|
}
|
|
134
137
|
}
|
|
135
138
|
|
|
139
|
+
const refreshMinimized = function() {
|
|
140
|
+
let items = minimizedModals;
|
|
141
|
+
let numOfItems = items.length;
|
|
142
|
+
let width = 0;
|
|
143
|
+
let height = 5;
|
|
144
|
+
for (let i = 0; i < numOfItems; i++) {
|
|
145
|
+
let item = items[i];
|
|
146
|
+
item.el.style.marginLeft = width;
|
|
147
|
+
item.el.style.marginBottom = height;
|
|
148
|
+
width += 205;
|
|
149
|
+
|
|
150
|
+
if (document.body.offsetWidth - width < 205) {
|
|
151
|
+
width = 0;
|
|
152
|
+
height += 50;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const setMini = function(self) {
|
|
158
|
+
// Minimize modals
|
|
159
|
+
minimizedModals.push(self);
|
|
160
|
+
// Refresh positions
|
|
161
|
+
refreshMinimized.call(self);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const removeMini = function(self) {
|
|
165
|
+
minimizedModals.splice(minimizedModals.indexOf(self), 1);
|
|
166
|
+
self.el.style.marginLeft = '';
|
|
167
|
+
self.el.style.marginBottom = '';
|
|
168
|
+
// Refresh positions
|
|
169
|
+
refreshMinimized.call(self);
|
|
170
|
+
}
|
|
171
|
+
|
|
136
172
|
const adjustTop = function() {
|
|
137
173
|
let self = this;
|
|
138
|
-
let rect = self.el.getBoundingClientRect();
|
|
139
174
|
self.el.style.marginTop = '';
|
|
175
|
+
let rect = self.el.getBoundingClientRect();
|
|
140
176
|
let limit = document.documentElement.clientHeight + window.scrollY - (rect.top + rect.height);
|
|
141
177
|
if (limit < 0) {
|
|
142
178
|
self.el.style.marginTop = limit - 10 + 'px';
|
|
@@ -145,8 +181,8 @@ if (!lemonade && typeof (require) === 'function') {
|
|
|
145
181
|
|
|
146
182
|
const adjustLeft = function() {
|
|
147
183
|
let self = this;
|
|
148
|
-
let rect = self.el.getBoundingClientRect();
|
|
149
184
|
self.el.style.marginLeft = '';
|
|
185
|
+
let rect = self.el.getBoundingClientRect();
|
|
150
186
|
// Make sure component will be visible on page
|
|
151
187
|
let limit = document.documentElement.clientWidth - (rect.left + rect.width);
|
|
152
188
|
if (limit < 0) {
|
|
@@ -211,9 +247,14 @@ if (!lemonade && typeof (require) === 'function') {
|
|
|
211
247
|
self.el.setAttribute('data-responsive', true);
|
|
212
248
|
}
|
|
213
249
|
|
|
250
|
+
// Bring to front on focus
|
|
251
|
+
if (self.layers !== false) {
|
|
252
|
+
self.el.classList.add('lm-modal-layers');
|
|
253
|
+
}
|
|
254
|
+
|
|
214
255
|
// Focus out of the component
|
|
215
256
|
self.el.addEventListener('focusout', function(e) {
|
|
216
|
-
if (self
|
|
257
|
+
if (isTrue(self['auto-close'])) {
|
|
217
258
|
if (!self.el.contains(e.relatedTarget)) {
|
|
218
259
|
self.closed = true;
|
|
219
260
|
}
|
|
@@ -237,7 +278,7 @@ if (!lemonade && typeof (require) === 'function') {
|
|
|
237
278
|
self.el.style[property] = self[property] + 'px';
|
|
238
279
|
|
|
239
280
|
// Adjust position
|
|
240
|
-
if (self
|
|
281
|
+
if (isTrue(self['auto-adjust'])) {
|
|
241
282
|
if (property === 'top') {
|
|
242
283
|
adjustTop.call(self);
|
|
243
284
|
} else if (property === 'left') {
|
|
@@ -287,39 +328,6 @@ if (!lemonade && typeof (require) === 'function') {
|
|
|
287
328
|
}
|
|
288
329
|
}
|
|
289
330
|
|
|
290
|
-
const refreshMinimized = function() {
|
|
291
|
-
let items = minimizedModals;
|
|
292
|
-
let numOfItems = items.length;
|
|
293
|
-
let width = 0;
|
|
294
|
-
let height = 5;
|
|
295
|
-
for (let i = 0; i < numOfItems; i++) {
|
|
296
|
-
let item = items[i];
|
|
297
|
-
item.el.style.marginLeft = width;
|
|
298
|
-
item.el.style.marginBottom = height;
|
|
299
|
-
width += 205;
|
|
300
|
-
|
|
301
|
-
if (document.body.offsetWidth - width < 205) {
|
|
302
|
-
width = 0;
|
|
303
|
-
height += 50;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
const setMini = function(self) {
|
|
309
|
-
// Minimize modals
|
|
310
|
-
minimizedModals.push(self);
|
|
311
|
-
// Refresh positions
|
|
312
|
-
refreshMinimized.call(self);
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
const removeMini = function(self) {
|
|
316
|
-
minimizedModals.splice(minimizedModals.indexOf(self), 1);
|
|
317
|
-
self.el.style.marginLeft = '';
|
|
318
|
-
self.el.style.marginBottom = '';
|
|
319
|
-
// Refresh positions
|
|
320
|
-
refreshMinimized.call(self);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
331
|
self.mousedown = function(e) {
|
|
324
332
|
// Get mouse coordinates
|
|
325
333
|
let [x,y] = getCoords(e);
|
package/dist/style.css
CHANGED
package/package.json
CHANGED