@ulu/frontend 0.1.0-beta.80 → 0.1.0-beta.81
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/CHANGELOG.md +15 -0
- package/dist/ulu-frontend.min.css +1 -1
- package/dist/ulu-frontend.min.js +15 -15
- package/docs-dev/changelog/index.html +40 -0
- package/docs-dev/demos/card/index.html +16 -16
- package/docs-dev/demos/css-icons/index.html +23 -0
- package/docs-dev/demos/data-table/index.html +100 -100
- package/docs-dev/demos/modals/index.html +9 -1
- package/docs-dev/javascript/events/index.html +41 -1
- package/docs-dev/javascript/settings/index.html +5 -0
- package/docs-dev/javascript/ui-resizer/index.html +79 -10
- package/docs-dev/javascript/utils-class-logger/index.html +1 -1
- package/docs-dev/sass/components/css-icon/index.html +1 -1
- package/docs-dev/sass/components/modal/index.html +15 -8
- package/js/events/index.js +17 -5
- package/js/settings.js +2 -0
- package/js/ui/dialog.js +47 -3
- package/js/ui/modal-builder.js +23 -12
- package/js/ui/resizer.js +186 -36
- package/js/utils/class-logger.js +3 -3
- package/js/utils/font-awesome.js +1 -0
- package/package.json +1 -1
- package/scss/components/_css-icon.scss +10 -0
- package/scss/components/_modal.scss +16 -3
- package/types/events/index.d.ts +10 -1
- package/types/events/index.d.ts.map +1 -1
- package/types/settings.d.ts +4 -0
- package/types/settings.d.ts.map +1 -1
- package/types/ui/dialog.d.ts.map +1 -1
- package/types/ui/modal-builder.d.ts +3 -0
- package/types/ui/modal-builder.d.ts.map +1 -1
- package/types/ui/resizer.d.ts +39 -12
- package/types/ui/resizer.d.ts.map +1 -1
- package/types/utils/font-awesome.d.ts.map +1 -1
|
@@ -5202,8 +5202,23 @@
|
|
|
5202
5202
|
|
|
5203
5203
|
<li><a href="#new-exports.resizer(container%2C-control%2C-options)">new exports.Resizer(container, control, options)</a>
|
|
5204
5204
|
</li>
|
|
5205
|
+
|
|
5206
|
+
<li><a href="#resizer.destroy()">resizer.destroy()</a>
|
|
5207
|
+
</li>
|
|
5205
5208
|
</ol>
|
|
5206
5209
|
</li>
|
|
5210
|
+
|
|
5211
|
+
<li><a href="#ui%2Fresizer~multiplier">ui/resizer~multiplier</a>
|
|
5212
|
+
</li>
|
|
5213
|
+
|
|
5214
|
+
<li><a href="#ui%2Fresizer~overridemaxdimensions">ui/resizer~overrideMaxDimensions</a>
|
|
5215
|
+
</li>
|
|
5216
|
+
|
|
5217
|
+
<li><a href="#ui%2Fresizer~fromx-%3A-%22left%22-%7C-%22right%22-%7C-null">ui/resizer~fromX : "left" | "right" | null</a>
|
|
5218
|
+
</li>
|
|
5219
|
+
|
|
5220
|
+
<li><a href="#ui%2Fresizer~fromy-%3A-%22top%22-%7C-%22bottom%22-%7C-null">ui/resizer~fromY : "top" | "bottom" | null</a>
|
|
5221
|
+
</li>
|
|
5207
5222
|
</ol>
|
|
5208
5223
|
</div>
|
|
5209
5224
|
</div>
|
|
@@ -5220,9 +5235,22 @@
|
|
|
5220
5235
|
<ul>
|
|
5221
5236
|
<li><a href="#module_ui/resizer">ui/resizer</a>
|
|
5222
5237
|
<ul>
|
|
5238
|
+
<li><em>static</em>
|
|
5239
|
+
<ul>
|
|
5223
5240
|
<li><a href="#module_ui/resizer.Resizer">.Resizer</a>
|
|
5224
5241
|
<ul>
|
|
5225
5242
|
<li><a href="#new_module_ui/resizer.Resizer_new">new exports.Resizer(container, control, options)</a></li>
|
|
5243
|
+
<li><a href="#module_ui/resizer.Resizer+destroy">.destroy()</a></li>
|
|
5244
|
+
</ul>
|
|
5245
|
+
</li>
|
|
5246
|
+
</ul>
|
|
5247
|
+
</li>
|
|
5248
|
+
<li><em>inner</em>
|
|
5249
|
+
<ul>
|
|
5250
|
+
<li><a href="#module_ui/resizer..multiplier">~multiplier</a></li>
|
|
5251
|
+
<li><a href="#module_ui/resizer..overrideMaxDimensions">~overrideMaxDimensions</a></li>
|
|
5252
|
+
<li><a href="#module_ui/resizer..fromX">~fromX</a> : <code>"left"</code> | <code>"right"</code> | <code>null</code></li>
|
|
5253
|
+
<li><a href="#module_ui/resizer..fromY">~fromY</a> : <code>"top"</code> | <code>"bottom"</code> | <code>null</code></li>
|
|
5226
5254
|
</ul>
|
|
5227
5255
|
</li>
|
|
5228
5256
|
</ul>
|
|
@@ -5230,14 +5258,23 @@
|
|
|
5230
5258
|
</ul>
|
|
5231
5259
|
<p><a name="module_ui/resizer.Resizer"></a></p>
|
|
5232
5260
|
<h2 id="ui%2Fresizer.resizer" tabindex="-1">ui/resizer.Resizer</h2>
|
|
5233
|
-
<p><strong>Kind</strong>: static class of <a href="#module_ui/resizer"><code>ui/resizer</code></a
|
|
5234
|
-
<
|
|
5261
|
+
<p><strong>Kind</strong>: static class of <a href="#module_ui/resizer"><code>ui/resizer</code></a></p>
|
|
5262
|
+
<ul>
|
|
5263
|
+
<li><a href="#module_ui/resizer.Resizer">.Resizer</a>
|
|
5264
|
+
<ul>
|
|
5265
|
+
<li><a href="#new_module_ui/resizer.Resizer_new">new exports.Resizer(container, control, options)</a></li>
|
|
5266
|
+
<li><a href="#module_ui/resizer.Resizer+destroy">.destroy()</a></li>
|
|
5267
|
+
</ul>
|
|
5268
|
+
</li>
|
|
5269
|
+
</ul>
|
|
5270
|
+
<p><a name="new_module_ui/resizer.Resizer_new"></a></p>
|
|
5235
5271
|
<h3 id="new-exports.resizer(container%2C-control%2C-options)" tabindex="-1">new exports.Resizer(container, control, options)</h3>
|
|
5236
5272
|
<table>
|
|
5237
5273
|
<thead>
|
|
5238
5274
|
<tr>
|
|
5239
5275
|
<th>Param</th>
|
|
5240
5276
|
<th>Type</th>
|
|
5277
|
+
<th>Default</th>
|
|
5241
5278
|
<th>Description</th>
|
|
5242
5279
|
</tr>
|
|
5243
5280
|
</thead>
|
|
@@ -5245,35 +5282,67 @@
|
|
|
5245
5282
|
<tr>
|
|
5246
5283
|
<td>container</td>
|
|
5247
5284
|
<td><code>Node</code></td>
|
|
5248
|
-
<td
|
|
5285
|
+
<td></td>
|
|
5286
|
+
<td>Container to be resized</td>
|
|
5249
5287
|
</tr>
|
|
5250
5288
|
<tr>
|
|
5251
5289
|
<td>control</td>
|
|
5252
5290
|
<td><code>Node</code></td>
|
|
5291
|
+
<td></td>
|
|
5253
5292
|
<td>Resize handle element</td>
|
|
5254
5293
|
</tr>
|
|
5255
5294
|
<tr>
|
|
5256
5295
|
<td>options</td>
|
|
5257
5296
|
<td><code>Object</code></td>
|
|
5258
|
-
<td
|
|
5297
|
+
<td></td>
|
|
5298
|
+
<td>Options to configure the resizer.</td>
|
|
5259
5299
|
</tr>
|
|
5260
5300
|
<tr>
|
|
5261
5301
|
<td>options.debug</td>
|
|
5262
5302
|
<td><code>Boolean</code></td>
|
|
5263
|
-
<td
|
|
5303
|
+
<td></td>
|
|
5304
|
+
<td>Enable non-essential debugging logs.</td>
|
|
5264
5305
|
</tr>
|
|
5265
5306
|
<tr>
|
|
5266
|
-
<td>options.
|
|
5307
|
+
<td>options.overrideMaxDimensions</td>
|
|
5267
5308
|
<td><code>Boolean</code></td>
|
|
5268
|
-
<td
|
|
5309
|
+
<td></td>
|
|
5310
|
+
<td>When script is activated by handle, remove the element's max-width/max-height and allow the resize to exceed them (default false).</td>
|
|
5269
5311
|
</tr>
|
|
5270
5312
|
<tr>
|
|
5271
|
-
<td>options.
|
|
5272
|
-
<td><code>
|
|
5273
|
-
<td
|
|
5313
|
+
<td>[options.fromX]</td>
|
|
5314
|
+
<td><code>"left"</code> | <code>"right"</code> | <code>null</code></td>
|
|
5315
|
+
<td><code></code></td>
|
|
5316
|
+
<td>Horizontal resizing direction.</td>
|
|
5317
|
+
</tr>
|
|
5318
|
+
<tr>
|
|
5319
|
+
<td>[options.fromY]</td>
|
|
5320
|
+
<td><code>"top"</code> | <code>"bottom"</code> | <code>null</code></td>
|
|
5321
|
+
<td><code></code></td>
|
|
5322
|
+
<td>Vertical resizing direction.</td>
|
|
5274
5323
|
</tr>
|
|
5275
5324
|
</tbody>
|
|
5276
5325
|
</table>
|
|
5326
|
+
<p><a name="module_ui/resizer.Resizer+destroy"></a></p>
|
|
5327
|
+
<h3 id="resizer.destroy()" tabindex="-1">resizer.destroy()</h3>
|
|
5328
|
+
<p>Cleans up event listeners to prevent memory leaks.</p>
|
|
5329
|
+
<p><strong>Kind</strong>: instance method of <a href="#module_ui/resizer.Resizer"><code>Resizer</code></a><br>
|
|
5330
|
+
<a name="module_ui/resizer..multiplier"></a></p>
|
|
5331
|
+
<h2 id="ui%2Fresizer~multiplier" tabindex="-1">ui/resizer~multiplier</h2>
|
|
5332
|
+
<p>Amount to increase size by (ie. pointer movement * multiplier)</p>
|
|
5333
|
+
<p><strong>Kind</strong>: inner property of <a href="#module_ui/resizer"><code>ui/resizer</code></a><br>
|
|
5334
|
+
<a name="module_ui/resizer..overrideMaxDimensions"></a></p>
|
|
5335
|
+
<h2 id="ui%2Fresizer~overridemaxdimensions" tabindex="-1">ui/resizer~overrideMaxDimensions</h2>
|
|
5336
|
+
<p>Remove max-width, max-height</p>
|
|
5337
|
+
<p><strong>Kind</strong>: inner property of <a href="#module_ui/resizer"><code>ui/resizer</code></a><br>
|
|
5338
|
+
<a name="module_ui/resizer..fromX"></a></p>
|
|
5339
|
+
<h2 id="ui%2Fresizer~fromx-%3A-%22left%22-%7C-%22right%22-%7C-null" tabindex="-1">ui/resizer~fromX : <code>"left"</code> | <code>"right"</code> | <code>null</code></h2>
|
|
5340
|
+
<p>Specifies the horizontal edge from which resizing occurs.<code>null</code> means no horizontal resizing.- Default null</p>
|
|
5341
|
+
<p><strong>Kind</strong>: inner property of <a href="#module_ui/resizer"><code>ui/resizer</code></a><br>
|
|
5342
|
+
<a name="module_ui/resizer..fromY"></a></p>
|
|
5343
|
+
<h2 id="ui%2Fresizer~fromy-%3A-%22top%22-%7C-%22bottom%22-%7C-null" tabindex="-1">ui/resizer~fromY : <code>"top"</code> | <code>"bottom"</code> | <code>null</code></h2>
|
|
5344
|
+
<p>Specifies the vertical edge from which resizing occurs.- <code>null</code> means no vertical resizing.- Default null</p>
|
|
5345
|
+
<p><strong>Kind</strong>: inner property of <a href="#module_ui/resizer"><code>ui/resizer</code></a></p>
|
|
5277
5346
|
|
|
5278
5347
|
</div>
|
|
5279
5348
|
</div>
|
|
@@ -5337,7 +5337,7 @@
|
|
|
5337
5337
|
</table>
|
|
5338
5338
|
<p><a name="module_utils/class-logger..config"></a></p>
|
|
5339
5339
|
<h2 id="utils%2Fclass-logger~config" tabindex="-1">utils/class-logger~config</h2>
|
|
5340
|
-
<p>Configuration Object</p>
|
|
5340
|
+
<p>Global Configuration Object</p>
|
|
5341
5341
|
<p><strong>Kind</strong>: inner constant of <a href="#module_utils/class-logger"><code>utils/class-logger</code></a></p>
|
|
5342
5342
|
|
|
5343
5343
|
</div>
|
|
@@ -5459,7 +5459,7 @@
|
|
|
5459
5459
|
<li><strong>Group:</strong> css-icon</li>
|
|
5460
5460
|
<li><strong>Type:</strong> mixin</li>
|
|
5461
5461
|
<li><strong>Lines (comments):</strong> 101-103</li>
|
|
5462
|
-
<li><strong>Lines (code):</strong> 105-
|
|
5462
|
+
<li><strong>Lines (code):</strong> 105-448</li>
|
|
5463
5463
|
</ul>
|
|
5464
5464
|
</details>
|
|
5465
5465
|
<h4 id="examples-1" tabindex="-1">Examples</h4>
|
|
@@ -5281,6 +5281,7 @@
|
|
|
5281
5281
|
<span class="pjs-token pjs-string">"resizer-color"</span><span class="pjs-token pjs-punctuation">:</span> <span class="pjs-token pjs-function">rgb</span><span class="pjs-token pjs-punctuation">(</span>99<span class="pjs-token pjs-punctuation">,</span> 99<span class="pjs-token pjs-punctuation">,</span> 99<span class="pjs-token pjs-punctuation">)</span><span class="pjs-token pjs-punctuation">,</span>
|
|
5282
5282
|
<span class="pjs-token pjs-string">"resizer-color-hover"</span><span class="pjs-token pjs-punctuation">:</span> black<span class="pjs-token pjs-punctuation">,</span>
|
|
5283
5283
|
<span class="pjs-token pjs-string">"resizer-width"</span><span class="pjs-token pjs-punctuation">:</span> 1.25rem<span class="pjs-token pjs-punctuation">,</span>
|
|
5284
|
+
<span class="pjs-token pjs-string">"resizer-center-size"</span> <span class="pjs-token pjs-punctuation">:</span> 1.65rem<span class="pjs-token pjs-punctuation">,</span>
|
|
5284
5285
|
<span class="pjs-token pjs-string">"title-color"</span><span class="pjs-token pjs-punctuation">:</span> white<span class="pjs-token pjs-punctuation">,</span>
|
|
5285
5286
|
<span class="pjs-token pjs-string">"title-font-weight"</span><span class="pjs-token pjs-punctuation">:</span> bold<span class="pjs-token pjs-punctuation">,</span>
|
|
5286
5287
|
<span class="pjs-token pjs-string">"title-font-family"</span> <span class="pjs-token pjs-punctuation">:</span> <span class="pjs-token pjs-null pjs-keyword">null</span><span class="pjs-token pjs-punctuation">,</span>
|
|
@@ -5298,8 +5299,8 @@
|
|
|
5298
5299
|
<li><strong>File:</strong> _modal.scss</li>
|
|
5299
5300
|
<li><strong>Group:</strong> modal</li>
|
|
5300
5301
|
<li><strong>Type:</strong> variable</li>
|
|
5301
|
-
<li><strong>Lines (comments):</strong> 31-
|
|
5302
|
-
<li><strong>Lines (code):</strong>
|
|
5302
|
+
<li><strong>Lines (comments):</strong> 31-72</li>
|
|
5303
|
+
<li><strong>Lines (code):</strong> 74-119</li>
|
|
5303
5304
|
</ul>
|
|
5304
5305
|
</details>
|
|
5305
5306
|
<h4 id="map-properties" tabindex="-1">Map Properties</h4>
|
|
@@ -5506,6 +5507,12 @@
|
|
|
5506
5507
|
<td style="text-align:left">The width of the resizer.</td>
|
|
5507
5508
|
</tr>
|
|
5508
5509
|
<tr>
|
|
5510
|
+
<td style="text-align:left">resizer-center-size</td>
|
|
5511
|
+
<td style="text-align:left">Dimension</td>
|
|
5512
|
+
<td style="text-align:left">1.65rem</td>
|
|
5513
|
+
<td style="text-align:left">The width/height of the resizer (in bottom right corner) used when position center with resize enabled</td>
|
|
5514
|
+
</tr>
|
|
5515
|
+
<tr>
|
|
5509
5516
|
<td style="text-align:left">title-color</td>
|
|
5510
5517
|
<td style="text-align:left">Color</td>
|
|
5511
5518
|
<td style="text-align:left">white</td>
|
|
@@ -5563,8 +5570,8 @@
|
|
|
5563
5570
|
<li><strong>File:</strong> _modal.scss</li>
|
|
5564
5571
|
<li><strong>Group:</strong> modal</li>
|
|
5565
5572
|
<li><strong>Type:</strong> mixin</li>
|
|
5566
|
-
<li><strong>Lines (comments):</strong>
|
|
5567
|
-
<li><strong>Lines (code):</strong>
|
|
5573
|
+
<li><strong>Lines (comments):</strong> 121-124</li>
|
|
5574
|
+
<li><strong>Lines (code):</strong> 126-128</li>
|
|
5568
5575
|
</ul>
|
|
5569
5576
|
</details>
|
|
5570
5577
|
<h4 id="examples" tabindex="-1">Examples</h4>
|
|
@@ -5603,8 +5610,8 @@
|
|
|
5603
5610
|
<li><strong>File:</strong> _modal.scss</li>
|
|
5604
5611
|
<li><strong>Group:</strong> modal</li>
|
|
5605
5612
|
<li><strong>Type:</strong> mixin</li>
|
|
5606
|
-
<li><strong>Lines (comments):</strong>
|
|
5607
|
-
<li><strong>Lines (code):</strong>
|
|
5613
|
+
<li><strong>Lines (comments):</strong> 140-142</li>
|
|
5614
|
+
<li><strong>Lines (code):</strong> 144-513</li>
|
|
5608
5615
|
</ul>
|
|
5609
5616
|
</details>
|
|
5610
5617
|
<h4 id="examples-1" tabindex="-1">Examples</h4>
|
|
@@ -5627,8 +5634,8 @@
|
|
|
5627
5634
|
<li><strong>File:</strong> _modal.scss</li>
|
|
5628
5635
|
<li><strong>Group:</strong> modal</li>
|
|
5629
5636
|
<li><strong>Type:</strong> function</li>
|
|
5630
|
-
<li><strong>Lines (comments):</strong>
|
|
5631
|
-
<li><strong>Lines (code):</strong>
|
|
5637
|
+
<li><strong>Lines (comments):</strong> 130-133</li>
|
|
5638
|
+
<li><strong>Lines (code):</strong> 135-138</li>
|
|
5632
5639
|
</ul>
|
|
5633
5640
|
</details>
|
|
5634
5641
|
<h4 id="examples-2" tabindex="-1">Examples</h4>
|
package/js/events/index.js
CHANGED
|
@@ -21,30 +21,31 @@ const events = {
|
|
|
21
21
|
* - Is triggered by modules that were responsible for modifying the page
|
|
22
22
|
*/
|
|
23
23
|
pageModified(context) {
|
|
24
|
-
context.dispatchEvent(
|
|
24
|
+
context.dispatchEvent(createEvent("pageModified"));
|
|
25
25
|
},
|
|
26
26
|
/**
|
|
27
27
|
* Event called when page is resized
|
|
28
28
|
*/
|
|
29
29
|
pageResized(context) {
|
|
30
|
-
context.dispatchEvent(
|
|
30
|
+
context.dispatchEvent(createEvent("pageResized"));
|
|
31
31
|
},
|
|
32
32
|
/**
|
|
33
33
|
* Event dispatched before page print begins (teardown/restructure/hide things)
|
|
34
34
|
*/
|
|
35
35
|
beforePrint(context) {
|
|
36
|
-
context.dispatchEvent(
|
|
36
|
+
context.dispatchEvent(createEvent("beforePrint"));
|
|
37
37
|
},
|
|
38
38
|
/**
|
|
39
39
|
* Event dispatched after page print (cleanup)
|
|
40
40
|
*/
|
|
41
41
|
afterPrint(context) {
|
|
42
|
-
context.dispatchEvent(
|
|
42
|
+
context.dispatchEvent(createEvent("afterPrint"));
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
|
-
* Triggers one of our custom events
|
|
47
|
+
* Triggers one of our custom events (page/document level events)
|
|
48
|
+
* - UI components may dispatch their own events, this is just used for system wide events
|
|
48
49
|
* @param {String} type Type of event to dispatch
|
|
49
50
|
* @param {Node} context Element to trigger the event from
|
|
50
51
|
* @example
|
|
@@ -62,6 +63,7 @@ export function dispatch(type, context) {
|
|
|
62
63
|
|
|
63
64
|
/**
|
|
64
65
|
* Namespaced event
|
|
66
|
+
* - Should be used for all ulu script/component events
|
|
65
67
|
* @param {String} type Type of event to get the actual event name for
|
|
66
68
|
* @returns {String}
|
|
67
69
|
*/
|
|
@@ -69,6 +71,16 @@ export function getName(type) {
|
|
|
69
71
|
return "ulu:" + type;
|
|
70
72
|
}
|
|
71
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Create ulu namespaced custom event
|
|
76
|
+
* @param {String} type Event base name (not prefixed)
|
|
77
|
+
* @param {any} data Custom data to pass with the event (will be available as `event.detail`)
|
|
78
|
+
* @param {Object} options CustomEvent options default `{ bubbles: true }`. If `detail` is also provided, it will be merged with this options object and will override the 'data' argument for this function
|
|
79
|
+
*/
|
|
80
|
+
export function createEvent(type, data = null, options = { bubbles: true }) {
|
|
81
|
+
return new CustomEvent(getName(type), { detail: data, ...options });
|
|
82
|
+
}
|
|
83
|
+
|
|
72
84
|
/**
|
|
73
85
|
* Setup resize handler/dispatch
|
|
74
86
|
*/
|
package/js/settings.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* @typedef {object} Defaults
|
|
9
9
|
* @property {string} iconClassClose - The CSS class string for the close icon
|
|
10
10
|
* @property {string} iconClassDragX - The CSS class string for the drag X icon
|
|
11
|
+
* @property {string} iconClassDragBoth - The CSS class string for the dragging in both directions
|
|
11
12
|
* @property {string} iconClassPrevious - The CSS class string for the previous icon
|
|
12
13
|
* @property {string} iconClassNext - The CSS class string for the next icon
|
|
13
14
|
* @property {string} cssvarPrefix - The prefix to use for CSS custom properties
|
|
@@ -19,6 +20,7 @@
|
|
|
19
20
|
const defaults = {
|
|
20
21
|
iconClassClose: "css-icon css-icon--close",
|
|
21
22
|
iconClassDragX: "css-icon css-icon--drag-x",
|
|
23
|
+
iconClassDragBoth: "css-icon css-icon--drag-both",
|
|
22
24
|
iconClassPrevious: "css-icon css-icon--angle-left",
|
|
23
25
|
iconClassNext: "css-icon css-icon--angle-right",
|
|
24
26
|
cssvarPrefix: "",
|
package/js/ui/dialog.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { ComponentInitializer } from "../utils/system.js";
|
|
6
6
|
import { wasClickOutside, preventScroll as setupPreventScroll } from "@ulu/utils/browser/dom.js";
|
|
7
|
+
import { debounce } from "@ulu/utils/performance.js";
|
|
7
8
|
import { pauseVideos as pauseYoutubeVideos, prepVideos as prepYoutubeVideos } from "../utils/pause-youtube-video.js";
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -131,9 +132,37 @@ export function setupDialog(dialog, userOptions) {
|
|
|
131
132
|
const options = Object.assign({}, currentDefaults, userOptions);
|
|
132
133
|
const body = document.body;
|
|
133
134
|
const { preventScrollShift: preventShift } = options;
|
|
135
|
+
let isPointerDown = false;
|
|
136
|
+
let isResizing = false;
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
// This was added to provide a simple flag for "isPointerDown" so that
|
|
140
|
+
// we can disable click outside if it was a click that originated inside the dialog, probable from
|
|
141
|
+
// native resize handle. If this causes issues in the future we can explore tracking the pointer
|
|
142
|
+
// with setPointerCapture but I'm worried about it affecting inner elements with their own pointer events
|
|
143
|
+
// This seems like it will be ok we just don't allow outside closing if there was pointerdown from within the modal
|
|
144
|
+
dialog.addEventListener("pointerdown", handlePointerdown);
|
|
134
145
|
|
|
135
146
|
dialog.addEventListener("click", handleClicks);
|
|
136
147
|
|
|
148
|
+
// Watching for resizes to avoid closing outside during resizes
|
|
149
|
+
// - There is no resize event for css resize (so this uses pointerdown and resize observer)
|
|
150
|
+
const handleResizeEnd = debounce(() => {
|
|
151
|
+
if (isResizing && !isPointerDown) {
|
|
152
|
+
isResizing = false;
|
|
153
|
+
}
|
|
154
|
+
}, 500);
|
|
155
|
+
|
|
156
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
157
|
+
if (isPointerDown) {
|
|
158
|
+
if (!isResizing) {
|
|
159
|
+
isResizing = true;
|
|
160
|
+
}
|
|
161
|
+
handleResizeEnd();
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
resizeObserver.observe(dialog);
|
|
165
|
+
|
|
137
166
|
if (options.documentEnd) {
|
|
138
167
|
body.appendChild(dialog);
|
|
139
168
|
}
|
|
@@ -158,12 +187,27 @@ export function setupDialog(dialog, userOptions) {
|
|
|
158
187
|
});
|
|
159
188
|
}
|
|
160
189
|
|
|
190
|
+
function handlePointerdown() {
|
|
191
|
+
if (isPointerDown) return;
|
|
192
|
+
isPointerDown = true;
|
|
193
|
+
|
|
194
|
+
const done = () => {
|
|
195
|
+
// After event queue (click) - so after click handler for outside is called
|
|
196
|
+
setTimeout(() => {
|
|
197
|
+
isPointerDown = false;
|
|
198
|
+
isResizing = false;
|
|
199
|
+
}, 0);
|
|
200
|
+
};
|
|
201
|
+
document.addEventListener("pointerup", done, { once: true });
|
|
202
|
+
document.addEventListener("pointercancel", done, { once: true });
|
|
203
|
+
}
|
|
204
|
+
|
|
161
205
|
function handleClicks(event) {
|
|
162
206
|
const { target } = event;
|
|
207
|
+
const targetIsDialog = target === dialog;
|
|
163
208
|
const closeFromButton = target.closest(initializer.attributeSelector("close"));
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
wasClickOutside(dialog, event);
|
|
209
|
+
const allowCloseOutside = !isResizing && options.clickOutsideCloses;
|
|
210
|
+
const closeFromOutside = allowCloseOutside && targetIsDialog && wasClickOutside(dialog, event);
|
|
167
211
|
if (closeFromOutside || closeFromButton) {
|
|
168
212
|
if (options.pauseVideos) {
|
|
169
213
|
pauseVideos(dialog);
|
package/js/ui/modal-builder.js
CHANGED
|
@@ -78,14 +78,16 @@ export const defaults = {
|
|
|
78
78
|
footerHtml: null,
|
|
79
79
|
classCloseIcon: wrapSettingString("iconClassClose"),
|
|
80
80
|
classResizerIcon: wrapSettingString("iconClassDragX"),
|
|
81
|
+
classResizerIconBoth: wrapSettingString("iconClassDragBoth"),
|
|
81
82
|
debug: false,
|
|
82
83
|
templateCloseIcon(config) {
|
|
83
84
|
const { baseClass, classCloseIcon } = config;
|
|
84
85
|
return `<span class="${ baseClass }__close-icon ${ classCloseIcon }" aria-hidden="true"></span>`;
|
|
85
86
|
},
|
|
86
87
|
templateResizerIcon(config) {
|
|
87
|
-
const { baseClass, classResizerIcon } = config;
|
|
88
|
-
|
|
88
|
+
const { baseClass, classResizerIcon, classResizerIconBoth } = config;
|
|
89
|
+
const iconClass = config.position === "center" ? classResizerIconBoth : classResizerIcon;
|
|
90
|
+
return `<span class="${ baseClass }__resizer-icon ${ iconClass }" aria-hidden="true"></span>`;
|
|
89
91
|
},
|
|
90
92
|
/**
|
|
91
93
|
* Default modal template
|
|
@@ -129,7 +131,7 @@ export const defaults = {
|
|
|
129
131
|
` : "" }
|
|
130
132
|
<div class="${ baseClass }__body" ${ initializer.getAttribute("body") }></div>
|
|
131
133
|
${ footerHtml ? `<div class="${ baseClass }__footer">${ footerHtml }</div>`: "" }
|
|
132
|
-
${ config.
|
|
134
|
+
${ config.allowResize ?
|
|
133
135
|
`<div class="${ baseClass }__resizer" ${ initializer.getAttribute("resizer") }>
|
|
134
136
|
${ config.templateResizerIcon(config) }
|
|
135
137
|
</div>` : ""
|
|
@@ -172,9 +174,8 @@ export function buildModal(content, options) {
|
|
|
172
174
|
|
|
173
175
|
const config = Object.assign({}, currentDefaults, options);
|
|
174
176
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
177
|
+
const { position } = config;
|
|
178
|
+
|
|
178
179
|
if (config.debug) {
|
|
179
180
|
initializer.log(config, content);
|
|
180
181
|
}
|
|
@@ -186,7 +187,7 @@ export function buildModal(content, options) {
|
|
|
186
187
|
const modal = createElementFromHtml(markup.trim());
|
|
187
188
|
const selectChild = key => modal.querySelector(initializer.attributeSelector(key));
|
|
188
189
|
const body = selectChild("body");
|
|
189
|
-
const
|
|
190
|
+
const resizerElement = selectChild("resizer");
|
|
190
191
|
const dialogOptions = separateDialogOptions(config);
|
|
191
192
|
|
|
192
193
|
// Replace content with new dialog, and then insert the content into the new dialogs body
|
|
@@ -209,10 +210,20 @@ export function buildModal(content, options) {
|
|
|
209
210
|
}
|
|
210
211
|
}
|
|
211
212
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
213
|
+
let resizer;
|
|
214
|
+
const resizablePositions = ["left", "right", "center"];
|
|
215
|
+
const isCenter = position === "center";
|
|
216
|
+
const isRight = position === "right";
|
|
217
|
+
|
|
218
|
+
if (config.allowResize) {
|
|
219
|
+
if (resizablePositions.includes(position)) {
|
|
220
|
+
const resizerOptions = isCenter ?
|
|
221
|
+
{ fromX: "right", fromY: "bottom", multiplier: 2 } :
|
|
222
|
+
{ fromX: isRight ? "left" : "right" };
|
|
223
|
+
resizer = new Resizer(modal, resizerElement, resizerOptions);
|
|
224
|
+
} else {
|
|
225
|
+
console.warn(`${ position } is not supported for resizing`);
|
|
226
|
+
}
|
|
216
227
|
}
|
|
217
228
|
|
|
218
229
|
if (config.print) {
|
|
@@ -225,7 +236,7 @@ export function buildModal(content, options) {
|
|
|
225
236
|
printClone.remove();
|
|
226
237
|
});
|
|
227
238
|
}
|
|
228
|
-
return { modal };
|
|
239
|
+
return { modal, resizer };
|
|
229
240
|
}
|
|
230
241
|
|
|
231
242
|
/**
|