Skip to content

Commit 0eb0954

Browse files
committed
Remove jQuery throttle-debounce dependency
1 parent 9ffbbba commit 0eb0954

File tree

4 files changed

+11
-259
lines changed

4 files changed

+11
-259
lines changed

Vendorfile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
folder 'vendor/assets' do
2-
folder 'jquery' do
3-
file 'jquery.throttle-debounce.js', 'https://raw.githubusercontent.com/cowboy/jquery-throttle-debounce/v1.1/jquery.ba-throttle-debounce.js'
4-
end
5-
62
folder 'leaflet' do
73
from 'https://github.com/kajic/leaflet-locationfilter.git' do
84
file 'leaflet.locationfilter.css', 'src/locationfilter.css'

app/assets/javascripts/application.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//= require jquery3
22
//= require jquery_ujs
3-
//= require jquery.throttle-debounce
43
//= require js-cookie/dist/js.cookie
54
//= require popper
65
//= require bootstrap-sprockets

app/assets/javascripts/id.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
/* globals iD */
44

5+
(() => {
6+
const originalReplaceState = window.history.replaceState;
7+
window.history.replaceState = function (...args) {
8+
const result = originalReplaceState.apply(this, args);
9+
window.dispatchEvent(new CustomEvent("replaceHistoryState", { detail: args }));
10+
return result;
11+
};
12+
})();
13+
514
document.addEventListener("DOMContentLoaded", function () {
615
const container = document.getElementById("id-container");
716

@@ -35,7 +44,7 @@ document.addEventListener("DOMContentLoaded", function () {
3544
}
3645

3746
let hashChangedAutomatically = false;
38-
id.map().on("move.embed", parent.$.throttle(250, function () {
47+
window.addEventListener("replaceHistoryState", function () {
3948
if (id.inIntro()) return;
4049
const zoom = ~~id.map().zoom(),
4150
center = id.map().center(),
@@ -50,7 +59,7 @@ document.addEventListener("DOMContentLoaded", function () {
5059
hashChangedAutomatically = true;
5160
parent.location.replace(parent.location.href.replace(/(#.*|$)/, hash));
5261
}
53-
}));
62+
});
5463

5564
function goToLocation(data) {
5665
// 0ms timeout to avoid iframe JS context weirdness.

vendor/assets/jquery/jquery.throttle-debounce.js

Lines changed: 0 additions & 252 deletions
This file was deleted.

0 commit comments

Comments
 (0)