i18n_feedback 0.2.0 → 0.2.1

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: ab6f3f1bb7c4568e3491627e947cf38424ec76f0c21cff477bee95440c4df762
4
- data.tar.gz: 8440049b960f561014f0217caf61395de948a0f665dc580b39e97f07bc55dddf
3
+ metadata.gz: fb6db4ee347586bcb037eaeedb37564d969e9d1395db2a8b6ca450710d943796
4
+ data.tar.gz: 4d9aeaa1a8ece352719e3019ae08049b7ad9103dc1ce61447e317149269451d3
5
5
  SHA512:
6
- metadata.gz: b0cafcd664c77f1f39c1a2029fe3f22d3e8d3dc3753c40a3d087a31d3b11c7bedaa73d2e22ddcc4abf9106a45510dcc63f2b287874555d439f536e09f7018c6f
7
- data.tar.gz: d402186abbb1c9437feee55e52110ddb11b82332f29d7d3443524b204eaa2a30dff4691ef2edcae7a28cfc71bae80eabd0b2b62283c0224167ddaaf9c02cefe6
6
+ metadata.gz: 48c4b5ac039436c560d5e667d7ed36f1474a784b1330e8efaea55376e306eecd0865d6ddb81fa8001cc20d1c790bfdb0668b8435322f3a8f13aca95b02a5a99e
7
+ data.tar.gz: cde3e82b0c34baf896c2d54c887bf581f48c8d00e65a74fe34d11e531b5264ed85c2267d69ab94c1715bd2abf5ba9ad102c22b746ec6f6d36721a61bf4b202d4
data/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.2.1]
6
+
7
+ - Keep the suggest pill and active-mode highlighting working across Turbo Drive
8
+ navigations. Turbo replaces `<body>` on each visit, which removed the pill; the
9
+ widget now re-runs its per-page setup on `turbo:load` instead of only on the
10
+ initial load, so it no longer requires a hard reload.
11
+
5
12
  ## [0.2.0]
6
13
 
7
14
  - Stamp the injected widget scripts with the request's Content-Security-Policy
@@ -42,18 +42,27 @@
42
42
  }
43
43
 
44
44
  ready(function () {
45
- injectStyles();
46
- if (config.showPill !== false) buildPill();
45
+ // Document-level listeners survive Turbo navigations, so register them once.
47
46
  document.addEventListener("keydown", handleKeydown);
47
+ if (config.active) document.addEventListener("click", handleClick, true);
48
+
49
+ // Everything else lives in <body>, which Turbo replaces on every visit —
50
+ // taking the pill and the active-mode highlighting with it. Re-run the
51
+ // per-page setup on each visit so the widget keeps working without a hard
52
+ // reload. render() also runs now for the initial (or non-Turbo) load.
53
+ render();
54
+ document.addEventListener("turbo:load", render);
55
+ document.addEventListener("turbo:frame-load", strip);
56
+ });
48
57
 
58
+ function render() {
59
+ injectStyles();
60
+ if (config.showPill !== false) buildPill();
49
61
  if (config.active) {
50
62
  document.documentElement.classList.add("i18nf-active");
51
- document.addEventListener("click", handleClick, true);
52
- document.addEventListener("turbo:load", strip);
53
- document.addEventListener("turbo:frame-load", strip);
54
63
  strip();
55
64
  }
56
- });
65
+ }
57
66
 
58
67
  // --- suggest-mode toggle --------------------------------------------------
59
68
 
@@ -123,6 +132,9 @@
123
132
  // --- pill -----------------------------------------------------------------
124
133
 
125
134
  function buildPill() {
135
+ var existing = document.querySelector(".i18nf-pill");
136
+ if (existing) existing.remove();
137
+
126
138
  var pill = document.createElement("button");
127
139
  pill.type = "button";
128
140
  pill.className = "i18nf-pill" + (config.active ? " i18nf-pill-on" : "");
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module I18nFeedback
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n_feedback
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yaroslav Shmarov
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
78
  requirements: []
79
- rubygems_version: 4.0.10
79
+ rubygems_version: 4.0.6
80
80
  specification_version: 4
81
81
  summary: 'In-context i18n proofreading for Rails: click any translated string and
82
82
  suggest a fix.'