testimonials 0.7.4 → 0.7.6

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.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +26 -0
  3. data/README.md +26 -6
  4. data/app/controllers/testimonials/collection_controller.rb +20 -6
  5. data/app/views/layouts/testimonials/application.html.erb +2 -7
  6. data/app/views/layouts/testimonials/collection.html.erb +2 -1
  7. data/app/views/testimonials/collection/nps.html.erb +14 -0
  8. data/app/views/testimonials/nps_responses/index.html.erb +12 -1
  9. data/app/views/testimonials/testimonials/_testimonial_panel.html.erb +15 -15
  10. data/app/views/testimonials/testimonials/index.html.erb +11 -1
  11. data/config/locales/testimonials.ar.yml +5 -2
  12. data/config/locales/testimonials.bg.yml +5 -2
  13. data/config/locales/testimonials.bn.yml +5 -2
  14. data/config/locales/testimonials.de.yml +5 -2
  15. data/config/locales/testimonials.el.yml +5 -2
  16. data/config/locales/testimonials.en.yml +5 -2
  17. data/config/locales/testimonials.es.yml +5 -2
  18. data/config/locales/testimonials.fr.yml +5 -2
  19. data/config/locales/testimonials.hi.yml +5 -2
  20. data/config/locales/testimonials.hr.yml +5 -2
  21. data/config/locales/testimonials.id.yml +5 -2
  22. data/config/locales/testimonials.it.yml +5 -2
  23. data/config/locales/testimonials.ja.yml +5 -2
  24. data/config/locales/testimonials.ko.yml +5 -2
  25. data/config/locales/testimonials.lb.yml +5 -2
  26. data/config/locales/testimonials.nl.yml +5 -2
  27. data/config/locales/testimonials.pl.yml +5 -2
  28. data/config/locales/testimonials.pt.yml +5 -2
  29. data/config/locales/testimonials.ro.yml +5 -2
  30. data/config/locales/testimonials.ru.yml +5 -2
  31. data/config/locales/testimonials.th.yml +5 -2
  32. data/config/locales/testimonials.tr.yml +5 -2
  33. data/config/locales/testimonials.uk.yml +5 -2
  34. data/config/locales/testimonials.ur.yml +5 -2
  35. data/config/locales/testimonials.vi.yml +5 -2
  36. data/config/locales/testimonials.zh-CN.yml +5 -2
  37. data/config/routes.rb +1 -0
  38. data/lib/generators/testimonials/install/install_generator.rb +1 -0
  39. data/lib/tasks/testimonials_tasks.rake +11 -0
  40. data/lib/testimonials/dashboard.css +6 -2
  41. data/lib/testimonials/demo/README.md +7 -0
  42. data/lib/testimonials/demo/flower.mp4 +0 -0
  43. data/lib/testimonials/engine.rb +4 -0
  44. data/lib/testimonials/seeds.rb +164 -0
  45. data/lib/testimonials/version.rb +1 -1
  46. data/lib/testimonials/widget.js +28 -9
  47. data/lib/testimonials.rb +1 -0
  48. metadata +6 -1
@@ -16,8 +16,9 @@
16
16
  * form right after. Auto-opens report shown/dismissed to the throttle
17
17
  * ledger; explicit opens don't.
18
18
  *
19
- * On the public collection page the same code renders the form inline into
20
- * <div data-testimonials-inline> (config.mode === "page").
19
+ * On the public standalone pages the same code renders inline into
20
+ * <div data-testimonials-inline>: the testimonial form (config.mode ===
21
+ * "page") or the NPS card (config.mode === "nps_page").
21
22
  */
