@lemonadejs/modal 2.3.1 → 2.3.3

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 CHANGED
@@ -10,14 +10,12 @@ 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
- /** Modal can be closed */
18
- closable?: boolean;
19
15
  /** Modal is minimized */
20
16
  minimized?: boolean;
17
+ /** Modal can be closed */
18
+ closable?: boolean;
21
19
  /** Modal can be minimized */
22
20
  minimizable?: boolean;
23
21
  /** Modal can be resized */
@@ -38,14 +36,17 @@ 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 {
48
- autoclose: boolean;
49
50
  closed: boolean;
50
51
  closable: boolean;
51
52
  minimized: boolean;
@@ -58,6 +59,7 @@ interface instance {
58
59
  height: number;
59
60
  top: number;
60
61
  left: number;
62
+ 'auto-close': boolean;
61
63
  }
62
64
 
63
65
  export declare function Modal(el: HTMLElement, options?: options): 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.autoclose === true) {
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.autoadjust) {
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
@@ -13,7 +13,7 @@
13
13
  border: 1px solid #e9e9e9;
14
14
  }
15
15
 
16
- .lm-modal:focus {
16
+ .lm-modal-layers:focus {
17
17
  z-index: 10;
18
18
  }
19
19
 
package/package.json CHANGED
@@ -16,5 +16,6 @@
16
16
  "lemonadejs": "^3.4.0"
17
17
  },
18
18
  "main": "dist/index.js",
19
- "version": "2.3.1"
19
+ "types": "dist/index.d.ts",
20
+ "version": "2.3.3"
20
21
  }