Skip to content
Snippets Groups Projects
Commit 1a8be897 authored by Anton Sarukhanov's avatar Anton Sarukhanov
Browse files

js cleanup

parent 8992e991
No related branches found
No related tags found
1 merge request!1Implemented Embed-code generator interface
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
], ],
"dependencies": { "dependencies": {
"leaflet": "~0.7.7", "leaflet": "~0.7.7",
"jquery": "~2.1.4", "jquery": "~2.2.3",
"leaflet.markercluster": "~0.4.0", "leaflet.markercluster": "~0.4.0",
"leaflet-marker-rotate": "https://git.xhost.io/anton/leaflet-marker-rotate.git", "leaflet-marker-rotate": "https://git.xhost.io/anton/leaflet-marker-rotate.git",
"Leaflet.label": "~0.2.1" "Leaflet.label": "~0.2.1"
......
...@@ -47,28 +47,28 @@ BusMap.Embed = function(opts) { ...@@ -47,28 +47,28 @@ BusMap.Embed = function(opts) {
var bindEventHandlers = function() { var bindEventHandlers = function() {
// OnChange event handlers for Embed Options form // OnChange event handlers for Embed Options form
$("#embed-height").change(function() { $("#embed-height").on('change', function() {
if ($(this).val() != "") { if ($(this).val() != "") {
$("#embed-preview iframe").attr('height', $(this).val() + "px"); $("#embed-preview iframe").attr('height', $(this).val() + "px");
} else { } else {
$("#embed-preview iframe").removeAttr('height'); $("#embed-preview iframe").removeAttr('height');
} }
}); });
$("#embed-width").change(function() { $("#embed-width").on('change', function() {
if ($(this).val() != "") { if ($(this).val() != "") {
$("#embed-preview iframe").attr('width', $(this).val() + "px"); $("#embed-preview iframe").attr('width', $(this).val() + "px");
} else { } else {
$("#embed-preview iframe").removeAttr('width'); $("#embed-preview iframe").removeAttr('width');
} }
}); });
$("#embed-responsive").change(function() { $("#embed-responsive").on('change', function() {
if ($(this).prop("checked")) { if ($(this).prop("checked")) {
$("#embed-preview iframe").css('max-width', '100%'); $("#embed-preview iframe").css('max-width', '100%');
} else { } else {
$("#embed-preview iframe").css('max-width', ''); $("#embed-preview iframe").css('max-width', '');
} }
}); });
$("#embed-mode").change(function() { $("#embed-mode").on('change', function() {
embedVars['mode'] = $(this).val(); embedVars['mode'] = $(this).val();
updateEmbedUrl(); updateEmbedUrl();
if ($(this).val() == "m") { if ($(this).val() == "m") {
...@@ -77,7 +77,7 @@ BusMap.Embed = function(opts) { ...@@ -77,7 +77,7 @@ BusMap.Embed = function(opts) {
$("label[for=embed-popup]").hide(); $("label[for=embed-popup]").hide();
} }
}); });
$("#embed-stop").change(function() { $("#embed-stop").on('change', function() {
if ($(this).val()) { if ($(this).val()) {
embedVars['stop'] = $(this).val(); embedVars['stop'] = $(this).val();
} else { } else {
...@@ -85,7 +85,7 @@ BusMap.Embed = function(opts) { ...@@ -85,7 +85,7 @@ BusMap.Embed = function(opts) {
} }
updateEmbedUrl(); updateEmbedUrl();
}); });
$("#embed-popup").change(function() { $("#embed-popup").on('change', function() {
if ($(this).prop("checked")) { if ($(this).prop("checked")) {
embedVars['popup'] = true; embedVars['popup'] = true;
} else { } else {
...@@ -94,7 +94,7 @@ BusMap.Embed = function(opts) { ...@@ -94,7 +94,7 @@ BusMap.Embed = function(opts) {
updateEmbedUrl(); updateEmbedUrl();
}); });
// After ANY field is updated... // After ANY field is updated...
$("#embed-form :input").change(function() { $("#embed-form :input").on('change', function() {
updateEmbedCode(); updateEmbedCode();
}); });
// Hilight code for easy copying on click, key, focus. // Hilight code for easy copying on click, key, focus.
......
...@@ -454,8 +454,15 @@ BusMap.Map = function(opts) { ...@@ -454,8 +454,15 @@ BusMap.Map = function(opts) {
var modalName = $(".modal").attr('id').split('-')[1]; var modalName = $(".modal").attr('id').split('-')[1];
view += ";" + modalName; view += ";" + modalName;
} }
if (window.location.hash == "#" + view) {
// Bail out if old hash == new hash.
// Otherwise, we'll set hashChangedProgrammatically, but
// the change handler will never fire, and it won't be unset.
// TODO: unfuck this bad design before it breaks something else
return;
}
that.hashChangedProgrammatically = true; // avoid infinite loop! that.hashChangedProgrammatically = true; // avoid infinite loop!
window.location.replace("#" + view); window.location.href.replace(window.location.hash, "#" + view);
} }
init(); init();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment