Skip to content

Commit cb09974

Browse files
committed
rails-ujs is deprecated so stop depending on it
1 parent 11c9336 commit cb09974

File tree

7 files changed

+72
-74
lines changed

7 files changed

+72
-74
lines changed

app/assets/javascripts/spotlight/spotlight.esm.js

Lines changed: 32 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/assets/javascripts/spotlight/spotlight.esm.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/assets/javascripts/spotlight/spotlight.js

Lines changed: 32 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/assets/javascripts/spotlight/spotlight.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/javascript/spotlight/admin/crop.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { addImageSelector } from 'add_image_selector'
2+
import Spotlight from 'spotlight'
23

34
export default class Crop {
45
constructor(cropArea) {
@@ -253,8 +254,6 @@ export default class Crop {
253254
}
254255

255256
uploadFile() {
256-
// Set a ujs adapter to support both rails-ujs and jquery-ujs
257-
var ujs = typeof Rails === 'undefined' ? $.rails : Rails;
258257
var url = this.fileInput.data('endpoint')
259258
// Every post creates a new image/masthead.
260259
// Because they create IIIF urls which are heavily cached.
@@ -266,7 +265,7 @@ export default class Crop {
266265
// Form data
267266
data: this.getData(),
268267
headers: {
269-
'X-CSRF-Token': ujs.csrfToken() || ''
268+
'X-CSRF-Token': Spotlight.csrfToken() || ''
270269
},
271270
//Options to tell jQuery not to process data or worry about content-type.
272271
cache: false,

app/javascript/spotlight/admin/pages.es6

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@ import Spotlight from 'spotlight'
44

55
export default class {
66
connect(){
7-
// Set a ujs adapter to support both rails-ujs and jquery-ujs
8-
var ujs = typeof Rails === 'undefined' ? $.rails : Rails;
97
SirTrevor.setDefaults({
108
iconUrl: Spotlight.sirTrevorIcon,
119
uploadUrl: $('[data-attachment-endpoint]').data('attachment-endpoint'),
1210
ajaxOptions: {
1311
headers: {
14-
'X-CSRF-Token': ujs.csrfToken() || ''
12+
'X-CSRF-Token': Spotlight.csrfToken() || ''
1513
},
1614
credentials: 'same-origin'
1715
}

app/javascript/spotlight/spotlight.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ const Spotlight = function() {
1010
buffer[i].call();
1111
}
1212
},
13+
csrfToken: function () {
14+
return document.querySelector('meta[name=csrf-token]')?.content
15+
},
1316
ZprLinks: {
1417
close: "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24\" viewBox=\"0 0 24 24\" width=\"24\"><path d=\"M0 0h24v24H0V0z\" fill=\"none\"/><path d=\"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z\"/></svg>",
1518
zoomIn: "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24\" viewBox=\"0 0 24 24\" width=\"24\"><path d=\"M0 0h24v24H0V0z\" fill=\"none\"/><path d=\"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zm.5-7H9v2H7v1h2v2h1v-2h2V9h-2z\"/></svg>\n",

0 commit comments

Comments
 (0)