22
23
  (function () {
23
24
  "use strict";
@@ -73,7 +74,7 @@
73
74
  // lock lives on documentElement, which survives the swap, so release it.
74
75
  if (!document.getElementById("tml-overlay")) unlockScroll();
75
76
 
76
- if (config.mode === "page") {
77
+ if (pageMode()) {
77
78
  renderInline();
78
79
  return;
79
80
  }
@@ -274,7 +275,13 @@
274
275
  }
275
276
  }
276
277
 
277
- // --- inline (public collection page) ----------------------------------------
278
+ // --- inline (the standalone public pages) -----------------------------------
279
+
280
+ // A page IS the prompt: the visitor followed a link here, so there is no
281
+ // overlay and nothing to dismiss — "Not now", Cancel and the × are omitted.
282
+ function pageMode() {
283
+ return config.mode === "page" || config.mode === "nps_page";
284
+ }
278
285
 
279
286
  function renderInline() {
280
287
  var host = document.querySelector("[data-testimonials-inline]");
@@ -283,7 +290,14 @@
283
290
  card.className = "tml-inline";
284
291
  if (config.rtl) card.setAttribute("dir", "rtl");
285
292
  host.appendChild(card);
286
- state = { kind: "testimonial", auto: false, rating: 0, submitted: false, videoBlob: null, source: "page" };
293
+
294
+ var nps = config.mode === "nps_page" && config.nps.enabled;
295
+ state = { kind: nps ? "nps" : "testimonial", auto: false, rating: 0,
296
+ submitted: false, videoBlob: null, source: "page" };
297
+ if (nps) {
298
+ card.appendChild(npsStage());
299
+ return;
300
+ }
287
301
  if (config.existing) prefillExisting();
288
302
  card.appendChild(formStage(config.existing ? config.labels.updateTitle : config.labels.shareTitle));
289
303
  }
@@ -388,7 +402,7 @@
388
402
  form.appendChild(error);
389
403
 
390
404
  var actions = el("div", "tml-actions");
391
- actions.appendChild(secondaryButton(config.labels.cancel, close));
405
+ if (overlay) actions.appendChild(secondaryButton(config.labels.cancel, close));
392
406
  var submit = el("button", "tml-primary", config.labels.submit);
393
407
  submit.type = "submit";
394
408
  actions.appendChild(submit);
@@ -417,7 +431,7 @@
417
431
  title.autocomplete = "organization-title";
418
432
  form.appendChild(field(config.labels.titleCompany + " (" + config.labels.optional + ")", title));
419
433
 
420
- if (config.mode === "page" && config.avatars.enabled) {
434
+ if (pageMode() && config.avatars.enabled) {
421
435
  var avatar = document.createElement("input");
422
436
  avatar.type = "file";
423
437
  avatar.name = "avatar";
@@ -873,7 +887,7 @@
873
887
  legend.appendChild(el("span", null, config.labels.npsHigh));
874
888
  stage.appendChild(legend);
875
889
 
876
- stage.appendChild(notNowButton());
890
+ if (overlay) stage.appendChild(notNowButton());
877
891
  return stage;
878
892
  }
879
893
 
@@ -920,7 +934,12 @@
920
934
  form.appendChild(error);
921
935
 
922
936
  var actions = el("div", "tml-actions");
923
- actions.appendChild(secondaryButton(config.labels.cancel, close));
937
+ // In the widget, Cancel closes. On the page there is nothing to close, so
938
+ // it discards this score and goes back to the scale — a mis-tapped number
939
+ // must not be a dead end.
940
+ actions.appendChild(secondaryButton(config.labels.cancel, overlay ? close : function () {
941
+ showStage(npsStage());
942
+ }));
924
943
  var submit = el("button", "tml-primary", config.labels.submit);
925
944
  submit.type = "submit";
926
945
  actions.appendChild(submit);
data/lib/testimonials.rb CHANGED
@@ -5,6 +5,7 @@ require 'testimonials/configuration'
5
5
  require 'testimonials/widget'
6
6
  require 'testimonials/prompt_helper'
7
7
  require 'testimonials/has_testimonials'
8
+ require 'testimonials/seeds'
8
9
  require 'testimonials/engine'
9
10
 
10
11
  # Testimonials, reviews and NPS for Rails. An iOS-style in-app widget collects
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testimonials
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
4
+ version: 0.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yaroslav Shmarov
@@ -60,6 +60,7 @@ files:
60
60
  - app/models/testimonials/testimonial.rb
61
61
  - app/views/layouts/testimonials/application.html.erb
62
62
  - app/views/layouts/testimonials/collection.html.erb
63
+ - app/views/testimonials/collection/nps.html.erb
63
64
  - app/views/testimonials/collection/show.html.erb
64
65
  - app/views/testimonials/nps_responses/_response_panel.html.erb
65
66
  - app/views/testimonials/nps_responses/index.html.erb
@@ -99,13 +100,17 @@ files:
99
100
  - lib/generators/testimonials/install/templates/initializer.rb
100
101
  - lib/generators/testimonials/tenant/templates/add_tenant_to_testimonials.rb.tt
101
102
  - lib/generators/testimonials/tenant/tenant_generator.rb
103
+ - lib/tasks/testimonials_tasks.rake
102
104
  - lib/testimonials.rb
103
105
  - lib/testimonials/configuration.rb
104
106
  - lib/testimonials/dashboard.css
105
107
  - lib/testimonials/dashboard.js
108
+ - lib/testimonials/demo/README.md
109
+ - lib/testimonials/demo/flower.mp4
106
110
  - lib/testimonials/engine.rb
107
111
  - lib/testimonials/has_testimonials.rb
108
112
  - lib/testimonials/prompt_helper.rb
113
+ - lib/testimonials/seeds.rb
109
114
  - lib/testimonials/version.rb
110
115
  - lib/testimonials/widget.js
111
116
  - lib/testimonials/widget.rb