Remove jQuery dependency

- Resolves #39
This commit is contained in:
Jonathan Abbett 2021-04-15 15:34:23 -04:00
parent eff726c6f4
commit 053093e660
3 changed files with 8 additions and 12 deletions

View File

@ -1,8 +1,7 @@
//= require jquery
//= require js-cookie/src/js.cookie //= require js-cookie/src/js.cookie
//= require shepherd.js/dist/js/shepherd //= require shepherd.js/dist/js/shepherd
$(document).on('turbolinks:before-cache', function() { document.addEventListener('turbolinks:before-cache', function() {
// Remove visible product tours // Remove visible product tours
$(".shepherd-step").remove(); document.querySelectorAll(".shepherd-element").forEach(function(el) { el.remove() });
}); });

View File

@ -2,13 +2,11 @@
var tour = new Shepherd.Tour(<%= Rails.configuration.abraham.tour_options.html_safe unless Rails.configuration.abraham.tour_options.nil? %>); var tour = new Shepherd.Tour(<%= Rails.configuration.abraham.tour_options.html_safe unless Rails.configuration.abraham.tour_options.nil? %>);
tour.on("complete", function() { tour.on("complete", function() {
// ajax // Make AJAX call to save history of tour completion
return $.ajax({ return fetch("/abraham_histories/", {
url: "/abraham_histories/", method: "POST",
type: "POST", headers: { 'Content-Type': 'application/json' },
dataType: "json", body: JSON.stringify({
contentType: "application/json",
data: JSON.stringify({
authenticity_token: '<%= form_authenticity_token %>', authenticity_token: '<%= form_authenticity_token %>',
controller_name: '<%= controller_name %>', controller_name: '<%= controller_name %>',
action_name: '<%= action_name %>', action_name: '<%= action_name %>',

View File

@ -2,7 +2,6 @@
"name": "abraham", "name": "abraham",
"private": true, "private": true,
"dependencies": { "dependencies": {
"jquery": "^3.4.0",
"js-cookie": "^2.2.0", "js-cookie": "^2.2.0",
"shepherd.js": "^6.0.0-beta" "shepherd.js": "^6.0.0-beta"
} }