drive 0.16.0 → 0.17.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bba39784566ab073fd1b48d9f3c2039c654f13428be44592e0eb6dc949136a43
4
- data.tar.gz: bcfdcacd52b9d29b94cdbf4573236d854536a847e036380b0ba3379d51dcbdd8
3
+ metadata.gz: 8578690e477feee9d2e1d7f1bee314192de30a35adbbee71ab4c2701c8be8150
4
+ data.tar.gz: 5b7bb3d5c598ccf0576170520243d5095e8c5dd70fa0a4dadadd972a3531aaba
5
5
  SHA512:
6
- metadata.gz: 96729b842a8714ae33ad3d758ca4b99c2be368148d2c09f5c7dceb0c332eb4adb07818760566d60a84fe9ace099b7816c202e5a982d9b6fd38f4b1f39f74407b
7
- data.tar.gz: 6a40e287f83d1e543fff492c8b47ec135245e1a768359acddf96c6b584ba18b5485c1e7424f972bb79882392f658f19c2bdd9e1e9819e590bdb872c271fab39d
6
+ metadata.gz: 42e6b99c7586b679f5a79a9bcc19e7cc6d6b34398db56ace0c93803510623ca3802f213ec7f7e22f897f6da52615d438d03d08e287557b69f8881020c710f354
7
+ data.tar.gz: ef48882a4c7e1973341568cb65c19cc1709e984d346b10feab1830fa7bd8c68cb7cf8871fed60b21910fe4203fdd73f3f3d53985efd91761764b2c89755522b1
data/CHANGELOG.md CHANGED
@@ -6,6 +6,12 @@ For more information about changelogs, check [Keep a Changelog](http://keepachan
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## 0.17.0 - 2026-11-06
10
+
11
+ * [FEATURE] `render layout: "easy/modal", locals: { id:, title:, close: }` (`open:`, `emoji:`, `classes:`) and
12
+ `easy/modal.js`: a dialog that always lets its reader out, its × and Esc closing it in place (the address becoming
13
+ the ×'s), the × a plain link without the script. A dialog closed by its #id opens again on a link to it.
14
+
9
15
  ## 0.16.0 - 2026-11-06
10
16
 
11
17
  * [FEATURE] `easy/mailer/code` (HTML and text): the email carrying a 6-digit code, the same from every easy app, the
@@ -0,0 +1,46 @@
1
+ // Every dialog of render "easy/modal" lets its reader out: its × or Esc closes it where it is, without loading a page,
2
+ // and the address becomes the × link's (the page without what opened it), or loses the #id that opened it. A link to
3
+ // that #id opens it again. Without the script, the × is a plain link.
4
+ // ES5 alone: every easy app has to work on old iPhones, Androids and Windows browsers.
5
+ (function () {
6
+ if (!document.querySelector || !document.addEventListener) { return; }
7
+
8
+ function close(modal) {
9
+ var link = modal.querySelector('.modal-x'), href = link && link.getAttribute('href');
10
+ modal.className = modal.className.replace(/\s*\bis-open\b/g, '') + ' is-closed';
11
+ if (!window.history || !history.replaceState) { return; }
12
+ if (href && href.charAt(0) !== '#') { history.replaceState(null, '', href + location.hash); }
13
+ else if (location.hash === '#' + modal.id) { history.replaceState(null, '', location.pathname + location.search); }
14
+ }
15
+
16
+ // The dialog showing: drawn open, or the one the address's #id names.
17
+ function shown() {
18
+ var target = location.hash.length > 1 && document.getElementById(location.hash.slice(1));
19
+ var open = document.querySelector('.modal.is-open');
20
+ if (open) { return open; }
21
+ return target && /(^|\s)modal(\s|$)/.test(target.className) && !/\bis-closed\b/.test(target.className) ? target : null;
22
+ }
23
+
24
+ // The node or its nearest ancestor with the class: old browsers have no closest().
25
+ function up(node, name) {
26
+ var pattern = new RegExp('(^|\\s)' + name + '(\\s|$)');
27
+ while (node && node.nodeType === 1 && !pattern.test(node.className)) { node = node.parentNode; }
28
+ return node && node.nodeType === 1 ? node : null;
29
+ }
30
+
31
+ document.addEventListener('click', function (event) {
32
+ var x = up(event.target, 'modal-x'), modal = x && up(x, 'modal');
33
+ if (!modal) { return; }
34
+ event.preventDefault();
35
+ close(modal);
36
+ });
37
+ document.addEventListener('keydown', function (event) {
38
+ if (event.key !== 'Escape' && event.key !== 'Esc' && event.keyCode !== 27) { return; }
39
+ var modal = shown();
40
+ if (modal) { event.preventDefault(); close(modal); }
41
+ });
42
+ window.addEventListener('hashchange', function () {
43
+ var target = location.hash.length > 1 && document.getElementById(location.hash.slice(1));
44
+ if (target) { target.className = target.className.replace(/\s*\bis-closed\b/g, ''); }
45
+ });
46
+ })();
@@ -171,6 +171,7 @@ ol.ad-card-list.js-live li.ad-card.superseded{display:block}
171
171
  /* modal: a dialog; tooltip: a hover or tap explanation; pin-code: the six-digit code */
172
172
  .modal{display:none;position:fixed;top:0;right:0;bottom:0;left:0;z-index:50;background:rgba(11,30,58,.55);align-items:center;justify-content:center;padding:16px}
173
173
  .modal:target,.modal.is-open{display:flex}
174
+ .modal.is-closed:not(.is-open){display:none}
174
175
  .modal-box{position:relative;width:100%;max-width:760px;max-height:100%;overflow:auto;background:var(--color-bg);color:var(--color-text);border-radius:18px;padding:28px 24px 24px;box-shadow:0 20px 50px rgba(0,0,0,.3)}
175
176
  .modal-box h2{font-size:22px;margin:0 32px 6px 0}
176
177
  .modal-box h2 > span[aria-hidden="true"]:first-child{margin-right:.35em}
@@ -0,0 +1,13 @@
1
+ <%# locals: (id:, title:, close:, open: false, emoji: nil, classes: nil) -%>
2
+ <%# A dialog over the page, rendered as a layout around what it holds (render layout: "easy/modal" do … end), which
3
+ always lets its reader out: its ×, Esc (easy/modal.js, which the page includes once), or without the script the
4
+ × as a link. Shown when its address's #id names it, or open: true (drawn already open, say once a form asked).
5
+ close: where the × leads, "#" for a dialog opened by its #id, the page without what opened it otherwise.
6
+ classes: the app's own, beside modal, to style what it holds. -%>
7
+ <%= tag.div id:, class: [ "modal", ("is-open" if open), classes ], role: "dialog", aria: { modal: true, labelledby: "#{id}-title" } do %>
8
+ <div class="modal-box">
9
+ <%= link_to "×", close, class: "modal-x", aria: { label: "Close" } %>
10
+ <h2 id="<%= id %>-title"><% if emoji %><span aria-hidden="true"><%= emoji %></span> <% end %><%= title %></h2>
11
+ <%= yield %>
12
+ </div>
13
+ <% end %>
data/lib/drive/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Drive
2
2
  # Version of the gem, read by the gemspec.
3
- VERSION = '0.16.0'.freeze
3
+ VERSION = '0.17.0'.freeze
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - claudiob
@@ -39,6 +39,7 @@ files:
39
39
  - app/assets/images/easy/sprite.svg
40
40
  - app/assets/javascripts/easy/flyer.js
41
41
  - app/assets/javascripts/easy/konami.js
42
+ - app/assets/javascripts/easy/modal.js
42
43
  - app/assets/javascripts/easy/pin_code.js
43
44
  - app/assets/javascripts/easy/rotating_placeholder.js
44
45
  - app/assets/stylesheets/easy/base.css
@@ -54,6 +55,7 @@ files:
54
55
  - app/models/serial.rb
55
56
  - app/views/drive/errors/show.html.erb
56
57
  - app/views/easy/_flyer.html.erb
58
+ - app/views/easy/_modal.html.erb
57
59
  - app/views/easy/_pin_code.html.erb
58
60
  - app/views/easy/mailer/_code.html.erb
59
61
  - app/views/easy/mailer/_code.text.erb